2014-04-24 14:43:20 +02:00
|
|
|
require 'java'
|
|
|
|
java_import java.lang.System
|
|
|
|
java_import java.io.PrintStream
|
|
|
|
|
2014-04-24 14:53:48 +02:00
|
|
|
module Vm
|
2014-04-24 14:43:20 +02:00
|
|
|
module Builtins
|
|
|
|
def add_builtins
|
|
|
|
public_static_method 'print', [], int, int do
|
|
|
|
iload 0
|
|
|
|
|
|
|
|
getstatic System, :out, PrintStream
|
|
|
|
swap
|
|
|
|
invokevirtual PrintStream, :print, [void, int]
|
|
|
|
|
|
|
|
ldc 0
|
|
|
|
ireturn
|
|
|
|
end
|
|
|
|
|
|
|
|
public_static_method 'minus', [], int, int, int do
|
|
|
|
iload 0
|
|
|
|
iload 1
|
|
|
|
isub
|
|
|
|
ireturn
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|