Bug 779724 - Replace JSOPTION_ONLY_CNG_SOURCE with an enum on CompileOptions. r=jorendorff

This commit is contained in:
Benjamin Peterson
2012-08-07 10:39:45 -07:00
parent 38629e3e28
commit ce2a12f6d9
7 changed files with 41 additions and 22 deletions

View File

@@ -65,14 +65,22 @@ frontend::CompileScript(JSContext *cx, HandleObject scopeChain, StackFrame *call
if (!CheckLength(cx, length))
return NULL;
JS_ASSERT_IF(staticLevel != 0, options.sourcePolicy != CompileOptions::LAZY_SOURCE);
ScriptSource *ss = cx->new_<ScriptSource>();
if (!ss)
return NULL;
ScriptSourceHolder ssh(cx->runtime, ss);
SourceCompressionToken sct(cx);
if (!cx->hasRunOption(JSOPTION_ONLY_CNG_SOURCE) || options.compileAndGo) {
switch (options.sourcePolicy) {
case CompileOptions::SAVE_SOURCE:
if (!ss->setSourceCopy(cx, chars, length, false, &sct))
return NULL;
break;
case CompileOptions::LAZY_SOURCE:
ss->setSourceRetrievable();
break;
case CompileOptions::NO_SOURCE:
break;
}
Parser parser(cx, options, chars, length, /* foldConstants = */ true);
@@ -236,8 +244,11 @@ frontend::CompileFunctionBody(JSContext *cx, HandleFunction fun, CompileOptions
return NULL;
ScriptSourceHolder ssh(cx->runtime, ss);
SourceCompressionToken sct(cx);
if (!ss->setSourceCopy(cx, chars, length, true, &sct))
return NULL;
JS_ASSERT(options.sourcePolicy != CompileOptions::LAZY_SOURCE);
if (options.sourcePolicy == CompileOptions::SAVE_SOURCE) {
if (!ss->setSourceCopy(cx, chars, length, true, &sct))
return NULL;
}
options.setCompileAndGo(false);
Parser parser(cx, options, chars, length, /* foldConstants = */ true);