myco 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/lib/myco/bootstrap/component.rb +6 -7
  3. data/lib/myco/bootstrap/instance.rb +14 -9
  4. data/lib/myco/bootstrap/meme.rb +34 -3
  5. data/lib/myco/code_loader.rb +17 -34
  6. data/lib/myco/code_tools/AST/ArgumentAssembly.my +60 -0
  7. data/lib/myco/code_tools/AST/ArgumentAssembly.my.rb +55 -0
  8. data/lib/myco/code_tools/AST/ArrayAssembly.my +43 -0
  9. data/lib/myco/code_tools/AST/ArrayAssembly.my.rb +37 -0
  10. data/lib/myco/code_tools/AST/BlockArgument.my +25 -0
  11. data/lib/myco/code_tools/AST/BlockArgument.my.rb +26 -0
  12. data/lib/myco/code_tools/AST/BlockLiteral.my +104 -0
  13. data/lib/myco/code_tools/AST/BlockLiteral.my.rb +126 -0
  14. data/lib/myco/code_tools/AST/BlockParameter.my +25 -0
  15. data/lib/myco/code_tools/AST/BlockParameter.my.rb +24 -0
  16. data/lib/myco/code_tools/AST/Body.my +18 -0
  17. data/lib/myco/code_tools/AST/Body.my.rb +20 -0
  18. data/lib/myco/code_tools/AST/BranchOperator.my +59 -0
  19. data/lib/myco/code_tools/AST/BranchOperator.my.rb +87 -0
  20. data/lib/myco/code_tools/AST/ConstantAccess.my +30 -0
  21. data/lib/myco/code_tools/AST/ConstantAccess.my.rb +32 -0
  22. data/lib/myco/code_tools/AST/ConstantAssignment.my +40 -0
  23. data/lib/myco/code_tools/AST/ConstantAssignment.my.rb +45 -0
  24. data/lib/myco/code_tools/AST/ConstantDefine.my +30 -0
  25. data/lib/myco/code_tools/AST/ConstantDefine.my.rb +36 -0
  26. data/lib/myco/code_tools/AST/ConstantReopen.my +29 -0
  27. data/lib/myco/code_tools/AST/ConstantReopen.my.rb +35 -0
  28. data/lib/myco/code_tools/AST/DeclareCategory.my +35 -0
  29. data/lib/myco/code_tools/AST/DeclareCategory.my.rb +40 -0
  30. data/lib/myco/code_tools/AST/DeclareDecorator.my +20 -0
  31. data/lib/myco/code_tools/AST/DeclareDecorator.my.rb +28 -0
  32. data/lib/myco/code_tools/AST/DeclareFile.my +38 -0
  33. data/lib/myco/code_tools/AST/DeclareFile.my.rb +53 -0
  34. data/lib/myco/code_tools/AST/DeclareMeme.my +79 -0
  35. data/lib/myco/code_tools/AST/DeclareMeme.my.rb +90 -0
  36. data/lib/myco/code_tools/AST/DeclareObject.my +58 -0
  37. data/lib/myco/code_tools/AST/DeclareObject.my.rb +67 -0
  38. data/lib/myco/code_tools/AST/DeclareString.my +26 -0
  39. data/lib/myco/code_tools/AST/DeclareString.my.rb +30 -0
  40. data/lib/myco/code_tools/AST/DynamicString.my +21 -0
  41. data/lib/myco/code_tools/AST/DynamicString.my.rb +22 -0
  42. data/lib/myco/code_tools/AST/DynamicSymbol.my +22 -0
  43. data/lib/myco/code_tools/AST/DynamicSymbol.my.rb +26 -0
  44. data/lib/myco/code_tools/AST/Invoke.my +37 -0
  45. data/lib/myco/code_tools/AST/Invoke.my.rb +58 -0
  46. data/lib/myco/code_tools/AST/InvokeMethod.my +19 -0
  47. data/lib/myco/code_tools/AST/InvokeMethod.my.rb +25 -0
  48. data/lib/myco/code_tools/AST/KeywordAssembly.my +30 -0
  49. data/lib/myco/code_tools/AST/KeywordAssembly.my.rb +36 -0
  50. data/lib/myco/code_tools/AST/LocalVariableAccessAmbiguous.my +22 -0
  51. data/lib/myco/code_tools/AST/LocalVariableAccessAmbiguous.my.rb +22 -0
  52. data/lib/myco/code_tools/AST/LocalVariableAssignment.my +20 -0
  53. data/lib/myco/code_tools/AST/LocalVariableAssignment.my.rb +20 -0
  54. data/lib/myco/{parser/ast/myco_module_scope.rb → code_tools/AST/MycoModuleScope.my} +32 -39
  55. data/lib/myco/code_tools/AST/MycoModuleScope.my.rb +82 -0
  56. data/lib/myco/code_tools/AST/Node.my +67 -0
  57. data/lib/myco/code_tools/AST/Node.my.rb +84 -0
  58. data/lib/myco/code_tools/AST/ParameterAssembly.my +248 -0
  59. data/lib/myco/code_tools/AST/ParameterAssembly.my.rb +314 -0
  60. data/lib/myco/code_tools/AST/Quest.my +61 -0
  61. data/lib/myco/code_tools/AST/Quest.my.rb +51 -0
  62. data/lib/myco/code_tools/AST/Script.my +27 -0
  63. data/lib/myco/code_tools/AST/Script.my.rb +33 -0
  64. data/lib/myco/code_tools/AST/SplatValue.my +23 -0
  65. data/lib/myco/code_tools/AST/SplatValue.my.rb +25 -0
  66. data/lib/myco/code_tools/AST/StringLiteral.my +17 -0
  67. data/lib/myco/code_tools/AST/StringLiteral.my.rb +16 -0
  68. data/lib/myco/code_tools/AST/SymbolLiteral.my +16 -0
  69. data/lib/myco/code_tools/AST/SymbolLiteral.my.rb +15 -0
  70. data/lib/myco/{parser/ast → code_tools/AST}/ToRuby.my +89 -90
  71. data/lib/myco/{parser/ast → code_tools/AST}/ToRuby.my.rb +89 -101
  72. data/lib/myco/code_tools/AST/misc.my +57 -0
  73. data/lib/myco/code_tools/AST/misc.my.rb +81 -0
  74. data/lib/myco/code_tools/AST.my +52 -0
  75. data/lib/myco/code_tools/AST.my.rb +40 -0
  76. data/lib/myco/{parser → code_tools/parser}/peg_parser.rb +107 -199
  77. data/lib/myco/{parser.rb → code_tools/parser.rb} +0 -17
  78. data/lib/myco/code_tools.rb +5 -0
  79. data/lib/myco/core/BasicDecorators.my +47 -0
  80. data/lib/myco/core/BasicDecorators.my.rb +66 -0
  81. data/lib/myco/core/FileToplevel.my +14 -3
  82. data/lib/myco/core/FileToplevel.my.rb +27 -12
  83. data/lib/myco/eval.rb +7 -37
  84. data/lib/myco/version.rb +1 -4
  85. data/lib/myco.rb +20 -22
  86. metadata +74 -66
  87. data/lib/myco/parser/ast/argument_assembly.rb +0 -76
  88. data/lib/myco/parser/ast/array_assembly.rb +0 -57
  89. data/lib/myco/parser/ast/branch_operator.rb +0 -73
  90. data/lib/myco/parser/ast/constant_access.rb +0 -15
  91. data/lib/myco/parser/ast/constant_define.rb +0 -40
  92. data/lib/myco/parser/ast/constant_reopen.rb +0 -46
  93. data/lib/myco/parser/ast/declare_category.rb +0 -53
  94. data/lib/myco/parser/ast/declare_decorator.rb +0 -35
  95. data/lib/myco/parser/ast/declare_file.rb +0 -54
  96. data/lib/myco/parser/ast/declare_meme.rb +0 -86
  97. data/lib/myco/parser/ast/declare_object.rb +0 -77
  98. data/lib/myco/parser/ast/declare_string.rb +0 -37
  99. data/lib/myco/parser/ast/invoke.rb +0 -48
  100. data/lib/myco/parser/ast/invoke_method.rb +0 -28
  101. data/lib/myco/parser/ast/local_variable_access_ambiguous.rb +0 -34
  102. data/lib/myco/parser/ast/misc.rb +0 -156
  103. data/lib/myco/parser/ast/quest.rb +0 -82
  104. data/lib/myco/parser/ast.rb +0 -21
