myco 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/lib/myco/bootstrap/instance.rb +13 -3
  3. data/lib/myco/code_tools/AST.my +0 -2
  4. data/lib/myco/code_tools/AST.my.rb +0 -1
  5. data/lib/myco/code_tools/AST/Block.my +15 -4
  6. data/lib/myco/code_tools/AST/Block.my.rb +16 -3
  7. data/lib/myco/code_tools/AST/DeclareMeme.my +44 -64
  8. data/lib/myco/code_tools/AST/DeclareMeme.my.rb +66 -74
  9. data/lib/myco/code_tools/AST/ToRuby.my +17 -20
  10. data/lib/myco/code_tools/AST/ToRuby.my.rb +24 -22
  11. data/lib/myco/code_tools/Parser.my +2 -1
  12. data/lib/myco/code_tools/Parser.my.rb +2 -1
  13. data/lib/myco/code_tools/parser/MycoBuilder.my +2 -2
  14. data/lib/myco/code_tools/parser/MycoBuilder.my.rb +2 -2
  15. data/lib/myco/code_tools/parser/MycoGrammar.my +28 -21
  16. data/lib/myco/code_tools/parser/MycoGrammar.my.rb +94 -56
  17. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces.my +10 -11
  18. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces.my.rb +10 -9
  19. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeHelpers.my +25 -3
  20. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeHelpers.my.rb +38 -0
  21. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Capture.my +152 -0
  22. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Capture.my.rb +189 -0
  23. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Common.my +84 -0
  24. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Common.my.rb +114 -0
  25. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Common/Parser.my +139 -0
  26. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/{BytecodeParser.my.rb → Common/Parser.my.rb} +17 -36
  27. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Composite.my +229 -0
  28. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Composite.my.rb +296 -0
  29. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Grammar.my +8 -25
  30. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Grammar.my.rb +9 -37
  31. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Parser.my +139 -37
  32. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Parser.my.rb +206 -36
  33. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Processor.my +21 -12
  34. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Processor.my.rb +45 -24
  35. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Stream.my +99 -0
  36. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Stream.my.rb +152 -0
  37. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Stream/Parser.my +37 -0
  38. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Stream/Parser.my.rb +57 -0
  39. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/String.my +136 -0
  40. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/String.my.rb +147 -0
  41. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/String/Parser.my +45 -0
  42. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/String/Parser.my.rb +85 -0
  43. data/lib/myco/code_tools/parser/pegleromyces/spec/Patterns.test.my +31 -25
  44. data/lib/myco/code_tools/parser/pegleromyces/spec/Patterns.test.my.rb +44 -25
  45. data/lib/myco/code_tools/parser/pegleromyces/spec/Stream/Parser.test.my +49 -0
  46. data/lib/myco/code_tools/parser/pegleromyces/spec/Stream/Parser.test.my.rb +119 -0
  47. data/lib/myco/code_tools/parser/pegleromyces/spec/Stream/Patterns.test.my +131 -0
  48. data/lib/myco/code_tools/parser/pegleromyces/spec/Stream/Patterns.test.my.rb +595 -0
  49. data/lib/myco/code_tools/parser/pegleromyces/spec/{BytecodeParser.test.my → String/Parser.test.my} +41 -2
  50. data/lib/myco/code_tools/parser/pegleromyces/spec/{BytecodeParser.test.my.rb → String/Parser.test.my.rb} +144 -3
  51. data/lib/myco/code_tools/parser/pegleromyces/spec/run.my +4 -10
  52. data/lib/myco/code_tools/parser/pegleromyces/spec/run.my.rb +4 -8
  53. data/lib/myco/core.my +1 -0
  54. data/lib/myco/core.my.rb +1 -0
  55. data/lib/myco/core/BasicObject.my +4 -2
  56. data/lib/myco/core/BasicObject.my.rb +2 -5
  57. data/lib/myco/core/Loop.my +5 -0
  58. data/lib/myco/core/Loop.my.rb +13 -0
  59. data/lib/myco/dev.rb +1 -0
  60. data/lib/myco/dev/profile.rb +12 -0
  61. data/lib/myco/version.rb +3 -3
  62. metadata +54 -59
  63. data/lib/myco/code_tools/AST/DeclareDecorator.my +0 -19
  64. data/lib/myco/code_tools/AST/DeclareDecorator.my.rb +0 -24
  65. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Builder.my +0 -4
  66. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Builder.my.rb +0 -5
  67. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeInstructions.my +0 -420
  68. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeInstructions.my.rb +0 -415
  69. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeParser.my +0 -147
  70. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Constructions.my +0 -183
  71. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Constructions.my.rb +0 -370
  72. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Instructions.my +0 -139
  73. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Instructions.my.rb +0 -284
  74. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Machine.my +0 -37
  75. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Machine.my.rb +0 -24
  76. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Patterns.my +0 -123
  77. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Patterns.my.rb +0 -164
  78. data/lib/myco/code_tools/parser/pegleromyces/spec/Builder.test.my +0 -10
  79. data/lib/myco/code_tools/parser/pegleromyces/spec/Builder.test.my.rb +0 -9
  80. data/lib/myco/code_tools/parser/pegleromyces/spec/BytecodeInstructions.test.my +0 -10
  81. data/lib/myco/code_tools/parser/pegleromyces/spec/BytecodeInstructions.test.my.rb +0 -9
  82. data/lib/myco/code_tools/parser/pegleromyces/spec/Constructions.test.my +0 -229
  83. data/lib/myco/code_tools/parser/pegleromyces/spec/Constructions.test.my.rb +0 -663
  84. data/lib/myco/code_tools/parser/pegleromyces/spec/Instructions.test.my +0 -10
  85. data/lib/myco/code_tools/parser/pegleromyces/spec/Instructions.test.my.rb +0 -9
  86. data/lib/myco/code_tools/parser/pegleromyces/spec/Machine.test.my +0 -13
  87. data/lib/myco/code_tools/parser/pegleromyces/spec/Machine.test.my.rb +0 -20
  88. data/lib/myco/code_tools/parser/pegleromyces/spec/Parser.test.my +0 -54
  89. 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: e8031fe74a54c47a6c344eef7a2c5e13855bf2bc
