Fix varargs handling
This commit is contained in:
@@ -16,7 +16,7 @@ public class LTable extends LValue {
|
|||||||
/** Metatable tag for intercepting table sets */
|
/** Metatable tag for intercepting table sets */
|
||||||
private static final LString TM_NEWINDEX = new LString("__newindex");
|
private static final LString TM_NEWINDEX = new LString("__newindex");
|
||||||
|
|
||||||
private Hashtable m_hash = new Hashtable();
|
public Hashtable m_hash = new Hashtable();
|
||||||
|
|
||||||
private Vector m_vector; // if non-null then size() > 0
|
private Vector m_vector; // if non-null then size() > 0
|
||||||
|
|
||||||
@@ -53,16 +53,16 @@ public class LTable extends LValue {
|
|||||||
if (m_vector == null) {
|
if (m_vector == null) {
|
||||||
if (iKey == 0) {
|
if (iKey == 0) {
|
||||||
m_vector = new Vector();
|
m_vector = new Vector();
|
||||||
m_vector.add(val);
|
m_vector.addElement(val);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (iKey >= 0) {
|
} else if (iKey >= 0) {
|
||||||
int size = m_vector.size();
|
int size = m_vector.size();
|
||||||
if (iKey < size) {
|
if (iKey < size) {
|
||||||
m_vector.set(iKey, val);
|
m_vector.setElementAt(val, iKey);
|
||||||
return;
|
return;
|
||||||
} else if (iKey == size) {
|
} else if (iKey == size) {
|
||||||
m_vector.add(iKey, val);
|
m_vector.addElement(val);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -137,7 +137,7 @@ public class LTable extends LValue {
|
|||||||
// where size = m_vector.size()
|
// where size = m_vector.size()
|
||||||
//
|
//
|
||||||
if ((iKey >= 0) && (iKey < m_vector.size())) {
|
if ((iKey >= 0) && (iKey < m_vector.size())) {
|
||||||
return (LValue) m_vector.get(iKey);
|
return (LValue) m_vector.elementAt(iKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -235,7 +235,7 @@ public class LTable extends LValue {
|
|||||||
vm.setResult();
|
vm.setResult();
|
||||||
if ((i >= 0) && (i < t.m_vector.size())) {
|
if ((i >= 0) && (i < t.m_vector.size())) {
|
||||||
vm.push(new LInteger(i+1));
|
vm.push(new LInteger(i+1));
|
||||||
vm.push((LValue) t.m_vector.get(i));
|
vm.push((LValue) t.m_vector.elementAt(i));
|
||||||
++i;
|
++i;
|
||||||
} else if ( e.hasMoreElements() ) {
|
} else if ( e.hasMoreElements() ) {
|
||||||
LValue key = (LValue) e.nextElement();
|
LValue key = (LValue) e.nextElement();
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
LUA_HOME=/cygdrive/c/programs/lua5.1
|
TESTS=`echo *.lua`
|
||||||
TESTS="test1 test2 test3 test4 test5 swingapp"
|
TESTS="test3.lua"
|
||||||
TESTS="test2"
|
|
||||||
for x in $TESTS
|
for x in $TESTS
|
||||||
do
|
do
|
||||||
echo compiling $x
|
echo compiling $x
|
||||||
${LUA_HOME}/luac5.1.exe -l -o ${x}.luac ${x}.lua
|
luac -l -o ${x}c ${x}
|
||||||
${LUA_HOME}/lua5.1.exe ${x}.luac
|
lua ${x}c
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ print( func(11, 12, 13) )
|
|||||||
print( func(23, 22, 21) )
|
print( func(23, 22, 21) )
|
||||||
print( func(func(32,33,34), func(45,46,47), func(58,59,50)) )
|
print( func(func(32,33,34), func(45,46,47), func(58,59,50)) )
|
||||||
|
|
||||||
--[[
|
|
||||||
function p(a,...)
|
function p(a,...)
|
||||||
print("a",a)
|
print("a",a)
|
||||||
print("...",...)
|
print("...",...)
|
||||||
@@ -50,4 +49,3 @@ p()
|
|||||||
p("q")
|
p("q")
|
||||||
p("q","r")
|
p("q","r")
|
||||||
p("q","r","s")
|
p("q","r","s")
|
||||||
--]]
|
|
||||||
Binary file not shown.
Reference in New Issue
Block a user