TSClass* RegisterEnum(TClassRegistryParams& params, const char* source) { auto syntax = params.syntax; TClass* cl = new TClass(syntax->base_class.get()); syntax->base_class->AddNested(cl); syntax->lexer.ParseSource(source); cl->AnalyzeSyntax(syntax->lexer); syntax->lexer.GetToken(TTokenType::Done); TSClass* scl = new TSClass(syntax->sem_base_class.get(), cl); syntax->sem_base_class->AddClass(scl); scl->Build(); std::vector<TSClassField*> static_fields; std::vector<TSLocalVar*> static_variables; TGlobalBuildContext global_build_context(&static_fields, &static_variables); scl->LinkSignature(global_build_context); scl->InitAutoMethods(); scl->LinkBody(global_build_context); scl->CheckForErrors(); std::vector<TSClass*> owners; scl->CalculateSizes(owners); scl->CalculateMethodsSizes(); owners.clear(); syntax->sem_base_class->CalculateSizes(owners);//т.к. в этом классе могут использоваться другие шаблонные класса, реализацию которых нужно обновить InitializeStaticClassFields(static_fields, *params.static_objects); InitializeStaticVariables(static_variables, *params.static_objects); return scl; }
void DeclareExternClass(TClassRegistryParams& params, TClassBinding* binding) { std::string source = BuildExternClassSource(binding->class_name, binding->methods); auto& syntax = params.syntax; TClass* cl = new TClass(syntax->base_class.get()); syntax->base_class->AddNested(cl); syntax->lexer.ParseSource(source.c_str()); cl->AnalyzeSyntax(syntax->lexer); syntax->lexer.GetToken(TTokenType::Done); binding->compiled = new TSClass(syntax->sem_base_class.get(), cl); syntax->sem_base_class->AddClass(binding->compiled); binding->compiled->Build(); binding->compiled->SetSize(LexerIntSizeOf(binding->size) / sizeof(int)); //binding->compiled->SetAutoMethodsInitialized(); }