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

42tiny-js a fork of this project #4

Closed
GoogleCodeExporter opened this issue Mar 24, 2015 · 7 comments
Closed

42tiny-js a fork of this project #4

GoogleCodeExporter opened this issue Mar 24, 2015 · 7 comments

Comments

@GoogleCodeExporter
Copy link

Many thanks for this nice project. I have started my own fork with many changes 
at http://code.google.com/p/42tiny-js/

Changelog:
Added boolean datatype (in string operators its shown as 'true'/'false' but in
math as '1'/'0'
Added '~' operator
Added bit-shift operators '<<' '>>'
Added assignment operators '<<=' '>>=' '|=' '&=' '^='
Addet comma operator like this 'var i=1,j,k=9;' or 'for(i=0,j=12; i<10; i++,
j++)' works
Added Conditional operator ( ? : )
Added automatic cast from doubles to integer e.G. by logic and binary operators
Added pre-increment/-decrement like '++i'/'--i' operator
Fixed post-increment/decrement now returns the previous value
Fixed throws an Error when invalid using of post/pre-increment/decrement (like
this 5++ works no more)
Fixed memoryleak (unref arrayClass at deconstructor of JS CTinyJS)
Fixed unary operator handling (like this '-~-5' works now)
Fixed operator prority order
            -> ','
            -> '=' '+=' '-=' '<<=' '>>=' '&=' '^=' '|='
            -> '? :' -> '||' -> '&&' -> '|' -> '^' -> '&'
            -> ['==' '===' '!=' '!==']
            -> [ '<' '<=' '=>' '>']
            -> ['<<' '>>'] -> [ '*' '/' '%']
            -> ['!' '~' '-' '++' '--']
Added do-while-loop ( do .... while(..); )
Added break and continue statements for loops

ardi

Original issue reported on code.google.com by [email protected] on 1 Sep 2010 at 5:49

@GoogleCodeExporter
Copy link
Author

Thanks, that's great! is it ok to pull those changes back into this project?

Out of interest, is there any reason you couldn't work off a branch on this 
project? Everyone seems to be starting a whole new repository - I just wondered 
if it's because I somehow disabled write access :)

Original comment by [email protected] on 2 Sep 2010 at 9:53

@GoogleCodeExporter
Copy link
Author

of course you can pull back my changes to your project

Original comment by [email protected] on 2 Sep 2010 at 11:34

@GoogleCodeExporter
Copy link
Author

When you me join as commiter, i have no problem to work of a branch.

I have created my own repository because my reflexion was that everyone only in 
the "trunk" looks ;-)

Join me and i will remove my fork and work on a branch.

Original comment by [email protected] on 2 Sep 2010 at 11:52

@GoogleCodeExporter
Copy link
Author

Thanks, I've just added you.
I updated the trunk with your changes to the lexer, the leak, and sprintf/etc, 
as well as some memory leak fixes I found too. If you're happy to do so you 
could put your changes into trunk if you want to - either that or branch them 
and we can pull back when you're happy?

Original comment by [email protected] on 3 Sep 2010 at 6:12

@GoogleCodeExporter
Copy link
Author

Original comment by [email protected] on 6 Sep 2010 at 5:10

  • Changed state: Fixed

@GoogleCodeExporter
Copy link
Author

Thanks for adding all the changes, using the map seems like it could improve 
speed quite a lot!

Did you run the automated tests in run_tests on it? It seems to fail a few of 
them now and segfaults when dumping empty classes (at least on Linux).

I don't know if you want to commit this? I don't want to mess with your branch, 
but this fixes the segfault for empty classes.

Index: TinyJS.cpp
===================================================================
--- TinyJS.cpp  (revision 26)
+++ TinyJS.cpp  (working copy)
@@ -1135,10 +1135,10 @@
    ostringstream funcStr;
    funcStr << "function (";
    // get list of parameters
-   SCRIPTVAR_CHILDS::iterator last_it = --(Childs.end());
+   int count = Childs.size();
    for(SCRIPTVAR_CHILDS::iterator it = Childs.begin(); it != Childs.end(); ++it) {
        funcStr << it->first;
-       if (it != last_it) funcStr << ", ";
+       if (--count) funcStr << ", ";
    }
    // add function body
    funcStr << ") " << getString();
@@ -1157,7 +1157,7 @@
        string indentedLinePrefix = linePrefix+"  ";
        // children - handle with bracketed list
        destination << "{ \n";
-       SCRIPTVAR_CHILDS::iterator last_it = --(Childs.end());
+       int count = Childs.size();
        for(SCRIPTVAR_CHILDS::iterator it = Childs.begin(); it != Childs.end(); ++it) {
            destination << indentedLinePrefix;
            if (isAlphaNum(it->first))
@@ -1166,9 +1166,8 @@
                destination  << getJSString(it->first);
            destination  << " : ";
            it->second->var->getJSON(destination, indentedLinePrefix);
-           if (it != last_it) {
+           if (--count) 
                destination  << ",\n";
-           }
        }
        destination << "\n" << linePrefix << "}";
    } else if (isArray()) {
Index: TinyJS_Functions.cpp
===================================================================
--- TinyJS_Functions.cpp    (revision 26)
+++ TinyJS_Functions.cpp    (working copy)
@@ -41,7 +41,7 @@
 using namespace std;
 // ----------------------------------------------- Actual Functions

-void scTrace(CScriptVar *UNUSED(c), void * userdata) {
+void scTrace(CScriptVar *c, void * userdata) {
    CTinyJS *js = (CTinyJS*)userdata;
    js->root->trace();
 }

Original comment by [email protected] on 6 Sep 2010 at 12:17

@GoogleCodeExporter
Copy link
Author

thanks for fixing this segfaults-bug
yes the result of "--(Childs.end())" by a blank "map" does not exist or is bad. 
I have not thought of it.;-)
i have fix my branch

Original comment by [email protected] on 6 Sep 2010 at 7:20

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

No branches or pull requests

1 participant