Fix for loop that uses iterator

This commit is contained in:
James Roseborough
2007-06-16 02:47:47 +00:00
parent 4fb619fe87
commit a9c72414d1
4 changed files with 10 additions and 8 deletions

View File

@@ -32,7 +32,6 @@ final class Builtin extends LFunction {
// perform a lua call // perform a lua call
public void luaStackCall(StackState state, int base, int top) { public void luaStackCall(StackState state, int base, int top) {
int returnValues = 0;
switch ( id ) { switch ( id ) {
case PRINT: case PRINT:
for ( int i=base+1; i<top; i++ ) { for ( int i=base+1; i<top; i++ ) {
@@ -40,17 +39,16 @@ final class Builtin extends LFunction {
System.out.print( "\t" ); System.out.print( "\t" );
} }
System.out.println(); System.out.println();
break; state.adjustTop(base);
return;
case PAIRS: case PAIRS:
state.adjustTop(base+2);
LValue value = state.stack[base+1].luaPairs(); LValue value = state.stack[base+1].luaPairs();
state.top = base+1;
state.stack[base] = value; state.stack[base] = value;
returnValues = 1; return;
break;
default: default:
luaUnsupportedOperation(); luaUnsupportedOperation();
} }
state.adjustTop(base+returnValues);
} }
} }

View File

@@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
LUA_HOME=/cygdrive/c/programs/lua5.1 LUA_HOME=/cygdrive/c/programs/lua5.1
TESTS="test1 test2 test3 test4 test5" TESTS="test1 test2 test3 test4 test5"
TESTS="test2" TESTS="test5"
for x in $TESTS for x in $TESTS
do do
echo compiling $x echo compiling $x

View File

@@ -1,3 +1,4 @@
i = 777 i = 777
while i<780 do while i<780 do
print(i) print(i)
@@ -13,4 +14,7 @@ end
for count = 336,330,-2 do print(count) end -- numerical iteration for count = 336,330,-2 do print(count) end -- numerical iteration
for key,value in pairs({a=10, 3.14159265358, c="banana" }) do print(key, value) end for key,value in pairs({a=10, 3.14159265358, c="banana" })
do
print(key, value)
end

Binary file not shown.