mirah 0.0.4-java → 0.0.5-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. data/History.txt +23 -0
  2. data/README.txt +13 -5
  3. data/Rakefile +30 -2
  4. data/bin/duby +16 -0
  5. data/bin/dubyc +16 -0
  6. data/bin/dubyp +16 -0
  7. data/bin/jrubyp +16 -0
  8. data/bin/mirah +17 -1
  9. data/bin/mirah.cmd +15 -0
  10. data/bin/mirahc +17 -1
  11. data/bin/mirahc.cmd +16 -1
  12. data/bin/mirahp +17 -1
  13. data/bin/mirahp.cmd +16 -1
  14. data/examples/appengine/Rakefile +17 -2
  15. data/examples/appengine/src/org/mirah/MirahApp.mirah +15 -0
  16. data/examples/bintrees.mirah +15 -0
  17. data/examples/construction.mirah +15 -0
  18. data/examples/dynamic.mirah +15 -0
  19. data/examples/edb.mirah +15 -0
  20. data/examples/fib.mirah +15 -0
  21. data/examples/fields.mirah +15 -0
  22. data/examples/fractal.mirah +15 -0
  23. data/examples/java_thing.mirah +15 -0
  24. data/examples/plugins/appengine/Rakefile +19 -4
  25. data/examples/plugins/appengine/lib/com/google/appengine/ext/duby/db/datastore.rb +21 -6
  26. data/examples/plugins/appengine/src/com/google/appengine/ext/duby/db/Model.duby +15 -0
  27. data/examples/plugins/appengine/test/com/google/appengine/ext/duby/db/ModelTest.duby +15 -0
  28. data/examples/simple_class.mirah +16 -1
  29. data/examples/sort_closure.mirah +15 -0
  30. data/examples/swing.mirah +17 -2
  31. data/examples/tak.mirah +15 -0
  32. data/examples/wiki/Rakefile +17 -2
  33. data/examples/wiki/src/org/mirah/wiki/MirahWiki.duby +15 -0
  34. data/examples/wiki/war/src/org/mirah/wiki/MirahWiki.duby +339 -0
  35. data/examples/wiki/war/src/org/mirah/wiki/edit.eduby.html +42 -0
  36. data/examples/wiki/war/src/org/mirah/wiki/error.eduby.html +2 -0
  37. data/examples/wiki/war/src/org/mirah/wiki/layout.eduby.html +69 -0
  38. data/examples/wiki/war/src/org/mirah/wiki/parser.eduby.html +7 -0
  39. data/examples/wiki/war/src/org/mirah/wiki/view.eduby.html +15 -0
  40. data/javalib/mirah-bootstrap.jar +0 -0
  41. data/javalib/mirah-parser.jar +0 -0
  42. data/lib/duby.rb +15 -0
  43. data/lib/mirah/appengine_tasks.rb +20 -6
  44. data/lib/mirah/ast/call.rb +19 -4
  45. data/lib/mirah/ast/class.rb +19 -4
  46. data/lib/mirah/ast/flow.rb +16 -1
  47. data/lib/mirah/ast/intrinsics.rb +36 -21
  48. data/lib/mirah/ast/literal.rb +16 -1
  49. data/lib/mirah/ast/local.rb +16 -1
  50. data/lib/mirah/ast/method.rb +18 -3
  51. data/lib/mirah/ast/scope.rb +19 -4
  52. data/lib/mirah/ast/structure.rb +16 -1
  53. data/lib/mirah/ast/type.rb +24 -9
  54. data/lib/mirah/ast.rb +24 -9
  55. data/lib/mirah/compiler.rb +16 -1
  56. data/lib/mirah/env.rb +16 -1
  57. data/lib/mirah/jvm/base.rb +18 -3
  58. data/lib/mirah/jvm/compiler.rb +35 -21
  59. data/lib/mirah/jvm/method_lookup.rb +16 -1
  60. data/lib/mirah/jvm/source_compiler.rb +29 -14
  61. data/lib/mirah/jvm/source_generator/builder.rb +21 -6
  62. data/lib/mirah/jvm/source_generator/loops.rb +16 -1
  63. data/lib/mirah/jvm/source_generator/precompile.rb +17 -2
  64. data/lib/mirah/jvm/source_generator/typer.rb +17 -2
  65. data/lib/mirah/jvm/typer.rb +19 -4
  66. data/lib/mirah/jvm/types/basic_types.rb +16 -1
  67. data/lib/mirah/jvm/types/boolean.rb +17 -2
  68. data/lib/mirah/jvm/types/enumerable.rb +21 -6
  69. data/lib/mirah/jvm/types/extensions.rb +16 -1
  70. data/lib/mirah/jvm/types/factory.rb +18 -3
  71. data/lib/mirah/jvm/types/floats.rb +16 -1
  72. data/lib/mirah/jvm/types/integers.rb +22 -7
  73. data/lib/mirah/jvm/types/intrinsics.rb +29 -14
  74. data/lib/mirah/jvm/types/literals.rb +16 -1
  75. data/lib/mirah/jvm/types/methods.rb +24 -9
  76. data/lib/mirah/jvm/types/number.rb +16 -1
  77. data/lib/mirah/jvm/types.rb +23 -4
  78. data/lib/mirah/nbcompiler.rb +19 -4
  79. data/lib/mirah/plugin/edb.rb +18 -3
  80. data/lib/mirah/plugin/gwt.rb +22 -7
  81. data/lib/mirah/plugin/java.rb +18 -3
  82. data/lib/mirah/transform.rb +35 -20
  83. data/lib/mirah/transform2.rb +20 -5
  84. data/lib/mirah/typer.rb +23 -8
  85. data/lib/mirah/version.rb +18 -0
  86. data/lib/mirah.rb +101 -50
  87. data/lib/mirah_task.rb +27 -12
  88. data/test/test_ast.rb +16 -1
  89. data/test/test_compilation.rb +18 -3
  90. data/test/test_env.rb +26 -11
  91. data/test/test_gwt.rb +18 -3
  92. data/test/test_java_typer.rb +27 -12
  93. data/test/test_javac_compiler.rb +17 -2
  94. data/test/test_jvm_compiler.rb +44 -14
  95. data/test/test_typer.rb +16 -1
  96. metadata +203 -193
