myco 0.1.8 → 0.1.9
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/instance.rb +13 -3
- data/lib/myco/code_tools/AST.my +0 -2
- data/lib/myco/code_tools/AST.my.rb +0 -1
- data/lib/myco/code_tools/AST/Block.my +15 -4
- data/lib/myco/code_tools/AST/Block.my.rb +16 -3
- data/lib/myco/code_tools/AST/DeclareMeme.my +44 -64
- data/lib/myco/code_tools/AST/DeclareMeme.my.rb +66 -74
- data/lib/myco/code_tools/AST/ToRuby.my +17 -20
- data/lib/myco/code_tools/AST/ToRuby.my.rb +24 -22
- data/lib/myco/code_tools/Parser.my +2 -1
- data/lib/myco/code_tools/Parser.my.rb +2 -1
- data/lib/myco/code_tools/parser/MycoBuilder.my +2 -2
- data/lib/myco/code_tools/parser/MycoBuilder.my.rb +2 -2
- data/lib/myco/code_tools/parser/MycoGrammar.my +28 -21
- data/lib/myco/code_tools/parser/MycoGrammar.my.rb +94 -56
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces.my +10 -11
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces.my.rb +10 -9
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeHelpers.my +25 -3
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeHelpers.my.rb +38 -0
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Capture.my +152 -0
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Capture.my.rb +189 -0
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Common.my +84 -0
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Common.my.rb +114 -0
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Common/Parser.my +139 -0
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/{BytecodeParser.my.rb → Common/Parser.my.rb} +17 -36
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Composite.my +229 -0
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Composite.my.rb +296 -0
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Grammar.my +8 -25
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Grammar.my.rb +9 -37
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Parser.my +139 -37
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Parser.my.rb +206 -36
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Processor.my +21 -12
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Processor.my.rb +45 -24
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Stream.my +99 -0
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Stream.my.rb +152 -0
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Stream/Parser.my +37 -0
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Stream/Parser.my.rb +57 -0
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/String.my +136 -0
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/String.my.rb +147 -0
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/String/Parser.my +45 -0
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/String/Parser.my.rb +85 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Patterns.test.my +31 -25
- data/lib/myco/code_tools/parser/pegleromyces/spec/Patterns.test.my.rb +44 -25
- data/lib/myco/code_tools/parser/pegleromyces/spec/Stream/Parser.test.my +49 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Stream/Parser.test.my.rb +119 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Stream/Patterns.test.my +131 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Stream/Patterns.test.my.rb +595 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/{BytecodeParser.test.my → String/Parser.test.my} +41 -2
- data/lib/myco/code_tools/parser/pegleromyces/spec/{BytecodeParser.test.my.rb → String/Parser.test.my.rb} +144 -3
- data/lib/myco/code_tools/parser/pegleromyces/spec/run.my +4 -10
- data/lib/myco/code_tools/parser/pegleromyces/spec/run.my.rb +4 -8
- data/lib/myco/core.my +1 -0
- data/lib/myco/core.my.rb +1 -0
- data/lib/myco/core/BasicObject.my +4 -2
- data/lib/myco/core/BasicObject.my.rb +2 -5
- data/lib/myco/core/Loop.my +5 -0
- data/lib/myco/core/Loop.my.rb +13 -0
- data/lib/myco/dev.rb +1 -0
- data/lib/myco/dev/profile.rb +12 -0
- data/lib/myco/version.rb +3 -3
- metadata +54 -59
- data/lib/myco/code_tools/AST/DeclareDecorator.my +0 -19
- data/lib/myco/code_tools/AST/DeclareDecorator.my.rb +0 -24
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Builder.my +0 -4
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Builder.my.rb +0 -5
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeInstructions.my +0 -420
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeInstructions.my.rb +0 -415
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeParser.my +0 -147
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Constructions.my +0 -183
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Constructions.my.rb +0 -370
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Instructions.my +0 -139
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Instructions.my.rb +0 -284
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Machine.my +0 -37
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Machine.my.rb +0 -24
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Patterns.my +0 -123
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Patterns.my.rb +0 -164
- data/lib/myco/code_tools/parser/pegleromyces/spec/Builder.test.my +0 -10
- data/lib/myco/code_tools/parser/pegleromyces/spec/Builder.test.my.rb +0 -9
- data/lib/myco/code_tools/parser/pegleromyces/spec/BytecodeInstructions.test.my +0 -10
- data/lib/myco/code_tools/parser/pegleromyces/spec/BytecodeInstructions.test.my.rb +0 -9
- data/lib/myco/code_tools/parser/pegleromyces/spec/Constructions.test.my +0 -229
- data/lib/myco/code_tools/parser/pegleromyces/spec/Constructions.test.my.rb +0 -663
- data/lib/myco/code_tools/parser/pegleromyces/spec/Instructions.test.my +0 -10
- data/lib/myco/code_tools/parser/pegleromyces/spec/Instructions.test.my.rb +0 -9
- data/lib/myco/code_tools/parser/pegleromyces/spec/Machine.test.my +0 -13
- data/lib/myco/code_tools/parser/pegleromyces/spec/Machine.test.my.rb +0 -20
- data/lib/myco/code_tools/parser/pegleromyces/spec/Parser.test.my +0 -54
- data/lib/myco/code_tools/parser/pegleromyces/spec/Parser.test.my.rb +0 -215
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10d6d42881d428ea5359f83d8bfdce81ebf34ea7
|
4
|
+
data.tar.gz: fa2936dff1fbf455e7b8462c1c969cc023de020b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9663e17bf43f6b64241939eafeb51350bb6a7298add9322c815f4ed4dec266efa93398ad4c27243bdfd20524a314c6cc8a0eaf6f8f3016dc807660df07bd65e5
|
7
|
+
data.tar.gz: da1ebe5deab665ceef785c9ddb89cb62fd6e551d616c8bbacb0af15fd590cdaf32a10597d051dab58fc4476290003dde6bcda25f9fcbc3ed8b27479dfe7b515d
|
@@ -99,12 +99,22 @@ module Myco
|
|
99
99
|
"#<#{__component__.to_s}>"
|
100
100
|
end
|
101
101
|
|
102
|
-
def inspect
|
102
|
+
def inspect(pretty: true)
|
103
103
|
vars = __ivar_names__.map { |var|
|
104
104
|
[var.to_s[1..-1], __get_ivar__(var).inspect].join(": ")
|
105
105
|
}
|
106
|
-
|
107
|
-
|
106
|
+
|
107
|
+
vars = if vars.empty?
|
108
|
+
""
|
109
|
+
elsif vars.size == 1
|
110
|
+
vars.first
|
111
|
+
elsif !pretty
|
112
|
+
vars.join(", ")
|
113
|
+
else
|
114
|
+
"\n " + vars.join("\n").gsub("\n", "\n ") + "\n"
|
115
|
+
end
|
116
|
+
|
117
|
+
"#{__component__.to_s}#(#{vars})"
|
108
118
|
end
|
109
119
|
|
110
120
|
alias_method :hash, :__hash__ # TODO: remove?
|
data/lib/myco/code_tools/AST.my
CHANGED
@@ -42,7 +42,6 @@
|
|
42
42
|
declare_meme(:"AST/DeclareFile.my", [[:import, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
43
43
|
declare_meme(:"AST/DeclareExtension.my", [[:import, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
44
44
|
declare_meme(:"AST/DeclareCategory.my", [[:import, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
45
|
-
declare_meme(:"AST/DeclareDecorator.my", [[:import, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
46
45
|
declare_meme(:"AST/DeclareMeme.my", [[:import, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
47
46
|
declare_meme(:"AST/Invoke.my", [[:import, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
48
47
|
declare_meme(:"AST/InvokeMethod.my", [[:import, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
@@ -6,11 +6,11 @@ CodeTools::AST << {
|
|
6
6
|
field parameters, field body
|
7
7
|
|
8
8
|
var parent # TODO: investigate removing
|
9
|
+
var new_cscope
|
9
10
|
|
10
11
|
CompilerClass: CodeTools::Compiler # TODO: remove this
|
11
12
|
|
12
|
-
setter
|
13
|
-
setter body: |given| given || NullLiteral.new(line:self.line)
|
13
|
+
setter body: |given| given || NullLiteral.new(line:self.line)
|
14
14
|
|
15
15
|
locals: self.body.?locals.?body.map(&:value) ?? null
|
16
16
|
|
@@ -59,13 +59,19 @@ CodeTools::AST << {
|
|
59
59
|
|
60
60
|
new_nested_local: |name| new_local(name).nested_reference
|
61
61
|
|
62
|
+
effective_parameters: self.parameters || ParameterAssembly.new(
|
63
|
+
line: self.line
|
64
|
+
rest: RestParameter.new(line: self.line)
|
65
|
+
)
|
66
|
+
|
62
67
|
bytecode: |g| {
|
63
68
|
pos(g)
|
64
69
|
|
65
70
|
state = g.state
|
66
71
|
state.scope.nest_scope(self)
|
67
72
|
|
68
|
-
|
73
|
+
parameters = self.effective_parameters
|
74
|
+
blk = new_block_generator(g, parameters)
|
69
75
|
|
70
76
|
blk.push_state(self)
|
71
77
|
blk.definition_line(self.line)
|
@@ -77,7 +83,7 @@ CodeTools::AST << {
|
|
77
83
|
# Push line info down.
|
78
84
|
pos(blk)
|
79
85
|
|
80
|
-
|
86
|
+
parameters.bytecode(blk)
|
81
87
|
|
82
88
|
blk.state.push_block
|
83
89
|
blk.push_modifiers
|
@@ -97,6 +103,11 @@ CodeTools::AST << {
|
|
97
103
|
blk.local_count = local_count
|
98
104
|
blk.local_names = local_names
|
99
105
|
|
106
|
+
self.new_cscope &? (
|
107
|
+
g.push_scope
|
108
|
+
g.send(:for_method_definition, 0)
|
109
|
+
g.add_scope
|
110
|
+
)
|
100
111
|
g.create_block(blk)
|
101
112
|
}
|
102
113
|
}
|
@@ -9,8 +9,8 @@
|
|
9
9
|
declare_meme(:parameters, [[:field, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
10
10
|
declare_meme(:body, [[:field, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
11
11
|
declare_meme(:parent, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
12
|
+
declare_meme(:new_cscope, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
12
13
|
::Myco.cscope.for_method_definition::CompilerClass = (::Myco.find_constant(:CodeTools)::Compiler)
|
13
|
-
declare_meme(:parameters, [[:setter, []]], nil, ::Myco.cscope.dup) { |given| (::Myco.branch_op(:"||", given) {::Myco.find_constant(:ParameterAssembly).new({:line => self.line})})}
|
14
14
|
declare_meme(:body, [[:setter, []]], nil, ::Myco.cscope.dup) { |given| (::Myco.branch_op(:"||", given) {::Myco.find_constant(:NullLiteral).new({:line => self.line})})}
|
15
15
|
declare_meme(:locals, [], nil, ::Myco.cscope.dup) { |*| (::Myco.branch_op(:"??", (Rubinius::Type.object_respond_to?((Rubinius::Type.object_respond_to?(self.body, :locals).false? ? ::Myco::Void : self.body.locals), :body).false? ? ::Myco::Void : (Rubinius::Type.object_respond_to?(self.body, :locals).false? ? ::Myco::Void : self.body.locals).body).map(&:value)) {nil})}
|
16
16
|
declare_meme(:block_local?, [], nil, ::Myco.cscope.dup) { |name| (::Myco.branch_op(:"??", (Rubinius::Type.object_respond_to?(self.locals, :include?).false? ? ::Myco::Void : self.locals.__send__(
|
@@ -72,13 +72,18 @@
|
|
72
72
|
)) {::Myco.find_constant(:CompilerClass)::LocalVariable.new(self.allocate_slot)}
|
73
73
|
))}
|
74
74
|
declare_meme(:new_nested_local, [], nil, ::Myco.cscope.dup) { |name| (self.new_local(name).nested_reference)}
|
75
|
+
declare_meme(:effective_parameters, [], nil, ::Myco.cscope.dup) { |*| (::Myco.branch_op(:"||", self.parameters) {::Myco.find_constant(:ParameterAssembly).new({
|
76
|
+
:line => self.line,
|
77
|
+
:rest => ::Myco.find_constant(:RestParameter).new({:line => self.line})
|
78
|
+
})})}
|
75
79
|
declare_meme(:bytecode, [], nil, ::Myco.cscope.dup) { |g| (
|
76
80
|
self.pos(g)
|
77
81
|
state = g.state
|
78
82
|
state.scope.nest_scope(self)
|
83
|
+
parameters = self.effective_parameters
|
79
84
|
blk = self.new_block_generator(
|
80
85
|
g,
|
81
|
-
|
86
|
+
parameters
|
82
87
|
)
|
83
88
|
blk.push_state(self)
|
84
89
|
blk.definition_line(self.line)
|
@@ -86,7 +91,7 @@
|
|
86
91
|
blk.state.push_eval(state.eval)
|
87
92
|
blk.state.push_name(blk.name)
|
88
93
|
self.pos(blk)
|
89
|
-
|
94
|
+
parameters.bytecode(blk)
|
90
95
|
blk.state.push_block
|
91
96
|
blk.push_modifiers
|
92
97
|
blk.__send__(
|
@@ -116,6 +121,14 @@
|
|
116
121
|
:local_names=,
|
117
122
|
self.local_names
|
118
123
|
)
|
124
|
+
::Myco.branch_op(:"&?", self.new_cscope) {(
|
125
|
+
g.push_scope
|
126
|
+
g.send(
|
127
|
+
:for_method_definition,
|
128
|
+
0
|
129
|
+
)
|
130
|
+
g.add_scope
|
131
|
+
)}
|
119
132
|
g.create_block(blk)
|
120
133
|
)}
|
121
134
|
)}}
|
@@ -1,78 +1,58 @@
|
|
1
1
|
|
2
2
|
CodeTools::AST << {
|
3
3
|
|
4
|
-
|
5
|
-
node_type
|
6
|
-
field
|
4
|
+
DeclareMeme < Node {
|
5
|
+
node_type meme
|
6
|
+
field decorations, field body
|
7
7
|
|
8
8
|
bytecode: |g| {
|
9
9
|
pos(g)
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
meth.ret
|
30
|
-
meth.close
|
31
|
-
meth.pop_state
|
32
|
-
|
33
|
-
g.push_scope
|
34
|
-
g.send(:for_method_definition, 0)
|
35
|
-
g.add_scope
|
36
|
-
|
37
|
-
# Create the BlockEnvironment from the meth Generator
|
38
|
-
g.create_block(meth)
|
11
|
+
self.effective_name.node_type == :symbol &? (
|
12
|
+
##
|
13
|
+
# module = scope.for_method_definition
|
14
|
+
# module.send :declare_meme, name, decorations, Proc(body)
|
15
|
+
#
|
16
|
+
g.push_scope
|
17
|
+
g.send(:for_method_definition, 0)
|
18
|
+
self.effective_name.bytecode(g)
|
19
|
+
self.effective_decorations.bytecode(g)
|
20
|
+
self.effective_body.bytecode(g)
|
21
|
+
g.send(:declare_meme, 3)
|
22
|
+
) ?? (
|
23
|
+
ConstantAssignment.new(
|
24
|
+
line: self.line
|
25
|
+
constant: self.effective_name
|
26
|
+
value: self.effective_body.block.body
|
27
|
+
).bytecode(g)
|
28
|
+
)
|
39
29
|
}
|
40
|
-
}
|
41
|
-
|
42
|
-
DeclareMeme < Node {
|
43
|
-
node_type meme
|
44
|
-
field name, field decorations, field parameters, field body
|
45
30
|
|
46
|
-
|
47
|
-
x.value
|
48
|
-
setter decorations: |x|
|
49
|
-
x || ArrayAssembly.new(line:line, body:[])
|
50
|
-
setter parameters: |x|
|
51
|
-
x || ParameterAssembly.new(line:line, required:[], rest:RestParameter.new(line:line))
|
52
|
-
setter body: |x|
|
53
|
-
x || NullLiteral.new(line:line)
|
31
|
+
effective_name: self.decorations.last
|
54
32
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
33
|
+
effective_decorations: {
|
34
|
+
decorations = self.decorations[Ruby::Range.new(0, -1, true)]
|
35
|
+
|
36
|
+
ArrayAssembly.new(line: self.line, body: decorations.reverse.map |d| {
|
37
|
+
d.node_type == :invoke &? (
|
38
|
+
ArrayAssembly.new(line: d.line, body: [
|
39
|
+
SymbolLiteral.new(line: d.line, value: d.name)
|
40
|
+
ArrayAssembly.new(line: d.line, body: d.arguments.body)
|
41
|
+
])
|
42
|
+
) ?? (
|
43
|
+
d
|
44
|
+
)
|
45
|
+
})
|
46
|
+
}
|
61
47
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
g.push_scope
|
71
|
-
g.send(:for_method_definition, 0)
|
72
|
-
g.push_literal(self.name)
|
73
|
-
self.decorations.bytecode(g)
|
74
|
-
body_implementation.bytecode(g)
|
75
|
-
g.send(:declare_meme, 3)
|
48
|
+
effective_body: {
|
49
|
+
body = self.body || BlockLiteral.new(line: self.line,
|
50
|
+
block: Block.new(line: self.line,
|
51
|
+
body: NullLiteral.new(line: self.line)
|
52
|
+
)
|
53
|
+
)
|
54
|
+
body.block.new_cscope = true
|
55
|
+
body
|
76
56
|
}
|
77
57
|
}
|
78
58
|
|
@@ -1,85 +1,77 @@
|
|
1
1
|
|
2
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
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
self.parameters
|
15
|
-
)
|
16
|
-
meth.push_state(self)
|
17
|
-
meth.state.push_super(self)
|
18
|
-
meth.definition_line(self.line)
|
19
|
-
meth.state.push_name(self.name.to_sym)
|
20
|
-
self.parameters.bytecode(meth)
|
21
|
-
self.body.bytecode(meth)
|
22
|
-
meth.state.pop_name
|
23
|
-
meth.__send__(
|
24
|
-
:local_count=,
|
25
|
-
self.local_count
|
26
|
-
)
|
27
|
-
meth.__send__(
|
28
|
-
:local_names=,
|
29
|
-
self.local_names
|
30
|
-
)
|
31
|
-
meth.ret
|
32
|
-
meth.close
|
33
|
-
meth.pop_state
|
3
|
+
.tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco.find_constant(:CodeTools)::AST.component_eval {(::Myco.cscope.for_method_definition::DeclareMeme = ::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(:meme, [[:node_type, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
6
|
+
declare_meme(:decorations, [[:field, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
7
|
+
declare_meme(:body, [[:field, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
8
|
+
declare_meme(:bytecode, [], nil, ::Myco.cscope.dup) { |g| (
|
9
|
+
self.pos(g)
|
10
|
+
::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", self.effective_name.node_type.__send__(
|
11
|
+
:==,
|
12
|
+
:symbol
|
13
|
+
)) {(
|
34
14
|
g.push_scope
|
35
15
|
g.send(
|
36
16
|
:for_method_definition,
|
37
17
|
0
|
38
18
|
)
|
39
|
-
g
|
40
|
-
|
41
|
-
|
42
|
-
)}}
|
43
|
-
.tap { |__c__| __c__.__name__ = :DeclareMemeBody }
|
44
|
-
::Myco.cscope.for_method_definition::DeclareMeme = ::Myco::Component.new([::Myco.find_constant(:Node)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
45
|
-
.tap { |__c__| __c__.__last__ = __c__.component_eval {(
|
46
|
-
declare_meme(:meme, [[:node_type, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
47
|
-
declare_meme(:name, [[:field, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
48
|
-
declare_meme(:decorations, [[:field, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
49
|
-
declare_meme(:parameters, [[:field, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
50
|
-
declare_meme(:body, [[:field, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
51
|
-
declare_meme(:name, [[:setter, []]], nil, ::Myco.cscope.dup) { |x| (x.value)}
|
52
|
-
declare_meme(:decorations, [[:setter, []]], nil, ::Myco.cscope.dup) { |x| (::Myco.branch_op(:"||", x) {::Myco.find_constant(:ArrayAssembly).new({
|
53
|
-
:line => self.line,
|
54
|
-
:body => []
|
55
|
-
})})}
|
56
|
-
declare_meme(:parameters, [[:setter, []]], nil, ::Myco.cscope.dup) { |x| (::Myco.branch_op(:"||", x) {::Myco.find_constant(:ParameterAssembly).new({
|
57
|
-
:line => self.line,
|
58
|
-
:required => [],
|
59
|
-
:rest => ::Myco.find_constant(:RestParameter).new({:line => self.line})
|
60
|
-
})})}
|
61
|
-
declare_meme(:body, [[:setter, []]], nil, ::Myco.cscope.dup) { |x| (::Myco.branch_op(:"||", x) {::Myco.find_constant(:NullLiteral).new({:line => self.line})})}
|
62
|
-
declare_meme(:body_implementation, [], nil, ::Myco.cscope.dup) { |*| (::Myco.find_constant(:DeclareMemeBody).new({
|
63
|
-
:line => self.line,
|
64
|
-
:name => self.name,
|
65
|
-
:parameters => self.parameters,
|
66
|
-
:body => self.body
|
67
|
-
}))}
|
68
|
-
declare_meme(:bytecode, [], nil, ::Myco.cscope.dup) { |g| (
|
69
|
-
self.pos(g)
|
70
|
-
g.push_scope
|
71
|
-
g.send(
|
72
|
-
:for_method_definition,
|
73
|
-
0
|
74
|
-
)
|
75
|
-
g.push_literal(self.name)
|
76
|
-
self.decorations.bytecode(g)
|
77
|
-
self.body_implementation.bytecode(g)
|
19
|
+
self.effective_name.bytecode(g)
|
20
|
+
self.effective_decorations.bytecode(g)
|
21
|
+
self.effective_body.bytecode(g)
|
78
22
|
g.send(
|
79
23
|
:declare_meme,
|
80
24
|
3
|
81
25
|
)
|
82
|
-
)}
|
83
|
-
|
84
|
-
|
85
|
-
|
26
|
+
)}) {::Myco.find_constant(:ConstantAssignment).new({
|
27
|
+
:line => self.line,
|
28
|
+
:constant => self.effective_name,
|
29
|
+
:value => self.effective_body.block.body
|
30
|
+
}).bytecode(g)}
|
31
|
+
)}
|
32
|
+
declare_meme(:effective_name, [], nil, ::Myco.cscope.dup) { |*| (self.decorations.last)}
|
33
|
+
declare_meme(:effective_decorations, [], nil, ::Myco.cscope.dup) { |*| (
|
34
|
+
decorations = self.decorations.__send__(
|
35
|
+
:[],
|
36
|
+
::Myco.find_constant(:Ruby)::Range.new(
|
37
|
+
0,
|
38
|
+
-1,
|
39
|
+
true
|
40
|
+
)
|
41
|
+
)
|
42
|
+
::Myco.find_constant(:ArrayAssembly).new({
|
43
|
+
:line => self.line,
|
44
|
+
:body => decorations.reverse.map { |d| (::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", d.node_type.__send__(
|
45
|
+
:==,
|
46
|
+
:invoke
|
47
|
+
)) {::Myco.find_constant(:ArrayAssembly).new({
|
48
|
+
:line => d.line,
|
49
|
+
:body => [
|
50
|
+
::Myco.find_constant(:SymbolLiteral).new({
|
51
|
+
:line => d.line,
|
52
|
+
:value => d.name
|
53
|
+
}),
|
54
|
+
::Myco.find_constant(:ArrayAssembly).new({
|
55
|
+
:line => d.line,
|
56
|
+
:body => d.arguments.body
|
57
|
+
})
|
58
|
+
]
|
59
|
+
})}) {d})}
|
60
|
+
})
|
61
|
+
)}
|
62
|
+
declare_meme(:effective_body, [], nil, ::Myco.cscope.dup) { |*| (
|
63
|
+
body = ::Myco.branch_op(:"||", self.body) {::Myco.find_constant(:BlockLiteral).new({
|
64
|
+
:line => self.line,
|
65
|
+
:block => ::Myco.find_constant(:Block).new({
|
66
|
+
:line => self.line,
|
67
|
+
:body => ::Myco.find_constant(:NullLiteral).new({:line => self.line})
|
68
|
+
})
|
69
|
+
})}
|
70
|
+
body.block.__send__(
|
71
|
+
:new_cscope=,
|
72
|
+
true
|
73
|
+
)
|
74
|
+
body
|
75
|
+
)}
|
76
|
+
)}}
|
77
|
+
.tap { |__c__| __c__.__name__ = :DeclareMeme })})}}.instance
|
@@ -238,25 +238,22 @@ CodeTools::AST << {
|
|
238
238
|
|
239
239
|
DeclareMeme << {
|
240
240
|
to_ruby: |g| {
|
241
|
-
|
242
|
-
|
243
|
-
|
241
|
+
name = self.decorations.last
|
242
|
+
name.node_type == :symbol &? (
|
244
243
|
g.add("declare_meme(")
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
g.add("
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
g.list(self.arguments.body, ",", auto_lines:true)
|
259
|
-
g.add("]]")
|
244
|
+
g.list([
|
245
|
+
self.effective_name
|
246
|
+
self.effective_decorations
|
247
|
+
self.effective_body
|
248
|
+
], ",", auto_lines: true)
|
249
|
+
g.add(")")
|
250
|
+
) ?? (
|
251
|
+
g.add(ConstantAssignment.new(
|
252
|
+
line: self.line
|
253
|
+
constant: self.effective_name
|
254
|
+
value: self.effective_body.block.body
|
255
|
+
))
|
256
|
+
)
|
260
257
|
}
|
261
258
|
}
|
262
259
|
|
@@ -351,9 +348,9 @@ CodeTools::AST << {
|
|
351
348
|
Block << {
|
352
349
|
to_ruby: |g| {
|
353
350
|
g.with_nested_var_scope(self) {
|
354
|
-
g.var_scope_declare_locals(*self.
|
351
|
+
g.var_scope_declare_locals(*self.effective_parameters.names)
|
355
352
|
|
356
|
-
g.add(" "); g.add(self.
|
353
|
+
g.add(" "); g.add(self.effective_parameters); g.add(" "); g.add(self.body)
|
357
354
|
}
|
358
355
|
}
|
359
356
|
}
|