Commit Graph

1120 Commits

Author SHA1 Message Date
Ian Farmer
534e69fcfb Add pattern matcher implementation ported from C version of Lua. Still
work to do:
(1) Replace use of recursion with while/continue
(2) Remove as many array bounds checks as possible
2007-09-18 04:18:39 +00:00
Ian Farmer
108fabc58f Add missing return statement in autoload test case. Still doesn't work. 2007-09-18 04:16:46 +00:00
James Roseborough
952a2f9f16 Add skeleton for string library calls. 2007-09-18 01:00:36 +00:00
James Roseborough
5efda81b17 Add loadstring and other standard library commands (untested) 2007-09-15 00:51:30 +00:00
Ian Farmer
6d0e9bb566 Add some helper methods:
(1) getKeys() in LTable is now public. It provides a convenient interface
    to access the table's elements from Java instead of Lua.
(2) LString.toInputStream produces an instance of InputStream from which
    the string's bytes can be read.
2007-09-12 05:22:30 +00:00
Ian Farmer
31e2d95076 Fix broken LTable test case. 2007-09-10 06:41:25 +00:00
Ian Farmer
aeafca11b6 Change LString to use an array of bytes instead of wrapping Java's String.
This brings our implementation more in line with regular C Lua.
2007-09-10 06:27:54 +00:00
Ian Farmer
aa44eedf4b Allow metatable operations on values of all types, and use the metatable
on strings as the string package, so that string functions can be called
with self (:) syntax. Autoload test case now inexplicably fails more,
but it was already broken.
2007-09-08 20:54:40 +00:00
Ian Farmer
e30646bcf8 Add string.rep and string.sub to LuaCompat add-on. With these implemented,
we get to line 34 of the strings.lua standard test case.
2007-09-06 03:22:00 +00:00
Ian Farmer
35131f9f66 Fix "factorial" function in test case that was not actually factorial function. 2007-09-05 03:02:57 +00:00
Ian Farmer
75fb975410 Fix a few VM issues which were causing subtle failures in the test cases.
Includes a new VM method, newCall, which must be called before pushing
a call onto the stack to make sure that base is set correctly.
A couple of weird issues remain with autoload.lua.
2007-09-04 01:52:33 +00:00
Ian Farmer
0f81c4deaf Fix typo and add TODO comment. 2007-09-03 06:00:37 +00:00
Ian Farmer
49bcc0d2f8 Fix a bug where "base" was not set correctly for metatable operations. 2007-09-03 05:53:55 +00:00
Ian Farmer
b8571b93f9 New implementation for Lua tables. Does not use Vector or Hashtable, instead
uses plain Java arrays directly to keep heap allocation to a minimum.
Includes some unit tests that seem to indicate the basic operations are
correct. However, the following things are not implemented:

* Shrinking the capacity when elements are removed
* Optimal storage of each element in array vs. hash when entries are
  added out of order. A junit test case is there for this.
2007-09-03 00:38:38 +00:00
James Roseborough
79d5642bfd Fix breakpoint handling 2007-08-11 05:29:56 +00:00
James Roseborough
add892968d Add DebugStackState to be used as a debugging VM in and IDE. 2007-08-11 04:53:35 +00:00
Shu Lei
a80351e1ef added the skeleton code for luaJ debugging support 2007-08-10 06:31:21 +00:00
James Roseborough
64d02d3559 Fix gettable result handling in LInstances 2007-08-03 15:32:40 +00:00
James Roseborough
b8376fe0ef Fix tail call argument handling. 2007-08-03 05:42:50 +00:00
James Roseborough
5fb097d107 Fix varargs handling 2007-08-02 03:00:46 +00:00
James Roseborough
80677e9a16 Let Nil be converted to int, but other values cannot. 2007-08-01 06:16:28 +00:00
James Roseborough
01c5595fd6 Let luaAsInt() return sensible values for non-numeric data. 2007-08-01 06:11:43 +00:00
James Roseborough
32dcbaca3a Make modulo arithmetic conform to lua rules for negative values. 2007-08-01 04:57:12 +00:00
Ian Farmer
737c5e2855 Various changes:
(1) New lua compatibility bindings, including select() and math functions
(2) fix some VM bugs
(3) fix some table bugs, and attempt to restore metatable functionality.
2007-08-01 04:15:27 +00:00
James Roseborough
68b3e68169 Remove unused variables. 2007-07-31 05:47:35 +00:00
James Roseborough
7cd3195bcd Add guard to prevent null values from being put on stack 2007-07-30 04:53:58 +00:00
James Roseborough
fbeded0388 Make printCode public, remove unused code from Lua.java 2007-07-29 17:39:15 +00:00
Christopher Colby
b9fdb731fe optimization for tables that include sequential integral indices starting with 0.
commented out: a more sophisticated (but space-consuming) optimization
that accounts for arbitrary starting index, stride, and direction (increasing/decreasing).

