summaryrefslogtreecommitdiff
path: root/cpp/src/Slice/Parser.cpp
diff options
context:
space:
mode:
authorMarc Laukien <marc@zeroc.com>2003-03-25 14:55:29 +0000
committerMarc Laukien <marc@zeroc.com>2003-03-25 14:55:29 +0000
commit3a55694282aaa787b276b0c68e1c0445449c2c7f (patch)
treeafa6f91f28f9b576212aa528df84f11b28e36643 /cpp/src/Slice/Parser.cpp
parentfile ServerTest.ice was initially added on branch slicing. (diff)
downloadice-3a55694282aaa787b276b0c68e1c0445449c2c7f.tar.bz2
ice-3a55694282aaa787b276b0c68e1c0445449c2c7f.tar.xz
ice-3a55694282aaa787b276b0c68e1c0445449c2c7f.zip
dict fix
Diffstat (limited to 'cpp/src/Slice/Parser.cpp')
-rw-r--r--cpp/src/Slice/Parser.cpp78
1 files changed, 34 insertions, 44 deletions
diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp
index 7853bab5e56..aa48414bbec 100644
--- a/cpp/src/Slice/Parser.cpp
+++ b/cpp/src/Slice/Parser.cpp
@@ -2732,54 +2732,13 @@ Slice::Dictionary::recDependencies(set<ConstructedPtr>& dependencies)
}
//
-// Check that the key type of a dictionary is legal. Legal types are integral types, string, and sequences and
-// structs containing only integral types or strings.
+// Check that the key type of a dictionary is legal. Legal types are
+// integral types, string, and sequences and structs containing only
+// other legal key types.
//
bool
Slice::Dictionary::legalKeyType(const TypePtr& type)
{
- if(legalSimpleKeyType(type))
- {
- return true;
- }
-
- SequencePtr seqp = SequencePtr::dynamicCast(type);
- if(seqp && legalSimpleKeyType(seqp->type()))
- {
- return true;
- }
-
- StructPtr strp = StructPtr::dynamicCast(type);
- if(strp)
- {
- DataMemberList dml = strp->dataMembers();
- for(DataMemberList::const_iterator mem = dml.begin(); mem != dml.end(); ++mem)
- {
- if(!legalSimpleKeyType((*mem)->type()))
- {
- return false;
- }
- }
- return true;
- }
-
- return false;
-}
-
-Slice::Dictionary::Dictionary(const ContainerPtr& container, const string& name, const TypePtr& keyType,
- const TypePtr& valueType, bool local) :
- Constructed(container, name, local),
- Type(container->unit()),
- Contained(container, name),
- SyntaxTreeBase(container->unit()),
- _keyType(keyType),
- _valueType(valueType)
-{
-}
-
-bool
-Slice::Dictionary::legalSimpleKeyType(const TypePtr& type)
-{
BuiltinPtr bp = BuiltinPtr::dynamicCast(type);
if(bp)
{
@@ -2814,9 +2773,40 @@ Slice::Dictionary::legalSimpleKeyType(const TypePtr& type)
return true;
}
+ SequencePtr seqp = SequencePtr::dynamicCast(type);
+ if(seqp && legalKeyType(seqp->type()))
+ {
+ return true;
+ }
+
+ StructPtr strp = StructPtr::dynamicCast(type);
+ if(strp)
+ {
+ DataMemberList dml = strp->dataMembers();
+ for(DataMemberList::const_iterator mem = dml.begin(); mem != dml.end(); ++mem)
+ {
+ if(!legalKeyType((*mem)->type()))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
return false;
}
+Slice::Dictionary::Dictionary(const ContainerPtr& container, const string& name, const TypePtr& keyType,
+ const TypePtr& valueType, bool local) :
+ Constructed(container, name, local),
+ Type(container->unit()),
+ Contained(container, name),
+ SyntaxTreeBase(container->unit()),
+ _keyType(keyType),
+ _valueType(valueType)
+{
+}
+
// ----------------------------------------------------------------------
// Enum
// ----------------------------------------------------------------------