mirah 0.1.1-java → 0.1.2-java

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 94bd269f142b48ceb3d74a18a8b55830d23abef4
4
+ data.tar.gz: db296eba09334207d811878f5c703ca7dafd8167
5
+ SHA512:
6
+ metadata.gz: 103411eeafff8608f3ee284ef2298fd85f14b065c70b69799ed94d5c2650e3a7806fa9aaabe327a3db73fdccb1e46c64d3d7161c0d971ec5bf35ee9210fb7af9
7
+ data.tar.gz: 591ed4759862e3ecf0b9c33a4332a87639ea82c761b925ea7b56a961610af0f0fb3a7efd8ccd1b2e3aef602d521fcac9b49bf05e4a2590b688984977e4870607
@@ -1,3 +1,136 @@
1
+ === 0.1.2 New Year, New Release / 2014-01-05
2
+
3
+ 8421140 add desc'd rake task for building mirahc.jar
4
+ 325ec54 replace deprecated import usage w/ java_import in test helper
5
+ f3c7911 move classpath-> Java URLs helper to Env module
6
+ 7e738c3 add passed classpath to run classpath when running with mirah
7
+ 1766599 split out test class file destinations for fixtures vs test classes
8
+ e4e6f49 don't use platform dependent path separator literals in jvm type factory classpath munging
9
+ 223042f clean up run command
10
+ 66f8b24 rm puts in jvm base compiler
11
+ 0bb156e fix gem task definition ordering
12
+ c2e59b4 add apache 2 license to gemspec
13
+ 3480594 move a few local variable assignments in the typer closer to their usage
14
+ 68d883e clean up Rakefile & fix gem task so that it depends on bootstrap
15
+ e46edc7 add tests for type future classes, fix a couple associated bugs
16
+ 860f87f do some c&p to maybe get CallCompiler reliably building on CI
17
+ 8cf13b1 reorder call_compiler initializers to see if that'll fix it (annoyingly)
18
+ 331005e reformat initialize args for CallCompiler
19
+ 8e86d54 comment out non local return support so that this branch can be merged into master
20
+ cedd8c2 break out multi arg block tests into typed and untyped
21
+ 9e19a49 have CallFuture log resolved target as well as args
22
+ c9321ae add custom inspect for MirahError
23
+ 044f7ef improve scope inspect st it includes capture info
24
+ 8ab9e91 try removing unused var / move replace self down
25
+ b8aac8a replace manually created lists with literals
26
+ 89c71f7 refactor node replacement into an extracted method
27
+ ce7817a pull out more common code from macro expansion
28
+ ca1a4e0 begin cleaning up macro expansion in typer
29
+ 8ced4e7 consolidate field type inference
30
+ bbf8356 extract common target type lookup for fields
31
+ 81ec8ad extract helper for defaultExceptionTypeName
32
+ 3dffc61 extract inferring annotations
33
+ d011167 extract inferring params
34
+ 5dbd367 consolidate call method type future creation
35
+ 71b731e consolidate workaround methods via widened type
36
+ 39a66ee extract creating scopes w/ selfType
37
+ 52723e9 extract adding nested scopes in typer
38
+ f2410e6 collapse a couple more getTypeOfs
39
+ 88fe75a add widened getLocalType helper that works for any Named node
40
+ 062b55a refactor typer method def: reorg declaration to usage
41
+ a38ae97 extract common call target inference
42
+ 21b7307 remove unnecessary temp vars from Typer.getLocalType
43
+ 5af117d pull out helper for adding new scope to typer
44
+ 71616c9 use type helper in a couple non-obvious places
45
+ 80cc787 wrap getting types from the typesystem in a helper
46
+ 150b91c typer: rm unneeded temp vars named outer_scope
47
+ d2eff01 wrap scope getting w/ a helper method in typer
48
+ f4f25f2 extract helper for argument types that works for all but rest args
49
+ 4f83d90 pushing more helper code around in typer
50
+ e301bab oops. types for getLocalType helper were wrong. Fixed them, and added scope back
51
+ 114421a more reformatting of MethodDefinition typing
52
+ b4ebaa6 add helper for constructing local type for args
53
+ a632bae extract some helper methods for methoddefinition typing
54
+ 951c7a3 add some newline formatting in the typer
55
+ e9e6b5e replace todos w/ methods noted w/ todos
56
+ a5f7e63 Merge branch 'master' into closure_changes
57
+ 41640bc add cli help for new options
58
+ c0d557b Merge branch 'string_ext' of git://github.com/altamic/mirah
59
+ 59fc3a8 closure work continues
60
+ ea86178 Minor patches + Merge branch 'master' into closure_changes :/
61
+ 8e0f9b8 Fix jruby jar path
62
+ c7e537e Fix double expansion of macros in FunctionalCall
63
+ b61f5bf Fix return types.
64
+ b30d7eb Fix for field assignment as a method call.
65
+ 084366d Add a pass to fix unitialized locals.
66
+ 35abdad merge
67
+ b534cb6 Add a target to bootstrap using javalib/mirahc.jar.
68
+ c2f8bb9 Expose the correct type system to macros.
69
+ b783d57 Fix ambiguity for nil method parameters.
70
+ e7b7f2b More fixes to compile with the selfhosted mirahc.jar
71
+ 3fe8e4b Fix vararg generic methods.
72
+ 0429eb6 Typo
73
+ 9b4655e Better error reporting.
74
+ 8efd6b2 Bug fixes
75
+ e472901 ScriptCleanup is not reusable.
76
+ c9ce542 Fixes to get code compiling with mirahc.jar
77
+ 1584448 Fix for macro compilation.
78
+ 343ac03 Fix for overrides with optional arguments.
79
+ 1c4dbde Fix calls to protected methods using super.
80
+ a6bac61 Fix for recompiling a class that is also on the classpath.
81
+ 21fdfd9 add method def internal support, get a few more tests passing
82
+ fed5aa6 use bundled mirahc instead of just built mirahc
83
+ 5ad5b1a added << operator to StringBuilder (somewhat fixes #40)
84
+ 079ded9 Added include? method to String (closes #133)
85
+ 41de27f added =~ operator to String (closes #160)
86
+ ab10d98 use the jruby jar in javalib instead of the in-use one
87
+ 8dc1bd6 beginnings of a better way to build closures -- still has problems
88
+ 068b248 rm the compiler jar on clean
89
+ ac45fa0 add more nlr tests
90
+ 9c9eaa7 wrap rescue around parent node list
91
+ 2cc0cd5 first pass at non local return
92
+ 5bdeca4 download jruby jar instead of keeping it in git
93
+ 02cee59 bump version to 0.1.2.dev
94
+ 1b74e54 Hack to support covariant return types.
95
+ 4f0ba15 Try to make debug info a little more sane
96
+ f356201 Optional arguments don't need a declaration.
97
+ a5cd63c Mirah methods should not return generic types
98
+ 0c1feee Another missing import
99
+ 1b326e2 Print the number of errors.
100
+ d863176 Fix some override bugs.
101
+ 162848b Guard against concurrent modification in BaseType.notifyOfIncompatibleChange
102
+ 36a0635 Fix test_method_requiring_subclass_of_abstract_class_finds_abstract_method
103
+ 60dcf76 Add missing file
104
+ d895ad2 Better support for overridden methods.
105
+ 82b089f Fix expansion order for macros.
106
+ 4eabcc5 Ensure method changes from supertypes get propagated
107
+ 5388d85 Don't consider macros when inferring overridden method types.
108
+ 9036f24 More debug logging to track down unhelpful error messages during inference.
109
+ 31c9cee bump history again
110
+ 33afd17 bump bitescript dependency
111
+ 98f57da bump 0.1.1 history
112
+ af66397 bump bitescript version to 0.1.3
113
+ 776b74f when bundled in a jar, add the jar to the classpath
114
+ 71d3b82 rm dynalink from zip/jar dist
115
+ 383c615 bump version to 0.1.1; update history
116
+ 97d46fc add tests to nail down super behavior
117
+ 4ef8b3b add inherited lookup to static fields
118
+ dabe54d fix missing conversion for implicit returns in new backend
119
+ 754cc38 fix primitive conversion errors in code generation for implicit return in methods
120
+ d565657 update maven release instructions
121
+ 9d7529f the gem now relies on mirrors and the new backend
122
+ 8a781fc Merge branch 'master' of https://github.com/mirah/mirah
123
+ 0ef465c More missing imports
124
+ ac60613 bump history again
125
+ 00e481f Missing import
126
+ ff8c5b3 Show inference error messages from multiple classes.
127
+ ea7a434 Support inferring overridden types when the same override is contained in multiple supertypes.
128
+ ba84b9c Better error handling in generic method processing
129
+ fc831a8 Guard against concurrent modification
130
+ b214f8f Typo
131
+ bdba3fc Support missing selfType in MethodLookup.
132
+ aeaa4bc Fix compilation of extensions inside a package.
133
+
1
134
  === 0.1.1 Summer Summit / 2013-08-05
2
135
 
3
136
  e94e5be bump bitescript dependency
data/Rakefile CHANGED
@@ -22,6 +22,11 @@ require 'java'
22
22
  require 'jruby/compiler'
23
23
  require 'ant'
24
24
 
25
+ # this definition ensures that the bootstrap tasks will be completed before
26
+ # building the .gem file. Otherwise, the gem may not contain the jars.
27
+ task :gem => [:bootstrap,
28
+ "javalib/mirah-compiler.jar",
29
+ "javalib/mirah-mirrors.jar"]
25
30
  Gem::PackageTask.new Gem::Specification.load('mirah.gemspec') do |pkg|
26
31
  pkg.need_zip = true
27
32
  pkg.need_tar = true
@@ -29,14 +34,16 @@ end
29
34
 
30
35
  bitescript_lib_dir = File.dirname Gem.find_files('bitescript').first
31
36
 
32
- task :gem => ['jar:bootstrap', "javalib/mirah-compiler.jar", "javalib/mirah-mirrors.jar"]
33
- task :bootstrap => ['javalib/mirah-bootstrap.jar', 'javalib/mirah-builtins.jar', 'javalib/mirah-util.jar']
37
+ task :bootstrap => ['javalib/mirah-bootstrap.jar',
38
+ 'javalib/mirah-builtins.jar',
39
+ 'javalib/mirah-util.jar']
34
40
 
35
41
 
36
42
  task :default => :bytecode_ci
37
43
 
38
44
  desc "run bytecode backend ci"
39
- task :bytecode_ci => [:'test:core', :'test:jvm:bytecode']
45
+ task :bytecode_ci => [:'test:core',
46
+ :'test:jvm:bytecode']
40
47
  desc "run new backend ci"
41
48
  task :new_ci => [:'test:core', :'test:jvm:new']
42
49
 
@@ -86,7 +93,9 @@ namespace :test do
86
93
  task :test_setup => [:clean_tmp_test_directory, :build_test_fixtures]
87
94
 
88
95
  desc "run jvm tests compiling to bytecode"
89
- Rake::TestTask.new :bytecode => [:bootstrap, :test_setup] do |t|
96
+ Rake::TestTask.new :bytecode => [:bootstrap,
97
+ "javalib/mirah-compiler.jar",
98
+ :test_setup] do |t|
90
99
  t.libs << 'test' <<'test/jvm'
91
100
  t.ruby_opts.concat ["-r", "bytecode_test_helper"]
92
101
  t.test_files = FileList["test/jvm/**/*test.rb"]
@@ -119,10 +128,12 @@ end
119
128
  task :clean_tmp_test_directory do
120
129
  FileUtils.rm_rf "tmp_test"
121
130
  FileUtils.mkdir_p "tmp_test"
131
+ FileUtils.mkdir_p "tmp_test/test_classes"
132
+ FileUtils.mkdir_p "tmp_test/fixtures"
122
133
  end
123
134
 
124
135
  task :build_test_fixtures do
125
- ant.javac 'destdir' => "tmp_test", 'srcdir' => 'test/fixtures',
136
+ ant.javac 'destdir' => "tmp_test/fixtures", 'srcdir' => 'test/fixtures',
126
137
  'includeantruntime' => false, 'debug' => true, 'listfiles' => true
127
138
  end
128
139
 
@@ -136,8 +147,10 @@ task :clean do
136
147
  ant.delete 'quiet' => true, 'dir' => 'build'
137
148
  ant.delete 'quiet' => true, 'dir' => 'dist'
138
149
  rm_f 'javalib/mirah-bootstrap.jar'
150
+ rm_f 'javalib/mirah-compiler.jar'
139
151
  rm_f 'javalib/mirah-builtins.jar'
140
152
  rm_f 'javalib/mirah-util.jar'
153
+ rm_f 'javalib/mirah-mirrors.jar'
141
154
  rm_rf 'tmp'
142
155
  end
143
156
 
@@ -163,8 +176,11 @@ task :jar => :compile do
163
176
  end
164
177
 
165
178
  namespace :jar do
179
+ desc "build mirahc.jar"
180
+ task :mirahc => 'javalib/mirahc.jar'
181
+
166
182
  desc "build self-contained, complete jar"
167
- task :complete => :jar do
183
+ task :complete => [:jar, 'javalib/jruby-complete.jar'] do
168
184
  ant.jar 'jarfile' => 'dist/mirah-complete.jar' do
169
185
  zipfileset 'src' => 'dist/mirah.jar'
170
186
  zipfileset 'src' => 'javalib/jruby-complete.jar'
@@ -174,9 +190,6 @@ namespace :jar do
174
190
  end
175
191
  end
176
192
  end
177
-
178
- desc "build bootstrap jar used by the gem"
179
- task :bootstrap => 'javalib/mirah-bootstrap.jar'
180
193
  end
181
194
 
182
195
  desc "Build a distribution zip file"
@@ -201,6 +214,16 @@ end
201
214
  desc "Build all redistributable files"
202
215
  task :dist => [:gem, :zip]
203
216
 
217
+ file_create 'javalib/jruby-complete.jar' do
218
+ require 'open-uri'
219
+ puts "Downloading jruby-complete.jar"
220
+ open('http://jruby.org.s3.amazonaws.com/downloads/1.7.4/jruby-complete-1.7.4.jar', 'rb') do |src|
221
+ open('javalib/jruby-complete.jar', 'wb') do |dest|
222
+ dest.write(src.read)
223
+ end
224
+ end
225
+ end
226
+
204
227
  file_create 'javalib/mirah-newast-transitional.jar' do
205
228
  require 'open-uri'
206
229
  puts "Downloading mirah-newast-transitional.jar"
@@ -243,6 +266,43 @@ file 'javalib/mirah-bootstrap.jar' => ['javalib/mirah-newast-transitional.jar',
243
266
  end
244
267
  end
245
268
 
269
+ file 'javalib/mirahc-2.jar' => ['javalib/mirahc.jar'] do
270
+ build_dir = 'build/bootstrap'
271
+ rm_rf build_dir
272
+ mkdir_p build_dir
273
+
274
+ # Compile annotations and class loader
275
+ ant.javac 'source' => '1.5', 'destdir' => build_dir, 'srcdir' => 'src',
276
+ 'includeantruntime' => false, 'debug' => true, 'listfiles' => true
277
+
278
+ # Compile the Typer and Macro compiler
279
+ stage1_files = Dir['src/org/mirah/{builtins,jvm/types,macros,util,}/*.mirah',
280
+ 'src/org/mirah/typer/**/*.mirah']
281
+ runjava('javalib/mirahc.jar',
282
+ '-d', build_dir,
283
+ '-classpath', 'javalib/mirah-parser.jar',
284
+ *stage1_files)
285
+
286
+ add_quote_macro
287
+ cp Dir['src/org/mirah/macros/*.tpl'], "#{build_dir}/org/mirah/macros"
288
+
289
+ stage2_files = Dir['src/org/mirah/jvm/{compiler,mirrors,model}/**/*.mirah',
290
+ 'src/org/mirah/tool/*.mirah']
291
+ runjava('javalib/mirahc.jar',
292
+ '-d', build_dir,
293
+ '-classpath', "javalib/mirah-parser.jar:#{build_dir}",
294
+ *stage2_files)
295
+
296
+ # Build the jar
297
+ ant.jar 'jarfile' => 'javalib/mirahc-2.jar' do
298
+ fileset 'dir' => build_dir
299
+ zipfileset :src => 'javalib/jruby-complete.jar', :includes => 'org/jruby/org/objectweb/**/*'
300
+ zipfileset :src => 'javalib/mirah-parser.jar'
301
+ manifest do
302
+ attribute :name => 'Main-Class', :value => 'org.mirah.tool.Mirahc'
303
+ end
304
+ end
305
+ end
246
306
 
247
307
  file 'javalib/mirah-util.jar' do
248
308
  require 'mirah'
@@ -260,7 +320,7 @@ file 'javalib/mirah-util.jar' do
260
320
 
261
321
  # compile ant stuff
262
322
  ant_classpath = $CLASSPATH.grep(/ant/).map{|x| x.sub(/^file:/,'')}.join(File::PATH_SEPARATOR)
263
- sh *%W(jruby -Ilib bin/mirahc --classpath #{ant_classpath}:#{build_dir} --dest #{build_dir} src/org/mirah/ant)
323
+ sh *%W(jruby -S mirahc --classpath #{ant_classpath}:#{build_dir} --dest #{build_dir} src/org/mirah/ant)
264
324
 
265
325
  # compile invokedynamic stuff
266
326
  ant.javac 'destdir' => build_dir, 'srcdir' => 'src',
@@ -279,7 +339,7 @@ file 'javalib/mirah-builtins.jar' => ['javalib/mirah-bootstrap.jar'] + Dir['src/
279
339
  rm_f 'javalib/mirah-builtins.jar'
280
340
  rm_rf 'build/builtins'
281
341
  mkdir_p 'build/builtins'
282
- sh *%w(jruby -Ilib bin/mirahc --dest build/builtins src/org/mirah/builtins)
342
+ sh *%w(jruby -S mirahc --dest build/builtins src/org/mirah/builtins)
283
343
  ant.jar 'jarfile' => 'javalib/mirah-builtins.jar' do
284
344
  fileset 'dir' => 'build/builtins'
285
345
  end
@@ -293,29 +353,28 @@ file 'javalib/mirah-compiler.jar' => ['javalib/mirah-builtins.jar'] + Dir['src/o
293
353
  phase3_files = Dir['src/org/mirah/jvm/compiler/{class,interface,script}_compiler.mirah'] + ['src/org/mirah/jvm/compiler/backend.mirah']
294
354
  phase2_files = Dir['src/org/mirah/jvm/compiler/{condition,method,string}_compiler.mirah']
295
355
  phase1_files = Dir['src/org/mirah/jvm/compiler/*.mirah'] - phase2_files - phase3_files
296
- sh *(%w(jruby -Ilib bin/mirahc --dest build/compiler ) +
356
+ sh *(%w(jruby -S mirahc --dest build/compiler ) +
297
357
  %w(--classpath javalib/mirah-parser.jar:javalib/mirah-bootstrap.jar) +
298
358
  %w(src/org/mirah/util src/org/mirah/jvm/types src/org/mirah/jvm/compiler/base_compiler.mirah))
299
- sh *(%w(jruby -Ilib bin/mirahc --dest build/compiler ) +
359
+ sh *(%w(jruby -S mirahc --dest build/compiler ) +
300
360
  %w(--classpath javalib/mirah-parser.jar:javalib/mirah-bootstrap.jar:build/compiler) +
301
361
  %w(src/org/mirah/util/context.mirah) + phase1_files)
302
- sh *(%w(jruby -Ilib bin/mirahc --dest build/compiler ) +
362
+ sh *(%w(jruby -S mirahc --dest build/compiler ) +
303
363
  %w(--classpath javalib/mirah-parser.jar:javalib/mirah-bootstrap.jar:build/compiler) +
304
364
  %w(src/org/mirah/util/context.mirah) + phase2_files)
305
- sh *(%w(jruby -Ilib bin/mirahc --dest build/compiler ) +
365
+ sh *(%w(jruby -S mirahc --dest build/compiler ) +
306
366
  %w(--classpath javalib/mirah-parser.jar:javalib/mirah-bootstrap.jar:build/compiler) +
307
367
  %w(src/org/mirah/util/context.mirah) + phase3_files)
308
368
  ant.jar 'jarfile' => 'javalib/mirah-compiler.jar' do
309
369
  fileset 'dir' => 'build/compiler'
310
370
  end
311
- rm_rf 'build/compiler'
312
371
  end
313
372
 
314
373
  file 'javalib/mirah-mirrors.jar' => ['javalib/mirah-compiler.jar'] + Dir['src/org/mirah/jvm/mirrors/**/*.mirah','src/org/mirah/jvm/model/**/*.mirah'] do
315
374
  rm_f 'javalib/mirah-mirrors.jar'
316
375
  rm_rf 'build/mirrors'
317
376
  mkdir_p 'build/mirrors'
318
- sh *(%w(jruby -Ilib bin/mirahc -N --dest build/mirrors ) +
377
+ sh *(%w(jruby -S mirahc -N --dest build/mirrors ) +
319
378
  %w(--classpath javalib/mirah-parser.jar:javalib/mirah-bootstrap.jar:javalib/mirah-compiler.jar) +
320
379
  %w(src/org/mirah/jvm/mirrors/ src/org/mirah/jvm/model/))
321
380
  ant.jar 'jarfile' => 'javalib/mirah-mirrors.jar' do
@@ -324,21 +383,13 @@ file 'javalib/mirah-mirrors.jar' => ['javalib/mirah-compiler.jar'] + Dir['src/or
324
383
  rm_rf 'build/mirrors'
325
384
  end
326
385
 
327
- def find_jruby_jar
328
- require 'java'
329
- java_import 'org.jruby.Ruby'
330
- path = Ruby.java_class.resource('Ruby.class').toString
331
- path =~ %r{^jar:file:(.+)!/org/jruby/Ruby.class}
332
- $1
333
- end
334
-
335
386
  file 'javalib/mirahc.jar' => ['javalib/mirah-mirrors.jar',
336
387
  'src/org/mirah/tool/mirahc.mirah',
337
388
  ] do
338
389
  rm_f 'javalib/mirahc.jar'
339
390
  rm_rf 'build/mirahc'
340
391
  mkdir_p 'build/mirahc'
341
- sh *(%w(jruby -Ilib bin/mirahc -N --dest build/mirahc ) +
392
+ sh *(%w(jruby -S mirahc -N --dest build/mirahc ) +
342
393
  %w(--classpath javalib/mirah-parser.jar:javalib/mirah-bootstrap.jar:javalib/mirah-compiler.jar:javalib/mirah-mirrors.jar) +
343
394
  %w(src/org/mirah/tool/))
344
395
  ant.jar :jarfile => 'javalib/mirahc.jar' do
@@ -348,7 +399,7 @@ file 'javalib/mirahc.jar' => ['javalib/mirah-mirrors.jar',
348
399
  zipfileset :src => 'javalib/mirah-util.jar'
349
400
  zipfileset :src => 'javalib/mirah-compiler.jar'
350
401
  zipfileset :src => 'javalib/mirah-mirrors.jar'
351
- zipfileset :src => find_jruby_jar, :includes => 'org/jruby/org/objectweb/**/*'
402
+ zipfileset :src => 'javalib/jruby-complete.jar', :includes => 'org/jruby/org/objectweb/**/*'
352
403
  zipfileset :src => 'javalib/mirah-parser.jar'
353
404
  manifest do
354
405
  attribute :name => 'Main-Class', :value => 'org.mirah.tool.Mirahc'
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -46,7 +46,8 @@ module Mirah
46
46
  end
47
47
 
48
48
  def to_s
49
- "#<StaticScope node=#{@scope_node.inspect}>"
49
+ #"#<StaticScope node=#{@scope_node.to_s}>"
50
+ inspect
50
51
  end
51
52
 
52
53
  def inspect
@@ -54,6 +55,7 @@ module Mirah
54
55
  result << "parent=#{@parent}\n " if @parent
55
56
  result << "vars=#{locals.inspect}\n " if @vars.size > 0
56
57
  result << "shadowed=#{@shadowed.keys.inspect}\n " if @shadowed.size > 0
58
+ result << "captured=#{capturedLocals.inspect}\n " if capturedLocals.size > 0
57
59
  result << "temps=#{@temps.keys.inspect}\n " if @temps.size > 0
58
60
  result << "package=#{@package}\n " if @package
59
61
  result << "imports=#{@imports.inspect}\n " if @imports.size > 0
@@ -92,7 +94,7 @@ module Mirah
92
94
  end
93
95
 
94
96
  def temp(name="tmp")
95
- "$#{name}$#{@temps[name] += 1}"
97
+ "#{name}$#{@temps[name] += 1}"
96
98
  end
97
99
 
98
100
  def local_type(name, position=nil)
@@ -21,20 +21,12 @@ module Mirah
21
21
  class Run < Base
22
22
  def execute
23
23
  execute_base do
24
- main = nil
25
- class_map = {}
24
+ class_map = generate_classes
25
+ $CLASSPATH << Mirah::Env.decode_paths(@state.classpath) if @state.classpath
26
+ class_loader = load_classes class_map
26
27
 
27
- # generate all bytes for all classes
28
- generator = Mirah::Generator.new(@state, @state.compiler_class, false, @state.verbose)
28
+ main = find_main class_map, class_loader
29
29
 
30
- generator.generate(args).each do |result|
31
- class_map[result.classname.gsub(/\//, '.')] = Mirah::Util::ClassLoader.binary_string result.bytes
32
- end
33
-
34
- # load all classes
35
- main = load_classes_and_find_main(class_map)
36
-
37
- # run the main method we found
38
30
  run_main(main)
39
31
  end
40
32
  end
@@ -45,15 +37,18 @@ module Mirah
45
37
 
46
38
  private
47
39
 
48
- def load_classes_and_find_main(class_map)
49
- main = nil
50
- dcl = Mirah::Util::ClassLoader.new(JRuby.runtime.jruby_class_loader, class_map)
51
- class_map.each do |name,|
52
- cls = dcl.load_class(name)
53
- # TODO: using first main; find correct one?
54
- main ||= cls.get_method("main", java::lang::String[].java_class)
40
+ def load_classes(class_map)
41
+ Mirah::Util::ClassLoader.new(JRuby.runtime.jruby_class_loader, class_map)
42
+ end
43
+
44
+ def find_main class_map, class_loader
45
+ # TODO: using first main; find correct one?
46
+ class_map.keys.each do |name|
47
+ cls = class_loader.load_class(name)
48
+ main = cls.get_method("main", java::lang::String[].java_class)
49
+ return main if main
55
50
  end
56
- main
51
+ nil
57
52
  end
58
53
 
59
54
  def run_main(main)
@@ -68,6 +63,16 @@ module Mirah
68
63
  puts "No main found" unless @state.version_printed || @state.help_printed
69
64
  end
70
65
  end
66
+
67
+ def generate_classes
68
+ # generate all bytes for all classes
69
+ generator = Mirah::Generator.new(@state, @state.compiler_class, false, @state.verbose)
70
+ class_map = {}
71
+ generator.generate(args).each do |result|
72
+ class_map[result.classname.gsub(/\//, '.')] = Mirah::Util::ClassLoader.binary_string result.bytes
73
+ end
74
+ class_map
75
+ end
71
76
  end
72
77
  end
73
78
  end