[gogc] 3 new revisions pushed by bytbox on 2010-08-18 00:39 GMT

0 views
Skip to first unread message

go...@googlecode.com

unread,
Aug 17, 2010, 11:24:03 PM8/17/10
to go...@googlegroups.com
3 new revisions:

Revision: 023871bf93
Author: Michael Lippautz <michael....@gmail.com>
Date: Mon Jun 21 06:28:50 2010
Log: gogo: If/for should now be correct over multiple levels of expressions
http://code.google.com/p/gogc/source/detail?r=023871bf93

Revision: 5cfee10975
Author: Michael Lippautz <michael....@gmail.com>
Date: Mon Jun 21 06:29:35 2010
Log: Merge branch 'master' of gitorious.org:gogo/gogo
http://code.google.com/p/gogc/source/detail?r=5cfee10975

Revision: 13f910bf22
Author: Michael Lippautz <michael....@gmail.com>
Date: Mon Jun 21 07:35:08 2010
Log: gogo: Add logic for NOT. Works for small examples ;p
http://code.google.com/p/gogc/source/detail?r=13f910bf22

==============================================================================
Revision: 023871bf93
Author: Michael Lippautz <michael....@gmail.com>
Date: Mon Jun 21 06:28:50 2010
Log: gogo: If/for should now be correct over multiple levels of expressions
http://code.google.com/p/gogc/source/detail?r=023871bf93

Modified:
/src/_gogo_.sog
/src/gen-cond.go
/src/gen-expr.go
/src/gen-for.go
/src/gen-if.go
/src/globals.go

=======================================
--- /src/_gogo_.sog Mon Jun 21 01:53:07 2010
+++ /src/_gogo_.sog Mon Jun 21 06:28:50 2010
@@ -5502,9 +5502,9 @@
JNE IF_libgogo_symbol_271_1_END
CMPQ -32(SP), $0
JE IF_libgogo_symbol_271_2_END
-IF_libgogo_symbol_271_1_END:
CMPQ -40(SP), $0
JE IF_libgogo_symbol_271_2_END
+IF_libgogo_symbol_271_1_END:
JMP IF_libgogo_symbol_271_END
IF_libgogo_symbol_271_2_END:
//--- Assignment start at libgogo/symbol.go:272:24
@@ -5696,9 +5696,9 @@
JNE IF_libgogo_symbol_293_1_END
CMPQ -32(SP), $0
JE IF_libgogo_symbol_293_2_END
-IF_libgogo_symbol_293_1_END:
CMPQ -40(SP), $0
JE IF_libgogo_symbol_293_2_END
+IF_libgogo_symbol_293_1_END:
JMP IF_libgogo_symbol_293_END
IF_libgogo_symbol_293_2_END:
//--- If start at libgogo/symbol.go:294:16
@@ -5706,15 +5706,14 @@
JE IF_libgogo_symbol_294_1_END
CMPQ 48(SP), $0
JNE IF_libgogo_symbol_294_2_END
-IF_libgogo_symbol_294_1_END:
MOVQ -8(SP), R8
ADDQ $32, R8
MOVQ (R8), R8
CMPQ R8, $0
- JE IF_libgogo_symbol_294_3_END
+ JE IF_libgogo_symbol_294_1_END
IF_libgogo_symbol_294_2_END:
JMP IF_libgogo_symbol_294_END
-IF_libgogo_symbol_294_3_END:
+IF_libgogo_symbol_294_1_END:
//--- Assignment start at libgogo/symbol.go:295:28
//--- Assignment LHS load start at libgogo/symbol.go:295:28
//--- Assignment LHS load end at libgogo/symbol.go:295:28
=======================================
--- /src/gen-cond.go Wed Jun 2 01:51:52 2010
+++ /src/gen-cond.go Mon Jun 21 06:28:50 2010
@@ -46,12 +46,62 @@
func GenerateSubLabel(ed *ExpressionDescriptor, i uint64, label string)
string {
var str string;
var tmpStr string;
+
+ var depth uint64;
+ var labelnr uint64;
+ var stacksize uint64;
+
libgogo.StringAppend(&str, ed.CurFile);
libgogo.StringAppend(&str, "_");
tmpStr = libgogo.IntToString(ed.CurLine);
libgogo.StringAppend(&str, tmpStr);
libgogo.StringAppend(&str, "_");

+ if i == 0 {
+ stacksize = libgogo.GetStackItemCount(&ed.FS);
+ if stacksize == 0 {
+ tmpStr = libgogo.IntToString(ed.IncCnt);
+ labelnr = ed.IncCnt;
+ depth = ed.ExpressionDepth;
+ ed.IncCnt = ed.IncCnt + 1;
+ libgogo.Push(&ed.FS, labelnr);
+ libgogo.Push(&ed.FDepthS, depth);
+ } else {
+ labelnr = libgogo.Peek(&ed.FS);
+ depth = libgogo.Peek(&ed.FDepthS);
+ if ed.ExpressionDepth > depth {
+ labelnr = ed.IncCnt;
+ depth = ed.ExpressionDepth;
+ libgogo.Push(&ed.FS, labelnr);
+ libgogo.Push(&ed.FDepthS, depth);
+ ed.IncCnt = ed.IncCnt +1;
+ }
+ }
+ tmpStr = libgogo.IntToString(labelnr);
+ } else {
+ stacksize = libgogo.GetStackItemCount(&ed.TS);
+ if stacksize == 0 {
+ tmpStr = libgogo.IntToString(ed.IncCnt);
+ labelnr = ed.IncCnt;
+ depth = ed.ExpressionDepth;
+ ed.IncCnt = ed.IncCnt + 1;
+ libgogo.Push(&ed.TS, labelnr);
+ libgogo.Push(&ed.TDepthS, depth);
+ } else {
+ labelnr = libgogo.Peek(&ed.TS);
+ depth = libgogo.Peek(&ed.TDepthS);
+ if ed.ExpressionDepth > depth {
+ labelnr = ed.IncCnt;
+ depth = ed.ExpressionDepth;
+ libgogo.Push(&ed.TS, labelnr);
+ libgogo.Push(&ed.TDepthS, depth);
+ ed.IncCnt = ed.IncCnt + 1;
+ }
+ }
+ tmpStr = libgogo.IntToString(labelnr);
+ }
+
+/*
if i == 0 {
if ed.F == 0 {
tmpStr = libgogo.IntToString(ed.IncCnt);
@@ -71,6 +121,7 @@
tmpStr = libgogo.IntToString(ed.T);
}
}
+*/
libgogo.StringAppend(&str, tmpStr);

libgogo.StringAppend(&str, "_");
@@ -85,6 +136,8 @@
func GetSubLabel(ed *ExpressionDescriptor, i uint64, label string) string {
var str string;
var tmpStr string;
+ var labelnr uint64;
+
libgogo.StringAppend(&str, ed.CurFile);
libgogo.StringAppend(&str, "_");
tmpStr = libgogo.IntToString(ed.CurLine);
@@ -92,9 +145,13 @@
libgogo.StringAppend(&str, "_");

if i == 0 {
- tmpStr = libgogo.IntToString(ed.F);
+ labelnr = libgogo.Peek(&ed.FS);
+ tmpStr = libgogo.IntToString(labelnr);
+ //tmpStr = libgogo.IntToString(ed.F);
} else {
- tmpStr = libgogo.IntToString(ed.T);
+ labelnr = libgogo.Peek(&ed.TS);
+ tmpStr = libgogo.IntToString(labelnr);
+ //tmpStr = libgogo.IntToString(ed.T);
}
libgogo.StringAppend(&str, tmpStr);

=======================================
--- /src/gen-expr.go Mon Jun 21 01:21:30 2010
+++ /src/gen-expr.go Mon Jun 21 06:28:50 2010
@@ -41,6 +41,11 @@
ed.F = 0;
ed.TDepth = 0;
ed.FDepth = 0;
+
+ libgogo.InitializeStack(&ed.TS);
+ libgogo.InitializeStack(&ed.FS);
+ libgogo.InitializeStack(&ed.TDepthS);
+ libgogo.InitializeStack(&ed.FDepthS);
}

//
@@ -96,18 +101,20 @@
func GenerateRelative(item *libgogo.Item, op uint64, ed
*ExpressionDescriptor) {
var labelString string;
var jmp string;
+ var depth uint64;
+ var stacksize uint64;

if Compile != 0 {
if item.Mode != libgogo.MODE_COND {
GenErrorWeak("Can use relative operators only with
conditionals.");
}
if op == TOKEN_REL_AND {
- labelString = GenerateSubLabel(ed,0,"END");
+ labelString = GenerateSubLabel(ed,0 /*negative*/,"END");
if ed.Not == 0 {
jmp = GetJump(item.C, 1);
} else {
if ed.TDepth > ed.ExpressionDepth {
- labelString = GenerateSubLabel(ed,1,"END");
+ labelString = GenerateSubLabel(ed,1
/*positive*/ ,"END");
jmp = GetJump(item.C, 0);
ed.Not = 0;
SwapExpressionBranches(ed);
@@ -116,12 +123,23 @@
}
}
PrintJump(jmp, labelString);
- if ed.T != 0 {
- if ed.TDepth >= ed.ExpressionDepth {
+
+ stacksize = libgogo.GetStackItemCount(&ed.TS);
+ if stacksize > 0 {
+ depth = libgogo.Peek(&ed.TDepthS);
+ if depth >= ed.ExpressionDepth {
PrintLabelWrapped(ed, 1 /*local*/, 1
/*positive*/, "END");
- ed.T = 0;
+ libgogo.Pop(&ed.TS);
+ libgogo.Pop(&ed.TDepthS);
}
}
+
+ //if ed.T != 0 {
+ // if ed.TDepth < ed.ExpressionDepth {
+ // PrintLabelWrapped(ed, 1 /*local*/, 1
/*positive*/, "END");
+ // ed.T = 0;
+ // }
+ //}
} else {
if op == TOKEN_REL_OR {
labelString = GenerateSubLabel(ed,1,"END");
@@ -138,12 +156,21 @@
}
}
PrintJump(jmp, labelString);
- if ed.F != 0 {
- if ed.FDepth >= ed.ExpressionDepth {
- PrintLabelWrapped(ed, 1 /*local*/, 0
/*negative*/, "END")
- ed.F = 0;
+ stacksize = libgogo.GetStackItemCount(&ed.FS);
+ if stacksize > 0 {
+ depth = libgogo.Peek(&ed.FDepthS);
+ if depth >= ed.ExpressionDepth {
+ PrintLabelWrapped(ed, 1 /*local*/, 0
/*negative*/, "END");
+ libgogo.Pop(&ed.FS);
+ libgogo.Pop(&ed.FDepthS);
}
}
+ //if ed.F != 0 {
+ // if ed.FDepth < ed.ExpressionDepth {
+ // PrintLabelWrapped(ed, 1 /*local*/, 0
/*negative*/, "END")
+ // ed.F = 0;
+ // }
+ //}
} else {
GenErrorWeak("Relative AND or OR expected.");
}
@@ -327,3 +354,4 @@
}
return ret;
}
+
=======================================
--- /src/gen-for.go Tue Jun 15 07:42:10 2010
+++ /src/gen-for.go Mon Jun 21 06:28:50 2010
@@ -13,6 +13,7 @@
func GenerateForStart(item *libgogo.Item, ed *ExpressionDescriptor) {
var labelString string;
var jmp string;
+ var stacksize uint64;

labelString = GenerateSubLabel(ed,1,"END");
if ed.Not == 0 {
@@ -26,16 +27,27 @@

// Important: Since last jump is a positive one, we have to start with
the
// negative path
- if ed.F != 0 {
+ //if ed.F != 0 {
+ // PrintLabelWrapped(ed, 1 /*local*/, 0 /*negative*/, "END");
+ //}
+ for stacksize = libgogo.GetStackItemCount(&ed.FS); stacksize > 0 ;
stacksize = libgogo.GetStackItemCount(&ed.FS) {
PrintLabelWrapped(ed, 1 /*local*/, 0 /*negative*/, "END");
+ libgogo.Pop(&ed.FS);
+ libgogo.Pop(&ed.FDepthS);
}
PrintJumpWrapped("JMP", ed, 0 /*global*/, 0 /*unused*/, "END");

// Positive branch starts after this label, thus insert last remaining
// positive label (if available) here
- if ed.T != 0 {
+ //if ed.T != 0 {
+ // PrintLabelWrapped(ed, 1 /*local*/, 1 /*positive*/, "END");
+ //}
+ for stacksize = libgogo.GetStackItemCount(&ed.TS); stacksize > 0 ;
stacksize = libgogo.GetStackItemCount(&ed.TS) {
PrintLabelWrapped(ed, 1 /*local*/, 1 /*positive*/, "END");
- }
+ libgogo.Pop(&ed.TS);
+ libgogo.Pop(&ed.TDepthS);
+ }
+

item.C = 0;
FreeRegisterIfRequired(item);
=======================================
--- /src/gen-if.go Tue Jun 15 07:42:10 2010
+++ /src/gen-if.go Mon Jun 21 06:28:50 2010
@@ -13,6 +13,7 @@
func GenerateIfStart(item *libgogo.Item, ed *ExpressionDescriptor) {
var labelString string;
var jmp string;
+ var stacksize uint64;

labelString = GenerateSubLabel(ed,1,"END");
if ed.Not == 0 {
@@ -26,15 +27,26 @@

// Important: Since last jump is a positive one, we have to start with
the
// negative path
- if ed.F != 0 {
+
+ //if ed.F != 0 {
+ // PrintLabelWrapped(ed, 1 /*local*/, 0 /*negative*/, "END");
+ //}
+ for stacksize = libgogo.GetStackItemCount(&ed.FS); stacksize > 0 ;
stacksize = libgogo.GetStackItemCount(&ed.FS) {
PrintLabelWrapped(ed, 1 /*local*/, 0 /*negative*/, "END");
+ libgogo.Pop(&ed.FS);
+ libgogo.Pop(&ed.FDepthS);
}
PrintJumpWrapped("JMP", ed, 0 /*global*/, 0 /*unused*/, "END");

// Positive branch starts after this label, thus insert last remaining
// positive label (if available) here
- if ed.T != 0 {
+ //if ed.T != 0 {
+ // PrintLabelWrapped(ed, 1 /*local*/, 1 /*positive*/, "END");
+ //}
+ for stacksize = libgogo.GetStackItemCount(&ed.TS); stacksize > 0 ;
stacksize = libgogo.GetStackItemCount(&ed.TS) {
PrintLabelWrapped(ed, 1 /*local*/, 1 /*positive*/, "END");
+ libgogo.Pop(&ed.TS);
+ libgogo.Pop(&ed.TDepthS);
}

item.C = 0;
=======================================
--- /src/globals.go Sun Jun 20 08:36:58 2010
+++ /src/globals.go Mon Jun 21 06:28:50 2010
@@ -8,6 +8,8 @@

package main

+import "./libgogo/_obj/libgogo"
+
//
// Struct holding the information about a file that is compiled
//
@@ -37,6 +39,11 @@
FDepth uint64; // Same as true depth.
Not uint64; // Flag indicating not branch

+ TS libgogo.Stack;
+ FS libgogo.Stack;
+ TDepthS libgogo.Stack;
+ FDepthS libgogo.Stack;
+
//
// Break continue information
//

==============================================================================
Revision: 5cfee10975
Author: Michael Lippautz <michael....@gmail.com>
Date: Mon Jun 21 06:29:35 2010
Log: Merge branch 'master' of gitorious.org:gogo/gogo
http://code.google.com/p/gogc/source/detail?r=5cfee10975

==============================================================================
Revision: 13f910bf22
Author: Michael Lippautz <michael....@gmail.com>
Date: Mon Jun 21 07:35:08 2010
Log: gogo: Add logic for NOT. Works for small examples ;p
http://code.google.com/p/gogc/source/detail?r=13f910bf22

Modified:
/src/gen-expr.go
/src/gen-for.go
/src/gen-if.go

=======================================
--- /src/gen-expr.go Mon Jun 21 06:28:50 2010
+++ /src/gen-expr.go Mon Jun 21 07:35:08 2010
@@ -11,10 +11,33 @@
import "./libgogo/_obj/libgogo"

func SwapExpressionBranches(ed *ExpressionDescriptor) {
- var tmp uint64;
- tmp = ed.T;
- ed.T = ed.F;
- ed.F = tmp;
+ var stacksize uint64;
+ var depth uint64;
+ var tvalue uint64 = 0;
+ var fvalue uint64 = 0;
+
+ stacksize = libgogo.GetStackItemCount(&ed.FS);
+ if stacksize > 0 {
+ depth = libgogo.Peek(&ed.FDepthS);
+ if depth >= ed.ExpressionDepth {
+ fvalue = libgogo.Pop(&ed.FS);
+ }
+ }
+
+ stacksize = libgogo.GetStackItemCount(&ed.TS);
+ if stacksize > 0 {
+ depth = libgogo.Peek(&ed.TDepthS);
+ if depth >= ed.ExpressionDepth {
+ tvalue = libgogo.Pop(&ed.TS);
+ }
+ }
+
+ if tvalue != 0 {
+ libgogo.Push(&ed.FS, tvalue);
+ }
+ if fvalue != 0 {
+ libgogo.Push(&ed.TS, fvalue);
+ }
}

//
@@ -113,13 +136,17 @@
if ed.Not == 0 {
jmp = GetJump(item.C, 1);
} else {
- if ed.TDepth > ed.ExpressionDepth {
- labelString = GenerateSubLabel(ed,1
/*positive*/ ,"END");
- jmp = GetJump(item.C, 0);
- ed.Not = 0;
- SwapExpressionBranches(ed);
+ ed.Not = 0;
+ stacksize = libgogo.GetStackItemCount(&ed.TS);
+ if stacksize > 0 {
+ depth = libgogo.Peek(&ed.TDepthS);
+ if depth >= ed.ExpressionDepth {
+ labelString = GenerateSubLabel(ed,1,"END");
+ jmp = GetJump(item.C, 0);
+ SwapExpressionBranches(ed);
+ }
} else {
- jmp = GetJump(item.C,1);
+ jmp = GetJump(item.C,0);
}
}
PrintJump(jmp, labelString);
@@ -133,26 +160,24 @@
libgogo.Pop(&ed.TDepthS);
}
}
-
- //if ed.T != 0 {
- // if ed.TDepth < ed.ExpressionDepth {
- // PrintLabelWrapped(ed, 1 /*local*/, 1
/*positive*/, "END");
- // ed.T = 0;
- // }
- //}
} else {
if op == TOKEN_REL_OR {
labelString = GenerateSubLabel(ed,1,"END");
if ed.Not == 0 {
jmp = GetJump(item.C, 0);
} else {
- if ed.FDepth > ed.ExpressionDepth {
- labelString = GenerateSubLabel(ed,0,"END");
- jmp = GetJump(item.C, 1);
- ed.Not = 0;
- SwapExpressionBranches(ed);
+ ed.Not = 0;
+ stacksize = libgogo.GetStackItemCount(&ed.FS);
+ if stacksize > 0 {
+ depth = libgogo.Peek(&ed.FDepthS);
+ if depth >= ed.ExpressionDepth {
+
+ labelString = GenerateSubLabel(ed,0,"END");
+ jmp = GetJump(item.C, 1);
+ SwapExpressionBranches(ed);
+ }
} else {
- jmp = GetJump(item.C,0);
+ jmp = GetJump(item.C,1);
}
}
PrintJump(jmp, labelString);
@@ -165,12 +190,6 @@
libgogo.Pop(&ed.FDepthS);
}
}
- //if ed.F != 0 {
- // if ed.FDepth < ed.ExpressionDepth {
- // PrintLabelWrapped(ed, 1 /*local*/, 0
/*negative*/, "END")
- // ed.F = 0;
- // }
- //}
} else {
GenErrorWeak("Relative AND or OR expected.");
}
=======================================
--- /src/gen-for.go Mon Jun 21 06:28:50 2010
+++ /src/gen-for.go Mon Jun 21 07:35:08 2010
@@ -19,17 +19,13 @@
if ed.Not == 0 {
jmp = GetJump(item.C, 0);
} else {
- labelString = GenerateSubLabel(ed,0,"END");
+ labelString = GenerateSubLabel(ed,1,"END");
jmp = GetJump(item.C, 1);
- SwapExpressionBranches(ed);
}
PrintJump(jmp, labelString);

// Important: Since last jump is a positive one, we have to start with
the
// negative path
- //if ed.F != 0 {
- // PrintLabelWrapped(ed, 1 /*local*/, 0 /*negative*/, "END");
- //}
for stacksize = libgogo.GetStackItemCount(&ed.FS); stacksize > 0 ;
stacksize = libgogo.GetStackItemCount(&ed.FS) {
PrintLabelWrapped(ed, 1 /*local*/, 0 /*negative*/, "END");
libgogo.Pop(&ed.FS);
@@ -39,9 +35,6 @@

// Positive branch starts after this label, thus insert last remaining
// positive label (if available) here
- //if ed.T != 0 {
- // PrintLabelWrapped(ed, 1 /*local*/, 1 /*positive*/, "END");
- //}
for stacksize = libgogo.GetStackItemCount(&ed.TS); stacksize > 0 ;
stacksize = libgogo.GetStackItemCount(&ed.TS) {
PrintLabelWrapped(ed, 1 /*local*/, 1 /*positive*/, "END");
libgogo.Pop(&ed.TS);
=======================================
--- /src/gen-if.go Mon Jun 21 06:28:50 2010
+++ /src/gen-if.go Mon Jun 21 07:35:08 2010
@@ -16,21 +16,17 @@
var stacksize uint64;

labelString = GenerateSubLabel(ed,1,"END");
+
if ed.Not == 0 {
jmp = GetJump(item.C, 0);
} else {
- labelString = GenerateSubLabel(ed,0,"END");
+ labelString = GenerateSubLabel(ed,1,"END");
jmp = GetJump(item.C, 1);
- SwapExpressionBranches(ed);
}
PrintJump(jmp, labelString);

// Important: Since last jump is a positive one, we have to start with
the
// negative path
-
- //if ed.F != 0 {
- // PrintLabelWrapped(ed, 1 /*local*/, 0 /*negative*/, "END");
- //}
for stacksize = libgogo.GetStackItemCount(&ed.FS); stacksize > 0 ;
stacksize = libgogo.GetStackItemCount(&ed.FS) {
PrintLabelWrapped(ed, 1 /*local*/, 0 /*negative*/, "END");
libgogo.Pop(&ed.FS);
@@ -40,9 +36,6 @@

// Positive branch starts after this label, thus insert last remaining
// positive label (if available) here
- //if ed.T != 0 {
- // PrintLabelWrapped(ed, 1 /*local*/, 1 /*positive*/, "END");
- //}
for stacksize = libgogo.GetStackItemCount(&ed.TS); stacksize > 0 ;
stacksize = libgogo.GetStackItemCount(&ed.TS) {
PrintLabelWrapped(ed, 1 /*local*/, 1 /*positive*/, "END");
libgogo.Pop(&ed.TS);

Reply all
Reply to author
Forward
0 new messages