bitescript 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +7 -13
- data/Rakefile +5 -11
- data/bitescript.gemspec +21 -0
- data/examples/fib.bs +1 -1
- data/examples/hello_world.bs +5 -0
- data/examples/hello_world_macro.bs +23 -0
- data/examples/indy.bs +1 -0
- data/examples/mixed_bag.rb +5 -5
- data/examples/simple_loop.rb +1 -1
- data/examples/using_ruby.bs +7 -0
- data/lib/bitescript/asm.rb +4 -0
- data/lib/bitescript/builder.rb +48 -36
- data/lib/bitescript.rb +0 -2
- data/nbproject/private/config.properties +0 -0
- data/nbproject/private/private.properties +3 -0
- data/nbproject/private/private.xml +4 -0
- data/nbproject/project.properties +9 -0
- data/nbproject/project.xml +16 -0
- data/test/test_builder.rb +22 -24
- data/test/test_bytecode.rb +4 -3
- data/test/test_java_class.rb +4 -4
- metadata +22 -21
- data/Manifest.txt +0 -20
data/History.txt
CHANGED
@@ -1,18 +1,12 @@
|
|
1
|
+
=== 0.0.5 / 2010-02-04
|
2
|
+
|
3
|
+
* Get tests and examples all working nicely again
|
4
|
+
* Clean up some -w noise from mangled ASM path
|
5
|
+
* Annotations, exceptions, many other Java features added
|
6
|
+
|
1
7
|
=== 0.0.4 / 2009-10-27
|
2
8
|
|
3
|
-
*
|
4
|
-
* Add support for shadowing local variables
|
5
|
-
* Interface and "throws" support.
|
6
|
-
* Add an accessor for ClassBuilder.interfaces
|
7
|
-
* ignore nil line numbers
|
8
|
-
* Fix typo in line numbering
|
9
|
-
* Improve debug info support
|
10
|
-
* Fix class.stop to generate a valid constructor when one is not defined.
|
11
|
-
* Fix void comparison bugs
|
12
|
-
* Fix string concat
|
13
|
-
* Allow custom classes to represent primitive types
|
14
|
-
* Add support for big locals (long/double)
|
15
|
-
* Add a static? accessor to MethodBuilder.
|
9
|
+
* Numeric fixes and feature additions to support Duby and other consumers
|
16
10
|
|
17
11
|
=== 0.0.3 / 2009-06-14
|
18
12
|
|
data/Rakefile
CHANGED
@@ -1,17 +1,11 @@
|
|
1
1
|
require 'rake'
|
2
2
|
require 'rake/testtask'
|
3
3
|
require 'rake/rdoctask'
|
4
|
-
require 'hoe'
|
5
4
|
$: << './lib'
|
6
|
-
require 'bitescript.rb'
|
7
|
-
|
8
|
-
Hoe.new('bitescript', BiteScript::VERSION) do |p|
|
9
|
-
p.rubyforge_name = 'jruby-extras'
|
10
|
-
p.url = "http://kenai.com/projects/jvmscript"
|
11
|
-
p.author = "charles.nutter@sun.com"
|
12
|
-
p.summary = "BiteScript is a Ruby DSL for generating Java bytecode."
|
13
|
-
p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
|
14
|
-
p.developer('Charles Oliver Nutter', 'charles.nutter@sun.com')
|
15
|
-
end
|
16
5
|
|
17
6
|
task :default => :test
|
7
|
+
|
8
|
+
Rake::TestTask.new :test do |t|
|
9
|
+
t.libs << "lib"
|
10
|
+
t.test_files = FileList["test/**/*.rb"]
|
11
|
+
end
|
data/bitescript.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{bitescript}
|
5
|
+
s.version = "0.0.5"
|
6
|
+
s.authors = ["Charles Oliver Nutter", "Ryan Brown"]
|
7
|
+
s.date = Time.now.strftime('YYYY-MM-DD')
|
8
|
+
s.description = %q{BiteScript is a Ruby DSL for generating Java bytecode and classes.}
|
9
|
+
s.email = ["headius@headius.com", "ribrdb@gmail.com"]
|
10
|
+
s.executables = ["bite", "bitec"]
|
11
|
+
s.extra_rdoc_files = Dir['*.txt']
|
12
|
+
s.files = Dir['{bin,examples,lib,nbproject,test}/**/*'] + Dir['{*.txt,*.gemspec,Rakefile}']
|
13
|
+
puts s.files
|
14
|
+
s.homepage = %q{http://kenai.com/projects/jvmscript}
|
15
|
+
s.rdoc_options = ["--main", "README.txt"]
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.rubyforge_project = %q{jruby-extras}
|
18
|
+
s.rubygems_version = %q{1.3.5}
|
19
|
+
s.summary = %q{BiteScript is a Ruby DSL for generating Java bytecode.}
|
20
|
+
s.test_files = Dir["test/test*.rb"]
|
21
|
+
end
|
data/examples/fib.bs
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
import java.lang.System
|
2
|
+
import java.io.PrintStream
|
3
|
+
|
4
|
+
macro :aprintln do
|
5
|
+
getstatic System, :out, PrintStream
|
6
|
+
swap
|
7
|
+
invokevirtual PrintStream, println, [Object]
|
8
|
+
end
|
9
|
+
|
10
|
+
macro :aprint do
|
11
|
+
getstatic System, :out, PrintStream
|
12
|
+
swap
|
13
|
+
invokevirtual PrintStream, print, [Object]
|
14
|
+
end
|
15
|
+
|
16
|
+
main do
|
17
|
+
ldc "Hello, "
|
18
|
+
aprint
|
19
|
+
aload 0
|
20
|
+
aaload 0
|
21
|
+
aprintln
|
22
|
+
returnvoid
|
23
|
+
end
|
data/examples/indy.bs
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
main { aload 0; invokedynamic object, 'foo', [object]; returnvoid }
|
data/examples/mixed_bag.rb
CHANGED
@@ -10,7 +10,7 @@ builder = BiteScript::FileBuilder.build("somefile.source") do
|
|
10
10
|
public_class "MyClass", object do
|
11
11
|
public_field "list", ArrayList
|
12
12
|
|
13
|
-
public_constructor string, ArrayList do
|
13
|
+
public_constructor [], string, ArrayList do
|
14
14
|
aload 0
|
15
15
|
invokespecial object, "<init>", [void]
|
16
16
|
aload 0
|
@@ -23,7 +23,7 @@ builder = BiteScript::FileBuilder.build("somefile.source") do
|
|
23
23
|
returnvoid
|
24
24
|
end
|
25
25
|
|
26
|
-
public_static_method "foo", this, string do
|
26
|
+
public_static_method "foo", [], this, string do
|
27
27
|
new this
|
28
28
|
dup
|
29
29
|
aload 0
|
@@ -34,7 +34,7 @@ builder = BiteScript::FileBuilder.build("somefile.source") do
|
|
34
34
|
areturn
|
35
35
|
end
|
36
36
|
|
37
|
-
public_method "bar", ArrayList, string, ArrayList do
|
37
|
+
public_method "bar", [], ArrayList, string, ArrayList do
|
38
38
|
aload 1
|
39
39
|
invokevirtual(string, "toLowerCase", string)
|
40
40
|
aload 2
|
@@ -44,13 +44,13 @@ builder = BiteScript::FileBuilder.build("somefile.source") do
|
|
44
44
|
areturn
|
45
45
|
end
|
46
46
|
|
47
|
-
public_method("getList", ArrayList) do
|
47
|
+
public_method("getList", [], ArrayList) do
|
48
48
|
aload 0
|
49
49
|
getfield this, "list", ArrayList
|
50
50
|
areturn
|
51
51
|
end
|
52
52
|
|
53
|
-
public_static_method("main", void, string[]) do
|
53
|
+
public_static_method("main", [], void, string[]) do
|
54
54
|
aload 0
|
55
55
|
ldc_int 0
|
56
56
|
aaload
|
data/examples/simple_loop.rb
CHANGED
data/lib/bitescript/asm.rb
CHANGED
@@ -4,6 +4,9 @@ module BiteScript
|
|
4
4
|
module ASM
|
5
5
|
begin
|
6
6
|
# try mangled names for the version included with JRuby
|
7
|
+
java.lang.Class.for_name 'jruby.objectweb.asm.Opcodes'
|
8
|
+
|
9
|
+
# no error, proceed with mangled name
|
7
10
|
asm_package = Java::jruby.objectweb.asm
|
8
11
|
java_import asm_package.Opcodes
|
9
12
|
rescue Exception
|
@@ -13,5 +16,6 @@ module BiteScript
|
|
13
16
|
end
|
14
17
|
java_import asm_package.Label
|
15
18
|
java_import asm_package.Type
|
19
|
+
java_import asm_package.ClassWriter
|
16
20
|
end
|
17
21
|
end
|
data/lib/bitescript/builder.rb
CHANGED
@@ -58,6 +58,29 @@ module BiteScript
|
|
58
58
|
nil
|
59
59
|
end
|
60
60
|
end
|
61
|
+
|
62
|
+
module Annotatable
|
63
|
+
java_import "java.lang.annotation.Retention"
|
64
|
+
def annotate(cls, runtime=nil)
|
65
|
+
if Java::JavaClass === cls
|
66
|
+
java_class = cls
|
67
|
+
else
|
68
|
+
java_class = cls.java_class
|
69
|
+
end
|
70
|
+
|
71
|
+
if runtime.nil?
|
72
|
+
retention = java_class.annotation(Retention.java_class)
|
73
|
+
return if retention && retention.value.name == 'CLASS'
|
74
|
+
runtime = retention && retention.value.name == 'RUNTIME'
|
75
|
+
end
|
76
|
+
|
77
|
+
annotation = visit_annotation(Signature.ci(java_class), runtime)
|
78
|
+
annotation.extend AnnotationBuilder
|
79
|
+
|
80
|
+
yield annotation
|
81
|
+
annotation.visit_end
|
82
|
+
end
|
83
|
+
end
|
61
84
|
|
62
85
|
class FileBuilder
|
63
86
|
include Util
|
@@ -173,14 +196,8 @@ module BiteScript
|
|
173
196
|
class ClassBuilder
|
174
197
|
include Util
|
175
198
|
include QuickTypes
|
176
|
-
|
177
|
-
|
178
|
-
java_import "jruby.objectweb.asm.Opcodes"
|
179
|
-
java_import "jruby.objectweb.asm.ClassWriter"
|
180
|
-
rescue
|
181
|
-
java_import "org.objectweb.asm.Opcodes"
|
182
|
-
java_import "org.objectweb.asm.ClassWriter"
|
183
|
-
end
|
199
|
+
include Annotatable
|
200
|
+
include ASM
|
184
201
|
|
185
202
|
java_import java.lang.Object
|
186
203
|
java_import java.lang.Void
|
@@ -202,7 +219,7 @@ module BiteScript
|
|
202
219
|
@interface = opts[:interface]
|
203
220
|
flags = Opcodes::ACC_SUPER
|
204
221
|
if @interface
|
205
|
-
flags
|
222
|
+
flags = Opcodes::ACC_INTERFACE | Opcodes::ACC_ABSTRACT
|
206
223
|
end
|
207
224
|
|
208
225
|
@class_writer = ClassWriter.new(ClassWriter::COMPUTE_MAXS)
|
@@ -271,32 +288,32 @@ module BiteScript
|
|
271
288
|
", binding, __FILE__, __LINE__
|
272
289
|
# instance methods; also defines a "this" local at index 0
|
273
290
|
eval "
|
274
|
-
def #{modifier}_method(name, exceptions, *signature, &block)
|
291
|
+
def #{modifier}_method(name, exceptions=[], *signature, &block)
|
275
292
|
method(Opcodes::ACC_#{modifier.upcase}, name, signature, exceptions, &block)
|
276
293
|
end
|
277
294
|
", binding, __FILE__, __LINE__
|
278
295
|
# static methods
|
279
296
|
eval "
|
280
|
-
def #{modifier}_static_method(name, exceptions, *signature, &block)
|
297
|
+
def #{modifier}_static_method(name, exceptions=[], *signature, &block)
|
281
298
|
method(Opcodes::ACC_STATIC | Opcodes::ACC_#{modifier.upcase}, name, signature, exceptions, &block)
|
282
299
|
end
|
283
300
|
", binding, __FILE__, __LINE__
|
284
301
|
# native methods
|
285
302
|
eval "
|
286
|
-
def #{modifier}_native_method(name, exceptions, *signature)
|
303
|
+
def #{modifier}_native_method(name, exceptions=[], *signature)
|
287
304
|
method(Opcodes::ACC_NATIVE | Opcodes::ACC_#{modifier.upcase}, name, signature, exceptions)
|
288
305
|
end
|
289
306
|
", binding, __FILE__, __LINE__
|
290
307
|
# constructors; also defines a "this" local at index 0
|
291
308
|
eval "
|
292
|
-
def #{modifier}_constructor(exceptions, *signature, &block)
|
309
|
+
def #{modifier}_constructor(exceptions=[], *signature, &block)
|
293
310
|
@constructor = method(Opcodes::ACC_#{modifier.upcase}, \"<init>\", [nil, *signature], exceptions, &block)
|
294
311
|
end
|
295
312
|
", binding, __FILE__, __LINE__
|
296
313
|
end
|
297
314
|
|
298
315
|
def static_init(&block)
|
299
|
-
method(Opcodes::ACC_STATIC, "<clinit>", [void], &block)
|
316
|
+
method(Opcodes::ACC_STATIC, "<clinit>", [void], [], &block)
|
300
317
|
end
|
301
318
|
|
302
319
|
def method(flags, name, signature, exceptions, &block)
|
@@ -350,7 +367,8 @@ module BiteScript
|
|
350
367
|
end
|
351
368
|
|
352
369
|
def field(flags, name, type)
|
353
|
-
@class_writer.visit_field(flags, name, ci(type), nil, nil)
|
370
|
+
field = @class_writer.visit_field(flags, name, ci(type), nil, nil)
|
371
|
+
field.extend Annotatable
|
354
372
|
end
|
355
373
|
|
356
374
|
# name for signature generation using the class being generated
|
@@ -372,9 +390,15 @@ module BiteScript
|
|
372
390
|
self
|
373
391
|
end
|
374
392
|
|
393
|
+
def visit_annotation(*args)
|
394
|
+
@class_writer.visit_annotation(*args)
|
395
|
+
end
|
396
|
+
|
375
397
|
def new_method(modifiers, name, signature, exceptions)
|
376
398
|
exceptions ||= []
|
377
|
-
|
399
|
+
unless exceptions.kind_of?(Array)
|
400
|
+
raise ArgumentError, "Expected array of exceptions, got #{exceptions.inspect}"
|
401
|
+
end
|
378
402
|
exceptions = exceptions.map {|e| path(e)}
|
379
403
|
@class_writer.visit_method(modifiers, name, sig(*signature), nil, exceptions.to_java(:string))
|
380
404
|
end
|
@@ -385,14 +409,10 @@ module BiteScript
|
|
385
409
|
end
|
386
410
|
|
387
411
|
class MethodBuilder
|
388
|
-
begin
|
389
|
-
java_import "jruby.objectweb.asm.Opcodes"
|
390
|
-
rescue
|
391
|
-
java_import "org.objectweb.asm.Opcodes"
|
392
|
-
end
|
393
|
-
|
394
412
|
include QuickTypes
|
413
|
+
include Annotatable
|
395
414
|
include BiteScript::Bytecode
|
415
|
+
include ASM
|
396
416
|
|
397
417
|
attr_reader :method_visitor
|
398
418
|
attr_reader :static
|
@@ -458,7 +478,7 @@ module BiteScript
|
|
458
478
|
@class_builder
|
459
479
|
end
|
460
480
|
|
461
|
-
def local(name, type)
|
481
|
+
def local(name, type=nil)
|
462
482
|
if name == "this" && @static
|
463
483
|
raise "'this' attempted to load from static method"
|
464
484
|
end
|
@@ -466,6 +486,7 @@ module BiteScript
|
|
466
486
|
if @locals[name]
|
467
487
|
return @locals[name][-1][0]
|
468
488
|
else
|
489
|
+
raise ArgumentError, 'Local type required' unless type
|
469
490
|
return push_local(name, type, @start_label)
|
470
491
|
end
|
471
492
|
end
|
@@ -508,22 +529,13 @@ module BiteScript
|
|
508
529
|
@locals[name][-1][-1] = here if @locals[name].size > 0
|
509
530
|
end
|
510
531
|
|
511
|
-
def
|
512
|
-
|
513
|
-
java_class = cls
|
514
|
-
else
|
515
|
-
java_class = cls.java_class
|
516
|
-
end
|
517
|
-
|
518
|
-
annotation = @method_visitor.visit_annotation(ci(java_class), true)
|
519
|
-
annotation.extend AnnotationBuilder
|
520
|
-
|
521
|
-
yield annotation
|
522
|
-
annotation.visit_end
|
532
|
+
def visit_annotation(*args)
|
533
|
+
@method_visitor.visit_annotation(*args)
|
523
534
|
end
|
524
535
|
end
|
525
536
|
|
526
537
|
module AnnotationBuilder
|
538
|
+
include Signature
|
527
539
|
def method_missing(name, val)
|
528
540
|
name_str = name.to_s
|
529
541
|
if name_str[-1] == ?=
|
@@ -543,7 +555,7 @@ module BiteScript
|
|
543
555
|
visit k, v
|
544
556
|
end
|
545
557
|
def annotation(name, cls)
|
546
|
-
if Java::JavaClass
|
558
|
+
if Java::JavaClass === cls
|
547
559
|
java_class = cls
|
548
560
|
else
|
549
561
|
java_class = cls.java_class
|
data/lib/bitescript.rb
CHANGED
File without changes
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project xmlns="http://www.netbeans.org/ns/project/1">
|
3
|
+
<type>org.netbeans.modules.ruby.rubyproject</type>
|
4
|
+
<configuration>
|
5
|
+
<data xmlns="http://www.netbeans.org/ns/ruby-project/1">
|
6
|
+
<name>BiteScript</name>
|
7
|
+
<source-roots>
|
8
|
+
<root id="src.examples.dir"/>
|
9
|
+
<root id="src.lib.dir"/>
|
10
|
+
</source-roots>
|
11
|
+
<test-roots>
|
12
|
+
<root id="test.test.dir"/>
|
13
|
+
</test-roots>
|
14
|
+
</data>
|
15
|
+
</configuration>
|
16
|
+
</project>
|
data/test/test_builder.rb
CHANGED
@@ -20,7 +20,7 @@ class TestBuilder < Test::Unit::TestCase
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def dummy_constructor(class_builder)
|
23
|
-
class_builder.public_constructor do
|
23
|
+
class_builder.public_constructor([]) do
|
24
24
|
aload local 'this'
|
25
25
|
invokespecial object, '<init>', [void]
|
26
26
|
returnvoid
|
@@ -43,7 +43,7 @@ class TestBuilder < Test::Unit::TestCase
|
|
43
43
|
def try(return_type, &b)
|
44
44
|
class_name = new_class_name
|
45
45
|
cb = @builder.public_class(class_name, @builder.object);
|
46
|
-
cb.public_static_method("foo", return_type, &b)
|
46
|
+
cb.public_static_method("foo", [], return_type, &b)
|
47
47
|
dummy_constructor(cb)
|
48
48
|
cls = load(class_name, cb)
|
49
49
|
cls.foo
|
@@ -75,7 +75,6 @@ class TestBuilder < Test::Unit::TestCase
|
|
75
75
|
pop
|
76
76
|
aload 0
|
77
77
|
# monitorexit
|
78
|
-
label :end
|
79
78
|
trycatch(:begin, :finally, :finally, nil)
|
80
79
|
trycatch(:finally, :end, :finally, nil)
|
81
80
|
after.set!
|
@@ -171,7 +170,6 @@ class TestBuilder < Test::Unit::TestCase
|
|
171
170
|
label :catch
|
172
171
|
ldc 2
|
173
172
|
ireturn
|
174
|
-
label :end
|
175
173
|
trycatch(:begin, :catch, :catch, java.lang.Exception)
|
176
174
|
}
|
177
175
|
end
|
@@ -248,10 +246,10 @@ class TestBuilder < Test::Unit::TestCase
|
|
248
246
|
|
249
247
|
def test_instance_method_this
|
250
248
|
cb = @builder.public_class(@class_name, @builder.object);
|
251
|
-
method = cb.public_method("foo", cb.this) {aload local 'this'; areturn}
|
249
|
+
method = cb.public_method("foo", [], cb.this) {aload local 'this'; areturn}
|
252
250
|
|
253
251
|
# ensure "this" is taking slot zero
|
254
|
-
method.local('another')
|
252
|
+
method.local('another', Java::int)
|
255
253
|
assert_equal(method.local('this'), 0)
|
256
254
|
assert_equal(method.local('another'), 1)
|
257
255
|
|
@@ -264,7 +262,7 @@ class TestBuilder < Test::Unit::TestCase
|
|
264
262
|
def test_constructor_this
|
265
263
|
cb = @builder.public_class(@class_name, @builder.object);
|
266
264
|
cb.private_field "self", cb.this
|
267
|
-
constructor = cb.public_constructor do
|
265
|
+
constructor = cb.public_constructor([]) do
|
268
266
|
aload 0
|
269
267
|
dup
|
270
268
|
invokespecial object, "<init>", [void]
|
@@ -273,14 +271,14 @@ class TestBuilder < Test::Unit::TestCase
|
|
273
271
|
returnvoid
|
274
272
|
end
|
275
273
|
|
276
|
-
cb.public_method "get_self", cb.this do
|
274
|
+
cb.public_method "get_self", [], cb.this do
|
277
275
|
aload 0
|
278
276
|
getfield this, "self", this
|
279
277
|
areturn
|
280
278
|
end
|
281
279
|
|
282
280
|
# ensure "this" is taking slot zero
|
283
|
-
constructor.local('another')
|
281
|
+
constructor.local('another', Java::int)
|
284
282
|
assert_equal(constructor.local('this'), 0)
|
285
283
|
assert_equal(constructor.local('another'), 1)
|
286
284
|
|
@@ -292,7 +290,7 @@ class TestBuilder < Test::Unit::TestCase
|
|
292
290
|
cb = @builder.public_class(@class_name, @builder.object);
|
293
291
|
|
294
292
|
body_called = false
|
295
|
-
cb.public_native_method("yoohoo") {body_called = true}
|
293
|
+
cb.public_native_method("yoohoo", []) {body_called = true}
|
296
294
|
|
297
295
|
assert !body_called
|
298
296
|
|
@@ -309,10 +307,10 @@ class TestBuilder < Test::Unit::TestCase
|
|
309
307
|
cb.public_field('inst_field', JString)
|
310
308
|
cb.public_static_field('static_field', JString)
|
311
309
|
|
312
|
-
cb.public_method('set_inst', cb.void) {aload 0; ldc 'instance'; putfield this, 'inst_field', JString; returnvoid}
|
313
|
-
cb.public_method('set_static', cb.void) {ldc 'static'; putstatic this, 'static_field', JString; returnvoid}
|
314
|
-
cb.public_method('get_inst', JString) {aload 0; getfield this, 'inst_field', JString; areturn}
|
315
|
-
cb.public_method('get_static', JString) {getstatic this, 'static_field', JString; areturn}
|
310
|
+
cb.public_method('set_inst', [], cb.void) {aload 0; ldc 'instance'; putfield this, 'inst_field', JString; returnvoid}
|
311
|
+
cb.public_method('set_static', [], cb.void) {ldc 'static'; putstatic this, 'static_field', JString; returnvoid}
|
312
|
+
cb.public_method('get_inst', [], JString) {aload 0; getfield this, 'inst_field', JString; areturn}
|
313
|
+
cb.public_method('get_static', [], JString) {getstatic this, 'static_field', JString; areturn}
|
316
314
|
|
317
315
|
dummy_constructor(cb)
|
318
316
|
obj = load_and_construct(@class_name, cb);
|
@@ -328,15 +326,15 @@ class TestBuilder < Test::Unit::TestCase
|
|
328
326
|
def test_arrays
|
329
327
|
cb = @builder.public_class(@class_name, @builder.object);
|
330
328
|
|
331
|
-
cb.public_method("newbooleanarray", cb.boolean[]) {ldc 5; newbooleanarray; dup; ldc 1; ldc true; bastore; dup; dup; ldc 2; swap; ldc 1; baload; bastore; areturn}
|
332
|
-
cb.public_method("newbytearray", cb.byte[]) {ldc 5; newbytearray; dup; ldc 1; ldc 1; bastore; dup; dup; ldc 2; swap; ldc 1; baload; bastore; areturn}
|
333
|
-
cb.public_method("newshortarray", cb.short[]) {ldc 5; newshortarray; dup; ldc 1; ldc 1; sastore; dup; dup; ldc 2; swap; ldc 1; saload; sastore; areturn}
|
334
|
-
cb.public_method("newchararray", cb.char[]) {ldc 5; newchararray; dup; ldc 1; ldc 1; castore; dup; dup; ldc 2; swap; ldc 1; caload; castore; areturn}
|
335
|
-
cb.public_method("newintarray", cb.int[]) {ldc 5; newintarray; dup; ldc 1; ldc 1; iastore; dup; dup; ldc 2; swap; ldc 1; iaload; iastore; areturn}
|
336
|
-
cb.public_method("newlongarray", cb.long[]) {ldc 5; newlongarray; dup; ldc 1; ldc_long 1; lastore; dup; dup; ldc 2; swap; ldc 1; laload; lastore; areturn}
|
337
|
-
cb.public_method("newfloatarray", cb.float[]) {ldc 5; newfloatarray; dup; ldc 1; ldc_float 1.0; fastore; dup; dup; ldc 2; swap; ldc 1; faload; fastore; areturn}
|
338
|
-
cb.public_method("newdoublearray", cb.double[]) {ldc 5; newdoublearray; dup; ldc 1; ldc 1.0; dastore; dup; dup; ldc 2; swap; ldc 1; daload; dastore; areturn}
|
339
|
-
cb.public_method("anewarray", cb.string[]) {ldc 5; anewarray JString; dup; ldc 1; ldc 'foo'; aastore; dup; dup; ldc 2; swap; ldc 1; aaload; aastore; areturn}
|
329
|
+
cb.public_method("newbooleanarray", [], cb.boolean[]) {ldc 5; newbooleanarray; dup; ldc 1; ldc true; bastore; dup; dup; ldc 2; swap; ldc 1; baload; bastore; areturn}
|
330
|
+
cb.public_method("newbytearray", [], cb.byte[]) {ldc 5; newbytearray; dup; ldc 1; ldc 1; bastore; dup; dup; ldc 2; swap; ldc 1; baload; bastore; areturn}
|
331
|
+
cb.public_method("newshortarray", [], cb.short[]) {ldc 5; newshortarray; dup; ldc 1; ldc 1; sastore; dup; dup; ldc 2; swap; ldc 1; saload; sastore; areturn}
|
332
|
+
cb.public_method("newchararray", [], cb.char[]) {ldc 5; newchararray; dup; ldc 1; ldc 1; castore; dup; dup; ldc 2; swap; ldc 1; caload; castore; areturn}
|
333
|
+
cb.public_method("newintarray", [], cb.int[]) {ldc 5; newintarray; dup; ldc 1; ldc 1; iastore; dup; dup; ldc 2; swap; ldc 1; iaload; iastore; areturn}
|
334
|
+
cb.public_method("newlongarray", [], cb.long[]) {ldc 5; newlongarray; dup; ldc 1; ldc_long 1; lastore; dup; dup; ldc 2; swap; ldc 1; laload; lastore; areturn}
|
335
|
+
cb.public_method("newfloatarray", [], cb.float[]) {ldc 5; newfloatarray; dup; ldc 1; ldc_float 1.0; fastore; dup; dup; ldc 2; swap; ldc 1; faload; fastore; areturn}
|
336
|
+
cb.public_method("newdoublearray", [], cb.double[]) {ldc 5; newdoublearray; dup; ldc 1; ldc 1.0; dastore; dup; dup; ldc 2; swap; ldc 1; daload; dastore; areturn}
|
337
|
+
cb.public_method("anewarray", [], cb.string[]) {ldc 5; anewarray JString; dup; ldc 1; ldc 'foo'; aastore; dup; dup; ldc 2; swap; ldc 1; aaload; aastore; areturn}
|
340
338
|
|
341
339
|
dummy_constructor(cb)
|
342
340
|
obj = load_and_construct(@class_name, cb);
|
@@ -404,7 +402,7 @@ class TestBuilder < Test::Unit::TestCase
|
|
404
402
|
def test_annotation
|
405
403
|
cb = @builder.public_class(@class_name, @builder.object);
|
406
404
|
|
407
|
-
cb.public_method("annotated", cb.void) do
|
405
|
+
cb.public_method("annotated", [], cb.void) do
|
408
406
|
annotate(JRubyMethod, true) do |anno|
|
409
407
|
anno.name = ["foo"]
|
410
408
|
anno.required = 1
|
data/test/test_bytecode.rb
CHANGED
@@ -70,8 +70,8 @@ class TestBytecode < Test::Unit::TestCase
|
|
70
70
|
|
71
71
|
assert_equal([:visit_int_insn, Opcodes::SIPUSH, -129], @dummy.single {ldc(-129)})
|
72
72
|
assert_equal([:visit_int_insn, Opcodes::SIPUSH, 128], @dummy.single {ldc(128)})
|
73
|
-
assert_equal([:visit_ldc_insn, -
|
74
|
-
assert_equal([:visit_ldc_insn,
|
73
|
+
assert_equal([:visit_ldc_insn, java.lang.Integer.new(-32769)], @dummy.single {ldc(-32769)})
|
74
|
+
assert_equal([:visit_ldc_insn, java.lang.Integer.new(32768)], @dummy.single {ldc(32768)})
|
75
75
|
assert_equal([:visit_ldc_insn, java.lang.Integer::MIN_VALUE - 1], @dummy.single {ldc(java.lang.Integer::MIN_VALUE - 1)})
|
76
76
|
assert_equal([:visit_ldc_insn, java.lang.Integer::MAX_VALUE + 1], @dummy.single {ldc(java.lang.Integer::MAX_VALUE + 1)})
|
77
77
|
|
@@ -394,7 +394,8 @@ class TestBytecode < Test::Unit::TestCase
|
|
394
394
|
|
395
395
|
def test_label
|
396
396
|
l1 = label
|
397
|
-
|
397
|
+
l1.set!
|
398
|
+
assert_equal([:visit_label, l1.label], @dummy.all.first)
|
398
399
|
end
|
399
400
|
|
400
401
|
def test_aprintln
|
data/test/test_java_class.rb
CHANGED
@@ -19,8 +19,8 @@ class TestJavaClass < Test::Unit::TestCase
|
|
19
19
|
assert_equal [java.lang.String.java_class], cons2.parameter_types
|
20
20
|
|
21
21
|
cls = BiteScript::FileBuilder.new('x').#{visibility}_class('y')
|
22
|
-
cls.public_constructor()
|
23
|
-
cls.public_constructor(java.lang.String.java_class)
|
22
|
+
cls.public_constructor([])
|
23
|
+
cls.public_constructor([], java.lang.String.java_class)
|
24
24
|
|
25
25
|
cons1 = cls.constructor()
|
26
26
|
cons2 = cls.constructor(java.lang.String.java_class)
|
@@ -47,8 +47,8 @@ class TestJavaClass < Test::Unit::TestCase
|
|
47
47
|
assert_equal [java.lang.Object.java_class], m2.parameter_types
|
48
48
|
|
49
49
|
cls = BiteScript::FileBuilder.new('x').#{visibility}_class('y')
|
50
|
-
cls.public_method('toString', java.lang.String.java_class)
|
51
|
-
cls.public_method('equals', Java::boolean.java_class, java.lang.Object.java_class)
|
50
|
+
cls.public_method('toString', [], java.lang.String.java_class)
|
51
|
+
cls.public_method('equals', [], Java::boolean.java_class, java.lang.Object.java_class)
|
52
52
|
|
53
53
|
m1 = cls.java_method('toString')
|
54
54
|
m2 = cls.java_method('equals', java.lang.Object.java_class)
|
metadata
CHANGED
@@ -1,30 +1,23 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitescript
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Charles Oliver Nutter
|
8
|
+
- Ryan Brown
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
12
|
|
12
|
-
date:
|
13
|
+
date: 2010-02-15 12:41:28.313000 -06:00
|
13
14
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
16
|
-
name: hoe
|
17
|
-
type: :development
|
18
|
-
version_requirement:
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 2.3.3
|
24
|
-
version:
|
15
|
+
dependencies: []
|
16
|
+
|
25
17
|
description: BiteScript is a Ruby DSL for generating Java bytecode and classes.
|
26
18
|
email:
|
27
|
-
-
|
19
|
+
- headius@headius.com
|
20
|
+
- ribrdb@gmail.com
|
28
21
|
executables:
|
29
22
|
- bite
|
30
23
|
- bitec
|
@@ -33,29 +26,37 @@ extensions: []
|
|
33
26
|
extra_rdoc_files:
|
34
27
|
- History.txt
|
35
28
|
- LICENSE.txt
|
36
|
-
- Manifest.txt
|
37
29
|
- README.txt
|
38
30
|
files:
|
39
|
-
- History.txt
|
40
|
-
- LICENSE.txt
|
41
|
-
- Manifest.txt
|
42
|
-
- README.txt
|
43
|
-
- Rakefile
|
44
31
|
- bin/bite
|
45
32
|
- bin/bitec
|
46
33
|
- examples/fib.bs
|
34
|
+
- examples/hello_world.bs
|
35
|
+
- examples/hello_world_macro.bs
|
36
|
+
- examples/indy.bs
|
47
37
|
- examples/mixed_bag.rb
|
48
38
|
- examples/simple_loop.rb
|
39
|
+
- examples/using_ruby.bs
|
49
40
|
- lib/bitescript.rb
|
50
41
|
- lib/bitescript/asm.rb
|
51
42
|
- lib/bitescript/builder.rb
|
52
43
|
- lib/bitescript/bytecode.rb
|
53
44
|
- lib/bitescript/signature.rb
|
45
|
+
- nbproject/project.properties
|
46
|
+
- nbproject/project.xml
|
47
|
+
- nbproject/private/config.properties
|
48
|
+
- nbproject/private/private.properties
|
49
|
+
- nbproject/private/private.xml
|
54
50
|
- test/test_bitescript.rb
|
55
51
|
- test/test_builder.rb
|
56
52
|
- test/test_bytecode.rb
|
57
53
|
- test/test_java_class.rb
|
58
54
|
- test/test_signature.rb
|
55
|
+
- History.txt
|
56
|
+
- LICENSE.txt
|
57
|
+
- README.txt
|
58
|
+
- bitescript.gemspec
|
59
|
+
- Rakefile
|
59
60
|
has_rdoc: true
|
60
61
|
homepage: http://kenai.com/projects/jvmscript
|
61
62
|
licenses: []
|
data/Manifest.txt
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
History.txt
|
2
|
-
LICENSE.txt
|
3
|
-
Manifest.txt
|
4
|
-
README.txt
|
5
|
-
Rakefile
|
6
|
-
bin/bite
|
7
|
-
bin/bitec
|
8
|
-
examples/fib.bs
|
9
|
-
examples/mixed_bag.rb
|
10
|
-
examples/simple_loop.rb
|
11
|
-
lib/bitescript.rb
|
12
|
-
lib/bitescript/asm.rb
|
13
|
-
lib/bitescript/builder.rb
|
14
|
-
lib/bitescript/bytecode.rb
|
15
|
-
lib/bitescript/signature.rb
|
16
|
-
test/test_bitescript.rb
|
17
|
-
test/test_builder.rb
|
18
|
-
test/test_bytecode.rb
|
19
|
-
test/test_java_class.rb
|
20
|
-
test/test_signature.rb
|