commented out some table metatable stuff that was wrong.  metatables
need to be implemented properly.
2007-07-24 06:22:07 +00:00
James Roseborough
8bf4c82a12 Rework the main API"s that implement the calling convention. Provide utility methods to get arguments that were supplied, and provide return values. Add a VM interface to clarify the relationship between the VM, things that call the VM, and things that are called by the VM. Make the code more closely aligned with the C++ version. 2007-07-24 05:06:10 +00:00
James Roseborough
56f33b373d Move LUA_MULTRET def to Lua.java 2007-07-22 16:59:50 +00:00
Ian Farmer
ee5007e718 Add implicit LString to number coercions. 2007-07-22 06:20:14 +00:00
Ian Farmer
daf71ee672 New LuaCompat add-on provides some standard lua functions that allow the
test cases to make more progress: assert, collectgarbage, loadfile,
tonumber, rawget, and setfenv. Also added zip file of standard tests to
Eclipse classpath, for convenience.
2007-07-22 05:47:14 +00:00
Ian Farmer
e1d6ddf99c New autoload and math test cases. Currently autoload does not work because
the GETGLOBAL instruction does not handle the case where a metatable method
is invoked.
2007-07-21 04:44:22 +00:00
Ian Farmer
b4ac032fd7 Fix the NOT instruction. Includes test case. 2007-07-21 04:08:28 +00:00
Ian Farmer
c0f054549b Change the pom.xml and remove some use of Java 1.5 features to reduce the
number of errors produced by "mvn package".
2007-07-19 04:23:42 +00:00
Ian Farmer
2a64db32b5 Add last Lua type: userdata. Changed LInstance to inherit from LUserData,
and changed instanceof/casts to LInstance to use LUserData instead. This
should enable various add-ons to be compatible without knowing much, or
anything, about each other.
2007-07-17 04:04:18 +00:00
Ian Farmer
8c3fe262f9 Adding test suite with tests from the set of standard Lua test cases. These
test cases were downloaded from:
  http://www.inf.puc-rio.br/~roberto/lua/lua5.1-tests.tar.gz
2007-07-17 03:20:53 +00:00
Ian Farmer
635f127cd0 Add new built-in function type() that returns the name of the type of
the given value as a string. Includes test case.
2007-07-16 02:37:08 +00:00
Ian Farmer
c65dec54fb Fix a bug in how comparison instructions are handled: the 'a' intruction field
was ignored.  Includes new test case.
2007-07-15 20:33:20 +00:00
James Roseborough
ba3da1ca2c Fine-tune protection to enable compiler porting. 2007-07-13 14:49:58 +00:00
Ian Farmer
2a28925f74 Fix a bug in how OP_SETLIST is handled. Includes new test case. 2007-07-12 04:06:41 +00:00
Ian Farmer
f7d6a49acb Add a new test case for upvalues, and enhance upvalue handling so that
they pass.
2007-07-09 04:10:25 +00:00
Ian Farmer
45964d7e22 Add simple test for correct upvalue handling. 2007-07-09 01:43:34 +00:00
Ian Farmer
62022d5881 While loading chunks, check if double values can be represented as integers,
and load them as LIntegers instead of LDoubles if so. Also change test2 so that
it does not fail because of the rounding problem. With these changes, 4 out of
7 test cases in LuaJTest now pass.
2007-07-09 01:31:31 +00:00
Ian Farmer
241edfbf37 Added a JUnit test case. Unfortunately, it will almost certainly not work on
Windows in its present form, and only one of the test cases passes.
In addition two changes to print() were made: output can be redirected to
an arbitrary OutputStream and tabs are no longer printed at the end of
each line.
2007-07-04 04:25:06 +00:00
Ian Farmer
ba26aed248 Add maven's "target" directory to .cvsignore file. 2007-07-04 03:24:44 +00:00
Ian Farmer
d987d89092 Fix two bugs in LuaJava compatibility addon:
(1) LDouble to Double/double coercions were missing
(2) LuaJava.LMethod.luaStackCall adjusted the top of stack in a way that
produces the wrong results when the call occurs as the argument to another
function (such as print)

Also added two lines to the bottom of test7.lua to test luajava.bindClass.
2007-07-04 03:23:09 +00:00
Ian Farmer
a3ffb9a207 Add .cvsignore listing "bin" directory, which is Eclipse's build outputs
directory.
2007-07-04 02:46:18 +00:00
Ian Farmer
bb8844f6b8 Fix Eclipse project settings: Java 1.5 features are used, so the java
language version must be set to 5.
2007-07-04 02:44:07 +00:00
James Roseborough
7aab64e6d3 Allow null values in arguments to pushCall, expose the underlying storage in LTable to simplify add-ons until the lTable is finished. 2007-07-02 14:39:17 +00:00