This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Google Summer of Code


On Fri, 04 Apr 2014 12:49:25 -0700
Per Bothner <per@bothner.com> wrote:

> Is this numCases==0? If so I don't see where the bug is.
> Perhaps you could put System.println("line N SP:"+SP) on
> various lines and see if you can figure out what the problem is.

Also with numCases == 1

> // only an else clause
> numCases: 0 
> Before code.pushType(Type.intType);  SP:1
> After code.pushType(Type.intType);  SP:2
> Before code.emitPop(1); SP:2
> After code.emitPop(1); SP:1
> Before code.emitGoto(defaultLabel); SP:1
> Exception in thread "main" java.lang.InternalError: setTypes for
> Label#7-pos:31 SP:0 code.SP:1

> // one clause with an else clause
> numCases: 1 
> Before code.pushType(Type.intType);  SP:1
> After code.pushType(Type.intType);  SP:2
> Before code.emitIfIntEqZero(); SP:2
> After code.emitIfIntEqZero(); SP:1
> Before code.emitGoto(labels[0]); SP:1
> Exception in thread "main" java.lang.InternalError: setTypes for
> Label#7-pos:31 SP:0 code.SP:1

> // one clouse without an else clause
> numCases: 1
> Before code.pushType(Type.intType);  SP:0
> After code.pushType(Type.intType);  SP:1
> Before code.emitIfIntEqZero(); SP:1
> After code.emitIfIntEqZero(); SP:0
> Before code.emitGoto(labels[0]); SP:0
> After code.emitGoto(labels[0]); SP:0
> Before code.emitElse(); SP:0
> After code.emitElse(); SP:0
> Before code.emitGoto(defaultLabel); SP:0
> After code.emitGoto(defaultLabel); SP:0
> Before code.emitFi(); SP:0
> After code.emitFi(); SP:0
>
> No error during compilation
> Executes the right case expression correctly
> After execution: DEBUG MESSAGE: unimplemented bytecode
> java.lang.NullPointerException
>	at it.polimi.kawacase.syntax.run(syntax.scm:69)
>	at gnu.expr.ModuleBody.runAsMain(ModuleBody.java:152)
>	at it.polimi.kawacase.syntax.main(syntax.scm)

Maybe there is some problem with my code. I think the problem is the
SP:1 at the starting point of finish(). I suppose from the emitPop(1)
in the code that at that point is always expected an SP:0. There SP is 1
because the default clause expression is compiled with a StackTarget,
so the result is expected to be put on the stack.

Concerning the "unimplemented bytecode" message, I have no idea. When I
have no else clause I add a default void case:

>sw.addDefault(code);
>QuoteExp.voidExp.compile(comp, new StackTarget(PrimType.void_type));
>sw.finish(code);

Andrea 
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]