4
- data.tar.gz: c2f129e293c295731e643372d5add7704fdf9252
3
+ metadata.gz: 10d6d42881d428ea5359f83d8bfdce81ebf34ea7
4
+ data.tar.gz: fa2936dff1fbf455e7b8462c1c969cc023de020b
5
5
  SHA512:
6
- metadata.gz: 4fb206f4849977fcfe676b435b76de6d0145cc96507456fde0071f63b291f5743deeac07729f3d30717a58ac94acf55465266d32599395e76fc4e17249f18a7f
7
- data.tar.gz: 2735f64a252ba18ab5b43ddb62e0f3b96772902146dcc645a9dfb1754d99eb0609a8449d06469e45600b82908702b3c9219f3032f54cebaf7df8acfbba0d03ac
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
- vars = vars.any? ? (" " + vars.join(", ")) : ""
107
- "#<#{__component__.to_s}#{vars}>"
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?
@@ -45,8 +45,6 @@ import 'AST/DeclareString.my'
45
45
  import 'AST/DeclareFile.my'
46
46
  import 'AST/DeclareExtension.my'
47
47
  import 'AST/DeclareCategory.my'
48
-
49
- import 'AST/DeclareDecorator.my'
50
48
  import 'AST/DeclareMeme.my'
51
49
 
52
50
  import 'AST/Invoke.my'
@@ -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 parameters: |given| given || ParameterAssembly.new(line:self.line)
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
- blk = new_block_generator(g, self.parameters)
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
- self.parameters.bytecode(blk)
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
- self.parameters
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
- self.parameters.bytecode(blk)
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
- DeclareMemeBody < Block {
5
- node_type "DeclareMemeBody" # To prevent it from masquerading as a Block TODO: remove
6
- field name
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
- g.state.scope.nest_scope(self)
12
-
13
- meth = new_generator(g, self.name, self.parameters)
14
-
15
- meth.push_state(self)
16
- meth.state.push_super(self)
17
- meth.definition_line(self.line)
18
-
19
- meth.state.push_name(self.name.to_sym)
20
-
21
- self.parameters.bytecode(meth)
22
- self.body.bytecode(meth)
23
-
24
- meth.state.pop_name
25
-
26
- meth.local_count = local_count
27
- meth.local_names = local_names
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
- setter name: |x|
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
- body_implementation: DeclareMemeBody.new(
56
- line: self.line
57
- name: self.name
58
- parameters: self.parameters
59
- body: self.body
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
- bytecode: |g| {
63
- pos(g)
64
-
65
- ##
66
- # module = scope.for_method_definition
67
- # module.send :declare_meme, self.name, self.decorations,
68
- # BlockEnvironment(body_implementation)
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
- ::Myco.cscope.for_method_definition::DeclareMemeBody = ::Myco::Component.new([::Myco.find_constant(:Block)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
5
- .tap { |__c__| __c__.__last__ = __c__.component_eval {(
6
- declare_meme(:DeclareMemeBody, [[:node_type, []]], nil, ::Myco.cscope.dup) { |*| nil}
7
- declare_meme(:name, [[:field, []]], nil, ::Myco.cscope.dup) { |*| nil}
8
- declare_meme(:bytecode, [], nil, ::Myco.cscope.dup) { |g| (
9
- self.pos(g)
10
- g.state.scope.nest_scope(self)
11
- meth = self.new_generator(
12
- g,
13
- self.name,
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.add_scope
40
- g.create_block(meth)
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
- .tap { |__c__| __c__.__name__ = :DeclareMeme }
85
- )})}}.instance
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
- g.with_nested_var_scope(body_implementation) {
242
- g.var_scope_declare_locals(*self.parameters.names)
243
-
241
+ name = self.decorations.last
242
+ name.node_type == :symbol &? (
244
243
  g.add("declare_meme(")
245
- g.add(""self.name.inspect", ")
246
- g.add(self.decorations); g.add(", nil, ::Myco.cscope.dup)")
247
- g.add(" { ");
248
- g.add(self.parameters); g.add(" ")
249
- g.add(self.body);
250
- g.add("}")
251
- }
252
- }
253
- }
254
-
255
- DeclareDecorator << {
256
- to_ruby: |g| {
257
- g.add("["self.name.value.inspect", [")
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.parameters.names)
351
+ g.var_scope_declare_locals(*self.effective_parameters.names)
355
352
 
356
- g.add(" "); g.add(self.parameters); g.add(" "); g.add(self.body)
353
+ g.add(" "); g.add(self.effective_parameters); g.add(" "); g.add(self.body)
357
354
  }
358
355
  }
359
356
  }