fb39ca4 / picoc

Automatically exported from code.google.com/p/picoc
0 stars 0 forks source link

LED example doesn't work #85

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Test #32 doesn't work. Find out why.

Original issue reported on code.google.com by zik.sale...@gmail.com on 3 Jul 2010 at 4:34

GoogleCodeExporter commented 8 years ago
Problem is AddAssign is not supported, e.g.

    /* print top lines of all digits */

    for(i=n-1;i>=0;i--){
        topline(d[i],buf);
        buf += 3;
        *buf++=' ';
    }

You need to add the handling in function ExpressionInfixOperator, e.g.

    ...

    else if (BottomValue->Typ->Base == TypePointer && IS_NUMERIC_COERCIBLE(TopValue))
    {
        ...
        else if (Op == TokenAddAssign || Op == TokenSubtractAssign)
        {
            /* pointer arithmetic */
            int Size = TypeSize(BottomValue->Typ->FromType, 0, TRUE);

            Pointer = BottomValue->Val->Pointer;
            if (Pointer == NULL)
                ProgramFail(Parser, "invalid use of a NULL pointer");

            if (Op == TokenAddAssign)
                Pointer = (void *)((char *)Pointer + TopInt * Size);
            else
                Pointer = (void *)((char *)Pointer - TopInt * Size);

            HeapUnpopStack(sizeof(struct Value));   /* XXX - possible bug if lvalue is a temp value and takes more than sizeof(struct Value) */
            BottomValue->Val->Pointer = Pointer;
            ExpressionStackPushValueNode(Parser, StackTop, BottomValue);
        }
        else
            ProgramFail(Parser, "invalid operation");

Original comment by duncan.f...@gmail.com on 21 Jul 2010 at 1:34

GoogleCodeExporter commented 8 years ago
Thanks - your contribution is very much appreciated. Thanks.

Original comment by zik.sale...@gmail.com on 21 Jul 2010 at 5:40

GoogleCodeExporter commented 8 years ago
I've made a number of fixes on this one now.

* Comments were causing problems with line number counting
* "static" wasn't recognised. Now I'm recognising and ignoring it.
* Constants ending with "L" weren't handled. Now the "L" is recognised and 
ignored.
* Plus Duncan Forster's fix for += handling.

Original comment by zik.sale...@gmail.com on 24 Jul 2010 at 4:53

GoogleCodeExporter commented 8 years ago
Scheduled for release 2.0

Original comment by zik.sale...@gmail.com on 27 Jul 2010 at 10:55

GoogleCodeExporter commented 8 years ago
Appears to be resolved now - must have fixed the bug which was affecting it at 
some point along the way.

I've added this to the official tests now.

Original comment by zik.sale...@gmail.com on 11 Feb 2011 at 5:05