Skip to content

Commit 8762242

Browse files
committed
Re-format standdard library
Binary class files and source files are separate now, much more cleaner! Objects now have hash codes! New Throwable and StackTraceElement classes! They will soon be used for exceptions
1 parent 02491a0 commit 8762242

33 files changed

+169
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
jexer
2+
gnucp

lib/nativeDefault.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ function lukyt_OS_clock()
4646
return types.new("double", os.clock())
4747
end
4848

49+
function java_lang_Object_hashCode(class, method, thread, args)
50+
local this = args[1]
51+
return types.new("int", this.hashCode)
52+
end
53+
4954
function java_lang_System_getProperty(class, method, thread, args)
5055
local key = args[1]
5156
if key.type == "null" then

lib/thread.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,8 @@ function lib:instantiateClass(class, parameters, doInit, initDescriptor)
696696
local object = types.new("reference", {
697697
type = "object",
698698
object = {},
699-
class = classReference
699+
class = classReference,
700+
hashCode = math.floor(math.random() * 0x7FFFFFFF)
700701
})
701702
for k, v in pairs(class.fields) do
702703
object[2].object[v.name] = types.nullReference()

lukyt.lua

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ local file = nil
1111
local args = table.pack(...)
1212
local printHelp = true
1313
local cp = "./"
14-
local bcp = "./std/" -- bootstrap class path
14+
local bcp = "./std/bin/" -- bootstrap class path
1515

1616
local osName = "Unknown"
1717
if package.cpath then
@@ -38,7 +38,7 @@ systemProperties = {
3838
["java.vm.specification.name"] = "Playground",
3939
["java.vm.version"] = "0.1",
4040
["java.vm.vendor"] = "Lukyt",
41-
["java.vm.name"] = "Acapella",
41+
["java.vm.name"] = "Lukyt",
4242
["java.class.version"] = "46.0",
4343
["java.class.path"] = "", -- TODO
4444
["java.library.path"] = "/;./",
@@ -72,6 +72,11 @@ for k, v in ipairs(args) do
7272
if cp:sub(#cp,#cp) ~= "/" then
7373
cp = cp .. "/"
7474
end
75+
elseif v:sub(1,5) == "--cp=" then
76+
cp = v:sub(6)
77+
if cp:sub(#cp,#cp) ~= "/" then
78+
cp = cp .. "/"
79+
end
7580
elseif v:sub(1,22) == "--bootstrap-classpath=" then
7681
bcp = v:sub(23)
7782
if bcp:sub(#bcp,#bcp) ~= "/" then
@@ -86,9 +91,11 @@ for k, v in ipairs(args) do
8691
value = "true"
8792
end
8893
systemProperties[name] = value
89-
else
94+
elseif not file then
9095
file = v .. ".class"
9196
printHelp = false
97+
else
98+
error("unrecognized argument: " .. v)
9299
end
93100
end
94101

@@ -100,8 +107,9 @@ if printHelp then
100107
print(" Available: freqs, none")
101108
print(" --classpath=path: Set the classpath to search non-bootstrap classes")
102109
print(" Default: ./")
110+
print(" --cp=path: Short for --classpath=path")
103111
print(" --bootstrap-classpath=path: Set the classpath to search bootstrap classes")
104-
print(" Default: ./std/")
112+
print(" Default: ./std/bin/")
105113
print(" -Dname=value: Define Java system property")
106114
print(" ex: -Dos.name=JEternal")
107115
return
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)