Commenting out of previous node value caching scheme. This allows us to profile later, without having these smaller optimizations
clutter up the flow. This also allows us to pass the reflection test.
This commit is contained in:
parent
8a6a46d0d3
commit
054179ead3
@ -65,14 +65,15 @@ namespace chaiscript
|
||||
int identifier;
|
||||
const char *filename;
|
||||
File_Position start, end;
|
||||
/*
|
||||
bool is_cached;
|
||||
Boxed_Value cached_value;
|
||||
|
||||
*/
|
||||
std::vector<AST_NodePtr> children;
|
||||
AST_NodePtr annotation;
|
||||
|
||||
AST_Node(const std::string &ast_node_text, int id, const char *fname, int start_line, int start_col, int end_line, int end_col) :
|
||||
text(ast_node_text), identifier(id), filename(fname), is_cached(false) {
|
||||
text(ast_node_text), identifier(id), filename(fname)/*, is_cached(false)*/ {
|
||||
|
||||
start.line = start_line;
|
||||
start.column = start_col;
|
||||
@ -80,13 +81,14 @@ namespace chaiscript
|
||||
end.column = end_col;
|
||||
}
|
||||
AST_Node(const std::string &ast_node_text, int id, const char *fname) :
|
||||
text(ast_node_text), identifier(id), filename(fname), is_cached(false) { }
|
||||
|
||||
text(ast_node_text), identifier(id), filename(fname)/*, is_cached(false)*/ { }
|
||||
|
||||
/*
|
||||
void cache_const(const Boxed_Value &value) {
|
||||
this->cached_value = value;
|
||||
this->is_cached = true;
|
||||
}
|
||||
*/
|
||||
|
||||
virtual Boxed_Value eval(Dispatch_Engine &) {
|
||||
Boxed_Value bv;
|
||||
|
@ -66,28 +66,40 @@ namespace chaiscript
|
||||
*/
|
||||
Boxed_Value Id_AST_Node::eval(Dispatch_Engine &ss) {
|
||||
if (this->text == "true") {
|
||||
/*
|
||||
if (!this->is_cached) {
|
||||
cache_const(const_var(true));
|
||||
}
|
||||
return this->cached_value;
|
||||
*/
|
||||
return const_var(true);
|
||||
}
|
||||
else if (this->text == "false") {
|
||||
/*
|
||||
if (!this->is_cached) {
|
||||
cache_const(const_var(false));
|
||||
}
|
||||
return this->cached_value;
|
||||
*/
|
||||
return const_var(false);
|
||||
}
|
||||
else if (this->text == "Infinity") {
|
||||
/*
|
||||
if (!this->is_cached) {
|
||||
cache_const(const_var(std::numeric_limits<double>::infinity()));
|
||||
}
|
||||
return this->cached_value;
|
||||
*/
|
||||
return const_var(std::numeric_limits<double>::infinity());
|
||||
}
|
||||
else if (this->text == "NaN") {
|
||||
/*
|
||||
if (!this->is_cached) {
|
||||
cache_const(const_var(std::numeric_limits<double>::quiet_NaN()));
|
||||
}
|
||||
return this->cached_value;
|
||||
*/
|
||||
return const_var(std::numeric_limits<double>::quiet_NaN());
|
||||
}
|
||||
else {
|
||||
try {
|
||||
@ -103,41 +115,39 @@ namespace chaiscript
|
||||
* Evaluates a floating point number
|
||||
*/
|
||||
Boxed_Value Float_AST_Node::eval(Dispatch_Engine &) {
|
||||
/*
|
||||
if (!this->is_cached) {
|
||||
cache_const(const_var(double(atof(this->text.c_str()))));
|
||||
}
|
||||
return this->cached_value;
|
||||
*/
|
||||
return const_var(double(atof(this->text.c_str())));
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates an integer
|
||||
*/
|
||||
Boxed_Value Int_AST_Node::eval(Dispatch_Engine &) {
|
||||
/*
|
||||
if (!this->is_cached) {
|
||||
cache_const(const_var(int(atoi(this->text.c_str()))));
|
||||
}
|
||||
return this->cached_value;
|
||||
*/
|
||||
return const_var(int(atoi(this->text.c_str())));
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates a quoted string
|
||||
*/
|
||||
Boxed_Value Quoted_String_AST_Node::eval(Dispatch_Engine &) {
|
||||
//return const_var(node->text);
|
||||
|
||||
/*
|
||||
if ((node->text.size() > 0) && (node->text[0] == '$')) {
|
||||
node->text.erase(0, 1);
|
||||
Param_List_Builder plb;
|
||||
plb << node->text;
|
||||
|
||||
return ss.call_function("eval", plb);
|
||||
}
|
||||
*/
|
||||
if (!this->is_cached) {
|
||||
cache_const(const_var(this->text));
|
||||
}
|
||||
return this->cached_value;
|
||||
*/
|
||||
return const_var(this->text);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -145,10 +155,13 @@ namespace chaiscript
|
||||
*/
|
||||
|
||||
Boxed_Value Single_Quoted_String_AST_Node::eval(Dispatch_Engine &) {
|
||||
/*
|
||||
if (!this->is_cached) {
|
||||
cache_const(const_var(char(this->text[0])));
|
||||
cache_const(const_var);
|
||||
}
|
||||
return this->cached_value;
|
||||
*/
|
||||
return const_var(char(this->text[0]));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user