@@ -0,0 +1,33 @@
1
+
2
+ ::Myco::Component.new([::Myco::FileToplevel], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
3
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco.find_constant(:CodeTools)::AST.component_eval {(::Myco.cscope.for_method_definition.const_set(:Script, ::Myco::Component.new([::Myco.find_constant(:Node)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
4
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(
5
+ declare_meme(:file, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
6
+ declare_meme(:body, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
7
+ declare_meme(:variable_scope, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
8
+ ::Myco.cscope.for_method_definition.const_set(:Form, ([
9
+ :script,
10
+ :file,
11
+ :body
12
+ ]))
13
+ declare_meme(:nest_scope, [], nil, ::Myco.cscope.dup) { |scope| (scope.__send__(
14
+ :parent=,
15
+ self
16
+ ))}
17
+ declare_meme(:search_local, [], nil, ::Myco.cscope.dup) { |*| (nil)}
18
+ declare_meme(:bytecode, [], nil, ::Myco.cscope.dup) { |g| (
19
+ g.__send__(
20
+ :name=,
21
+ :__script__
22
+ )
23
+ g.__send__(
24
+ :file=,
25
+ self.file.to_sym
26
+ )
27
+ g.push_state(self)
28
+ self.body.bytecode(g)
29
+ g.ret
30
+ g.pop_state
31
+ )}
32
+ )}})
33
+ .tap { |__c__| __c__.__name__ = :Script })})}}.instance
@@ -0,0 +1,23 @@
1
+
2
+ CodeTools::AST << {
3
+
4
+ SplatValue < Node {
5
+ var value
6
+
7
+ Form: [:splat, :value]
8
+
9
+ bytecode: |g| {
10
+ self.value.bytecode(g)
11
+
12
+ # TODO: determine if coercion from other types is necessary here
13
+ g.dup
14
+ g.push_rubinius
15
+ g.find_const(:"Runtime")
16
+ g.swap
17
+ g.send(:dup_as_array, 1, true)
18
+
19
+ g.swap
20
+ g.pop
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,25 @@
1
+
2
+ ::Myco::Component.new([::Myco::FileToplevel], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
3
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco.find_constant(:CodeTools)::AST.component_eval {(::Myco.cscope.for_method_definition.const_set(:SplatValue, ::Myco::Component.new([::Myco.find_constant(:Node)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
4
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(
5
+ declare_meme(:value, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
6
+ ::Myco.cscope.for_method_definition.const_set(:Form, ([
7
+ :splat,
8
+ :value
9
+ ]))
10
+ declare_meme(:bytecode, [], nil, ::Myco.cscope.dup) { |g| (
11
+ self.value.bytecode(g)
12
+ g.dup
13
+ g.push_rubinius
14
+ g.find_const(:Runtime)
15
+ g.swap
16
+ g.send(
17
+ :dup_as_array,
18
+ 1,
19
+ true
20
+ )
21
+ g.swap
22
+ g.pop
23
+ )}
24
+ )}})
25
+ .tap { |__c__| __c__.__name__ = :SplatValue })})}}.instance
@@ -0,0 +1,17 @@
1
+
2
+ CodeTools::AST << {
3
+
4
+ StringLiteral < Node {
5
+ var value
6
+
7
+ Form: [:str, :value]
8
+
9
+ bytecode: |g| {
10
+ pos(g)
11
+
12
+ g.push_literal(self.value)
13
+ g.string_dup
14
+ }
15
+ }
16
+
17
+ }
@@ -0,0 +1,16 @@
1
+
2
+ ::Myco::Component.new([::Myco::FileToplevel], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
3
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco.find_constant(:CodeTools)::AST.component_eval {(::Myco.cscope.for_method_definition.const_set(:StringLiteral, ::Myco::Component.new([::Myco.find_constant(:Node)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
4
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(
5
+ declare_meme(:value, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
6
+ ::Myco.cscope.for_method_definition.const_set(:Form, ([
7
+ :str,
8
+ :value
9
+ ]))
10
+ declare_meme(:bytecode, [], nil, ::Myco.cscope.dup) { |g| (
11
+ self.pos(g)
12
+ g.push_literal(self.value)
13
+ g.string_dup
14
+ )}
15
+ )}})
16
+ .tap { |__c__| __c__.__name__ = :StringLiteral })})}}.instance
@@ -0,0 +1,16 @@
1
+
2
+ CodeTools::AST << {
3
+
4
+ SymbolLiteral < Node {
5
+ var value
6
+
7
+ Form: [:lit, :value]
8
+
9
+ bytecode: |g| {
10
+ pos(g)
11
+
12
+ g.push_literal(self.value)
13
+ }
14
+ }
15
+
16
+ }
@@ -0,0 +1,15 @@
1
+
2
+ ::Myco::Component.new([::Myco::FileToplevel], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
3
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco.find_constant(:CodeTools)::AST.component_eval {(::Myco.cscope.for_method_definition.const_set(:SymbolLiteral, ::Myco::Component.new([::Myco.find_constant(:Node)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
4
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(
5
+ declare_meme(:value, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
6
+ ::Myco.cscope.for_method_definition.const_set(:Form, ([
7
+ :lit,
8
+ :value
9
+ ]))
10
+ declare_meme(:bytecode, [], nil, ::Myco.cscope.dup) { |g| (
11
+ self.pos(g)
12
+ g.push_literal(self.value)
13
+ )}
14
+ )}})
15
+ .tap { |__c__| __c__.__name__ = :SymbolLiteral })})}}.instance
@@ -104,18 +104,15 @@ CodeTools::AST << {
104
104
  TrueLiteral << { to_ruby: |g| g.add("true") }
105
105
  FalseLiteral << { to_ruby: |g| g.add("false") }
106
106
 
107
- StringLiteral << { to_ruby: |g| g.add(self.string.inspect) }
107
+ StringLiteral << { to_ruby: |g| g.add(self.value.inspect) }
108
108
  SymbolLiteral << { to_ruby: |g| g.add(self.value.inspect) }
109
109
 
110
110
  DynamicString << {
111
111
  to_ruby: |g| {
112
- inspect_escape = Proc.new |str| { str.inspect.slice(::Range.new(1, -2)) }
113
-
114
112
  g.add('"')
115
- g.add(inspect_escape.call(self.string))
116
- self.array.each_slice(2) |interpolated, inner_string| {
117
- g.add('#{'); g.add(interpolated.value); g.add('}')
118
- g.add(inspect_escape.call(inner_string.value))
113
+ self.body.each_slice(2) |string, to_string| {
114
+ g.add(string.value.to_s.inspect.slice(::Range.new(1, -2)))
115
+ to_string && (g.add('#{'); g.add(to_string); g.add('}'))
119
116
  }
120
117
  g.add('"')
121
118
  }
@@ -123,69 +120,78 @@ CodeTools::AST << {
123
120
 
124
121
  DynamicSymbol << {
125
122
  to_ruby: |g| {
126
- g.add(":")
127
- # TODO: use super here
128
- DynamicString.instance_method(:to_ruby).bind(self).call(g)
123
+ g.add(':"')
124
+ self.body.each_slice(2) |string, to_string| {
125
+ g.add(string.value.to_s.inspect.slice(::Range.new(1, -2)))
126
+ to_string && (g.add('#{'); g.add(to_string); g.add('}'))
127
+ }
128
+ g.add('"')
129
129
  }
130
130
  }
131
131
 
132
- HashLiteral << {
132
+ ArrayAssembly << {
133
+ to_ruby: |g|
134
+ g.add("["); g.list(self.body, ",", auto_lines:true); g.add("]")
135
+ }
136
+
137
+ KeywordAssembly << {
133
138
  to_ruby: |g| {
134
139
  g.add("{")
135
- g.list(self.array.each_slice(2).to_a, ",", auto_lines:true) |pair| {
140
+ g.list(self.body.each_slice(2).to_a, ",", auto_lines:true) |pair| {
136
141
  g.add(pair.first, " => ", pair.last)
137
142
  }
138
143
  g.add("}")
139
144
  }
140
145
  }
141
146
 
142
- ArrayAssembly << {
143
- to_ruby: |g|
144
- g.add("["); g.list(self.body, ",", auto_lines:true); g.add("]")
145
- }
146
-
147
- ScopedConstant << {
148
- to_ruby: |g|
149
- g.add(self.parent); g.add("::"self.name"")
150
-
151
- to_ruby_assign: |g, value|
152
- to_ruby(g); g.add(" = "); g.add(value)
153
- }
154
-
155
- ToplevelConstant << {
156
- to_ruby: |g|
157
- g.add("::"self.name"")
158
-
159
- to_ruby_assign: |g, value|
160
- to_ruby(g); g.add(" = "); g.add(value)
161
- }
162
-
163
147
  ConstantAccess << {
164
- to_ruby: |g|
165
- g.add("::Myco.find_constant("self.name.inspect")")
166
-
167
- to_ruby_assign: |g, value| {
168
- g.add("::Myco.cscope.for_method_definition.const_set("self.name.inspect", ")
169
- g.add(value); g.add(")")
148
+ to_ruby: |g| {
149
+ name_list = self.names.map(&:to_sym)
150
+ first_name = name_list.shift
151
+
152
+ self.toplevel &? (
153
+ g.add("::"first_name"")
154
+ ) ?? (
155
+ g.add("::Myco.find_constant("first_name.inspect")")
156
+ )
157
+ name_list.each |name| { g.add("::"name"") }
170
158
  }
171
159
  }
172
160
 
173
161
  ConstantAssignment << {
174
- to_ruby: |g| self.constant.to_ruby_assign(g, self.value)
162
+ to_ruby: |g| {
163
+ name_list = self.constant.names.map(&:to_sym)
164
+ last_name = name_list.pop
165
+ first_name = name_list.any? && name_list.shift
166
+
167
+ self.constant.toplevel &? (
168
+ first_name && g.add("::"first_name"")
169
+ ) ?? (
170
+ first_name &? (
171
+ g.add("::Myco.find_constant("first_name.inspect")")
172
+ ) ?? (
173
+ g.add("::Myco.cscope.for_method_definition")
174
+ )
175
+ )
176
+ name_list.each |name| { g.add("::"name"") }
177
+ g.add("::"last_name" = ")
178
+
179
+ g.add(self.value)
180
+ }
175
181
  }
176
182
 
177
183
  ConstantDefine << {
178
184
  to_ruby: |g| {
179
185
  g.add(implementation)
180
186
  g.line(".tap { |__c__| __c__.__name__ = ")
181
- g.add(self.name.name.inspect)
187
+ g.add(self.constant.names.last.inspect)
182
188
  g.add(" }")
183
189
  }
184
190
  }
185
191
 
186
192
  ConstantReopen << {
187
193
  to_ruby: |g| {
188
- g.add(self.name); g.add(".component_eval {")
194
+ g.add(self.constant); g.add(".component_eval {")
189
195
  g.add(self.body); g.add("}")
190
196
  }
191
197
  }
@@ -195,7 +201,7 @@ CodeTools::AST << {
195
201
  g.with_nested_var_scope(self) { g.add(self.body) }
196
202
  }
197
203
 
198
- EvalExpression << { to_ruby: |g| g.add(self.body) }
204
+ Script << { to_ruby: |g| g.add(self.body) }
199
205
  DeclareFile << { to_ruby: |g| g.line; implementation.to_ruby(g); g.line }
200
206
 
201
207
  DeclareObject << {
@@ -210,7 +216,7 @@ CodeTools::AST << {
210
216
 
211
217
  DeclareCategory << {
212
218
  to_ruby: |g| {
213
- g.add("__category__("self.name.value.inspect")")
219
+ g.add("__category__("self.name.inspect")")
214
220
  g.add(".component_eval {"); g.add(self.body); g.add("}")
215
221
  }
216
222
  }
@@ -218,13 +224,13 @@ CodeTools::AST << {
218
224
  DeclareMeme << {
219
225
  to_ruby: |g| {
220
226
  g.with_nested_var_scope(body_implementation) {
221
- g.var_scope_declare_locals(*self.arguments.names)
227
+ g.var_scope_declare_locals(*self.parameters.names)
222
228
 
223
229
  g.add("declare_meme(")
224
230
  g.add(""self.name.inspect", ")
225
231
  g.add(self.decorations); g.add(", nil, ::Myco.cscope.dup)")
226
232
  g.add(" { ");
227
- g.add(self.arguments); g.add(" ")
233
+ g.add(self.parameters); g.add(" ")
228
234
  g.add(self.body);
229
235
  g.add("}")
230
236
  }
@@ -236,56 +242,56 @@ CodeTools::AST << {
236
242
  g.add("["self.name.value.inspect", "); g.add(self.arguments); g.add("]")
237
243
  }
238
244
 
239
- Parameters << {
245
+ BlockParameter << {
246
+ to_ruby: |g| g.add("&"self.name"")
247
+ }
248
+
249
+ ParameterAssembly << {
240
250
  to_ruby: |g| {
241
251
  list = []
242
252
  list_add = Proc.new |&blk| { list.push(Proc.new(&blk)) }
243
253
 
244
254
  self.required.each |item| { list_add.call { g.add(item.to_s) } }
245
255
 
246
- self.defaults &? (
247
- self.defaults.arguments.each |asgn| {
248
- name = asgn.name
249
- value = asgn.value
250
- list_add.call {
251
- g.add(""name"=")
252
- (value.is_a?(SymbolLiteral) && value.value==:"*") || g.add(value)
253
- }
256
+ self.optional.each |asgn| {
257
+ name = asgn.name
258
+ value = asgn.value
259
+ list_add.call {
260
+ g.add(""name"=")
261
+ (value.is_a?(SymbolLiteral) && value.value==:"*") || g.add(value)
254
262
  }
255
- )
263
+ }
256
264
 
257
- (self.splat == :"*") &? (
265
+ (self.splat == true) &? (
258
266
  list_add.call { g.add("*") }
259
267
  ) ?? (self.splat &? ( # TODO: make prettier elsif alternative
260
268
  list_add.call { g.add("*"self.splat"") }
261
269
  ))
262
270
 
263
- self.keywords &? (
264
- self.keywords.arguments.each |asgn| {
265
- name = asgn.name
266
- value = asgn.value
267
- list_add.call {
268
- g.add(""name":")
269
- (value.is_a?(SymbolLiteral) && value.value==:"*") || g.add(value)
270
- }
271
+ self.post.each |item| { list_add.call { g.add(item.to_s) } }
272
+
273
+ self.kwargs.each |asgn| {
274
+ name = asgn.name
275
+ value = asgn.value
276
+ list_add.call {
277
+ g.add(""name":")
278
+ (value.is_a?(SymbolLiteral) && value.value==:"*") || g.add(value)
271
279
  }
272
-
273
- (self.keywords.kwrest == true) &? (
274
- list_add.call { g.add("**") }
275
- ) ?? self.keywords.kwrest &? (
276
- list_add.call { g.add("**"self.keywords.kwrest.name"") }
277
- )
278
- )
280
+ }
279
281
 
280
- self.block_arg &? (
281
- list_add.call { g.add("&"self.block_arg.name"") }
282
- )
282
+ (self.kwrest == true) &? (
283
+ list_add.call { g.add("**") }
284
+ ) ?? (self.kwrest &? ( # TODO: make prettier elsif alternative
285
+ list_add.call { g.add("**"self.kwrest"") }
286
+ ))
287
+
288
+ self.block && list_add.call { g.add(self.block) }
283
289
 
284
290
  g.add("|"); g.list(list, ", ") |proc| { proc.call }; g.add("|")
285
291
  }
286
292
  }
287
293
 
288
- Block << {
294
+ Body << {
289
295
  to_ruby: |g|
290
296
  g.add("("); g.list(self.array, "", auto_lines:true); g.add(")")
291
297
  }
@@ -295,7 +301,7 @@ CodeTools::AST << {
295
301
  InvokeMethod << {
296
302
  to_ruby: |g| {
297
303
  list = self.arguments &? self.arguments.body.dup ?? []
298
- self.arguments.block.is_a?(BlockPass) &&
304
+ self.arguments.block.is_a?(BlockArgument) && # TODO: receive block as part of arguments list
299
305
  list.push(self.arguments.block)
300
306
 
301
307
  g.add(self.receiver)
@@ -304,7 +310,7 @@ CodeTools::AST << {
304
310
  g.add("."self.name"")
305
311
  ) ?? (
306
312
  g.add(".__send__")
307
- list.unshift(SymbolLiteral.new(self.line, self.name))
313
+ list.unshift(SymbolLiteral.new(line:self.line, value:self.name))
308
314
  )
309
315
 
310
316
  list.any? && (
@@ -313,7 +319,7 @@ CodeTools::AST << {
313
319
  g.add(")")
314
320
  )
315
321
 
316
- self.arguments.block.is_a?(Iter) && (
322
+ self.arguments.block.is_a?(BlockLiteral) && (
317
323
  g.add(" {"); g.add(self.arguments.block); g.add("}")
318
324
  )
319
325
  }
@@ -353,20 +359,17 @@ CodeTools::AST << {
353
359
  )
354
360
  }
355
361
  }
356
- CollectSplat << { to_ruby: |g| { } } # TODO
357
- ConcatArgs << { to_ruby: |g| { } } # TODO
358
- PushArgs << { to_ruby: |g| { } } # TODO
359
362
 
360
- BlockPass << {
363
+ BlockArgument << {
361
364
  to_ruby: |g| g.add("&"); g.add(self.body)
362
365
  }
363
366
 
364
- Iter << {
367
+ BlockLiteral << {
365
368
  to_ruby: |g| {
366
369
  g.with_nested_var_scope(self) {
367
- g.var_scope_declare_locals(*self.arguments.names)
370
+ g.var_scope_declare_locals(*self.parameters.names)
368
371
 
369
- g.add(" "); g.add(self.arguments); g.add(" "); g.add(self.body)
372
+ g.add(" "); g.add(self.parameters); g.add(" "); g.add(self.body)
370
373
  }
371
374
  }
372
375
  }
@@ -393,8 +396,4 @@ CodeTools::AST << {
393
396
  g.add(self.right); g.add('}')
394
397
  }
395
398
  }
396
-
397
- Return << {
398
- to_ruby: |g| g.add("return "); g.add(self.value)
399
- }
400
399
  }