myco 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/lib/myco/bootstrap/component.rb +2 -0
  3. data/lib/myco/bootstrap/evaluator.rb +58 -0
  4. data/lib/myco/bootstrap/instance.rb +1 -1
  5. data/lib/myco/bootstrap/meme.rb +4 -9
  6. data/lib/myco/bootstrap.my +1 -1
  7. data/lib/myco/bootstrap.my.rb +1 -1
  8. data/lib/myco/code_loader.rb +6 -1
  9. data/lib/myco/code_tools/AST/ArgumentAssembly.my +8 -12
  10. data/lib/myco/code_tools/AST/ArgumentAssembly.my.rb +12 -9
  11. data/lib/myco/code_tools/AST/ArrayAssembly.my +2 -3
  12. data/lib/myco/code_tools/AST/ArrayAssembly.my.rb +2 -5
  13. data/lib/myco/code_tools/AST/Block.my +4 -4
  14. data/lib/myco/code_tools/AST/Block.my.rb +3 -7
  15. data/lib/myco/code_tools/AST/BlockArgument.my +4 -5
  16. data/lib/myco/code_tools/AST/BlockArgument.my.rb +2 -5
  17. data/lib/myco/code_tools/AST/BlockLiteral.my +3 -4
  18. data/lib/myco/code_tools/AST/BlockLiteral.my.rb +6 -6
  19. data/lib/myco/code_tools/AST/BlockParameter.my +4 -11
  20. data/lib/myco/code_tools/AST/BlockParameter.my.rb +4 -13
  21. data/lib/myco/code_tools/AST/BranchOperator.my +2 -3
  22. data/lib/myco/code_tools/AST/BranchOperator.my.rb +4 -9
  23. data/lib/myco/code_tools/AST/ConstantAccess.my +11 -8
  24. data/lib/myco/code_tools/AST/ConstantAccess.my.rb +16 -12
  25. data/lib/myco/code_tools/AST/ConstantAssignment.my +13 -5
  26. data/lib/myco/code_tools/AST/ConstantAssignment.my.rb +16 -11
  27. data/lib/myco/code_tools/AST/ConstantDefine.my +2 -3
  28. data/lib/myco/code_tools/AST/ConstantDefine.my.rb +3 -7
  29. data/lib/myco/code_tools/AST/DeclareCategory.my +4 -14
  30. data/lib/myco/code_tools/AST/DeclareCategory.my.rb +20 -36
  31. data/lib/myco/code_tools/AST/DeclareDecorator.my +2 -3
  32. data/lib/myco/code_tools/AST/DeclareDecorator.my.rb +3 -7
  33. data/lib/myco/code_tools/AST/DeclareExtension.my +22 -0
  34. data/lib/myco/code_tools/AST/DeclareExtension.my.rb +19 -0
  35. data/lib/myco/code_tools/AST/DeclareFile.my +4 -15
  36. data/lib/myco/code_tools/AST/DeclareFile.my.rb +34 -50
  37. data/lib/myco/code_tools/AST/DeclareMeme.my +5 -7
  38. data/lib/myco/code_tools/AST/DeclareMeme.my.rb +8 -17
  39. data/lib/myco/code_tools/AST/DeclareObject.my +6 -18
  40. data/lib/myco/code_tools/AST/DeclareObject.my.rb +41 -59
  41. data/lib/myco/code_tools/AST/DeclareString.my +2 -3
  42. data/lib/myco/code_tools/AST/DeclareString.my.rb +3 -7
  43. data/lib/myco/code_tools/AST/{MycoModuleScope.my → DeclaredScope.my} +15 -16
  44. data/lib/myco/code_tools/AST/{MycoModuleScope.my.rb → DeclaredScope.my.rb} +15 -20
  45. data/lib/myco/code_tools/AST/Invoke.my +8 -8
  46. data/lib/myco/code_tools/AST/Invoke.my.rb +13 -21
  47. data/lib/myco/code_tools/AST/InvokeMethod.my +2 -3
  48. data/lib/myco/code_tools/AST/InvokeMethod.my.rb +4 -9
  49. data/lib/myco/code_tools/AST/KeywordAssembly.my +3 -4
  50. data/lib/myco/code_tools/AST/KeywordAssembly.my.rb +2 -5
  51. data/lib/myco/code_tools/AST/KeywordOptionalParameter.my +16 -0
  52. data/lib/myco/code_tools/AST/KeywordOptionalParameter.my.rb +14 -0
  53. data/lib/myco/code_tools/AST/KeywordRequiredParameter.my +16 -0
  54. data/lib/myco/code_tools/AST/KeywordRequiredParameter.my.rb +13 -0
  55. data/lib/myco/code_tools/AST/KeywordRestParameter.my +16 -0
  56. data/lib/myco/code_tools/AST/KeywordRestParameter.my.rb +13 -0
  57. data/lib/myco/code_tools/AST/LocalVariableAccessAmbiguous.my +2 -3
  58. data/lib/myco/code_tools/AST/LocalVariableAccessAmbiguous.my.rb +2 -5
  59. data/lib/myco/code_tools/AST/LocalVariableAssignment.my +3 -3
  60. data/lib/myco/code_tools/AST/LocalVariableAssignment.my.rb +3 -7
  61. data/lib/myco/code_tools/AST/Node.my +32 -2
  62. data/lib/myco/code_tools/AST/Node.my.rb +34 -1
  63. data/lib/myco/code_tools/AST/NumericLiteral.my +15 -0
  64. data/lib/myco/code_tools/AST/NumericLiteral.my.rb +12 -0
  65. data/lib/myco/code_tools/AST/OptionalParameter.my +24 -0
  66. data/lib/myco/code_tools/AST/OptionalParameter.my.rb +19 -0
  67. data/lib/myco/code_tools/AST/ParameterAssembly.my +60 -103
  68. data/lib/myco/code_tools/AST/ParameterAssembly.my.rb +60 -121
  69. data/lib/myco/code_tools/AST/PipeOperator.my +2 -3
  70. data/lib/myco/code_tools/AST/PipeOperator.my.rb +3 -7
  71. data/lib/myco/code_tools/AST/Quest.my +8 -10
  72. data/lib/myco/code_tools/AST/Quest.my.rb +9 -13
  73. data/lib/myco/code_tools/AST/RequiredParameter.my +12 -0
  74. data/lib/myco/code_tools/AST/RequiredParameter.my.rb +10 -0
  75. data/lib/myco/code_tools/AST/RestParameter.my +12 -0
  76. data/lib/myco/code_tools/AST/RestParameter.my.rb +10 -0
  77. data/lib/myco/code_tools/AST/Script.my +4 -4
  78. data/lib/myco/code_tools/AST/Script.my.rb +3 -7
  79. data/lib/myco/code_tools/AST/Sequence.my +2 -3
  80. data/lib/myco/code_tools/AST/Sequence.my.rb +2 -5
  81. data/lib/myco/code_tools/AST/SplatValue.my +3 -4
  82. data/lib/myco/code_tools/AST/SplatValue.my.rb +2 -5
  83. data/lib/myco/code_tools/AST/{DynamicString.my → StringCompose.my} +3 -4
  84. data/lib/myco/code_tools/AST/{DynamicString.my.rb → StringCompose.my.rb} +4 -7
  85. data/lib/myco/code_tools/AST/StringLiteral.my +2 -3
  86. data/lib/myco/code_tools/AST/StringLiteral.my.rb +2 -5
  87. data/lib/myco/code_tools/AST/{DynamicSymbol.my → SymbolCompose.my} +3 -4
  88. data/lib/myco/code_tools/AST/{DynamicSymbol.my.rb → SymbolCompose.my.rb} +4 -7
  89. data/lib/myco/code_tools/AST/SymbolLiteral.my +2 -3
  90. data/lib/myco/code_tools/AST/SymbolLiteral.my.rb +2 -5
  91. data/lib/myco/code_tools/AST/ToRuby.my +40 -57
  92. data/lib/myco/code_tools/AST/ToRuby.my.rb +43 -52
  93. data/lib/myco/code_tools/AST/misc.my +19 -24
  94. data/lib/myco/code_tools/AST/misc.my.rb +18 -23
  95. data/lib/myco/code_tools/AST.my +17 -8
  96. data/lib/myco/code_tools/AST.my.rb +14 -7
  97. data/lib/myco/code_tools/Parser.my +1 -1
  98. data/lib/myco/code_tools/parser/MycoBuilder.my +3 -3
  99. data/lib/myco/code_tools/parser/MycoBuilder.my.rb +3 -3
  100. data/lib/myco/code_tools/parser/MycoGrammar.my +67 -74
  101. data/lib/myco/code_tools/parser/MycoGrammar.my.rb +211 -316
  102. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeHelpers.my +3 -3
  103. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeHelpers.my.rb +2 -2
  104. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeInstructions.my +9 -9
  105. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeInstructions.my.rb +9 -9
  106. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeParser.my +2 -2
  107. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeParser.my.rb +4 -1
  108. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Grammar.my +2 -3
  109. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Grammar.my.rb +2 -3
  110. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Machine.my +1 -1
  111. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Machine.my.rb +1 -1
  112. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Processor.my +5 -5
  113. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Processor.my.rb +5 -5
  114. data/lib/myco/command.my +1 -1
  115. data/lib/myco/command.my.rb +1 -1
  116. data/lib/myco/core/BasicDecorators.my +10 -8
  117. data/lib/myco/core/BasicDecorators.my.rb +7 -7
  118. data/lib/myco/core/BasicObject.my +38 -7
  119. data/lib/myco/core/BasicObject.my.rb +23 -4
  120. data/lib/myco/tools/BasicCommand.my +1 -1
  121. data/lib/myco/tools/BasicCommand.my.rb +1 -1
  122. data/lib/myco/version.rb +1 -1
  123. data/lib/myco.rb +3 -0
  124. metadata +41 -26
  125. data/lib/myco/code_tools/AST/ConstantReopen.my +0 -29
  126. data/lib/myco/code_tools/AST/ConstantReopen.my.rb +0 -35
