From b132a6670757359ccaed51ef20e8685e7da281e7 Mon Sep 17 00:00:00 2001 From: Martin Carlberg Date: Fri, 20 Nov 2015 12:33:00 +0100 Subject: [PATCH] Fixed: Compiler option 'IncludeTypeSignatures' is default turn on for all type of builds. It can optionally be turned off. --- Objective-J/CommonJS/lib/objective-j.js | 31 ++++++++++++--- .../CommonJS/lib/objective-j/compiler.js | 14 ++++--- Objective-J/ObjJAcornCompiler.js | 38 +++++++++---------- .../OutputTests/Class/accessors.js | 2 +- .../Class/root-class-multiple-ivars.js | 2 +- .../OutputTests/Class/root-class-one-ivar.js | 2 +- .../Preprocessor/OutputTests/Misc/ref-self.js | 2 +- .../Preprocessor/OutputTests/OutputTest.j | 4 +- .../Templates/Application/index-debug.html | 15 +++++++- .../Templates/Application/index.html | 5 +++ .../Templates/NibApplication/index-debug.html | 15 +++++++- .../Templates/NibApplication/index.html | 5 +++ .../ThemeDescriptor/index-debug.html | 15 +++++++- .../Templates/ThemeDescriptor/index.html | 5 +++ 14 files changed, 114 insertions(+), 41 deletions(-) diff --git a/Objective-J/CommonJS/lib/objective-j.js b/Objective-J/CommonJS/lib/objective-j.js index f3e1db5c4..1d74d0f10 100644 --- a/Objective-J/CommonJS/lib/objective-j.js +++ b/Objective-J/CommonJS/lib/objective-j.js @@ -90,11 +90,14 @@ exports.run = function(args) if (argv[0] === "--help" || argv[0] === "-h") { print("Usage (objj): " + args[0] + " [options] [--] files..."); - print(" -v, --version print the current version of objj"); - print(" -I, --objj-include-paths include a specific framework paths") - print(" -h, --help print this help"); - print(" -m, --multifiles launch objj on several files") - print(" -x, --xml specify the output format in xml.") + print(" -v, --version print the current version of objj"); + print(" -I, --objj-include-paths include a specific framework paths") + print(" -h, --help print this help"); + print(" -m, --multifiles launch objj on several files") + print(" -x, --xml specify the output format in xml.") + print(" -g, --include-debug-symbols Include debug symbols when compiling.") + print(" -T, --dont-include-type-signatures Do not include type signatures when compiling.") + print(" -O2, --inline-msg-send Inline objj_msgSend function when compiling.") return; } @@ -119,6 +122,24 @@ exports.run = function(args) argv.shift(); exports.outputFormatInXML = true; break; + + case "-g": + case "--include-debug-symbols": + argv.shift(); + (OBJJ_COMPILER_FLAGS || (OBJJ_COMPILER_FLAGS = [])).push("IncludeDebugSymbols"); + break; + + case "-T": + case "--dont-include-type-signatures": + argv.shift(); + (OBJJ_COMPILER_FLAGS || (OBJJ_COMPILER_FLAGS = [])).push("IncludeTypeSignatures"); + break; + + case "-O2": + case "--inline-msg-send": + argv.shift(); + (OBJJ_COMPILER_FLAGS || (OBJJ_COMPILER_FLAGS = [])).push("InlineMsgSend"); + break; } } } diff --git a/Objective-J/CommonJS/lib/objective-j/compiler.js b/Objective-J/CommonJS/lib/objective-j/compiler.js index 6f7f91972..6f761e3a5 100644 --- a/Objective-J/CommonJS/lib/objective-j/compiler.js +++ b/Objective-J/CommonJS/lib/objective-j/compiler.js @@ -187,7 +187,7 @@ function resolveFlags(args) objjcFlags &= ~ObjectiveJ.ObjJAcornCompiler.Flags.CheckSyntax; else if (argument.indexOf("-T") === 0) - objjcFlags |= ObjectiveJ.ObjJAcornCompiler.Flags.IncludeTypeSignatures; + objjcFlags &= ~ObjectiveJ.ObjJAcornCompiler.Flags.IncludeTypeSignatures; else if (argument.indexOf("-g") === 0) objjcFlags |= ObjectiveJ.ObjJAcornCompiler.Flags.IncludeDebugSymbols; @@ -259,12 +259,16 @@ exports.main = function(args) if (argv[0] === "--help" || argv[0].substr(0, 1) == '-') { print("Usage (objjc 2.0): " + args[0] + " [options] [--] file..."); - print(" -p, --print print the output directly to stdout"); - print(" --unmarked don't tag the output with @STATIC header"); + print(" -p, --print print the output directly to stdout"); + print(" --unmarked don't tag the output with @STATIC header"); print(""); - print(" -T, --includeTypeSignatures include type signatures in the compiled output"); + print(" -T, --dont-include-type-signatures include type signatures in the compiled output"); + print(" -g, --include-debug-symbols include debug symbols in the compiled output"); + print(" -T, --include-type-signatures include type signatures in the compiled output"); + print(" -O, --compress compress the compiled output"); + print(" -O2, --inline-msg-send inline objj_msgSend function in the compiled output"); print(""); - print(" --help print this help"); + print(" --help print this help"); return; } diff --git a/Objective-J/ObjJAcornCompiler.js b/Objective-J/ObjJAcornCompiler.js index 89d1d6d76..fb53b2481 100644 --- a/Objective-J/ObjJAcornCompiler.js +++ b/Objective-J/ObjJAcornCompiler.js @@ -365,9 +365,6 @@ var MethodDef = function(name, types) this.types = types; } -var currentCompilerFlags = 0; -var currentGccCompilerFlags = ""; - var reservedIdentifiers = exports.acorn.makePredicate("self _cmd undefined localStorage arguments"); var wordPrefixOperators = exports.acorn.makePredicate("delete in instanceof new typeof void"); @@ -425,6 +422,16 @@ var ObjJAcornCompiler = function(/*String*/ aString, /*CFURL*/ aURL, /*unsigned* compile(this.tokens, new Scope(null ,{ compiler: this }), pass === 2 ? pass2 : pass1); } +ObjJAcornCompiler.Flags = { }; + +ObjJAcornCompiler.Flags.IncludeDebugSymbols = 1 << 0; +ObjJAcornCompiler.Flags.IncludeTypeSignatures = 1 << 1; +ObjJAcornCompiler.Flags.Generate = 1 << 2; +ObjJAcornCompiler.Flags.InlineMsgSend = 1 << 3; + +var currentCompilerFlags = ObjJAcornCompiler.Flags.IncludeTypeSignatures; +var currentGccCompilerFlags = ""; + exports.ObjJAcornCompiler = ObjJAcornCompiler; exports.ObjJAcornCompiler.compileToExecutable = function(/*String*/ aString, /*CFURL*/ aURL, /*unsigned*/ flags) @@ -494,25 +501,25 @@ exports.setCurrentGccCompilerFlags = function(/*String*/ compilerFlags) var args = compilerFlags.split(" "), count = args.length, - objjcFlags = 0; + objjcFlags = ObjJAcornCompiler.Flags.IncludeTypeSignatures; for (var index = 0; index < count; ++index) { var argument = args[index]; if (argument.indexOf("-g") === 0) - objjcFlags |= ObjectiveJ.ObjJAcornCompiler.Flags.IncludeDebugSymbols; - + objjcFlags |= ObjJAcornCompiler.Flags.IncludeDebugSymbols; else if (argument.indexOf("-O") === 0) { - objjcFlags |= ObjectiveJ.ObjJAcornCompiler.Flags.Compress; - // FIXME: currently we are sending in '-O2' when we want InlineMsgSend. Here we only check if we it is '-O...'. + objjcFlags |= ObjJAcornCompiler.Flags.Compress; + // FIXME: currently we are sending in '-O2' when we want InlineMsgSend. Here we only check if it is '-O...'. // Maybe we should have some other option for this if (argument.length > 2) - objjcFlags |= ObjectiveJ.ObjJAcornCompiler.Flags.InlineMsgSend; + objjcFlags |= ObjJAcornCompiler.Flags.InlineMsgSend; } - else if (argument.indexOf("-G") === 0) - objjcFlags |= ObjectiveJ.ObjJAcornCompiler.Flags.Generate; + objjcFlags |= ObjJAcornCompiler.Flags.Generate; + else if (argument.indexOf("-T") === 0) + objjcFlags &= ~ObjJAcornCompiler.Flags.IncludeTypeSignatures; } currentCompilerFlags = objjcFlags; @@ -533,13 +540,6 @@ exports.currentCompilerFlags = function(/*String*/ compilerFlags) return currentCompilerFlags; } -ObjJAcornCompiler.Flags = { }; - -ObjJAcornCompiler.Flags.IncludeDebugSymbols = 1 << 0; -ObjJAcornCompiler.Flags.IncludeTypeSignatures = 1 << 1; -ObjJAcornCompiler.Flags.Generate = 1 << 2; -ObjJAcornCompiler.Flags.InlineMsgSend = 1 << 3; - ObjJAcornCompiler.prototype.addWarning = function(/* Warning */ aWarning) { this.warnings.push(aWarning); @@ -2325,7 +2325,7 @@ MethodDeclarationStatement: function(node, st, c) { compiler.jsBuffer.concat("Nil\n"); } - if (compiler.flags & ObjJAcornCompiler.Flags.IncludeDebugSymbols) + if (compiler.flags & ObjJAcornCompiler.Flags.IncludeTypeSignatures) compiler.jsBuffer.concat(","+JSON.stringify(types)); compiler.jsBuffer.concat(")"); diff --git a/Tests/Objective-J/Preprocessor/OutputTests/Class/accessors.js b/Tests/Objective-J/Preprocessor/OutputTests/Class/accessors.js index ae78cbb53..faa0a5474 100644 --- a/Tests/Objective-J/Preprocessor/OutputTests/Class/accessors.js +++ b/Tests/Objective-J/Preprocessor/OutputTests/Class/accessors.js @@ -5,7 +5,7 @@ if(!the_class){ throw new SyntaxError("*** Could not find definition for class \"TestClass\""); } var meta_class=the_class.isa; -class_addIvars(the_class,[new objj_ivar("ivar")]); +class_addIvars(the_class,[new objj_ivar("ivar","Type")]); class_addMethods(the_class,[new objj_method(sel_getUid("ivar"),function $TestClass__ivar(_1,_2){ return _1.ivar; },["Type"]),new objj_method(sel_getUid("setIvar:"),function $TestClass__setIvar_(_3,_4,_5){ diff --git a/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-multiple-ivars.js b/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-multiple-ivars.js index 8cf16dc3b..622661139 100644 --- a/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-multiple-ivars.js +++ b/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-multiple-ivars.js @@ -1,6 +1,6 @@ var the_class = objj_allocateClassPair(Nil, "TestClass"), meta_class = the_class.isa; -class_addIvars(the_class,[new objj_ivar("ivar"), new objj_ivar("array"), new objj_ivar("string"), new objj_ivar("integer")]); +class_addIvars(the_class,[new objj_ivar("ivar","Type"), new objj_ivar("array","CPArray"), new objj_ivar("string","CPString"), new objj_ivar("integer","int")]); objj_registerClassPair(the_class); diff --git a/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-one-ivar.js b/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-one-ivar.js index 165c23dc8..a0327a8c8 100644 --- a/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-one-ivar.js +++ b/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-one-ivar.js @@ -2,6 +2,6 @@ var the_class = objj_allocateClassPair(Nil, "TestClass"), meta_class = the_class.isa; -class_addIvars(the_class,[new objj_ivar("ivar")]); +class_addIvars(the_class,[new objj_ivar("ivar","Type")]); objj_registerClassPair(the_class); diff --git a/Tests/Objective-J/Preprocessor/OutputTests/Misc/ref-self.js b/Tests/Objective-J/Preprocessor/OutputTests/Misc/ref-self.js index 778d931d6..b73f3c35f 100644 --- a/Tests/Objective-J/Preprocessor/OutputTests/Misc/ref-self.js +++ b/Tests/Objective-J/Preprocessor/OutputTests/Misc/ref-self.js @@ -1,5 +1,5 @@ {var the_class = objj_allocateClassPair(Nil, "TC"), -meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_control")]);objj_registerClassPair(the_class); +meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_control","id")]);objj_registerClassPair(the_class); class_addMethods(the_class, [new objj_method(sel_getUid("a"), function $TC__a(self, _cmd) { function(__input) { if (arguments.length) return self._control = __input; return self._control; }; diff --git a/Tests/Objective-J/Preprocessor/OutputTests/OutputTest.j b/Tests/Objective-J/Preprocessor/OutputTests/OutputTest.j index 8b19d2062..34150d7f2 100644 --- a/Tests/Objective-J/Preprocessor/OutputTests/OutputTest.j +++ b/Tests/Objective-J/Preprocessor/OutputTests/OutputTest.j @@ -53,12 +53,12 @@ var FILENAMES = [ correctInlined = FILE.exists(p) ? FILE.read(p) : correct; // Get inlined version if it exists. Otherwise use the regular one. [self assertNoThrow:function() { - preprocessed = ObjectiveJ.ObjJAcornCompiler.compileToExecutable(unpreprocessed, nil, ObjectiveJ.ObjJAcornCompiler.Flags.IncludeDebugSymbols/* | ObjectiveJ.ObjJAcornCompiler.Flags.IncludeTypeSignatures*/).code(); + preprocessed = ObjectiveJ.ObjJAcornCompiler.compileToExecutable(unpreprocessed, nil, ObjectiveJ.ObjJAcornCompiler.Flags.IncludeDebugSymbols | ObjectiveJ.ObjJAcornCompiler.Flags.IncludeTypeSignatures).code(); preprocessed = compressor.compress(preprocessed, { charset : "UTF-8", useServer : true }); correct = compressor.compress(correct, { charset : "UTF-8", useServer : true }); // Get an Inlined version - preprocessedInlined = ObjectiveJ.ObjJAcornCompiler.compileToExecutable(unpreprocessed, nil, ObjectiveJ.ObjJAcornCompiler.Flags.IncludeDebugSymbols | ObjectiveJ.ObjJAcornCompiler.Flags.InlineMsgSend/* | ObjectiveJ.ObjJAcornCompiler.Flags.IncludeTypeSignatures*/).code(); + preprocessedInlined = ObjectiveJ.ObjJAcornCompiler.compileToExecutable(unpreprocessed, nil, ObjectiveJ.ObjJAcornCompiler.Flags.IncludeDebugSymbols | ObjectiveJ.ObjJAcornCompiler.Flags.InlineMsgSend | ObjectiveJ.ObjJAcornCompiler.Flags.IncludeTypeSignatures).code(); preprocessedInlined = compressor.compress(preprocessedInlined, { charset : "UTF-8", useServer : true }); correctInlined = compressor.compress(correctInlined, { charset : "UTF-8", useServer : true }); }]; diff --git a/Tools/capp/Resources/Templates/Application/index-debug.html b/Tools/capp/Resources/Templates/Application/index-debug.html index 91f96346c..652466be6 100644 --- a/Tools/capp/Resources/Templates/Application/index-debug.html +++ b/Tools/capp/Resources/Templates/Application/index-debug.html @@ -33,8 +33,18 @@