myco 0.1.6 → 0.1.7
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/component.rb +2 -0
- data/lib/myco/bootstrap/evaluator.rb +58 -0
- data/lib/myco/bootstrap/instance.rb +1 -1
- data/lib/myco/bootstrap/meme.rb +4 -9
- data/lib/myco/bootstrap.my +1 -1
- data/lib/myco/bootstrap.my.rb +1 -1
- data/lib/myco/code_loader.rb +6 -1
- data/lib/myco/code_tools/AST/ArgumentAssembly.my +8 -12
- data/lib/myco/code_tools/AST/ArgumentAssembly.my.rb +12 -9
- data/lib/myco/code_tools/AST/ArrayAssembly.my +2 -3
- data/lib/myco/code_tools/AST/ArrayAssembly.my.rb +2 -5
- data/lib/myco/code_tools/AST/Block.my +4 -4
- data/lib/myco/code_tools/AST/Block.my.rb +3 -7
- data/lib/myco/code_tools/AST/BlockArgument.my +4 -5
- data/lib/myco/code_tools/AST/BlockArgument.my.rb +2 -5
- data/lib/myco/code_tools/AST/BlockLiteral.my +3 -4
- data/lib/myco/code_tools/AST/BlockLiteral.my.rb +6 -6
- data/lib/myco/code_tools/AST/BlockParameter.my +4 -11
- data/lib/myco/code_tools/AST/BlockParameter.my.rb +4 -13
- data/lib/myco/code_tools/AST/BranchOperator.my +2 -3
- data/lib/myco/code_tools/AST/BranchOperator.my.rb +4 -9
- data/lib/myco/code_tools/AST/ConstantAccess.my +11 -8
- data/lib/myco/code_tools/AST/ConstantAccess.my.rb +16 -12
- data/lib/myco/code_tools/AST/ConstantAssignment.my +13 -5
- data/lib/myco/code_tools/AST/ConstantAssignment.my.rb +16 -11
- data/lib/myco/code_tools/AST/ConstantDefine.my +2 -3
- data/lib/myco/code_tools/AST/ConstantDefine.my.rb +3 -7
- data/lib/myco/code_tools/AST/DeclareCategory.my +4 -14
- data/lib/myco/code_tools/AST/DeclareCategory.my.rb +20 -36
- data/lib/myco/code_tools/AST/DeclareDecorator.my +2 -3
- data/lib/myco/code_tools/AST/DeclareDecorator.my.rb +3 -7
- data/lib/myco/code_tools/AST/DeclareExtension.my +22 -0
- data/lib/myco/code_tools/AST/DeclareExtension.my.rb +19 -0
- data/lib/myco/code_tools/AST/DeclareFile.my +4 -15
- data/lib/myco/code_tools/AST/DeclareFile.my.rb +34 -50
- data/lib/myco/code_tools/AST/DeclareMeme.my +5 -7
- data/lib/myco/code_tools/AST/DeclareMeme.my.rb +8 -17
- data/lib/myco/code_tools/AST/DeclareObject.my +6 -18
- data/lib/myco/code_tools/AST/DeclareObject.my.rb +41 -59
- data/lib/myco/code_tools/AST/DeclareString.my +2 -3
- data/lib/myco/code_tools/AST/DeclareString.my.rb +3 -7
- data/lib/myco/code_tools/AST/{MycoModuleScope.my → DeclaredScope.my} +15 -16
- data/lib/myco/code_tools/AST/{MycoModuleScope.my.rb → DeclaredScope.my.rb} +15 -20
- data/lib/myco/code_tools/AST/Invoke.my +8 -8
- data/lib/myco/code_tools/AST/Invoke.my.rb +13 -21
- data/lib/myco/code_tools/AST/InvokeMethod.my +2 -3
- data/lib/myco/code_tools/AST/InvokeMethod.my.rb +4 -9
- data/lib/myco/code_tools/AST/KeywordAssembly.my +3 -4
- data/lib/myco/code_tools/AST/KeywordAssembly.my.rb +2 -5
- data/lib/myco/code_tools/AST/KeywordOptionalParameter.my +16 -0
- data/lib/myco/code_tools/AST/KeywordOptionalParameter.my.rb +14 -0
- data/lib/myco/code_tools/AST/KeywordRequiredParameter.my +16 -0
- data/lib/myco/code_tools/AST/KeywordRequiredParameter.my.rb +13 -0
- data/lib/myco/code_tools/AST/KeywordRestParameter.my +16 -0
- data/lib/myco/code_tools/AST/KeywordRestParameter.my.rb +13 -0
- data/lib/myco/code_tools/AST/LocalVariableAccessAmbiguous.my +2 -3
- data/lib/myco/code_tools/AST/LocalVariableAccessAmbiguous.my.rb +2 -5
- data/lib/myco/code_tools/AST/LocalVariableAssignment.my +3 -3
- data/lib/myco/code_tools/AST/LocalVariableAssignment.my.rb +3 -7
- data/lib/myco/code_tools/AST/Node.my +32 -2
- data/lib/myco/code_tools/AST/Node.my.rb +34 -1
- data/lib/myco/code_tools/AST/NumericLiteral.my +15 -0
- data/lib/myco/code_tools/AST/NumericLiteral.my.rb +12 -0
- data/lib/myco/code_tools/AST/OptionalParameter.my +24 -0
- data/lib/myco/code_tools/AST/OptionalParameter.my.rb +19 -0
- data/lib/myco/code_tools/AST/ParameterAssembly.my +60 -103
- data/lib/myco/code_tools/AST/ParameterAssembly.my.rb +60 -121
- data/lib/myco/code_tools/AST/PipeOperator.my +2 -3
- data/lib/myco/code_tools/AST/PipeOperator.my.rb +3 -7
- data/lib/myco/code_tools/AST/Quest.my +8 -10
- data/lib/myco/code_tools/AST/Quest.my.rb +9 -13
- data/lib/myco/code_tools/AST/RequiredParameter.my +12 -0
- data/lib/myco/code_tools/AST/RequiredParameter.my.rb +10 -0
- data/lib/myco/code_tools/AST/RestParameter.my +12 -0
- data/lib/myco/code_tools/AST/RestParameter.my.rb +10 -0
- data/lib/myco/code_tools/AST/Script.my +4 -4
- data/lib/myco/code_tools/AST/Script.my.rb +3 -7
- data/lib/myco/code_tools/AST/Sequence.my +2 -3
- data/lib/myco/code_tools/AST/Sequence.my.rb +2 -5
- data/lib/myco/code_tools/AST/SplatValue.my +3 -4
- data/lib/myco/code_tools/AST/SplatValue.my.rb +2 -5
- data/lib/myco/code_tools/AST/{DynamicString.my → StringCompose.my} +3 -4
- data/lib/myco/code_tools/AST/{DynamicString.my.rb → StringCompose.my.rb} +4 -7
- data/lib/myco/code_tools/AST/StringLiteral.my +2 -3
- data/lib/myco/code_tools/AST/StringLiteral.my.rb +2 -5
- data/lib/myco/code_tools/AST/{DynamicSymbol.my → SymbolCompose.my} +3 -4
- data/lib/myco/code_tools/AST/{DynamicSymbol.my.rb → SymbolCompose.my.rb} +4 -7
- data/lib/myco/code_tools/AST/SymbolLiteral.my +2 -3
- data/lib/myco/code_tools/AST/SymbolLiteral.my.rb +2 -5
- data/lib/myco/code_tools/AST/ToRuby.my +40 -57
- data/lib/myco/code_tools/AST/ToRuby.my.rb +43 -52
- data/lib/myco/code_tools/AST/misc.my +19 -24
- data/lib/myco/code_tools/AST/misc.my.rb +18 -23
- data/lib/myco/code_tools/AST.my +17 -8
- data/lib/myco/code_tools/AST.my.rb +14 -7
- data/lib/myco/code_tools/Parser.my +1 -1
- data/lib/myco/code_tools/parser/MycoBuilder.my +3 -3
- data/lib/myco/code_tools/parser/MycoBuilder.my.rb +3 -3
- data/lib/myco/code_tools/parser/MycoGrammar.my +67 -74
- data/lib/myco/code_tools/parser/MycoGrammar.my.rb +211 -316
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeHelpers.my +3 -3
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeHelpers.my.rb +2 -2
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeInstructions.my +9 -9
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeInstructions.my.rb +9 -9
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeParser.my +2 -2
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeParser.my.rb +4 -1
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Grammar.my +2 -3
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Grammar.my.rb +2 -3
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Machine.my +1 -1
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Machine.my.rb +1 -1
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Processor.my +5 -5
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Processor.my.rb +5 -5
- data/lib/myco/command.my +1 -1
- data/lib/myco/command.my.rb +1 -1
- data/lib/myco/core/BasicDecorators.my +10 -8
- data/lib/myco/core/BasicDecorators.my.rb +7 -7
- data/lib/myco/core/BasicObject.my +38 -7
- data/lib/myco/core/BasicObject.my.rb +23 -4
- data/lib/myco/tools/BasicCommand.my +1 -1
- data/lib/myco/tools/BasicCommand.my.rb +1 -1
- data/lib/myco/version.rb +1 -1
- data/lib/myco.rb +3 -0
- metadata +41 -26
- data/lib/myco/code_tools/AST/ConstantReopen.my +0 -29
- data/lib/myco/code_tools/AST/ConstantReopen.my.rb +0 -35
@@ -2,13 +2,9 @@
|
|
2
2
|
::Myco::Component.new([::Myco::FileToplevel], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
3
3
|
.tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco.find_constant(:CodeTools)::AST.component_eval {(::Myco.cscope.for_method_definition::ConstantDefine = ::Myco::Component.new([::Myco.find_constant(:Node)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
4
4
|
.tap { |__c__| __c__.__last__ = __c__.component_eval {(
|
5
|
-
declare_meme(:
|
6
|
-
declare_meme(:
|
7
|
-
::Myco.cscope.
|
8
|
-
:cdefn,
|
9
|
-
:constant,
|
10
|
-
:object
|
11
|
-
])
|
5
|
+
declare_meme(:cdefn, [[:node_type, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
6
|
+
declare_meme(:constant, [[:field, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
7
|
+
declare_meme(:object, [[:field, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
12
8
|
declare_meme(:implementation, [], nil, ::Myco.cscope.dup) { |*| (::Myco.find_constant(:ConstantAssignment).new({
|
13
9
|
:line => self.line,
|
14
10
|
:constant => self.constant,
|
@@ -1,24 +1,14 @@
|
|
1
1
|
|
2
2
|
CodeTools::AST << {
|
3
3
|
|
4
|
-
DeclareCategoryScope < MycoModuleScope {
|
5
|
-
body_bytecode: |g| {
|
6
|
-
g.push_scope
|
7
|
-
g.send(:set_myco_category, 0)
|
8
|
-
g.pop
|
9
|
-
|
10
|
-
self.body.bytecode(g)
|
11
|
-
}
|
12
|
-
}
|
13
|
-
|
14
4
|
DeclareCategory < Node {
|
15
|
-
|
16
|
-
|
17
|
-
Form: [:category, :name, :body]
|
5
|
+
node_type category
|
6
|
+
field name, field body
|
18
7
|
|
19
|
-
scope_implementation:
|
8
|
+
scope_implementation: DeclaredScope.new(
|
20
9
|
line: self.line
|
21
10
|
body: self.body
|
11
|
+
scope_method: :set_myco_category
|
22
12
|
)
|
23
13
|
|
24
14
|
bytecode: |g| {
|
@@ -1,40 +1,24 @@
|
|
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
|
-
|
3
|
+
.tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco.find_constant(:CodeTools)::AST.component_eval {(::Myco.cscope.for_method_definition::DeclareCategory = ::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(:category, [[:node_type, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
6
|
+
declare_meme(:name, [[:field, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
7
|
+
declare_meme(:body, [[:field, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
8
|
+
declare_meme(:scope_implementation, [], nil, ::Myco.cscope.dup) { |*| (::Myco.find_constant(:DeclaredScope).new({
|
9
|
+
:line => self.line,
|
10
|
+
:body => self.body,
|
11
|
+
:scope_method => :set_myco_category
|
12
|
+
}))}
|
13
|
+
declare_meme(:bytecode, [], nil, ::Myco.cscope.dup) { |g| (
|
14
|
+
self.pos(g)
|
15
|
+
g.push_self
|
16
|
+
g.push_literal(self.name)
|
7
17
|
g.send(
|
8
|
-
:
|
9
|
-
|
18
|
+
:__category__,
|
19
|
+
1
|
10
20
|
)
|
11
|
-
g
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
::Myco.cscope.for_method_definition::DeclareCategory = ::Myco::Component.new([::Myco.find_constant(:Node)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
16
|
-
.tap { |__c__| __c__.__last__ = __c__.component_eval {(
|
17
|
-
declare_meme(:name, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
18
|
-
declare_meme(:body, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
19
|
-
::Myco.cscope.for_method_definition::Form = ([
|
20
|
-
:category,
|
21
|
-
:name,
|
22
|
-
:body
|
23
|
-
])
|
24
|
-
declare_meme(:scope_implementation, [], nil, ::Myco.cscope.dup) { |*| (::Myco.find_constant(:DeclareCategoryScope).new({
|
25
|
-
:line => self.line,
|
26
|
-
:body => self.body
|
27
|
-
}))}
|
28
|
-
declare_meme(:bytecode, [], nil, ::Myco.cscope.dup) { |g| (
|
29
|
-
self.pos(g)
|
30
|
-
g.push_self
|
31
|
-
g.push_literal(self.name)
|
32
|
-
g.send(
|
33
|
-
:__category__,
|
34
|
-
1
|
35
|
-
)
|
36
|
-
self.scope_implementation.bytecode(g)
|
37
|
-
)}
|
38
|
-
)}}
|
39
|
-
.tap { |__c__| __c__.__name__ = :DeclareCategory }
|
40
|
-
)})}}.instance
|
21
|
+
self.scope_implementation.bytecode(g)
|
22
|
+
)}
|
23
|
+
)}}
|
24
|
+
.tap { |__c__| __c__.__name__ = :DeclareCategory })})}}.instance
|
@@ -2,13 +2,12 @@
|
|
2
2
|
CodeTools::AST << {
|
3
3
|
|
4
4
|
DeclareDecorator < Node {
|
5
|
-
|
5
|
+
node_type deco
|
6
|
+
field name, field arguments
|
6
7
|
|
7
8
|
setter arguments: |x|
|
8
9
|
x || ArrayAssembly.new(line:self.line, body:[])
|
9
10
|
|
10
|
-
Form: [:deco, :name, :arguments]
|
11
|
-
|
12
11
|
implementation: ArrayAssembly.new(
|
13
12
|
line:self.line
|
14
13
|
body:[self.name, self.arguments]
|
@@ -2,17 +2,13 @@
|
|
2
2
|
::Myco::Component.new([::Myco::FileToplevel], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
3
3
|
.tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco.find_constant(:CodeTools)::AST.component_eval {(::Myco.cscope.for_method_definition::DeclareDecorator = ::Myco::Component.new([::Myco.find_constant(:Node)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
4
4
|
.tap { |__c__| __c__.__last__ = __c__.component_eval {(
|
5
|
-
declare_meme(:
|
6
|
-
declare_meme(:
|
5
|
+
declare_meme(:deco, [[:node_type, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
6
|
+
declare_meme(:name, [[:field, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
7
|
+
declare_meme(:arguments, [[:field, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
7
8
|
declare_meme(:arguments, [[:setter, []]], nil, ::Myco.cscope.dup) { |x| (::Myco.branch_op(:"||", x) {::Myco.find_constant(:ArrayAssembly).new({
|
8
9
|
:line => self.line,
|
9
10
|
:body => []
|
10
11
|
})})}
|
11
|
-
::Myco.cscope.for_method_definition::Form = ([
|
12
|
-
:deco,
|
13
|
-
:name,
|
14
|
-
:arguments
|
15
|
-
])
|
16
12
|
declare_meme(:implementation, [], nil, ::Myco.cscope.dup) { |*| (::Myco.find_constant(:ArrayAssembly).new({
|
17
13
|
:line => self.line,
|
18
14
|
:body => [
|
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
CodeTools::AST << {
|
3
|
+
|
4
|
+
DeclareExtension < Node {
|
5
|
+
node_type copen
|
6
|
+
field constant, field body
|
7
|
+
|
8
|
+
bytecode: |g| {
|
9
|
+
pos(g)
|
10
|
+
|
11
|
+
scope = DeclaredScope.new(
|
12
|
+
line: self.line
|
13
|
+
body: self.body
|
14
|
+
scope_method: :set_myco_component
|
15
|
+
)
|
16
|
+
|
17
|
+
self.constant.bytecode(g)
|
18
|
+
scope.bytecode(g)
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
}
|
@@ -0,0 +1,19 @@
|
|
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::DeclareExtension = ::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(:copen, [[:node_type, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
6
|
+
declare_meme(:constant, [[: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
|
+
scope = ::Myco.find_constant(:DeclaredScope).new({
|
11
|
+
:line => self.line,
|
12
|
+
:body => self.body,
|
13
|
+
:scope_method => :set_myco_component
|
14
|
+
})
|
15
|
+
self.constant.bytecode(g)
|
16
|
+
scope.bytecode(g)
|
17
|
+
)}
|
18
|
+
)}}
|
19
|
+
.tap { |__c__| __c__.__name__ = :DeclareExtension })})}}.instance
|
@@ -1,30 +1,19 @@
|
|
1
1
|
|
2
2
|
CodeTools::AST << {
|
3
3
|
|
4
|
-
DeclareFileScope < MycoModuleScope {
|
5
|
-
body_bytecode: |g| {
|
6
|
-
g.push_scope
|
7
|
-
g.send(:set_myco_file, 0)
|
8
|
-
g.pop
|
9
|
-
|
10
|
-
self.body.bytecode(g)
|
11
|
-
}
|
12
|
-
}
|
13
|
-
|
14
4
|
DeclareFile < Node {
|
15
|
-
|
16
|
-
|
17
|
-
Form: [:declfile, :body]
|
5
|
+
node_type declfile
|
6
|
+
field body
|
18
7
|
|
19
8
|
# Use minimal inspect to avoid huge inspect output for inner AST nodes
|
20
9
|
# that store a reference to a DeclareFile in an instance variable.
|
21
10
|
inspect: to_s
|
22
11
|
|
23
12
|
implementation: {
|
24
|
-
type = ConstantAccess.new(line:self.line, toplevel:true, names:[:
|
13
|
+
type = ConstantAccess.new(line:self.line, toplevel:true, names:[:Myco, :FileToplevel])
|
25
14
|
types = ArrayAssembly.new(line:self.line, body:[type])
|
26
15
|
decl = DeclareObject.new(line:self.line, types:types, body:self.body)
|
27
|
-
decl.
|
16
|
+
decl.scope_implementation.scope_method = :set_myco_file
|
28
17
|
decl
|
29
18
|
}
|
30
19
|
|
@@ -1,53 +1,37 @@
|
|
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
|
-
|
3
|
+
.tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco.find_constant(:CodeTools)::AST.component_eval {(::Myco.cscope.for_method_definition::DeclareFile = ::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(:declfile, [[:node_type, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
6
|
+
declare_meme(:body, [[:field, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
7
|
+
declare_meme(:inspect, [], nil, ::Myco.cscope.dup) { |*| (self.to_s)}
|
8
|
+
declare_meme(:implementation, [], nil, ::Myco.cscope.dup) { |*| (
|
9
|
+
type = ::Myco.find_constant(:ConstantAccess).new({
|
10
|
+
:line => self.line,
|
11
|
+
:toplevel => true,
|
12
|
+
:names => [
|
13
|
+
:Myco,
|
14
|
+
:FileToplevel
|
15
|
+
]
|
16
|
+
})
|
17
|
+
types = ::Myco.find_constant(:ArrayAssembly).new({
|
18
|
+
:line => self.line,
|
19
|
+
:body => [type]
|
20
|
+
})
|
21
|
+
decl = ::Myco.find_constant(:DeclareObject).new({
|
22
|
+
:line => self.line,
|
23
|
+
:types => types,
|
24
|
+
:body => self.body
|
25
|
+
})
|
26
|
+
decl.scope_implementation.__send__(
|
27
|
+
:scope_method=,
|
28
|
+
:set_myco_file
|
10
29
|
)
|
11
|
-
|
12
|
-
|
13
|
-
)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
:declfile,
|
20
|
-
:body
|
21
|
-
])
|
22
|
-
declare_meme(:inspect, [], nil, ::Myco.cscope.dup) { |*| (self.to_s)}
|
23
|
-
declare_meme(:implementation, [], nil, ::Myco.cscope.dup) { |*| (
|
24
|
-
type = ::Myco.find_constant(:ConstantAccess).new({
|
25
|
-
:line => self.line,
|
26
|
-
:toplevel => true,
|
27
|
-
:names => [
|
28
|
-
:Myco,
|
29
|
-
:FileToplevel
|
30
|
-
]
|
31
|
-
})
|
32
|
-
types = ::Myco.find_constant(:ArrayAssembly).new({
|
33
|
-
:line => self.line,
|
34
|
-
:body => [type]
|
35
|
-
})
|
36
|
-
decl = ::Myco.find_constant(:DeclareObject).new({
|
37
|
-
:line => self.line,
|
38
|
-
:types => types,
|
39
|
-
:body => self.body
|
40
|
-
})
|
41
|
-
decl.__send__(
|
42
|
-
:scope_type=,
|
43
|
-
::Myco.find_constant(:DeclareFileScope)
|
44
|
-
)
|
45
|
-
decl
|
46
|
-
)}
|
47
|
-
declare_meme(:bytecode, [], nil, ::Myco.cscope.dup) { |g| (
|
48
|
-
self.pos(g)
|
49
|
-
self.implementation.bytecode(g)
|
50
|
-
)}
|
51
|
-
)}}
|
52
|
-
.tap { |__c__| __c__.__name__ = :DeclareFile }
|
53
|
-
)})}}.instance
|
30
|
+
decl
|
31
|
+
)}
|
32
|
+
declare_meme(:bytecode, [], nil, ::Myco.cscope.dup) { |g| (
|
33
|
+
self.pos(g)
|
34
|
+
self.implementation.bytecode(g)
|
35
|
+
)}
|
36
|
+
)}}
|
37
|
+
.tap { |__c__| __c__.__name__ = :DeclareFile })})}}.instance
|
@@ -2,9 +2,8 @@
|
|
2
2
|
CodeTools::AST << {
|
3
3
|
|
4
4
|
DeclareMemeBody < Block {
|
5
|
-
|
6
|
-
|
7
|
-
Form: [:"DeclareMemeBody", :name] # To prevent it from masquerading as a Block TODO: remove
|
5
|
+
node_type "DeclareMemeBody" # To prevent it from masquerading as a Block TODO: remove
|
6
|
+
field name
|
8
7
|
|
9
8
|
bytecode: |g| {
|
10
9
|
pos(g)
|
@@ -41,16 +40,15 @@ CodeTools::AST << {
|
|
41
40
|
}
|
42
41
|
|
43
42
|
DeclareMeme < Node {
|
44
|
-
|
45
|
-
|
46
|
-
Form: [:meme, :name, :decorations, :parameters, :body]
|
43
|
+
node_type meme
|
44
|
+
field name, field decorations, field parameters, field body
|
47
45
|
|
48
46
|
setter name: |x|
|
49
47
|
x.value
|
50
48
|
setter decorations: |x|
|
51
49
|
x || ArrayAssembly.new(line:line, body:[])
|
52
50
|
setter parameters: |x|
|
53
|
-
x || ParameterAssembly.new(line:line, required:[],
|
51
|
+
x || ParameterAssembly.new(line:line, required:[], rest:RestParameter.new(line:line))
|
54
52
|
setter body: |x|
|
55
53
|
x || NullLiteral.new(line:line)
|
56
54
|
|
@@ -3,11 +3,8 @@
|
|
3
3
|
.tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco.find_constant(:CodeTools)::AST.component_eval {(
|
4
4
|
::Myco.cscope.for_method_definition::DeclareMemeBody = ::Myco::Component.new([::Myco.find_constant(:Block)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
5
5
|
.tap { |__c__| __c__.__last__ = __c__.component_eval {(
|
6
|
-
declare_meme(:
|
7
|
-
::Myco.cscope.
|
8
|
-
:DeclareMemeBody,
|
9
|
-
:name
|
10
|
-
])
|
6
|
+
declare_meme(:DeclareMemeBody, [[:node_type, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
7
|
+
declare_meme(:name, [[:field, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
11
8
|
declare_meme(:bytecode, [], nil, ::Myco.cscope.dup) { |g| (
|
12
9
|
self.pos(g)
|
13
10
|
g.state.scope.nest_scope(self)
|
@@ -46,17 +43,11 @@
|
|
46
43
|
.tap { |__c__| __c__.__name__ = :DeclareMemeBody }
|
47
44
|
::Myco.cscope.for_method_definition::DeclareMeme = ::Myco::Component.new([::Myco.find_constant(:Node)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
48
45
|
.tap { |__c__| __c__.__last__ = __c__.component_eval {(
|
49
|
-
declare_meme(:
|
50
|
-
declare_meme(:
|
51
|
-
declare_meme(:
|
52
|
-
declare_meme(:
|
53
|
-
::Myco.cscope.
|
54
|
-
:meme,
|
55
|
-
:name,
|
56
|
-
:decorations,
|
57
|
-
:parameters,
|
58
|
-
:body
|
59
|
-
])
|
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}
|
60
51
|
declare_meme(:name, [[:setter, []]], nil, ::Myco.cscope.dup) { |x| (x.value)}
|
61
52
|
declare_meme(:decorations, [[:setter, []]], nil, ::Myco.cscope.dup) { |x| (::Myco.branch_op(:"||", x) {::Myco.find_constant(:ArrayAssembly).new({
|
62
53
|
:line => self.line,
|
@@ -65,7 +56,7 @@
|
|
65
56
|
declare_meme(:parameters, [[:setter, []]], nil, ::Myco.cscope.dup) { |x| (::Myco.branch_op(:"||", x) {::Myco.find_constant(:ParameterAssembly).new({
|
66
57
|
:line => self.line,
|
67
58
|
:required => [],
|
68
|
-
:
|
59
|
+
:rest => ::Myco.find_constant(:RestParameter).new({:line => self.line})
|
69
60
|
})})}
|
70
61
|
declare_meme(:body, [[:setter, []]], nil, ::Myco.cscope.dup) { |x| (::Myco.branch_op(:"||", x) {::Myco.find_constant(:NullLiteral).new({:line => self.line})})}
|
71
62
|
declare_meme(:body_implementation, [], nil, ::Myco.cscope.dup) { |*| (::Myco.find_constant(:DeclareMemeBody).new({
|
@@ -1,36 +1,24 @@
|
|
1
1
|
|
2
2
|
CodeTools::AST << {
|
3
3
|
|
4
|
-
DeclareObjectScope < MycoModuleScope {
|
5
|
-
body_bytecode: |g| {
|
6
|
-
g.push_scope
|
7
|
-
g.send(:set_myco_component, 0)
|
8
|
-
g.pop
|
9
|
-
|
10
|
-
self.body.bytecode(g)
|
11
|
-
}
|
12
|
-
}
|
13
|
-
|
14
4
|
DeclareObject < Node {
|
15
|
-
|
16
|
-
|
17
|
-
Form: [:declobj, :types, :body]
|
5
|
+
node_type declobj
|
6
|
+
field types, field body
|
18
7
|
|
19
8
|
var create: true
|
20
|
-
var scope_type: DeclareObjectScope
|
21
9
|
|
22
|
-
var scope_implementation:
|
10
|
+
var scope_implementation: DeclaredScope.new(
|
23
11
|
line: self.line
|
24
12
|
body: self.body
|
13
|
+
scope_method: :set_myco_component
|
25
14
|
)
|
26
15
|
|
27
16
|
bytecode: |g| {
|
28
17
|
pos(g)
|
29
18
|
|
30
19
|
# ::Myco::Component.new types, parent, filename
|
31
|
-
g.
|
32
|
-
g.find_const(:
|
33
|
-
g.find_const(:"Component")
|
20
|
+
g.push_myco
|
21
|
+
g.find_const(:Component)
|
34
22
|
self.types.bytecode(g)
|
35
23
|
g.push_scope; g.send(:for_method_definition, 0)
|
36
24
|
g.push_scope; g.send(:active_path, 0); g.meta_to_s
|
@@ -1,67 +1,49 @@
|
|
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
|
-
|
3
|
+
.tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco.find_constant(:CodeTools)::AST.component_eval {(::Myco.cscope.for_method_definition::DeclareObject = ::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(:declobj, [[:node_type, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
6
|
+
declare_meme(:types, [[:field, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
7
|
+
declare_meme(:body, [[:field, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
8
|
+
declare_meme(:create, [[:var, []]], nil, ::Myco.cscope.dup) { |*| (true)}
|
9
|
+
declare_meme(:scope_implementation, [[:var, []]], nil, ::Myco.cscope.dup) { |*| (::Myco.find_constant(:DeclaredScope).new({
|
10
|
+
:line => self.line,
|
11
|
+
:body => self.body,
|
12
|
+
:scope_method => :set_myco_component
|
13
|
+
}))}
|
14
|
+
declare_meme(:bytecode, [], nil, ::Myco.cscope.dup) { |g| (
|
15
|
+
self.pos(g)
|
16
|
+
g.push_myco
|
17
|
+
g.find_const(:Component)
|
18
|
+
self.types.bytecode(g)
|
6
19
|
g.push_scope
|
7
20
|
g.send(
|
8
|
-
:
|
21
|
+
:for_method_definition,
|
9
22
|
0
|
10
23
|
)
|
24
|
+
g.push_scope
|
25
|
+
g.send(
|
26
|
+
:active_path,
|
27
|
+
0
|
28
|
+
)
|
29
|
+
g.meta_to_s
|
30
|
+
g.push_int(self.line)
|
31
|
+
g.send(
|
32
|
+
:new,
|
33
|
+
4
|
34
|
+
)
|
35
|
+
g.dup_top
|
36
|
+
g.dup_top
|
37
|
+
self.scope_implementation.bytecode(g)
|
38
|
+
g.send(
|
39
|
+
:__last__=,
|
40
|
+
1
|
41
|
+
)
|
11
42
|
g.pop
|
12
|
-
self.
|
13
|
-
|
14
|
-
|
15
|
-
::Myco.cscope.for_method_definition::DeclareObject = ::Myco::Component.new([::Myco.find_constant(:Node)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
16
|
-
.tap { |__c__| __c__.__last__ = __c__.component_eval {(
|
17
|
-
declare_meme(:types, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
18
|
-
declare_meme(:body, [[:var, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
19
|
-
::Myco.cscope.for_method_definition::Form = ([
|
20
|
-
:declobj,
|
21
|
-
:types,
|
22
|
-
:body
|
23
|
-
])
|
24
|
-
declare_meme(:create, [[:var, []]], nil, ::Myco.cscope.dup) { |*| (true)}
|
25
|
-
declare_meme(:scope_type, [[:var, []]], nil, ::Myco.cscope.dup) { |*| (::Myco.find_constant(:DeclareObjectScope))}
|
26
|
-
declare_meme(:scope_implementation, [[:var, []]], nil, ::Myco.cscope.dup) { |*| (self.scope_type.new({
|
27
|
-
:line => self.line,
|
28
|
-
:body => self.body
|
29
|
-
}))}
|
30
|
-
declare_meme(:bytecode, [], nil, ::Myco.cscope.dup) { |g| (
|
31
|
-
self.pos(g)
|
32
|
-
g.push_cpath_top
|
33
|
-
g.find_const(:Myco)
|
34
|
-
g.find_const(:Component)
|
35
|
-
self.types.bytecode(g)
|
36
|
-
g.push_scope
|
37
|
-
g.send(
|
38
|
-
:for_method_definition,
|
39
|
-
0
|
40
|
-
)
|
41
|
-
g.push_scope
|
42
|
-
g.send(
|
43
|
-
:active_path,
|
44
|
-
0
|
45
|
-
)
|
46
|
-
g.meta_to_s
|
47
|
-
g.push_int(self.line)
|
48
|
-
g.send(
|
49
|
-
:new,
|
50
|
-
4
|
51
|
-
)
|
52
|
-
g.dup_top
|
53
|
-
g.dup_top
|
54
|
-
self.scope_implementation.bytecode(g)
|
55
|
-
g.send(
|
56
|
-
:__last__=,
|
57
|
-
1
|
58
|
-
)
|
59
|
-
g.pop
|
60
|
-
::Myco.branch_op(:"&&", self.create) {g.send(
|
61
|
-
:instance,
|
62
|
-
0
|
63
|
-
)}
|
43
|
+
::Myco.branch_op(:"&&", self.create) {g.send(
|
44
|
+
:instance,
|
45
|
+
0
|
64
46
|
)}
|
65
|
-
)}
|
66
|
-
|
67
|
-
)})}}.instance
|
47
|
+
)}
|
48
|
+
)}}
|
49
|
+
.tap { |__c__| __c__.__name__ = :DeclareObject })})}}.instance
|
@@ -2,13 +2,9 @@
|
|
2
2
|
::Myco::Component.new([::Myco::FileToplevel], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
3
3
|
.tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco.find_constant(:CodeTools)::AST.component_eval {(::Myco.cscope.for_method_definition::DeclareString = ::Myco::Component.new([::Myco.find_constant(:Node)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
4
4
|
.tap { |__c__| __c__.__last__ = __c__.component_eval {(
|
5
|
-
declare_meme(:
|
6
|
-
declare_meme(:
|
7
|
-
::Myco.cscope.
|
8
|
-
:declstr,
|
9
|
-
:types,
|
10
|
-
:string
|
11
|
-
])
|
5
|
+
declare_meme(:declstr, [[:node_type, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
6
|
+
declare_meme(:types, [[:field, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
7
|
+
declare_meme(:string, [[:field, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
12
8
|
declare_meme(:implementation, [], nil, ::Myco.cscope.dup) { |*| (::Myco.find_constant(:InvokeMethod).new({
|
13
9
|
:line => self.string.line,
|
14
10
|
:name => :from_string,
|
@@ -1,9 +1,10 @@
|
|
1
1
|
|
2
2
|
CodeTools::AST << {
|
3
3
|
|
4
|
-
# TODO:
|
5
|
-
|
4
|
+
# TODO: remove from AST nodes, as this is just common behavior and has nothing itself to do with syntax
|
5
|
+
DeclaredScope < CodeTools::Compiler::LocalVariables, Node {
|
6
6
|
var name, var body
|
7
|
+
var scope_method
|
7
8
|
|
8
9
|
bytecode: |g| {
|
9
10
|
pos(g)
|
@@ -13,26 +14,26 @@ CodeTools::AST << {
|
|
13
14
|
# (Necessary to pass local variables from above to memes below)
|
14
15
|
g.state.scope.nest_scope(self)
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
# TODO: figure out how to keep in sync with ClosedScope#attach_and_call impl
|
20
|
-
attach_and_call: |g, arg_name, scoped=false, pass_block=false| {
|
21
|
-
self.name = :"MycoModuleScope" # TODO: remove/fix
|
22
|
-
name = self.name || arg_name
|
17
|
+
# This name is arbitrary and is just for the benefit of backtraces
|
18
|
+
name = :__declaration__
|
19
|
+
|
23
20
|
meth = new_generator(g, name)
|
24
21
|
|
25
22
|
meth.push_state(self)
|
26
23
|
meth.for_module_body = true
|
27
24
|
|
28
|
-
|
29
|
-
|
30
|
-
meth.add_scope
|
31
|
-
)
|
25
|
+
meth.push_self
|
26
|
+
meth.add_scope
|
32
27
|
|
33
28
|
meth.state.push_name(name.to_sym)
|
34
29
|
|
35
|
-
|
30
|
+
self.scope_method && (
|
31
|
+
meth.push_scope
|
32
|
+
meth.send(self.scope_method, 0)
|
33
|
+
meth.pop
|
34
|
+
)
|
35
|
+
|
36
|
+
self.body.bytecode(meth)
|
36
37
|
|
37
38
|
meth.state.pop_name
|
38
39
|
|
@@ -53,8 +54,6 @@ CodeTools::AST << {
|
|
53
54
|
meth
|
54
55
|
}
|
55
56
|
|
56
|
-
body_bytecode: |g| self.body.bytecode(g)
|
57
|
-
|
58
57
|
# Become the AST scope parent of the given AST scope Node .
|
59
58
|
# This is only for the benefit of LocalVariableAccessAmbiguous
|
60
59
|
# being able to call search_local, and has nothing to do with
|