diff options
| author | Franklin Wei <git@fwei.tk> | 2015-11-11 11:27:44 -0500 |
|---|---|---|
| committer | Franklin Wei <git@fwei.tk> | 2015-11-11 11:27:44 -0500 |
| commit | ac3d13839cd797d2992d9111a16b649668e2f06d (patch) | |
| tree | eaff2783f7a0af726fab70ddfdbfc5e712d3f0d2 /src/compile.c | |
| parent | dc371f18db2fe07fd0be9e096666fbe9d07c8817 (diff) | |
| download | ducky-ac3d13839cd797d2992d9111a16b649668e2f06d.zip ducky-ac3d13839cd797d2992d9111a16b649668e2f06d.tar.gz ducky-ac3d13839cd797d2992d9111a16b649668e2f06d.tar.bz2 ducky-ac3d13839cd797d2992d9111a16b649668e2f06d.tar.xz | |
stuff
Diffstat (limited to 'src/compile.c')
| -rw-r--r-- | src/compile.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/compile.c b/src/compile.c index 1db46af..a5c3f9a 100644 --- a/src/compile.c +++ b/src/compile.c @@ -109,6 +109,13 @@ static void setVariable(const char *name, vartype val) write_varid(get_varid(name)); } +static void makeConstantVariable(const char *name, vartype val) +{ + write_instr(DECL_CONST); + write_varid(get_varid(name)); + write_imm(val); +} + static void setConst(const char *name, bool c) { if(c) @@ -743,7 +750,7 @@ static vartype eval_expr(char *str) } } } - + if(tstart) { //push_numstack(getValue(tstart, expr)); @@ -1210,14 +1217,10 @@ void ducky_compile(int fd, bool verbose, int out) /* initialize some other constants */ - setVariable(".", 0); - setConst(".", true); - - setVariable("true", 1); - setConst("true", true); - - setVariable("false", 0); - setConst("false", true); + makeConstantVariable(".", 0); + + makeConstantVariable("true", 1); + makeConstantVariable("false", 0); /* initialize labels (using output from index_lines) */ index_labels(file_des); |