@@ -0,0 +1,69 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
5
+ <title><%=h @title %></title>
6
+ <link type="text/css" rel="stylesheet" href="/stylesheets/main.css">
7
+ <link href="/stylesheets/prettify.css" type="text/css" rel="stylesheet" />
8
+ <script type="text/javascript" src="/javascripts/prettify.js"></script>
9
+ </head>
10
+ <body onload="prettyPrint()">
11
+ <div id="page">
12
+ <div id="sidebar">
13
+
14
+ <h1>Mirah</h1>
15
+
16
+ <ul id="sidebar-items">
17
+
18
+ <li>
19
+ <h3>Join the community</h3>
20
+ <ul class="links">
21
+ <li><a href="/">Home Page</a></li>
22
+ <li><a href="http://github.com/mirah/mirah">github</a></li>
23
+ <li><a href="/wiki/Resources">Resources</a></li>
24
+ <li><a href="/wiki/MirahHowto">Howto</a></li>
25
+ <li><a
26
+ href="http://groups.google.com/group/mirah/"
27
+ target="_new">Send Feedback</a></li>
28
+ </ul>
29
+ </li>
30
+
31
+ <li>
32
+ <h3>Sample Apps</h3>
33
+ <ul class="links">
34
+ <li><a href="http://github.com/mirah/mirah/tree/master/examples/appengine/">Guestbook</a> |
35
+ <a href="http://github.com/jacortinas/appengine-rails-jquery-demo">Mustache</a></li>
36
+ </ul>
37
+ <a href="/wiki/MirahSamples">Sample Code</a>
38
+ </li>
39
+
40
+ <li>
41
+ <h3>Mirah Videos</h3>
42
+ <ul class="links">
43
+ <li><a href="http://www.youtube.com/watch?v=08rNKxW0PPo">ribrdb</a> |
44
+ <a href="http://confreaks.net/videos/196-rubyconf2009-ruby-mutants">headius</a></li>
45
+ </ul>
46
+ </li>
47
+
48
+ </div>
49
+
50
+ <div id="content">
51
+ <div id=hlinks>
52
+ <% if user %>
53
+ <%=h user.getEmail %>&nbsp;|&nbsp;
54
+ <% extra_links.each do |_pair|;pair = List(_pair) %>
55
+ <a href="<%=h pair.get(1)%>"><%=h pair.get(0)%></a>&nbsp;|&nbsp;
56
+ <% end %>
57
+ <a href="<%=h users.createLogoutURL('/')%>">Sign Out</a>
58
+ <% else %>
59
+ <a href="<%=users.createLoginURL(url)%>">Sign In</a>
60
+ <% end %>
61
+ </div>
62
+ <div id=wikicontent>
63
+ <%= @content %>
64
+ </div>
65
+ </div>
66
+ </div>
67
+ </body>
68
+ </html>
69
+
@@ -0,0 +1,7 @@
1
+ <form method=post>
2
+ <p><textarea name="code" cols=80 rows=20><%=h @code %></textarea><br>
3
+ <input type="submit" value="Parse"/>
4
+ </p>
5
+ </form>
6
+ <h2>Parsed:</h2>
7
+ <div><tt><%=h @parsed %></tt></div>
@@ -0,0 +1,15 @@
1
+ <script>
2
+ function newPage() {
3
+ var p=prompt('Page name', '')
4
+ if (p) {
5
+ document.location = '/edit/' + p
6
+ }
7
+ }
8
+ </script>
9
+ <% if @page %>
10
+ <%= markdown @page.body %>
11
+ <% else %>
12
+ <h1><%=h @name%></h1>
13
+ <p>That page does not exist. Click <a href="/edit/<%=h @name%>">here</a>
14
+ to create it.</p>
15
+ <% end%>
Binary file
Binary file
data/lib/duby.rb CHANGED
@@ -1,2 +1,17 @@
1
+ # Copyright (c) 2010 The Mirah project authors. All Rights Reserved.
2
+ # All contributing project authors may be found in the NOTICE file.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
1
16
  puts "WARNING: Duby is now Mirah. Please require 'mirah'."
