|
|
|
@ -17,6 +17,7 @@ public:
@@ -17,6 +17,7 @@ public:
|
|
|
|
|
// toNumber
|
|
|
|
|
// toFunction
|
|
|
|
|
// toArray
|
|
|
|
|
// toElement
|
|
|
|
|
// toObject
|
|
|
|
|
// toReference
|
|
|
|
|
// toForward
|
|
|
|
@ -59,7 +60,7 @@ public:
@@ -59,7 +60,7 @@ public:
|
|
|
|
|
|
|
|
|
|
class js_number : public js_internal_storage { |
|
|
|
|
public: |
|
|
|
|
signed long value; |
|
|
|
|
double value; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
class js_object : public js_internal_storage { |
|
|
|
@ -69,9 +70,18 @@ public:
@@ -69,9 +70,18 @@ public:
|
|
|
|
|
|
|
|
|
|
class js_array : public js_internal_storage { |
|
|
|
|
public: |
|
|
|
|
std::vector<js_internal_storage> value; |
|
|
|
|
std::vector<js_internal_storage *> value; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
class Node; // fwd declr
|
|
|
|
|
|
|
|
|
|
class js_element : public js_internal_storage { |
|
|
|
|
public: |
|
|
|
|
Node *value; // shared_ptr ?
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
class JavaScript; // fwd declr
|
|
|
|
|
|
|
|
|
|
// we probably should extend js_object
|
|
|
|
|
class js_function : public js_internal_storage { |
|
|
|
|
public: |
|
|
|
@ -79,6 +89,7 @@ public:
@@ -79,6 +89,7 @@ public:
|
|
|
|
|
std::vector<std::string> parameters; // incoming call or defined vars?
|
|
|
|
|
js_function *parentScope = nullptr; |
|
|
|
|
js_object locals; |
|
|
|
|
JavaScript *script = nullptr; // can store any type of JavaScript
|
|
|
|
|
//js_scope scope;
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -139,11 +150,13 @@ public:
@@ -139,11 +150,13 @@ public:
|
|
|
|
|
JavaScript() { |
|
|
|
|
this->setUpRoot(); |
|
|
|
|
} |
|
|
|
|
virtual ~JavaScript() = default; |
|
|
|
|
void setUpRoot() { |
|
|
|
|
// set up default window reference
|
|
|
|
|
js_reference *window = new js_reference; |
|
|
|
|
window->ptr = &rootScope; |
|
|
|
|
rootScope.locals.value["window"] = window; |
|
|
|
|
this->rootScope.locals.value["window"] = window; |
|
|
|
|
this->rootScope.script = this; |
|
|
|
|
} |
|
|
|
|
void clear() { |
|
|
|
|
tokens.clear(); |
|
|
|
@ -161,7 +174,7 @@ public:
@@ -161,7 +174,7 @@ public:
|
|
|
|
|
void parse(const std::string); |
|
|
|
|
void append(const std::shared_ptr<JavaScript> &source); |
|
|
|
|
void applyScope(const std::shared_ptr<JavaScript> &source); |
|
|
|
|
void execute(); |
|
|
|
|
void execute(); // probably not needed
|
|
|
|
|
// each token is one statement
|
|
|
|
|
std::vector<std::string> tokens; |
|
|
|
|
// we're just settings the rootScope.variables
|
|
|
|
|