felixhao28 / JSCPP

A simple C++ interpreter written in JavaScript

Home Page:https://felixhao28.github.io/JSCPP/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to add extra methods

WayneKeenan opened this issue · comments

Hi,

I'm trying to create a custom class in ts but I'm running into a couple of issues, this is one...

If I add a second method, by simply modifying dummy_class_foo.ts like this:

        rt.regFunc(_plusX, type, "plusX", [rt.intTypeLiteral], rt.intTypeLiteral);
        rt.regFunc(_plusX, type, "plusX2", [rt.intTypeLiteral], rt.intTypeLiteral);

Using the class_basics in an HTML file:

    var code = "#include <iostream>"+
        "#include <foo>"+
        "using namespace std;"+
        "int main() {"+
        "    Foo foo;"+
        "    cout << foo.x << ',' << foo.y << endl;"+
        "    cout << foo.plusX(5) << endl;"+
        "    cout << foo.plusX2(5) << endl;"+
        "    return 0;"+
        "}";

I get this error:

[Error] TypeError: undefined is not an object (evaluating 't.v')
	dispatchException (JSCPP.es5.min.js:1:334009)
	(anonymous function) (JSCPP.es5.min.js:1:330361)
	run (JSCPP.es5.min.js:1:220827)
	Global Code (class.html:32)

Any help would be greatly appreciated. Thanks.

Have you run npm run build to regenerate JSCPP.es5.min.js after the change?

thanks, I was usingwatch-ts but that wasn't enough.