├── .gitattributes ├── .idea ├── .name ├── watcherTasks.xml ├── scopes │ └── scope_settings.xml ├── dictionaries │ └── aparajita.xml ├── misc.xml ├── vcs.xml ├── encodings.xml ├── jsLinters │ ├── eslint.xml │ ├── jslint.xml │ └── jshint.xml ├── inspectionProfiles │ └── profiles_settings.xml ├── modules.xml ├── eslintPlugin.xml ├── jsLibraryMappings.xml ├── webResources.xml ├── codeStyleSettings.xml ├── libraries │ └── node_modules.xml └── cappuccino.compiler.iml ├── .npmrc ├── .eslintignore ├── test ├── fixtures │ ├── cli │ │ ├── code │ │ │ ├── src │ │ │ │ ├── ast-0.txt │ │ │ │ ├── ast-2.txt │ │ │ │ ├── stdin.js │ │ │ │ ├── inline-msg-send.j │ │ │ │ ├── allow-hash-bang.js │ │ │ │ ├── source-map.txt │ │ │ │ ├── source-map-only.txt │ │ │ │ ├── no-method-names.j │ │ │ │ ├── no-type-signatures.j │ │ │ │ ├── objj-scope.j │ │ │ │ ├── format-name.js │ │ │ │ ├── format-path.js │ │ │ │ ├── format-name.json.js │ │ │ │ ├── environment-browser.js │ │ │ │ └── environment-node.js │ │ │ └── dest │ │ │ │ ├── stdin.js │ │ │ │ ├── allow-hash-bang.js │ │ │ │ ├── environment-browser.js │ │ │ │ ├── environment-node.js │ │ │ │ ├── objj-scope.js │ │ │ │ ├── source-map-only.txt │ │ │ │ ├── format-name.js │ │ │ │ ├── format-path.js │ │ │ │ ├── format-name.json.js │ │ │ │ ├── inline-msg-send.js │ │ │ │ ├── source-map.txt │ │ │ │ ├── no-type-signatures.js │ │ │ │ ├── no-method-names.js │ │ │ │ ├── ast-0.txt │ │ │ │ └── ast-2.txt │ │ ├── misc │ │ │ ├── list-formats.txt │ │ │ └── list-optional-warnings.txt │ │ └── exceptions │ │ │ ├── src │ │ │ ├── format-invalid.json │ │ │ ├── quiet.j │ │ │ ├── strict-semicolons.js │ │ │ ├── module.js │ │ │ ├── max-errors-1.j │ │ │ ├── ignore-warnings.j │ │ │ ├── max-errors-0.j │ │ │ ├── warnings-none.j │ │ │ ├── warnings-all.j │ │ │ ├── warnings-enable-disable.j │ │ │ └── warnings-list.j │ │ │ └── dest │ │ │ ├── quiet.txt │ │ │ ├── module.txt │ │ │ ├── strict-semicolons.txt │ │ │ ├── ignore-warnings.txt │ │ │ ├── max-errors-1.txt │ │ │ ├── warnings-none.txt │ │ │ ├── warnings-list.txt │ │ │ ├── warnings-enable-disable.txt │ │ │ ├── warnings-all.txt │ │ │ └── max-errors-0.txt │ ├── exceptions │ │ ├── src │ │ │ ├── debugger.j │ │ │ ├── stdin.j │ │ │ ├── bad-import.j │ │ │ ├── circular-import.j │ │ │ ├── imports │ │ │ │ ├── circular.j │ │ │ │ ├── acorn-error.j │ │ │ │ ├── file-scope.j │ │ │ │ ├── foo.j │ │ │ │ └── bar.j │ │ │ ├── import-parse-error.j │ │ │ ├── recursive-import.j │ │ │ ├── import-stack.j │ │ │ ├── reserved-words.j │ │ │ ├── super-outside.j │ │ │ ├── import-scope.j │ │ │ ├── read-only-globals.j │ │ │ ├── duplicate-ivars.j │ │ │ ├── dereference.j │ │ │ ├── super-root.j │ │ │ ├── missing-dependencies.j │ │ │ ├── duplicate-methods.j │ │ │ ├── suggestions.j │ │ │ ├── duplicate-global-symbols.j │ │ │ ├── accessors.j │ │ │ ├── self.j │ │ │ ├── symbol-redefinition.j │ │ │ ├── protocol-conformance.j │ │ │ ├── identifiers.j │ │ │ ├── method-types.j │ │ │ └── shadowed-vars.j │ │ └── dest │ │ │ ├── stdin.txt │ │ │ ├── debugger.txt │ │ │ ├── import-scope.txt │ │ │ ├── super-root.txt │ │ │ ├── bad-import.txt │ │ │ ├── recursive-import.txt │ │ │ ├── super-outside.txt │ │ │ ├── circular-import.txt │ │ │ ├── dereference.txt │ │ │ ├── import-parse-error.txt │ │ │ ├── read-only-globals.txt │ │ │ ├── reserved-words.txt │ │ │ ├── duplicate-ivars.txt │ │ │ ├── suggestions.txt │ │ │ ├── accessors.txt │ │ │ ├── import-stack.txt │ │ │ ├── self.txt │ │ │ ├── duplicate-methods.txt │ │ │ ├── missing-dependencies.txt │ │ │ ├── identifiers.txt │ │ │ ├── duplicate-global-symbols.txt │ │ │ └── protocol-conformance.txt │ ├── objj-nodes │ │ ├── src │ │ │ ├── import │ │ │ │ ├── foo.j │ │ │ │ ├── foo │ │ │ │ │ ├── bar.j │ │ │ │ │ └── import-relative.j │ │ │ │ ├── chained.j │ │ │ │ ├── import-chain.j │ │ │ │ ├── import-local.j │ │ │ │ └── import-cache.j │ │ │ ├── selector-literal-expression.j │ │ │ ├── array-literal.j │ │ │ ├── array-literal-inline.j │ │ │ ├── accessors-inline.j │ │ │ ├── protocol-literal-expression.j │ │ │ ├── global-statement.j │ │ │ ├── dictionary-literal.j │ │ │ ├── dictionary-literal-inline.j │ │ │ ├── no-method-names.j │ │ │ ├── no-types.j │ │ │ ├── typedef-statement.j │ │ │ ├── class-statement.j │ │ │ ├── self-super.j │ │ │ ├── reference-dereference.j │ │ │ ├── protocol-declaration.j │ │ │ ├── accessors.j │ │ │ ├── method-declaration.j │ │ │ ├── class-declaration.j │ │ │ ├── message-send-expression-inline.j │ │ │ └── message-send-expression.j │ │ └── dest │ │ │ ├── import │ │ │ ├── import-cache.js │ │ │ ├── import-chain.js │ │ │ ├── foo │ │ │ │ └── import-relative.js │ │ │ └── import-local.js │ │ │ ├── selector-literal-expression.js │ │ │ ├── global-statement.js │ │ │ ├── protocol-literal-expression.js │ │ │ ├── array-literal.js │ │ │ ├── dictionary-literal.js │ │ │ ├── class-statement.js │ │ │ ├── array-literal-inline.js │ │ │ ├── no-types.js │ │ │ ├── dictionary-literal-inline.js │ │ │ ├── no-method-names.js │ │ │ ├── typedef-statement.js │ │ │ ├── accessors-inline.js │ │ │ ├── self-super.js │ │ │ ├── reference-dereference.js │ │ │ ├── method-declaration.js │ │ │ ├── protocol-declaration.js │ │ │ ├── class-declaration.js │ │ │ ├── message-send-expression-inline.js │ │ │ ├── message-send-expression.js │ │ │ └── accessors.js │ └── js-nodes │ │ ├── dest │ │ ├── debugger-statement.js │ │ ├── logical-expression.js │ │ ├── this-expression.js │ │ ├── throw-statement.js │ │ ├── conditional-expression.js │ │ ├── update-expression.js │ │ ├── member-expression.js │ │ ├── var-declaration.js │ │ ├── literal.js │ │ ├── new-expression.js │ │ ├── binary-expression.js │ │ ├── for-in-statement.js │ │ ├── sequence-expression.js │ │ ├── function-declaration.js │ │ ├── while-statement.js │ │ ├── object-expression.js │ │ ├── do-while-statement.js │ │ ├── array-expression.js │ │ ├── labeled-statement.js │ │ ├── assignment-expression.js │ │ ├── call-expression.js │ │ ├── with-statement.js │ │ ├── unary-expression.js │ │ ├── block-statement.js │ │ ├── switch-statement.js │ │ ├── function-expression.js │ │ ├── for-statement.js │ │ ├── break-statement.js │ │ ├── continue-statement.js │ │ ├── try-statement.js │ │ ├── return-statement.js │ │ └── if-statement.js │ │ └── src │ │ ├── debugger-statement.js │ │ ├── logical-expression.js │ │ ├── this-expression.js │ │ ├── throw-statement.js │ │ ├── conditional-expression.js │ │ ├── update-expression.js │ │ ├── member-expression.js │ │ ├── var-declaration.js │ │ ├── literal.js │ │ ├── new-expression.js │ │ ├── for-in-statement.js │ │ ├── sequence-expression.js │ │ ├── function-declaration.js │ │ ├── while-statement.js │ │ ├── object-expression.js │ │ ├── do-while-statement.js │ │ ├── labeled-statement.js │ │ ├── array-expression.js │ │ ├── assignment-expression.js │ │ ├── with-statement.js │ │ ├── unary-expression.js │ │ ├── block-statement.js │ │ ├── switch-statement.js │ │ ├── function-expression.js │ │ ├── call-expression.js │ │ ├── for-statement.js │ │ ├── break-statement.js │ │ ├── try-statement.js │ │ ├── return-statement.js │ │ ├── continue-statement.js │ │ ├── binary-expression.js │ │ └── if-statement.js ├── .eslintrc.yml ├── mocha.opts ├── code.js └── exceptions.js ├── index.js ├── .eslintrc.yml ├── bin └── objjc.js ├── .jscsrc ├── .npmignore ├── .gitignore ├── .istanbul.yml ├── .editorconfig ├── .travis.yml ├── appveyor.yml ├── lib ├── reporter.js ├── nullbuffer.js ├── indentation.js ├── exceptions.js ├── utils.js └── stringbuffer.js ├── LICENSE └── package.json /.gitattributes: -------------------------------------------------------------------------------- 1 | * text eol=lf 2 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | cappuccino.compiler -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | save-prefix = "~" 2 | access=public 3 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | test/coverage 2 | test/fixtures 3 | -------------------------------------------------------------------------------- /test/fixtures/cli/code/src/ast-0.txt: -------------------------------------------------------------------------------- 1 | var x = 7; 2 | -------------------------------------------------------------------------------- /test/fixtures/cli/code/src/ast-2.txt: -------------------------------------------------------------------------------- 1 | var x = 7; 2 | -------------------------------------------------------------------------------- /test/fixtures/cli/code/src/stdin.js: -------------------------------------------------------------------------------- 1 | var x = 7; 2 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/src/debugger.j: -------------------------------------------------------------------------------- 1 | debugger; 2 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/src/stdin.j: -------------------------------------------------------------------------------- 1 | var x = y; 2 | -------------------------------------------------------------------------------- /test/.eslintrc.yml: -------------------------------------------------------------------------------- 1 | --- 2 | env: 3 | mocha: true 4 | -------------------------------------------------------------------------------- /test/fixtures/cli/code/dest/stdin.js: -------------------------------------------------------------------------------- 1 | var x = 7; 2 | 3 | -------------------------------------------------------------------------------- /test/fixtures/cli/misc/list-formats.txt: -------------------------------------------------------------------------------- 1 | cappuccino 2 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/src/import/foo.j: -------------------------------------------------------------------------------- 1 | @global X 2 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/src/import/foo/bar.j: -------------------------------------------------------------------------------- 1 | Y = 7; 2 | -------------------------------------------------------------------------------- /test/mocha.opts: -------------------------------------------------------------------------------- 1 | --reporter spec 2 | --inline-diffs 3 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/dest/debugger-statement.js: -------------------------------------------------------------------------------- 1 | debugger; 2 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/src/debugger-statement.js: -------------------------------------------------------------------------------- 1 | debugger; 2 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/dest/logical-expression.js: -------------------------------------------------------------------------------- 1 | x = a || b; 2 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/src/logical-expression.js: -------------------------------------------------------------------------------- 1 | x = a || b; 2 | -------------------------------------------------------------------------------- /test/fixtures/cli/code/dest/allow-hash-bang.js: -------------------------------------------------------------------------------- 1 | x = "hello!"; 2 | 3 | -------------------------------------------------------------------------------- /test/fixtures/cli/exceptions/src/format-invalid.json: -------------------------------------------------------------------------------- 1 | "bad": "worse" 2 | -------------------------------------------------------------------------------- /test/fixtures/cli/exceptions/src/quiet.j: -------------------------------------------------------------------------------- 1 | // warning 2 | var x = y; 3 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/dest/this-expression.js: -------------------------------------------------------------------------------- 1 | this.doSomething(); 2 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/src/this-expression.js: -------------------------------------------------------------------------------- 1 | this.doSomething(); 2 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | exports.Runner = require("./lib/runner"); 4 | -------------------------------------------------------------------------------- /test/fixtures/cli/code/dest/environment-browser.js: -------------------------------------------------------------------------------- 1 | var x = window; 2 | 3 | -------------------------------------------------------------------------------- /test/fixtures/cli/code/dest/environment-node.js: -------------------------------------------------------------------------------- 1 | var x = __filename; 2 | 3 | -------------------------------------------------------------------------------- /test/fixtures/cli/code/dest/objj-scope.js: -------------------------------------------------------------------------------- 1 | function one() 2 | { 3 | } 4 | 5 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/dest/throw-statement.js: -------------------------------------------------------------------------------- 1 | throw new Error("Doh!"); 2 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/src/throw-statement.js: -------------------------------------------------------------------------------- 1 | throw new Error("Doh!"); 2 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/src/bad-import.j: -------------------------------------------------------------------------------- 1 | // Doesn't exist 2 | @import "foo.j" 3 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/src/circular-import.j: -------------------------------------------------------------------------------- 1 | @import "imports/circular.j" 2 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/src/imports/circular.j: -------------------------------------------------------------------------------- 1 | @import "../circular-import.j" 2 | -------------------------------------------------------------------------------- /.eslintrc.yml: -------------------------------------------------------------------------------- 1 | --- 2 | extends: cappuccino 3 | 4 | globals: 5 | DEBUG: true 6 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/src/import-parse-error.j: -------------------------------------------------------------------------------- 1 | @import "imports/acorn-error.j" 2 | -------------------------------------------------------------------------------- /test/fixtures/cli/code/src/inline-msg-send.j: -------------------------------------------------------------------------------- 1 | @class Foo 2 | 3 | [Foo bar:7 baz:@"foo"]; 4 | -------------------------------------------------------------------------------- /test/fixtures/cli/exceptions/src/strict-semicolons.js: -------------------------------------------------------------------------------- 1 | var x = 7 2 | 3 | console.log(x); 4 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/dest/conditional-expression.js: -------------------------------------------------------------------------------- 1 | x = y ? "yeah! :)" : "bummer :("; 2 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/src/conditional-expression.js: -------------------------------------------------------------------------------- 1 | x = y ? "yeah! :)" : "bummer :("; 2 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/src/import/chained.j: -------------------------------------------------------------------------------- 1 | @import "foo/bar.j" 2 | 3 | var y = Y; 4 | -------------------------------------------------------------------------------- /test/fixtures/cli/code/src/allow-hash-bang.js: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/node 2 | 3 | x = "hello!"; 4 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/src/import/import-chain.j: -------------------------------------------------------------------------------- 1 | @import "chained.j" 2 | 3 | var y = Y; 4 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/src/recursive-import.j: -------------------------------------------------------------------------------- 1 | // Circular import 2 | @import "recursive-import.j" 3 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/src/update-expression.js: -------------------------------------------------------------------------------- 1 | var a = 7; 2 | 3 | ++a; 4 | a++; 5 | --a; 6 | a--; 7 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/src/selector-literal-expression.j: -------------------------------------------------------------------------------- 1 | var sel = @selector(this:is:a:test:); 2 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/src/import-stack.j: -------------------------------------------------------------------------------- 1 | @import "imports/foo.j" 2 | 3 | // warning 4 | var x = y; 5 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/dest/update-expression.js: -------------------------------------------------------------------------------- 1 | var a = 7; 2 | 3 | ++a; 4 | a++; 5 | --a; 6 | a--; 7 | -------------------------------------------------------------------------------- /test/fixtures/cli/code/src/source-map.txt: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var x = 7; 4 | 5 | function test() 6 | { 7 | } 8 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/src/array-literal.j: -------------------------------------------------------------------------------- 1 | x = @[]; 2 | x = @["one"]; 3 | x = @["one", "two", 3, four, 5.0]; 4 | -------------------------------------------------------------------------------- /test/fixtures/cli/code/src/source-map-only.txt: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var x = 7; 4 | 5 | function test() 6 | { 7 | } 8 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/src/reserved-words.j: -------------------------------------------------------------------------------- 1 | var arguments = false, 2 | NaN = false, 3 | undefined = false; 4 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/dest/member-expression.js: -------------------------------------------------------------------------------- 1 | x = one.two.three; 2 | x = one[two.three]; 3 | x = one[two[three]]; 4 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/dest/var-declaration.js: -------------------------------------------------------------------------------- 1 | var a; 2 | 3 | var a, 4 | b; 5 | 6 | var a = 7, 7 | b = 13; 8 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/src/member-expression.js: -------------------------------------------------------------------------------- 1 | x = one.two.three; 2 | x = one[two.three]; 3 | x = one[two[three]]; 4 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/src/var-declaration.js: -------------------------------------------------------------------------------- 1 | var a; 2 | 3 | var a, 4 | b; 5 | 6 | var a = 7, 7 | b = 13; 8 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/src/array-literal-inline.j: -------------------------------------------------------------------------------- 1 | x = @[]; 2 | x = @["one"]; 3 | x = @["one", "two", 3, four, 5.0]; 4 | -------------------------------------------------------------------------------- /test/fixtures/cli/code/src/no-method-names.j: -------------------------------------------------------------------------------- 1 | @implementation Test 2 | 3 | - (void)one:(int)two 4 | { 5 | } 6 | 7 | @end 8 | -------------------------------------------------------------------------------- /test/fixtures/cli/code/src/no-type-signatures.j: -------------------------------------------------------------------------------- 1 | @implementation Test 2 | 3 | - (void)one:(int)two 4 | { 5 | } 6 | 7 | @end 8 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/src/super-outside.j: -------------------------------------------------------------------------------- 1 | // 'super' outside of function or class (acorn error) 2 | [super doSomething]; 3 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/dest/literal.js: -------------------------------------------------------------------------------- 1 | var s1 = "string", 2 | s2 = "string", 3 | num = 7, 4 | re = /foo|bar/; 5 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/src/literal.js: -------------------------------------------------------------------------------- 1 | var s1 = "string", 2 | s2 = @"string", 3 | num = 7, 4 | re = /foo|bar/; 5 | -------------------------------------------------------------------------------- /test/fixtures/cli/code/src/objj-scope.j: -------------------------------------------------------------------------------- 1 | // This will be transformed into: 2 | // one = function() 3 | function one() 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/src/import/foo/import-relative.j: -------------------------------------------------------------------------------- 1 | @import "../foo.j" 2 | 3 | // X is defined in foo.j 4 | var x = X; 5 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/dest/import/import-cache.js: -------------------------------------------------------------------------------- 1 | (function() 2 | { 3 | // @import "foo.j" 4 | // @import "foo.j" 5 | })(); 6 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/src/accessors-inline.j: -------------------------------------------------------------------------------- 1 | @implementation Accessors 2 | { 3 | int copyMe @accessors(copy); 4 | } 5 | @end 6 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/src/protocol-literal-expression.j: -------------------------------------------------------------------------------- 1 | @protocol SomeProtocol 2 | @end 3 | 4 | var p = @protocol(SomeProtocol); 5 | -------------------------------------------------------------------------------- /test/fixtures/cli/code/src/format-name.js: -------------------------------------------------------------------------------- 1 | var x=27; 2 | if (x>7) { 3 | console.log( true ); 4 | } else { 5 | console.log( false); 6 | } 7 | -------------------------------------------------------------------------------- /test/fixtures/cli/code/src/format-path.js: -------------------------------------------------------------------------------- 1 | var x=27; 2 | if (x>7) { 3 | console.log( true ); 4 | } else { 5 | console.log( false); 6 | } 7 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/dest/import/import-chain.js: -------------------------------------------------------------------------------- 1 | (function() 2 | { 3 | // @import "chained.j" 4 | 5 | var y = Y; 6 | })(); 7 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/dest/selector-literal-expression.js: -------------------------------------------------------------------------------- 1 | (function() 2 | { 3 | var sel = sel_getUid("this:is:a:test:"); 4 | })(); 5 | -------------------------------------------------------------------------------- /bin/objjc.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | "use strict"; 3 | 4 | const cli = require("../lib/cli.js"); 5 | 6 | process.exit(cli.run(process.argv)); 7 | -------------------------------------------------------------------------------- /test/fixtures/cli/code/src/format-name.json.js: -------------------------------------------------------------------------------- 1 | var x=27; 2 | if (x>7) { 3 | console.log( true ); 4 | } else { 5 | console.log( false); 6 | } 7 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/dest/import/foo/import-relative.js: -------------------------------------------------------------------------------- 1 | (function() 2 | { 3 | // @import "../foo.j" 4 | 5 | var x = X; 6 | })(); 7 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/src/imports/acorn-error.j: -------------------------------------------------------------------------------- 1 | var x = 7; 2 | 3 | // acorn parse error at ==== 4 | if (x ==== 7) 5 | console.log("Seven"); 6 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/src/imports/file-scope.j: -------------------------------------------------------------------------------- 1 | // This declaration is in file scope, not visible to files that import this file 2 | var x = 7; 3 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/src/new-expression.js: -------------------------------------------------------------------------------- 1 | x = new Error; 2 | x = new Error(); 3 | x = new Error("test"); 4 | x = new Error("test", something()); 5 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/dest/new-expression.js: -------------------------------------------------------------------------------- 1 | x = new Error(); 2 | x = new Error(); 3 | x = new Error("test"); 4 | x = new Error("test", something()); 5 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/src/global-statement.j: -------------------------------------------------------------------------------- 1 | @global Foo 2 | @global Bar, Foobar 3 | 4 | var foo = Foo, 5 | bar = Bar, 6 | foobar = Foobar; 7 | -------------------------------------------------------------------------------- /test/fixtures/cli/code/dest/source-map-only.txt: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["source-map-only.txt"],"names":[],"mappings":"AAAA;;AAEA,IAAI,IAAI","sourceRoot":"."} 2 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/dest/binary-expression.js: -------------------------------------------------------------------------------- 1 | x = (y ? 7 : 31) > 27; 2 | x = (7 + 13) * 27; 3 | x = 7 + (13 + 27); 4 | x = 7 * 13 + 27 << 31 / 2 % (10 - 3); 5 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/dest/for-in-statement.js: -------------------------------------------------------------------------------- 1 | for (var prop in object) 2 | doSomething(); 3 | 4 | for (var prop in object) 5 | { 6 | doSomething(); 7 | } 8 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/src/for-in-statement.js: -------------------------------------------------------------------------------- 1 | for (var prop in object) 2 | doSomething(); 3 | 4 | for (var prop in object) 5 | { 6 | doSomething(); 7 | } 8 | -------------------------------------------------------------------------------- /.idea/watcherTasks.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /test/fixtures/cli/exceptions/src/module.js: -------------------------------------------------------------------------------- 1 | // This should generate a reserved word warning when --module is used, 2 | // because that forces strict mode. 3 | var export; 4 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/dest/sequence-expression.js: -------------------------------------------------------------------------------- 1 | doSomething(), doSomethingElse(); 2 | 3 | for (var i = 0, count = array.length; i < count; i++) 4 | doSomething(i); 5 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/src/sequence-expression.js: -------------------------------------------------------------------------------- 1 | doSomething(), doSomethingElse(); 2 | 3 | for (var i = 0, count = array.length; i < count; i++) 4 | doSomething(i); 5 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/src/dictionary-literal.j: -------------------------------------------------------------------------------- 1 | x = @{}; 2 | 3 | x = @{ @"key": "value" }; 4 | 5 | x = @{ 6 | @"name": "Tiny Tim", 7 | @"flower": "tulips" 8 | }; 9 | -------------------------------------------------------------------------------- /test/fixtures/cli/code/dest/format-name.js: -------------------------------------------------------------------------------- 1 | var x = 27; 2 | 3 | if (x > 7) 4 | { 5 | console.log(true); 6 | } 7 | else 8 | { 9 | console.log(false); 10 | } 11 | 12 | -------------------------------------------------------------------------------- /test/fixtures/cli/code/dest/format-path.js: -------------------------------------------------------------------------------- 1 | var x = 27; 2 | 3 | if (x > 7) 4 | { 5 | console.log(true); 6 | } 7 | else 8 | { 9 | console.log(false); 10 | } 11 | 12 | -------------------------------------------------------------------------------- /.idea/scopes/scope_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.jscsrc: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": ["jscs-cappuccino"], 3 | "preset": "cappuccino", 4 | "excludeFiles": [ 5 | "coverage/**", 6 | "test/fixtures/**" 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /test/fixtures/cli/code/dest/format-name.json.js: -------------------------------------------------------------------------------- 1 | var x = 27; 2 | 3 | if (x > 7) 4 | { 5 | console.log(true); 6 | } 7 | else 8 | { 9 | console.log(false); 10 | } 11 | 12 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/src/import-scope.j: -------------------------------------------------------------------------------- 1 | @import "imports/file-scope.j" 2 | 3 | // x is defined as a var in file-scope.j, but it's in file scope, so undefined here 4 | var a = x; 5 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/dest/function-declaration.js: -------------------------------------------------------------------------------- 1 | function test() 2 | { 3 | } 4 | 5 | function test(one) 6 | { 7 | } 8 | 9 | function test(one, two, three) 10 | { 11 | } 12 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/src/function-declaration.js: -------------------------------------------------------------------------------- 1 | function test() 2 | { 3 | } 4 | 5 | function test(one) 6 | { 7 | } 8 | 9 | function test(one, two, three) 10 | { 11 | } 12 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/src/dictionary-literal-inline.j: -------------------------------------------------------------------------------- 1 | x = @{}; 2 | 3 | x = @{ @"key": "value" }; 4 | 5 | x = @{ 6 | @"name": "Tiny Tim", 7 | @"flower": "tulips" 8 | }; 9 | -------------------------------------------------------------------------------- /test/fixtures/cli/code/src/environment-browser.js: -------------------------------------------------------------------------------- 1 | // This should not generate a warning because 'window' is 2 | // a known predefined global in the 'browser' environment. 3 | var x = window; 4 | -------------------------------------------------------------------------------- /test/fixtures/cli/code/src/environment-node.js: -------------------------------------------------------------------------------- 1 | // This should not generate a warning because '__filename' is 2 | // a known predefined global in the 'node' environment. 3 | var x = __filename; 4 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/dest/while-statement.js: -------------------------------------------------------------------------------- 1 | while (i > 10) 2 | doSomething(); 3 | 4 | while (true) 5 | { 6 | doSomething(); 7 | 8 | if (stop) 9 | break; 10 | } 11 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/src/while-statement.js: -------------------------------------------------------------------------------- 1 | while (i > 10) 2 | doSomething(); 3 | 4 | while (true) 5 | { 6 | doSomething(); 7 | 8 | if (stop) 9 | break; 10 | } 11 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/src/no-method-names.j: -------------------------------------------------------------------------------- 1 | @implementation NoMethodNames 2 | 3 | + (void)initialize 4 | { 5 | } 6 | 7 | - (int)methodOne:(id)param 8 | { 9 | } 10 | 11 | @end 12 | -------------------------------------------------------------------------------- /test/fixtures/cli/exceptions/dest/quiet.txt: -------------------------------------------------------------------------------- 1 | 2 | test/fixtures/cli/exceptions/src/quiet.j:2:9: warning: reference to unknown identifier 'y' 3 | var x = y; 4 | ^ 5 | 6 | 1 warning generated. 7 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/dest/object-expression.js: -------------------------------------------------------------------------------- 1 | var o = {}, 2 | o2 = { 3 | seven: 7, 4 | thirteen: "13", 5 | twentySeven: 31 - 4, 6 | "thirty-one": 31 7 | }; 8 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/src/object-expression.js: -------------------------------------------------------------------------------- 1 | var o = {}, 2 | o2 = { 3 | seven: 7, 4 | thirteen: "13", 5 | twentySeven: 31 - 4, 6 | "thirty-one": 31 7 | }; 8 | -------------------------------------------------------------------------------- /.idea/dictionaries/aparajita.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | optionator 5 | 6 | 7 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .editorconfig 2 | .eslintignore 3 | .eslintrc 4 | .gitignore 5 | .istanbul.yml 6 | .jscsrc 7 | .npmignore 8 | .travis.yml 9 | appveyor.yml 10 | 11 | .idea/ 12 | coverage/ 13 | test/ 14 | -------------------------------------------------------------------------------- /test/fixtures/cli/misc/list-optional-warnings.txt: -------------------------------------------------------------------------------- 1 | +debugger 2 | +implicit-globals 3 | -parameter-types 4 | +shadowed-vars 5 | +unimplemented-protocol-methods 6 | +unknown-identifiers 7 | -unknown-types 8 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/dest/do-while-statement.js: -------------------------------------------------------------------------------- 1 | do 2 | something(); 3 | while (test() > 7); 4 | 5 | do 6 | { 7 | something(); 8 | somethingElse(); 9 | } 10 | while (test() > 7); 11 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/src/do-while-statement.js: -------------------------------------------------------------------------------- 1 | do 2 | something(); 3 | while (test() > 7); 4 | 5 | do 6 | { 7 | something(); 8 | somethingElse(); 9 | } 10 | while (test() > 7); 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | *.log 3 | 4 | # Coverage directory used by tools like istanbul 5 | coverage/ 6 | 7 | # Dependency directory 8 | node_modules/ 9 | 10 | # WebStorm IDE 11 | .idea/workspace.xml 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/dest/array-expression.js: -------------------------------------------------------------------------------- 1 | var a = [], 2 | b = [1], 3 | c = [1, 2, 3], 4 | d = [ 5 | 1, 6 | 2, 7 | , 8 | 4, 9 | 5 10 | ]; 11 | -------------------------------------------------------------------------------- /test/fixtures/cli/code/dest/inline-msg-send.js: -------------------------------------------------------------------------------- 1 | (function() 2 | { 3 | // @class Foo 4 | /* [Foo bar:7 baz:@"foo"] */ (Foo.isa.method_msgSend["bar:baz:"] || _objj_forward)(Foo, "bar:baz:", 7, "foo"); 5 | })(); 6 | 7 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/src/read-only-globals.j: -------------------------------------------------------------------------------- 1 | // No error, this is writable 2 | onload = function() { } 3 | 4 | // Warning, this is read-only 5 | undefined = 7; 6 | 7 | // Warning, this is read-only 8 | window = 13; 9 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/dest/labeled-statement.js: -------------------------------------------------------------------------------- 1 | foo: 2 | for (var i = 0; i < 10; i++) 3 | { 4 | for (var j = 0; j < 10; j++) 5 | { 6 | if (j % i === 0) 7 | continue foo; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/src/labeled-statement.js: -------------------------------------------------------------------------------- 1 | foo: 2 | for (var i = 0; i < 10; i++) 3 | { 4 | for (var j = 0; j < 10; j++) 5 | { 6 | if (j % i === 0) 7 | continue foo; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/dest/global-statement.js: -------------------------------------------------------------------------------- 1 | (function() 2 | { 3 | // @global Foo 4 | // @global Bar, Foobar 5 | 6 | var foo = Foo, 7 | bar = Bar, 8 | foobar = Foobar; 9 | })(); 10 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/dest/import/import-local.js: -------------------------------------------------------------------------------- 1 | (function() 2 | { 3 | // @import "foo.j" 4 | // @import "foo/bar.j" 5 | 6 | var x = X; 7 | 8 | if (Y) 9 | console.log("Y!"); 10 | })(); 11 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/src/import/import-local.j: -------------------------------------------------------------------------------- 1 | @import "foo.j" 2 | @import "foo/bar.j" 3 | 4 | // X is defined in foo.j 5 | var x = X; 6 | 7 | // Y is defined in foo/bar.j 8 | if (Y) 9 | console.log("Y!"); 10 | -------------------------------------------------------------------------------- /.istanbul.yml: -------------------------------------------------------------------------------- 1 | reporting: 2 | print: detail 3 | reports: 4 | - html 5 | 6 | check: 7 | global: 8 | statements: 100 9 | lines: 100 10 | branches: 100 11 | functions: 100 12 | -------------------------------------------------------------------------------- /test/fixtures/cli/exceptions/dest/module.txt: -------------------------------------------------------------------------------- 1 | 2 | test/fixtures/cli/exceptions/src/module.js:3:5: error: unexpected token 3 | var export; 4 | ^ 5 | 6 | 1 error generated. 7 | 8 | objjc: error: compilation aborted, fatal error 9 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/src/array-expression.js: -------------------------------------------------------------------------------- 1 | var a = [], 2 | b = [1], 3 | c = [1, 2, 3], 4 | d = [ 5 | 1, 6 | 2, 7 | , // element is undefined 8 | 4, 9 | 5 10 | ]; 11 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/src/import/import-cache.j: -------------------------------------------------------------------------------- 1 | @import "foo.j" 2 | 3 | // If imports were not cached, the second import would re-parse foo.j 4 | // and generate a warning about a duplicate @global declaration. 5 | 6 | @import "foo.j" 7 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/src/no-types.j: -------------------------------------------------------------------------------- 1 | @implementation NoTypes 2 | { 3 | int one; 4 | id two; 5 | } 6 | 7 | - (int)methodOne:(id)param 8 | { 9 | } 10 | 11 | - (void)methodTwo:(int)param 12 | { 13 | } 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/src/duplicate-ivars.j: -------------------------------------------------------------------------------- 1 | @implementation One 2 | { 3 | int foo; 4 | int bar; 5 | float foo; 6 | } 7 | 8 | @end 9 | 10 | @implementation Two : One 11 | { 12 | double bar; 13 | } 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/dest/assignment-expression.js: -------------------------------------------------------------------------------- 1 | var x; 2 | 3 | x.y.z = doSomething() + 7; 4 | x += 7; 5 | x -= 7; 6 | x *= 7; 7 | x /= 7; 8 | x %= 7; 9 | x <<= 7; 10 | x >>= 7; 11 | x >>>= 7; 12 | x &= 7; 13 | x ^= 7; 14 | x |= 7; 15 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/src/assignment-expression.js: -------------------------------------------------------------------------------- 1 | var x; 2 | 3 | x.y.z = doSomething() + 7; 4 | x += 7; 5 | x -= 7; 6 | x *= 7; 7 | x /= 7; 8 | x %= 7; 9 | x <<= 7; 10 | x >>= 7; 11 | x >>>= 7; 12 | x &= 7; 13 | x ^= 7; 14 | x |= 7; 15 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/dest/stdin.txt: -------------------------------------------------------------------------------- 1 | 2 | :1:9: warning: reference to unknown identifier 'y' 3 | var x = y; 4 | ^ 5 | 6 | 1 warning generated. 7 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/dest/call-expression.js: -------------------------------------------------------------------------------- 1 | doSomething(); 2 | visitor[virtualType || node.type](node, scope, compileNode); 3 | eval("x = 7"); 4 | 5 | function test() 6 | { 7 | var self = 7; 8 | 9 | eval("doSomething()"); 10 | } 11 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/jsLinters/eslint.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/jsLinters/jslint.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | -------------------------------------------------------------------------------- /test/fixtures/cli/exceptions/dest/strict-semicolons.txt: -------------------------------------------------------------------------------- 1 | 2 | test/fixtures/cli/exceptions/src/strict-semicolons.js:1:10: error: expected a semicolon 3 | var x = 7 4 | ^ 5 | 6 | 1 error generated. 7 | 8 | objjc: error: compilation aborted, fatal error 9 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/dest/debugger.txt: -------------------------------------------------------------------------------- 1 | 2 | test/fixtures/exceptions/src/debugger.j:1:1: warning: debugger statement 3 | debugger; 4 | ^ 5 | 6 | 1 warning generated. 7 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/dest/with-statement.js: -------------------------------------------------------------------------------- 1 | o = { 2 | first: "Francisco", 3 | last: "Tolmasky" 4 | }; 5 | 6 | with (o) 7 | console.log(first + " " + last); 8 | 9 | with (o) 10 | { 11 | console.log(first); 12 | console.log(last); 13 | } 14 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/src/with-statement.js: -------------------------------------------------------------------------------- 1 | o = { 2 | first: "Francisco", 3 | last: "Tolmasky" 4 | }; 5 | 6 | with (o) 7 | console.log(first + " " + last); 8 | 9 | with (o) 10 | { 11 | console.log(first); 12 | console.log(last); 13 | } 14 | -------------------------------------------------------------------------------- /test/fixtures/cli/exceptions/dest/ignore-warnings.txt: -------------------------------------------------------------------------------- 1 | 2 | test/fixtures/cli/exceptions/src/ignore-warnings.j:5:23: error: cannot find implementation declaration for 'Bar', superclass of 'Foo' 3 | @implementation Foo : Bar 4 | ^ 5 | 6 | 1 error generated. 7 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/src/imports/foo.j: -------------------------------------------------------------------------------- 1 | @import "bar.j" 2 | 3 | // warning 4 | var x = y; 5 | 6 | // This code is for coverage of nullbuffer.js 7 | 8 | for (var i = 0; i < 7; i++) 9 | console.log(j); 10 | 11 | if (x > 7) 12 | console.log("woo-hoo!"); 13 | -------------------------------------------------------------------------------- /test/fixtures/cli/code/dest/source-map.txt: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var x = 7; 4 | 5 | function test() 6 | { 7 | } 8 | //# sourceMappingURL=source-map.js.map 9 | 10 | {"version":3,"sources":["source-map.txt"],"names":[],"mappings":"AAAA;;AAEA,IAAI,IAAI","sourceRoot":"."} 11 | -------------------------------------------------------------------------------- /test/fixtures/cli/exceptions/src/max-errors-1.j: -------------------------------------------------------------------------------- 1 | // 1st error 2 | @implementation Foo : Bar 3 | @end 4 | 5 | // 2nd error, compilation aborted 6 | @implementation One : Two 7 | @end 8 | 9 | // This code is not compiled, no error 10 | @implementation One : Two 11 | @end 12 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 4 7 | end_of_line = lf 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [package.json] 12 | indent_size = 2 13 | 14 | [*.yml] 15 | indent_size = 2 16 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/dest/unary-expression.js: -------------------------------------------------------------------------------- 1 | var type1 = typeof "foo", 2 | type2 = typeof "foo", 3 | v1 = void 0, 4 | v2 = void 0, 5 | positive = +7, 6 | negative = -7, 7 | logicalNot = !object, 8 | bitwiseNot = ~7; 9 | 10 | delete object.property; 11 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/src/unary-expression.js: -------------------------------------------------------------------------------- 1 | var type1 = typeof "foo", 2 | type2 = typeof("foo"), 3 | v1 = void 0, 4 | v2 = void(0), 5 | positive = +7, 6 | negative = -7, 7 | logicalNot = !object, 8 | bitwiseNot = ~7; 9 | 10 | delete object.property; 11 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/dest/import-scope.txt: -------------------------------------------------------------------------------- 1 | 2 | test/fixtures/exceptions/src/import-scope.j:4:9: warning: reference to unknown identifier 'x' 3 | var a = x; 4 | ^ 5 | 6 | 1 warning generated. 7 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/dest/block-statement.js: -------------------------------------------------------------------------------- 1 | if (true) 2 | { 3 | "bar"; 4 | } 5 | 6 | for (var i = 0; i < 10; i++) 7 | { 8 | console.log(i); 9 | } 10 | { 11 | } 12 | { 13 | 7; 14 | 15 | { 16 | { 17 | 13; 18 | 27; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/src/block-statement.js: -------------------------------------------------------------------------------- 1 | if (true) 2 | { 3 | "bar"; 4 | } 5 | 6 | for (var i = 0; i < 10; i++) 7 | { 8 | console.log(i); 9 | } 10 | 11 | { 12 | } 13 | 14 | { 15 | 7; 16 | 17 | { 18 | { 19 | 13; 20 | 27; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/src/imports/bar.j: -------------------------------------------------------------------------------- 1 | // warning 2 | var x = y, 3 | z = 7; 4 | 5 | // This code is for coverage of nullbuffer.js 6 | 7 | @implementation Test 8 | { 9 | int one; 10 | int two; 11 | } 12 | 13 | - (void)test 14 | { 15 | one = 7; 16 | 17 | var one; 18 | } 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/src/switch-statement.js: -------------------------------------------------------------------------------- 1 | switch (foo) 2 | { 3 | case "Tom": 4 | log("Hi Tom!"); 5 | break; 6 | 7 | case "Dick": 8 | case "Harry": 9 | { 10 | log("Bye!"); 11 | break; 12 | } 13 | 14 | default: 15 | log("Yo!"); 16 | } 17 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/dest/super-root.txt: -------------------------------------------------------------------------------- 1 | 2 | test/fixtures/exceptions/src/super-root.j:6:13: error: 'Test' class cannot use 'super' because it is a root class 3 | return [super init]; 4 | ^ 5 | 6 | 1 error generated. 7 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/dest/switch-statement.js: -------------------------------------------------------------------------------- 1 | switch (foo) 2 | { 3 | case "Tom": 4 | log("Hi Tom!"); 5 | break; 6 | 7 | case "Dick": 8 | case "Harry": 9 | { 10 | log("Bye!"); 11 | break; 12 | } 13 | 14 | default: 15 | log("Yo!"); 16 | } 17 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/dest/bad-import.txt: -------------------------------------------------------------------------------- 1 | 2 | test/fixtures/exceptions/src/bad-import.j:2:1: error: no such file '/Users/aparajita/Developer/cappuccino/objjc/test/fixtures/exceptions/src/foo.j' 3 | @import "foo.j" 4 | ^ 5 | 6 | 1 error generated. 7 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/src/typedef-statement.j: -------------------------------------------------------------------------------- 1 | @typedef ColorType 2 | @typedef ViewType, DataSource 3 | 4 | @implementation Test 5 | { 6 | ColorType color; 7 | ViewType view; 8 | DataSource dataSource; 9 | } 10 | 11 | - (BOOL)hasColorOfType:(ColorType)type 12 | { 13 | return type === color; 14 | } 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/dest/recursive-import.txt: -------------------------------------------------------------------------------- 1 | 2 | test/fixtures/exceptions/src/recursive-import.j:2:1: error: circular import 3 | @import "recursive-import.j" 4 | ^ 5 | 6 | 1 error generated. 7 | 8 | objjc: error: compilation aborted, fatal error 9 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/dest/function-expression.js: -------------------------------------------------------------------------------- 1 | var anonymous = function() 2 | { 3 | }; 4 | 5 | var test = function test(one, two, three) 6 | { 7 | }; 8 | 9 | test = function() 10 | { 11 | }; 12 | 13 | var lambdas = { 14 | empty: function() { }, 15 | oneline: function() { doSomething(); } 16 | }; 17 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/src/function-expression.js: -------------------------------------------------------------------------------- 1 | var anonymous = function() 2 | { 3 | }; 4 | 5 | var test = function test(one, two, three) 6 | { 7 | }; 8 | 9 | test = function() 10 | { 11 | }; 12 | 13 | var lambdas = { 14 | empty: function() { }, 15 | oneline: function() { doSomething(); } 16 | }; 17 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/dest/protocol-literal-expression.js: -------------------------------------------------------------------------------- 1 | (function() 2 | { 3 | // @protocol SomeProtocol 4 | var $the_protocol = objj_allocateProtocol("SomeProtocol"); 5 | 6 | objj_registerProtocol($the_protocol); 7 | 8 | // @end: @protocol SomeProtocol 9 | 10 | var p = objj_getProtocol("SomeProtocol"); 11 | })(); 12 | -------------------------------------------------------------------------------- /test/fixtures/cli/exceptions/src/ignore-warnings.j: -------------------------------------------------------------------------------- 1 | // unknown identifier warning, but it's ignored 2 | var foo = bar; 3 | 4 | // unknown superclass error 5 | @implementation Foo : Bar 6 | @end 7 | 8 | function test() 9 | { 10 | // implicit global warning, but it's ignored 11 | x = 7; 12 | } 13 | 14 | // ignored warning 15 | debugger; 16 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/dest/super-outside.txt: -------------------------------------------------------------------------------- 1 | 2 | test/fixtures/exceptions/src/super-outside.j:2:2: error: 'super' outside of function or class 3 | [super doSomething]; 4 | ^ 5 | 6 | 1 error generated. 7 | 8 | objjc: error: compilation aborted, fatal error 9 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/src/call-expression.js: -------------------------------------------------------------------------------- 1 | doSomething(); 2 | visitor[virtualType || node.type](node, scope, compileNode); 3 | eval("x = 7"); 4 | 5 | function test() 6 | { 7 | // This is for code coverage. eval within an objj method 8 | // marks self as mutated. 9 | var self = 7; 10 | 11 | eval("doSomething()"); 12 | } 13 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/dest/circular-import.txt: -------------------------------------------------------------------------------- 1 | 2 | In file imported from 'test/fixtures/exceptions/src/circular-import.j':1 3 | test/fixtures/exceptions/src/imports/circular.j:1:1: error: circular import 4 | @import "../circular-import.j" 5 | ^ 6 | 7 | 1 error generated. 8 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/dest/dereference.txt: -------------------------------------------------------------------------------- 1 | 2 | test/fixtures/exceptions/src/dereference.j:4:19: error: expected ')' after ref 3 | @deref(choose ? ref1 : ref2) = 7; 4 | ^ 5 | 6 | 1 error generated. 7 | 8 | objjc: error: compilation aborted, fatal error 9 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/src/dereference.j: -------------------------------------------------------------------------------- 1 | function test(choose, ref1, ref2) 2 | { 3 | // @deref can only take an identifier. 4 | @deref(choose ? ref1 : ref2) = 7; 5 | 6 | // To work, the code above must be written: 7 | var ref = choose ? ref1 : ref2; 8 | 9 | @deref(ref) = 7; 10 | } 11 | 12 | var x, y; 13 | 14 | test(true, @ref(x), @ref(y)); 15 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/dest/for-statement.js: -------------------------------------------------------------------------------- 1 | for (; ; ) 2 | doSomething(); 3 | 4 | for (var i = 0; ; ) 5 | doSomething(); 6 | 7 | for (; i < 7; ) 8 | doSomething(); 9 | 10 | for (; ; i++) 11 | doSomething(); 12 | 13 | for (var i = 0; i < 7; i++) 14 | doSomething(); 15 | 16 | for (var i = 0; i < 7; i++) 17 | { 18 | doSomething(); 19 | } 20 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/src/for-statement.js: -------------------------------------------------------------------------------- 1 | for (; ; ) 2 | doSomething(); 3 | 4 | for (var i = 0; ; ) 5 | doSomething(); 6 | 7 | for (; i < 7; ) 8 | doSomething(); 9 | 10 | for (; ; i++) 11 | doSomething(); 12 | 13 | for (var i = 0; i < 7; i++) 14 | doSomething(); 15 | 16 | for (var i = 0; i < 7; i++) 17 | { 18 | doSomething(); 19 | } 20 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/src/super-root.j: -------------------------------------------------------------------------------- 1 | @implementation Test 2 | 3 | - (id)init 4 | { 5 | // 'Test' cannot use 'super' because it is a root class 6 | return [super init]; 7 | } 8 | 9 | @end 10 | 11 | @implementation SubTest : Test 12 | 13 | - (id)init 14 | { 15 | // no warning, it isn't a root class 16 | return [super init]; 17 | } 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/dest/break-statement.js: -------------------------------------------------------------------------------- 1 | while (true) 2 | { 3 | if (test()) 4 | break; 5 | } 6 | 7 | outer: 8 | for (var i = 0; i < 7; i++) 9 | { 10 | for (var j = 0; j < i; j++) 11 | { 12 | if (j % i === 2) 13 | break outer; 14 | 15 | console.log("j = " + j); 16 | } 17 | 18 | console.log("i = " + i); 19 | } 20 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/src/class-statement.j: -------------------------------------------------------------------------------- 1 | // Second Foo warns but is ignored 2 | @class Foo 3 | @class Bar, Foobar, Foo 4 | 5 | @implementation Test 6 | { 7 | Foo foo; 8 | Bar bar; 9 | Foobar foobar; 10 | } 11 | @end 12 | 13 | // No warning, @implementation replaces @class 14 | @implementation Foo 15 | @end 16 | 17 | // Warn but ignore 18 | @class Foo 19 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/src/break-statement.js: -------------------------------------------------------------------------------- 1 | while (true) 2 | { 3 | if (test()) 4 | break; 5 | } 6 | 7 | outer: 8 | for (var i = 0; i < 7; i++) 9 | { 10 | for (var j = 0; j < i; j++) 11 | { 12 | if (j % i === 2) 13 | break outer; 14 | 15 | console.log("j = " + j); 16 | } 17 | 18 | console.log("i = " + i); 19 | } 20 | -------------------------------------------------------------------------------- /.idea/eslintPlugin.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/dest/continue-statement.js: -------------------------------------------------------------------------------- 1 | while (true) 2 | { 3 | if (test()) 4 | continue; 5 | 6 | console.log("yo"); 7 | } 8 | 9 | outer: 10 | for (var i = 0; i < 7; i++) 11 | { 12 | for (var j = 0; j < i; j++) 13 | { 14 | if (j % i === 2) 15 | continue outer; 16 | 17 | console.log("j = " + j); 18 | } 19 | 20 | console.log("i = " + i); 21 | } 22 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/dest/try-statement.js: -------------------------------------------------------------------------------- 1 | try 2 | { 3 | doSomething(); 4 | } 5 | catch (ex) 6 | { 7 | console.log("Doh!"); 8 | } 9 | 10 | try 11 | { 12 | doSomething(); 13 | } 14 | finally 15 | { 16 | console.log("Done"); 17 | } 18 | 19 | try 20 | { 21 | doSomething(); 22 | } 23 | catch (ex) 24 | { 25 | console.log("Doh!"); 26 | } 27 | finally 28 | { 29 | console.log("Done"); 30 | } 31 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/src/try-statement.js: -------------------------------------------------------------------------------- 1 | try 2 | { 3 | doSomething(); 4 | } 5 | catch (ex) 6 | { 7 | console.log("Doh!"); 8 | } 9 | 10 | try 11 | { 12 | doSomething(); 13 | } 14 | finally 15 | { 16 | console.log("Done"); 17 | } 18 | 19 | try 20 | { 21 | doSomething(); 22 | } 23 | catch (ex) 24 | { 25 | console.log("Doh!"); 26 | } 27 | finally 28 | { 29 | console.log("Done"); 30 | } 31 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/dest/import-parse-error.txt: -------------------------------------------------------------------------------- 1 | 2 | In file imported from 'test/fixtures/exceptions/src/import-parse-error.j':1 3 | test/fixtures/exceptions/src/imports/acorn-error.j:4:10: error: unexpected token 4 | if (x ==== 7) 5 | ^ 6 | 7 | 1 error generated. 8 | 9 | objjc: error: compilation aborted, fatal error 10 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/dest/return-statement.js: -------------------------------------------------------------------------------- 1 | function test() 2 | { 3 | return someTest() ? "Woo-hoo!" : "Bummer"; 4 | } 5 | 6 | function test2() 7 | { 8 | doSomething(); 9 | 10 | return { 11 | first: "Francisco", 12 | last: "Tolmasky" 13 | }; 14 | } 15 | 16 | function test3() 17 | { 18 | doSomething(); 19 | 20 | if (test()) 21 | return; 22 | 23 | doSomethingElse(); 24 | } 25 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/src/return-statement.js: -------------------------------------------------------------------------------- 1 | function test() 2 | { 3 | return someTest() ? "Woo-hoo!" : "Bummer"; 4 | } 5 | 6 | function test2() 7 | { 8 | doSomething(); 9 | 10 | return { 11 | first: "Francisco", 12 | last: "Tolmasky" 13 | }; 14 | } 15 | 16 | function test3() 17 | { 18 | doSomething(); 19 | 20 | if (test()) 21 | return; 22 | 23 | doSomethingElse(); 24 | } 25 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/src/continue-statement.js: -------------------------------------------------------------------------------- 1 | while (true) 2 | { 3 | if (test()) 4 | continue; 5 | 6 | console.log("yo"); 7 | } 8 | 9 | outer: 10 | for (var i = 0; i < 7; i++) 11 | { 12 | for (var j = 0; j < i; j++) 13 | { 14 | if (j % i === 2) 15 | continue outer; 16 | 17 | console.log("j = " + j); 18 | } 19 | 20 | console.log("i = " + i); 21 | } 22 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/src/self-super.j: -------------------------------------------------------------------------------- 1 | @implementation CPObject 2 | @end 3 | 4 | @implementation Test : CPObject 5 | 6 | - (void)test 7 | { 8 | [self doSomething]; 9 | [super doSomething]; 10 | 11 | function testme() 12 | { 13 | [self doSomething]; 14 | [super doSomething]; 15 | } 16 | } 17 | 18 | @end 19 | 20 | function test() 21 | { 22 | var self = 7; 23 | 24 | self = 13; 25 | } 26 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | # Use trusty 4 | sudo: true 5 | dist: trusty 6 | 7 | # Don't build commits in the queue if a new commit arrives 8 | git: 9 | depth: 1 10 | 11 | # node versions to test 12 | node_js: 13 | - "5" # Minimum version 14 | - "6" # Latest version 15 | 16 | # If any version fails, cancel the others 17 | matrix: 18 | fast_finish: true 19 | 20 | before_script: 21 | - npm install -g gulp-cli 22 | 23 | script: gulp 24 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/src/reference-dereference.j: -------------------------------------------------------------------------------- 1 | 2 | @implementation Reference 3 | 4 | - (void)mungeRef:(@ref)ref 5 | { 6 | var i = ++@deref(ref); 7 | 8 | i = @deref(ref)++; 9 | i = --@deref(ref); 10 | i = @deref(ref)--; 11 | @deref(ref) = 27; 12 | @deref(ref) += 4; 13 | @deref(ref) = @deref(ref) - 4; 14 | } 15 | 16 | - (void)test 17 | { 18 | var i = 13; 19 | 20 | [self mungeRef:@ref(i)]; 21 | } 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /.idea/jsLibraryMappings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/webResources.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.idea/codeStyleSettings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /test/fixtures/cli/exceptions/src/max-errors-0.j: -------------------------------------------------------------------------------- 1 | // Default error limit is 20 2 | @implementation Foo 3 | { 4 | int a; 5 | int a; 6 | int a; 7 | int a; 8 | int a; 9 | int a; 10 | int a; 11 | int a; 12 | int a; 13 | int a; 14 | int a; 15 | int a; 16 | int a; 17 | int a; 18 | int a; 19 | int a; 20 | int a; 21 | int a; 22 | int a; 23 | int a; 24 | int a; 25 | int a; // 21st error 26 | } 27 | @end 28 | -------------------------------------------------------------------------------- /.idea/libraries/node_modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /test/fixtures/cli/code/dest/no-type-signatures.js: -------------------------------------------------------------------------------- 1 | (function() 2 | { 3 | // @implementation Test 4 | var $the_class = objj_allocateClassPair(Nil, "Test"); 5 | objj_registerClassPair($the_class); 6 | 7 | // Instance methods 8 | class_addMethods($the_class, 9 | [ 10 | // - (void)one: 11 | new objj_method(sel_getUid("one:"), 12 | function $Test__one_(self, _cmd, two) 13 | { 14 | }) 15 | ]); 16 | // @end: @implementation Test 17 | })(); 18 | 19 | -------------------------------------------------------------------------------- /test/fixtures/cli/exceptions/dest/max-errors-1.txt: -------------------------------------------------------------------------------- 1 | 2 | test/fixtures/cli/exceptions/src/max-errors-1.j:2:23: error: cannot find implementation declaration for 'Bar', superclass of 'Foo' 3 | @implementation Foo : Bar 4 | ^ 5 | test/fixtures/cli/exceptions/src/max-errors-1.j:6:23: error: cannot find implementation declaration for 'Two', superclass of 'One' 6 | @implementation One : Two 7 | ^ 8 | 9 | 2 errors generated. 10 | 11 | objjc: error: compilation aborted, too many errors (>1) 12 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/dest/read-only-globals.txt: -------------------------------------------------------------------------------- 1 | 2 | test/fixtures/exceptions/src/read-only-globals.j:5:1: warning: assigning to a read-only predefined global 3 | undefined = 7; 4 | ^ 5 | test/fixtures/exceptions/src/read-only-globals.j:8:1: warning: assigning to a read-only predefined global 6 | window = 13; 7 | ^ 8 | 9 | 2 warnings generated. 10 | -------------------------------------------------------------------------------- /test/fixtures/cli/code/dest/no-method-names.js: -------------------------------------------------------------------------------- 1 | (function() 2 | { 3 | // @implementation Test 4 | var $the_class = objj_allocateClassPair(Nil, "Test"); 5 | objj_registerClassPair($the_class); 6 | 7 | // Instance methods 8 | class_addMethods($the_class, 9 | [ 10 | // - (void)one: 11 | new objj_method(sel_getUid("one:"), 12 | function(self, _cmd, two) 13 | { 14 | }, 15 | // argument types 16 | ["void", "int"]) 17 | ]); 18 | // @end: @implementation Test 19 | })(); 20 | 21 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/src/protocol-declaration.j: -------------------------------------------------------------------------------- 1 | @protocol Person 2 | 3 | - (void)eat; 4 | 5 | @end 6 | 7 | @protocol Parent 8 | 9 | - (void)one; 10 | - (int)two; 11 | + (void)classMethod; 12 | 13 | @end 14 | 15 | @protocol Child 16 | 17 | - (float)three; 18 | 19 | @required 20 | - (id)required; 21 | 22 | @optional 23 | - (void)optional 24 | 25 | @end 26 | 27 | // It's legal to have a class with the same name as a protocol 28 | @implementation Person 29 | 30 | - (void)eat 31 | { 32 | console.log("Yum!"); 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/dest/array-literal.js: -------------------------------------------------------------------------------- 1 | (function() 2 | { 3 | x = (___r1 = CPArray.isa.objj_msgSend0(CPArray, "alloc"), ___r1 == null ? null : ___r1.isa.objj_msgSend0(___r1, "init")); 4 | x = (___r1 = CPArray.isa.objj_msgSend0(CPArray, "alloc"), ___r1 == null ? null : ___r1.isa.objj_msgSend2(___r1, "initWithObjects:count:", ["one"], 1)); 5 | x = (___r1 = CPArray.isa.objj_msgSend0(CPArray, "alloc"), ___r1 == null ? null : ___r1.isa.objj_msgSend2(___r1, "initWithObjects:count:", ["one", "two", 3, four, 5.0], 5)); 6 | 7 | // Generated receiver temp variables 8 | var ___r1; 9 | })(); 10 | -------------------------------------------------------------------------------- /test/fixtures/cli/exceptions/src/warnings-none.j: -------------------------------------------------------------------------------- 1 | // warning - off 2 | debugger; 3 | 4 | var i = 13; 5 | 6 | @implementation One 7 | 8 | // shadowed var warning - off 9 | - (void)test:(int)i 10 | { 11 | // implicit global warning - off 12 | x = 7; 13 | } 14 | 15 | // unknown type warning - off 16 | - (Foo)foo:(int)bar 17 | { 18 | // unknown identifier warning - off 19 | var y = boo; 20 | } 21 | 22 | @end 23 | 24 | @implementation Two : One 25 | 26 | // return/parameter type warnings - off 27 | - (void)foo:(double)bar 28 | { 29 | // reserved word warning - not optional 30 | var NaN = "yo"; 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/src/missing-dependencies.j: -------------------------------------------------------------------------------- 1 | // cannot find implementation for 'Bar' 2 | @implementation Foo : Bar 3 | @end 4 | 5 | // cannot find protocol 6 | @protocol One 7 | @end 8 | 9 | // cannot find protocol 10 | @implementation NoProtocol 11 | 12 | // cannot find protocol 13 | - (id)one:(id)protocol 14 | { 15 | } 16 | 17 | // cannot find protocol 18 | - (id)two:(id)protocol 19 | { 20 | // cannot find protocol 21 | var p = @protocol(Foo); 22 | } 23 | 24 | @end 25 | 26 | // cannot find implementation 27 | @implementation SomeClass (SomeCategory) 28 | @end 29 | -------------------------------------------------------------------------------- /test/fixtures/cli/exceptions/src/warnings-all.j: -------------------------------------------------------------------------------- 1 | // warning 2 | debugger; 3 | 4 | var i = 13; 5 | 6 | @implementation One 7 | { 8 | // unknown type warning 9 | CPString title; 10 | } 11 | 12 | // shadowed var warning 13 | - (void)test:(int)i 14 | { 15 | // implicit global warning 16 | x = 7; 17 | } 18 | 19 | // unknown type warning 20 | - (Foo)foo:(int)bar 21 | { 22 | // unknown identifier warning 23 | var y = boo; 24 | } 25 | 26 | @end 27 | 28 | @implementation Two : One 29 | 30 | // return/parameter type warnings 31 | - (void)foo:(double)bar 32 | { 33 | // reserved word warning 34 | var NaN = "yo"; 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /test/fixtures/cli/exceptions/src/warnings-enable-disable.j: -------------------------------------------------------------------------------- 1 | // warning 2 | debugger; 3 | 4 | var i = 13; 5 | 6 | @implementation One 7 | 8 | // shadowed var warning 9 | - (void)test:(int)i 10 | { 11 | // implicit global warning - disabled 12 | x = 7; 13 | } 14 | 15 | // unknown type warning - disabled by default 16 | - (Foo)foo:(int)bar 17 | { 18 | // unknown identifier warning 19 | var y = boo; 20 | } 21 | 22 | @end 23 | 24 | @implementation Two : One 25 | 26 | // return/parameter type warnings - enabled 27 | - (void)foo:(double)bar 28 | { 29 | // reserved word warning - not optional 30 | var NaN = "yo"; 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/dest/dictionary-literal.js: -------------------------------------------------------------------------------- 1 | (function() 2 | { 3 | x = (___r1 = CPDictionary.isa.objj_msgSend0(CPDictionary, "alloc"), ___r1 == null ? null : ___r1.isa.objj_msgSend0(___r1, "init")); 4 | x = (___r1 = CPDictionary.isa.objj_msgSend0(CPDictionary, "alloc"), ___r1 == null ? null : ___r1.isa.objj_msgSend2(___r1, "initWithObjects:forKeys:", ["value"], ["key"])); 5 | x = (___r1 = CPDictionary.isa.objj_msgSend0(CPDictionary, "alloc"), ___r1 == null ? null : ___r1.isa.objj_msgSend2(___r1, "initWithObjects:forKeys:", ["Tiny Tim", "tulips"], ["name", "flower"])); 6 | 7 | // Generated receiver temp variables 8 | var ___r1; 9 | })(); 10 | -------------------------------------------------------------------------------- /test/fixtures/cli/exceptions/src/warnings-list.j: -------------------------------------------------------------------------------- 1 | // warning - enabled 2 | debugger; 3 | 4 | var i = 13; 5 | 6 | @implementation One 7 | 8 | // shadowed var warning - disabled 9 | - (void)test:(int)i 10 | { 11 | // implicit global warning - disabled 12 | x = 7; 13 | } 14 | 15 | // unknown type warning - enabled 16 | - (Foo)foo:(int)bar 17 | { 18 | // unknown identifier warning - disabled 19 | var y = boo; 20 | } 21 | 22 | @end 23 | 24 | @implementation Two : One 25 | 26 | // return/parameter type warnings - disabled 27 | - (void)foo:(double)bar 28 | { 29 | // reserved word warning - not optional 30 | var NaN = "yo"; 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/src/duplicate-methods.j: -------------------------------------------------------------------------------- 1 | @implementation One 2 | 3 | - (void)one 4 | { 5 | } 6 | 7 | - (void)two 8 | { 9 | } 10 | 11 | // duplicate method error 12 | - (void)one 13 | { 14 | } 15 | 16 | // instance and class methods can have the same name 17 | + (void)one 18 | { 19 | } 20 | 21 | // duplicate method error 22 | + (void)one 23 | { 24 | } 25 | 26 | @end 27 | 28 | @protocol ProtocolOne 29 | 30 | - (void)one; 31 | - (void)two; 32 | 33 | // duplicate ignored warning 34 | - (void)one; 35 | 36 | // duplicate ignored warning 37 | - (void)one; 38 | 39 | + (void)class1; 40 | 41 | // duplicate ignored warning 42 | + (void)class1; 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/src/suggestions.j: -------------------------------------------------------------------------------- 1 | @class CPString 2 | 3 | // unknown identifier 'CPstring', did you mean 'CPString'? 4 | var str = [CPstring stringWithFormat:@"%s cool", @"way"]; 5 | 6 | @protocol CPCopying 7 | @end 8 | 9 | @typedef ColorScheme 10 | 11 | // unknown protocol, did you mean 'CPCopying'? 12 | @implementation MyObject 13 | 14 | // unknown type, did you mean 'ColorScheme'? 15 | - (Colorscheme)getSchemeWithName:(CPString)name 16 | { 17 | } 18 | 19 | // unknown type, did you mean 'int'? 20 | - (Int)count 21 | { 22 | } 23 | 24 | // unknown type, did you mean 'MyObject'? 25 | - (Myobject)copy:(MyObject)other 26 | { 27 | } 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/src/binary-expression.js: -------------------------------------------------------------------------------- 1 | // Coverage for Compiler.subnodeHasPrecedence 2 | 3 | // subnodePrecedence > nodePrecendence 4 | x = (y ? 7 : 31) > 27; 5 | 6 | // nodePrecedence === subnodePrecedence && isLogicalOrBinaryExpression.test(nodeType) 7 | // subnodeOperatorPrecedence > nodeOperatorPrecedence 8 | x = (7 + 13) * 27; 9 | 10 | // nodePrecedence === subnodePrecedence && isLogicalOrBinaryExpression.test(nodeType) 11 | // right === true && nodeOperatorPrecedence === subnodeOperatorPrecedence 12 | x = 7 + (13 + 27); 13 | 14 | // Parens except for (10-3) should be removed because they duplicate precedence rules 15 | x = (7 * 13) + 27 << ((31 / 2) % (10 - 3)); 16 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/dest/class-statement.js: -------------------------------------------------------------------------------- 1 | (function() 2 | { 3 | // @class Foo 4 | // @class Bar, Foobar, Foo 5 | 6 | // @implementation Test 7 | var $the_class = objj_allocateClassPair(Nil, "Test"); 8 | objj_registerClassPair($the_class); 9 | 10 | class_addIvars($the_class, 11 | [ 12 | new objj_ivar("foo", "Foo"), 13 | new objj_ivar("bar", "Bar"), 14 | new objj_ivar("foobar", "Foobar") 15 | ]); 16 | // @end: @implementation Test 17 | 18 | // @implementation Foo 19 | var $the_class = objj_allocateClassPair(Nil, "Foo"); 20 | objj_registerClassPair($the_class); 21 | // @end: @implementation Foo 22 | 23 | // @class Foo 24 | })(); 25 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/src/accessors.j: -------------------------------------------------------------------------------- 1 | @implementation Accessors 2 | { 3 | int accessors @accessors; 4 | int copyMe @accessors(copy); 5 | int readOnly @accessors(readonly); 6 | int propertyAccessors @accessors(property=property); 7 | int getter @accessors(getter=getMe); 8 | int setter @accessors(setter=setMe); 9 | int getterSetter @accessors(getter=getMe, setter=setIt); 10 | int hasGetter @accessors; 11 | int hasSetter @accessors; 12 | int _underscore @accessors; // _ is stripped from accessor names 13 | } 14 | 15 | - (int)hasGetter 16 | { 17 | return self.hasGetter; 18 | } 19 | 20 | - (void)setHasSetter:(int)newValue 21 | { 22 | self.hasSetter = newValue; 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /.idea/cappuccino.compiler.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/dest/reserved-words.txt: -------------------------------------------------------------------------------- 1 | 2 | test/fixtures/exceptions/src/reserved-words.j:1:5: warning: reserved word used as a variable name 3 | var arguments = false, 4 | ^ 5 | test/fixtures/exceptions/src/reserved-words.j:2:5: warning: reserved word used as a variable name 6 | NaN = false, 7 | ^ 8 | test/fixtures/exceptions/src/reserved-words.j:3:5: warning: reserved word used as a variable name 9 | undefined = false; 10 | ^ 11 | 12 | 3 warnings generated. 13 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/dest/if-statement.js: -------------------------------------------------------------------------------- 1 | if (a < b) 2 | print(a); 3 | 4 | if (a > b) 5 | print(a); 6 | else 7 | print(b); 8 | 9 | if (a > b) 10 | { 11 | print(a); 12 | max = a; 13 | } 14 | else 15 | print(b); 16 | 17 | if (a > b) 18 | { 19 | print(a); 20 | max = a; 21 | } 22 | else 23 | { 24 | print(b); 25 | } 26 | 27 | if (a > b) 28 | print(a); 29 | else 30 | { 31 | print(b); 32 | max = b; 33 | } 34 | 35 | if (a > b) 36 | print(a); 37 | else if (b > a) 38 | { 39 | print(b); 40 | max = b; 41 | } 42 | else 43 | print("equal"); 44 | 45 | if (a > b) 46 | { 47 | print(a); 48 | max = a; 49 | } 50 | else if (b > a) 51 | { 52 | print(b); 53 | max = b; 54 | } 55 | else 56 | print("equal"); 57 | -------------------------------------------------------------------------------- /test/fixtures/js-nodes/src/if-statement.js: -------------------------------------------------------------------------------- 1 | if (a < b) 2 | print(a); 3 | 4 | if (a > b) 5 | print(a); 6 | else 7 | print(b); 8 | 9 | if (a > b) 10 | { 11 | print(a); 12 | max = a; 13 | } 14 | else 15 | print(b); 16 | 17 | if (a > b) 18 | { 19 | print(a); 20 | max = a; 21 | } 22 | else 23 | { 24 | print(b); 25 | } 26 | 27 | if (a > b) 28 | print(a); 29 | else 30 | { 31 | print(b); 32 | max = b; 33 | } 34 | 35 | if (a > b) 36 | print(a); 37 | else if (b > a) 38 | { 39 | print(b); 40 | max = b; 41 | } 42 | else 43 | print("equal"); 44 | 45 | if (a > b) 46 | { 47 | print(a); 48 | max = a; 49 | } 50 | else if (b > a) 51 | { 52 | print(b); 53 | max = b; 54 | } 55 | else 56 | print("equal"); 57 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # Version format 2 | version: "{build}" 3 | 4 | # node versions to test against 5 | environment: 6 | matrix: 7 | - nodejs_version: "5" # Minimum verion 8 | 9 | # If any node versions fail, stop the others 10 | matrix: 11 | fast_finish: true 12 | 13 | # Install runtime environment 14 | install: 15 | - ps: Install-Product node $env:nodejs_version 16 | - set CI=true 17 | - npm -g install npm@latest 18 | - npm -g install gulp-cli mocha 19 | - set PATH=%APPDATA%\npm;%PATH% 20 | - npm install 21 | 22 | # Download a zip of the repo 23 | shallow_clone: true 24 | 25 | # Don't need the repo history 26 | clone_depth: 1 27 | 28 | # Nothing to build before testing 29 | build: off 30 | 31 | test_script: 32 | - node --version 33 | - npm --version 34 | - gulp 35 | -------------------------------------------------------------------------------- /test/fixtures/cli/code/dest/ast-0.txt: -------------------------------------------------------------------------------- 1 | {"type":"Program","start":0,"end":11,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":0}},"sourceFile":"ast-0.txt","body":[{"type":"VariableDeclaration","start":0,"end":10,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":10}},"sourceFile":"ast-0.txt","declarations":[{"type":"VariableDeclarator","start":4,"end":9,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":9}},"sourceFile":"ast-0.txt","id":{"type":"Identifier","start":4,"end":5,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":5}},"sourceFile":"ast-0.txt","name":"x"},"init":{"type":"Literal","start":8,"end":9,"loc":{"start":{"line":1,"column":8},"end":{"line":1,"column":9}},"sourceFile":"ast-0.txt","value":7,"raw":"7"}}],"kind":"var"}],"sourceType":"script"} 2 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/dest/array-literal-inline.js: -------------------------------------------------------------------------------- 1 | (function() 2 | { 3 | x = (___r1 = (CPArray.isa.method_msgSend["alloc"] || _objj_forward)(CPArray, "alloc"), ___r1 == null ? null : (___r1.isa.method_msgSend["init"] || _objj_forward)(___r1, "init")); 4 | x = (___r1 = (CPArray.isa.method_msgSend["alloc"] || _objj_forward)(CPArray, "alloc"), ___r1 == null ? null : (___r1.isa.method_msgSend["initWithObjects:count:"] || _objj_forward)(___r1, "initWithObjects:count:", ["one"], 1)); 5 | x = (___r1 = (CPArray.isa.method_msgSend["alloc"] || _objj_forward)(CPArray, "alloc"), ___r1 == null ? null : (___r1.isa.method_msgSend["initWithObjects:count:"] || _objj_forward)(___r1, "initWithObjects:count:", ["one", "two", 3, four, 5.0], 5)); 6 | 7 | // Generated receiver temp variables 8 | var ___r1; 9 | })(); 10 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/dest/no-types.js: -------------------------------------------------------------------------------- 1 | (function() 2 | { 3 | // @implementation NoTypes 4 | var $the_class = objj_allocateClassPair(Nil, "NoTypes"); 5 | objj_registerClassPair($the_class); 6 | 7 | class_addIvars($the_class, 8 | [ 9 | new objj_ivar("one"), 10 | new objj_ivar("two") 11 | ]); 12 | 13 | // Instance methods 14 | class_addMethods($the_class, 15 | [ 16 | // - (int)methodOne: 17 | new objj_method(sel_getUid("methodOne:"), 18 | function $NoTypes__methodOne_(self, _cmd, param) 19 | { 20 | }), 21 | 22 | // - (void)methodTwo: 23 | new objj_method(sel_getUid("methodTwo:"), 24 | function $NoTypes__methodTwo_(self, _cmd, param) 25 | { 26 | }) 27 | ]); 28 | // @end: @implementation NoTypes 29 | })(); 30 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/src/method-declaration.j: -------------------------------------------------------------------------------- 1 | @protocol Protocol1 2 | @end 3 | 4 | @protocol Protocol2 5 | @end 6 | 7 | @implementation Methods 8 | 9 | // Return type defaults to id if not present 10 | - defaultType 11 | { 12 | } 13 | 14 | // @action/IBAction return type becomes void in generated code 15 | - (@action)action1 16 | { 17 | } 18 | 19 | - (IBAction)action2 20 | { 21 | } 22 | 23 | // Return type can have protocols 24 | - (id)returnProtocols 25 | { 26 | } 27 | 28 | - (void)selectorWith:(int)one 29 | { 30 | // eval within a method marks self as mutated 31 | eval("doSomething()"); 32 | } 33 | 34 | - (void)selectorWith:(int)one two:(double)two 35 | { 36 | } 37 | 38 | - (void)selectorWithProtocols:(id)protocols 39 | { 40 | } 41 | 42 | - (void)varArgs:(int)count, ... 43 | { 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/dest/dictionary-literal-inline.js: -------------------------------------------------------------------------------- 1 | (function() 2 | { 3 | x = (___r1 = (CPDictionary.isa.method_msgSend["alloc"] || _objj_forward)(CPDictionary, "alloc"), ___r1 == null ? null : (___r1.isa.method_msgSend["init"] || _objj_forward)(___r1, "init")); 4 | x = (___r1 = (CPDictionary.isa.method_msgSend["alloc"] || _objj_forward)(CPDictionary, "alloc"), ___r1 == null ? null : (___r1.isa.method_msgSend["initWithObjects:forKeys:"] || _objj_forward)(___r1, "initWithObjects:forKeys:", ["value"], ["key"])); 5 | x = (___r1 = (CPDictionary.isa.method_msgSend["alloc"] || _objj_forward)(CPDictionary, "alloc"), ___r1 == null ? null : (___r1.isa.method_msgSend["initWithObjects:forKeys:"] || _objj_forward)(___r1, "initWithObjects:forKeys:", ["Tiny Tim", "tulips"], ["name", "flower"])); 6 | 7 | // Generated receiver temp variables 8 | var ___r1; 9 | })(); 10 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/dest/no-method-names.js: -------------------------------------------------------------------------------- 1 | (function() 2 | { 3 | // @implementation NoMethodNames 4 | var $the_class = objj_allocateClassPair(Nil, "NoMethodNames"); 5 | objj_registerClassPair($the_class); 6 | 7 | // Instance methods 8 | class_addMethods($the_class, 9 | [ 10 | // - (int)methodOne: 11 | new objj_method(sel_getUid("methodOne:"), 12 | function(self, _cmd, param) 13 | { 14 | }, 15 | // argument types 16 | ["int", "id"]) 17 | ]); 18 | 19 | // Class methods 20 | class_addMethods($the_class.isa, 21 | [ 22 | // + (void)initialize 23 | new objj_method(sel_getUid("initialize"), 24 | function(self, _cmd) 25 | { 26 | }, 27 | // argument types 28 | ["void"]) 29 | ]); 30 | // @end: @implementation NoMethodNames 31 | })(); 32 | -------------------------------------------------------------------------------- /lib/reporter.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const 4 | issueHandler = require("acorn-issue-handler"), 5 | utils = require("./utils.js"); 6 | 7 | class ObjjcReporter extends issueHandler.reporters.ConsoleReporter 8 | { 9 | constructor(options) 10 | { 11 | super(options); 12 | this.lastIssue = null; 13 | } 14 | 15 | renderIssue(issue) 16 | { 17 | const file = issue.file; 18 | let importStack = ""; 19 | 20 | if ((this.lastIssue === null || this.lastIssue.file !== issue.file) && issue.importStack) 21 | importStack = issue.importStack; 22 | 23 | this.lastIssue = issue; 24 | issue.file = utils.getRelativeSourcePath(file); 25 | 26 | const result = importStack + super.renderIssue(issue); 27 | 28 | issue.file = file; 29 | 30 | return result; 31 | } 32 | } 33 | 34 | module.exports = ObjjcReporter; 35 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/dest/duplicate-ivars.txt: -------------------------------------------------------------------------------- 1 | 2 | test/fixtures/exceptions/src/duplicate-ivars.j:5:11: error: redeclaration of instance variable 'foo' in class 'One' 3 | float foo; 4 | ^ 5 | test/fixtures/exceptions/src/duplicate-ivars.j:3:9: note: previous declaration is here, in class 'One' 6 | int foo; 7 | ^ 8 | test/fixtures/exceptions/src/duplicate-ivars.j:12:12: error: redeclaration of instance variable 'bar' in class 'Two' 9 | double bar; 10 | ^ 11 | test/fixtures/exceptions/src/duplicate-ivars.j:4:9: note: previous declaration is here, in class 'One' 12 | int bar; 13 | ^ 14 | 15 | 2 errors generated. 16 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/src/class-declaration.j: -------------------------------------------------------------------------------- 1 | @implementation Empty 2 | { 3 | } 4 | @end 5 | 6 | @implementation Empty (Category) 7 | @end 8 | 9 | @implementation Subclass : Empty 10 | @end 11 | 12 | @protocol Protocol1 13 | @end 14 | 15 | @protocol Protocol2 16 | @end 17 | 18 | @implementation OneProtocol 19 | @end 20 | 21 | @implementation TwoProtocols 22 | @end 23 | 24 | @implementation EmptyIvars 25 | {} 26 | @end 27 | 28 | @implementation Ivars 29 | { 30 | int one; 31 | Empty two; 32 | @outlet id outlet; 33 | IBOutlet id outlet2; 34 | } 35 | @end 36 | 37 | @implementation Statements 38 | 39 | var x = 7; 40 | 41 | function test() 42 | { 43 | doSomething(); 44 | } 45 | 46 | @end 47 | 48 | @implementation Methods : Statements 49 | 50 | var initialized = false, 51 | initCount = 0; 52 | 53 | + (void)initialize 54 | { 55 | initialized = true; 56 | } 57 | 58 | - (id)init 59 | { 60 | self = [super init]; 61 | 62 | if (self) 63 | initCount++; 64 | 65 | return self; 66 | } 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/dest/typedef-statement.js: -------------------------------------------------------------------------------- 1 | (function() 2 | { 3 | // @typedef ColorType 4 | objj_registerTypeDef(objj_allocateTypeDef("ColorType")); 5 | // @typedef ViewType, DataSource 6 | objj_registerTypeDef(objj_allocateTypeDef("ViewType")); 7 | objj_registerTypeDef(objj_allocateTypeDef("DataSource")); 8 | 9 | // @implementation Test 10 | var $the_class = objj_allocateClassPair(Nil, "Test"); 11 | objj_registerClassPair($the_class); 12 | 13 | class_addIvars($the_class, 14 | [ 15 | new objj_ivar("color", "ColorType"), 16 | new objj_ivar("view", "ViewType"), 17 | new objj_ivar("dataSource", "DataSource") 18 | ]); 19 | 20 | // Instance methods 21 | class_addMethods($the_class, 22 | [ 23 | // - (BOOL)hasColorOfType: 24 | new objj_method(sel_getUid("hasColorOfType:"), 25 | function $Test__hasColorOfType_(self, _cmd, type) 26 | { 27 | return type === self.color; 28 | }, 29 | // argument types 30 | ["BOOL", "ColorType"]) 31 | ]); 32 | // @end: @implementation Test 33 | })(); 34 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 The Cappuccino Project 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /lib/nullbuffer.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /** 4 | * API-compatible version of StringBuffer that does nothing. Used when importing 5 | * since no code needs to be generated when importing. 6 | */ 7 | class NullBuffer 8 | { 9 | remove(/* index */) 10 | { 11 | } 12 | 13 | concat(/* string, node */) 14 | { 15 | } 16 | 17 | concatFormat(/* node, scope, selector */) 18 | { 19 | } 20 | 21 | concatWithFormat(/* node, scope, string, format, mapNode */) 22 | { 23 | } 24 | 25 | concatWithFormats(/* node, scope, before, string, after, mapNode */) 26 | { 27 | } 28 | 29 | concatLeftParens(/* node, scope */) 30 | { 31 | } 32 | 33 | concatRightParens(/* node, scope */) 34 | { 35 | } 36 | 37 | concatComma(/* node, scope */) 38 | { 39 | } 40 | 41 | concatOperator(/* node, scope, operator */) 42 | { 43 | } 44 | 45 | concatParenthesizedBlock(node, scope, func) 46 | { 47 | // istanbul ignore next: no need to test 48 | if (func) 49 | func(); 50 | } 51 | 52 | concatBuffer(/* buffer */) 53 | { 54 | } 55 | } 56 | 57 | module.exports = NullBuffer; 58 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/dest/accessors-inline.js: -------------------------------------------------------------------------------- 1 | (function() 2 | { 3 | // @implementation Accessors 4 | var $the_class = objj_allocateClassPair(Nil, "Accessors"); 5 | objj_registerClassPair($the_class); 6 | 7 | class_addIvars($the_class, 8 | [ 9 | new objj_ivar("copyMe", "int") 10 | ]); 11 | 12 | // Instance methods 13 | class_addMethods($the_class, 14 | [ 15 | // copyMe @accessors(copy) [getter] 16 | // - (int)copyMe 17 | new objj_method(sel_getUid("copyMe"), 18 | function $Accessors__copyMe(self, _cmd) 19 | { 20 | return self.copyMe; 21 | }, 22 | // argument types 23 | ["int"]), 24 | 25 | // copyMe @accessors(copy) [setter] 26 | // - (void)setCopyMe:(int)newValue 27 | new objj_method(sel_getUid("setCopyMe:"), 28 | function $Accessors__setCopyMe_(self, _cmd, newValue) 29 | { 30 | if (self.copyMe !== newValue) 31 | /* copyMe = [newValue copy] */ self.copyMe = newValue == null ? null : (newValue.isa.method_msgSend["setCopyMe:"] || _objj_forward)(newValue, "copy"); 32 | }, 33 | // argument types 34 | ["void", "int"]) 35 | ]); 36 | // @end: @implementation Accessors 37 | })(); 38 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/src/duplicate-global-symbols.j: -------------------------------------------------------------------------------- 1 | @implementation First 2 | @end 3 | 4 | // duplicate definition of class 5 | @implementation First 6 | @end 7 | 8 | @implementation First (Category) 9 | @end 10 | 11 | // duplicate definition of category 12 | @implementation First (Category) 13 | @end 14 | 15 | // duplicate class definition is ignored 16 | @class First 17 | 18 | @class Before, Second 19 | 20 | // @class definition is unnecessary 21 | @implementation Second 22 | @end 23 | 24 | // duplicate definition is ignored 25 | @class Third, Second 26 | 27 | // duplicate definition is ignored 28 | @class Fourth, Third 29 | 30 | @protocol Protocol 31 | @end 32 | 33 | // duplicate definition is ignored 34 | @protocol Protocol 35 | @end 36 | 37 | @typedef colorScheme 38 | 39 | // duplicate definition is ignored 40 | @typedef something, colorScheme 41 | 42 | @global Foo, Bar 43 | 44 | // duplicate definition is ignored 45 | @global Bar 46 | 47 | SomeGlobal = 7; 48 | 49 | // duplicate definition is ignored 50 | @global SomeGlobal 51 | 52 | @global AnotherGlobal 53 | 54 | // no warning, it replaces the @global 55 | AnotherGlobal = 7; 56 | 57 | // duplicate predefined global definition is ignored 58 | @global Node 59 | 60 | // reserved word used as a variable name 61 | var NaN = 7; 62 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/dest/suggestions.txt: -------------------------------------------------------------------------------- 1 | 2 | test/fixtures/exceptions/src/suggestions.j:4:12: warning: reference to unknown identifier 'CPstring'; did you mean 'CPString'? 3 | var str = [CPstring stringWithFormat:@"%s cool", @"way"]; 4 | ^ 5 | test/fixtures/exceptions/src/suggestions.j:12:27: error: cannot find protocol declaration for 'CPcopying'; did you mean 'CPCopying'? 6 | @implementation MyObject 7 | ^ 8 | test/fixtures/exceptions/src/suggestions.j:15:4: warning: unknown type 'Colorscheme'; did you mean 'ColorScheme'? 9 | - (Colorscheme)getSchemeWithName:(CPString)name 10 | ^ 11 | test/fixtures/exceptions/src/suggestions.j:20:4: warning: unknown type 'Int'; did you mean 'int'? 12 | - (Int)count 13 | ^ 14 | test/fixtures/exceptions/src/suggestions.j:25:4: warning: unknown type 'Myobject'; did you mean 'MyObject'? 15 | - (Myobject)copy:(MyObject)other 16 | ^ 17 | 18 | 4 warnings and 1 error generated. 19 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/dest/self-super.js: -------------------------------------------------------------------------------- 1 | (function() 2 | { 3 | // @implementation CPObject 4 | var $the_class = objj_allocateClassPair(Nil, "CPObject"); 5 | objj_registerClassPair($the_class); 6 | // @end: @implementation CPObject 7 | 8 | // @implementation Test : CPObject 9 | var $the_class = objj_allocateClassPair(CPObject, "Test"); 10 | objj_registerClassPair($the_class); 11 | 12 | // Instance methods 13 | class_addMethods($the_class, 14 | [ 15 | // - (void)test 16 | new objj_method(sel_getUid("test"), 17 | function $Test__test(self, _cmd) 18 | { 19 | /* [self doSomething] */ self.isa.objj_msgSend0(self, "doSomething"); 20 | /* [super doSomething] */ objj_msgSendSuper0({ receiver: self, super_class: objj_getClass("Test").super_class }, "doSomething"); 21 | 22 | function testme() 23 | { 24 | /* [self doSomething] */ self.isa.objj_msgSend0(self, "doSomething"); 25 | /* [super doSomething] */ objj_msgSendSuper0({ receiver: self, super_class: objj_getClass("Test").super_class }, "doSomething"); 26 | } 27 | }, 28 | // argument types 29 | ["void"]) 30 | ]); 31 | // @end: @implementation Test : CPObject 32 | 33 | test = function test() 34 | { 35 | var self = 7; 36 | 37 | self = 13; 38 | }; 39 | })(); 40 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/dest/reference-dereference.js: -------------------------------------------------------------------------------- 1 | (function() 2 | { 3 | // @implementation Reference 4 | var $the_class = objj_allocateClassPair(Nil, "Reference"); 5 | objj_registerClassPair($the_class); 6 | 7 | // Instance methods 8 | class_addMethods($the_class, 9 | [ 10 | // - (void)mungeRef: 11 | new objj_method(sel_getUid("mungeRef:"), 12 | function $Reference__mungeRef_(self, _cmd, ref) 13 | { 14 | var i = /* ++@deref(ref) */ (ref)(ref() + 1); 15 | 16 | i = /* @deref(ref)++ */ ((ref)(ref() + 1) - 1); 17 | i = /* --@deref(ref) */ (ref)(ref() - 1); 18 | i = /* @deref(ref)-- */ ((ref)(ref() - 1) + 1); 19 | /* @deref(ref) = 27 */ (ref)(27); 20 | /* @deref(ref) += 4 */ (ref)(ref() + 4); 21 | /* @deref(ref) = @deref(ref) - 4 */ (ref)(ref() - 4); 22 | }, 23 | // argument types 24 | ["void", "@ref"]), 25 | 26 | // - (void)test 27 | new objj_method(sel_getUid("test"), 28 | function $Reference__test(self, _cmd) 29 | { 30 | var i = 13; 31 | 32 | /* [self mungeRef:@ref(i)] */ self.isa.objj_msgSend1(self, "mungeRef:", /* @ref(i) */ function $at_ref(__value) { return arguments.length ? i = __value : i; }); 33 | }, 34 | // argument types 35 | ["void"]) 36 | ]); 37 | // @end: @implementation Reference 38 | })(); 39 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/src/message-send-expression-inline.j: -------------------------------------------------------------------------------- 1 | @implementation CPApplication 2 | @end 3 | 4 | @implementation CPString 5 | @end 6 | 7 | @implementation CPTextField 8 | @end 9 | 10 | @class CPArray 11 | 12 | var fileVar = [[CPApplication sharedApplication] mainWindow]; 13 | 14 | @implementation Super 15 | @end 16 | 17 | @implementation Test : Super 18 | { 19 | CPTextField field; 20 | } 21 | 22 | + (void)initialize 23 | { 24 | [super initialize]; 25 | [self classInit]; 26 | } 27 | 28 | + (void)classInit 29 | { 30 | } 31 | 32 | - (id)init 33 | { 34 | self = [super init]; 35 | 36 | if (self) 37 | [self foo]; 38 | 39 | return self; 40 | } 41 | 42 | - (void)foo 43 | { 44 | // Make sure temp vars are *not* put in this block 45 | { 46 | var count = [[self subviews] count]; 47 | } 48 | 49 | field = [[CPTextField alloc] init]; 50 | [field setTitle:[CPString stringWithFormat:@"Count: %d", count]]; 51 | } 52 | 53 | - (CPArray)subviews 54 | { 55 | return [[[[CPApplication sharedApplication] mainWindow] contentView] subviews]; 56 | } 57 | 58 | - (void)doSomething:(CPString)something withNumber:(int)number and:(CPString)and andAlso:(int)also 59 | { 60 | console.log([CPString stringWithFormat:@"%s, %d, %s, %i", something, number, and, also]); 61 | } 62 | 63 | - (void)bigSelector 64 | { 65 | [self doSomething:@"bold" withNumber:7 and:@"something else" andAlso:27]; 66 | } 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/src/accessors.j: -------------------------------------------------------------------------------- 1 | @implementation Test 2 | { 3 | // setter cannot be specified for a readonly ivar 4 | int one @accessors(readonly, setter=setMe); 5 | double two @accessors(readonly); 6 | BOOL three; 7 | id four @accessors; 8 | int prop @accessors(readonly, property=foo); 9 | } 10 | 11 | // Ordinarily this would trigger an error, but since the ivar 'one' is readonly 12 | // and specifies a setter, that error obviates making this an error. 13 | - (void)setMe:(int)newValue 14 | { 15 | } 16 | 17 | // setter method cannot be specified for a readonly ivar 18 | - (void)setTwo:(double)newValue 19 | { 20 | } 21 | 22 | // ivar has no accessors, no problem 23 | - (void)setThree:(BOOL)newValue 24 | { 25 | } 26 | 27 | // ivar is not readonly, no problem 28 | - (void)setFour:(id)newValue 29 | { 30 | } 31 | 32 | // Not a potential setter method 33 | - (double)getTwo 34 | { 35 | } 36 | 37 | // Not a potential setter method since 'two' ivar is readonly 38 | - (void)setTwo 39 | { 40 | } 41 | 42 | // Doesn't match any ivars 43 | - (void)setToo:(double)newValue 44 | { 45 | } 46 | 47 | // setter method cannot be specified for a readonly ivar, make sure we check against the property name 48 | - (void)setFoo:(int)newValue 49 | { 50 | } 51 | 52 | // Class method is not checked 53 | + (void)setTwo:(double)newValue 54 | { 55 | } 56 | 57 | @end 58 | 59 | @protocol Protocol 60 | 61 | // Protocol methods are not checked, they have no ivars 62 | - (void)setTwo:(double)newValue; 63 | 64 | @end 65 | -------------------------------------------------------------------------------- /test/fixtures/cli/exceptions/dest/warnings-none.txt: -------------------------------------------------------------------------------- 1 | (function() 2 | { 3 | debugger; 4 | 5 | var i = 13; 6 | 7 | // @implementation One 8 | var $the_class = objj_allocateClassPair(Nil, "One"); 9 | objj_registerClassPair($the_class); 10 | 11 | // Instance methods 12 | class_addMethods($the_class, 13 | [ 14 | // - (void)test: 15 | new objj_method(sel_getUid("test:"), 16 | function $One__test_(self, _cmd, i) 17 | { 18 | x = 7; 19 | }, 20 | // argument types 21 | ["void", "int"]), 22 | 23 | // - (Foo)foo: 24 | new objj_method(sel_getUid("foo:"), 25 | function $One__foo_(self, _cmd, bar) 26 | { 27 | var y = boo; 28 | }, 29 | // argument types 30 | ["Foo", "int"]) 31 | ]); 32 | // @end: @implementation One 33 | 34 | // @implementation Two : One 35 | var $the_class = objj_allocateClassPair(One, "Two"); 36 | objj_registerClassPair($the_class); 37 | 38 | // Instance methods 39 | class_addMethods($the_class, 40 | [ 41 | // - (void)foo: 42 | new objj_method(sel_getUid("foo:"), 43 | function $Two__foo_(self, _cmd, bar) 44 | { 45 | var NaN = "yo"; 46 | }, 47 | // argument types 48 | ["void", "double"]) 49 | ]); 50 | // @end: @implementation Two : One 51 | })(); 52 | 53 | 54 | test/fixtures/cli/exceptions/src/warnings-none.j:30:9: warning: reserved word used as a variable name 55 | var NaN = "yo"; 56 | ^ 57 | 58 | 1 warning generated. 59 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/src/self.j: -------------------------------------------------------------------------------- 1 | // These uses are all OK 2 | 3 | @implementation Superclass 4 | 5 | - (id)init 6 | { 7 | return self; 8 | } 9 | 10 | @end 11 | 12 | @implementation Test : Superclass 13 | 14 | - (id)init 15 | { 16 | self = [super init]; 17 | 18 | if (self) 19 | { 20 | [self doSomethingWith:[self getSomething]]; 21 | [self useSelf:self]; 22 | } 23 | 24 | return self; 25 | } 26 | 27 | - (void)useSelf:(id)_self 28 | { 29 | [_self doSomethingWith:13]; 30 | } 31 | 32 | - (void)doSomethingWith:(int)something 33 | { 34 | function test() 35 | { 36 | var x = [self getSomething]; 37 | } 38 | } 39 | 40 | - (int)getSomething 41 | { 42 | return 7; 43 | } 44 | 45 | + (void)classMethod:(int)someInt 46 | { 47 | } 48 | 49 | @end 50 | 51 | function selfParam(one, two, self) 52 | { 53 | console.log(self); 54 | } 55 | 56 | function selfVar() 57 | { 58 | var self = Test; 59 | 60 | return [self classMethod:7]; 61 | } 62 | 63 | // These uses generate errors 64 | 65 | // unknown identifier 'self' 66 | [self doSomethingWith:self]; 67 | 68 | // unknown identifier 'self' 69 | var x = self; 70 | 71 | function test() 72 | { 73 | // unknown identifier 'self' 74 | var me = self; 75 | 76 | // unknown identifier 'self' 77 | [self doSomething:[self somethingElse]]; 78 | } 79 | 80 | @implementation Dumb 81 | 82 | // 'self' used as a method parameter 83 | - (void)test:(int)self 84 | { 85 | } 86 | 87 | - (void)testFunction 88 | { 89 | // 'self' used as a function parameter within a method 90 | function selfTest(one, two, self) 91 | { 92 | } 93 | } 94 | 95 | @end 96 | -------------------------------------------------------------------------------- /test/fixtures/cli/exceptions/dest/warnings-list.txt: -------------------------------------------------------------------------------- 1 | (function() 2 | { 3 | debugger; 4 | 5 | var i = 13; 6 | 7 | // @implementation One 8 | var $the_class = objj_allocateClassPair(Nil, "One"); 9 | objj_registerClassPair($the_class); 10 | 11 | // Instance methods 12 | class_addMethods($the_class, 13 | [ 14 | // - (void)test: 15 | new objj_method(sel_getUid("test:"), 16 | function $One__test_(self, _cmd, i) 17 | { 18 | x = 7; 19 | }, 20 | // argument types 21 | ["void", "int"]), 22 | 23 | // - (Foo)foo: 24 | new objj_method(sel_getUid("foo:"), 25 | function $One__foo_(self, _cmd, bar) 26 | { 27 | var y = boo; 28 | }, 29 | // argument types 30 | ["Foo", "int"]) 31 | ]); 32 | // @end: @implementation One 33 | 34 | // @implementation Two : One 35 | var $the_class = objj_allocateClassPair(One, "Two"); 36 | objj_registerClassPair($the_class); 37 | 38 | // Instance methods 39 | class_addMethods($the_class, 40 | [ 41 | // - (void)foo: 42 | new objj_method(sel_getUid("foo:"), 43 | function $Two__foo_(self, _cmd, bar) 44 | { 45 | var NaN = "yo"; 46 | }, 47 | // argument types 48 | ["void", "double"]) 49 | ]); 50 | // @end: @implementation Two : One 51 | })(); 52 | 53 | 54 | test/fixtures/cli/exceptions/src/warnings-list.j:2:1: warning: debugger statement 55 | debugger; 56 | ^ 57 | test/fixtures/cli/exceptions/src/warnings-list.j:16:4: warning: unknown type 'Foo' 58 | - (Foo)foo:(int)bar 59 | ^ 60 | test/fixtures/cli/exceptions/src/warnings-list.j:30:9: warning: reserved word used as a variable name 61 | var NaN = "yo"; 62 | ^ 63 | 64 | 3 warnings generated. 65 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/dest/accessors.txt: -------------------------------------------------------------------------------- 1 | 2 | test/fixtures/exceptions/src/accessors.j:13:1: error: setter method 'setMe:' cannot be defined for the readonly ivar 'one' 3 | - (void)setMe:(int)newValue 4 | ^ 5 | test/fixtures/exceptions/src/accessors.j:4:9: note: ivar declaration is here 6 | int one @accessors(readonly, setter=setMe); 7 | ^ 8 | test/fixtures/exceptions/src/accessors.j:18:1: error: setter method 'setTwo:' cannot be defined for the readonly ivar 'two' 9 | - (void)setTwo:(double)newValue 10 | ^ 11 | test/fixtures/exceptions/src/accessors.j:5:12: note: ivar declaration is here 12 | double two @accessors(readonly); 13 | ^ 14 | test/fixtures/exceptions/src/accessors.j:48:1: error: setter method 'setFoo:' cannot be defined for the readonly ivar 'prop' 15 | - (void)setFoo:(int)newValue 16 | ^ 17 | test/fixtures/exceptions/src/accessors.j:8:9: note: ivar declaration is here 18 | int prop @accessors(readonly, property=foo); 19 | ^ 20 | test/fixtures/exceptions/src/accessors.j:4:41: error: setter cannot be specified for a readonly ivar 21 | int one @accessors(readonly, setter=setMe); 22 | ^ 23 | 24 | 4 errors generated. 25 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/dest/import-stack.txt: -------------------------------------------------------------------------------- 1 | 2 | In file imported from 'test/fixtures/exceptions/src/import-stack.j':1 3 | In file imported from 'test/fixtures/exceptions/src/imports/foo.j':1 4 | test/fixtures/exceptions/src/imports/bar.j:2:9: warning: reference to unknown identifier 'y' 5 | var x = y, 6 | ^ 7 | test/fixtures/exceptions/src/imports/bar.j:15:5: warning: reference to local variable 'one' hides an instance variable 8 | one = 7; 9 | ^ 10 | test/fixtures/exceptions/src/imports/bar.j:17:9: warning: local declaration of 'one' hides an instance variable 11 | var one; 12 | ^ 13 | test/fixtures/exceptions/src/imports/bar.j:9:9: note: hidden declaration is here 14 | int one; 15 | ^ 16 | In file imported from 'test/fixtures/exceptions/src/import-stack.j':1 17 | test/fixtures/exceptions/src/imports/foo.j:4:9: warning: reference to unknown identifier 'y' 18 | var x = y; 19 | ^ 20 | test/fixtures/exceptions/src/imports/foo.j:9:17: warning: reference to unknown identifier 'j' 21 | console.log(j); 22 | ^ 23 | test/fixtures/exceptions/src/import-stack.j:4:9: warning: reference to unknown identifier 'y' 24 | var x = y; 25 | ^ 26 | 27 | 6 warnings generated. 28 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/src/symbol-redefinition.j: -------------------------------------------------------------------------------- 1 | // 2 | // @class 3 | // 4 | @class Have, Some, Class 5 | 6 | // 'Class' previously defined as a class 7 | @global Class 8 | @typedef One, Class 9 | 10 | @protocol Class 11 | @end 12 | 13 | Class = "class"; 14 | 15 | 16 | // 17 | // @global 18 | // 19 | @global Global 20 | 21 | // 'Global' previously defined as a global 22 | @class Global 23 | @typedef Two, Global 24 | 25 | @implementation Global 26 | @end 27 | 28 | @protocol Global 29 | @end 30 | 31 | // no error 32 | Global = 7; 33 | 34 | // 35 | // @typedef 36 | // 37 | @typedef Foo, Typedef 38 | 39 | // 'Typedef' previously defined as a typedef 40 | @class Bar, Typedef 41 | @global Typedef 42 | Typedef = 7; 43 | 44 | @implementation Typedef 45 | @end 46 | 47 | @protocol Typedef 48 | @end 49 | 50 | 51 | // 52 | // global 53 | // 54 | SomeGlobal = 7; 55 | 56 | // 'SomeGlobal' previously defined as a global 57 | @class Something, SomeGlobal 58 | @typedef SomeGlobal 59 | 60 | @implementation SomeGlobal 61 | @end 62 | 63 | @protocol SomeGlobal 64 | @end 65 | 66 | 67 | // 68 | // predefined global 69 | // 70 | 71 | // 'Node' is a predefined global 72 | @class Node 73 | @typedef Node 74 | 75 | @implementation Node 76 | @end 77 | 78 | @protocol Node 79 | @end 80 | 81 | 82 | // 83 | // @implementation 84 | // 85 | @implementation WooHoo 86 | @end 87 | 88 | // 'WooHoo' previously defined as a class 89 | @global WooHoo 90 | @typedef WooHoo 91 | 92 | WooHoo = 7; 93 | 94 | @protocol WooHoo 95 | @end 96 | 97 | 98 | // 99 | // @protocol 100 | // 101 | @protocol Protocol 102 | @end 103 | 104 | // 'Protocol' previously defined as a protocol 105 | @global Protocol 106 | @typedef Protocol 107 | 108 | Protocol = 7; 109 | 110 | @implementation Protocol 111 | @end 112 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/dest/self.txt: -------------------------------------------------------------------------------- 1 | 2 | test/fixtures/exceptions/src/self.j:66:2: warning: reference to unknown identifier 'self' 3 | [self doSomethingWith:self]; 4 | ^ 5 | test/fixtures/exceptions/src/self.j:66:23: warning: reference to unknown identifier 'self' 6 | [self doSomethingWith:self]; 7 | ^ 8 | test/fixtures/exceptions/src/self.j:69:9: warning: reference to unknown identifier 'self' 9 | var x = self; 10 | ^ 11 | test/fixtures/exceptions/src/self.j:74:14: warning: reference to unknown identifier 'self' 12 | var me = self; 13 | ^ 14 | test/fixtures/exceptions/src/self.j:77:6: warning: reference to unknown identifier 'self' 15 | [self doSomething:[self somethingElse]]; 16 | ^ 17 | test/fixtures/exceptions/src/self.j:77:24: warning: reference to unknown identifier 'self' 18 | [self doSomething:[self somethingElse]]; 19 | ^ 20 | test/fixtures/exceptions/src/self.j:83:19: error: 'self' used as a method parameter 21 | - (void)test:(int)self 22 | ^ 23 | test/fixtures/exceptions/src/self.j:90:33: error: 'self' used as a function parameter within a method 24 | function selfTest(one, two, self) 25 | ^ 26 | 27 | 6 warnings and 2 errors generated. 28 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cappuccino.compiler", 3 | "version": "1.0.0-beta.1", 4 | "description": "JavaScript (ECMAScript) and Objective-J compiler", 5 | "homepage": "https://github.com/cappuccino/objjc", 6 | "keywords": [ 7 | "JavaScript", 8 | "ECMAScript", 9 | "Objective-J", 10 | "Cappuccino", 11 | "compiler" 12 | ], 13 | "contributors": [ 14 | "Martin Carlberg (http://carlberg.org)", 15 | "Aparajita Fishman (http://www.aparajita.com)" 16 | ], 17 | "license": "MIT", 18 | "repository": { 19 | "type": "git", 20 | "url": "https://github.com/cappuccino/objjc.git" 21 | }, 22 | "bugs": "https://github.com/cappuccino/objjc/issues", 23 | "engines": { 24 | "node": ">=5" 25 | }, 26 | "bin": { 27 | "objjc": "./bin/objjc.js" 28 | }, 29 | "scripts": { 30 | "test": "gulp test", 31 | "postversion": "git push && git push --tags && npm publish" 32 | }, 33 | "dependencies": { 34 | "acorn": "~3.2.0", 35 | "acorn-issue-handler": "~1.1.1", 36 | "acorn-objj": "~1.1.3", 37 | "chalk": "~1.1.3", 38 | "mkdirp": "~0.5.1", 39 | "optionator": "~0.8.1", 40 | "source-map": "~0.5.6" 41 | }, 42 | "devDependencies": { 43 | "capture-stream": "~0.1.2", 44 | "code": "~3.0.1", 45 | "del": "~2.2.1", 46 | "eslint": "~3.0.0", 47 | "eslint-clang-formatter": "~1.3.0", 48 | "eslint-config-cappuccino": "~1.3.6", 49 | "gulp": "~3.9.1", 50 | "gulp-eslint": "~2.0.0", 51 | "gulp-jscs": "~4.0.0", 52 | "gulp-load-plugins": "~1.2.4", 53 | "gulp-mocha": "~2.2.0", 54 | "gulp-newer": "~1.2.0", 55 | "gulp-rename": "~1.2.2", 56 | "gulp-replace": "~0.5.3", 57 | "gulp-util": "^3.0.7", 58 | "istanbul": "~0.4.4", 59 | "jscs": "~3.0.6", 60 | "jscs-cappuccino": "~1.1.0", 61 | "jscs-clang-reporter": "~1.1.11", 62 | "mocha": "~2.5.3", 63 | "path-exists": "~3.0.0", 64 | "rimraf": "~2.5.2", 65 | "run-sequence": "~1.2.2", 66 | "through2": "~2.0.1" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /lib/indentation.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | let Instance = null; 4 | 5 | /** 6 | * Indenter 7 | */ 8 | class Indenter 9 | { 10 | constructor() 11 | { 12 | this.indentString = ""; 13 | this.indentWidth = 0; 14 | this.indentSize = this.indentWidth * this.indentString.length; 15 | this.indentStep = this.indentString.repeat(this.indentWidth); 16 | this.indentation = ""; 17 | } 18 | 19 | /** 20 | * @returns {Indenter} - Singleton instance of this class 21 | */ 22 | static instance() 23 | { 24 | // istanbul ignore else: just in case 25 | if (!Instance) 26 | Instance = new Indenter(); 27 | 28 | return Instance; 29 | } 30 | 31 | setIndent(string, width) 32 | { 33 | this.indentString = string; 34 | this.indentWidth = width; 35 | this.indentSize = this.indentWidth * this.indentString.length; 36 | this.indentStep = this.indentString.repeat(this.indentWidth); 37 | this.indentation = ""; 38 | } 39 | 40 | indent(count) 41 | { 42 | this.indentation += this.indentStep.repeat(count || 1); 43 | } 44 | 45 | dedent(count) 46 | { 47 | this.indentation = this.indentation.substring(this.indentSize * (count || 1)); 48 | } 49 | 50 | static indentString(string, skipFirstLine) 51 | { 52 | // First indent the beginning of each line that is not empty 53 | const lines = string.split("\n"); 54 | 55 | for (let i = skipFirstLine ? 1 : 0; i < lines.length; i++) 56 | { 57 | const line = lines[i]; 58 | 59 | if (/\S/.test(line)) 60 | lines[i] = Instance.indentation + lines[i]; 61 | } 62 | 63 | // Finally replace tab placeholders with an indent step 64 | return lines.join("\n").replace(/→/g, Instance.indentStep); 65 | } 66 | } 67 | 68 | /** 69 | * @type {Indenter} 70 | */ 71 | module.exports = { 72 | indenter: Indenter.instance(), 73 | indentString: Indenter.indentString 74 | }; 75 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/src/protocol-conformance.j: -------------------------------------------------------------------------------- 1 | @protocol One 2 | 3 | // implicitly required 4 | - (void)oneRequired1; 5 | + (void)oneClassRequired1; 6 | 7 | @required 8 | - (void)oneRequired2; 9 | - (void)oneRequired3; 10 | - (void)override; 11 | + (void)oneClassRequired2; 12 | 13 | @optional 14 | - (void)oneOptional1; 15 | - (void)oneOptional2; 16 | - (void)oneClassOptional1; 17 | 18 | @end 19 | 20 | @protocol Two 21 | 22 | @required 23 | - (void)twoRequired1; 24 | - (int)override; 25 | + (void)twoClassRequired1; 26 | 27 | @optional 28 | - (void)twoOptional1; 29 | + (void)twoClassOptional1; 30 | 31 | @end 32 | 33 | @protocol Three 34 | 35 | // implicitly required 36 | - (void)threeRequired1; 37 | + (void)threeClassRequired1; 38 | 39 | @optional 40 | - (void)threeOptional1; 41 | 42 | @end 43 | 44 | // Warnings: 45 | // oneRequired1, oneRequired2, oneClassRequired2, override 46 | // twoRequired1, twoClassRequired1, override 47 | // threeRequired1 48 | @implementation Class1 49 | 50 | + (void)oneClassRequired1 51 | { 52 | } 53 | 54 | + (void)threeClassRequired1 55 | { 56 | } 57 | 58 | - (void)oneRequired3 59 | { 60 | } 61 | 62 | - (void)oneOptional2 63 | { 64 | } 65 | 66 | @end 67 | 68 | // Protocol conformance is assumed in inherited classes, 69 | // so there should be no warnings for this class. 70 | @implementation Class2 : Class1 71 | @end 72 | 73 | // Warnings: 74 | // oneRequired3, oneClassRequired2, override 75 | @implementation Class3 76 | 77 | - (void)oneRequired1 78 | { 79 | } 80 | 81 | + (void)oneClassRequired1 82 | { 83 | } 84 | 85 | - (void)oneRequired2 86 | { 87 | } 88 | 89 | @end 90 | 91 | // adopts , but because protocol conformance is assumed in inherited classes, 92 | // and Class3 adopts , this class will only warn about methods from itself, 93 | // override and twoClassRequired1. 94 | @implementation Class4: Class3 95 | 96 | - (void)override 97 | { 98 | } 99 | 100 | @end 101 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/src/message-send-expression.j: -------------------------------------------------------------------------------- 1 | @implementation CPApplication 2 | @end 3 | 4 | @implementation CPString 5 | @end 6 | 7 | @implementation CPTextField 8 | @end 9 | 10 | @class CPArray 11 | 12 | var fileVar = [ 13 | [CPApplication sharedApplication] 14 | mainWindow 15 | ]; 16 | 17 | @implementation Super 18 | 19 | - (void)manyArgs:(int)one two:(int)two three:(int)three four:(int)four 20 | { 21 | } 22 | 23 | @end 24 | 25 | @implementation Test : Super 26 | { 27 | CPTextField field; 28 | } 29 | 30 | + (void)initialize 31 | { 32 | [super initialize]; 33 | [self classInit]; 34 | } 35 | 36 | + (void)classInit 37 | { 38 | } 39 | 40 | - (id)init 41 | { 42 | self = [super init]; 43 | 44 | if (self) 45 | [self foo]; 46 | 47 | return self; 48 | } 49 | 50 | - (void)foo 51 | { 52 | // Make sure temp vars are *not* put in this block 53 | { 54 | var count = [[self subviews] count]; 55 | } 56 | 57 | field = [[CPTextField alloc] init]; 58 | [field setTitle: 59 | [CPString stringWithFormat:@"Count: %d", count]]; 60 | } 61 | 62 | - (CPArray)subviews 63 | { 64 | // We're using funky indentation here to test source map generation 65 | return [[[ 66 | [CPApplication sharedApplication] 67 | mainWindow] 68 | contentView] 69 | subviews]; 70 | } 71 | 72 | - (void)doSomething:(CPString)something withNumber:(int)number and:(CPString)and andAlso:(int)also 73 | { 74 | console.log([CPString stringWithFormat:@"%s, %d, %s, %i", something, number, and, also]); 75 | } 76 | 77 | - (void)bigSelector 78 | { 79 | [self doSomething:@"bold" 80 | withNumber:7 81 | and:@"something else" 82 | andAlso:27]; 83 | [super manyArgs:1 84 | two:2 85 | three:3 86 | four:4]; 87 | } 88 | 89 | - (void)emptySelector:(int)one :(double)two :(CPArray)three 90 | { 91 | } 92 | 93 | - (void)testEmptySelector 94 | { 95 | [self emptySelector:1 :2 :[3]]; 96 | } 97 | 98 | @end 99 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/src/identifiers.j: -------------------------------------------------------------------------------- 1 | // unknown identifier 'bar' 2 | var foo = bar; 3 | 4 | // unknown identifier 'CPString' 5 | var str = [CPString stringWithFormat:@"%s cool", @"way"]; 6 | 7 | // unknown identifier 'CPApp', but it is declared later so there is no warning 8 | [CPApp doSomething]; 9 | 10 | @class CPApp 11 | 12 | @implementation Test 13 | 14 | - (void)test 15 | { 16 | var one = 7, 17 | two = 13; // Oops, this should have been a comma, the next three assignments create implicit globals 18 | three = 27, 19 | four = 31, 20 | x = @"foo"; 21 | 22 | // At this point 'x' created an implicit global warning, but the var declaration will remove it. 23 | var x; 24 | 25 | // unknown identifier warning 26 | x = unknownVar; 27 | 28 | // This creates an unknown identifier warning, but the var declaration later removes it. 29 | one = deferredVar; 30 | 31 | var deferredVar; 32 | } 33 | 34 | @end 35 | 36 | function doSomething() 37 | { 38 | } 39 | 40 | function test() 41 | { 42 | // Even though the 'two' and 'three' assignments are made to known implicit globals from the 'test' 43 | // method above, we warn again because we assume they are mistaken implicit globals in this scope. 44 | 45 | var one = 7; // Oops, this should have been a comma, the next assignment warns about implicit global 46 | two = 1931; 47 | 48 | // This will not warn because 'two' is already an implicit global in this scope 49 | two = 2; 50 | 51 | // This will warn because 'four' is an implicit global in another scope 52 | four = "bar"; 53 | 54 | // implicit global warning 55 | for (i = 0, j = 0; j < 7; ++j, jj = 13) 56 | console.log(j); 57 | 58 | // implicit global warning 59 | while (k = doSomething()) 60 | console.log(k); 61 | 62 | // implicit global warning 63 | if (l = doSomething()) 64 | console.log(l); 65 | 66 | // implicit global warning 67 | console.log(z || (z = "foo")); 68 | 69 | var a = []; 70 | 71 | a[x || (x = 7)]; 72 | 73 | q += 1; 74 | } 75 | -------------------------------------------------------------------------------- /lib/exceptions.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const issueHandler = require("acorn-issue-handler"); 4 | 5 | class CompileAbortedError extends Error {} 6 | 7 | class TooManyErrors extends CompileAbortedError 8 | { 9 | constructor(maxErrors) 10 | { 11 | super(`too many errors (>${maxErrors})`); 12 | } 13 | } 14 | 15 | class FilterableWarning extends issueHandler.Warning 16 | { 17 | constructor(source, file, location, message) 18 | { 19 | super(source, file, location, message); 20 | this.filterable = true; 21 | } 22 | } 23 | 24 | class ImplicitGlobalWarning extends FilterableWarning 25 | { 26 | static identifierIsValidInScope(identifier, scope) 27 | { 28 | const scopeVar = scope.getLocalVar(identifier); 29 | 30 | return scopeVar && !scopeVar.implicit; 31 | } 32 | 33 | isValidInScope(scope) 34 | { 35 | return this.constructor.identifierIsValidInScope(this.node.name, scope); 36 | } 37 | } 38 | 39 | class ImplicitGlobalNote extends issueHandler.Note 40 | { 41 | constructor(source, file, location, message) 42 | { 43 | super(source, file, location, message); 44 | this.filterable = true; 45 | } 46 | 47 | isValidInScope(scope) 48 | { 49 | return ImplicitGlobalWarning.identifierIsValidInScope(this.node.name, scope); 50 | } 51 | } 52 | 53 | class UnknownIdentifierWarning extends FilterableWarning 54 | { 55 | isValidInScope(scope) 56 | { 57 | const identifier = this.node.name; 58 | 59 | return ( 60 | scope.getLocalVar(identifier) || 61 | scope.getGlobalVar(identifier) || 62 | scope.compiler.getClassDef(identifier) 63 | ); 64 | } 65 | } 66 | 67 | class GlobalIdentifierNote extends issueHandler.Note {} 68 | 69 | exports.CompileAbortedError = CompileAbortedError; 70 | exports.TooManyErrors = TooManyErrors; 71 | exports.ImplicitGlobalWarning = ImplicitGlobalWarning; 72 | exports.ImplicitGlobalNote = ImplicitGlobalNote; 73 | exports.UnknownIdentifierWarning = UnknownIdentifierWarning; 74 | exports.GlobalIdentifierNote = GlobalIdentifierNote; 75 | -------------------------------------------------------------------------------- /test/fixtures/cli/code/dest/ast-2.txt: -------------------------------------------------------------------------------- 1 | { 2 | "type": "Program", 3 | "start": 0, 4 | "end": 11, 5 | "loc": { 6 | "start": { 7 | "line": 1, 8 | "column": 0 9 | }, 10 | "end": { 11 | "line": 2, 12 | "column": 0 13 | } 14 | }, 15 | "sourceFile": "ast-2.txt", 16 | "body": [ 17 | { 18 | "type": "VariableDeclaration", 19 | "start": 0, 20 | "end": 10, 21 | "loc": { 22 | "start": { 23 | "line": 1, 24 | "column": 0 25 | }, 26 | "end": { 27 | "line": 1, 28 | "column": 10 29 | } 30 | }, 31 | "sourceFile": "ast-2.txt", 32 | "declarations": [ 33 | { 34 | "type": "VariableDeclarator", 35 | "start": 4, 36 | "end": 9, 37 | "loc": { 38 | "start": { 39 | "line": 1, 40 | "column": 4 41 | }, 42 | "end": { 43 | "line": 1, 44 | "column": 9 45 | } 46 | }, 47 | "sourceFile": "ast-2.txt", 48 | "id": { 49 | "type": "Identifier", 50 | "start": 4, 51 | "end": 5, 52 | "loc": { 53 | "start": { 54 | "line": 1, 55 | "column": 4 56 | }, 57 | "end": { 58 | "line": 1, 59 | "column": 5 60 | } 61 | }, 62 | "sourceFile": "ast-2.txt", 63 | "name": "x" 64 | }, 65 | "init": { 66 | "type": "Literal", 67 | "start": 8, 68 | "end": 9, 69 | "loc": { 70 | "start": { 71 | "line": 1, 72 | "column": 8 73 | }, 74 | "end": { 75 | "line": 1, 76 | "column": 9 77 | } 78 | }, 79 | "sourceFile": "ast-2.txt", 80 | "value": 7, 81 | "raw": "7" 82 | } 83 | } 84 | ], 85 | "kind": "var" 86 | } 87 | ], 88 | "sourceType": "script" 89 | } 90 | -------------------------------------------------------------------------------- /lib/utils.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const 4 | fs = require("fs"), 5 | path = require("path"); 6 | 7 | exports.readSource = sourcePath => 8 | { 9 | let source; 10 | 11 | try 12 | { 13 | source = fs.readFileSync(sourcePath, "utf8"); 14 | } 15 | catch (e) 16 | { 17 | let error; 18 | 19 | switch (e.code) 20 | { 21 | case "ENOENT": 22 | error = `no such file '${sourcePath}'`; 23 | break; 24 | 25 | case "EISDIR": 26 | error = `'${sourcePath}' is a directory`; 27 | break; 28 | 29 | // istanbul ignore next: failsafe 30 | default: 31 | error = `could not read file (${e.message})`; 32 | } 33 | 34 | throw new Error(error); 35 | } 36 | 37 | return source; 38 | }; 39 | 40 | /** 41 | * Convert an absolute path to a relative path. 42 | * 43 | * @param {string} sourcePath - Path to convert. 44 | * @returns {string} - Converted path. 45 | */ 46 | exports.getRelativeSourcePath = function(sourcePath) 47 | { 48 | if (sourcePath === "") 49 | return sourcePath; 50 | 51 | let relativePath = path.relative(process.cwd(), sourcePath); 52 | 53 | // If the relative path has more than two successive .. motions, make it absolute. 54 | // istanbul ignore next: I've tested this manually and I'm satisfied it works 55 | if (/^\.\.[/\\]\.\.[/\\]\.\./.test(relativePath)) 56 | relativePath = path.resolve(relativePath); 57 | 58 | return relativePath; 59 | }; 60 | 61 | /** 62 | When storing nodes for later reference, we don't want to store 63 | the whole thing, because this would not allow child nodes to 64 | be garbage collected. So we copy only the info that we need. 65 | 66 | @param {acorn.Node} node - Node to copy info from. 67 | @returns {Object} - New object with relevant node info. 68 | */ 69 | exports.copyNode = function(node) 70 | { 71 | return { 72 | type: node.type, 73 | name: node.name, 74 | start: node.start, 75 | end: node.end, 76 | loc: node.loc, 77 | objj: node.objj, 78 | sourceFile: node.sourceFile 79 | }; 80 | }; 81 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/dest/duplicate-methods.txt: -------------------------------------------------------------------------------- 1 | 2 | test/fixtures/exceptions/src/duplicate-methods.j:12:1: error: duplicate definition of method 'one' 3 | - (void)one 4 | ^ 5 | test/fixtures/exceptions/src/duplicate-methods.j:3:1: note: original definition is here: 6 | - (void)one 7 | ^ 8 | test/fixtures/exceptions/src/duplicate-methods.j:22:1: error: duplicate definition of method 'one' 9 | + (void)one 10 | ^ 11 | test/fixtures/exceptions/src/duplicate-methods.j:17:1: note: original definition is here: 12 | + (void)one 13 | ^ 14 | test/fixtures/exceptions/src/duplicate-methods.j:34:1: warning: duplicate declaration of method 'one' ignored 15 | - (void)one; 16 | ^ 17 | test/fixtures/exceptions/src/duplicate-methods.j:30:1: note: first declaration is here: 18 | - (void)one; 19 | ^ 20 | test/fixtures/exceptions/src/duplicate-methods.j:37:1: warning: duplicate declaration of method 'one' ignored 21 | - (void)one; 22 | ^ 23 | test/fixtures/exceptions/src/duplicate-methods.j:30:1: note: first declaration is here: 24 | - (void)one; 25 | ^ 26 | test/fixtures/exceptions/src/duplicate-methods.j:42:1: warning: duplicate declaration of method 'class1' ignored 27 | + (void)class1; 28 | ^ 29 | test/fixtures/exceptions/src/duplicate-methods.j:39:1: note: first declaration is here: 30 | + (void)class1; 31 | ^ 32 | 33 | 3 warnings and 2 errors generated. 34 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/dest/method-declaration.js: -------------------------------------------------------------------------------- 1 | (function() 2 | { 3 | // @protocol Protocol1 4 | var $the_protocol = objj_allocateProtocol("Protocol1"); 5 | 6 | objj_registerProtocol($the_protocol); 7 | 8 | // @end: @protocol Protocol1 9 | 10 | // @protocol Protocol2 11 | var $the_protocol = objj_allocateProtocol("Protocol2"); 12 | 13 | objj_registerProtocol($the_protocol); 14 | 15 | // @end: @protocol Protocol2 16 | 17 | // @implementation Methods 18 | var $the_class = objj_allocateClassPair(Nil, "Methods"); 19 | objj_registerClassPair($the_class); 20 | 21 | // Instance methods 22 | class_addMethods($the_class, 23 | [ 24 | // - (id)defaultType 25 | new objj_method(sel_getUid("defaultType"), 26 | function $Methods__defaultType(self, _cmd) 27 | { 28 | }, 29 | // argument types 30 | ["id"]), 31 | 32 | // - (void)action1 33 | new objj_method(sel_getUid("action1"), 34 | function $Methods__action1(self, _cmd) 35 | { 36 | }, 37 | // argument types 38 | ["void"]), 39 | 40 | // - (void)action2 41 | new objj_method(sel_getUid("action2"), 42 | function $Methods__action2(self, _cmd) 43 | { 44 | }, 45 | // argument types 46 | ["void"]), 47 | 48 | // - (id)returnProtocols 49 | new objj_method(sel_getUid("returnProtocols"), 50 | function $Methods__returnProtocols(self, _cmd) 51 | { 52 | }, 53 | // argument types 54 | ["id"]), 55 | 56 | // - (void)selectorWith: 57 | new objj_method(sel_getUid("selectorWith:"), 58 | function $Methods__selectorWith_(self, _cmd, one) 59 | { 60 | eval("doSomething()"); 61 | }, 62 | // argument types 63 | ["void", "int"]), 64 | 65 | // - (void)selectorWith:two: 66 | new objj_method(sel_getUid("selectorWith:two:"), 67 | function $Methods__selectorWith_two_(self, _cmd, one, two) 68 | { 69 | }, 70 | // argument types 71 | ["void", "int", "double"]), 72 | 73 | // - (void)selectorWithProtocols: 74 | new objj_method(sel_getUid("selectorWithProtocols:"), 75 | function $Methods__selectorWithProtocols_(self, _cmd, protocols) 76 | { 77 | }, 78 | // argument types 79 | ["void", "id"]), 80 | 81 | // - (void)varArgs: 82 | new objj_method(sel_getUid("varArgs:"), 83 | function $Methods__varArgs_(self, _cmd, count) 84 | { 85 | }, 86 | // argument types 87 | ["void", "int"]) 88 | ]); 89 | // @end: @implementation Methods 90 | })(); 91 | -------------------------------------------------------------------------------- /test/code.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const 4 | expect = require("code").expect, 5 | fs = require("fs"), 6 | path = require("path"), 7 | utils = require("./lib/utils.js"); 8 | 9 | function makeTest(prefix, file) 10 | { 11 | const 12 | srcName = path.basename(file), 13 | baseName = path.basename(file, path.extname(file)), 14 | fixture = `${prefix}/src/${srcName}`, 15 | dest = `${prefix}/dest/${baseName}.js`; 16 | 17 | specify(baseName.replace(/-/g, " "), () => 18 | { 19 | const 20 | baseOptions = { 21 | ignoreWarnings: !prefix.startsWith("warnings") 22 | }, 23 | compileOptions = Object.assign({}, baseOptions, utils.setCompilerOptions({}, srcName)), 24 | code = utils.compiledFixture(fixture, compileOptions).code; 25 | 26 | expect(code).to.equal(utils.readFixture(dest)); 27 | }); 28 | } 29 | 30 | function makeContext(title, prefix) 31 | { 32 | context(title, () => 33 | { 34 | const 35 | filePath = `test/fixtures/${prefix}/src`, 36 | files = fs.readdirSync(filePath); 37 | 38 | for (let file of files) 39 | { 40 | const st = fs.statSync(`${filePath}/${file}`); 41 | 42 | if (st.isFile()) 43 | makeTest(prefix, file); 44 | } 45 | 46 | if (prefix.includes("objj-nodes")) 47 | testImports(); 48 | }); 49 | } 50 | 51 | function testImports() 52 | { 53 | const 54 | baseDir = "objj-nodes", 55 | srcDir = `${baseDir}/src/import`, 56 | destDir = `${baseDir}/dest/import`, 57 | fileInfo = [ 58 | ["import-local", "@import \"foo.j\" should import the global symbols from 'foo.j'"], 59 | ["import-chain", "Imported files may themselves import other files"], 60 | ["foo/import-relative", "Local imports paths are relative to the file in which @import appears"], 61 | ["import-cache", "Only the first import of a file parses its symbols, subsequent imports are ignored"] 62 | ]; 63 | 64 | context("import", () => 65 | { 66 | for (const info of fileInfo) 67 | { 68 | const 69 | filename = info[0], 70 | description = info[1]; 71 | 72 | specify(description, () => 73 | { 74 | const code = utils.compiledFixture(`${srcDir}/${filename}.j`).code; 75 | 76 | expect(code).to.equal(utils.readFixture(`${destDir}/${filename}.js`)); 77 | }); 78 | } 79 | }); 80 | } 81 | 82 | context("Code generation", () => 83 | { 84 | makeContext("Javascript nodes", "js-nodes"); 85 | makeContext("Objective-J nodes", "objj-nodes"); 86 | }); 87 | -------------------------------------------------------------------------------- /test/fixtures/cli/exceptions/dest/warnings-enable-disable.txt: -------------------------------------------------------------------------------- 1 | (function() 2 | { 3 | debugger; 4 | 5 | var i = 13; 6 | 7 | // @implementation One 8 | var $the_class = objj_allocateClassPair(Nil, "One"); 9 | objj_registerClassPair($the_class); 10 | 11 | // Instance methods 12 | class_addMethods($the_class, 13 | [ 14 | // - (void)test: 15 | new objj_method(sel_getUid("test:"), 16 | function $One__test_(self, _cmd, i) 17 | { 18 | x = 7; 19 | }, 20 | // argument types 21 | ["void", "int"]), 22 | 23 | // - (Foo)foo: 24 | new objj_method(sel_getUid("foo:"), 25 | function $One__foo_(self, _cmd, bar) 26 | { 27 | var y = boo; 28 | }, 29 | // argument types 30 | ["Foo", "int"]) 31 | ]); 32 | // @end: @implementation One 33 | 34 | // @implementation Two : One 35 | var $the_class = objj_allocateClassPair(One, "Two"); 36 | objj_registerClassPair($the_class); 37 | 38 | // Instance methods 39 | class_addMethods($the_class, 40 | [ 41 | // - (void)foo: 42 | new objj_method(sel_getUid("foo:"), 43 | function $Two__foo_(self, _cmd, bar) 44 | { 45 | var NaN = "yo"; 46 | }, 47 | // argument types 48 | ["void", "double"]) 49 | ]); 50 | // @end: @implementation Two : One 51 | })(); 52 | 53 | 54 | test/fixtures/cli/exceptions/src/warnings-enable-disable.j:2:1: warning: debugger statement 55 | debugger; 56 | ^ 57 | test/fixtures/cli/exceptions/src/warnings-enable-disable.j:9:19: warning: method parameter 'i' hides a file variable 58 | - (void)test:(int)i 59 | ^ 60 | test/fixtures/cli/exceptions/src/warnings-enable-disable.j:4:5: note: hidden declaration is here 61 | var i = 13; 62 | ^ 63 | test/fixtures/cli/exceptions/src/warnings-enable-disable.j:19:13: warning: reference to unknown identifier 'boo' 64 | var y = boo; 65 | ^ 66 | test/fixtures/cli/exceptions/src/warnings-enable-disable.j:30:9: warning: reserved word used as a variable name 67 | var NaN = "yo"; 68 | ^ 69 | test/fixtures/cli/exceptions/src/warnings-enable-disable.j:27:4: warning: conflicting return type in declaration of 'foo:': 'void' vs. 'Foo' 70 | - (void)foo:(double)bar 71 | ^ 72 | test/fixtures/cli/exceptions/src/warnings-enable-disable.j:16:4: note: previous declaration is here 73 | - (Foo)foo:(int)bar 74 | ^ 75 | test/fixtures/cli/exceptions/src/warnings-enable-disable.j:27:14: warning: conflicting parameter type in declaration of 'foo:': 'double' vs. 'int' 76 | - (void)foo:(double)bar 77 | ^ 78 | test/fixtures/cli/exceptions/src/warnings-enable-disable.j:16:13: note: previous declaration is here 79 | - (Foo)foo:(int)bar 80 | ^ 81 | 82 | 6 warnings generated. 83 | -------------------------------------------------------------------------------- /.idea/jsLinters/jshint.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 83 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/dest/missing-dependencies.txt: -------------------------------------------------------------------------------- 1 | 2 | test/fixtures/exceptions/src/missing-dependencies.j:2:23: error: cannot find implementation declaration for 'Bar', superclass of 'Foo' 3 | @implementation Foo : Bar 4 | ^ 5 | test/fixtures/exceptions/src/missing-dependencies.j:6:16: error: cannot find protocol declaration for 'Two' 6 | @protocol One 7 | ^ 8 | test/fixtures/exceptions/src/missing-dependencies.j:6:21: error: cannot find protocol declaration for 'Three' 9 | @protocol One 10 | ^ 11 | test/fixtures/exceptions/src/missing-dependencies.j:10:34: error: cannot find protocol declaration for 'Two' 12 | @implementation NoProtocol 13 | ^ 14 | test/fixtures/exceptions/src/missing-dependencies.j:10:39: error: cannot find protocol declaration for 'Three' 15 | @implementation NoProtocol 16 | ^ 17 | test/fixtures/exceptions/src/missing-dependencies.j:13:12: warning: cannot find protocol declaration for 'Three' 18 | - (id)one:(id)protocol 19 | ^ 20 | test/fixtures/exceptions/src/missing-dependencies.j:13:27: warning: cannot find protocol declaration for 'Two' 21 | - (id)one:(id)protocol 22 | ^ 23 | test/fixtures/exceptions/src/missing-dependencies.j:13:32: warning: cannot find protocol declaration for 'Three' 24 | - (id)one:(id)protocol 25 | ^ 26 | test/fixtures/exceptions/src/missing-dependencies.j:18:7: warning: cannot find protocol declaration for 'Two' 27 | - (id)two:(id)protocol 28 | ^ 29 | test/fixtures/exceptions/src/missing-dependencies.j:21:23: error: cannot find protocol declaration for 'Foo' 30 | var p = @protocol(Foo); 31 | ^ 32 | test/fixtures/exceptions/src/missing-dependencies.j:27:1: error: cannot find implementation declaration for 'SomeClass' 33 | @implementation SomeClass (SomeCategory) 34 | ^ 35 | 36 | 4 warnings and 7 errors generated. 37 | -------------------------------------------------------------------------------- /test/fixtures/cli/exceptions/dest/warnings-all.txt: -------------------------------------------------------------------------------- 1 | (function() 2 | { 3 | debugger; 4 | 5 | var i = 13; 6 | 7 | // @implementation One 8 | var $the_class = objj_allocateClassPair(Nil, "One"); 9 | objj_registerClassPair($the_class); 10 | 11 | class_addIvars($the_class, 12 | [ 13 | new objj_ivar("title", "CPString") 14 | ]); 15 | 16 | // Instance methods 17 | class_addMethods($the_class, 18 | [ 19 | // - (void)test: 20 | new objj_method(sel_getUid("test:"), 21 | function $One__test_(self, _cmd, i) 22 | { 23 | x = 7; 24 | }, 25 | // argument types 26 | ["void", "int"]), 27 | 28 | // - (Foo)foo: 29 | new objj_method(sel_getUid("foo:"), 30 | function $One__foo_(self, _cmd, bar) 31 | { 32 | var y = boo; 33 | }, 34 | // argument types 35 | ["Foo", "int"]) 36 | ]); 37 | // @end: @implementation One 38 | 39 | // @implementation Two : One 40 | var $the_class = objj_allocateClassPair(One, "Two"); 41 | objj_registerClassPair($the_class); 42 | 43 | // Instance methods 44 | class_addMethods($the_class, 45 | [ 46 | // - (void)foo: 47 | new objj_method(sel_getUid("foo:"), 48 | function $Two__foo_(self, _cmd, bar) 49 | { 50 | var NaN = "yo"; 51 | }, 52 | // argument types 53 | ["void", "double"]) 54 | ]); 55 | // @end: @implementation Two : One 56 | })(); 57 | 58 | 59 | test/fixtures/cli/exceptions/src/warnings-all.j:2:1: warning: debugger statement 60 | debugger; 61 | ^ 62 | test/fixtures/cli/exceptions/src/warnings-all.j:9:5: warning: unknown type 'CPString' 63 | CPString title; 64 | ^ 65 | test/fixtures/cli/exceptions/src/warnings-all.j:13:19: warning: method parameter 'i' hides a file variable 66 | - (void)test:(int)i 67 | ^ 68 | test/fixtures/cli/exceptions/src/warnings-all.j:4:5: note: hidden declaration is here 69 | var i = 13; 70 | ^ 71 | test/fixtures/cli/exceptions/src/warnings-all.j:16:5: warning: implicitly creating the global variable 'x' in the method 'test:'; did you mean to use 'var x'? 72 | x = 7; 73 | ^ 74 | test/fixtures/cli/exceptions/src/warnings-all.j:23:13: warning: reference to unknown identifier 'boo' 75 | var y = boo; 76 | ^ 77 | test/fixtures/cli/exceptions/src/warnings-all.j:20:4: warning: unknown type 'Foo' 78 | - (Foo)foo:(int)bar 79 | ^ 80 | test/fixtures/cli/exceptions/src/warnings-all.j:34:9: warning: reserved word used as a variable name 81 | var NaN = "yo"; 82 | ^ 83 | test/fixtures/cli/exceptions/src/warnings-all.j:31:4: warning: conflicting return type in declaration of 'foo:': 'void' vs. 'Foo' 84 | - (void)foo:(double)bar 85 | ^ 86 | test/fixtures/cli/exceptions/src/warnings-all.j:20:4: note: previous declaration is here 87 | - (Foo)foo:(int)bar 88 | ^ 89 | test/fixtures/cli/exceptions/src/warnings-all.j:31:14: warning: conflicting parameter type in declaration of 'foo:': 'double' vs. 'int' 90 | - (void)foo:(double)bar 91 | ^ 92 | test/fixtures/cli/exceptions/src/warnings-all.j:20:13: note: previous declaration is here 93 | - (Foo)foo:(int)bar 94 | ^ 95 | 96 | 9 warnings generated. 97 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/dest/protocol-declaration.js: -------------------------------------------------------------------------------- 1 | (function() 2 | { 3 | // @protocol Person 4 | var $the_protocol = objj_allocateProtocol("Person"); 5 | 6 | objj_registerProtocol($the_protocol); 7 | 8 | protocol_addMethodDescriptions($the_protocol, 9 | [ 10 | // - (void)eat 11 | new objj_method(sel_getUid("eat"), null, 12 | // argument types 13 | ["void"]) 14 | ], 15 | true, true); 16 | // @end: @protocol Person 17 | 18 | // @protocol Parent 19 | var $the_protocol = objj_allocateProtocol("Parent"); 20 | 21 | objj_registerProtocol($the_protocol); 22 | 23 | protocol_addMethodDescriptions($the_protocol, 24 | [ 25 | // - (void)one 26 | new objj_method(sel_getUid("one"), null, 27 | // argument types 28 | ["void"]), 29 | 30 | // - (int)two 31 | new objj_method(sel_getUid("two"), null, 32 | // argument types 33 | ["int"]) 34 | ], 35 | true, true); 36 | 37 | protocol_addMethodDescriptions($the_protocol, 38 | [ 39 | // + (void)classMethod 40 | new objj_method(sel_getUid("classMethod"), null, 41 | // argument types 42 | ["void"]) 43 | ], 44 | true, false); 45 | // @end: @protocol Parent 46 | 47 | // @protocol Child 48 | var $the_protocol = objj_allocateProtocol("Child"); 49 | 50 | var $the_incorporated_protocol = objj_getProtocol("Parent"); 51 | 52 | if (!$the_incorporated_protocol) 53 | throw new ReferenceError("Cannot find protocol declaration for 'Parent'"); 54 | 55 | protocol_addProtocol($the_protocol, $the_incorporated_protocol); 56 | 57 | $the_incorporated_protocol = objj_getProtocol("Person"); 58 | 59 | if (!$the_incorporated_protocol) 60 | throw new ReferenceError("Cannot find protocol declaration for 'Person'"); 61 | 62 | protocol_addProtocol($the_protocol, $the_incorporated_protocol); 63 | 64 | objj_registerProtocol($the_protocol); 65 | 66 | protocol_addMethodDescriptions($the_protocol, 67 | [ 68 | // - (float)three 69 | new objj_method(sel_getUid("three"), null, 70 | // argument types 71 | ["float"]), 72 | 73 | // - (id)required 74 | new objj_method(sel_getUid("required"), null, 75 | // argument types 76 | ["id"]) 77 | ], 78 | true, true); 79 | // @end: @protocol Child 80 | 81 | // @implementation Person 82 | var $the_class = objj_allocateClassPair(Nil, "Person"); 83 | var $the_protocol = objj_getProtocol("Person"); 84 | 85 | if (!$the_protocol) 86 | throw new ReferenceError("Cannot find protocol declaration for 'Person'"); 87 | 88 | class_addProtocol($the_class, $the_protocol); 89 | objj_registerClassPair($the_class); 90 | 91 | // Instance methods 92 | class_addMethods($the_class, 93 | [ 94 | // - (void)eat 95 | new objj_method(sel_getUid("eat"), 96 | function $Person__eat(self, _cmd) 97 | { 98 | console.log("Yum!"); 99 | }, 100 | // argument types 101 | ["void"]) 102 | ]); 103 | // @end: @implementation Person 104 | })(); 105 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/src/method-types.j: -------------------------------------------------------------------------------- 1 | @class CPString 2 | @typedef KnownType 3 | 4 | @implementation One 5 | 6 | + (void)makeSomethingWith:(CPInteger)number 7 | { 8 | } 9 | 10 | - (void)returnType 11 | { 12 | } 13 | 14 | - (id)returnClass 15 | { 16 | } 17 | 18 | - (id)returnPOD 19 | { 20 | } 21 | 22 | - (void)parameterTypes:(int)one two:(double)two three:(CPString)three 23 | { 24 | } 25 | 26 | - (id)thisIsOkay:(int)ok 27 | { 28 | } 29 | 30 | // warnings for UnknownType and AnotherUnknownType 31 | - (UnknownType)unknownType:(AnotherUnknownType)type another:(KnownType)another 32 | { 33 | } 34 | 35 | // @action resolves to return type void 36 | - (@action)test1 37 | { 38 | } 39 | 40 | - (int)test2 41 | { 42 | } 43 | 44 | // no return type resolves to id 45 | - test3 46 | { 47 | } 48 | 49 | - (int)test4 50 | { 51 | } 52 | 53 | - (void)idVsClassParam:(id)one 54 | { 55 | } 56 | 57 | - (void)idVsPODParam:(id)one 58 | { 59 | } 60 | 61 | - (void)implicitIdParam1:(int)one 62 | { 63 | } 64 | 65 | - (void)implicitIdParam2:one 66 | { 67 | } 68 | 69 | @end 70 | 71 | @implementation Two : One 72 | 73 | // warnings for return type and parameter 74 | + (id)makeSomethingWith:(CPTimeInterval)number 75 | { 76 | } 77 | 78 | // warning for return type 79 | - (int)returnType 80 | { 81 | } 82 | 83 | // no warning, concrete class can substitute for id 84 | - (CPString)returnClass 85 | { 86 | } 87 | 88 | // warning, POD type cannot be substituted for id 89 | - (int)returnPOD 90 | { 91 | } 92 | 93 | // warnings for all parameter types 94 | - (void)parameterTypes:(CPString)one two:(int)two three:(double)three 95 | { 96 | } 97 | 98 | // no warning, same types 99 | - (id)thisIsOkay:(int)ok 100 | { 101 | } 102 | 103 | // warning: void vs. int return type 104 | - (int)test1 105 | { 106 | } 107 | 108 | // warning: int vs. void return type 109 | - (@action)test2 110 | { 111 | } 112 | 113 | // warning: id vs. int return type 114 | - (int)test3 115 | { 116 | } 117 | 118 | // warning: int vs. id return type 119 | - test4 120 | { 121 | } 122 | 123 | // no warning, it's okay to use id in a superclass and a non-POD type in a subclass 124 | - (void)idVsClassParam:(CPString)one 125 | { 126 | } 127 | 128 | // warning: id vs. int 129 | - (void)idVsPODParam:(int)one 130 | { 131 | } 132 | 133 | // warning: int vs. id 134 | - (void)implicitIdParam1:one 135 | { 136 | } 137 | 138 | // warning: id vs. int 139 | - (void)implicitIdParam2:(int)one 140 | { 141 | } 142 | 143 | @end 144 | 145 | // In Objective-J (as in Objective-C), subclass method overrides can legally redeclare 146 | // the return and parameter types, which then apply to subclasses of the subclass. 147 | 148 | @implementation Three : Two 149 | 150 | // warning, because Two's override redeclared return type as int 151 | - (id)returnPOD 152 | { 153 | } 154 | 155 | // warnings for all parameter types, because Two's override redeclared them 156 | - (void)parameterTypes:(int)one two:(double)two three:(CPString)three 157 | { 158 | } 159 | 160 | @end 161 | 162 | @protocol P1 163 | - (void)one:(int)first; 164 | @end 165 | 166 | @protocol P2 167 | // warnings for all parameter types 168 | - (int)one:(double)first; 169 | 170 | @end 171 | 172 | @protocol P3 173 | // warnings for all parameter types, because P2's override redeclared them 174 | - (void)one:(int)first; 175 | @end 176 | 177 | @implementation Protocol 178 | 179 | // warnings for all types 180 | - (int)one:(double)first 181 | { 182 | } 183 | 184 | @end 185 | -------------------------------------------------------------------------------- /test/exceptions.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /* eslint-disable max-nested-callbacks, no-loop-func */ 4 | 5 | const 6 | expect = require("code").expect, 7 | utils = require("./lib/utils.js"); 8 | 9 | const testData = [ // jscs: ignore requireMultipleVarDecl 10 | ["accessors", "problems with accessor attributes should generate an error"], 11 | ["bad-import", "importing a non-existent file should generate a fatal error"], 12 | ["circular-import", "circular imports should generate a fatal error"], 13 | ["debugger", "debugger statements should generate a warning"], 14 | ["dereference", "@deref whose ref is not a simple identifier should generate a warning"], 15 | ["duplicate-global-symbols", "duplicate global symbol definitions should generate a warning"], 16 | ["duplicate-ivars", "duplicate ivar definitions should generate an error"], 17 | ["duplicate-methods", "duplicate method declarations should generate an exception"], 18 | ["identifiers", "references to unknown identifiers and implicit globals should generate a warning"], 19 | ["import-parse-error", "the import stack should be printed before acorn parse errors in import files"], 20 | ["import-scope", "top level vars in imported files are not visible to files that import them"], 21 | ["import-stack", "the import stack should be printed before the first issue in a series from the same import file"], 22 | ["method-types", "conflicting/unknown method return/parameter types should generate a warning"], 23 | ["missing-dependencies", "missing class/protocol dependencies should generate an exception"], 24 | ["protocol-conformance", "unimplemented required protocol methods should generate a warning"], 25 | ["read-only-globals", "assigning to a read-only predefined global should generate a warning"], 26 | ["recursive-import", "importing oneself should generate a fatal error"], 27 | ["reserved-words", "using a reserved word as a variable name should generate a warning"], 28 | ["self", "using 'self' outside of a method or as a method/function parameter should generate an exception"], 29 | ["shadowed-vars", "var declarations that shadow names in outer scopes should generate a warning"], 30 | ["stdin", "issues generated from stdin should show the filename as ''"], 31 | ["suggestions", "unknown names that differ from known names only in capitalization should give a suggestion"], 32 | ["super-outside", "using 'super' outside of a method should generate an error"], 33 | ["super-root", "using 'super' in a root class should generate an error"], 34 | ["symbol-redefinition", "redefining a global symbol as a different type should generate an error"], 35 | ]; 36 | 37 | 38 | /* 39 | * Strip out all but the filename from the 'sourceFile' property of AST nodes. 40 | */ 41 | function stripPaths(str) 42 | { 43 | return str.replace( 44 | /no such file '.+[/\\](.+)'/g, 45 | (match, filename) => filename 46 | ); 47 | } 48 | 49 | function makeTest(description, filename) 50 | { 51 | specify(description, () => 52 | { 53 | let options = { captureStdout: true }; 54 | 55 | if (filename === "stdin") 56 | options.stdin = true; 57 | 58 | const 59 | output = utils.compiledFixture(`exceptions/src/${filename}`, options), 60 | text = stripPaths(utils.convertIssuePathsToPosix(output.stdout)); 61 | 62 | expect(text).to.equal(stripPaths(utils.readFixture(`exceptions/dest/${filename}.txt`))); 63 | }); 64 | } 65 | 66 | context("Warnings and errors", () => 67 | { 68 | for (const info of testData) 69 | { 70 | const 71 | should = info[1], 72 | filename = info[2] ? info[2] : info[0]; 73 | 74 | makeTest(should, filename); 75 | } 76 | }); 77 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/dest/class-declaration.js: -------------------------------------------------------------------------------- 1 | (function() 2 | { 3 | // @implementation Empty 4 | var $the_class = objj_allocateClassPair(Nil, "Empty"); 5 | objj_registerClassPair($the_class); 6 | // @end: @implementation Empty 7 | 8 | // @implementation Empty (Category) 9 | var $the_class = objj_getClass("Empty"); 10 | 11 | if (!$the_class) 12 | throw new ReferenceError("Cannot find declaration for class 'Empty'"); 13 | 14 | // @end: @implementation Empty (Category) 15 | 16 | // @implementation Subclass : Empty 17 | var $the_class = objj_allocateClassPair(Empty, "Subclass"); 18 | objj_registerClassPair($the_class); 19 | // @end: @implementation Subclass : Empty 20 | 21 | // @protocol Protocol1 22 | var $the_protocol = objj_allocateProtocol("Protocol1"); 23 | 24 | objj_registerProtocol($the_protocol); 25 | 26 | // @end: @protocol Protocol1 27 | 28 | // @protocol Protocol2 29 | var $the_protocol = objj_allocateProtocol("Protocol2"); 30 | 31 | objj_registerProtocol($the_protocol); 32 | 33 | // @end: @protocol Protocol2 34 | 35 | // @implementation OneProtocol 36 | var $the_class = objj_allocateClassPair(Nil, "OneProtocol"); 37 | var $the_protocol = objj_getProtocol("Protocol1"); 38 | 39 | if (!$the_protocol) 40 | throw new ReferenceError("Cannot find protocol declaration for 'Protocol1'"); 41 | 42 | class_addProtocol($the_class, $the_protocol); 43 | objj_registerClassPair($the_class); 44 | // @end: @implementation OneProtocol 45 | 46 | // @implementation TwoProtocols 47 | var $the_class = objj_allocateClassPair(Nil, "TwoProtocols"); 48 | var $the_protocol = objj_getProtocol("Protocol1"); 49 | 50 | if (!$the_protocol) 51 | throw new ReferenceError("Cannot find protocol declaration for 'Protocol1'"); 52 | 53 | class_addProtocol($the_class, $the_protocol); 54 | $the_protocol = objj_getProtocol("Protocol2"); 55 | 56 | if (!$the_protocol) 57 | throw new ReferenceError("Cannot find protocol declaration for 'Protocol2'"); 58 | 59 | class_addProtocol($the_class, $the_protocol); 60 | objj_registerClassPair($the_class); 61 | // @end: @implementation TwoProtocols 62 | 63 | // @implementation EmptyIvars 64 | var $the_class = objj_allocateClassPair(Nil, "EmptyIvars"); 65 | objj_registerClassPair($the_class); 66 | // @end: @implementation EmptyIvars 67 | 68 | // @implementation Ivars 69 | var $the_class = objj_allocateClassPair(Nil, "Ivars"); 70 | objj_registerClassPair($the_class); 71 | 72 | class_addIvars($the_class, 73 | [ 74 | new objj_ivar("one", "int"), 75 | new objj_ivar("two", "Empty"), 76 | new objj_ivar("outlet", "id"), 77 | new objj_ivar("outlet2", "id") 78 | ]); 79 | // @end: @implementation Ivars 80 | 81 | // @implementation Statements 82 | var $the_class = objj_allocateClassPair(Nil, "Statements"); 83 | objj_registerClassPair($the_class); 84 | var x = 7; 85 | 86 | test = function test() 87 | { 88 | doSomething(); 89 | }; 90 | // @end: @implementation Statements 91 | 92 | // @implementation Methods : Statements 93 | var $the_class = objj_allocateClassPair(Statements, "Methods"); 94 | objj_registerClassPair($the_class); 95 | var initialized = false, 96 | initCount = 0; 97 | 98 | // Instance methods 99 | class_addMethods($the_class, 100 | [ 101 | // - (id)init 102 | new objj_method(sel_getUid("init"), 103 | function $Methods__init(self, _cmd) 104 | { 105 | self = /* [super init] */ objj_msgSendSuper0({ receiver: self, super_class: objj_getClass("Methods").super_class }, "init"); 106 | 107 | if (self) 108 | initCount++; 109 | 110 | return self; 111 | }, 112 | // argument types 113 | ["id"]) 114 | ]); 115 | 116 | // Class methods 117 | class_addMethods($the_class.isa, 118 | [ 119 | // + (void)initialize 120 | new objj_method(sel_getUid("initialize"), 121 | function $Methods__initialize(self, _cmd) 122 | { 123 | initialized = true; 124 | }, 125 | // argument types 126 | ["void"]) 127 | ]); 128 | // @end: @implementation Methods : Statements 129 | })(); 130 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/dest/identifiers.txt: -------------------------------------------------------------------------------- 1 | 2 | test/fixtures/exceptions/src/identifiers.j:2:11: warning: reference to unknown identifier 'bar' 3 | var foo = bar; 4 | ^ 5 | test/fixtures/exceptions/src/identifiers.j:5:12: warning: reference to unknown identifier 'CPString' 6 | var str = [CPString stringWithFormat:@"%s cool", @"way"]; 7 | ^ 8 | test/fixtures/exceptions/src/identifiers.j:18:9: warning: implicitly creating the global variable 'three' in the method 'test' 9 | three = 27, 10 | ^ 11 | test/fixtures/exceptions/src/identifiers.j:17:17: note: did you mean to use a comma here? 12 | two = 13; // Oops, this should have been a comma, the next three assignments create implicit globals 13 | ^ 14 | test/fixtures/exceptions/src/identifiers.j:19:9: warning: implicitly creating the global variable 'four' in the method 'test' 15 | four = 31, 16 | ^ 17 | test/fixtures/exceptions/src/identifiers.j:17:17: note: did you mean to use a comma here? 18 | two = 13; // Oops, this should have been a comma, the next three assignments create implicit globals 19 | ^ 20 | test/fixtures/exceptions/src/identifiers.j:26:9: warning: reference to unknown identifier 'unknownVar' 21 | x = unknownVar; 22 | ^ 23 | test/fixtures/exceptions/src/identifiers.j:46:9: warning: implicitly creating the global variable 'two' in the function 'test' 24 | two = 1931; 25 | ^ 26 | test/fixtures/exceptions/src/identifiers.j:45:16: note: did you mean to use a comma here? 27 | var one = 7; // Oops, this should have been a comma, the next assignment warns about implicit global 28 | ^ 29 | test/fixtures/exceptions/src/identifiers.j:52:5: warning: implicitly creating the global variable 'four' in the function 'test'; did you mean to use 'var four'? 30 | four = "bar"; 31 | ^ 32 | test/fixtures/exceptions/src/identifiers.j:55:10: warning: implicitly creating the global variable 'i' in the function 'test'; did you mean to use 'var i'? 33 | for (i = 0, j = 0; j < 7; ++j, jj = 13) 34 | ^ 35 | test/fixtures/exceptions/src/identifiers.j:55:17: warning: implicitly creating the global variable 'j' in the function 'test'; did you mean to use 'var j'? 36 | for (i = 0, j = 0; j < 7; ++j, jj = 13) 37 | ^ 38 | test/fixtures/exceptions/src/identifiers.j:55:36: warning: implicitly creating the global variable 'jj' in the function 'test'; did you mean to use 'var jj'? 39 | for (i = 0, j = 0; j < 7; ++j, jj = 13) 40 | ^ 41 | test/fixtures/exceptions/src/identifiers.j:59:12: warning: implicitly creating the global variable 'k' in the function 'test'; did you mean to use 'var k'? 42 | while (k = doSomething()) 43 | ^ 44 | test/fixtures/exceptions/src/identifiers.j:63:9: warning: implicitly creating the global variable 'l' in the function 'test'; did you mean to use 'var l'? 45 | if (l = doSomething()) 46 | ^ 47 | test/fixtures/exceptions/src/identifiers.j:67:23: warning: implicitly creating the global variable 'z' in the function 'test'; did you mean to use 'var z'? 48 | console.log(z || (z = "foo")); 49 | ^ 50 | test/fixtures/exceptions/src/identifiers.j:71:13: warning: implicitly creating the global variable 'x' in the function 'test'; did you mean to use 'var x'? 51 | a[x || (x = 7)]; 52 | ^ 53 | test/fixtures/exceptions/src/identifiers.j:73:5: warning: reference to unknown identifier 'q' 54 | q += 1; 55 | ^ 56 | 57 | 15 warnings generated. 58 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/dest/duplicate-global-symbols.txt: -------------------------------------------------------------------------------- 1 | 2 | test/fixtures/exceptions/src/duplicate-global-symbols.j:5:1: error: duplicate definition of class 'First' 3 | @implementation First 4 | ^ 5 | test/fixtures/exceptions/src/duplicate-global-symbols.j:1:1: note: previous definition is here 6 | @implementation First 7 | ^ 8 | test/fixtures/exceptions/src/duplicate-global-symbols.j:12:1: error: duplicate definition of category 'First (Category)' 9 | @implementation First (Category) 10 | ^ 11 | test/fixtures/exceptions/src/duplicate-global-symbols.j:8:1: note: previous definition is here 12 | @implementation First (Category) 13 | ^ 14 | test/fixtures/exceptions/src/duplicate-global-symbols.j:16:8: warning: duplicate class definition 'First' is ignored 15 | @class First 16 | ^ 17 | test/fixtures/exceptions/src/duplicate-global-symbols.j:1:1: note: previous definition is here 18 | @implementation First 19 | ^ 20 | test/fixtures/exceptions/src/duplicate-global-symbols.j:18:16: warning: @class definition 'Second' is unnecessary 21 | @class Before, Second 22 | ^ 23 | test/fixtures/exceptions/src/duplicate-global-symbols.j:21:1: note: superceded by this definition 24 | @implementation Second 25 | ^ 26 | test/fixtures/exceptions/src/duplicate-global-symbols.j:25:15: warning: duplicate class definition 'Second' is ignored 27 | @class Third, Second 28 | ^ 29 | test/fixtures/exceptions/src/duplicate-global-symbols.j:21:1: note: previous definition is here 30 | @implementation Second 31 | ^ 32 | test/fixtures/exceptions/src/duplicate-global-symbols.j:28:16: warning: duplicate class definition 'Third' is ignored 33 | @class Fourth, Third 34 | ^ 35 | test/fixtures/exceptions/src/duplicate-global-symbols.j:25:8: note: previous definition is here 36 | @class Third, Second 37 | ^ 38 | test/fixtures/exceptions/src/duplicate-global-symbols.j:34:1: warning: duplicate protocol definition 'Protocol' is ignored 39 | @protocol Protocol 40 | ^ 41 | test/fixtures/exceptions/src/duplicate-global-symbols.j:30:1: note: previous definition is here 42 | @protocol Protocol 43 | ^ 44 | test/fixtures/exceptions/src/duplicate-global-symbols.j:40:21: warning: duplicate typedef definition 'colorScheme' is ignored 45 | @typedef something, colorScheme 46 | ^ 47 | test/fixtures/exceptions/src/duplicate-global-symbols.j:37:10: note: previous definition is here 48 | @typedef colorScheme 49 | ^ 50 | test/fixtures/exceptions/src/duplicate-global-symbols.j:45:9: warning: duplicate global definition 'Bar' is ignored 51 | @global Bar 52 | ^ 53 | test/fixtures/exceptions/src/duplicate-global-symbols.j:42:14: note: previous definition is here 54 | @global Foo, Bar 55 | ^ 56 | test/fixtures/exceptions/src/duplicate-global-symbols.j:50:9: warning: duplicate global definition 'SomeGlobal' is ignored 57 | @global SomeGlobal 58 | ^ 59 | test/fixtures/exceptions/src/duplicate-global-symbols.j:47:1: note: previous definition is here 60 | SomeGlobal = 7; 61 | ^ 62 | test/fixtures/exceptions/src/duplicate-global-symbols.j:58:9: warning: duplicate predefined global definition 'Node' is ignored 63 | @global Node 64 | ^ 65 | test/fixtures/exceptions/src/duplicate-global-symbols.j:61:5: warning: reserved word used as a variable name 66 | var NaN = 7; 67 | ^ 68 | 69 | 10 warnings and 2 errors generated. 70 | -------------------------------------------------------------------------------- /test/fixtures/cli/exceptions/dest/max-errors-0.txt: -------------------------------------------------------------------------------- 1 | 2 | test/fixtures/cli/exceptions/src/max-errors-0.j:5:9: error: redeclaration of instance variable 'a' in class 'Foo' 3 | int a; 4 | ^ 5 | test/fixtures/cli/exceptions/src/max-errors-0.j:4:9: note: previous declaration is here, in class 'Foo' 6 | int a; 7 | ^ 8 | test/fixtures/cli/exceptions/src/max-errors-0.j:6:9: error: redeclaration of instance variable 'a' in class 'Foo' 9 | int a; 10 | ^ 11 | test/fixtures/cli/exceptions/src/max-errors-0.j:4:9: note: previous declaration is here, in class 'Foo' 12 | int a; 13 | ^ 14 | test/fixtures/cli/exceptions/src/max-errors-0.j:7:9: error: redeclaration of instance variable 'a' in class 'Foo' 15 | int a; 16 | ^ 17 | test/fixtures/cli/exceptions/src/max-errors-0.j:4:9: note: previous declaration is here, in class 'Foo' 18 | int a; 19 | ^ 20 | test/fixtures/cli/exceptions/src/max-errors-0.j:8:9: error: redeclaration of instance variable 'a' in class 'Foo' 21 | int a; 22 | ^ 23 | test/fixtures/cli/exceptions/src/max-errors-0.j:4:9: note: previous declaration is here, in class 'Foo' 24 | int a; 25 | ^ 26 | test/fixtures/cli/exceptions/src/max-errors-0.j:9:9: error: redeclaration of instance variable 'a' in class 'Foo' 27 | int a; 28 | ^ 29 | test/fixtures/cli/exceptions/src/max-errors-0.j:4:9: note: previous declaration is here, in class 'Foo' 30 | int a; 31 | ^ 32 | test/fixtures/cli/exceptions/src/max-errors-0.j:10:9: error: redeclaration of instance variable 'a' in class 'Foo' 33 | int a; 34 | ^ 35 | test/fixtures/cli/exceptions/src/max-errors-0.j:4:9: note: previous declaration is here, in class 'Foo' 36 | int a; 37 | ^ 38 | test/fixtures/cli/exceptions/src/max-errors-0.j:11:9: error: redeclaration of instance variable 'a' in class 'Foo' 39 | int a; 40 | ^ 41 | test/fixtures/cli/exceptions/src/max-errors-0.j:4:9: note: previous declaration is here, in class 'Foo' 42 | int a; 43 | ^ 44 | test/fixtures/cli/exceptions/src/max-errors-0.j:12:9: error: redeclaration of instance variable 'a' in class 'Foo' 45 | int a; 46 | ^ 47 | test/fixtures/cli/exceptions/src/max-errors-0.j:4:9: note: previous declaration is here, in class 'Foo' 48 | int a; 49 | ^ 50 | test/fixtures/cli/exceptions/src/max-errors-0.j:13:9: error: redeclaration of instance variable 'a' in class 'Foo' 51 | int a; 52 | ^ 53 | test/fixtures/cli/exceptions/src/max-errors-0.j:4:9: note: previous declaration is here, in class 'Foo' 54 | int a; 55 | ^ 56 | test/fixtures/cli/exceptions/src/max-errors-0.j:14:9: error: redeclaration of instance variable 'a' in class 'Foo' 57 | int a; 58 | ^ 59 | test/fixtures/cli/exceptions/src/max-errors-0.j:4:9: note: previous declaration is here, in class 'Foo' 60 | int a; 61 | ^ 62 | test/fixtures/cli/exceptions/src/max-errors-0.j:15:9: error: redeclaration of instance variable 'a' in class 'Foo' 63 | int a; 64 | ^ 65 | test/fixtures/cli/exceptions/src/max-errors-0.j:4:9: note: previous declaration is here, in class 'Foo' 66 | int a; 67 | ^ 68 | test/fixtures/cli/exceptions/src/max-errors-0.j:16:9: error: redeclaration of instance variable 'a' in class 'Foo' 69 | int a; 70 | ^ 71 | test/fixtures/cli/exceptions/src/max-errors-0.j:4:9: note: previous declaration is here, in class 'Foo' 72 | int a; 73 | ^ 74 | test/fixtures/cli/exceptions/src/max-errors-0.j:17:9: error: redeclaration of instance variable 'a' in class 'Foo' 75 | int a; 76 | ^ 77 | test/fixtures/cli/exceptions/src/max-errors-0.j:4:9: note: previous declaration is here, in class 'Foo' 78 | int a; 79 | ^ 80 | test/fixtures/cli/exceptions/src/max-errors-0.j:18:9: error: redeclaration of instance variable 'a' in class 'Foo' 81 | int a; 82 | ^ 83 | test/fixtures/cli/exceptions/src/max-errors-0.j:4:9: note: previous declaration is here, in class 'Foo' 84 | int a; 85 | ^ 86 | test/fixtures/cli/exceptions/src/max-errors-0.j:19:9: error: redeclaration of instance variable 'a' in class 'Foo' 87 | int a; 88 | ^ 89 | test/fixtures/cli/exceptions/src/max-errors-0.j:4:9: note: previous declaration is here, in class 'Foo' 90 | int a; 91 | ^ 92 | test/fixtures/cli/exceptions/src/max-errors-0.j:20:9: error: redeclaration of instance variable 'a' in class 'Foo' 93 | int a; 94 | ^ 95 | test/fixtures/cli/exceptions/src/max-errors-0.j:4:9: note: previous declaration is here, in class 'Foo' 96 | int a; 97 | ^ 98 | test/fixtures/cli/exceptions/src/max-errors-0.j:21:9: error: redeclaration of instance variable 'a' in class 'Foo' 99 | int a; 100 | ^ 101 | test/fixtures/cli/exceptions/src/max-errors-0.j:4:9: note: previous declaration is here, in class 'Foo' 102 | int a; 103 | ^ 104 | test/fixtures/cli/exceptions/src/max-errors-0.j:22:9: error: redeclaration of instance variable 'a' in class 'Foo' 105 | int a; 106 | ^ 107 | test/fixtures/cli/exceptions/src/max-errors-0.j:4:9: note: previous declaration is here, in class 'Foo' 108 | int a; 109 | ^ 110 | test/fixtures/cli/exceptions/src/max-errors-0.j:23:9: error: redeclaration of instance variable 'a' in class 'Foo' 111 | int a; 112 | ^ 113 | test/fixtures/cli/exceptions/src/max-errors-0.j:4:9: note: previous declaration is here, in class 'Foo' 114 | int a; 115 | ^ 116 | test/fixtures/cli/exceptions/src/max-errors-0.j:24:9: error: redeclaration of instance variable 'a' in class 'Foo' 117 | int a; 118 | ^ 119 | test/fixtures/cli/exceptions/src/max-errors-0.j:4:9: note: previous declaration is here, in class 'Foo' 120 | int a; 121 | ^ 122 | test/fixtures/cli/exceptions/src/max-errors-0.j:25:9: error: redeclaration of instance variable 'a' in class 'Foo' 123 | int a; // 21st error 124 | ^ 125 | test/fixtures/cli/exceptions/src/max-errors-0.j:4:9: note: previous declaration is here, in class 'Foo' 126 | int a; 127 | ^ 128 | 129 | 21 errors generated. 130 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/dest/message-send-expression-inline.js: -------------------------------------------------------------------------------- 1 | (function() 2 | { 3 | // @implementation CPApplication 4 | var $the_class = objj_allocateClassPair(Nil, "CPApplication"); 5 | objj_registerClassPair($the_class); 6 | // @end: @implementation CPApplication 7 | 8 | // @implementation CPString 9 | var $the_class = objj_allocateClassPair(Nil, "CPString"); 10 | objj_registerClassPair($the_class); 11 | // @end: @implementation CPString 12 | 13 | // @implementation CPTextField 14 | var $the_class = objj_allocateClassPair(Nil, "CPTextField"); 15 | objj_registerClassPair($the_class); 16 | // @end: @implementation CPTextField 17 | 18 | // @class CPArray 19 | 20 | var fileVar = /* [[CPApplication sharedApplication] mainWindow] */ ((___r1 = (CPApplication.isa.method_msgSend["sharedApplication"] || _objj_forward)(CPApplication, "sharedApplication")), ___r1 == null ? null : (___r1.isa.method_msgSend["mainWindow"] || _objj_forward)(___r1, "mainWindow")); 21 | 22 | // @implementation Super 23 | var $the_class = objj_allocateClassPair(Nil, "Super"); 24 | objj_registerClassPair($the_class); 25 | // @end: @implementation Super 26 | 27 | // @implementation Test : Super 28 | var $the_class = objj_allocateClassPair(Super, "Test"); 29 | objj_registerClassPair($the_class); 30 | 31 | class_addIvars($the_class, 32 | [ 33 | new objj_ivar("field", "CPTextField") 34 | ]); 35 | 36 | // Instance methods 37 | class_addMethods($the_class, 38 | [ 39 | // - (id)init 40 | new objj_method(sel_getUid("init"), 41 | function $Test__init(self, _cmd) 42 | { 43 | self = /* [super init] */ (objj_getClass("Test").super_class.method_dtable["init"] || _objj_forward)(self, "init"); 44 | 45 | if (self) 46 | /* [self foo] */ (self == null ? null : (self.isa.method_msgSend["foo"] || _objj_forward)(self, "foo")); 47 | 48 | return self; 49 | }, 50 | // argument types 51 | ["id"]), 52 | 53 | // - (void)foo 54 | new objj_method(sel_getUid("foo"), 55 | function $Test__foo(self, _cmd) 56 | { 57 | { 58 | var count = /* [[self subviews] count] */ ((___r1 = (self.isa.method_msgSend["subviews"] || _objj_forward)(self, "subviews")), ___r1 == null ? null : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")); 59 | } 60 | 61 | self.field = /* [[CPTextField alloc] init] */ ((___r1 = (CPTextField.isa.method_msgSend["alloc"] || _objj_forward)(CPTextField, "alloc")), ___r1 == null ? null : (___r1.isa.method_msgSend["init"] || _objj_forward)(___r1, "init")); 62 | /* [field setTitle:[CPString stringWithFormat:@"Count: %d", count]] */ ((___r1 = self.field), ___r1 == null ? null : (___r1.isa.method_msgSend["setTitle:"] || _objj_forward)(___r1, "setTitle:", (CPString.isa.method_msgSend["stringWithFormat:"] || _objj_forward)(CPString, "stringWithFormat:", "Count: %d", count))); 63 | 64 | // Generated receiver temp variables 65 | var ___r1; 66 | }, 67 | // argument types 68 | ["void"]), 69 | 70 | // - (CPArray)subviews 71 | new objj_method(sel_getUid("subviews"), 72 | function $Test__subviews(self, _cmd) 73 | { 74 | return /* [[[[CPApplication sharedApplication] mainWindow] contentView] subviews] */ ((___r1 = ((___r2 = ((___r3 = (CPApplication.isa.method_msgSend["sharedApplication"] || _objj_forward)(CPApplication, "sharedApplication")), ___r3 == null ? null : (___r3.isa.method_msgSend["mainWindow"] || _objj_forward)(___r3, "mainWindow"))), ___r2 == null ? null : (___r2.isa.method_msgSend["contentView"] || _objj_forward)(___r2, "contentView"))), ___r1 == null ? null : (___r1.isa.method_msgSend["subviews"] || _objj_forward)(___r1, "subviews")); 75 | 76 | // Generated receiver temp variables 77 | var ___r1, ___r2, ___r3; 78 | }, 79 | // argument types 80 | ["CPArray"]), 81 | 82 | // - (void)doSomething:withNumber:and:andAlso: 83 | new objj_method(sel_getUid("doSomething:withNumber:and:andAlso:"), 84 | function $Test__doSomething_withNumber_and_andAlso_(self, _cmd, something, number, and, also) 85 | { 86 | console.log(/* [CPString stringWithFormat:@"%s, %d, %s, %i", something, number, and, also] */ (CPString.isa.method_msgSend["stringWithFormat:"] || _objj_forward)(CPString, "stringWithFormat:", "%s, %d, %s, %i", something, number, and, also)); 87 | }, 88 | // argument types 89 | ["void", "CPString", "int", "CPString", "int"]), 90 | 91 | // - (void)bigSelector 92 | new objj_method(sel_getUid("bigSelector"), 93 | function $Test__bigSelector(self, _cmd) 94 | { 95 | /* [self doSomething:@"bold" withNumber:7 and:@"something else" andAlso:27] */ (self.isa.method_msgSend["doSomething:withNumber:and:andAlso:"] || _objj_forward)(self, "doSomething:withNumber:and:andAlso:", "bold", 7, "something else", 27); 96 | }, 97 | // argument types 98 | ["void"]) 99 | ]); 100 | 101 | // Class methods 102 | class_addMethods($the_class.isa, 103 | [ 104 | // + (void)initialize 105 | new objj_method(sel_getUid("initialize"), 106 | function $Test__initialize(self, _cmd) 107 | { 108 | /* [super initialize] */ (objj_getMetaClass("Test").super_class.method_dtable["initialize"] || _objj_forward)(self, "initialize"); 109 | /* [self classInit] */ (self.isa.method_msgSend["classInit"] || _objj_forward)(self, "classInit"); 110 | }, 111 | // argument types 112 | ["void"]), 113 | 114 | // + (void)classInit 115 | new objj_method(sel_getUid("classInit"), 116 | function $Test__classInit(self, _cmd) 117 | { 118 | }, 119 | // argument types 120 | ["void"]) 121 | ]); 122 | // @end: @implementation Test : Super 123 | 124 | // Generated receiver temp variables 125 | var ___r1; 126 | })(); 127 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/src/shadowed-vars.j: -------------------------------------------------------------------------------- 1 | var x = 7; 2 | 3 | function hiddenFileVar() 4 | { 5 | // local declaration hides file var 6 | var x = 13; 7 | } 8 | 9 | // function parameter hides file var 10 | function hiddenFileVarParam(x) 11 | { 12 | } 13 | 14 | // function parameter 'arg' hides a function parameter 15 | function duplicateArgs(arg, arg2, arg) 16 | { 17 | } 18 | 19 | function implicitGlobal() 20 | { 21 | // This generates an implicit global warning which is removed 22 | // when the scope closes because of the var declaration below. 23 | y = 7; 24 | 25 | // This does not generate a warning as it's legal in Javascript. 26 | // The implicit global y is converted to a local var by the compiler. 27 | var y; 28 | } 29 | 30 | @global someGlobal 31 | 32 | // local declaration hides global 33 | var someGlobal = 27; 34 | 35 | @global foo 36 | ActualGlobal = 31; 37 | 38 | function hiddenGlobal() 39 | { 40 | // local declaration hides global 41 | var foo = 7; 42 | 43 | // local declaration hides global 44 | var ActualGlobal = 31; 45 | } 46 | 47 | // function parameter hides global 48 | function hiddenGlobalParam(foo, ActualGlobal) 49 | { 50 | } 51 | 52 | @class someClass 53 | 54 | function hiddenClassStatement() 55 | { 56 | // local declaration hides class 57 | var someClass = "oops!"; 58 | } 59 | 60 | // function parameter hides class 61 | function hiddenClassStatementParam(someClass) 62 | { 63 | } 64 | 65 | @implementation Test 66 | @end 67 | 68 | function hiddenImplementation() 69 | { 70 | // local declaration hides class 71 | var Test = "hidden"; 72 | } 73 | 74 | // function parameter hides class 75 | function hiddenImplementationParam(Test) 76 | { 77 | } 78 | 79 | @protocol TestProtocol 80 | @end 81 | 82 | function hiddenProtocol() 83 | { 84 | // local declaration hides protocol 85 | var TestProtocol = "hidden"; 86 | } 87 | 88 | // function parameter hides protocol 89 | function hiddenProtocolParam(TestProtocol) 90 | { 91 | } 92 | 93 | @typedef colorScheme, typedef 94 | 95 | function hiddenTypedef() 96 | { 97 | // local declaration hides typedef 98 | var colorScheme = null, 99 | typedef = "Homer"; 100 | } 101 | 102 | // function parameter hides typedef 103 | function hiddenTypedefParam(colorScheme) 104 | { 105 | } 106 | 107 | // local declaration hides predefined global 108 | var window = null; 109 | 110 | // no warning, this predefined global is defined to ignore shadowing 111 | var location = "here"; 112 | 113 | function testParameters(one, two) 114 | { 115 | // local declaration hides a function parameter 116 | var one = 7, 117 | two = 13; 118 | } 119 | 120 | @implementation TestMethodParameters 121 | 122 | - (void)testMethodParameters:(int)first two:(int)second 123 | { 124 | // local declaration hides a method parameter 125 | var first = 7, 126 | second = 13; 127 | } 128 | 129 | - (void)testDuplicateParameters:(int)param two:(int)param 130 | { 131 | } 132 | 133 | @end 134 | 135 | // Within an Objective-J method, 'self' and '_cmd' are implicit parameters, 136 | // and should not be hidden by a local variable. 137 | 138 | function outer() 139 | { 140 | // Outside of a method, using 'self' or '_cmd' as a variable is legal 141 | var self = 7, 142 | _cmd = 13; 143 | } 144 | 145 | @implementation TestImplicit 146 | 147 | - (void)test 148 | { 149 | // local declaration hides implicit method parameter 150 | var self = 7, 151 | _cmd = 13; 152 | 153 | function inner() 154 | { 155 | // local declaration hides implicit method parameter 156 | var self = 27, 157 | _cmd = 31; 158 | } 159 | } 160 | 161 | @end 162 | 163 | @implementation IvarTest 164 | { 165 | int one; 166 | int two; 167 | int three; 168 | } 169 | 170 | - (void)test 171 | { 172 | // local reference hides instance variable 173 | two = 13; 174 | two = 4 / 13/ 1964; 175 | 176 | // local declaration + reference hides instance variable 177 | var two = one + 27; 178 | 179 | // local declaration hides instance variable 180 | var one = 7; 181 | } 182 | 183 | // method parameter hides instance variable 184 | - (int)test:(int)one and:(int)two 185 | { 186 | // local reference hides instance variable 187 | return one + two; 188 | } 189 | 190 | - (void)nested 191 | { 192 | // for coverage 193 | one = 7; 194 | two = 13; 195 | 196 | // function parameter hides instance variable 197 | function nestParams(one, two) 198 | { 199 | } 200 | 201 | // cover case where nested scope has a parent scope with ivar refs 202 | function nestVars() 203 | { 204 | // local declaration hides instance variable 205 | var one, 206 | two; 207 | 208 | // test ivar refs within functions 209 | three = 31; 210 | } 211 | } 212 | 213 | // for coverage 214 | - (void)moreNesting 215 | { 216 | // cover case where nested scope has a parent scope without ivar refs 217 | function nested() 218 | { 219 | console.log(one + two); 220 | } 221 | } 222 | 223 | // no warning, instance variables are not visible here 224 | function bad(one, two) 225 | { 226 | return one + two; 227 | } 228 | 229 | @end 230 | 231 | @implementation TestHiddenTypes 232 | 233 | - (void)testFileVar:(int)x 234 | actualGlobal:(int)ActualGlobal 235 | globalStatement:(int)foo 236 | classStatement:(int)someClass 237 | classDeclaration:(int)Test 238 | protocol:(int)TestProtocol 239 | typedef:(int)colorScheme 240 | typedef2:(int)typedef 241 | document:(int)document // ignores shadow, no warning 242 | event:(int)event 243 | { 244 | } 245 | 246 | @end 247 | 248 | function nestingTest() 249 | { 250 | var one = 7, 251 | two = 13; 252 | 253 | function nested() 254 | { 255 | // local declaration hides a variable in a containing closure 256 | var one = 27, 257 | two = 31; 258 | } 259 | } 260 | 261 | function implicitGlobal() 262 | { 263 | // Create an implicit global 264 | implicit = 7; 265 | } 266 | 267 | // function parameter hides an implicit global 268 | function implicitGlobalParam(implicit) 269 | { 270 | } 271 | 272 | function implicitGlobalVar() 273 | { 274 | // local declaration hides an implicit global 275 | var implicit = 13; 276 | } 277 | -------------------------------------------------------------------------------- /lib/stringbuffer.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const 4 | indenter = require("./indentation.js").indenter, 5 | path = require("path"), 6 | sourceMap = require("source-map"); 7 | 8 | class StringBuffer 9 | { 10 | constructor(compiler) 11 | { 12 | this.atoms = []; 13 | this.generateSourceMap = compiler.options.sourceMap; 14 | this.compiler = compiler; 15 | this._sourceMap = null; 16 | 17 | if (this.generateSourceMap) 18 | this.sourceMapGenerator = new sourceMap.SourceMapGenerator({ sourceRoot: compiler.options.sourceRoot }); 19 | else 20 | this.sourceMapGenerator = null; 21 | } 22 | 23 | get length() 24 | { 25 | return this.atoms.length; 26 | } 27 | 28 | toString() 29 | { 30 | let string = ""; 31 | 32 | for (let i = 0; i < this.atoms.length; i++) 33 | string += this.atoms[i].string; 34 | 35 | return string; 36 | } 37 | 38 | remove(index) 39 | { 40 | this.atoms[index] = { string: "" }; 41 | } 42 | 43 | static advancePosition(position, string) 44 | { 45 | let lastPos = 0; 46 | 47 | while (true) 48 | { 49 | const pos = string.indexOf("\n", lastPos); 50 | 51 | if (pos >= 0) 52 | { 53 | ++position.line; 54 | position.column = 0; 55 | lastPos = pos + 1; 56 | } 57 | else 58 | { 59 | position.column += string.length - lastPos; 60 | break; 61 | } 62 | } 63 | } 64 | 65 | get sourceMap() 66 | { 67 | // istanbul ignore else: would need a spy to test caching, not worth it 68 | if (this.generateSourceMap && !this._sourceMap) 69 | { 70 | const position = { line: 1, column: 0 }; 71 | 72 | for (let i = 0; i < this.atoms.length; i++) 73 | { 74 | const 75 | atom = this.atoms[i], 76 | location = atom.location; 77 | 78 | if (location) 79 | { 80 | this.sourceMapGenerator.addMapping({ 81 | source: location.sourceFile, 82 | original: { 83 | line: location.line, 84 | column: location.column 85 | }, 86 | generated: { 87 | line: position.line, 88 | column: position.column 89 | } 90 | }); 91 | } 92 | 93 | this.constructor.advancePosition(position, atom.string); 94 | } 95 | 96 | this._sourceMap = this.sourceMapGenerator.toString(); 97 | } 98 | 99 | return this._sourceMap; 100 | } 101 | 102 | concat(string, node) 103 | { 104 | const atom = { string }; 105 | 106 | if (node && this.generateSourceMap) 107 | { 108 | const location = node.loc.start; 109 | 110 | atom.location = { 111 | line: location.line, 112 | column: location.column, 113 | sourceFile: path.basename(node.sourceFile) 114 | }; 115 | } 116 | 117 | this.atoms.push(atom); 118 | } 119 | 120 | concatFormat(node, scope, selector) 121 | { 122 | const 123 | format = scope.compiler.format, 124 | value = format.valueForProperty(node, node.type, selector); 125 | 126 | if (!value) 127 | return; 128 | 129 | const 130 | lines = value.split("\n"), 131 | lastIndex = lines.length - 1; 132 | 133 | for (let i = 0; i <= lastIndex; i++) 134 | { 135 | let line = lines[i], 136 | pos = line.indexOf("|"), 137 | isEmptyLine = false; 138 | 139 | if (pos >= 0) 140 | { 141 | const indentAmount = parseInt(line.substring(pos + 1), 10); 142 | 143 | if (indentAmount > 0) 144 | indenter.indent(indentAmount); 145 | else if (indentAmount < 0) 146 | indenter.dedent(-indentAmount); 147 | else // indentAmount === 0 148 | isEmptyLine = true; 149 | 150 | line = line.substring(0, pos); 151 | } 152 | 153 | // If there are multiple lines, don't indent empty ones before the last. 154 | if (!isEmptyLine && i > 0) 155 | { 156 | if (i < lastIndex && line.length === 0) 157 | lines[i] = line; 158 | else 159 | lines[i] = indenter.indentation + line; 160 | } 161 | else 162 | lines[i] = line; 163 | } 164 | 165 | this.concat(lines.join("\n")); 166 | } 167 | 168 | concatWithFormat(node, scope, string, format, mapNode) 169 | { 170 | format = format || string; 171 | 172 | this.concatFormat(node, scope, "before-" + format); 173 | this.concat(string, mapNode ? node : null); 174 | this.concatFormat(node, scope, "after-" + format); 175 | } 176 | 177 | concatWithFormats(node, scope, before, string, after, mapNode) 178 | { 179 | if (before) 180 | this.concatFormat(node, scope, before); 181 | 182 | this.concat(string, mapNode ? node : null); 183 | 184 | if (after) 185 | this.concatFormat(node, scope, after); 186 | } 187 | 188 | concatLeftParens(node, scope) 189 | { 190 | this.concatWithFormat(node, scope, "(", "left-parens"); 191 | } 192 | 193 | concatRightParens(node, scope) 194 | { 195 | this.concatWithFormat(node, scope, ")", "right-parens"); 196 | } 197 | 198 | concatComma(node, scope) 199 | { 200 | this.concatWithFormat(node, scope, ",", "comma"); 201 | } 202 | 203 | concatOperator(node, scope, operator) 204 | { 205 | this.concatWithFormat(node, scope, operator || node.operator, "operator"); 206 | } 207 | 208 | concatParenthesizedBlock(node, scope, func) 209 | { 210 | this.concatWithFormats(node, scope, "before-left-parens", "(", func ? "after-left-parens" : null); 211 | 212 | if (func) 213 | func(); 214 | 215 | this.concatWithFormats(node, scope, func ? "before-left-parens" : null, ")", "after-left-parens"); 216 | } 217 | 218 | concatBuffer(buffer) 219 | { 220 | this.atoms.push(...buffer.atoms); 221 | } 222 | } 223 | 224 | StringBuffer.RECEIVER_TEMP_VAR = "___r"; 225 | 226 | module.exports = StringBuffer; 227 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/dest/message-send-expression.js: -------------------------------------------------------------------------------- 1 | (function() 2 | { 3 | // @implementation CPApplication 4 | var $the_class = objj_allocateClassPair(Nil, "CPApplication"); 5 | objj_registerClassPair($the_class); 6 | // @end: @implementation CPApplication 7 | 8 | // @implementation CPString 9 | var $the_class = objj_allocateClassPair(Nil, "CPString"); 10 | objj_registerClassPair($the_class); 11 | // @end: @implementation CPString 12 | 13 | // @implementation CPTextField 14 | var $the_class = objj_allocateClassPair(Nil, "CPTextField"); 15 | objj_registerClassPair($the_class); 16 | // @end: @implementation CPTextField 17 | 18 | // @class CPArray 19 | 20 | var fileVar = /* [ 21 | [CPApplication sharedApplication] 22 | mainWindow 23 | ] */ ((___r1 = CPApplication.isa.objj_msgSend0(CPApplication, "sharedApplication")), ___r1 == null ? null : ___r1.isa.objj_msgSend0(___r1, "mainWindow")); 24 | 25 | // @implementation Super 26 | var $the_class = objj_allocateClassPair(Nil, "Super"); 27 | objj_registerClassPair($the_class); 28 | 29 | // Instance methods 30 | class_addMethods($the_class, 31 | [ 32 | // - (void)manyArgs:two:three:four: 33 | new objj_method(sel_getUid("manyArgs:two:three:four:"), 34 | function $Super__manyArgs_two_three_four_(self, _cmd, one, two, three, four) 35 | { 36 | }, 37 | // argument types 38 | ["void", "int", "int", "int", "int"]) 39 | ]); 40 | // @end: @implementation Super 41 | 42 | // @implementation Test : Super 43 | var $the_class = objj_allocateClassPair(Super, "Test"); 44 | objj_registerClassPair($the_class); 45 | 46 | class_addIvars($the_class, 47 | [ 48 | new objj_ivar("field", "CPTextField") 49 | ]); 50 | 51 | // Instance methods 52 | class_addMethods($the_class, 53 | [ 54 | // - (id)init 55 | new objj_method(sel_getUid("init"), 56 | function $Test__init(self, _cmd) 57 | { 58 | self = /* [super init] */ objj_msgSendSuper0({ receiver: self, super_class: objj_getClass("Test").super_class }, "init"); 59 | 60 | if (self) 61 | /* [self foo] */ (self == null ? null : self.isa.objj_msgSend0(self, "foo")); 62 | 63 | return self; 64 | }, 65 | // argument types 66 | ["id"]), 67 | 68 | // - (void)foo 69 | new objj_method(sel_getUid("foo"), 70 | function $Test__foo(self, _cmd) 71 | { 72 | { 73 | var count = /* [[self subviews] count] */ ((___r1 = self.isa.objj_msgSend0(self, "subviews")), ___r1 == null ? null : ___r1.isa.objj_msgSend0(___r1, "count")); 74 | } 75 | 76 | self.field = /* [[CPTextField alloc] init] */ ((___r1 = CPTextField.isa.objj_msgSend0(CPTextField, "alloc")), ___r1 == null ? null : ___r1.isa.objj_msgSend0(___r1, "init")); 77 | /* [field setTitle: 78 | [CPString stringWithFormat:@"Count: %d", count]] */ ((___r1 = self.field), ___r1 == null ? null : ___r1.isa.objj_msgSend1(___r1, "setTitle:", CPString.isa.objj_msgSend2(CPString, "stringWithFormat:", "Count: %d", count))); 79 | 80 | // Generated receiver temp variables 81 | var ___r1; 82 | }, 83 | // argument types 84 | ["void"]), 85 | 86 | // - (CPArray)subviews 87 | new objj_method(sel_getUid("subviews"), 88 | function $Test__subviews(self, _cmd) 89 | { 90 | return /* [[[ 91 | [CPApplication sharedApplication] 92 | mainWindow] 93 | contentView] 94 | subviews] */ ((___r1 = ((___r2 = ((___r3 = CPApplication.isa.objj_msgSend0(CPApplication, "sharedApplication")), ___r3 == null ? null : ___r3.isa.objj_msgSend0(___r3, "mainWindow"))), ___r2 == null ? null : ___r2.isa.objj_msgSend0(___r2, "contentView"))), ___r1 == null ? null : ___r1.isa.objj_msgSend0(___r1, "subviews")); 95 | 96 | // Generated receiver temp variables 97 | var ___r1, ___r2, ___r3; 98 | }, 99 | // argument types 100 | ["CPArray"]), 101 | 102 | // - (void)doSomething:withNumber:and:andAlso: 103 | new objj_method(sel_getUid("doSomething:withNumber:and:andAlso:"), 104 | function $Test__doSomething_withNumber_and_andAlso_(self, _cmd, something, number, and, also) 105 | { 106 | console.log(/* [CPString stringWithFormat:@"%s, %d, %s, %i", something, number, and, also] */ CPString.isa.objj_msgSend(CPString, "stringWithFormat:", "%s, %d, %s, %i", something, number, and, also)); 107 | }, 108 | // argument types 109 | ["void", "CPString", "int", "CPString", "int"]), 110 | 111 | // - (void)bigSelector 112 | new objj_method(sel_getUid("bigSelector"), 113 | function $Test__bigSelector(self, _cmd) 114 | { 115 | /* [self doSomething:@"bold" 116 | withNumber:7 117 | and:@"something else" 118 | andAlso:27] */ self.isa.objj_msgSend(self, "doSomething:withNumber:and:andAlso:", "bold", 7, "something else", 27); 119 | /* [super manyArgs:1 120 | two:2 121 | three:3 122 | four:4] */ objj_msgSendSuper({ receiver: self, super_class: objj_getClass("Test").super_class }, "manyArgs:two:three:four:", 1, 2, 3, 4); 123 | }, 124 | // argument types 125 | ["void"]), 126 | 127 | // - (void)emptySelector::: 128 | new objj_method(sel_getUid("emptySelector:::"), 129 | function $Test__emptySelector___(self, _cmd, one, two, three) 130 | { 131 | }, 132 | // argument types 133 | ["void", "int", "double", "CPArray"]), 134 | 135 | // - (void)testEmptySelector 136 | new objj_method(sel_getUid("testEmptySelector"), 137 | function $Test__testEmptySelector(self, _cmd) 138 | { 139 | /* [self emptySelector:1 :2 :[3]] */ self.isa.objj_msgSend3(self, "emptySelector:::", 1, 2, [3]); 140 | }, 141 | // argument types 142 | ["void"]) 143 | ]); 144 | 145 | // Class methods 146 | class_addMethods($the_class.isa, 147 | [ 148 | // + (void)initialize 149 | new objj_method(sel_getUid("initialize"), 150 | function $Test__initialize(self, _cmd) 151 | { 152 | /* [super initialize] */ objj_msgSendSuper0({ receiver: self, super_class: objj_getMetaClass("Test").super_class }, "initialize"); 153 | /* [self classInit] */ self.isa.objj_msgSend0(self, "classInit"); 154 | }, 155 | // argument types 156 | ["void"]), 157 | 158 | // + (void)classInit 159 | new objj_method(sel_getUid("classInit"), 160 | function $Test__classInit(self, _cmd) 161 | { 162 | }, 163 | // argument types 164 | ["void"]) 165 | ]); 166 | // @end: @implementation Test : Super 167 | 168 | // Generated receiver temp variables 169 | var ___r1; 170 | })(); 171 | -------------------------------------------------------------------------------- /test/fixtures/objj-nodes/dest/accessors.js: -------------------------------------------------------------------------------- 1 | (function() 2 | { 3 | // @implementation Accessors 4 | var $the_class = objj_allocateClassPair(Nil, "Accessors"); 5 | objj_registerClassPair($the_class); 6 | 7 | class_addIvars($the_class, 8 | [ 9 | new objj_ivar("accessors", "int"), 10 | new objj_ivar("copyMe", "int"), 11 | new objj_ivar("readOnly", "int"), 12 | new objj_ivar("propertyAccessors", "int"), 13 | new objj_ivar("getter", "int"), 14 | new objj_ivar("setter", "int"), 15 | new objj_ivar("getterSetter", "int"), 16 | new objj_ivar("hasGetter", "int"), 17 | new objj_ivar("hasSetter", "int"), 18 | new objj_ivar("_underscore", "int") 19 | ]); 20 | 21 | // Instance methods 22 | class_addMethods($the_class, 23 | [ 24 | // - (int)hasGetter 25 | new objj_method(sel_getUid("hasGetter"), 26 | function $Accessors__hasGetter(self, _cmd) 27 | { 28 | return self.hasGetter; 29 | }, 30 | // argument types 31 | ["int"]), 32 | 33 | // - (void)setHasSetter: 34 | new objj_method(sel_getUid("setHasSetter:"), 35 | function $Accessors__setHasSetter_(self, _cmd, newValue) 36 | { 37 | self.hasSetter = newValue; 38 | }, 39 | // argument types 40 | ["void", "int"]), 41 | 42 | // accessors @accessors [getter] 43 | // - (int)accessors 44 | new objj_method(sel_getUid("accessors"), 45 | function $Accessors__accessors(self, _cmd) 46 | { 47 | return self.accessors; 48 | }, 49 | // argument types 50 | ["int"]), 51 | 52 | // accessors @accessors [setter] 53 | // - (void)setAccessors:(int)newValue 54 | new objj_method(sel_getUid("setAccessors:"), 55 | function $Accessors__setAccessors_(self, _cmd, newValue) 56 | { 57 | self.accessors = newValue; 58 | }, 59 | // argument types 60 | ["void", "int"]), 61 | 62 | // copyMe @accessors(copy) [getter] 63 | // - (int)copyMe 64 | new objj_method(sel_getUid("copyMe"), 65 | function $Accessors__copyMe(self, _cmd) 66 | { 67 | return self.copyMe; 68 | }, 69 | // argument types 70 | ["int"]), 71 | 72 | // copyMe @accessors(copy) [setter] 73 | // - (void)setCopyMe:(int)newValue 74 | new objj_method(sel_getUid("setCopyMe:"), 75 | function $Accessors__setCopyMe_(self, _cmd, newValue) 76 | { 77 | if (self.copyMe !== newValue) 78 | /* copyMe = [newValue copy] */ self.copyMe = newValue == null ? null : newValue.isa.objj_msgSend0(newValue, "copy"); 79 | }, 80 | // argument types 81 | ["void", "int"]), 82 | 83 | // readOnly @accessors(readonly) [getter] 84 | // - (int)readOnly 85 | new objj_method(sel_getUid("readOnly"), 86 | function $Accessors__readOnly(self, _cmd) 87 | { 88 | return self.readOnly; 89 | }, 90 | // argument types 91 | ["int"]), 92 | 93 | // propertyAccessors @accessors(property=property) [getter] 94 | // - (int)property 95 | new objj_method(sel_getUid("property"), 96 | function $Accessors__property(self, _cmd) 97 | { 98 | return self.propertyAccessors; 99 | }, 100 | // argument types 101 | ["int"]), 102 | 103 | // propertyAccessors @accessors(property=property) [setter] 104 | // - (void)setProperty:(int)newValue 105 | new objj_method(sel_getUid("setProperty:"), 106 | function $Accessors__setProperty_(self, _cmd, newValue) 107 | { 108 | self.propertyAccessors = newValue; 109 | }, 110 | // argument types 111 | ["void", "int"]), 112 | 113 | // getter @accessors(getter=getMe) [getter] 114 | // - (int)getMe 115 | new objj_method(sel_getUid("getMe"), 116 | function $Accessors__getMe(self, _cmd) 117 | { 118 | return self.getter; 119 | }, 120 | // argument types 121 | ["int"]), 122 | 123 | // getter @accessors(getter=getMe) [setter] 124 | // - (void)setGetter:(int)newValue 125 | new objj_method(sel_getUid("setGetter:"), 126 | function $Accessors__setGetter_(self, _cmd, newValue) 127 | { 128 | self.getter = newValue; 129 | }, 130 | // argument types 131 | ["void", "int"]), 132 | 133 | // setter @accessors(setter=setMe) [getter] 134 | // - (int)setter 135 | new objj_method(sel_getUid("setter"), 136 | function $Accessors__setter(self, _cmd) 137 | { 138 | return self.setter; 139 | }, 140 | // argument types 141 | ["int"]), 142 | 143 | // setter @accessors(setter=setMe) [setter] 144 | // - (void)setMe:(int)newValue 145 | new objj_method(sel_getUid("setMe:"), 146 | function $Accessors__setMe_(self, _cmd, newValue) 147 | { 148 | self.setter = newValue; 149 | }, 150 | // argument types 151 | ["void", "int"]), 152 | 153 | // getterSetter @accessors(getter=getMe, setter=setIt) [setter] 154 | // - (void)setIt:(int)newValue 155 | new objj_method(sel_getUid("setIt:"), 156 | function $Accessors__setIt_(self, _cmd, newValue) 157 | { 158 | self.getterSetter = newValue; 159 | }, 160 | // argument types 161 | ["void", "int"]), 162 | 163 | // hasGetter @accessors [setter] 164 | // - (void)setHasGetter:(int)newValue 165 | new objj_method(sel_getUid("setHasGetter:"), 166 | function $Accessors__setHasGetter_(self, _cmd, newValue) 167 | { 168 | self.hasGetter = newValue; 169 | }, 170 | // argument types 171 | ["void", "int"]), 172 | 173 | // hasSetter @accessors [getter] 174 | // - (int)hasSetter 175 | new objj_method(sel_getUid("hasSetter"), 176 | function $Accessors__hasSetter(self, _cmd) 177 | { 178 | return self.hasSetter; 179 | }, 180 | // argument types 181 | ["int"]), 182 | 183 | // _underscore @accessors [getter] 184 | // - (int)underscore 185 | new objj_method(sel_getUid("underscore"), 186 | function $Accessors__underscore(self, _cmd) 187 | { 188 | return self._underscore; 189 | }, 190 | // argument types 191 | ["int"]), 192 | 193 | // _underscore @accessors [setter] 194 | // - (void)setUnderscore:(int)newValue 195 | new objj_method(sel_getUid("setUnderscore:"), 196 | function $Accessors__setUnderscore_(self, _cmd, newValue) 197 | { 198 | self._underscore = newValue; 199 | }, 200 | // argument types 201 | ["void", "int"]) 202 | ]); 203 | // @end: @implementation Accessors 204 | })(); 205 | -------------------------------------------------------------------------------- /test/fixtures/exceptions/dest/protocol-conformance.txt: -------------------------------------------------------------------------------- 1 | 2 | test/fixtures/exceptions/src/protocol-conformance.j:24:4: warning: conflicting return type in declaration of 'override': 'int' vs. 'void' 3 | - (int)override; 4 | ^ 5 | test/fixtures/exceptions/src/protocol-conformance.j:10:4: note: previous declaration is here 6 | - (void)override; 7 | ^ 8 | test/fixtures/exceptions/src/protocol-conformance.j:48:25: warning: method 'twoRequired1' in protocol 'Two' not implemented 9 | @implementation Class1 10 | ^ 11 | test/fixtures/exceptions/src/protocol-conformance.j:23:1: note: method 'twoRequired1' declared here 12 | - (void)twoRequired1; 13 | ^ 14 | test/fixtures/exceptions/src/protocol-conformance.j:48:25: warning: method 'override' in protocol 'Two' not implemented 15 | @implementation Class1 16 | ^ 17 | test/fixtures/exceptions/src/protocol-conformance.j:24:1: note: method 'override' declared here 18 | - (int)override; 19 | ^ 20 | test/fixtures/exceptions/src/protocol-conformance.j:48:25: warning: method 'oneRequired1' in protocol 'One' not implemented 21 | @implementation Class1 22 | ^ 23 | test/fixtures/exceptions/src/protocol-conformance.j:4:1: note: method 'oneRequired1' declared here 24 | - (void)oneRequired1; 25 | ^ 26 | test/fixtures/exceptions/src/protocol-conformance.j:48:25: warning: method 'oneRequired2' in protocol 'One' not implemented 27 | @implementation Class1 28 | ^ 29 | test/fixtures/exceptions/src/protocol-conformance.j:8:1: note: method 'oneRequired2' declared here 30 | - (void)oneRequired2; 31 | ^ 32 | test/fixtures/exceptions/src/protocol-conformance.j:48:25: warning: method 'override' in protocol 'One' not implemented 33 | @implementation Class1 34 | ^ 35 | test/fixtures/exceptions/src/protocol-conformance.j:10:1: note: method 'override' declared here 36 | - (void)override; 37 | ^ 38 | test/fixtures/exceptions/src/protocol-conformance.j:48:25: warning: method 'twoClassRequired1' in protocol 'Two' not implemented 39 | @implementation Class1 40 | ^ 41 | test/fixtures/exceptions/src/protocol-conformance.j:25:1: note: method 'twoClassRequired1' declared here 42 | + (void)twoClassRequired1; 43 | ^ 44 | test/fixtures/exceptions/src/protocol-conformance.j:48:25: warning: method 'oneClassRequired2' in protocol 'One' not implemented 45 | @implementation Class1 46 | ^ 47 | test/fixtures/exceptions/src/protocol-conformance.j:11:1: note: method 'oneClassRequired2' declared here 48 | + (void)oneClassRequired2; 49 | ^ 50 | test/fixtures/exceptions/src/protocol-conformance.j:48:30: warning: method 'threeRequired1' in protocol 'Three' not implemented 51 | @implementation Class1 52 | ^ 53 | test/fixtures/exceptions/src/protocol-conformance.j:36:1: note: method 'threeRequired1' declared here 54 | - (void)threeRequired1; 55 | ^ 56 | test/fixtures/exceptions/src/protocol-conformance.j:75:25: warning: method 'oneRequired3' in protocol 'One' not implemented 57 | @implementation Class3 58 | ^ 59 | test/fixtures/exceptions/src/protocol-conformance.j:9:1: note: method 'oneRequired3' declared here 60 | - (void)oneRequired3; 61 | ^ 62 | test/fixtures/exceptions/src/protocol-conformance.j:75:25: warning: method 'override' in protocol 'One' not implemented 63 | @implementation Class3 64 | ^ 65 | test/fixtures/exceptions/src/protocol-conformance.j:10:1: note: method 'override' declared here 66 | - (void)override; 67 | ^ 68 | test/fixtures/exceptions/src/protocol-conformance.j:75:25: warning: method 'oneClassRequired2' in protocol 'One' not implemented 69 | @implementation Class3 70 | ^ 71 | test/fixtures/exceptions/src/protocol-conformance.j:11:1: note: method 'oneClassRequired2' declared here 72 | + (void)oneClassRequired2; 73 | ^ 74 | test/fixtures/exceptions/src/protocol-conformance.j:96:4: warning: conflicting return type in declaration of 'override': 'void' vs. 'int' 75 | - (void)override 76 | ^ 77 | test/fixtures/exceptions/src/protocol-conformance.j:24:4: note: previous declaration is here 78 | - (int)override; 79 | ^ 80 | test/fixtures/exceptions/src/protocol-conformance.j:94:33: warning: method 'twoRequired1' in protocol 'Two' not implemented 81 | @implementation Class4: Class3 82 | ^ 83 | test/fixtures/exceptions/src/protocol-conformance.j:23:1: note: method 'twoRequired1' declared here 84 | - (void)twoRequired1; 85 | ^ 86 | test/fixtures/exceptions/src/protocol-conformance.j:94:33: warning: method 'twoClassRequired1' in protocol 'Two' not implemented 87 | @implementation Class4: Class3 88 | ^ 89 | test/fixtures/exceptions/src/protocol-conformance.j:25:1: note: method 'twoClassRequired1' declared here 90 | + (void)twoClassRequired1; 91 | ^ 92 | 93 | 15 warnings generated. 94 | --------------------------------------------------------------------------------