Squirrel

The programming language
Welcome to Squirrel Sign in | Join | Help
in Search

SQ3.0b1: EmitCompoundArith with outer operand

Last post 12-24-2009, 4:26 PM by fagiano. 1 replies.
Sort Posts: Previous Next
  •  12-23-2009, 7:54 AM 3601

    SQ3.0b1: EmitCompoundArith with outer operand

    Hi,

    The "real" free-variable feature introduced on 3.0 is very cool!
    But there's a little bug which can be easily fixed:


    Reproduce:

    sq> local k=0; function foo() { k-=10; print(k) }
    sq> foo()
    10
    sq> foo()
    0
    sq> foo()
    10
    sq> foo()
    0

    Suggested patch:

    at EmitCompoundArith(), sqcompiler.cpp line 357:

    (before)
    _fs->AddInstruction(ChooseArithOpByToken(tok), tmp, tmp, val, 0);

    (fix)
    _fs->AddInstruction(ChooseArithOpByToken(tok), tmp, val, tmp, 0);

    You can just switch arg1 and arg2 for arith op.

    test:
    sq> local k=0; function foo() { k-=10; print(k) }
    sq> foo()
    -10
    sq> foo()
    -20
    sq> foo()
    -30
    sq> foo()
    -40

    Tested with '/=', '%=' also without problem.

    I hope this helpful.
    Thanks.
  •  12-24-2009, 4:26 PM 3603 in reply to 3601

    Re: SQ3.0b1: EmitCompoundArith with outer operand

    thanks a lot, I'll look into that.

    ciao
    Alberto
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems