myco 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/lib/myco/code_tools/AST/ArgumentAssembly.my.rb +4 -4
  3. data/lib/myco/code_tools/AST/ArrayAssembly.my.rb +4 -4
  4. data/lib/myco/code_tools/AST/Block.my +104 -0
  5. data/lib/myco/code_tools/AST/Block.my.rb +126 -0
  6. data/lib/myco/code_tools/AST/BlockArgument.my.rb +4 -4
  7. data/lib/myco/code_tools/AST/BlockLiteral.my +15 -94
  8. data/lib/myco/code_tools/AST/BlockLiteral.my.rb +18 -121
  9. data/lib/myco/code_tools/AST/BlockParameter.my.rb +4 -4
  10. data/lib/myco/code_tools/AST/BranchOperator.my.rb +4 -4
  11. data/lib/myco/code_tools/AST/ConstantAccess.my.rb +4 -4
  12. data/lib/myco/code_tools/AST/ConstantAssignment.my.rb +4 -4
  13. data/lib/myco/code_tools/AST/ConstantDefine.my.rb +4 -4
  14. data/lib/myco/code_tools/AST/ConstantReopen.my.rb +6 -6
  15. data/lib/myco/code_tools/AST/DeclareCategory.my.rb +6 -6
  16. data/lib/myco/code_tools/AST/DeclareDecorator.my.rb +4 -4
  17. data/lib/myco/code_tools/AST/DeclareFile.my.rb +6 -6
  18. data/lib/myco/code_tools/AST/DeclareMeme.my +3 -1
  19. data/lib/myco/code_tools/AST/DeclareMeme.my.rb +10 -6
  20. data/lib/myco/code_tools/AST/DeclareObject.my.rb +6 -6
  21. data/lib/myco/code_tools/AST/DeclareString.my.rb +4 -4
  22. data/lib/myco/code_tools/AST/DynamicString.my.rb +4 -4
  23. data/lib/myco/code_tools/AST/DynamicSymbol.my.rb +4 -4
  24. data/lib/myco/code_tools/AST/Invoke.my +3 -4
  25. data/lib/myco/code_tools/AST/Invoke.my.rb +5 -15
  26. data/lib/myco/code_tools/AST/InvokeMethod.my.rb +4 -4
  27. data/lib/myco/code_tools/AST/KeywordAssembly.my.rb +4 -4
  28. data/lib/myco/code_tools/AST/LocalVariableAccessAmbiguous.my.rb +4 -4
  29. data/lib/myco/code_tools/AST/LocalVariableAssignment.my.rb +4 -4
  30. data/lib/myco/code_tools/AST/MycoModuleScope.my +1 -1
  31. data/lib/myco/code_tools/AST/MycoModuleScope.my.rb +2 -2
  32. data/lib/myco/code_tools/AST/Node.my.rb +4 -4
  33. data/lib/myco/code_tools/AST/ParameterAssembly.my.rb +4 -4
  34. data/lib/myco/code_tools/AST/PipeOperator.my +25 -0
  35. data/lib/myco/code_tools/AST/PipeOperator.my.rb +28 -0
  36. data/lib/myco/code_tools/AST/Quest.my.rb +7 -7
  37. data/lib/myco/code_tools/AST/Script.my.rb +4 -4
  38. data/lib/myco/code_tools/AST/{Body.my → Sequence.my} +2 -2
  39. data/lib/myco/code_tools/AST/{Body.my.rb → Sequence.my.rb} +6 -6
  40. data/lib/myco/code_tools/AST/SplatValue.my.rb +4 -4
  41. data/lib/myco/code_tools/AST/StringLiteral.my.rb +4 -4
  42. data/lib/myco/code_tools/AST/SymbolLiteral.my.rb +4 -4
  43. data/lib/myco/code_tools/AST/ToRuby.my +9 -3
  44. data/lib/myco/code_tools/AST/ToRuby.my.rb +7 -5
  45. data/lib/myco/code_tools/AST/misc.my.rb +17 -17
  46. data/lib/myco/code_tools/AST.my +5 -3
  47. data/lib/myco/code_tools/AST.my.rb +7 -6
  48. data/lib/myco/code_tools/Parser.my.rb +4 -4
  49. data/lib/myco/code_tools/parser/MycoBuilder.my.rb +1 -1
  50. data/lib/myco/code_tools/parser/MycoCharacterClasses.my.rb +2 -2
  51. data/lib/myco/code_tools/parser/MycoGrammar.my +68 -25
  52. data/lib/myco/code_tools/parser/MycoGrammar.my.rb +126 -51
  53. data/lib/myco/code_tools/parser/MycoTokens.my +3 -2
  54. data/lib/myco/code_tools/parser/MycoTokens.my.rb +11 -7
  55. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Builder.my.rb +2 -2
  56. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeHelpers.my +1 -1
  57. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeHelpers.my.rb +3 -3
  58. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeInstructions.my +11 -11
  59. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeInstructions.my.rb +11 -11
  60. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeParser.my +1 -1
  61. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeParser.my.rb +3 -6
  62. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Constructions.my.rb +40 -40
  63. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Grammar.my +3 -2
  64. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Grammar.my.rb +9 -8
  65. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Instructions.my.rb +2 -2
  66. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Machine.my.rb +2 -2
  67. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Parser.my.rb +2 -2
  68. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Patterns.my.rb +44 -44
  69. data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Processor.my.rb +4 -4
  70. data/lib/myco/tools/BasicCommand.my.rb +4 -4
  71. data/lib/myco/version.rb +1 -1
  72. metadata +16 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bc8d9aa903a16793652f0a984ea68b5dc0058dee
