Advertisement
tinyevil

Untitled

Nov 5th, 2018
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.18 KB | None | 0 0
  1.  
  2. class Codegen{
  3. public:
  4.     Codegen();
  5.    
  6.     void prepare(CompilerContext* cc, MemPool::Slice* mem, MemPool::Slice& tmp);
  7.     void generate(MemPool::Slice* mem, MemPool::Slice& tmp);
  8.     void generateNativeStubs(MemPool::Slice* mem, MemPool::Slice& tmp);
  9. private:
  10.     void genHeader(FormattedWriter* writer);
  11.     void genImpl(FormattedWriter* writer);
  12.     void genNativeStubs(FormattedWriter* writer);
  13.  
  14.     bool writePackageNS(CUPackage* package);
  15.     void writePackageInclPath(CUPackage* package);
  16.  
  17.     void preparePackage(CUPackage* package);
  18.  
  19.     void prepareScope(ir::FileScope* scope);
  20.     void prepareType(ir::Type* type);
  21.     void prepareDefinitionOwner(ir::Definition* def);
  22.     void prepareSignature(ir::FileScope* scope, ir::Class* class_, ir::FunctionSignature* signature);
  23.     void prepareImplVTable(ir::Class* class_);
  24.  
  25.     bool doesHaveNativeStubs();
  26.  
  27.     // codegen accesses stuff from cu, needs cu to be codegened
  28.     void uses(ir::Definition* def);
  29.     void uses(CompilationUnit* cu);
  30.  
  31.     void writeScopeHeader(ir::FileScope* scope);
  32.     void writeScopeForwardDecl(ir::FileScope* scope);
  33.     void writeScopeImpl(ir::FileScope* scope);
  34.     void writeScopeNativeStubs(ir::FileScope* scope);
  35.     void writeForwardDecl(ir::Definition* def);
  36.  
  37.     void visitScopeImpl(ir::FileScope* scope);
  38.     void requireTypeImpl(ir::Type* type);
  39.     void requireSignatureImpl(ir::FunctionSignature* signature);
  40.     void visitClassMethodImpl(ir::ClassMethod* method);
  41.     void visitClassFieldImpl(ir::ClassField* field);
  42.     void requireDefinitionImpl(ir::Definition* definition);
  43.  
  44.     void writeInterfaceVTable(ir::Interface* iface);
  45.  
  46.     void writeClassVTableContents(ir::Class* owner, ir::Class* class_);
  47.     void writeClassConstructor(ir::Class* class_);
  48.     void writeClassVTable(ir::Class* class_);
  49.     void writeClassInstanceFields(ir::Class* owner, ir::Class* class_);
  50.     void writeClassStaticFields(ir::Class* class_);
  51.     void writeClassField(ir::Class* owner, ir::ClassField* field);
  52.     void writeClassStaticMethod(ir::ClassMethod* method);
  53.     void writeClassInstanceMethod(ir::ClassMethod* method);
  54.     void writeInterfaceMethod(ir::InterfaceMethod* method);
  55.     void writeGenericProxy(ir::ClassMethod* method);
  56.     void writeGenericProxyImpl(ir::ClassMethod* method);
  57.  
  58.     void writeTypeInfo(ir::Type* type);
  59.     void writeInterfaceImplRef(ir::Class* class_, ir::Interface* iface);
  60.  
  61.     void writeSignature(ir::FunctionSignature* signature, bool first_arg, bool param_names);
  62.     void writeProxyPass(ir::FunctionSignature* sginature, bool first_arg);
  63.  
  64.     void writeFrame(icode::FuncFrame* frame);
  65.  
  66.     void writeRef(ir::Definition* def);
  67.     void writeRef(ir::ClassMethod* method);
  68.     void writeRef(ir::ClassField* field);
  69.     void writePrivateNS(CompilationUnit* cu);
  70.     void writeNamespaceForScope(ir::FileScope* scope);
  71.     void writeNamespaceForPackage(CUPackage* package);
  72.  
  73.     void writeClassConstructorImpl(ir::Class* class_);
  74.     void writeClassNewImpl(ir::Class* class_);
  75.     void writeClassMethodImpl(ir::ClassMethod* method);
  76.     void writeClassStaticFieldImpl(ir::ClassField* field);
  77.  
  78.     void writeStaticInitImpl(ir::FileScope* scope);
  79.  
  80.     void writeFieldType(ir::Type* type);
  81.     void writeParamType(ir::Type* type);
  82.     void writeReturnType(ir::Type* type);
  83.     void writeTypeDesignator(ir::Type* type);
  84.  
  85.     void uwrapClosurePayload(StringRef value, ir::Type* type);
  86.  
  87.     void codegenUnpackVec(ir::Type* type);
  88.     void codegenPackVec(ir::Type* type);
  89.  
  90.     void requireStaticInitiailization(ir::Class* class_);
  91.     void requireStaticInitiailization(ir::GlobalVar* class_);
  92.     void codegenRunStaticInitialize(CompilationUnit* target_unit);
  93.    
  94.     void codegenPreVisitFrame(icode::FuncFrame* frame);
  95.     void codegenDefaultValue(ir::Type* type);
  96.     void codegenBasicBlock(icode::BasicBlock* bb, icode::BasicBlock* follower);
  97.     void codegenPrologueBasicBlock(icode::BasicBlock* bb, icode::BasicBlock* follower);
  98.     void codegenInstr(icode::Instr* instr, icode::BasicBlock* current_bb, icode::BasicBlock* follower);
  99.     void codegenCmpOperator(icode::CmpOp op);
  100.     void codegenNumOperator(icode::NumBinaryOp op);
  101.     void codegenGoto(icode::BasicBlock* current_bb, icode::BasicBlock* bb, icode::BasicBlock* follower);
  102.     void codegenValue(icode::Value* value);
  103.     void codegenRegisterName(icode::Instr* instr);
  104.     void codegenVectorEltType(ir::Type* type);
  105.     void codegenCanonicalType(ir::Type* type);
  106.     void codegenToAny(icode::Value* value);
  107.  
  108.     bool isAny(ir::Type* type);
  109.  
  110.     CodegenCall* codegenPrepareCall(ir::FunctionSignature* signature, ArrayRef<icode::Value*> args);
  111.     void codegenCallParams(CodegenCall* call, ir::FunctionSignature* signature, ArrayRef<icode::Value*> args);
  112.  
  113.     StringRef mangleIdentifier(icode::LocalVar* var);
  114.     StringRef mangleIdentifier(ir::FunctionParam* param);
  115.     StringRef mangleIdentifier(ir::NamespaceDef* def, StringRef name);
  116.     StringRef mangleIdentifier(ir::NamespaceDef* def, StringRef name, MangleKind kind);
  117.     StringRef mangleIdentifier(ir::NamespaceDef* def, StringRef name, MangleKind kind, ir::Accessor accessor);
  118.     StringRef mangleNamespace(StringRef name);
  119.  
  120.     void generateStringLiteral(icode::ConstantString* string);
  121.  
  122.     CompilerContext* cc;
  123.     CompilationUnit* cu;
  124.     CodegenCU* cu_codegen;
  125.     FormattedWriter* writer;
  126.     ir::File* IR;
  127.     MemPool::Slice* mem;
  128.     MemPool::Slice* tmp;
  129.     CodegenFrame* frame;
  130.     icode::ICodeCompiler icode_compiler;
  131. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement