Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various issues discovered while compiling Rawrcat #117

Closed
wbrown opened this issue Nov 10, 2020 · 16 comments
Closed

Various issues discovered while compiling Rawrcat #117

wbrown opened this issue Nov 10, 2020 · 16 comments
Labels

Comments

@wbrown
Copy link

wbrown commented Nov 10, 2020

I saw this project, and decided to give it a shot on compiling my JavaScript implementation of RawrCat.

https://github.com/ephsec/rawrcat

Tested versions:

  • NectarJS v0.7.99
  • NectarJS master off github.

Invoking nectarjs on rawrcat.js uncovered several issues:

  • delete item[k] throws a parse error in babel

  • for() loops require explicit var declaration inside the for() if the variable isn't defined beforehand. (This is something I will fix in my source code, for linting purposes)

  • My use of null comparison isn't yet supported:

Visitor VISITOR.objectExpression not implemented yet for NullLiteral
  • My use of conditional expressions doesn't seem to be much liked either:
Visitor VISITOR.objectExpression not implemented yet for ConditionalExpression

Is there a debug mode that will tell me exactly where in the source it's having issues? --verbose does not appear to do much.

This project interests me, and I'd like to help get it to where it can compile RawrCat. I'm a language, parser, and compiler nerd myself.

@adrien-thierry
Copy link
Contributor

Hi @wbrown ,

thank you for your interest in NectarJS,

I will try to compile Rawrcat to check the bugs and correct them

Right now there is no debug mode, but it's on the roadmap

@wbrown
Copy link
Author

wbrown commented Nov 10, 2020

  • for() loops require explicit var declaration inside the for() if the variable isn't defined beforehand. (This is something I will fix in my source code, for linting purposes)

I've just corrected the above in my source code, as it's actually more correct code to use var to avoid bringing in scope from outside the loop.

@adrien-thierry
Copy link
Contributor

the file you want to compile is rawrcat.js ?

@wbrown
Copy link
Author

wbrown commented Nov 11, 2020

@adrien-thierry Yes, sir. Though now that I think about it -- how does it handle require() calls?

@adrien-thierry
Copy link
Contributor

Ok, i will check it

For require, code is encapsuled into a function call then integrated in the code

@wbrown
Copy link
Author

wbrown commented Nov 17, 2020

@adrien-thierry Any updates? Any way I can help? :)

@adrien-thierry
Copy link
Contributor

Hi, yes sorry, a lot of things ti do haha

NectarJS doesn't support dynamic require yet, can you modify this ?

I will add the missing visitors and missing method

adrien-thierry added a commit that referenced this issue Nov 19, 2020
@adrien-thierry
Copy link
Contributor

I corrected the delete item[k] problem,
I will continue to correct things until we can compile Rawrcat

@wbrown
Copy link
Author

wbrown commented Nov 19, 2020

NectarJS doesn't support dynamic require yet, can you modify this ?

So what do you mean by this? Just static require statements for the modules in question?

Rather than wrapping require in a handler with a variable passed, do static requires for the modules?

i.e. rather than: https://github.com/ephsec/RawrCat/blob/master/rawrcat.js#L17-L36

... and dynamically loading the modules in at runtime, like so: https://github.com/ephsec/RawrCat/blob/master/index.html#L43

... we do:

require("js/rawrterm.js")

... ?

@adrien-thierry
Copy link
Contributor

Yes, exactly, atm, require in NectarJS is a macro that manage code including wrapped in a module. When NectarJS will be self compiled, we will be able to self embed the compiler and generate code from module on the fly, but for now, the only solution is to use static require

@wbrown
Copy link
Author

wbrown commented Nov 20, 2020

@adrien-thierry Is there a test or variable I can check to detect that that the code is being compiled by NectarJS, or running as a NectarJS-produced executable?

I've managed to avoid a build system thus far by checking the runtime environment, and I'd like to continue to do this if possible. :)

@adrien-thierry
Copy link
Contributor

Yes, you can check the __NJS_ENV global var like :

if(__NJS_ENV)
{
  // NectarJS
}
else 
{
 // not NectarJS
}

The __NJS_ENV var store the name of the env you compile the code with (std, android, arduino, node ...)

@wbrown
Copy link
Author

wbrown commented Nov 20, 2020

@adrien-thierry I've added the check for the existence of __NJS_ENV, hopefully this works:

ephsec/RawrCat@7b38fd9

@adrien-thierry
Copy link
Contributor

Hi @wbrown , I corrected some problems, i will continue

@wbrown
Copy link
Author

wbrown commented Dec 7, 2020

Hi @wbrown , I corrected some problems, i will continue

Awesome. Which problems, out of curiosity?

@adrien-thierry
Copy link
Contributor

Hi @wbrown , we implemented our own parser, we will release a big update soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants