Fix cleanup
This commit is contained in:
parent
30457cd81a
commit
70cecced8d
@ -10,13 +10,7 @@ pkgs.stdenv.mkDerivation rec {
|
|||||||
pkgs.gdb
|
pkgs.gdb
|
||||||
];
|
];
|
||||||
|
|
||||||
configurePhase = ''
|
nativeBuildInputs = [ pkgs.cmake ];
|
||||||
cmake .
|
|
||||||
'';
|
|
||||||
|
|
||||||
buildPhase = ''
|
|
||||||
make
|
|
||||||
'';
|
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
|
@ -2,16 +2,6 @@
|
|||||||
|
|
||||||
#include "context.h"
|
#include "context.h"
|
||||||
|
|
||||||
// Args Args::toArgs(Context& cxt, Value input) {
|
|
||||||
// Args args;
|
|
||||||
// if (input.type() == typeid(std::vector<std::any>)) {
|
|
||||||
// args.args = std::any_cast<std::vector<std::any>>(input);
|
|
||||||
// } else {
|
|
||||||
// cxt.error("Unimplemented toArgs");
|
|
||||||
// }
|
|
||||||
// return args;
|
|
||||||
// }
|
|
||||||
|
|
||||||
Value Func::execute(Context& cxt, Args& args) {
|
Value Func::execute(Context& cxt, Args& args) {
|
||||||
if (ast == nullptr) {
|
if (ast == nullptr) {
|
||||||
return nativeFunction(cxt, args);
|
return nativeFunction(cxt, args);
|
||||||
@ -100,64 +90,61 @@ Value::~Value() {
|
|||||||
|
|
||||||
void Value::cleanup() {
|
void Value::cleanup() {
|
||||||
if (isString()) {
|
if (isString()) {
|
||||||
std::cerr << "string" << std::endl;
|
|
||||||
delete value.string;
|
delete value.string;
|
||||||
} else if (isFunction()) {
|
} else if (isFunction()) {
|
||||||
std::cerr << "func" << std::endl;
|
|
||||||
delete value.function;
|
delete value.function;
|
||||||
} else if (isArgs()) {
|
} else if (isArgs()) {
|
||||||
std::cerr << "args" << std::endl;
|
|
||||||
delete value.args;
|
delete value.args;
|
||||||
} else if (isIdentifier()) {
|
} else if (isIdentifier()) {
|
||||||
std::cerr << "identifier" << std::endl;
|
|
||||||
delete value.identifier;
|
delete value.identifier;
|
||||||
}
|
}
|
||||||
|
type = TypeNil;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value& Value::operator=(Nil rhs) {
|
Value& Value::operator=(Nil rhs) {
|
||||||
// cleanup();
|
cleanup();
|
||||||
type = TypeNil;
|
type = TypeNil;
|
||||||
value.nil = rhs;
|
value.nil = rhs;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
Value& Value::operator=(long rhs) {
|
Value& Value::operator=(long rhs) {
|
||||||
// cleanup();
|
cleanup();
|
||||||
type = TypeInt;
|
type = TypeInt;
|
||||||
value.int_ = rhs;
|
value.int_ = rhs;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
Value& Value::operator=(double rhs) {
|
Value& Value::operator=(double rhs) {
|
||||||
// cleanup();
|
cleanup();
|
||||||
type = TypeFloat;
|
type = TypeFloat;
|
||||||
value.float_ = rhs;
|
value.float_ = rhs;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
Value& Value::operator=(bool rhs) {
|
Value& Value::operator=(bool rhs) {
|
||||||
// cleanup();
|
cleanup();
|
||||||
type = TypeBoolean;
|
type = TypeBoolean;
|
||||||
value.bool_ = rhs;
|
value.bool_ = rhs;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
Value& Value::operator=(const std::string &rhs) {
|
Value& Value::operator=(const std::string &rhs) {
|
||||||
// cleanup();
|
cleanup();
|
||||||
type = TypeString;
|
type = TypeString;
|
||||||
value.string = new std::string(rhs);
|
value.string = new std::string(rhs);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
Value& Value::operator=(const Func &rhs) {
|
Value& Value::operator=(const Func &rhs) {
|
||||||
// cleanup();
|
cleanup();
|
||||||
type = TypeFunction;
|
type = TypeFunction;
|
||||||
value.function = new Func(rhs);
|
value.function = new Func(rhs);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
Value& Value::operator=(const Args &rhs) {
|
Value& Value::operator=(const Args &rhs) {
|
||||||
// cleanup();
|
cleanup();
|
||||||
type = TypeArgs;
|
type = TypeArgs;
|
||||||
value.args = new Args(rhs);
|
value.args = new Args(rhs);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
Value& Value::operator=(const Identifier &rhs) {
|
Value& Value::operator=(const Identifier &rhs) {
|
||||||
// cleanup();
|
cleanup();
|
||||||
type = TypeIdentifier;
|
type = TypeIdentifier;
|
||||||
value.identifier = new Identifier(rhs);
|
value.identifier = new Identifier(rhs);
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -79,7 +79,7 @@ protected:
|
|||||||
Identifier *identifier;
|
Identifier *identifier;
|
||||||
};
|
};
|
||||||
|
|
||||||
Type type;
|
Type type = TypeNil;
|
||||||
TypeValues value;
|
TypeValues value;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user