Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

nsc compiler works, but how to run result? #164

Description

@plaurent

The README in the 3.0 branch specifies how to compile code, but not how to run the result.

Given a file called Example1.ns:

@class TheClass
- (String) doSomethingWithString:(String)string andNumber:(Number)number
{
    return string + "-" + number;    
}
@end

let instance = [[TheClass alloc] init];
console.log([instance doSomethingWithString:"A" andNumber:3]);

using nsc Example1.ns -o a.js, when I run a.js I get:

root@9e1af5a6a5d9:~/Project1# node a.js 
/root/Project1/a.js:1
N$$_._registerClass("N$_c_TheClass",null,function(N$_s, N$_m) { function N$_c_TheClass() { this.constructor = N$_c_TheClass;this.N$_id = ++N$$_._id;}
^

ReferenceError: N$$_ is not defined
    at Object.<anonymous> (/root/Project1/a.js:1:1)
    at Module._compile (internal/modules/cjs/loader.js:936:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
    at Module.load (internal/modules/cjs/loader.js:790:32)
    at Function.Module._load (internal/modules/cjs/loader.js:703:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:999:10)
    at internal/main/run_main_module.js:17:11
root@9e1af5a6a5d9:~/Project1# 

How can I run a.js? Do I need to import something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions