summaryrefslogtreecommitdiffhomepage
path: root/compiler.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2021-05-25 19:24:19 +0200
committerJo-Philipp Wich <jo@mein.io>2021-05-25 21:02:40 +0200
commit44354cf8209185479c2aa62b855d058495ea7bde (patch)
tree892a85f123f582a3978a3069e8d060124683cd00 /compiler.c
parent5879bdf94fa8f899a1961f6eb5fbc4aacfa84b2a (diff)
lexer, compiler: separate TK_BOOL token into TK_TRUE and TK_FALSE tokens
The token type split allows us to drop the token value union in the reserved word list with a subsequent commit. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'compiler.c')
-rw-r--r--compiler.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/compiler.c b/compiler.c
index d978f38..4f20be0 100644
--- a/compiler.c
+++ b/compiler.c
@@ -60,7 +60,8 @@ uc_compiler_parse_rules[TK_ERROR + 1] = {
[TK_NUMBER] = { uc_compiler_compile_constant, NULL, P_NONE },
[TK_DOUBLE] = { uc_compiler_compile_constant, NULL, P_NONE },
[TK_STRING] = { uc_compiler_compile_constant, NULL, P_NONE },
- [TK_BOOL] = { uc_compiler_compile_constant, NULL, P_NONE },
+ [TK_TRUE] = { uc_compiler_compile_constant, NULL, P_NONE },
+ [TK_FALSE] = { uc_compiler_compile_constant, NULL, P_NONE },
[TK_NULL] = { uc_compiler_compile_constant, NULL, P_NONE },
[TK_THIS] = { uc_compiler_compile_constant, NULL, P_NONE },
[TK_REGEXP] = { uc_compiler_compile_constant, NULL, P_NONE },
@@ -1455,9 +1456,12 @@ uc_compiler_compile_constant(uc_compiler *compiler, bool assignable)
uc_compiler_emit_insn(compiler, compiler->parser->prev.pos, I_LNULL);
break;
- case TK_BOOL:
- uc_compiler_emit_insn(compiler, compiler->parser->prev.pos,
- ucv_boolean_get(compiler->parser->prev.uv) ? I_LTRUE : I_LFALSE);
+ case TK_TRUE:
+ uc_compiler_emit_insn(compiler, compiler->parser->prev.pos, I_LTRUE);
+ break;
+
+ case TK_FALSE:
+ uc_compiler_emit_insn(compiler, compiler->parser->prev.pos, I_LFALSE);
break;
case TK_STRING: