Created
September 19, 2012 14:07
-
-
Save jpf91/3749879 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct StructBuilder | |
| { | |
| Scope *scope; | |
| Loc loc; | |
| StructDeclaration *decl; | |
| TypeStruct *type; | |
| StructBuilder(Module *mod, const char* name) | |
| { | |
| scope = mod->scope; | |
| loc = Loc(mod, 1); | |
| decl = new StructDeclaration(loc, new Identifier(name, 0)); | |
| type = new TypeStruct(decl); | |
| decl->type = type; | |
| decl->members = new Dsymbols(); | |
| } | |
| void addField(const char* name, Type* fieldType) | |
| { | |
| Identifier* fieldId = new Identifier(name, 0); | |
| VarDeclaration *fieldDecl = new VarDeclaration(loc, fieldType, fieldId, NULL); | |
| decl->members->push(fieldDecl); | |
| } | |
| void finish() | |
| { | |
| decl->semantic(scope); | |
| decl->finalizeSize(scope); | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment