From 30457cd81a3b7604b663c5fe220eba37c19bd3ae Mon Sep 17 00:00:00 2001 From: zuckerberg <5-zuckerberg@users.noreply.git.neet.dev> Date: Mon, 12 Jul 2021 18:23:48 -0400 Subject: [PATCH] wip --- src/context.cpp | 28 +++++----- src/types.cpp | 142 +++++++++++++++++++++++++++++++++--------------- src/types.h | 29 +++++++--- 3 files changed, 133 insertions(+), 66 deletions(-) diff --git a/src/context.cpp b/src/context.cpp index 1ed70a8..fb5c07b 100644 --- a/src/context.cpp +++ b/src/context.cpp @@ -51,7 +51,7 @@ Value Context::eval(peg::Ast& ast) { for (int i=0; igetVar(*this, name); int op = (*nodes[1]).choice; auto v2 = getValue(eval(*nodes[2])); - Value result = Value(Nil()); + Value result = Nil(); // TODO: floats if (op == 0) { - result = Value(v1.getInt(cxt) * v2.getInt(cxt)); + result = v1.getInt(cxt) * v2.getInt(cxt); } else if (op == 1) { - result = Value(v1.getInt(cxt) % v2.getInt(cxt)); + result = v1.getInt(cxt) % v2.getInt(cxt); } else if (op == 2) { - result = Value(v1.getInt(cxt) + v2.getInt(cxt)); + result = v1.getInt(cxt) + v2.getInt(cxt); } else if (op == 3) { - result = Value(v1.getInt(cxt) - v2.getInt(cxt)); + result = v1.getInt(cxt) - v2.getInt(cxt); } else if (op == 4) { - result = Value(v1.getInt(cxt) & v2.getInt(cxt)); + result = v1.getInt(cxt) & v2.getInt(cxt); } else if (op == 5) { - result = Value(v1.getInt(cxt) ^ v2.getInt(cxt)); + result = v1.getInt(cxt) ^ v2.getInt(cxt); } else if (op == 6) { - result = Value(v1.getInt(cxt) | v2.getInt(cxt)); + result = v1.getInt(cxt) | v2.getInt(cxt); } else if (op == 7) { result = v2; } @@ -141,7 +141,7 @@ Value Context::eval(peg::Ast& ast) { } } else if (ast.name == "Block") { // TODO create new scope - Value result = Value(Nil()); + Value result = Nil(); for (int i=0; i