Commit e3f7f8a769534ba879c06192a44f65b245112578
Exists in
master
Merge branch 'master' of git.ucsd.edu:acs008/cse131-pa4
Showing 5 changed files Side-by-side Diff
ast_expr.cc
View file @
e3f7f8a
... | ... | @@ -131,4 +131,16 @@ |
131 | 131 | if (field) field->Print(indentLevel+1); |
132 | 132 | if (actuals) actuals->PrintAll(indentLevel+1, "(actuals) "); |
133 | 133 | } |
134 | + | |
135 | +llvm::Value* IntConstant::Emit() { | |
136 | + return llvm::ConstantInt::get(llvm::Type::getInt32Ty(*irgen.GetContext()), value, true); | |
137 | +} | |
138 | + | |
139 | +llvm::Value* FloatConstant::Emit() { | |
140 | + return llvm::ConstantInt::get(llvm::Type::getFloatTy(*irgen.GetContext()), value, true); | |
141 | +} | |
142 | + | |
143 | +llvm::Value* BoolConstant::Emit() { | |
144 | + return llvm::ConstantInt::get(llvm::Type::getInt1Ty(*irgen.GetContext()), value, false); | |
145 | +} |
ast_expr.h
View file @
e3f7f8a
... | ... | @@ -56,6 +56,7 @@ |
56 | 56 | IntConstant(yyltype loc, int val); |
57 | 57 | const char *GetPrintNameForNode() { return "IntConstant"; } |
58 | 58 | void PrintChildren(int indentLevel); |
59 | + llvm::Value* Emit(); | |
59 | 60 | }; |
60 | 61 | |
61 | 62 | class FloatConstant: public Expr |
... | ... | @@ -67,6 +68,7 @@ |
67 | 68 | FloatConstant(yyltype loc, double val); |
68 | 69 | const char *GetPrintNameForNode() { return "FloatConstant"; } |
69 | 70 | void PrintChildren(int indentLevel); |
71 | + llvm::Value* Emit(); | |
70 | 72 | }; |
71 | 73 | |
72 | 74 | class BoolConstant : public Expr |
... | ... | @@ -78,6 +80,7 @@ |
78 | 80 | BoolConstant(yyltype loc, bool val); |
79 | 81 | const char *GetPrintNameForNode() { return "BoolConstant"; } |
80 | 82 | void PrintChildren(int indentLevel); |
83 | + llvm::Value* Emit(); | |
81 | 84 | }; |
82 | 85 | |
83 | 86 | class VarExpr : public Expr |
ast_stmt.cc
View file @
e3f7f8a
... | ... | @@ -30,7 +30,7 @@ |
30 | 30 | // You can use this as a template and create Emit() function |
31 | 31 | // for individual node to fill in the module structure and instructions. |
32 | 32 | // |
33 | - IRGenerator irgen; | |
33 | + //IRGenerator irgen; | |
34 | 34 | llvm::Module *mod = irgen.GetOrCreateModule("Name_the_Module.bc"); |
35 | 35 | |
36 | 36 | // create a function signature |
irgen.cc
View file @
e3f7f8a