Browse Source

run the source through the JS parser

master
Odilitime 5 years ago
parent
commit
e380371d50
  1. 11
      src/interfaces/elements/SCRIPTElement.cpp

11
src/interfaces/elements/SCRIPTElement.cpp

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
#include "../components/DocumentComponent.h"
#include "../../WebResource.h"
#include "../../Log.h"
#include "../../parsers/scripting/javascript/JSParser.h"
std::unique_ptr<Component> SCRIPTElement::renderer(const ElementRenderRequest &request) {
TagNode *tagNode = dynamic_cast<TagNode*>(request.node.get());
@ -44,6 +45,16 @@ std::unique_ptr<Component> SCRIPTElement::renderer(const ElementRenderRequest &r @@ -44,6 +45,16 @@ std::unique_ptr<Component> SCRIPTElement::renderer(const ElementRenderRequest &r
}
// parse JS
//std::cout << "SCRIPTElement::renderer - source: " << source << std::endl;
JSParser parser;
const std::clock_t begin = clock();
std::shared_ptr<JavaScript> newScript = parser.parse(source);
const std::clock_t end = clock();
logDebug() << "SCRIPTElement::renderer - Parsed document in: " << std::fixed << ((static_cast<double>(end - begin)) / CLOCKS_PER_SEC) << std::scientific << " seconds" << std::endl;
request.docComponent->mainScript = parser.append(request.docComponent->mainScript, newScript);
// we need to execute the new instructions with the combined scope
// copy scope back into our script
newScript->rootScope = request.docComponent->mainScript->rootScope;
}
return nullptr;
}

Loading…
Cancel
Save