From 70cecced8d00b89c40de196fc87642dadf992ff4 Mon Sep 17 00:00:00 2001 From: zuckerberg Date: Tue, 13 Jul 2021 17:29:59 -0400 Subject: [PATCH] Fix cleanup --- default.nix | 8 +------- src/types.cpp | 31 +++++++++---------------------- src/types.h | 2 +- 3 files changed, 11 insertions(+), 30 deletions(-) diff --git a/default.nix b/default.nix index dea883a..455d590 100644 --- a/default.nix +++ b/default.nix @@ -10,13 +10,7 @@ pkgs.stdenv.mkDerivation rec { pkgs.gdb ]; - configurePhase = '' - cmake . - ''; - - buildPhase = '' - make - ''; + nativeBuildInputs = [ pkgs.cmake ]; installPhase = '' mkdir -p $out/bin diff --git a/src/types.cpp b/src/types.cpp index 4cb3e64..dbd2acb 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -2,16 +2,6 @@ #include "context.h" -// Args Args::toArgs(Context& cxt, Value input) { -// Args args; -// if (input.type() == typeid(std::vector)) { -// args.args = std::any_cast>(input); -// } else { -// cxt.error("Unimplemented toArgs"); -// } -// return args; -// } - Value Func::execute(Context& cxt, Args& args) { if (ast == nullptr) { return nativeFunction(cxt, args); @@ -100,64 +90,61 @@ Value::~Value() { void Value::cleanup() { if (isString()) { - std::cerr << "string" << std::endl; delete value.string; } else if (isFunction()) { - std::cerr << "func" << std::endl; delete value.function; } else if (isArgs()) { - std::cerr << "args" << std::endl; delete value.args; } else if (isIdentifier()) { - std::cerr << "identifier" << std::endl; delete value.identifier; } + type = TypeNil; } Value& Value::operator=(Nil rhs) { - // cleanup(); + cleanup(); type = TypeNil; value.nil = rhs; return *this; } Value& Value::operator=(long rhs) { - // cleanup(); + cleanup(); type = TypeInt; value.int_ = rhs; return *this; } Value& Value::operator=(double rhs) { - // cleanup(); + cleanup(); type = TypeFloat; value.float_ = rhs; return *this; } Value& Value::operator=(bool rhs) { - // cleanup(); + cleanup(); type = TypeBoolean; value.bool_ = rhs; return *this; } Value& Value::operator=(const std::string &rhs) { - // cleanup(); + cleanup(); type = TypeString; value.string = new std::string(rhs); return *this; } Value& Value::operator=(const Func &rhs) { - // cleanup(); + cleanup(); type = TypeFunction; value.function = new Func(rhs); return *this; } Value& Value::operator=(const Args &rhs) { - // cleanup(); + cleanup(); type = TypeArgs; value.args = new Args(rhs); return *this; } Value& Value::operator=(const Identifier &rhs) { - // cleanup(); + cleanup(); type = TypeIdentifier; value.identifier = new Identifier(rhs); return *this; diff --git a/src/types.h b/src/types.h index 40e7ec3..2987759 100644 --- a/src/types.h +++ b/src/types.h @@ -79,7 +79,7 @@ protected: Identifier *identifier; }; - Type type; + Type type = TypeNil; TypeValues value; public: