Skip to content

Commit

Permalink
small fix to switch
Browse files Browse the repository at this point in the history
--HG--
branch : com.mozilla.es4.smlnj
extra : convert_revision : f605dd37c16a259220c45f3279c48fca55cd402f
  • Loading branch information
jeffdyer committed Sep 2, 2007
1 parent ba846ae commit 8fcf66f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
2 changes: 1 addition & 1 deletion comp-esc1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#./esc.sh tests/self/ast.es
#./esc.sh tests/self/lex-char.es
#./esc.sh tests/self/lex-token.es
./esc.sh tests/self/lex-scan.es
#./esc.sh tests/self/lex-scan.es
#./esc.sh tests/self/parse-util.es
#./esc.sh tests/self/parse-ident.es
#./esc.sh tests/self/parse-lhsexpr.es
Expand Down
34 changes: 18 additions & 16 deletions tests/self/cogen-stmt.es
Original file line number Diff line number Diff line change
Expand Up @@ -217,43 +217,45 @@
var hasBreak = false;
for ( let i=0 ; i < cases.length ; i++ ) {
let c = cases[i];
if (c.expr == null)

if (c.expr == null) {
assert (Ldefault===null);
Ldefault = asm.I_label(); // label default pos
}

if (Lnext !== null) {
asm.I_label(Lnext); // label next pos
print ("case label");
asm.I_label(Lnext); // label next pos
Lnext = null;
}

if (c.expr !== null) {
cgExpr(nctx, c.expr); // check for match
if (c.expr != null) {
cgExpr(nctx, c.expr); // check for match
asm.I_getlocal(t);
asm.I_strictequals();
Lnext = asm.I_iffalse(); // if no match jump to next label
if (Lfall !== null) { // label fall through pos
asm.I_label(Lfall);
print ("fall through label");
Lfall = null;
}
Lnext = asm.I_iffalse(); // if no match jump to next label
}

if (Lfall !== null) { // label fall through pos
asm.I_label(Lfall);
Lfall = null;
}

let stmts = c.stmts;
for ( let j=0 ; j < stmts.length ; j++ ) {
if (stmts[j] is BreakStmt) {
if (stmts[j] is BreakStmt) { // FIXME might be nested in if
var hasBreak=true;
}

cgStmt(nctx, stmts[j] );
}
if (!hasBreak) { // if no break then jump past
Lfall = asm.I_jump (); // next test

if (!hasBreak) { // if no break then jump past
Lfall = asm.I_jump (); // next test
}
}
if (Lnext !== null)
asm.I_label(Lnext);
if (Lfall !== null)
asm.I_jump(Lfall);
asm.I_label(Lfall);
if (Ldefault !== null)
asm.I_jump(Ldefault);
asm.I_label(Lbreak);
Expand Down
3 changes: 0 additions & 3 deletions tests/self/parse-ident.es
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,8 @@ use namespace Release;

var str = ""; // fixme: evaluator isn't happy if this is inside of the switch



switch (hd (ts)) {
case Token::Identifier:
print("ident found");
case Token::Call:
case Token::Cast:
case Token::Const:
Expand Down
5 changes: 4 additions & 1 deletion tests/self/t.es
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ print(a.length)
print(a)
*/

/*
function f (x) {
switch (x) {
case 10:
Expand All @@ -15,7 +16,6 @@ print(20);
break;
case 30:
print(30);
break;
default:
print('default');
break;
Expand All @@ -25,3 +25,6 @@ f(10) // 10 20
f(20) // 20
f(30) // 30
f(40) // default
*/

print ("hello world")

0 comments on commit 8fcf66f

Please sign in to comment.