myco 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/myco/bootstrap.my.rb +6 -15
- data/lib/myco/command/inoculate.my.rb +71 -122
- data/lib/myco/command.my.rb +26 -69
- data/lib/myco/core/BasicDecorators.my.rb +65 -126
- data/lib/myco/core/BasicObject.my.rb +19 -42
- data/lib/myco/core/Category.my.rb +9 -18
- data/lib/myco/core/Decorator.my.rb +32 -51
- data/lib/myco/core/FileToplevel.my.rb +20 -41
- data/lib/myco/core/Object.my.rb +24 -53
- data/lib/myco/core/Switch.my.rb +52 -73
- data/lib/myco/parser/ast/ToRuby.my +1 -1
- data/lib/myco/parser/ast/ToRuby.my.rb +375 -566
- data/lib/myco/tools/BasicCommand.my.rb +55 -78
- data/lib/myco/tools/mycompile.my.rb +53 -112
- data/lib/myco/version.rb +1 -1
- metadata +13 -14
@@ -1,574 +1,383 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
.
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
], ::Myco.cscope.
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
)}
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
)}
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
)
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
)}
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
)
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
)
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
g.add("nil")
|
147
|
-
)}
|
148
|
-
)}
|
149
|
-
::Myco.find_constant(:VoidLiteral).component_eval {(
|
150
|
-
declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
151
|
-
g.add("::Myco::Void")
|
152
|
-
)}
|
153
|
-
)}
|
154
|
-
::Myco.find_constant(:TrueLiteral).component_eval {(
|
155
|
-
declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
156
|
-
g.add("true")
|
157
|
-
)}
|
158
|
-
)}
|
159
|
-
::Myco.find_constant(:FalseLiteral).component_eval {(
|
160
|
-
declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
161
|
-
g.add("false")
|
162
|
-
)}
|
163
|
-
)}
|
164
|
-
::Myco.find_constant(:StringLiteral).component_eval {(
|
165
|
-
declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
166
|
-
g.add(self.string.inspect)
|
167
|
-
)}
|
168
|
-
)}
|
169
|
-
::Myco.find_constant(:SymbolLiteral).component_eval {(
|
170
|
-
declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
171
|
-
g.add(self.value.inspect)
|
172
|
-
)}
|
173
|
-
)}
|
174
|
-
::Myco.find_constant(:DynamicString).component_eval {(
|
175
|
-
declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
176
|
-
inspect_escape = ::Myco.find_constant(:Proc).new { |str| (
|
177
|
-
str.inspect.slice(::Range.new(
|
178
|
-
1,
|
179
|
-
-2
|
180
|
-
))
|
181
|
-
)}
|
182
|
-
g.add("\"")
|
183
|
-
g.add(inspect_escape.call(self.string))
|
184
|
-
self.array.each_slice(2) { |interpolated, inner_string| (
|
185
|
-
g.add("\#{")
|
186
|
-
g.add(interpolated.value)
|
187
|
-
g.add("}")
|
188
|
-
g.add(inspect_escape.call(inner_string.value))
|
189
|
-
)}
|
190
|
-
g.add("\"")
|
191
|
-
)}
|
192
|
-
)}
|
193
|
-
::Myco.find_constant(:DynamicSymbol).component_eval {(
|
194
|
-
declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
195
|
-
g.add(":")
|
196
|
-
::Myco.find_constant(:DynamicString).instance_method(:to_ruby).bind(self).call(g)
|
197
|
-
)}
|
198
|
-
)}
|
199
|
-
::Myco.find_constant(:HashLiteral).component_eval {(
|
200
|
-
declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
201
|
-
g.add("{")
|
202
|
-
g.list(
|
203
|
-
self.array.each_slice(2).to_a,
|
204
|
-
",",
|
205
|
-
{
|
206
|
-
:auto_lines => true
|
207
|
-
}
|
208
|
-
) { |pair| (
|
209
|
-
g.add(
|
210
|
-
pair.first,
|
211
|
-
" => ",
|
212
|
-
pair.last
|
213
|
-
)
|
214
|
-
)}
|
215
|
-
g.add("}")
|
216
|
-
)}
|
217
|
-
)}
|
218
|
-
::Myco.find_constant(:ArrayAssembly).component_eval {(
|
219
|
-
declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
220
|
-
g.add("[")
|
221
|
-
g.list(
|
222
|
-
self.body,
|
223
|
-
",",
|
224
|
-
{
|
225
|
-
:auto_lines => true
|
226
|
-
}
|
227
|
-
)
|
228
|
-
g.add("]")
|
229
|
-
)}
|
230
|
-
)}
|
231
|
-
::Myco.find_constant(:ScopedConstant).component_eval {(
|
232
|
-
declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
233
|
-
g.add(self.parent)
|
234
|
-
g.add("::#{self.name}")
|
235
|
-
)}
|
236
|
-
declare_meme(:to_ruby_assign, [], nil, ::Myco.cscope.dup) { |g, value| (
|
237
|
-
self.to_ruby(g)
|
238
|
-
g.add(" = ")
|
239
|
-
g.add(value)
|
240
|
-
)}
|
241
|
-
)}
|
242
|
-
::Myco.find_constant(:ToplevelConstant).component_eval {(
|
243
|
-
declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
244
|
-
g.add("::#{self.name}")
|
245
|
-
)}
|
246
|
-
declare_meme(:to_ruby_assign, [], nil, ::Myco.cscope.dup) { |g, value| (
|
247
|
-
self.to_ruby(g)
|
248
|
-
g.add(" = ")
|
249
|
-
g.add(value)
|
250
|
-
)}
|
251
|
-
)}
|
252
|
-
::Myco.find_constant(:ConstantAccess).component_eval {(
|
253
|
-
declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
254
|
-
g.add("::Myco.find_constant(#{self.name.inspect})")
|
255
|
-
)}
|
256
|
-
declare_meme(:to_ruby_assign, [], nil, ::Myco.cscope.dup) { |g, value| (
|
257
|
-
g.add("::Myco.cscope.for_method_definition.const_set(#{self.name.inspect}, ")
|
258
|
-
g.add(value)
|
259
|
-
g.add(")")
|
260
|
-
)}
|
261
|
-
)}
|
262
|
-
::Myco.find_constant(:ConstantAssignment).component_eval {(
|
263
|
-
declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
264
|
-
self.constant.to_ruby_assign(
|
265
|
-
g,
|
266
|
-
self.value
|
267
|
-
)
|
268
|
-
)}
|
269
|
-
)}
|
270
|
-
::Myco.find_constant(:ConstantDefine).component_eval {(
|
271
|
-
declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
272
|
-
g.add(self.implementation)
|
273
|
-
g.line(".tap { |__c__| __c__.__name__ = ")
|
274
|
-
g.add(self.name.name.inspect)
|
275
|
-
g.add(" }")
|
276
|
-
)}
|
277
|
-
)}
|
278
|
-
::Myco.find_constant(:ConstantReopen).component_eval {(
|
279
|
-
declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
280
|
-
g.add(self.name)
|
281
|
-
g.add(".component_eval {")
|
282
|
-
g.add(self.body)
|
283
|
-
g.add("}")
|
284
|
-
)}
|
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 {(
|
4
|
+
::Myco.cscope.for_method_definition.const_set(:ToRuby, ::Myco::Component.new([::Myco::Object], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
5
|
+
.tap { |__c__| __c__.__last__ = __c__.component_eval {(
|
6
|
+
declare_meme(:lines, [[:var, []]], nil, ::Myco.cscope.dup) { |*| ([""])}
|
7
|
+
declare_meme(:to_s, [], nil, ::Myco.cscope.dup) { |*| (self.lines.join("\n"))}
|
8
|
+
declare_meme(:add, [], nil, ::Myco.cscope.dup) { |*strings| (strings.each { |string| (::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", string.__send__(
|
9
|
+
:is_a?,
|
10
|
+
::Myco.find_constant(:String)
|
11
|
+
)) {self.lines.last.concat(string.dup)}) {string.to_ruby(self)})})}
|
12
|
+
declare_meme(:line, [], nil, ::Myco.cscope.dup) { |*strings| (
|
13
|
+
self.lines.push(self.indents.last.dup)
|
14
|
+
self.add(*strings)
|
15
|
+
)}
|
16
|
+
declare_meme(:list, [], nil, ::Myco.cscope.dup) { |items, separator="", auto_lines:false, &block| (::Myco.branch_op(:"&&", items.__send__(:any?)) {(
|
17
|
+
items = items.dup
|
18
|
+
last_item = items.pop
|
19
|
+
use_lines = ::Myco.branch_op(:"&&", items.__send__(:any?)) {auto_lines}
|
20
|
+
::Myco.branch_op(:"&&", use_lines) {self.push_indent}
|
21
|
+
items.each { |item| (
|
22
|
+
::Myco.branch_op(:"&&", use_lines) {self.line}
|
23
|
+
::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", block) {block.call(item)}) {self.add(item)}
|
24
|
+
self.add(separator)
|
25
|
+
)}
|
26
|
+
::Myco.branch_op(:"&&", use_lines) {self.line}
|
27
|
+
::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", block) {block.call(last_item)}) {self.add(last_item)}
|
28
|
+
::Myco.branch_op(:"&&", use_lines) {self.pop_indent}
|
29
|
+
::Myco.branch_op(:"&&", use_lines) {self.line}
|
30
|
+
)})}
|
31
|
+
declare_meme(:indents, [[:var, []]], nil, ::Myco.cscope.dup) { |*| ([""])}
|
32
|
+
declare_meme(:indent_amount, [[:var, []]], nil, ::Myco.cscope.dup) { |*| (2)}
|
33
|
+
declare_meme(:pop_indent, [], nil, ::Myco.cscope.dup) { |*| (self.indents.pop)}
|
34
|
+
declare_meme(:push_indent, [], nil, ::Myco.cscope.dup) { |amount=self.indent_amount| (self.indents.push(self.indents.last.__send__(
|
35
|
+
:+,
|
36
|
+
" ".__send__(
|
37
|
+
:*,
|
38
|
+
amount
|
39
|
+
)
|
40
|
+
)))}
|
41
|
+
declare_meme(:var_scopes, [[:var, []]], nil, ::Myco.cscope.dup) { |*| ([])}
|
42
|
+
declare_meme(:var_scope, [], nil, ::Myco.cscope.dup) { |*| (self.var_scopes.last)}
|
43
|
+
declare_meme(:with_nested_var_scope, [], nil, ::Myco.cscope.dup) { |node, &block| (
|
44
|
+
self.var_scopes.push(node)
|
45
|
+
block.call
|
46
|
+
self.var_scopes.pop
|
47
|
+
)}
|
48
|
+
declare_meme(:var_scope_declare_local, [], nil, ::Myco.cscope.dup) { |name| (self.var_scope.variables.__send__(
|
49
|
+
:[]=,
|
50
|
+
name,
|
51
|
+
true
|
52
|
+
))}
|
53
|
+
declare_meme(:var_scope_declare_locals, [], nil, ::Myco.cscope.dup) { |*names| (names.each { |name| (self.var_scope_declare_local(name))})}
|
54
|
+
declare_meme(:var_scope_has_local?, [], nil, ::Myco.cscope.dup) { |name| (self.var_scopes.reverse.detect { |scope| (scope.variables.__send__(
|
55
|
+
:has_key?,
|
56
|
+
name
|
57
|
+
))}.__send__(:!).__send__(:!))}
|
58
|
+
declare_meme(:easy_ident?, [], nil, ::Myco.cscope.dup) { |sym| (
|
59
|
+
str = sym.to_s
|
60
|
+
::Myco.branch_op(:"&&", str.__send__(
|
61
|
+
:=~,
|
62
|
+
::Myco.find_constant(:Regexp).new("^[a-z_][A-Za-z_]*$")
|
63
|
+
)) {[
|
64
|
+
:if,
|
65
|
+
:unless,
|
66
|
+
:and,
|
67
|
+
:or,
|
68
|
+
:def,
|
69
|
+
:do,
|
70
|
+
:class,
|
71
|
+
:module,
|
72
|
+
:end,
|
73
|
+
:break,
|
74
|
+
:begin,
|
75
|
+
:rescue,
|
76
|
+
:ensure
|
77
|
+
].__send__(
|
78
|
+
:include?,
|
79
|
+
sym
|
80
|
+
).__send__(:!)}
|
81
|
+
)}
|
82
|
+
)}})
|
83
|
+
.tap { |__c__| __c__.__name__ = :ToRuby }
|
84
|
+
::Myco.find_constant(:Node).component_eval {(declare_meme(:to_ruby_code, [], nil, ::Myco.cscope.dup) { |*| (
|
85
|
+
g = ::Myco.find_constant(:ToRuby).new
|
86
|
+
self.to_ruby(g)
|
87
|
+
g.to_s
|
88
|
+
)})}
|
89
|
+
::Myco.find_constant(:Self).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (g.add("self"))})}
|
90
|
+
::Myco.find_constant(:NullLiteral).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (g.add("nil"))})}
|
91
|
+
::Myco.find_constant(:VoidLiteral).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (g.add("::Myco::Void"))})}
|
92
|
+
::Myco.find_constant(:TrueLiteral).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (g.add("true"))})}
|
93
|
+
::Myco.find_constant(:FalseLiteral).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (g.add("false"))})}
|
94
|
+
::Myco.find_constant(:StringLiteral).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (g.add(self.string.inspect))})}
|
95
|
+
::Myco.find_constant(:SymbolLiteral).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (g.add(self.value.inspect))})}
|
96
|
+
::Myco.find_constant(:DynamicString).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
97
|
+
inspect_escape = ::Myco.find_constant(:Proc).new { |str| (str.inspect.slice(::Range.new(
|
98
|
+
1,
|
99
|
+
-2
|
100
|
+
)))}
|
101
|
+
g.add("\"")
|
102
|
+
g.add(inspect_escape.call(self.string))
|
103
|
+
self.array.each_slice(2) { |interpolated, inner_string| (
|
104
|
+
g.add("\#{")
|
105
|
+
g.add(interpolated.value)
|
106
|
+
g.add("}")
|
107
|
+
g.add(inspect_escape.call(inner_string.value))
|
108
|
+
)}
|
109
|
+
g.add("\"")
|
110
|
+
)})}
|
111
|
+
::Myco.find_constant(:DynamicSymbol).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
112
|
+
g.add(":")
|
113
|
+
::Myco.find_constant(:DynamicString).instance_method(:to_ruby).bind(self).call(g)
|
114
|
+
)})}
|
115
|
+
::Myco.find_constant(:HashLiteral).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
116
|
+
g.add("{")
|
117
|
+
g.list(
|
118
|
+
self.array.each_slice(2).to_a,
|
119
|
+
",",
|
120
|
+
{:auto_lines => true}
|
121
|
+
) { |pair| (g.add(
|
122
|
+
pair.first,
|
123
|
+
" => ",
|
124
|
+
pair.last
|
125
|
+
))}
|
126
|
+
g.add("}")
|
127
|
+
)})}
|
128
|
+
::Myco.find_constant(:ArrayAssembly).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
129
|
+
g.add("[")
|
130
|
+
g.list(
|
131
|
+
self.body,
|
132
|
+
",",
|
133
|
+
{:auto_lines => true}
|
134
|
+
)
|
135
|
+
g.add("]")
|
136
|
+
)})}
|
137
|
+
::Myco.find_constant(:ScopedConstant).component_eval {(
|
138
|
+
declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
139
|
+
g.add(self.parent)
|
140
|
+
g.add("::#{self.name}")
|
141
|
+
)}
|
142
|
+
declare_meme(:to_ruby_assign, [], nil, ::Myco.cscope.dup) { |g, value| (
|
143
|
+
self.to_ruby(g)
|
144
|
+
g.add(" = ")
|
145
|
+
g.add(value)
|
285
146
|
)}
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
)
|
292
|
-
|
293
|
-
::Myco.find_constant(:EvalExpression).component_eval {(
|
294
|
-
declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
295
|
-
g.add(self.body)
|
296
|
-
)}
|
297
|
-
)}
|
298
|
-
::Myco.find_constant(:DeclareFile).component_eval {(
|
299
|
-
declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
300
|
-
self.implementation.to_ruby(g)
|
301
|
-
)}
|
302
|
-
)}
|
303
|
-
::Myco.find_constant(:DeclareObject).component_eval {(
|
304
|
-
declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
305
|
-
g.add("::Myco::Component.new(")
|
306
|
-
g.add(self.types)
|
307
|
-
g.add(", ::Myco.cscope.for_method_definition, __FILE__, __LINE__)")
|
308
|
-
g.line(".tap { |__c__| __c__.__last__ = __c__.component_eval {")
|
309
|
-
g.add(self.scope_implementation)
|
310
|
-
g.add("}}")
|
311
|
-
::Myco.branch_op(:"&&", self.create) {g.add(".instance")}
|
312
|
-
)}
|
313
|
-
)}
|
314
|
-
::Myco.find_constant(:DeclareString).component_eval {(
|
315
|
-
declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
316
|
-
g.add(self.implementation)
|
317
|
-
)}
|
318
|
-
)}
|
319
|
-
::Myco.find_constant(:DeclareCategory).component_eval {(
|
320
|
-
declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
321
|
-
g.add("__category__(#{self.name.value.inspect})")
|
322
|
-
g.add(".component_eval {")
|
323
|
-
g.add(self.body)
|
324
|
-
g.add("}")
|
325
|
-
)}
|
326
|
-
)}
|
327
|
-
::Myco.find_constant(:DeclareMeme).component_eval {(
|
328
|
-
declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
329
|
-
g.with_nested_var_scope(self.body_implementation) { || (
|
330
|
-
g.var_scope_declare_locals(*self.arguments.names)
|
331
|
-
g.add("declare_meme(")
|
332
|
-
g.add("#{self.name.inspect}, ")
|
333
|
-
g.add(self.decorations)
|
334
|
-
g.add(", nil, ::Myco.cscope.dup)")
|
335
|
-
g.add(" { ")
|
336
|
-
g.add(self.arguments)
|
337
|
-
g.add(" ")
|
338
|
-
g.add(self.body)
|
339
|
-
g.add("}")
|
340
|
-
)}
|
341
|
-
)}
|
147
|
+
)}
|
148
|
+
::Myco.find_constant(:ToplevelConstant).component_eval {(
|
149
|
+
declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (g.add("::#{self.name}"))}
|
150
|
+
declare_meme(:to_ruby_assign, [], nil, ::Myco.cscope.dup) { |g, value| (
|
151
|
+
self.to_ruby(g)
|
152
|
+
g.add(" = ")
|
153
|
+
g.add(value)
|
342
154
|
)}
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
)
|
155
|
+
)}
|
156
|
+
::Myco.find_constant(:ConstantAccess).component_eval {(
|
157
|
+
declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (g.add("::Myco.find_constant(#{self.name.inspect})"))}
|
158
|
+
declare_meme(:to_ruby_assign, [], nil, ::Myco.cscope.dup) { |g, value| (
|
159
|
+
g.add("::Myco.cscope.for_method_definition.const_set(#{self.name.inspect}, ")
|
160
|
+
g.add(value)
|
161
|
+
g.add(")")
|
349
162
|
)}
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
163
|
+
)}
|
164
|
+
::Myco.find_constant(:ConstantAssignment).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (self.constant.to_ruby_assign(
|
165
|
+
g,
|
166
|
+
self.value
|
167
|
+
))})}
|
168
|
+
::Myco.find_constant(:ConstantDefine).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
169
|
+
g.add(self.implementation)
|
170
|
+
g.line(".tap { |__c__| __c__.__name__ = ")
|
171
|
+
g.add(self.name.name.inspect)
|
172
|
+
g.add(" }")
|
173
|
+
)})}
|
174
|
+
::Myco.find_constant(:ConstantReopen).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
175
|
+
g.add(self.name)
|
176
|
+
g.add(".component_eval {")
|
177
|
+
g.add(self.body)
|
178
|
+
g.add("}")
|
179
|
+
)})}
|
180
|
+
::Myco.find_constant(:MycoModuleScope).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (g.with_nested_var_scope(self) { || (g.add(self.body))})})}
|
181
|
+
::Myco.find_constant(:EvalExpression).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (g.add(self.body))})}
|
182
|
+
::Myco.find_constant(:DeclareFile).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
183
|
+
g.line
|
184
|
+
self.implementation.to_ruby(g)
|
185
|
+
g.line
|
186
|
+
)})}
|
187
|
+
::Myco.find_constant(:DeclareObject).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
188
|
+
g.add("::Myco::Component.new(")
|
189
|
+
g.add(self.types)
|
190
|
+
g.add(", ::Myco.cscope.for_method_definition, __FILE__, __LINE__)")
|
191
|
+
g.line(".tap { |__c__| __c__.__last__ = __c__.component_eval {")
|
192
|
+
g.add(self.scope_implementation)
|
193
|
+
g.add("}}")
|
194
|
+
::Myco.branch_op(:"&&", self.create) {g.add(".instance")}
|
195
|
+
)})}
|
196
|
+
::Myco.find_constant(:DeclareString).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (g.add(self.implementation))})}
|
197
|
+
::Myco.find_constant(:DeclareCategory).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
198
|
+
g.add("__category__(#{self.name.value.inspect})")
|
199
|
+
g.add(".component_eval {")
|
200
|
+
g.add(self.body)
|
201
|
+
g.add("}")
|
202
|
+
)})}
|
203
|
+
::Myco.find_constant(:DeclareMeme).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (g.with_nested_var_scope(self.body_implementation) { || (
|
204
|
+
g.var_scope_declare_locals(*self.arguments.names)
|
205
|
+
g.add("declare_meme(")
|
206
|
+
g.add("#{self.name.inspect}, ")
|
207
|
+
g.add(self.decorations)
|
208
|
+
g.add(", nil, ::Myco.cscope.dup)")
|
209
|
+
g.add(" { ")
|
210
|
+
g.add(self.arguments)
|
211
|
+
g.add(" ")
|
212
|
+
g.add(self.body)
|
213
|
+
g.add("}")
|
214
|
+
)})})}
|
215
|
+
::Myco.find_constant(:DeclareDecorator).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
216
|
+
g.add("[#{self.name.value.inspect}, ")
|
217
|
+
g.add(self.arguments)
|
218
|
+
g.add("]")
|
219
|
+
)})}
|
220
|
+
::Myco.find_constant(:Parameters).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
221
|
+
list = []
|
222
|
+
list_add = ::Myco.find_constant(:Proc).new { |&blk| (list.push(::Myco.find_constant(:Proc).new(&blk)))}
|
223
|
+
self.required.each { |item| (list_add.call { || (g.add(item.to_s))})}
|
224
|
+
::Myco.branch_op(:"&?", self.defaults) {self.defaults.arguments.each { |asgn| (
|
225
|
+
name = asgn.name
|
226
|
+
value = asgn.value
|
227
|
+
list_add.call { || (
|
228
|
+
g.add("#{name}=")
|
229
|
+
::Myco.branch_op(:"||", ::Myco.branch_op(:"&&", value.__send__(
|
230
|
+
:is_a?,
|
231
|
+
::Myco.find_constant(:SymbolLiteral)
|
232
|
+
)) {value.value.__send__(
|
376
233
|
:==,
|
377
234
|
:*
|
378
|
-
)) {
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
)}) {g.add(value)}
|
396
|
-
)}
|
397
|
-
)}
|
398
|
-
::Myco.branch_op(:"&?", ::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", self.keywords.kwrest.__send__(
|
235
|
+
)}) {g.add(value)}
|
236
|
+
)}
|
237
|
+
)}}
|
238
|
+
::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", self.splat.__send__(
|
239
|
+
:==,
|
240
|
+
:*
|
241
|
+
)) {list_add.call { || (g.add("*"))}}) {::Myco.branch_op(:"&?", self.splat) {list_add.call { || (g.add("*#{self.splat}"))}}}
|
242
|
+
::Myco.branch_op(:"&?", self.keywords) {(
|
243
|
+
self.keywords.arguments.each { |asgn| (
|
244
|
+
name = asgn.name
|
245
|
+
value = asgn.value
|
246
|
+
list_add.call { || (
|
247
|
+
g.add("#{name}:")
|
248
|
+
::Myco.branch_op(:"||", ::Myco.branch_op(:"&&", value.__send__(
|
249
|
+
:is_a?,
|
250
|
+
::Myco.find_constant(:SymbolLiteral)
|
251
|
+
)) {value.value.__send__(
|
399
252
|
:==,
|
400
|
-
|
401
|
-
)) {
|
402
|
-
g.add("**")
|
403
|
-
)}}) {self.keywords.kwrest}) {list_add.call { || (
|
404
|
-
g.add("**#{self.keywords.kwrest.name}")
|
405
|
-
)}}
|
406
|
-
)}
|
407
|
-
::Myco.branch_op(:"&?", self.block_arg) {list_add.call { || (
|
408
|
-
g.add("&#{self.block_arg.name}")
|
409
|
-
)}}
|
410
|
-
g.add("|")
|
411
|
-
g.list(
|
412
|
-
list,
|
413
|
-
", "
|
414
|
-
) { |proc| (
|
415
|
-
proc.call
|
416
|
-
)}
|
417
|
-
g.add("|")
|
418
|
-
)}
|
419
|
-
)}
|
420
|
-
::Myco.find_constant(:Block).component_eval {(
|
421
|
-
declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
422
|
-
g.add("(")
|
423
|
-
g.list(
|
424
|
-
self.array,
|
425
|
-
"",
|
426
|
-
{
|
427
|
-
:auto_lines => true
|
428
|
-
}
|
429
|
-
)
|
430
|
-
g.add(")")
|
431
|
-
)}
|
432
|
-
)}
|
433
|
-
::Myco.find_constant(:Invoke).component_eval {(
|
434
|
-
declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
435
|
-
g.add(self.implementation)
|
436
|
-
)}
|
437
|
-
)}
|
438
|
-
::Myco.find_constant(:InvokeMethod).component_eval {(
|
439
|
-
declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
440
|
-
list = ::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", self.arguments) {self.arguments.body.dup}) {[]}
|
441
|
-
::Myco.branch_op(:"&&", self.arguments.block.__send__(
|
442
|
-
:is_a?,
|
443
|
-
::Myco.find_constant(:BlockPass)
|
444
|
-
)) {list.push(self.arguments.block)}
|
445
|
-
g.add(self.receiver)
|
446
|
-
::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", g.__send__(
|
447
|
-
:easy_ident?,
|
448
|
-
self.name
|
449
|
-
)) {g.add(".#{self.name}")}) {(
|
450
|
-
g.add(".__send__")
|
451
|
-
list.unshift(::Myco.find_constant(:SymbolLiteral).new(
|
452
|
-
self.line,
|
453
|
-
self.name
|
454
|
-
))
|
455
|
-
)}
|
456
|
-
::Myco.branch_op(:"&&", list.__send__(:any?)) {(
|
457
|
-
g.add("(")
|
458
|
-
g.list(
|
459
|
-
list,
|
460
|
-
",",
|
461
|
-
{
|
462
|
-
:auto_lines => true
|
463
|
-
}
|
464
|
-
)
|
465
|
-
g.add(")")
|
466
|
-
)}
|
467
|
-
::Myco.branch_op(:"&&", self.arguments.block.__send__(
|
468
|
-
:is_a?,
|
469
|
-
::Myco.find_constant(:Iter)
|
470
|
-
)) {(
|
471
|
-
g.add(" {")
|
472
|
-
g.add(self.arguments.block)
|
473
|
-
g.add("}")
|
474
|
-
)}
|
475
|
-
)}
|
476
|
-
)}
|
477
|
-
::Myco.find_constant(:LocalVariableAssignment).component_eval {(
|
478
|
-
declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
479
|
-
g.var_scope_declare_local(self.name)
|
480
|
-
g.var_scope.variables.__send__(
|
481
|
-
:[]=,
|
482
|
-
self.name,
|
483
|
-
true
|
484
|
-
)
|
485
|
-
g.add(self.name.to_s)
|
486
|
-
g.add(" = ")
|
487
|
-
g.add(self.value)
|
488
|
-
)}
|
489
|
-
)}
|
490
|
-
::Myco.find_constant(:LocalVariableAccessAmbiguous).component_eval {(
|
491
|
-
declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
492
|
-
::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", g.__send__(
|
493
|
-
:var_scope_has_local?,
|
494
|
-
self.name
|
495
|
-
)) {g.add(self.name.to_s)}) {(
|
496
|
-
g.add("self")
|
497
|
-
::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", g.__send__(
|
498
|
-
:easy_ident?,
|
499
|
-
self.name
|
500
|
-
)) {g.add(".#{self.name}")}) {g.add(".__send__(#{self.name.inspect})")}
|
501
|
-
)}
|
502
|
-
)}
|
503
|
-
)}
|
504
|
-
::Myco.find_constant(:SplatValue).component_eval {(
|
505
|
-
declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
506
|
-
::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", self.value.__send__(
|
507
|
-
:is_a?,
|
508
|
-
self.__send__(:class)
|
509
|
-
)) {self.value.to_ruby(g)}) {(
|
510
|
-
g.add("*")
|
511
|
-
self.value.to_ruby(g)
|
512
|
-
)}
|
513
|
-
)}
|
514
|
-
)}
|
515
|
-
::Myco.find_constant(:CollectSplat).component_eval {(
|
516
|
-
declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| nil}
|
517
|
-
)}
|
518
|
-
::Myco.find_constant(:ConcatArgs).component_eval {(
|
519
|
-
declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| nil}
|
520
|
-
)}
|
521
|
-
::Myco.find_constant(:PushArgs).component_eval {(
|
522
|
-
declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| nil}
|
523
|
-
)}
|
524
|
-
::Myco.find_constant(:BlockPass).component_eval {(
|
525
|
-
declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
526
|
-
g.add("&")
|
527
|
-
g.add(self.body)
|
528
|
-
)}
|
529
|
-
)}
|
530
|
-
::Myco.find_constant(:Iter).component_eval {(
|
531
|
-
declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
532
|
-
g.with_nested_var_scope(self) { || (
|
533
|
-
g.var_scope_declare_locals(*self.arguments.names)
|
534
|
-
g.add(" ")
|
535
|
-
g.add(self.arguments)
|
536
|
-
g.add(" ")
|
537
|
-
g.add(self.body)
|
253
|
+
:*
|
254
|
+
)}) {g.add(value)}
|
538
255
|
)}
|
539
256
|
)}
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
)
|
257
|
+
::Myco.branch_op(:"&?", ::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", self.keywords.kwrest.__send__(
|
258
|
+
:==,
|
259
|
+
true
|
260
|
+
)) {list_add.call { || (g.add("**"))}}) {self.keywords.kwrest}) {list_add.call { || (g.add("**#{self.keywords.kwrest.name}"))}}
|
261
|
+
)}
|
262
|
+
::Myco.branch_op(:"&?", self.block_arg) {list_add.call { || (g.add("&#{self.block_arg.name}"))}}
|
263
|
+
g.add("|")
|
264
|
+
g.list(
|
265
|
+
list,
|
266
|
+
", "
|
267
|
+
) { |proc| (proc.call)}
|
268
|
+
g.add("|")
|
269
|
+
)})}
|
270
|
+
::Myco.find_constant(:Block).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
271
|
+
g.add("(")
|
272
|
+
g.list(
|
273
|
+
self.array,
|
274
|
+
"",
|
275
|
+
{:auto_lines => true}
|
276
|
+
)
|
277
|
+
g.add(")")
|
278
|
+
)})}
|
279
|
+
::Myco.find_constant(:Invoke).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (g.add(self.implementation))})}
|
280
|
+
::Myco.find_constant(:InvokeMethod).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
281
|
+
list = ::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", self.arguments) {self.arguments.body.dup}) {[]}
|
282
|
+
::Myco.branch_op(:"&&", self.arguments.block.__send__(
|
283
|
+
:is_a?,
|
284
|
+
::Myco.find_constant(:BlockPass)
|
285
|
+
)) {list.push(self.arguments.block)}
|
286
|
+
g.add(self.receiver)
|
287
|
+
::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", g.__send__(
|
288
|
+
:easy_ident?,
|
289
|
+
self.name
|
290
|
+
)) {g.add(".#{self.name}")}) {(
|
291
|
+
g.add(".__send__")
|
292
|
+
list.unshift(::Myco.find_constant(:SymbolLiteral).new(
|
293
|
+
self.line,
|
294
|
+
self.name
|
295
|
+
))
|
296
|
+
)}
|
297
|
+
::Myco.branch_op(:"&&", list.__send__(:any?)) {(
|
298
|
+
g.add("(")
|
299
|
+
g.list(
|
300
|
+
list,
|
301
|
+
",",
|
302
|
+
{:auto_lines => true}
|
303
|
+
)
|
304
|
+
g.add(")")
|
305
|
+
)}
|
306
|
+
::Myco.branch_op(:"&&", self.arguments.block.__send__(
|
307
|
+
:is_a?,
|
308
|
+
::Myco.find_constant(:Iter)
|
309
|
+
)) {(
|
310
|
+
g.add(" {")
|
311
|
+
g.add(self.arguments.block)
|
312
|
+
g.add("}")
|
313
|
+
)}
|
314
|
+
)})}
|
315
|
+
::Myco.find_constant(:LocalVariableAssignment).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
316
|
+
g.var_scope_declare_local(self.name)
|
317
|
+
g.var_scope.variables.__send__(
|
318
|
+
:[]=,
|
319
|
+
self.name,
|
320
|
+
true
|
321
|
+
)
|
322
|
+
g.add(self.name.to_s)
|
323
|
+
g.add(" = ")
|
324
|
+
g.add(self.value)
|
325
|
+
)})}
|
326
|
+
::Myco.find_constant(:LocalVariableAccessAmbiguous).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", g.__send__(
|
327
|
+
:var_scope_has_local?,
|
328
|
+
self.name
|
329
|
+
)) {g.add(self.name.to_s)}) {(
|
330
|
+
g.add("self")
|
331
|
+
::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", g.__send__(
|
332
|
+
:easy_ident?,
|
333
|
+
self.name
|
334
|
+
)) {g.add(".#{self.name}")}) {g.add(".__send__(#{self.name.inspect})")}
|
335
|
+
)})})}
|
336
|
+
::Myco.find_constant(:SplatValue).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", self.value.__send__(
|
337
|
+
:is_a?,
|
338
|
+
self.__send__(:class)
|
339
|
+
)) {self.value.to_ruby(g)}) {(
|
340
|
+
g.add("*")
|
341
|
+
self.value.to_ruby(g)
|
342
|
+
)})})}
|
343
|
+
::Myco.find_constant(:CollectSplat).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| nil})}
|
344
|
+
::Myco.find_constant(:ConcatArgs).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| nil})}
|
345
|
+
::Myco.find_constant(:PushArgs).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| nil})}
|
346
|
+
::Myco.find_constant(:BlockPass).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
347
|
+
g.add("&")
|
348
|
+
g.add(self.body)
|
349
|
+
)})}
|
350
|
+
::Myco.find_constant(:Iter).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (g.with_nested_var_scope(self) { || (
|
351
|
+
g.var_scope_declare_locals(*self.arguments.names)
|
352
|
+
g.add(" ")
|
353
|
+
g.add(self.arguments)
|
354
|
+
g.add(" ")
|
355
|
+
g.add(self.body)
|
356
|
+
)})})}
|
357
|
+
::Myco.find_constant(:Quest).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
358
|
+
associated_questable = self.questable.dup
|
359
|
+
associated_questable.__send__(
|
360
|
+
:receiver=,
|
361
|
+
self.receiver
|
362
|
+
)
|
363
|
+
g.add("(")
|
364
|
+
g.add(self.receiver)
|
365
|
+
g.add(".respond_to?(#{self.questable.name.inspect}).false?")
|
366
|
+
g.add(" ? ::Myco::Void : ")
|
367
|
+
g.add(associated_questable)
|
368
|
+
g.add(")")
|
369
|
+
)})}
|
370
|
+
::Myco.find_constant(:BranchOperator).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
371
|
+
g.add("::Myco.branch_op(")
|
372
|
+
g.add(self.type.inspect)
|
373
|
+
g.add(", ")
|
374
|
+
g.add(self.left)
|
375
|
+
g.add(") {")
|
376
|
+
g.add(self.right)
|
377
|
+
g.add("}")
|
378
|
+
)})}
|
379
|
+
::Myco.find_constant(:Return).component_eval {(declare_meme(:to_ruby, [], nil, ::Myco.cscope.dup) { |g| (
|
380
|
+
g.add("return ")
|
381
|
+
g.add(self.value)
|
382
|
+
)})}
|
383
|
+
)})}}.instance
|