4
- data.tar.gz: 0ed0d4a3adb25552541a384019deeb7016d67057
3
+ metadata.gz: 9ac82f91bb59e1b38407f56839dc6f9a8a747813
4
+ data.tar.gz: d81314ee8a56b8950c7a42d253c77476ecef51e3
5
5
  SHA512:
6
- metadata.gz: d50aa9cdf66fec631609560ea0c5bac80a39a27be523ca32ad1529795cbb0aab4cf9db3b11b55e30718e86191915c86ec95edec7ee9562d0bb687ad13f1025c3
7
- data.tar.gz: c9ec127069f005ad5ba684b2a0fec708d7d8abceb297283838d323a14f65e0fe6df211840abf4cdbcce92db437c8b760049d2134ba30be15690c738a808d5fa5
6
+ metadata.gz: d594ed1f2693c0445ab02729a0f435ed13ca18251d4e9fd72b2b1070594e0fee3c7d3aa606936f57852fa41c1591f4250163463db690c91463ddc35aab6115d6
7
+ data.tar.gz: 2377868fe82a9a3fba6e5fdff7df63859d06c3514152661c32b89225f3d996501d5f363fa648645a727219b60441cfaa5a7536b0ee916adf162d182f33e03f91
@@ -1,13 +1,13 @@
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 {(::Myco.cscope.for_method_definition.const_set(:ArgumentAssembly, ::Myco::Component.new([::Myco.find_constant(:Node)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
3
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco.find_constant(:CodeTools)::AST.component_eval {(::Myco.cscope.for_method_definition::ArgumentAssembly = ::Myco::Component.new([::Myco.find_constant(:Node)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
4
4
  .tap { |__c__| __c__.__last__ = __c__.component_eval {(
5
5
  declare_meme(:body, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
6
6
  declare_meme(:block, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
7
- ::Myco.cscope.for_method_definition.const_set(:Form, ([
7
+ ::Myco.cscope.for_method_definition::Form = ([
8
8
  :argass,
9
9
  :body
10
- ]))
10
+ ])
11
11
  declare_meme(:body, [[:setter, []]], nil, ::Myco.cscope.dup) { |given_body| (
12
12
  ::Myco.branch_op(:"&&", given_body.last.__send__(
13
13
  :is_a?,
@@ -51,5 +51,5 @@
51
51
  :send_with_block
52
52
  )) {self.block_bytecode(g)}
53
53
  )}
54
- )}})
54
+ )}}
55
55
  .tap { |__c__| __c__.__name__ = :ArgumentAssembly })})}}.instance
@@ -1,12 +1,12 @@
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 {(::Myco.cscope.for_method_definition.const_set(:ArrayAssembly, ::Myco::Component.new([::Myco.find_constant(:Node)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
3
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco.find_constant(:CodeTools)::AST.component_eval {(::Myco.cscope.for_method_definition::ArrayAssembly = ::Myco::Component.new([::Myco.find_constant(:Node)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
4
4
  .tap { |__c__| __c__.__last__ = __c__.component_eval {(
5
5
  declare_meme(:body, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
6
- ::Myco.cscope.for_method_definition.const_set(:Form, ([
6
+ ::Myco.cscope.for_method_definition::Form = ([
7
7
  :arrass,
8
8
  :body
9
- ]))
9
+ ])
10
10
  declare_meme(:bytecode, [], nil, ::Myco.cscope.dup) { |g| (
11
11
  self.pos(g)
12
12
  ::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", self.body.__send__(:empty?)) {g.make_array(0)}) {(
@@ -33,5 +33,5 @@
33
33
  )})}
34
34
  )}
35
35
  )}
36
- )}})
36
+ )}}
37
37
  .tap { |__c__| __c__.__name__ = :ArrayAssembly })})}}.instance
