diff options
Diffstat (limited to 'cpp/src/Slice/Parser.cpp')
-rw-r--r-- | cpp/src/Slice/Parser.cpp | 52 |
1 files changed, 36 insertions, 16 deletions
diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp index 45ae1635d78..02e9a1d113b 100644 --- a/cpp/src/Slice/Parser.cpp +++ b/cpp/src/Slice/Parser.cpp @@ -695,7 +695,7 @@ Slice::Container::createClassDecl(const string& name, bool intf, bool local) } ExceptionPtr -Slice::Container::createException(const string& name, const ExceptionPtr& base, bool local) +Slice::Container::createException(const string& name, const ExceptionPtr& base, bool local, NodeType nt) { checkPrefix(name); @@ -727,7 +727,10 @@ Slice::Container::createException(const string& name, const ExceptionPtr& base, nameIsLegal(name, "exception"); // Don't return here -- we create the exception anyway - checkForGlobalDef(name, "exception"); // Don't return here -- we create the exception anyway + if(nt == Real) + { + checkForGlobalDef(name, "exception"); // Don't return here -- we create the exception anyway + } // // If this definition is non-local, base cannot be local. @@ -743,7 +746,7 @@ Slice::Container::createException(const string& name, const ExceptionPtr& base, } StructPtr -Slice::Container::createStruct(const string& name, bool local) +Slice::Container::createStruct(const string& name, bool local, NodeType nt) { checkPrefix(name); @@ -775,7 +778,10 @@ Slice::Container::createStruct(const string& name, bool local) nameIsLegal(name, "structure"); // Don't return here -- we create the struct anyway. - checkForGlobalDef(name, "structure"); // Don't return here -- we create the struct anyway. + if(nt == Real) + { + checkForGlobalDef(name, "structure"); // Don't return here -- we create the struct anyway. + } StructPtr p = new Struct(this, name, local); _contents.push_back(p); @@ -783,7 +789,8 @@ Slice::Container::createStruct(const string& name, bool local) } SequencePtr -Slice::Container::createSequence(const string& name, const TypePtr& type, const StringList& metaData, bool local) +Slice::Container::createSequence(const string& name, const TypePtr& type, const StringList& metaData, bool local, + NodeType nt) { checkPrefix(name); @@ -826,7 +833,10 @@ Slice::Container::createSequence(const string& name, const TypePtr& type, const nameIsLegal(name, "sequence"); // Don't return here -- we create the sequence anyway. - checkForGlobalDef(name, "sequence"); // Don't return here -- we create the sequence anyway. + if(nt == Real) + { + checkForGlobalDef(name, "sequence"); // Don't return here -- we create the sequence anyway. + } // // If sequence is non-local, element type cannot be local. @@ -844,7 +854,8 @@ Slice::Container::createSequence(const string& name, const TypePtr& type, const DictionaryPtr Slice::Container::createDictionary(const string& name, const TypePtr& keyType, const StringList& keyMetaData, - const TypePtr& valueType, const StringList& valueMetaData, bool local) + const TypePtr& valueType, const StringList& valueMetaData, bool local, + NodeType nt) { checkPrefix(name); @@ -887,9 +898,12 @@ Slice::Container::createDictionary(const string& name, const TypePtr& keyType, c nameIsLegal(name, "dictionary"); // Don't return here -- we create the dictionary anyway. - checkForGlobalDef(name, "dictionary"); // Don't return here -- we create the dictionary anyway. + if(nt == Real) + { + checkForGlobalDef(name, "dictionary"); // Don't return here -- we create the dictionary anyway. + } - if(!Dictionary::legalKeyType(keyType)) + if(nt == Real && !Dictionary::legalKeyType(keyType)) { _unit->error("dictionary `" + name + "' uses an illegal key type"); return 0; @@ -915,7 +929,7 @@ Slice::Container::createDictionary(const string& name, const TypePtr& keyType, c } EnumPtr -Slice::Container::createEnum(const string& name, bool local) +Slice::Container::createEnum(const string& name, bool local, NodeType nt) { checkPrefix(name); @@ -947,7 +961,10 @@ Slice::Container::createEnum(const string& name, bool local) nameIsLegal(name, "enumeration"); // Don't return here -- we create the enumeration anyway. - checkForGlobalDef(name, "enumeration"); // Don't return here -- we create the enumeration anyway. + if(nt == Real) + { + checkForGlobalDef(name, "enumeration"); // Don't return here -- we create the enumeration anyway. + } EnumPtr p = new Enum(this, name, local); _contents.push_back(p); @@ -994,7 +1011,7 @@ Slice::Container::createEnumerator(const string& name) ConstPtr Slice::Container::createConst(const string name, const TypePtr& constType, const StringList& metaData, - const SyntaxTreeBasePtr& literalType, const string& value) + const SyntaxTreeBasePtr& literalType, const string& value, NodeType nt) { checkPrefix(name); @@ -1026,12 +1043,15 @@ Slice::Container::createConst(const string name, const TypePtr& constType, const nameIsLegal(name, "constant"); // Don't return here -- we create the constant anyway. - checkForGlobalDef(name, "constant"); // Don't return here -- we create the constant anyway. + if(nt == Real) + { + checkForGlobalDef(name, "constant"); // Don't return here -- we create the constant anyway. + } // // Check that the constant type is legal. // - if(!Const::isLegalType(name, constType, _unit)) + if(nt == Real && !Const::isLegalType(name, constType, _unit)) { return 0; } @@ -1039,7 +1059,7 @@ Slice::Container::createConst(const string name, const TypePtr& constType, const // // Check that the type of the constant is compatible with the type of the initializer. // - if(!Const::typesAreCompatible(name, constType, literalType, value, _unit)) + if(nt == Real && !Const::typesAreCompatible(name, constType, literalType, value, _unit)) { return 0; } @@ -1047,7 +1067,7 @@ Slice::Container::createConst(const string name, const TypePtr& constType, const // // Check that the initializer is in range. // - if(!Const::isInRange(name, constType, value, _unit)) + if(nt == Real && !Const::isInRange(name, constType, value, _unit)) { return 0; } |