1. implement simple ByteCode (load, store, binary plus)

2. implement simple ByteCodeInterpreter
3. implement simple global env

we can run very simple script likes below now
a = b = 1;
b = a + 2;

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
This commit is contained in:
seonghyun kim 2016-11-29 22:40:21 +09:00
commit 7c47c6ed51
41 changed files with 1622 additions and 81 deletions

View file

@ -1,6 +1,7 @@
#include "Escargot.h"
#include "ScriptParser.h"
#include "runtime/Context.h"
#include "interpreter/ByteCode.h"
#include "parser/esprima_cpp/esprima.h"
#include "parser/ast/AST.h"
#include "parser/CodeBlock.h"
@ -68,10 +69,13 @@ ScriptParser::ScriptParserResult ScriptParser::parse(StringView scriptSource)
try {
ProgramNode* program = esprima::parseProgram(m_context, scriptSource, [](Escargot::Node* node, NodeLOC start, NodeLOC end) {
// printf("nd type %d\n", node->type());
node->m_loc = start;
});
CodeBlock* topCodeBlock = generateCodeBlockTreeFromAST(m_context, scriptSource, program);
topCodeBlock->m_cachedASTNode = program;
script = new Script(topCodeBlock);
// dump Code Block
#ifndef NDEBUG
if (getenv("DUMP_CODEBLOCK_TREE") && strlen(getenv("DUMP_CODEBLOCK_TREE"))) {