2
17
  require File.dirname(__FILE__) + '/mirah'
@@ -1,3 +1,18 @@
1
+ # Copyright (c) 2010 The Mirah project authors. All Rights Reserved.
2
+ # All contributing project authors may be found in the NOTICE file.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
1
16
  require 'appengine-sdk'
2
17
  require 'mirah_task'
3
18
  require 'java'
@@ -6,8 +21,7 @@ require 'rake'
6
21
  require 'yaml'
7
22
 
8
23
  module AppEngine::Rake
9
- SERVLET = AppEngine::SDK::SDK_ROOT +
10
- '/lib/shared/geronimo-servlet_2.5_spec-1.2.jar'
24
+ SERVLET = AppEngine::SDK::SDK_ROOT + '/lib/shared/servlet-api.jar'
11
25
  APIS = AppEngine::SDK::API_JAR
12
26
  TOOLS = AppEngine::SDK::TOOLS_JAR
13
27
 
@@ -30,8 +44,8 @@ module AppEngine::Rake
30
44
  webinf_lib_jars.each do |jar|
31
45
  $CLASSPATH << jar unless $CLASSPATH.include?(jar)
32
46
  end
33
- Duby.source_paths << src
34
- Duby.dest_paths << webinf_classes
47
+ Mirah.source_paths << src
48
+ Mirah.dest_paths << webinf_classes
35
49
  directory(webinf_classes)
36
50
  directory(webinf_lib)
37
51
 
@@ -108,7 +122,7 @@ module AppEngine::Rake
108
122
  end
109
123
 
110
124
  def app_yaml
111
- @war + '/app.yaml'
125
+ @war + '/WEB-INF/app.yaml'
112
126
  end
113
127
 
114
128
  def webinf_classes
@@ -143,4 +157,4 @@ def appengine_app(*args, &block)
143
157
  war = File.expand_path(war || 'war')
144
158
  task.init(src, war)
145
159
  task
146
- end
160
+ end
@@ -1,6 +1,21 @@
1
+ # Copyright (c) 2010 The Mirah project authors. All Rights Reserved.
2
+ # All contributing project authors may be found in the NOTICE file.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
1
16
  require 'delegate'
2
17
 
3
- module Duby::AST
18
+ module Mirah::AST
4
19
  class NodeProxy < DelegateClass(Node)
5
20
  include Java::DubyLangCompiler::Node
6
21
  def __inline__(node)
@@ -89,7 +104,7 @@ module Duby::AST
89
104
  typer.infer(param) || should_defer = true
90
105
  end
91
106
 
92
- parameter_types << Duby::AST.block_type if block
107
+ parameter_types << Mirah::AST.block_type if block
93
108
 
94
109
  unless should_defer
95
110
  if parameters.size == 1 && typer.known_type(scope, name)
@@ -189,7 +204,7 @@ module Duby::AST
189
204
  typer.infer(param) || should_defer = true
190
205
  end
191
206
 
192
- parameter_types << Duby::AST.block_type if block
207
+ parameter_types << Mirah::AST.block_type if block
193
208
 
194
209
  unless should_defer
