Closed GoogleCodeExporter closed 9 years ago
Here is the Java bytecode that produced it:
public void writeMap(Map dest, Object src) {
// <editor-fold defaultstate="collapsed" desc="Compiled Code">
/* 0: aload_0
* 1: aload_1
* 2: ldc frameNumber
* 4: aload_2
* 5: checkcast nl/synobsys/bowlingscore/data/Frame
* 8: invokevirtual nl/synobsys/bowlingscore/data/Frame.getFrameNumber:()I
* 11: new java/lang/Integer
* 14: dup_x1
* 15: swap
* 16: invokespecial java/lang/Integer."<init>":(I)V
* 19: invokevirtual ca/weblite/codename1/mapper/DataMapper.set:(Ljava/util/Map;Ljava/lang/String;Ljava/lang/Object;)V
* 22: aload_0
* 23: aload_1
* 24: ldc throw1
* 26: aload_2
* 27: checkcast nl/synobsys/bowlingscore/data/Frame
* 30: invokevirtual nl/synobsys/bowlingscore/data/Frame.getThrow1:()Ljava/lang/String;
* 33: invokevirtual ca/weblite/codename1/mapper/DataMapper.set:(Ljava/util/Map;Ljava/lang/String;Ljava/lang/Object;)V
* 36: aload_0
* 37: aload_1
* 38: ldc throw2
* 40: aload_2
* 41: checkcast nl/synobsys/bowlingscore/data/Frame
* 44: invokevirtual nl/synobsys/bowlingscore/data/Frame.getThrow2:()Ljava/lang/String;
* 47: invokevirtual ca/weblite/codename1/mapper/DataMapper.set:(Ljava/util/Map;Ljava/lang/String;Ljava/lang/Object;)V
* 50: aload_0
* 51: aload_1
* 52: ldc throw3
* 54: aload_2
* 55: checkcast nl/synobsys/bowlingscore/data/Frame
* 58: invokevirtual nl/synobsys/bowlingscore/data/Frame.getThrow3:()Ljava/lang/String;
* 61: invokevirtual ca/weblite/codename1/mapper/DataMapper.set:(Ljava/util/Map;Ljava/lang/String;Ljava/lang/Object;)V
* 64: aload_0
* 65: aload_1
* 66: ldc score
* 68: aload_2
* 69: checkcast nl/synobsys/bowlingscore/data/Frame
* 72: invokevirtual nl/synobsys/bowlingscore/data/Frame.getScore:()I
* 75: new java/lang/Integer
* 78: dup_x1
* 79: swap
* 80: invokespecial java/lang/Integer."<init>":(I)V
* 83: invokevirtual ca/weblite/codename1/mapper/DataMapper.set:(Ljava/util/Map;Ljava/lang/String;Ljava/lang/Object;)V
* 86: aload_0
* 87: aload_1
* 88: ldc class
* 90: aload_2
* 91: checkcast nl/synobsys/bowlingscore/data/Frame
* 94: invokevirtual java/lang/Object.getClass:()Ljava/lang/Class;
* 97: invokevirtual ca/weblite/codename1/mapper/DataMapper.set:(Ljava/util/Map;Ljava/lang/String;Ljava/lang/Object;)V
* 100: return
* */
// </editor-fold>
}
I believe it is line 15
Original comment by st...@weblite.ca
on 26 Jan 2015 at 5:40
That does look a bit suspect.
#define swapStack(array, sp) { \
struct elementStruct t = array[sp]; \
array[sp] = array[sp - 1]; \
array[sp - 1] = t; \
}
This is effectively copying a struct which might be a problem. If you change
swapStack to this does it solve it:
#define swapStack(array, sp) { \
javaTypes tt = array[sp].type; \
elementUnion td = array[sp].data; \
array[sp].type = array[sp - 1].type; \
array[sp].data = array[sp - 1].data; \
array[sp - 1].type = tt; \
array[sp - 1].data = td; \
}
Original comment by shai.almog
on 26 Jan 2015 at 5:49
[deleted comment]
I get the same result after changing swapStack().
I'm looking through the debugger at a few break points to see I can shed any
light on this.
Original comment by st...@weblite.ca
on 26 Jan 2015 at 6:19
I seem to get good results by changing swapStack to:
#define swapStack(array, sp) { \
struct elementStruct t = array[sp-1]; \
array[sp-1] = array[sp - 2]; \
array[sp - 2] = t; \
}
I'm still playing catchup here, but I believe the stack pointer is usually
(always??) pointing to the *next* position where something can be added to the
stack. Therefore swapping the top 2 items in the stack actually entails
swapping items at positions (sp-1 and sp-2), and not (sp and sp-1).
Do you see any flaws in my logic? If not, can I commit this?
Original comment by st...@weblite.ca
on 26 Jan 2015 at 6:57
I have gone ahead and committed this. I've gone through it with a number of
test cases, and I'm fairly certain that this is correct.
(At the very least it corrects this issue).
https://code.google.com/p/codenameone/source/detail?r=2040
Original comment by st...@weblite.ca
on 26 Jan 2015 at 7:15
I was just commenting for you to go ahead and got a conflict ;-)
Original comment by shai.almog
on 26 Jan 2015 at 7:16
Original issue reported on code.google.com by
st...@weblite.ca
on 26 Jan 2015 at 5:38