Javascript strange code


#1

Hi,

I was reading the Javascript code in Juce and found this:

// In struct LoopStatement:

                if (r == continueWasHit) continue;
                iterator->perform (s, nullptr);

One would expect that such code:

var i = 0;
for (i = 0; i < 3; i++) { if (i == 1) continue; } 

would exit.

However the parser above does not evaluate the "iterator" statement in case of continue is hit, and as such would never exit. 

 

Also, it would be very cool if you linked the Component class to the Javascript engine, so that we could call any component's method through the javascript parser.


#2

Ah, good catch, thanks!

I have been using it for GUI stuff in a side-project, but TBH couldn't find a good way to make this into generic functionality. It is something I'm tinkering with in my spare time though, so will probably come up with something..


#3

Also, I don't understand why in parseStringLiteral you're calling JSON::parseQuotedString.

Is it for regular expressions like "r/regex/" ?

 


#4

No.. Why shouldn't it use that function to parse the string? There'd be no point in having two different bits of code that do the same job (??)