Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Unified Diff: src/liveedit.cc

Issue 3586006: Begin a more aggressive refactoring of the Compiler interface. (Closed)
Patch Set: Always return false on a parse failure. Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ia32/codegen-ia32.cc ('k') | src/parser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/liveedit.cc
diff --git a/src/liveedit.cc b/src/liveedit.cc
index cfd2e357cc63abb6974b33796a4f1afe336649a0..ecbc115301172c0cbd5d2b0d4bdb5ac1b6b89a0b 100644
--- a/src/liveedit.cc
+++ b/src/liveedit.cc
@@ -398,31 +398,16 @@ Handle<JSArray> LiveEdit::CompareStringsLinewise(Handle<String> s1,
static void CompileScriptForTracker(Handle<Script> script) {
- const bool is_eval = false;
- const bool is_global = true;
// TODO(635): support extensions.
- Extension* extension = NULL;
-
PostponeInterruptsScope postpone;
- // Only allow non-global compiles for eval.
- ASSERT(is_eval || is_global);
-
// Build AST.
- ScriptDataImpl* pre_data = NULL;
- EagerCompilationInfo info(script, is_eval);
- FunctionLiteral* lit =
- Parser::MakeAST(is_global, script, extension, pre_data);
-
- // Check for parse errors.
- if (lit == NULL) {
- ASSERT(Top::has_pending_exception());
- return;
- }
- info.set_function(lit);
+ CompilationInfo info(script);
+ info.MarkAsGlobal();
+ if (!Parser::Parse(&info)) return;
// Compile the code.
- LiveEditFunctionTracker tracker(lit);
+ LiveEditFunctionTracker tracker(info.function());
Handle<Code> code = MakeCodeForLiveEdit(&info);
// Check for stack-overflow exceptions.
@@ -433,11 +418,13 @@ static void CompileScriptForTracker(Handle<Script> script) {
tracker.RecordRootFunctionInfo(code);
}
+
// Unwraps JSValue object, returning its field "value"
static Handle<Object> UnwrapJSValue(Handle<JSValue> jsValue) {
return Handle<Object>(jsValue->value());
}
+
// Wraps any object into a OpaqueReference, that will hide the object
// from JavaScript.
static Handle<JSValue> WrapInJSValue(Object* object) {
@@ -448,6 +435,7 @@ static Handle<JSValue> WrapInJSValue(Object* object) {
return result;
}
+
// Simple helper class that creates more or less typed structures over
// JSArray object. This is an adhoc method of passing structures from C++
// to JavaScript.
@@ -468,6 +456,7 @@ class JSArrayBasedStruct {
Handle<JSArray> GetJSArray() {
return array_;
}
+
protected:
void SetField(int field_position, Handle<Object> value) {
SetElement(array_, field_position, value);
@@ -482,6 +471,7 @@ class JSArrayBasedStruct {
Object* res = GetField(field_position);
return Smi::cast(res)->value();
}
+
private:
Handle<JSArray> array_;
};
@@ -554,6 +544,7 @@ class FunctionInfoWrapper : public JSArrayBasedStruct<FunctionInfoWrapper> {
friend class JSArrayBasedStruct<FunctionInfoWrapper>;
};
+
// Wraps SharedFunctionInfo along with some of its fields for passing it
// back to JavaScript. SharedFunctionInfo object itself is additionally
// wrapped into BlindReference for sanitizing reasons.
@@ -594,6 +585,7 @@ class SharedInfoWrapper : public JSArrayBasedStruct<SharedInfoWrapper> {
friend class JSArrayBasedStruct<SharedInfoWrapper>;
};
+
class FunctionInfoListener {
public:
FunctionInfoListener() {
@@ -620,7 +612,6 @@ class FunctionInfoListener {
current_parent_index_ = info.GetParentIndex();
}
- public:
// Saves only function code, because for a script function we
// may never create a SharedFunctionInfo object.
void FunctionCode(Handle<Code> function_code) {
@@ -708,6 +699,7 @@ class FunctionInfoListener {
int current_parent_index_;
};
+
static FunctionInfoListener* active_function_info_listener = NULL;
JSArray* LiveEdit::GatherCompileInfo(Handle<Script> script,
« no previous file with comments | « src/ia32/codegen-ia32.cc ('k') | src/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698