diff --git a/Objective-J/Executable.js b/Objective-J/Executable.js index 8a90209f3..6baaca567 100644 --- a/Objective-J/Executable.js +++ b/Objective-J/Executable.js @@ -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; } diff --git a/Objective-J/FileExecutable.js b/Objective-J/FileExecutable.js index 2acb89300..2081daba6 100644 --- a/Objective-J/FileExecutable.js +++ b/Objective-J/FileExecutable.js @@ -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); diff --git a/Objective-J/ObjJCompiler.js b/Objective-J/ObjJCompiler.js index 95c89d3f8..ca25a2f42 100644 --- a/Objective-J/ObjJCompiler.js +++ b/Objective-J/ObjJCompiler.js @@ -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;