@@ -2,15 +2,18 @@
2
2
  CodeTools::AST << {
3
3
 
4
4
  ParameterAssembly < Node {
5
- var required: []
6
- var optional: []
7
- var splat: null
8
- var post: []
9
- var kwargs: []
10
- var kwrest: null
11
- var block: null
5
+ node_type params
6
+ field required: []
7
+ field optional: []
8
+ field rest: null
9
+ field post: []
10
+ field kwrequired: []
11
+ field kwoptional: []
12
+ field kwrest: null
13
+ field block: null
12
14
 
13
- Form: [:args, :required, :optional, :splat, :post, :kwargs, :kwrest, :block]
15
+ keywords_any?:
16
+ self.kwrequired.any? || self.kwoptional.any? || self.kwrest
14
17
 
15
18
  # Called on a new method or block generator
16
19
  # to set up various parameter-related properties.
@@ -21,17 +24,17 @@ CodeTools::AST << {
21
24
 
22
25
  g.total_args =
23
26
  self.required.size + self.optional.size + self.post.size
24
- + ((self.kwargs.any? || self.kwrest) &? 1 ?? 0)
27
+ + (self.keywords_any? &? 1 ?? 0)
25
28
 
26
29
  g.splat_index =
27
- self.splat &? (self.required.size + self.optional.size) ?? null
30
+ self.rest &? (self.required.size + self.optional.size) ?? null
28
31
 
29
32
  g.block_index = self.block && (
30
33
  self.required.size
31
34
  + self.optional.size
32
- + (self.splat &? 1 ?? 0)
35
+ + (self.rest &? 1 ?? 0)
33
36
  + self.post.size
34
- + ((self.kwargs.any? || self.kwrest) &? 1 ?? 0)
37
+ + (self.keywords_any? &? 1 ?? 0)
35
38
  + 1 # for self.block
36
39
  )
37
40
 
@@ -40,28 +43,12 @@ CodeTools::AST << {
40
43
  g.keywords = self.keyword_entries
41
44
  }
42
45
 
43
- # TODO: remove/refactor out
44
- required_and_optional_kwargs: {
45
- # TODO: perhaps make these be given separately?
46
- required_kwargs = []
47
- optional_kwargs = []
48
-
49
- self.kwargs.each |param| {
50
- # TODO: use nil or some other param.value to represent required kwarg
51
- (param.value.kind_of?(SymbolLiteral) && param.value.value == :"*")
52
- &? required_kwargs.push(param)
53
- ?? optional_kwargs.push(param)
54
- }
55
-
56
- ret = [required_kwargs, optional_kwargs]
57
- }
58
-
59
46
  # TODO: remove/refactor out
60
47
  keyword_entries: {
61
- entries = required_and_optional_kwargs
62
- entries.first.map! |x| { [x.name, true] }
63
- entries.last.map! |x| { [x.name, false] }
64
- entries = entries.flatten(2)
48
+ entries = \
49
+ kwrequired.map |x| { [x.name, true] }
50
+ + kwoptional.map |x| { [x.name, false] }
51
+ entries = entries.flatten(1)
65
52
  entries.empty? &? null ?? entries
66
53
  }
67
54
 
@@ -69,19 +56,9 @@ CodeTools::AST << {
69
56
  arity: {
70
57
  arity = self.required.size + self.post.size
71
58
 
72
- # Check for required kwargs
73
- kwargs_are_required = self.kwargs.select |param| {
74
- # TODO: use nil or some other param.value to represent required kwarg
75
- (param.value.kind_of?(SymbolLiteral) && param.value.value == :"*")
76
- }
77
-
78
- kwargs_are_required && (
79
- arity = arity + 1
80
- )
59
+ kwrequired.any? && (arity = arity + 1)
81
60
 
82
- (self.splat
83
- || self.optional.any?
84
- || (kwargs.any? && !kwargs_are_required)) && (
61
+ (self.rest || self.optional.any? || kwoptional.any?) && (
85
62
  arity = arity + 1
86
63
  arity = arity * -1
87
64
  )
@@ -89,79 +66,58 @@ CodeTools::AST << {
89
66
  arity
90
67
  }
91
68
 
92
- names: [
69
+ all_params: [
93
70
  *self.required,
94
- *self.optional.map(&:name),
95
- *(self.splat.is_a?(Symbol) &? [self.splat] ?? []),
71
+ *self.optional,
72
+ *(self.rest &? [self.rest] ?? []),
96
73
  *self.post,
97
- *self.kwargs.map(&:name),
98
- *(self.kwrest.is_a?(Symbol) &? [self.kwrest] ?? []),
99
- *(self.block &? [self.block.name] ?? []),
74
+ *self.kwrequired,
75
+ *self.kwoptional,
76
+ *(self.kwrest &? [self.kwrest] ?? []),
77
+ *(self.block &? [self.block] ?? []),
100
78
  ]
101
79
 
102
- map_locals: |scope| {
103
- self.required.each |name| { scope.new_local(name) }
104
- self.optional.each |var| { scope.assign_local_reference(var) }
105
- self.splat && (self.splat.is_a?(Symbol) &? scope.new_local(self.splat) ?? scope.new_local(:"*"))
106
- self.post.each |name| { scope.new_local(name) }
107
-
108
- (self.kwargs.any? || self.kwrest) && scope.new_local(:"__myco_kwargs_value__")
109
- self.kwargs.each |var| { scope.assign_local_reference(var) }
110
- self.kwrest && (self.kwrest.is_a?(Symbol) && scope.new_local(self.kwrest))
111
-
112
- self.block && scope.assign_local_reference(self.block)
113
- }
80
+ names: all_params.map(&:name).compact
114
81
 
115
82
  # TODO: simplify
116
83
  bytecode: |g| {
117
84
  g.state.check_for_locals = false
118
- self.map_locals(g.state.scope)
85
+ all_params.each |param| { param.map_local(g.state.scope) }
119
86
 
120
- self.optional.each |param| {
121
- done = g.new_label
122
-
123
- param.variable.get_bytecode(g)
124
- g.goto_if_not_undefined(done)
125
- param.bytecode(g)
126
- g.pop
127
-
128
- done.set!
129
- }
87
+ self.required.each |param| { param.bytecode(g) }
88
+ self.optional.each |param| { param.bytecode(g) }
89
+ self.rest && self.rest.bytecode(g)
130
90
 
131
- (self.kwargs.any? || self.kwrest) && (
91
+ self.keywords_any? && (
132
92
  kw_done = g.new_label
133
93
  assignments_label = g.new_label
134
94
  missing_value_label = g.new_label
135
95
  defaults_label = g.new_label
136
96
 
137
- kwargs_value_var = g.state.scope.search_local(:"__myco_kwargs_value__")
138
- kwargs_value_var.get_bytecode(g)
97
+ g.state.scope.search_local(:__myco_keywords_value__).get_bytecode(g)
139
98
 
140
- g.dup; g.goto_if_not_nil(assignments_label) # TODO: trivially remove this line?
99
+ g.dup_top; g.goto_if_not_nil(assignments_label) # TODO: trivially remove this line?
141
100
 
142
101
  g.pop
143
102
  g.push_cpath_top
144
- g.find_const(:"Hash")
103
+ g.find_const(:Hash)
145
104
  g.send(:allocate, 0, true)
146
105
 
147
106
  assignments_label.set!
148
107
 
149
- entries = self.required_and_optional_kwargs
150
- required_kwargs = entries.first
151
- optional_kwargs = entries.last
152
-
153
- required_kwargs.each |param| {
154
- g.dup
108
+ self.kwrequired.each |param| {
109
+ g.dup_top
155
110
 
156
111
  g.push_literal(param.name)
157
112
  g.send(:find_item, 1, true)
158
113
 
159
- g.dup
114
+ g.dup_top
160
115
  g.goto_if_false(missing_value_label)
161
116
 
162
117
  g.send(:value, 0, true)
163
118
 
164
- param.variable.set_bytecode(g)
119
+ param_var = g.state.scope.search_local(param.name)
120
+ param_var.set_bytecode(g)
165
121
  g.pop
166
122
  }
167
123
 
@@ -170,7 +126,7 @@ CodeTools::AST << {
170
126
  missing_value_label.set!
171
127
  g.pop
172
128
  g.push_rubinius
173
- g.find_const(:"Runtime")
129
+ g.find_const(:Runtime)
174
130
  g.swap
175
131
  g.send(:keywords_missing, 1, true)
176
132
  g.goto(kw_done)
@@ -179,41 +135,42 @@ CodeTools::AST << {
179
135
 
180
136
  extra_keys_label = g.new_label
181
137
 
182
- optional_kwargs.empty? &? (
183
- g.dup
138
+ self.kwoptional.empty? &? (
139
+ g.dup_top
184
140
  g.send(:size, 0, true)
185
- g.push(required_kwargs.size)
141
+ g.push(self.kwrequired.size)
186
142
  g.goto_if_not_equal(extra_keys_label)
187
143
 
188
- self.kwrest.is_a?(Symbol) && (
144
+ self.kwrest && (
189
145
  g.push_cpath_top
190
- g.find_const(:"Hash")
146
+ g.find_const(:Hash)
191
147
  g.send(:allocate, 0, true)
192
- kwrest_asgn = g.state.scope.search_local(self.kwrest)
148
+ kwrest_asgn = g.state.scope.search_local(self.kwrest.name)
193
149
  kwrest_asgn.set_bytecode(g)
194
150
  g.pop
195
151
  )
196
152
 
197
153
  g.goto(kw_done)
198
154
  ) ?? (
199
- optional_kwargs.each |arg| {
155
+ self.kwoptional.each |param| {
200
156
  next_value_label = g.new_label
201
157
  default_value_label = g.new_label
202
158
 
203
- g.dup
204
- g.push_literal(arg.name)
159
+ g.dup_top
160
+ g.push_literal(param.name)
205
161
  g.send(:find_item, 1, true)
206
162
 
207
- g.dup
163
+ g.dup_top
208
164
  g.goto_if_false(default_value_label)
209
165
 
210
166
  g.send(:value, 0, true)
211
- arg.variable.set_bytecode(g)
167
+ g.state.scope.search_local(param.name).set_bytecode(g)
212
168
  g.goto(next_value_label)
213
169
 
214
170
  default_value_label.set!
215
171
  g.pop
216
- arg.bytecode(g)
172
+ param.value.bytecode(g)
173
+ g.state.scope.search_local(param.name).set_bytecode(g)
217
174
 
218
175
  next_value_label.set!
219
176
  g.pop
@@ -222,16 +179,16 @@ CodeTools::AST << {
222
179
 
223
180
  extra_keys_label.set!
224
181
 
225
- g.dup
182
+ g.dup_top
226
183
  g.push_rubinius
227
- g.find_const(:"Runtime")
184
+ g.find_const(:Runtime)
228
185
  g.swap
229
186
 
230
187
  self.kwrest &? g.push(:true) ?? g.push(:false)
231
188
 
232
189
  g.send(:keywords_extra, 2, true)
233
- self.kwrest.is_a?(Symbol) && (
234
- kwrest_asgn = g.state.scope.search_local(self.kwrest)
190
+ self.kwrest && (
191
+ kwrest_asgn = g.state.scope.search_local(self.kwrest.name)
235
192
  kwrest_asgn.set_bytecode(g)
236
193
  )
237
194
  g.pop
@@ -2,23 +2,16 @@
2
2
  ::Myco::Component.new([::Myco::FileToplevel], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
3
3
  .tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco.find_constant(:CodeTools)::AST.component_eval {(::Myco.cscope.for_method_definition::ParameterAssembly = ::Myco::Component.new([::Myco.find_constant(:Node)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
4
4
  .tap { |__c__| __c__.__last__ = __c__.component_eval {(
5
- declare_meme(:required, [[:var, []]], nil, ::Myco.cscope.dup) { |*| ([])}
6
- declare_meme(:optional, [[:var, []]], nil, ::Myco.cscope.dup) { |*| ([])}
7
- declare_meme(:splat, [[:var, []]], nil, ::Myco.cscope.dup) { |*| (nil)}
8
- declare_meme(:post, [[:var, []]], nil, ::Myco.cscope.dup) { |*| ([])}
9
- declare_meme(:kwargs, [[:var, []]], nil, ::Myco.cscope.dup) { |*| ([])}
10
- declare_meme(:kwrest, [[:var, []]], nil, ::Myco.cscope.dup) { |*| (nil)}
11
- declare_meme(:block, [[:var, []]], nil, ::Myco.cscope.dup) { |*| (nil)}
12
- ::Myco.cscope.for_method_definition::Form = ([
13
- :args,
14
- :required,
15
- :optional,
16
- :splat,
17
- :post,
18
- :kwargs,
19
- :kwrest,
20
- :block
21
- ])
5
+ declare_meme(:params, [[:node_type, []]], nil, ::Myco.cscope.dup) { |*| nil}
6
+ declare_meme(:required, [[:field, []]], nil, ::Myco.cscope.dup) { |*| ([])}
7
+ declare_meme(:optional, [[:field, []]], nil, ::Myco.cscope.dup) { |*| ([])}
8
+ declare_meme(:rest, [[:field, []]], nil, ::Myco.cscope.dup) { |*| (nil)}
9
+ declare_meme(:post, [[:field, []]], nil, ::Myco.cscope.dup) { |*| ([])}
10
+ declare_meme(:kwrequired, [[:field, []]], nil, ::Myco.cscope.dup) { |*| ([])}
11
+ declare_meme(:kwoptional, [[:field, []]], nil, ::Myco.cscope.dup) { |*| ([])}
12
+ declare_meme(:kwrest, [[:field, []]], nil, ::Myco.cscope.dup) { |*| (nil)}
13
+ declare_meme(:block, [[:field, []]], nil, ::Myco.cscope.dup) { |*| (nil)}
14
+ declare_meme(:keywords_any?, [], nil, ::Myco.cscope.dup) { |*| (::Myco.branch_op(:"||", ::Myco.branch_op(:"||", self.kwrequired.__send__(:any?)) {self.kwoptional.__send__(:any?)}) {self.kwrest})}
22
15
  declare_meme(:generator_setup, [], nil, ::Myco.cscope.dup) { |g| (
23
16
  g.__send__(
24
17
  :required_args=,
@@ -41,12 +34,12 @@
41
34
  self.post.size
42
35
  ).__send__(
43
36
  :+,
44
- ::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", ::Myco.branch_op(:"||", self.kwargs.__send__(:any?)) {self.kwrest}) {1}) {0}
37
+ ::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", self.__send__(:keywords_any?)) {1}) {0}
45
38
  )
46
39
  )
47
40
  g.__send__(
48
41
  :splat_index=,
49
- ::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", self.splat) {self.required.size.__send__(
42
+ ::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", self.rest) {self.required.size.__send__(
50
43
  :+,
51
44
  self.optional.size
52
45
  )}) {nil}
@@ -58,13 +51,13 @@
58
51
  self.optional.size
59
52
  ).__send__(
60
53
  :+,
61
- ::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", self.splat) {1}) {0}
54
+ ::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", self.rest) {1}) {0}
62
55
  ).__send__(
63
56
  :+,
64
57
  self.post.size
65
58
  ).__send__(
66
59
  :+,
67
- ::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", ::Myco.branch_op(:"||", self.kwargs.__send__(:any?)) {self.kwrest}) {1}) {0}
60
+ ::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", self.__send__(:keywords_any?)) {1}) {0}
68
61
  ).__send__(
69
62
  :+,
70
63
  1
@@ -79,32 +72,18 @@
79
72
  self.keyword_entries
80
73
  )
81
74
  )}
82
- declare_meme(:required_and_optional_kwargs, [], nil, ::Myco.cscope.dup) { |*| (
83
- required_kwargs = []
84
- optional_kwargs = []
85
- self.kwargs.each { |param| (::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", ::Myco.branch_op(:"&&", param.value.__send__(
86
- :kind_of?,
87
- ::Myco.find_constant(:SymbolLiteral)
88
- )) {param.value.value.__send__(
89
- :==,
90
- :*
91
- )}) {required_kwargs.push(param)}) {optional_kwargs.push(param)})}
92
- ret = [
93
- required_kwargs,
94
- optional_kwargs
95
- ]
96
- )}
97
75
  declare_meme(:keyword_entries, [], nil, ::Myco.cscope.dup) { |*| (
98
- entries = self.required_and_optional_kwargs
99
- entries.first.__send__(:map!) { |x| ([
76
+ entries = self.kwrequired.map { |x| ([
100
77
  x.name,
101
78
  true
102
- ])}
103
- entries.last.__send__(:map!) { |x| ([
104
- x.name,
105
- false
106
- ])}
107
- entries = entries.flatten(2)
79
+ ])}.__send__(
80
+ :+,
81
+ self.kwoptional.map { |x| ([
82
+ x.name,
83
+ false
84
+ ])}
85
+ )
86
+ entries = entries.flatten(1)
108
87
  ::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", entries.__send__(:empty?)) {nil}) {entries}
109
88
  )}
110
89
  declare_meme(:arity, [], nil, ::Myco.cscope.dup) { |*| (
@@ -112,18 +91,11 @@
112
91
  :+,
113
92
  self.post.size
114
93
  )
115
- kwargs_are_required = self.kwargs.select { |param| (::Myco.branch_op(:"&&", param.value.__send__(
116
- :kind_of?,
117
- ::Myco.find_constant(:SymbolLiteral)
118
- )) {param.value.value.__send__(
119
- :==,
120
- :*
121
- )})}
122
- ::Myco.branch_op(:"&&", kwargs_are_required) {arity = arity.__send__(
94
+ ::Myco.branch_op(:"&&", self.kwrequired.__send__(:any?)) {arity = arity.__send__(
123
95
  :+,
124
96
  1
125
97
  )}
126
- ::Myco.branch_op(:"&&", ::Myco.branch_op(:"||", ::Myco.branch_op(:"||", self.splat) {self.optional.__send__(:any?)}) {::Myco.branch_op(:"&&", self.kwargs.__send__(:any?)) {kwargs_are_required.__send__(:!)}}) {(
98
+ ::Myco.branch_op(:"&&", ::Myco.branch_op(:"||", ::Myco.branch_op(:"||", self.rest) {self.optional.__send__(:any?)}) {self.kwoptional.__send__(:any?)}) {(
127
99
  arity = arity.__send__(
128
100
  :+,
129
101
  1
@@ -135,59 +107,33 @@
135
107
  )}
136
108
  arity
137
109
  )}
138
- declare_meme(:names, [], nil, ::Myco.cscope.dup) { |*| ([
110
+ declare_meme(:all_params, [], nil, ::Myco.cscope.dup) { |*| ([
139
111
  *self.required,
140
- *self.optional.map(&:name),
141
- *::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", self.splat.__send__(
142
- :is_a?,
143
- ::Myco.find_constant(:Symbol)
144
- )) {[self.splat]}) {[]},
112
+ *self.optional,
113
+ *::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", self.rest) {[self.rest]}) {[]},
145
114
  *self.post,
146
- *self.kwargs.map(&:name),
147
- *::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", self.kwrest.__send__(
148
- :is_a?,
149
- ::Myco.find_constant(:Symbol)
150
- )) {[self.kwrest]}) {[]},
151
- *::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", self.block) {[self.block.name]}) {[]}
115
+ *self.kwrequired,
116
+ *self.kwoptional,
117
+ *::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", self.kwrest) {[self.kwrest]}) {[]},
118
+ *::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", self.block) {[self.block]}) {[]}
152
119
  ])}
153
- declare_meme(:map_locals, [], nil, ::Myco.cscope.dup) { |scope| (
154
- self.required.each { |name| (scope.new_local(name))}
155
- self.optional.each { |var| (scope.assign_local_reference(var))}
156
- ::Myco.branch_op(:"&&", self.splat) {::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", self.splat.__send__(
157
- :is_a?,
158
- ::Myco.find_constant(:Symbol)
159
- )) {scope.new_local(self.splat)}) {scope.new_local(:*)}}
160
- self.post.each { |name| (scope.new_local(name))}
161
- ::Myco.branch_op(:"&&", ::Myco.branch_op(:"||", self.kwargs.__send__(:any?)) {self.kwrest}) {scope.new_local(:__myco_kwargs_value__)}
162
- self.kwargs.each { |var| (scope.assign_local_reference(var))}
163
- ::Myco.branch_op(:"&&", self.kwrest) {::Myco.branch_op(:"&&", self.kwrest.__send__(
164
- :is_a?,
165
- ::Myco.find_constant(:Symbol)
166
- )) {scope.new_local(self.kwrest)}}
167
- ::Myco.branch_op(:"&&", self.block) {scope.assign_local_reference(self.block)}
168
- )}
120
+ declare_meme(:names, [], nil, ::Myco.cscope.dup) { |*| (self.all_params.map(&:name).compact)}
169
121
  declare_meme(:bytecode, [], nil, ::Myco.cscope.dup) { |g| (
170
122
  g.state.__send__(
171
123
  :check_for_locals=,
172
124
  false
173
125
  )
174
- self.map_locals(g.state.scope)
175
- self.optional.each { |param| (
176
- done = g.new_label
177
- param.variable.get_bytecode(g)
178
- g.goto_if_not_undefined(done)
179
- param.bytecode(g)
180
- g.pop
181
- done.__send__(:set!)
182
- )}
183
- ::Myco.branch_op(:"&&", ::Myco.branch_op(:"||", self.kwargs.__send__(:any?)) {self.kwrest}) {(
126
+ self.all_params.each { |param| (param.map_local(g.state.scope))}
127
+ self.required.each { |param| (param.bytecode(g))}
128
+ self.optional.each { |param| (param.bytecode(g))}
129
+ ::Myco.branch_op(:"&&", self.rest) {self.rest.bytecode(g)}
130
+ ::Myco.branch_op(:"&&", self.__send__(:keywords_any?)) {(
184
131
  kw_done = g.new_label
185
132
  assignments_label = g.new_label
186
133
  missing_value_label = g.new_label
187
134
  defaults_label = g.new_label
188
- kwargs_value_var = g.state.scope.search_local(:__myco_kwargs_value__)
189
- kwargs_value_var.get_bytecode(g)
190
- g.dup
135
+ g.state.scope.search_local(:__myco_keywords_value__).get_bytecode(g)
136
+ g.dup_top
191
137
  g.goto_if_not_nil(assignments_label)
192
138
  g.pop
193
139
  g.push_cpath_top
@@ -198,25 +144,23 @@
198
144
  true
199
145
  )
200
146
  assignments_label.__send__(:set!)
201
- entries = self.required_and_optional_kwargs
202
- required_kwargs = entries.first
203
- optional_kwargs = entries.last
204
- required_kwargs.each { |param| (
205
- g.dup
147
+ self.kwrequired.each { |param| (
148
+ g.dup_top
206
149
  g.push_literal(param.name)
207
150
  g.send(
208
151
  :find_item,
209
152
  1,
210
153
  true
211
154
  )
212
- g.dup
155
+ g.dup_top
213
156
  g.goto_if_false(missing_value_label)
214
157
  g.send(
215
158
  :value,
216
159
  0,
217
160
  true
218
161
  )
219
- param.variable.set_bytecode(g)
162
+ param_var = g.state.scope.search_local(param.name)
163
+ param_var.set_bytecode(g)
220
164
  g.pop
221
165
  )}
222
166
  g.goto(defaults_label)
@@ -233,19 +177,16 @@
233
177
  g.goto(kw_done)
234
178
  defaults_label.__send__(:set!)
235
179
  extra_keys_label = g.new_label
236
- ::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", optional_kwargs.__send__(:empty?)) {(
237
- g.dup
180
+ ::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", self.kwoptional.__send__(:empty?)) {(
181
+ g.dup_top
238
182
  g.send(
239
183
  :size,
240
184
  0,
241
185
  true
242
186
  )
243
- g.push(required_kwargs.size)
187
+ g.push(self.kwrequired.size)
244
188
  g.goto_if_not_equal(extra_keys_label)
245
- ::Myco.branch_op(:"&&", self.kwrest.__send__(
246
- :is_a?,
247
- ::Myco.find_constant(:Symbol)
248
- )) {(
189
+ ::Myco.branch_op(:"&&", self.kwrest) {(
249
190
  g.push_cpath_top
250
191
  g.find_const(:Hash)
251
192
  g.send(
@@ -253,38 +194,39 @@
253
194
  0,
254
195
  true
255
196
  )
256
- kwrest_asgn = g.state.scope.search_local(self.kwrest)
197
+ kwrest_asgn = g.state.scope.search_local(self.kwrest.name)
257
198
  kwrest_asgn.set_bytecode(g)
258
199
  g.pop
259
200
  )}
260
201
  g.goto(kw_done)
261
- )}) {optional_kwargs.each { |arg| (
202
+ )}) {self.kwoptional.each { |param| (
262
203
  next_value_label = g.new_label
263
204
  default_value_label = g.new_label
264
- g.dup
265
- g.push_literal(arg.name)
205
+ g.dup_top
206
+ g.push_literal(param.name)
266
207
  g.send(
267
208
  :find_item,
268
209
  1,
269
210
  true
270
211
  )
271
- g.dup
212
+ g.dup_top
272
213
  g.goto_if_false(default_value_label)
273
214
  g.send(
274
215
  :value,
275
216
  0,
276
217
  true
277
218
  )
278
- arg.variable.set_bytecode(g)
219
+ g.state.scope.search_local(param.name).set_bytecode(g)
279
220
  g.goto(next_value_label)
280
221
  default_value_label.__send__(:set!)
281
222
  g.pop
282
- arg.bytecode(g)
223
+ param.value.bytecode(g)
224
+ g.state.scope.search_local(param.name).set_bytecode(g)
283
225
  next_value_label.__send__(:set!)
284
226
  g.pop
285
227
  )}}
286
228
  extra_keys_label.__send__(:set!)
287
- g.dup
229
+ g.dup_top
288
230
  g.push_rubinius
289
231
  g.find_const(:Runtime)
290
232
  g.swap
@@ -294,11 +236,8 @@
294
236
  2,
295
237
  true
296
238
  )
297
- ::Myco.branch_op(:"&&", self.kwrest.__send__(
298
- :is_a?,
299
- ::Myco.find_constant(:Symbol)
300
- )) {(
301
- kwrest_asgn = g.state.scope.search_local(self.kwrest)
239
+ ::Myco.branch_op(:"&&", self.kwrest) {(
240
+ kwrest_asgn = g.state.scope.search_local(self.kwrest.name)
302
241
  kwrest_asgn.set_bytecode(g)
303
242
  )}
304
243
  g.pop
@@ -2,9 +2,8 @@
2
2
  CodeTools::AST << {
3
3
 
4
4
  PipeOperator < Node {
5
- var value, var invoke
6
-
7
- Form: [:pipe_op, :value, :invoke]
5
+ node_type pipe_op
6
+ field value, field invoke
8
7
 
9
8
  implementation_args: ArgumentAssembly.new(
10
9
  line: self.line
@@ -2,13 +2,9 @@
2
2
  ::Myco::Component.new([::Myco::FileToplevel], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
3
3
  .tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco.find_constant(:CodeTools)::AST.component_eval {(::Myco.cscope.for_method_definition::PipeOperator = ::Myco::Component.new([::Myco.find_constant(:Node)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
4
4
  .tap { |__c__| __c__.__last__ = __c__.component_eval {(
5
- declare_meme(:value, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
6
- declare_meme(:invoke, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
7
- ::Myco.cscope.for_method_definition::Form = ([
8
- :pipe_op,
9
- :value,
10
- :invoke
11
- ])
5
+ declare_meme(:pipe_op, [[:node_type, []]], nil, ::Myco.cscope.dup) { |*| nil}
6
+ declare_meme(:value, [[:field, []]], nil, ::Myco.cscope.dup) { |*| nil}
7
+ declare_meme(:invoke, [[:field, []]], nil, ::Myco.cscope.dup) { |*| nil}
12
8
  declare_meme(:implementation_args, [], nil, ::Myco.cscope.dup) { |*| (::Myco.find_constant(:ArgumentAssembly).new({
13
9
  :line => self.line,
14
10
  :body => [self.value].__send__(