@@ -0,0 +1,104 @@
1
+
2
+ CodeTools::AST << {
3
+
4
+ Block < CodeTools::Compiler::LocalVariables, Node {
5
+ var parameters, var body
6
+ var parent # TODO: investigate removing
7
+
8
+ Form: [:block, :parameters, :body]
9
+
10
+ CompilerClass: CodeTools::Compiler # TODO: remove this
11
+
12
+ setter parameters: |given| given || ParameterAssembly.new(line:self.line)
13
+ setter body: |given| given || NullLiteral.new(line:self.line)
14
+
15
+ locals: self.body.?locals.?body.map(&:value) ?? null
16
+
17
+ block_local?: |name|
18
+ locals.?include?(name) ?? false
19
+
20
+ module?: false
21
+
22
+ nest_scope: |scope| scope.parent = self
23
+
24
+ # Look up a local variable in this block's scope.
25
+ search_local: |name| {
26
+ (variable = self.variables[name]) &? (
27
+ variable.nested_reference
28
+ ) ?? (self.block_local?(name) &? (
29
+ self.new_local(name)
30
+ ) ?? ((reference = self.parent.search_local(name)) &? (
31
+ reference.depth = reference.depth + 1
32
+ reference
33
+ ) ?? (
34
+ null
35
+ )))
36
+ }
37
+
38
+ # Assign a slot number to a local variable access node.
39
+ # TODO: remove this method in favor of using search_local in all cases instead.
40
+ assign_local_reference: |var| {
41
+ var.variable = (variable = self.variables[var.name]) &? (
42
+ variable.reference
43
+ ) ?? (self.block_local?(var.name) &? (
44
+ variable = self.new_local(var.name)
45
+ variable.reference
46
+ ) ?? ((reference = self.parent.search_local(var.name)) &? (
47
+ reference.depth = reference.depth + 1
48
+ reference
49
+ ) ?? (
50
+ variable = self.new_local(var.name)
51
+ variable.reference
52
+ )))
53
+ }
54
+
55
+ new_local: |name| {
56
+ self.variables[name] = \
57
+ self.variables[name] || CompilerClass::LocalVariable.new(allocate_slot)
58
+ }
59
+
60
+ new_nested_local: |name| new_local(name).nested_reference
61
+
62
+ bytecode: |g| {
63
+ pos(g)
64
+
65
+ state = g.state
66
+ state.scope.nest_scope(self)
67
+
68
+ blk = new_block_generator(g, self.parameters)
69
+
70
+ blk.push_state(self)
71
+ blk.definition_line(self.line)
72
+ blk.state.push_super(state.super)
73
+ blk.state.push_eval(state.eval)
74
+
75
+ blk.state.push_name(blk.name)
76
+
77
+ # Push line info down.
78
+ pos(blk)
79
+
80
+ self.parameters.bytecode(blk)
81
+
82
+ blk.state.push_block
83
+ blk.push_modifiers
84
+ blk.break = null
85
+ blk.next = null
86
+ blk.redo = blk.new_label
87
+ blk.redo.set!
88
+
89
+ self.body.bytecode(blk)
90
+
91
+ blk.pop_modifiers
92
+ blk.state.pop_block
93
+ blk.ret
94
+ blk.close
95
+ blk.pop_state
96
+
97
+ blk.local_count = local_count
98
+ blk.local_names = local_names
99
+
100
+ g.create_block(blk)
101
+ }
102
+ }
103
+
104
+ }
@@ -0,0 +1,126 @@
1
+
2
+ ::Myco::Component.new([::Myco::FileToplevel], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
3
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco.find_constant(:CodeTools)::AST.component_eval {(::Myco.cscope.for_method_definition::Block = ::Myco::Component.new([
4
+ ::Myco.find_constant(:CodeTools)::Compiler::LocalVariables,
5
+ ::Myco.find_constant(:Node)
6
+ ], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
7
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(
8
+ declare_meme(:parameters, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
9
+ declare_meme(:body, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
10
+ declare_meme(:parent, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
11
+ ::Myco.cscope.for_method_definition::Form = ([
12
+ :block,
13
+ :parameters,
14
+ :body
15
+ ])
16
+ ::Myco.cscope.for_method_definition::CompilerClass = (::Myco.find_constant(:CodeTools)::Compiler)
17
+ declare_meme(:parameters, [[:setter, []]], nil, ::Myco.cscope.dup) { |given| (::Myco.branch_op(:"||", given) {::Myco.find_constant(:ParameterAssembly).new({:line => self.line})})}
18
+ declare_meme(:body, [[:setter, []]], nil, ::Myco.cscope.dup) { |given| (::Myco.branch_op(:"||", given) {::Myco.find_constant(:NullLiteral).new({:line => self.line})})}
19
+ declare_meme(:locals, [], nil, ::Myco.cscope.dup) { |*| (::Myco.branch_op(:"??", ((self.body.respond_to?(:locals).false? ? ::Myco::Void : self.body.locals).respond_to?(:body).false? ? ::Myco::Void : (self.body.respond_to?(:locals).false? ? ::Myco::Void : self.body.locals).body).map(&:value)) {nil})}
20
+ declare_meme(:block_local?, [], nil, ::Myco.cscope.dup) { |name| (::Myco.branch_op(:"??", (self.locals.respond_to?(:include?).false? ? ::Myco::Void : self.locals.__send__(
21
+ :include?,
22
+ name
23
+ ))) {false})}
24
+ declare_meme(:module?, [], nil, ::Myco.cscope.dup) { |*| (false)}
25
+ declare_meme(:nest_scope, [], nil, ::Myco.cscope.dup) { |scope| (scope.__send__(
26
+ :parent=,
27
+ self
28
+ ))}
29
+ declare_meme(:search_local, [], nil, ::Myco.cscope.dup) { |name| (::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", variable = self.variables.__send__(
30
+ :[],
31
+ name
32
+ )) {variable.nested_reference}) {::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", self.__send__(
33
+ :block_local?,
34
+ name
35
+ )) {self.new_local(name)}) {::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", reference = self.parent.search_local(name)) {(
36
+ reference.__send__(
37
+ :depth=,
38
+ reference.depth.__send__(
39
+ :+,
40
+ 1
41
+ )
42
+ )
43
+ reference
44
+ )}) {nil}}})}
45
+ declare_meme(:assign_local_reference, [], nil, ::Myco.cscope.dup) { |var| (var.__send__(
46
+ :variable=,
47
+ ::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", variable = self.variables.__send__(
48
+ :[],
49
+ var.name
50
+ )) {variable.reference}) {::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", self.__send__(
51
+ :block_local?,
52
+ var.name
53
+ )) {(
54
+ variable = self.new_local(var.name)
55
+ variable.reference
56
+ )}) {::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", reference = self.parent.search_local(var.name)) {(
57
+ reference.__send__(
58
+ :depth=,
59
+ reference.depth.__send__(
60
+ :+,
61
+ 1
62
+ )
63
+ )
64
+ reference
65
+ )}) {(
66
+ variable = self.new_local(var.name)
67
+ variable.reference
68
+ )}}}
69
+ ))}
70
+ declare_meme(:new_local, [], nil, ::Myco.cscope.dup) { |name| (self.variables.__send__(
71
+ :[]=,
72
+ name,
73
+ ::Myco.branch_op(:"||", self.variables.__send__(
74
+ :[],
75
+ name
76
+ )) {::Myco.find_constant(:CompilerClass)::LocalVariable.new(self.allocate_slot)}
77
+ ))}
78
+ declare_meme(:new_nested_local, [], nil, ::Myco.cscope.dup) { |name| (self.new_local(name).nested_reference)}
79
+ declare_meme(:bytecode, [], nil, ::Myco.cscope.dup) { |g| (
80
+ self.pos(g)
81
+ state = g.state
82
+ state.scope.nest_scope(self)
83
+ blk = self.new_block_generator(
84
+ g,
85
+ self.parameters
86
+ )
87
+ blk.push_state(self)
88
+ blk.definition_line(self.line)
89
+ blk.state.push_super(state.super)
90
+ blk.state.push_eval(state.eval)
91
+ blk.state.push_name(blk.name)
92
+ self.pos(blk)
93
+ self.parameters.bytecode(blk)
94
+ blk.state.push_block
95
+ blk.push_modifiers
96
+ blk.__send__(
97
+ :break=,
98
+ nil
99
+ )
100
+ blk.__send__(
101
+ :next=,
102
+ nil
103
+ )
104
+ blk.__send__(
105
+ :redo=,
106
+ blk.new_label
107
+ )
108
+ blk.redo.__send__(:set!)
109
+ self.body.bytecode(blk)
110
+ blk.pop_modifiers
111
+ blk.state.pop_block
112
+ blk.ret
113
+ blk.close
114
+ blk.pop_state
115
+ blk.__send__(
116
+ :local_count=,
117
+ self.local_count
118
+ )
119
+ blk.__send__(
120
+ :local_names=,
121
+ self.local_names
122
+ )
123
+ g.create_block(blk)
124
+ )}
125
+ )}}
126
+ .tap { |__c__| __c__.__name__ = :Block })})}}.instance
@@ -1,12 +1,12 @@
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 {(::Myco.cscope.for_method_definition.const_set(:BlockArgument, ::Myco::Component.new([::Myco.find_constant(:Node)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
3
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco.find_constant(:CodeTools)::AST.component_eval {(::Myco.cscope.for_method_definition::BlockArgument = ::Myco::Component.new([::Myco.find_constant(:Node)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
4
4
  .tap { |__c__| __c__.__last__ = __c__.component_eval {(
5
5
  declare_meme(:body, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
6
- ::Myco.cscope.for_method_definition.const_set(:Form, ([
6
+ ::Myco.cscope.for_method_definition::Form = ([
7
7
  :blkarg,
8
8
  :body
9
- ]))
9
+ ])
10
10
  declare_meme(:bytecode, [], nil, ::Myco.cscope.dup) { |g| (
11
11
  self.body.bytecode(g)
12
12
  done_label = g.new_label
@@ -22,5 +22,5 @@
22
22
  )
23
23
  done_label.__send__(:set!)
24
24
  )}
25
- )}})
25
+ )}}
26
26
  .tap { |__c__| __c__.__name__ = :BlockArgument })})}}.instance
