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;
|
int identifier;
|
||||||
const char *filename;
|
const char *filename;
|
||||||
File_Position start, end;
|
File_Position start, end;
|
||||||
|
/*
|
||||||
bool is_cached;
|
bool is_cached;
|
||||||
Boxed_Value cached_value;
|
Boxed_Value cached_value;
|
||||||
|
*/
|
||||||
std::vector<AST_NodePtr> children;
|
std::vector<AST_NodePtr> children;
|
||||||
AST_NodePtr annotation;
|
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) :
|
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.line = start_line;
|
||||||
start.column = start_col;
|
start.column = start_col;
|
||||||
@ -80,13 +81,14 @@ namespace chaiscript
|
|||||||
end.column = end_col;
|
end.column = end_col;
|
||||||
}
|
}
|
||||||
AST_Node(const std::string &ast_node_text, int id, const char *fname) :
|
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) {
|
void cache_const(const Boxed_Value &value) {
|
||||||
this->cached_value = value;
|
this->cached_value = value;
|
||||||
this->is_cached = true;
|
this->is_cached = true;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
virtual Boxed_Value eval(Dispatch_Engine &) {
|
virtual Boxed_Value eval(Dispatch_Engine &) {
|
||||||
Boxed_Value bv;
|
Boxed_Value bv;
|
||||||
|
@ -66,28 +66,40 @@ namespace chaiscript
|
|||||||
*/
|
*/
|
||||||
Boxed_Value Id_AST_Node::eval(Dispatch_Engine &ss) {
|
Boxed_Value Id_AST_Node::eval(Dispatch_Engine &ss) {
|
||||||
if (this->text == "true") {
|
if (this->text == "true") {
|
||||||
|
/*
|
||||||
if (!this->is_cached) {
|
if (!this->is_cached) {
|
||||||
cache_const(const_var(true));
|
cache_const(const_var(true));
|
||||||
}
|
}
|
||||||
return this->cached_value;
|
return this->cached_value;
|
||||||
|
*/
|
||||||
|
return const_var(true);
|
||||||
}
|
}
|
||||||
else if (this->text == "false") {
|
else if (this->text == "false") {
|
||||||
|
/*
|
||||||
if (!this->is_cached) {
|
if (!this->is_cached) {
|
||||||
cache_const(const_var(false));
|
cache_const(const_var(false));
|
||||||
}
|
}
|
||||||
return this->cached_value;
|
return this->cached_value;
|
||||||
|
*/
|
||||||
|
return const_var(false);
|
||||||
}
|
}
|
||||||
else if (this->text == "Infinity") {
|
else if (this->text == "Infinity") {
|
||||||
|
/*
|
||||||
if (!this->is_cached) {
|
if (!this->is_cached) {
|
||||||
cache_const(const_var(std::numeric_limits<double>::infinity()));
|
cache_const(const_var(std::numeric_limits<double>::infinity()));
|
||||||
}
|
}
|
||||||
return this->cached_value;
|
return this->cached_value;
|
||||||
|
*/
|
||||||
|
return const_var(std::numeric_limits<double>::infinity());
|
||||||
}
|
}
|
||||||
else if (this->text == "NaN") {
|
else if (this->text == "NaN") {
|
||||||
|
/*
|
||||||
if (!this->is_cached) {
|
if (!this->is_cached) {
|
||||||
cache_const(const_var(std::numeric_limits<double>::quiet_NaN()));
|
cache_const(const_var(std::numeric_limits<double>::quiet_NaN()));
|
||||||
}
|
}
|
||||||
return this->cached_value;
|
return this->cached_value;
|
||||||
|
*/
|
||||||
|
return const_var(std::numeric_limits<double>::quiet_NaN());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
@ -103,41 +115,39 @@ namespace chaiscript
|
|||||||
* Evaluates a floating point number
|
* Evaluates a floating point number
|
||||||
*/
|
*/
|
||||||
Boxed_Value Float_AST_Node::eval(Dispatch_Engine &) {
|
Boxed_Value Float_AST_Node::eval(Dispatch_Engine &) {
|
||||||
|
/*
|
||||||
if (!this->is_cached) {
|
if (!this->is_cached) {
|
||||||
cache_const(const_var(double(atof(this->text.c_str()))));
|
cache_const(const_var(double(atof(this->text.c_str()))));
|
||||||
}
|
}
|
||||||
return this->cached_value;
|
return this->cached_value;
|
||||||
|
*/
|
||||||
|
return const_var(double(atof(this->text.c_str())));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Evaluates an integer
|
* Evaluates an integer
|
||||||
*/
|
*/
|
||||||
Boxed_Value Int_AST_Node::eval(Dispatch_Engine &) {
|
Boxed_Value Int_AST_Node::eval(Dispatch_Engine &) {
|
||||||
|
/*
|
||||||
if (!this->is_cached) {
|
if (!this->is_cached) {
|
||||||
cache_const(const_var(int(atoi(this->text.c_str()))));
|
cache_const(const_var(int(atoi(this->text.c_str()))));
|
||||||
}
|
}
|
||||||
return this->cached_value;
|
return this->cached_value;
|
||||||
|
*/
|
||||||
|
return const_var(int(atoi(this->text.c_str())));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Evaluates a quoted string
|
* Evaluates a quoted string
|
||||||
*/
|
*/
|
||||||
Boxed_Value Quoted_String_AST_Node::eval(Dispatch_Engine &) {
|
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) {
|
if (!this->is_cached) {
|
||||||
cache_const(const_var(this->text));
|
cache_const(const_var(this->text));
|
||||||
}
|
}
|
||||||
return this->cached_value;
|
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 &) {
|
Boxed_Value Single_Quoted_String_AST_Node::eval(Dispatch_Engine &) {
|
||||||
|
/*
|
||||||
if (!this->is_cached) {
|
if (!this->is_cached) {
|
||||||
cache_const(const_var(char(this->text[0])));
|
cache_const(const_var);
|
||||||
}
|
}
|
||||||
return this->cached_value;
|
return this->cached_value;
|
||||||
|
*/
|
||||||
|
return const_var(char(this->text[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user