本文整理汇总了C++中Struct::codegen方法的典型用法代码示例。如果您正苦于以下问题:C++ Struct::codegen方法的具体用法?C++ Struct::codegen怎么用?C++ Struct::codegen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Struct
的用法示例。
在下文中一共展示了Struct::codegen方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: codegenTopLevel
// N-pass system.
// there's no point counting at this stage.
static void codegenTopLevel(CodegenInstance* cgi, int pass, std::deque<Expr*> expressions, bool isInsideNamespace)
{
if(pass == 0)
{
// add all the types for order-independence -- if we encounter a need, we can
// force codegen.
for(Expr* e : expressions)
{
NamespaceDecl* ns = dynamic_cast<NamespaceDecl*>(e);
TypeAlias* ta = dynamic_cast<TypeAlias*>(e);
Struct* str = dynamic_cast<Struct*>(e);
Class* cls = dynamic_cast<Class*>(e); // enum : class, extension : class
Func* fn = dynamic_cast<Func*>(e);
ForeignFuncDecl* ffi = dynamic_cast<ForeignFuncDecl*>(e);
OpOverload* oo = dynamic_cast<OpOverload*>(e);
if(ns) ns->codegenPass(cgi, pass);
else if(ta) addTypeToFuncTree(cgi, ta, ta->name, TypeKind::TypeAlias);
else if(str) addTypeToFuncTree(cgi, str, str->name, TypeKind::Struct);
else if(cls) addTypeToFuncTree(cgi, cls, cls->name, TypeKind::Class);
else if(fn) addFuncDeclToFuncTree(cgi, fn->decl);
else if(ffi) addFuncDeclToFuncTree(cgi, ffi->decl);
else if(oo) addOpOverloadToFuncTree(cgi, oo);
}
}
else if(pass == 1)
{
// pass 1: setup extensions
for(Expr* e : expressions)
{
Extension* ext = dynamic_cast<Extension*>(e);
NamespaceDecl* ns = dynamic_cast<NamespaceDecl*>(e);
if(ext) ext->mangledName = cgi->mangleWithNamespace(ext->name);
else if(ns) ns->codegenPass(cgi, pass);
}
// we need the 'Type' enum to be available, as well as the 'Any' type,
// before any variables are encountered.
if(!isInsideNamespace)
TypeInfo::initialiseTypeInfo(cgi);
}
else if(pass == 2)
{
// pass 2: create types
for(Expr* e : expressions)
{
Struct* str = dynamic_cast<Struct*>(e);
Class* cls = dynamic_cast<Class*>(e); // enums are handled, since enum : class
NamespaceDecl* ns = dynamic_cast<NamespaceDecl*>(e);
if(str) str->createType(cgi);
if(cls) cls->createType(cgi);
else if(ns) ns->codegenPass(cgi, pass);
}
}
else if(pass == 3)
{
// pass 3: override types with any extensions
for(Expr* e : expressions)
{
Extension* ext = dynamic_cast<Extension*>(e);
NamespaceDecl* ns = dynamic_cast<NamespaceDecl*>(e);
TypeAlias* ta = dynamic_cast<TypeAlias*>(e);
if(ext) ext->createType(cgi);
else if(ta) ta->createType(cgi);
else if(ns) ns->codegenPass(cgi, pass);
}
// step 3: generate the type info.
// now that we have all the types that we need, and they're all fully
// processed, we create the Type enum.
TypeInfo::generateTypeInfo(cgi);
}
else if(pass == 4)
{
// pass 4: create declarations
for(Expr* e : expressions)
{
ForeignFuncDecl* ffi = dynamic_cast<ForeignFuncDecl*>(e);
Func* func = dynamic_cast<Func*>(e);
NamespaceDecl* ns = dynamic_cast<NamespaceDecl*>(e);
if(ffi) ffi->codegen(cgi);
else if(ns) ns->codegenPass(cgi, pass);
else if(func)
{
// func->decl->codegen(cgi);
}
}
}
else if(pass == 5)
{
// start semantic analysis before any typechecking needs to happen.
SemAnalysis::rewriteDotOperators(cgi);
//.........这里部分代码省略.........