195
210
  @inferred_type = typer.method_type(receiver_type, name,
@@ -254,7 +269,7 @@ module Duby::AST
254
269
  begin
255
270
  typer.type_reference(scope, class_name, array)
256
271
  rescue NameError => ex
257
- typer.known_types[class_name] = Duby::AST.error_type
272
+ typer.known_types[class_name] = Mirah::AST.error_type
258
273
  raise ex
259
274
  end
260
275
  end
@@ -1,4 +1,19 @@
1
- module Duby::AST
1
+ # Copyright (c) 2010 The Mirah project authors. All Rights Reserved.
2
+ # All contributing project authors may be found in the NOTICE file.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ module Mirah::AST
2
17
  class ClassDefinition < Node
3
18
  include Annotated
4
19
  include Named
@@ -19,8 +34,8 @@ module Duby::AST
19
34
  @interface_nodes = []
20
35
  @name = name
21
36
  self.parent = parent
22
- if Duby::AST.type_factory.respond_to? :define_type
23
- Duby::AST.type_factory.define_type(self)
37
+ if Mirah::AST.type_factory.respond_to? :define_type
38
+ Mirah::AST.type_factory.define_type(self)
24
39
  end
25
40
  # We need somewhere to collect nodes that get appended during
26
41
  # the transform phase.
@@ -103,7 +118,7 @@ module Duby::AST
103
118
  def implements(*types)
104
119
  raise ArgumentError if types.any? {|x| x.nil?}
105
120
  types.each do |type|
106
- if Duby::AST::TypeReference === type
121
+ if Mirah::AST::TypeReference === type
107
122
  @interfaces << type
108
123
  else
109
124
  @interface_nodes << type
@@ -1,4 +1,19 @@
1
- module Duby
1
+ # Copyright (c) 2010 The Mirah project authors. All Rights Reserved.
2
+ # All contributing project authors may be found in the NOTICE file.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ module Mirah
2
17
  module AST
3
18
  class Condition < Node
4
19
  child :predicate
@@ -1,6 +1,21 @@
1
+ # Copyright (c) 2010 The Mirah project authors. All Rights Reserved.
2
+ # All contributing project authors may be found in the NOTICE file.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
1
16
  require 'fileutils'
2
17
 
3
- module Duby::AST
18
+ module Mirah::AST
4
19
 
5
20
  class Unquote < Node
6
21
  child :value
@@ -39,19 +54,19 @@ module Duby::AST
39
54
  end
40
55
 
41
56
  def self.__extracted
42
- Thread.current[:'Duby::AST::Unqote.extracted']
57
+ Thread.current[:'Mirah::AST::Unqote.extracted']
43
58
  end
44
59
 
45
60
  def self.__extracted=(value)
46
- Thread.current[:'Duby::AST::Unqote.extracted'] = value
61
+ Thread.current[:'Mirah::AST::Unqote.extracted'] = value
47
62
  end
48
63
 
49
64
  def self.__injected
50
- Thread.current[:'Duby::AST::Unqote.injected']
65
+ Thread.current[:'Mirah::AST::Unqote.injected']
51
66
  end
52
67
 
53
68
  def self.__injected=(value)
54
- Thread.current[:'Duby::AST::Unqote.injected'] = value
69
+ Thread.current[:'Mirah::AST::Unqote.injected'] = value
55
70
  end
56
71
 
57
72
  def self.extract_values
@@ -80,7 +95,7 @@ module Duby::AST
80
95
 
81
96
  def name
82
97
  case value
83
- when Duby::AST::String
98
+ when Mirah::AST::String
84
99
  value.literal
85
100
  when ::String
86
101
  value
@@ -235,7 +250,7 @@ module Duby::AST
235
250
  else
236
251
  # TODO support typed args. Also there should be a way
237
252
  # to accept any AST node.
238
- Duby::JVM::Types::Object
253
+ Mirah::JVM::Types::Object
239
254
  end
240
255
  end
241
256
  end
@@ -249,19 +264,19 @@ module Duby::AST
249
264
  end
250
265
 
251
266
  def build_and_load_extension(parent, name, state)
252
- transformer = Duby::Transform::Transformer.new(state)
267
+ transformer = Mirah::Transform::Transformer.new(state)
253
268
  transformer.filename = name.gsub(".", "/")
254
- orig_factory = Duby::AST.type_factory
269
+ orig_factory = Mirah::AST.type_factory
255
270
  new_factory = orig_factory.dup
256
- Duby::AST.type_factory = new_factory
271
+ Mirah::AST.type_factory = new_factory
257
272
  ast = build_ast(name, parent, transformer)
258
273
  puts ast.inspect if state.verbose
259
274
  classes = compile_ast(name, ast, transformer)
260
- loader = DubyClassLoader.new(
275
+ loader = MirahClassLoader.new(
261
276
  JRuby.runtime.jruby_class_loader, classes)
262
277
  klass = loader.loadClass(name, true)
263
278
  annotate(parent, name)
264
- Duby::AST.type_factory = orig_factory
279
+ Mirah::AST.type_factory = orig_factory
265
280
  klass
266
281
  end
267
282
 
@@ -289,10 +304,10 @@ module Duby::AST
289
304
  end
290
305
 
291
306
  def compile_ast(name, ast, transformer)
292
- typer = Duby::Typer::JVM.new(transformer)
307
+ typer = Mirah::Typer::JVM.new(transformer)
293
308
  typer.infer(ast)
294
309
  typer.resolve(true)
295
- compiler = Duby::Compiler::JVM.new
310
+ compiler = Mirah::Compiler::JVM.new
296
311
  ast.compile(compiler, false)
297
312
  class_map = {}
298
313
  compiler.generate do |outfile, builder|
@@ -311,25 +326,25 @@ module Duby::AST
311
326
  def build_ast(name, parent, transformer)
312
327
  # TODO should use a new type factory too.
313
328
 
314
- ast = Duby::AST.parse_ruby("begin;end")
329
+ ast = Mirah::AST.parse_ruby("begin;end")
315
330
  ast = transformer.transform(ast, nil)
316
331
 
317
332
  # Start building the extension class
318
333
  extension = transformer.define_class(position, name)
319
- #extension.superclass = Duby::AST.type(nil, 'duby.lang.compiler.Macro')
320
- extension.implements(Duby::AST.type(nil, 'duby.lang.compiler.Macro'))
334
+ #extension.superclass = Mirah::AST.type(nil, 'duby.lang.compiler.Macro')
335
+ extension.implements(Mirah::AST.type(nil, 'duby.lang.compiler.Macro'))
321
336
 
322
337
  extension.static_scope.import('duby.lang.compiler.Node', 'Node')
323
338
 
324
339
  # The constructor just saves the state
325
340
  extension.define_constructor(
326
341
  position,
327
- ['mirah', Duby::AST.type(nil, 'duby.lang.compiler.Compiler')],
328
- ['call', Duby::AST.type(nil, 'duby.lang.compiler.Call')]) do |c|
342
+ ['mirah', Mirah::AST.type(nil, 'duby.lang.compiler.Compiler')],
343
+ ['call', Mirah::AST.type(nil, 'duby.lang.compiler.Call')]) do |c|
329
344
  transformer.eval("@mirah = mirah;@call = call", '-', c, 'mirah', 'call')
330
345
  end
331
346
 
332
- node_type = Duby::AST.type(nil, 'duby.lang.compiler.Node')
347
+ node_type = Mirah::AST.type(nil, 'duby.lang.compiler.Node')
333
348
 
334
349
  # expand() parses the arguments out of call and then passes them off to
335
350
  # _expand
@@ -350,7 +365,7 @@ module Duby::AST
350
365
  end
351
366
  actual_args = arguments.map do |arg|
352
367
  type = if arg.kind_of?(BlockArgument)
353
- Duby::AST.type(nil, 'duby.lang.compiler.Block')
368
+ Mirah::AST.type(nil, 'duby.lang.compiler.Block')
354
369
  else
355
370
  node_type
356
371
  end
@@ -1,4 +1,19 @@
1
- module Duby::AST
1
+ # Copyright (c) 2010 The Mirah project authors. All Rights Reserved.
2
+ # All contributing project authors may be found in the NOTICE file.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ module Mirah::AST
2
17
  class Array < Node
3
18
  def initialize(parent, line_number, &block)
4
19
  super(parent, line_number, &block)
@@ -1,4 +1,19 @@
1
- module Duby::AST
1
+ # Copyright (c) 2010 The Mirah project authors. All Rights Reserved.
2
+ # All contributing project authors may be found in the NOTICE file.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ module Mirah::AST
2
17
  class LocalDeclaration < Node
3
18
  include Named
4
19
  include Typed
@@ -1,4 +1,19 @@
1
- module Duby::AST
1
+ # Copyright (c) 2010 The Mirah project authors. All Rights Reserved.
2
+ # All contributing project authors may be found in the NOTICE file.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ module Mirah::AST
2
17
  class Arguments < Node
3
18
  child :required
4
19
  child :opt_args
@@ -241,7 +256,7 @@ module Duby::AST
241
256
  if !abstract? &&
242
257
  forced_type != typer.no_type &&
243
258
  !actual_type.is_parent(inferred_type)
244
- raise Duby::Typer::InferenceError.new(
259
+ raise Mirah::Typer::InferenceError.new(
245
260
  "Inferred return type %s is incompatible with declared %s" %
246
261
  [inferred_type, actual_type], self)
247
262
  end
@@ -259,7 +274,7 @@ module Duby::AST
259
274
  # even if we can't infer the body yet.
260
275
  type ||= signature[:return] if argument_types && argument_types.all?
261
276
  if type
262
- argument_types ||= [Duby::AST.error_type] if type.error?
277
+ argument_types ||= [Mirah::AST.error_type] if type.error?
263
278
  typer.learn_method_type(defining_class, name, argument_types, type, signature[:throws])
264
279
 
265
280
  # learn the other overloads as well
@@ -1,4 +1,19 @@
1
- module Duby
1
+ # Copyright (c) 2010 The Mirah project authors. All Rights Reserved.
2
+ # All contributing project authors may be found in the NOTICE file.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ module Mirah
2
17
  module AST
3
18
  module Scoped
4
19
  def scope
@@ -79,7 +94,7 @@ module Duby
79
94
  existing_type = local_type(name)
80
95
  if existing_type
81
96
  unless existing_type.assignable_from?(type)
82
- raise Duby::Typer::InferenceError.new(
97
+ raise Mirah::Typer::InferenceError.new(
83
98
  "Can't assign #{type.full_name} to " \
84
99
  "variable of type #{existing_type.full_name}")
85
100
  end
@@ -147,11 +162,11 @@ module Duby
147
162
  parent.binding_type(defining_class, duby)
148
163
  else
149
164
  name = "#{defining_class.name}$#{duby.tmp}"
150
- factory = Duby::AST.type_factory
165
+ factory = Mirah::AST.type_factory
151
166
  if factory
152
167
  factory.declare_type(@scope_node, name)
153
168
  else
154
- Duby::AST::TypeReference.new(name, false, false)
169
+ Mirah::AST::TypeReference.new(name, false, false)
155
170
  end
156
171
  end
157
172
  end
@@ -1,4 +1,19 @@
1
- module Duby::AST
1
+ # Copyright (c) 2010 The Mirah project authors. All Rights Reserved.
2
+ # All contributing project authors may be found in the NOTICE file.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ module Mirah::AST
2
17
  class Body < Node
3
18
  def initialize(parent, line_number, &block)
4
19
  super(parent, line_number, &block)
@@ -1,4 +1,19 @@
1
- module Duby::AST
1
+ # Copyright (c) 2010 The Mirah project authors. All Rights Reserved.
2
+ # All contributing project authors may be found in the NOTICE file.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ module Mirah::AST
2
17
  class Import < Node
3
18
  include Scoped
4
19
  attr_accessor :short
@@ -18,7 +33,7 @@ module Duby::AST
18
33
  begin
19
34
  typer.type_reference(scope, @long)
20
35
  rescue NameError => ex
21
- typer.known_types[short] = Duby::AST.error_type
36
+ typer.known_types[short] = Mirah::AST.error_type
22
37
  raise ex
23
38
  end
24
39
  typer.no_type
@@ -47,7 +62,7 @@ module Duby::AST
47
62
  arg = node.parameters[0]
48
63
  unless (FunctionalCall === arg &&
49
64
  arg.name == 'as' && arg.parameters.size == 1)
50
- raise Duby::TransformError.new("unknown import syntax", fcall)
65
+ raise Mirah::TransformError.new("unknown import syntax", fcall)
51
66
  end
52
67
  short = arg.parameters[0].name
53
68
  pieces = [node.name]
@@ -57,16 +72,16 @@ module Duby::AST
57
72
  end
58
73
  long = pieces.reverse.join '.'
59
74
  else
60
- raise Duby::TransformError.new("unknown import syntax", fcall)
75
+ raise Mirah::TransformError.new("unknown import syntax", fcall)
61
76
  end
62
77
  else
63
- raise Duby::TransformError.new("unknown import syntax", fcall)
78
+ raise Mirah::TransformError.new("unknown import syntax", fcall)
64
79
  end
65
80
  when 2
66
81
  short = fcall.parameters[0].literal
67
82
  long = fcall.parameters[1].literal
68
83
  else
69
- raise Duby::TransformError.new("unknown import syntax", fcall)
84
+ raise Mirah::TransformError.new("unknown import syntax", fcall)
70
85
  end
71
86
  Import.new(parent, fcall.position, short, long)
72
87
  end
@@ -90,10 +105,10 @@ module Duby::AST
90
105
  name = node.name
91
106
  block ||= node.block
92
107
  else
93
- raise Duby::TransformError.new("unknown package syntax", fcall)
108
+ raise Mirah::TransformError.new("unknown package syntax", fcall)
94
109
  end
95
110
  if block
96
- raise Duby::TransformError.new("unknown package syntax", block)
111
+ raise Mirah::TransformError.new("unknown package syntax", block)
97
112
  new_scope = ScopedBody.new(parent, fcall.position)
98
113
  new_scope.static_scope.package = name
99
114
  new_scope << block.body
@@ -124,7 +139,7 @@ module Duby::AST
124
139
 
125
140
  class Builtin < Node
126
141
  def infer(typer)
127
- resolve_if(typer) {Duby::AST.type(nil, 'mirah.impl.Builtin')}
142
+ resolve_if(typer) {Mirah::AST.type(nil, 'mirah.impl.Builtin')}
128
143
  end
129
144
  end
130
145
  end