@@ -1,104 +1,25 @@
1
1
 
2
2
  CodeTools::AST << {
3
3
 
4
- BlockLiteral < CodeTools::Compiler::LocalVariables, Node {
5
- var parameters, var body
6
- var parent # TODO: investigate removing
4
+ BlockLiteral < Node {
5
+ var block
7
6
 
8
- Form: [:blklit, :parameters, :body]
7
+ Form: [:blklit, :block]
9
8
 
10
- CompilerClass: CodeTools::Compiler # TODO: remove this
9
+ implementation_receiver: ConstantAccess.new(
10
+ line: self.line
11
+ toplevel: true
12
+ names: [:"Proc"]
13
+ )
11
14
 
12
- setter parameters: |given| given || ParameterAssembly.new(line:self.line)
13
- setter body: |given| given || NullLiteral.new(line:self.line)
15
+ implementation: Invoke.new(
16
+ line: self.line
17
+ receiver: self.implementation_receiver
18
+ name: (:new)
19
+ block: self.block
20
+ )
14
21
 
15
- locals: self.body.?locals.?body.map(&:value) ?? null
16
-
17
- block_local?: |name|
18
- locals.?include?(name) ?? false
19
-
20
- module?: false
21
-
22
- nest_scope: |scope| scope.parent = self
23
-
24
- # Look up a local variable in this block's scope.
25
- search_local: |name| {
26
- (variable = self.variables[name]) &? (
27
- variable.nested_reference
28
- ) ?? (self.block_local?(name) &? (
29
- self.new_local(name)
30
- ) ?? ((reference = self.parent.search_local(name)) &? (
31
- reference.depth = reference.depth + 1
32
- reference
33
- ) ?? (
34
- null
35
- )))
36
- }
37
-
38
- # Assign a slot number to a local variable access node.
39
- # TODO: remove this method in favor of using search_local in all cases instead.
40
- assign_local_reference: |var| {
41
- var.variable = (variable = self.variables[var.name]) &? (
42
- variable.reference
43
- ) ?? (self.block_local?(var.name) &? (
44
- variable = self.new_local(var.name)
45
- variable.reference
46
- ) ?? ((reference = self.parent.search_local(var.name)) &? (
47
- reference.depth = reference.depth + 1
48
- reference
49
- ) ?? (
50
- variable = self.new_local(var.name)
51
- variable.reference
52
- )))
53
- }
54
-
55
- new_local: |name| {
56
- self.variables[name] = \
57
- self.variables[name] || CompilerClass::LocalVariable.new(allocate_slot)
58
- }
59
-
60
- new_nested_local: |name| new_local(name).nested_reference
61
-
62
- bytecode: |g| {
63
- pos(g)
64
-
65
- state = g.state
66
- state.scope.nest_scope(self)
67
-
68
- blk = new_block_generator(g, self.parameters)
69
-
70
- blk.push_state(self)
71
- blk.definition_line(self.line)
72
- blk.state.push_super(state.super)
73
- blk.state.push_eval(state.eval)
74
-
75
- blk.state.push_name(blk.name)
76
-
77
- # Push line info down.
78
- pos(blk)
79
-
80
- self.parameters.bytecode(blk)
81
-
82
- blk.state.push_block
83
- blk.push_modifiers
84
- blk.break = null
85
- blk.next = null
86
- blk.redo = blk.new_label
87
- blk.redo.set!
88
-
89
- self.body.bytecode(blk)
90
-
91
- blk.pop_modifiers
92
- blk.state.pop_block
93
- blk.ret
94
- blk.close
95
- blk.pop_state
96
-
97
- blk.local_count = local_count
98
- blk.local_names = local_names
99
-
100
- g.create_block(blk)
101
- }
22
+ bytecode: |g| implementation.bytecode(g)
102
23
  }
103
24
 
104
25
  }
@@ -1,126 +1,23 @@
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 {(::Myco.cscope.for_method_definition.const_set(:BlockLiteral, ::Myco::Component.new([
4
- ::Myco.find_constant(:CodeTools)::Compiler::LocalVariables,
5
- ::Myco.find_constant(:Node)
6
- ], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
3
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco.find_constant(:CodeTools)::AST.component_eval {(::Myco.cscope.for_method_definition::BlockLiteral = ::Myco::Component.new([::Myco.find_constant(:Node)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
7
4
  .tap { |__c__| __c__.__last__ = __c__.component_eval {(
8
- declare_meme(:parameters, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
9
- declare_meme(:body, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
10
- declare_meme(:parent, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
11
- ::Myco.cscope.for_method_definition.const_set(:Form, ([
5
+ declare_meme(:block, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
6
+ ::Myco.cscope.for_method_definition::Form = ([
12
7
  :blklit,
13
- :parameters,
14
- :body
15
- ]))
16
- ::Myco.cscope.for_method_definition.const_set(:CompilerClass, (::Myco.find_constant(:CodeTools)::Compiler))
17
- declare_meme(:parameters, [[:setter, []]], nil, ::Myco.cscope.dup) { |given| (::Myco.branch_op(:"||", given) {::Myco.find_constant(:ParameterAssembly).new({:line => self.line})})}
18
- declare_meme(:body, [[:setter, []]], nil, ::Myco.cscope.dup) { |given| (::Myco.branch_op(:"||", given) {::Myco.find_constant(:NullLiteral).new({:line => self.line})})}
19
- declare_meme(:locals, [], nil, ::Myco.cscope.dup) { |*| (::Myco.branch_op(:"??", ((self.body.respond_to?(:locals).false? ? ::Myco::Void : self.body.locals).respond_to?(:body).false? ? ::Myco::Void : (self.body.respond_to?(:locals).false? ? ::Myco::Void : self.body.locals).body).map(&:value)) {nil})}
20
- declare_meme(:block_local?, [], nil, ::Myco.cscope.dup) { |name| (::Myco.branch_op(:"??", (self.locals.respond_to?(:include?).false? ? ::Myco::Void : self.locals.__send__(
21
- :include?,
22
- name
23
- ))) {false})}
24
- declare_meme(:module?, [], nil, ::Myco.cscope.dup) { |*| (false)}
25
- declare_meme(:nest_scope, [], nil, ::Myco.cscope.dup) { |scope| (scope.__send__(
26
- :parent=,
27
- self
28
- ))}
29
- declare_meme(:search_local, [], nil, ::Myco.cscope.dup) { |name| (::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", variable = self.variables.__send__(
30
- :[],
31
- name
32
- )) {variable.nested_reference}) {::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", self.__send__(
33
- :block_local?,
34
- name
35
- )) {self.new_local(name)}) {::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", reference = self.parent.search_local(name)) {(
36
- reference.__send__(
37
- :depth=,
38
- reference.depth.__send__(
39
- :+,
40
- 1
41
- )
42
- )
43
- reference
44
- )}) {nil}}})}
45
- declare_meme(:assign_local_reference, [], nil, ::Myco.cscope.dup) { |var| (var.__send__(
46
- :variable=,
47
- ::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", variable = self.variables.__send__(
48
- :[],
49
- var.name
50
- )) {variable.reference}) {::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", self.__send__(
51
- :block_local?,
52
- var.name
53
- )) {(
54
- variable = self.new_local(var.name)
55
- variable.reference
56
- )}) {::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", reference = self.parent.search_local(var.name)) {(
57
- reference.__send__(
58
- :depth=,
59
- reference.depth.__send__(
60
- :+,
61
- 1
62
- )
63
- )
64
- reference
65
- )}) {(
66
- variable = self.new_local(var.name)
67
- variable.reference
68
- )}}}
69
- ))}
70
- declare_meme(:new_local, [], nil, ::Myco.cscope.dup) { |name| (self.variables.__send__(
71
- :[]=,
72
- name,
73
- ::Myco.branch_op(:"||", self.variables.__send__(
74
- :[],
75
- name
76
- )) {::Myco.find_constant(:CompilerClass)::LocalVariable.new(self.allocate_slot)}
77
- ))}
78
- declare_meme(:new_nested_local, [], nil, ::Myco.cscope.dup) { |name| (self.new_local(name).nested_reference)}
79
- declare_meme(:bytecode, [], nil, ::Myco.cscope.dup) { |g| (
80
- self.pos(g)
81
- state = g.state
82
- state.scope.nest_scope(self)
83
- blk = self.new_block_generator(
84
- g,
85
- self.parameters
86
- )
87
- blk.push_state(self)
88
- blk.definition_line(self.line)
89
- blk.state.push_super(state.super)
90
- blk.state.push_eval(state.eval)
91
- blk.state.push_name(blk.name)
92
- self.pos(blk)
93
- self.parameters.bytecode(blk)
94
- blk.state.push_block
95
- blk.push_modifiers
96
- blk.__send__(
97
- :break=,
98
- nil
99
- )
100
- blk.__send__(
101
- :next=,
102
- nil
103
- )
104
- blk.__send__(
105
- :redo=,
106
- blk.new_label
107
- )
108
- blk.redo.__send__(:set!)
109
- self.body.bytecode(blk)
110
- blk.pop_modifiers
111
- blk.state.pop_block
112
- blk.ret
113
- blk.close
114
- blk.pop_state
115
- blk.__send__(
116
- :local_count=,
117
- self.local_count
118
- )
119
- blk.__send__(
120
- :local_names=,
121
- self.local_names
122
- )
123
- g.create_block(blk)
124
- )}
125
- )}})
8
+ :block
9
+ ])
10
+ declare_meme(:implementation_receiver, [], nil, ::Myco.cscope.dup) { |*| (::Myco.find_constant(:ConstantAccess).new({
11
+ :line => self.line,
12
+ :toplevel => true,
13
+ :names => [:Proc]
14
+ }))}
15
+ declare_meme(:implementation, [], nil, ::Myco.cscope.dup) { |*| (::Myco.find_constant(:Invoke).new({
16
+ :line => self.line,
17
+ :receiver => self.implementation_receiver,
18
+ :name => :new,
19
+ :block => self.block
20
+ }))}
21
+ declare_meme(:bytecode, [], nil, ::Myco.cscope.dup) { |g| (self.implementation.bytecode(g))}
22
+ )}}
126
23
  .tap { |__c__| __c__.__name__ = :BlockLiteral })})}}.instance
