bool CPPAbstractSyntaxTree::IsUnknownIdentifier(const std::string& id) { CPPFunctionDeclarationStatement* tempFuncDecl; CPPVariableDeclarationStatement* tempVarDecl; CPPType localTempType; return (!FindFuncDeclByID(id, tempFuncDecl) && !FindVarDeclByID(id, tempVarDecl) && !FindTypeByID(id, localTempType)); }
void CPPAbstractSyntaxTree::FuncParamDeclBranch() { CPPType localTempType; if (FindTypeByID(m_TokenWords[m_WordIndex].word, localTempType)) { INC_WORD_INDEX; if (IsUnknownIdentifier(m_TokenWords[m_WordIndex].word)) { m_TempFuncParamsDecls.push_back(new CPPVariableDeclarationStatement(localTempType, m_TokenWords[m_WordIndex].word)); } } }
void CPPAbstractSyntaxTree::DeclBranch() { CPPType type; if (FindTypeByID(m_TokenWords[m_WordIndex].word, type)) { m_TempType = type; INC_WORD_INDEX; if (IsUnknownIdentifier(m_TokenWords[m_WordIndex].word)) { m_TempID = m_TokenWords[m_WordIndex].word; INC_WORD_INDEX; FuncDeclBranch(); VarDeclBranch(); } } }
void VETypeList::PrepareTypeEntry( VETypeEntry* inNewTypeEntry, VETypeEntry*& inDataModelParent, VETypeEntry*& inRuntimeParent, VETypeEntry*& inPreviousEntry) { // Validate pointers. ValidateThis_(); ValidateObject_(inNewTypeEntry); // Make sure the class ID is valid. if (inNewTypeEntry->GetClassID() == 0) Throw_(err_CantMakeTypeSpec); // See if this class already exists. Can't replace built-in or locked types. inPreviousEntry = FindTypeByID(inNewTypeEntry->GetClassID()); if (inPreviousEntry != nil) { ValidateObject_(inPreviousEntry); if (inPreviousEntry->IsBuiltIn()) Throw_(err_CantMakeTypeSpec); } // See if we can find parent class. There are two parent classes for each // class, a runtime parent (i.e. the class hierarchy that exists at runtime) // and a data model parent. The data model parent is usually the same as // the runtime parent, but may be different if there is a need for a // different property inspector window. ClassIDT dataModelParentID = inNewTypeEntry->GetParentClassID(); ClassIDT runtimeParentID = dataModelParentID; FixRuntimeParent(inNewTypeEntry->GetClassID(), runtimeParentID); inDataModelParent = nil; inRuntimeParent = nil; if ((dataModelParentID != 0) && (dataModelParentID != 0x3f3f3f3f)) { inDataModelParent = FindTypeByID(dataModelParentID); if (inDataModelParent == nil) Throw_(err_CantMakeTypeSpec); inDataModelParent->AddListener(inNewTypeEntry); } if ((runtimeParentID != 0) && (runtimeParentID != 0x3f3f3f3f)) { inRuntimeParent = FindTypeByID(runtimeParentID); if (inRuntimeParent == nil) Throw_(err_CantMakeTypeSpec); inRuntimeParent->AddListener(inNewTypeEntry); } inNewTypeEntry->mDataSuperClass = inDataModelParent; inNewTypeEntry->mRuntimeSuperClass = inRuntimeParent; // Create a prototype for this object. VEModelObjectPtr prototype; prototype = MakeModelObjectForClass(inNewTypeEntry->GetClassID()); // Copy attributes from parent class. if (inDataModelParent != nil) { // If there is no class-specific prototype for this class, // we can borrow the parent class' prototype. if (prototype == nil) prototype = (dynamic_cast<VEModelObject*>(inDataModelParent->mPrototype->ShallowClone())); // Copy attributes over. Since the attribute values don't change from parent // class to subclass, we can share the attribute objects between them. VEModelObject* parentProto = inDataModelParent->mPrototype; ValidateObject_(parentProto); DMFastIterator parentIter(parentProto->GetAttributes()); while (parentIter.NextElement()) { DMElement* parentAttr = parentIter.CurrentElement(); ValidateObject_(parentAttr); // DMElementPtr cloneAttr = parentAttr->Clone(); // ValidateObject_(cloneAttr.GetObject()); prototype->InsertElementAt(LArray::index_Last, parentAttr /* cloneAttr */, true); } } // If there's still no prototype, this type entry will be bogus. if (prototype == nil) Throw_(err_CantMakeTypeSpec); ValidateObject_(prototype.GetObject()); // Set basic information for class. inNewTypeEntry->mPrototype = prototype; inNewTypeEntry->mIsBuiltIn = mTypesAreBuiltIn; if (inRuntimeParent != nil) { ValidateObject_(inRuntimeParent); if (inRuntimeParent->mMustBeRoot) inNewTypeEntry->mMustBeRoot = true; } }