Added support to choose which compiler should be used when compiling in the browser. Default is old compiler but add "ObjJCompilerSetUsedVersion("objj_compiler2");" in the index.html (and/or index-debug.html) to use new compiler in browser.

This commit is contained in:
Martin Carlberg committed 2012-12-20 14:26:49 +01:00
1 parent 26be5bf264
commit 0f3d5f4b10
3 files changed
+32 -15

No files matched your search

+14 -14
View File
@@ -151,22 +151,22 @@ Executable.prototype.execute = function()
CPLog("EXECUTION: " + this.URL());
#endif
var fileDependencies = this.fileDependencies(),
index = 0,
count = fileDependencies.length;
for (; index < count; ++index)
{
var fileDependency = fileDependencies[index],
isQuoted = fileDependency.isLocal(),
URL = fileDependency.URL();
this.fileExecuter()(URL, isQuoted);
}
if (this._compiler)
{
this.setCode(this._compiler.compilePass2());
var fileDependencies = this.fileDependencies(),
index = 0,
count = fileDependencies.length;
for (; index < count; ++index)
{
var fileDependency = fileDependencies[index],
isQuoted = fileDependency.isLocal(),
URL = fileDependency.URL();
this.fileExecuter()(URL, isQuoted);
}
this.setCode(this._compiler.compilePass2());
this._compiler = null;
}
+8 -1
View File
@@ -42,7 +42,14 @@ function FileExecutable(/*CFURL|String*/ aURL, /*Dictionary*/ aFilenameTranslate
executable = decompile(fileContents, aURL);
else if ((extension === "j" || !extension) && !fileContents.match(/^{/))
executable = exports.compileFileDependencies(fileContents, aURL, ObjJCompiler.Flags.IncludeDebugSymbols); // FIXME: Include correct flags
{
if (!exports.ObjJCompiler.usedVersion || exports.ObjJCompiler.usedVersion === "preprocessor")
executable = exports.preprocess(fileContents, aURL, Preprocessor.Flags.IncludeDebugSymbols);
else if (exports.ObjJCompiler.usedVersion === "objj_compiler2")
executable = exports.compileFileDependencies(fileContents, aURL, ObjJCompiler.Flags.IncludeDebugSymbols);
else
throw new Error("Compiler to use is set to " + exports.ObjJCompiler.usedVersion + " but we only support 'preprocessor' (old compiler) and 'objj_compiler2' (new compiler)");
}
else
executable = new Executable(fileContents, [], aURL);
+10
View File
@@ -109,6 +109,16 @@ ObjJCompiler.prototype.compilePass2 = function()
exports.ObjJCompiler = ObjJCompiler;
// This will set the compiler version to use.
// These version works:
// "preprocessor" -> Old Cappuccino compiler
// "objj_compiler2" -> New Cappuccino compiler
GLOBAL(ObjJCompilerSetUsedVersion) = function(version)
{
ObjJCompiler.usedVersion = version;
}
exports.setCurrentCompilerFlags = function(/*String*/ compilerFlags)
{
currentCompilerFlags = compilerFlags;