@@ -1,13 +1,13 @@
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 {(::Myco.cscope.for_method_definition.const_set(:BlockParameter, ::Myco::Component.new([::Myco.find_constant(:Node)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
3
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco.find_constant(:CodeTools)::AST.component_eval {(::Myco.cscope.for_method_definition::BlockParameter = ::Myco::Component.new([::Myco.find_constant(:Node)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
4
4
  .tap { |__c__| __c__.__last__ = __c__.component_eval {(
5
5
  declare_meme(:name, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
6
6
  declare_meme(:variable, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
7
- ::Myco.cscope.for_method_definition.const_set(:Form, ([
7
+ ::Myco.cscope.for_method_definition::Form = ([
8
8
  :blkprm,
9
9
  :name
10
- ]))
10
+ ])
11
11
  declare_meme(:bytecode, [], nil, ::Myco.cscope.dup) { |g| (
12
12
  self.pos(g)
13
13
  g.push_proc
@@ -20,5 +20,5 @@
20
20
  )}) {g.set_local(self.variable.slot)}
21
21
  g.pop
22
22
  )}
23
- )}})
23
+ )}}
24
24
  .tap { |__c__| __c__.__name__ = :BlockParameter })})}}.instance
@@ -1,16 +1,16 @@
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 {(::Myco.cscope.for_method_definition.const_set(:BranchOperator, ::Myco::Component.new([::Myco.find_constant(:Node)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
3
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco.find_constant(:CodeTools)::AST.component_eval {(::Myco.cscope.for_method_definition::BranchOperator = ::Myco::Component.new([::Myco.find_constant(:Node)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
4
4
  .tap { |__c__| __c__.__last__ = __c__.component_eval {(
5
5
  declare_meme(:type, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
6
6
  declare_meme(:left, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
7
7
  declare_meme(:right, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
8
- ::Myco.cscope.for_method_definition.const_set(:Form, ([
8
+ ::Myco.cscope.for_method_definition::Form = ([
9
9
  :branch_op,
10
10
  :type,
11
11
  :left,
12
12
  :right
13
- ]))
13
+ ])
14
14
  declare_meme(:bytecode, [], nil, ::Myco.cscope.dup) { |g| (
15
15
  self.pos(g)
16
16
  done_label = g.new_label
@@ -83,5 +83,5 @@
83
83
  self.right.bytecode(g)
84
84
  done_label.__send__(:set!)
85
85
  )}
86
- )}})
86
+ )}}
87
87
  .tap { |__c__| __c__.__name__ = :BranchOperator })})}}.instance
@@ -1,14 +1,14 @@
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 {(::Myco.cscope.for_method_definition.const_set(:ConstantAccess, ::Myco::Component.new([::Myco.find_constant(:Node)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
3
+ .tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco.find_constant(:CodeTools)::AST.component_eval {(::Myco.cscope.for_method_definition::ConstantAccess = ::Myco::Component.new([::Myco.find_constant(:Node)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
4
4
  .tap { |__c__| __c__.__last__ = __c__.component_eval {(
5
5
  declare_meme(:toplevel, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
6
6
  declare_meme(:names, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
7
- ::Myco.cscope.for_method_definition.const_set(:Form, ([
7
+ ::Myco.cscope.for_method_definition::Form = ([
8
8
  :const,
9
9
  :toplevel,
10
10
  :names
11
- ]))
11
+ ])
12
12
  declare_meme(:bytecode, [], nil, ::Myco.cscope.dup) { |g| (
13
13
  self.pos(g)
14
14
  name_list = self.names.map(&:to_sym)
@@ -32,5 +32,5 @@
32
32
  2
33
33
  )
34
34
  )})}
35
- )}})
35
+ )}}
36
36
  .tap { |__c__| __c__.__name__ = :ConstantAccess })})}}.instance