myco 0.1.3 → 0.1.4
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 +6 -7
- data/lib/myco/bootstrap/instance.rb +14 -9
- data/lib/myco/bootstrap/meme.rb +34 -3
- data/lib/myco/code_loader.rb +17 -34
- data/lib/myco/code_tools/AST/ArgumentAssembly.my +60 -0
- data/lib/myco/code_tools/AST/ArgumentAssembly.my.rb +55 -0
- data/lib/myco/code_tools/AST/ArrayAssembly.my +43 -0
- data/lib/myco/code_tools/AST/ArrayAssembly.my.rb +37 -0
- data/lib/myco/code_tools/AST/BlockArgument.my +25 -0
- data/lib/myco/code_tools/AST/BlockArgument.my.rb +26 -0
- data/lib/myco/code_tools/AST/BlockLiteral.my +104 -0
- data/lib/myco/code_tools/AST/BlockLiteral.my.rb +126 -0
- data/lib/myco/code_tools/AST/BlockParameter.my +25 -0
- data/lib/myco/code_tools/AST/BlockParameter.my.rb +24 -0
- data/lib/myco/code_tools/AST/Body.my +18 -0
- data/lib/myco/code_tools/AST/Body.my.rb +20 -0
- data/lib/myco/code_tools/AST/BranchOperator.my +59 -0
- data/lib/myco/code_tools/AST/BranchOperator.my.rb +87 -0
- data/lib/myco/code_tools/AST/ConstantAccess.my +30 -0
- data/lib/myco/code_tools/AST/ConstantAccess.my.rb +32 -0
- data/lib/myco/code_tools/AST/ConstantAssignment.my +40 -0
- data/lib/myco/code_tools/AST/ConstantAssignment.my.rb +45 -0
- data/lib/myco/code_tools/AST/ConstantDefine.my +30 -0
- data/lib/myco/code_tools/AST/ConstantDefine.my.rb +36 -0
- data/lib/myco/code_tools/AST/ConstantReopen.my +29 -0
- data/lib/myco/code_tools/AST/ConstantReopen.my.rb +35 -0
- data/lib/myco/code_tools/AST/DeclareCategory.my +35 -0
- data/lib/myco/code_tools/AST/DeclareCategory.my.rb +40 -0
- data/lib/myco/code_tools/AST/DeclareDecorator.my +20 -0
- data/lib/myco/code_tools/AST/DeclareDecorator.my.rb +28 -0
- data/lib/myco/code_tools/AST/DeclareFile.my +38 -0
- data/lib/myco/code_tools/AST/DeclareFile.my.rb +53 -0
- data/lib/myco/code_tools/AST/DeclareMeme.my +79 -0
- data/lib/myco/code_tools/AST/DeclareMeme.my.rb +90 -0
- data/lib/myco/code_tools/AST/DeclareObject.my +58 -0
- data/lib/myco/code_tools/AST/DeclareObject.my.rb +67 -0
- data/lib/myco/code_tools/AST/DeclareString.my +26 -0
- data/lib/myco/code_tools/AST/DeclareString.my.rb +30 -0
- data/lib/myco/code_tools/AST/DynamicString.my +21 -0
- data/lib/myco/code_tools/AST/DynamicString.my.rb +22 -0
- data/lib/myco/code_tools/AST/DynamicSymbol.my +22 -0
- data/lib/myco/code_tools/AST/DynamicSymbol.my.rb +26 -0
- data/lib/myco/code_tools/AST/Invoke.my +37 -0
- data/lib/myco/code_tools/AST/Invoke.my.rb +58 -0
- data/lib/myco/code_tools/AST/InvokeMethod.my +19 -0
- data/lib/myco/code_tools/AST/InvokeMethod.my.rb +25 -0
- data/lib/myco/code_tools/AST/KeywordAssembly.my +30 -0
- data/lib/myco/code_tools/AST/KeywordAssembly.my.rb +36 -0
- data/lib/myco/code_tools/AST/LocalVariableAccessAmbiguous.my +22 -0
- data/lib/myco/code_tools/AST/LocalVariableAccessAmbiguous.my.rb +22 -0
- data/lib/myco/code_tools/AST/LocalVariableAssignment.my +20 -0
- data/lib/myco/code_tools/AST/LocalVariableAssignment.my.rb +20 -0
- data/lib/myco/{parser/ast/myco_module_scope.rb → code_tools/AST/MycoModuleScope.my} +32 -39
- data/lib/myco/code_tools/AST/MycoModuleScope.my.rb +82 -0
- data/lib/myco/code_tools/AST/Node.my +67 -0
- data/lib/myco/code_tools/AST/Node.my.rb +84 -0
- data/lib/myco/code_tools/AST/ParameterAssembly.my +248 -0
- data/lib/myco/code_tools/AST/ParameterAssembly.my.rb +314 -0
- data/lib/myco/code_tools/AST/Quest.my +61 -0
- data/lib/myco/code_tools/AST/Quest.my.rb +51 -0
- data/lib/myco/code_tools/AST/Script.my +27 -0
- data/lib/myco/code_tools/AST/Script.my.rb +33 -0
- data/lib/myco/code_tools/AST/SplatValue.my +23 -0
- data/lib/myco/code_tools/AST/SplatValue.my.rb +25 -0
- data/lib/myco/code_tools/AST/StringLiteral.my +17 -0
- data/lib/myco/code_tools/AST/StringLiteral.my.rb +16 -0
- data/lib/myco/code_tools/AST/SymbolLiteral.my +16 -0
- data/lib/myco/code_tools/AST/SymbolLiteral.my.rb +15 -0
- data/lib/myco/{parser/ast → code_tools/AST}/ToRuby.my +89 -90
- data/lib/myco/{parser/ast → code_tools/AST}/ToRuby.my.rb +89 -101
- data/lib/myco/code_tools/AST/misc.my +57 -0
- data/lib/myco/code_tools/AST/misc.my.rb +81 -0
- data/lib/myco/code_tools/AST.my +52 -0
- data/lib/myco/code_tools/AST.my.rb +40 -0
- data/lib/myco/{parser → code_tools/parser}/peg_parser.rb +107 -199
- data/lib/myco/{parser.rb → code_tools/parser.rb} +0 -17
- data/lib/myco/code_tools.rb +5 -0
- data/lib/myco/core/BasicDecorators.my +47 -0
- data/lib/myco/core/BasicDecorators.my.rb +66 -0
- data/lib/myco/core/FileToplevel.my +14 -3
- data/lib/myco/core/FileToplevel.my.rb +27 -12
- data/lib/myco/eval.rb +7 -37
- data/lib/myco/version.rb +1 -4
- data/lib/myco.rb +20 -22
- metadata +74 -66
- data/lib/myco/parser/ast/argument_assembly.rb +0 -76
- data/lib/myco/parser/ast/array_assembly.rb +0 -57
- data/lib/myco/parser/ast/branch_operator.rb +0 -73
- data/lib/myco/parser/ast/constant_access.rb +0 -15
- data/lib/myco/parser/ast/constant_define.rb +0 -40
- data/lib/myco/parser/ast/constant_reopen.rb +0 -46
- data/lib/myco/parser/ast/declare_category.rb +0 -53
- data/lib/myco/parser/ast/declare_decorator.rb +0 -35
- data/lib/myco/parser/ast/declare_file.rb +0 -54
- data/lib/myco/parser/ast/declare_meme.rb +0 -86
- data/lib/myco/parser/ast/declare_object.rb +0 -77
- data/lib/myco/parser/ast/declare_string.rb +0 -37
- data/lib/myco/parser/ast/invoke.rb +0 -48
- data/lib/myco/parser/ast/invoke_method.rb +0 -28
- data/lib/myco/parser/ast/local_variable_access_ambiguous.rb +0 -34
- data/lib/myco/parser/ast/misc.rb +0 -156
- data/lib/myco/parser/ast/quest.rb +0 -82
- data/lib/myco/parser/ast.rb +0 -21
@@ -9,12 +9,23 @@
|
|
9
9
|
|
10
10
|
# Run the code in the given file, ignoring the return value but
|
11
11
|
# importing the constants defined therein into the current namespace.
|
12
|
-
import: Decorator {
|
13
|
-
apply: |meme
|
12
|
+
var import: Decorator {
|
13
|
+
apply: |meme| {
|
14
14
|
load_paths = [meme.target.instance.dirname]
|
15
15
|
scope = meme.target.constant_scope
|
16
16
|
component = Myco.eval_file(meme.name.to_s, load_paths, false, scope)
|
17
|
-
|
17
|
+
|
18
|
+
const_name = meme.metadata[:as]
|
19
|
+
const_name &? (
|
20
|
+
meme.target.const_set(const_name, component)
|
21
|
+
) ?? (
|
22
|
+
meme.target.include(component)
|
23
|
+
)
|
18
24
|
}
|
19
25
|
}
|
26
|
+
# Force an import to assign to a constant in the current namespace
|
27
|
+
# instead of being included into the current namespace.
|
28
|
+
var as: Decorator {
|
29
|
+
apply: |meme, given| meme.metadata[:as] = given
|
30
|
+
}
|
20
31
|
}
|
@@ -5,17 +5,32 @@
|
|
5
5
|
declare_meme(:dirname, [], nil, ::Myco.cscope.dup) { |*| (self.component.instance_variable_get("@dirname"))}
|
6
6
|
declare_meme(:basename, [], nil, ::Myco.cscope.dup) { |*| (self.component.instance_variable_get("@basename"))}
|
7
7
|
declare_meme(:filename, [], nil, ::Myco.cscope.dup) { |*| (self.component.instance_variable_get("@filename"))}
|
8
|
-
__category__(:decorators).component_eval {(
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
8
|
+
__category__(:decorators).component_eval {(
|
9
|
+
declare_meme(:import, [[:var, []]], nil, ::Myco.cscope.dup) { |*| (::Myco::Component.new([::Myco.find_constant(:Decorator)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
10
|
+
.tap { |__c__| __c__.__last__ = __c__.component_eval {(declare_meme(:apply, [], nil, ::Myco.cscope.dup) { |meme| (
|
11
|
+
load_paths = [meme.target.instance.dirname]
|
12
|
+
scope = meme.target.constant_scope
|
13
|
+
component = ::Myco.find_constant(:Myco).eval_file(
|
14
|
+
meme.name.to_s,
|
15
|
+
load_paths,
|
16
|
+
false,
|
17
|
+
scope
|
18
|
+
)
|
19
|
+
const_name = meme.metadata.__send__(
|
20
|
+
:[],
|
21
|
+
:as
|
22
|
+
)
|
23
|
+
::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", const_name) {meme.target.const_set(
|
24
|
+
const_name,
|
25
|
+
component
|
26
|
+
)}) {meme.target.include(component)}
|
27
|
+
)})}}.instance)}
|
28
|
+
declare_meme(:as, [[:var, []]], nil, ::Myco.cscope.dup) { |*| (::Myco::Component.new([::Myco.find_constant(:Decorator)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
29
|
+
.tap { |__c__| __c__.__last__ = __c__.component_eval {(declare_meme(:apply, [], nil, ::Myco.cscope.dup) { |meme, given| (meme.metadata.__send__(
|
30
|
+
:[]=,
|
31
|
+
:as,
|
32
|
+
given
|
33
|
+
))})}}.instance)}
|
34
|
+
)}
|
20
35
|
)}}
|
21
36
|
.tap { |__c__| __c__.__name__ = :FileToplevel })}}.instance
|
data/lib/myco/eval.rb
CHANGED
@@ -1,37 +1,12 @@
|
|
1
1
|
|
2
2
|
module Myco
|
3
3
|
|
4
|
-
#
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
lineno = 1 if filename && !lineno
|
11
|
-
|
12
|
-
binding = ::Binding.setup(Rubinius::VariableScope.of_sender,
|
13
|
-
Rubinius::CompiledCode.of_sender,
|
14
|
-
(scope||Rubinius::ConstantScope.of_sender),
|
15
|
-
self)
|
16
|
-
|
17
|
-
filename ||= "(eval)"
|
18
|
-
|
19
|
-
lineno ||= binding.line_number
|
20
|
-
|
21
|
-
existing_scope = binding.constant_scope
|
22
|
-
binding.constant_scope = existing_scope.dup
|
23
|
-
|
24
|
-
compiler_class = case type
|
25
|
-
when :myco; Myco::ToolSet::Compiler
|
26
|
-
when :ruby; Rubinius::ToolSets::Runtime::Compiler
|
27
|
-
else; raise NotImplementedError
|
28
|
-
end
|
29
|
-
|
30
|
-
be = compiler_class.construct_block string, binding, filename, lineno
|
31
|
-
|
32
|
-
result = be.call_on_instance(binding.self)
|
33
|
-
binding.constant_scope = existing_scope
|
34
|
-
result
|
4
|
+
# TODO: deprecate with proper import set of functions
|
5
|
+
def self.eval string, call_depth:1
|
6
|
+
loader = Myco::CodeLoader::MycoLoader.new("(eval)")
|
7
|
+
loader.bind_to(call_depth: call_depth + 1)
|
8
|
+
loader.string = string
|
9
|
+
loader.load
|
35
10
|
end
|
36
11
|
|
37
12
|
# TODO: deprecate with proper import set of functions
|
@@ -41,12 +16,7 @@ module Myco
|
|
41
16
|
get_last ? file_toplevel.component.__last__ : file_toplevel.component
|
42
17
|
end
|
43
18
|
|
44
|
-
|
45
|
-
parser = Myco::ToolSet::Parser.new(use_path, 1, [])
|
46
|
-
ast = parser.parse_string File.read(use_path)
|
47
|
-
ast.to_ruby_code
|
48
|
-
end
|
49
|
-
|
19
|
+
# TODO: replace backtrace in a different way, without this hack
|
50
20
|
def self.rescue
|
51
21
|
begin
|
52
22
|
yield
|
data/lib/myco/version.rb
CHANGED
@@ -1,13 +1,10 @@
|
|
1
1
|
|
2
2
|
module Myco
|
3
|
-
MYCO_VERSION = '0.1.
|
3
|
+
MYCO_VERSION = '0.1.4'
|
4
4
|
|
5
5
|
MYCO_REQUIRED_GEMS = [
|
6
6
|
['rubinius-toolset', '~> 2.3'],
|
7
|
-
['rubinius-melbourne', '~> 2.2'],
|
8
|
-
['rubinius-processor', '~> 2.2'],
|
9
7
|
['rubinius-compiler', '~> 2.2'],
|
10
|
-
['rubinius-ast', '~> 2.2'],
|
11
8
|
]
|
12
9
|
|
13
10
|
# TODO: move elsewhere?
|
data/lib/myco.rb
CHANGED
@@ -8,32 +8,30 @@ require_relative 'myco/misc'
|
|
8
8
|
require_relative 'myco/backtrace'
|
9
9
|
require_relative 'myco/bootstrap'
|
10
10
|
|
11
|
-
Myco.rescue do
|
12
|
-
# TODO: be more clever here communicating the load path for bootstrapping
|
13
|
-
Myco::CoreLoadPath = File.expand_path('myco', File.dirname(__FILE__))
|
14
|
-
Myco.eval_file 'myco/bootstrap.my'
|
15
|
-
end
|
16
11
|
|
17
|
-
#
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
require_relative 'myco/parser'
|
26
|
-
end
|
12
|
+
# Detect whether a second pass is necessary (when no bytecode is available)
|
13
|
+
# TODO: recursively check mtime for all rbc files as well,
|
14
|
+
# to be sure that core implementation files don't need to be recompiled.
|
15
|
+
if File.file?(File.expand_path('myco/bootstrap.my.rbc', File.dirname(__FILE__)))
|
16
|
+
stages = [:myco]
|
17
|
+
else
|
18
|
+
stages = [:myco_boot, :myco]
|
27
19
|
end
|
28
20
|
|
29
|
-
#
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
21
|
+
# Run the stages, ultimately creating the runtime toolset
|
22
|
+
# First pass: Load the boot toolset (when only ruby source code is available)
|
23
|
+
# Second pass: Load the runtime toolset using the boot toolset to parse it
|
24
|
+
stages.each do |toolset_name|
|
25
|
+
Myco::ToolSet = Rubinius::ToolSets.create toolset_name do
|
26
|
+
|
27
|
+
Myco.rescue do
|
28
|
+
# TODO: be more clever here communicating the load path for bootstrapping
|
29
|
+
Myco::CoreLoadPath = File.expand_path('myco', File.dirname(__FILE__))
|
30
|
+
Myco.eval_file 'myco/bootstrap.my'
|
31
|
+
end
|
32
|
+
|
34
33
|
require "rubinius/compiler"
|
35
|
-
require "rubinius/ast"
|
36
34
|
|
37
|
-
require_relative 'myco/
|
35
|
+
require_relative 'myco/code_tools'
|
38
36
|
end
|
39
37
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: myco
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe McIlvain
|
@@ -24,34 +24,6 @@ dependencies:
|
|
24
24
|
- !ruby/object:Gem::Version
|
25
25
|
version: '2.3'
|
26
26
|
type: :runtime
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
version_requirements: !ruby/object:Gem::Requirement
|
29
|
-
requirements:
|
30
|
-
- - "~>"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '2.2'
|
33
|
-
name: rubinius-melbourne
|
34
|
-
prerelease: false
|
35
|
-
requirement: !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - "~>"
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '2.2'
|
40
|
-
type: :runtime
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
version_requirements: !ruby/object:Gem::Requirement
|
43
|
-
requirements:
|
44
|
-
- - "~>"
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: '2.2'
|
47
|
-
name: rubinius-processor
|
48
|
-
prerelease: false
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - "~>"
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '2.2'
|
54
|
-
type: :runtime
|
55
27
|
- !ruby/object:Gem::Dependency
|
56
28
|
version_requirements: !ruby/object:Gem::Requirement
|
57
29
|
requirements:
|
@@ -66,20 +38,6 @@ dependencies:
|
|
66
38
|
- !ruby/object:Gem::Version
|
67
39
|
version: '2.2'
|
68
40
|
type: :runtime
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
version_requirements: !ruby/object:Gem::Requirement
|
71
|
-
requirements:
|
72
|
-
- - "~>"
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version: '2.2'
|
75
|
-
name: rubinius-ast
|
76
|
-
prerelease: false
|
77
|
-
requirement: !ruby/object:Gem::Requirement
|
78
|
-
requirements:
|
79
|
-
- - "~>"
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version: '2.2'
|
82
|
-
type: :runtime
|
83
41
|
- !ruby/object:Gem::Dependency
|
84
42
|
version_requirements: !ruby/object:Gem::Requirement
|
85
43
|
requirements:
|
@@ -201,6 +159,79 @@ files:
|
|
201
159
|
- lib/myco/bootstrap/meme.rb
|
202
160
|
- lib/myco/bootstrap/void.rb
|
203
161
|
- lib/myco/code_loader.rb
|
162
|
+
- lib/myco/code_tools.rb
|
163
|
+
- lib/myco/code_tools/AST.my
|
164
|
+
- lib/myco/code_tools/AST.my.rb
|
165
|
+
- lib/myco/code_tools/AST/ArgumentAssembly.my
|
166
|
+
- lib/myco/code_tools/AST/ArgumentAssembly.my.rb
|
167
|
+
- lib/myco/code_tools/AST/ArrayAssembly.my
|
168
|
+
- lib/myco/code_tools/AST/ArrayAssembly.my.rb
|
169
|
+
- lib/myco/code_tools/AST/BlockArgument.my
|
170
|
+
- lib/myco/code_tools/AST/BlockArgument.my.rb
|
171
|
+
- lib/myco/code_tools/AST/BlockLiteral.my
|
172
|
+
- lib/myco/code_tools/AST/BlockLiteral.my.rb
|
173
|
+
- lib/myco/code_tools/AST/BlockParameter.my
|
174
|
+
- lib/myco/code_tools/AST/BlockParameter.my.rb
|
175
|
+
- lib/myco/code_tools/AST/Body.my
|
176
|
+
- lib/myco/code_tools/AST/Body.my.rb
|
177
|
+
- lib/myco/code_tools/AST/BranchOperator.my
|
178
|
+
- lib/myco/code_tools/AST/BranchOperator.my.rb
|
179
|
+
- lib/myco/code_tools/AST/ConstantAccess.my
|
180
|
+
- lib/myco/code_tools/AST/ConstantAccess.my.rb
|
181
|
+
- lib/myco/code_tools/AST/ConstantAssignment.my
|
182
|
+
- lib/myco/code_tools/AST/ConstantAssignment.my.rb
|
183
|
+
- lib/myco/code_tools/AST/ConstantDefine.my
|
184
|
+
- lib/myco/code_tools/AST/ConstantDefine.my.rb
|
185
|
+
- lib/myco/code_tools/AST/ConstantReopen.my
|
186
|
+
- lib/myco/code_tools/AST/ConstantReopen.my.rb
|
187
|
+
- lib/myco/code_tools/AST/DeclareCategory.my
|
188
|
+
- lib/myco/code_tools/AST/DeclareCategory.my.rb
|
189
|
+
- lib/myco/code_tools/AST/DeclareDecorator.my
|
190
|
+
- lib/myco/code_tools/AST/DeclareDecorator.my.rb
|
191
|
+
- lib/myco/code_tools/AST/DeclareFile.my
|
192
|
+
- lib/myco/code_tools/AST/DeclareFile.my.rb
|
193
|
+
- lib/myco/code_tools/AST/DeclareMeme.my
|
194
|
+
- lib/myco/code_tools/AST/DeclareMeme.my.rb
|
195
|
+
- lib/myco/code_tools/AST/DeclareObject.my
|
196
|
+
- lib/myco/code_tools/AST/DeclareObject.my.rb
|
197
|
+
- lib/myco/code_tools/AST/DeclareString.my
|
198
|
+
- lib/myco/code_tools/AST/DeclareString.my.rb
|
199
|
+
- lib/myco/code_tools/AST/DynamicString.my
|
200
|
+
- lib/myco/code_tools/AST/DynamicString.my.rb
|
201
|
+
- lib/myco/code_tools/AST/DynamicSymbol.my
|
202
|
+
- lib/myco/code_tools/AST/DynamicSymbol.my.rb
|
203
|
+
- lib/myco/code_tools/AST/Invoke.my
|
204
|
+
- lib/myco/code_tools/AST/Invoke.my.rb
|
205
|
+
- lib/myco/code_tools/AST/InvokeMethod.my
|
206
|
+
- lib/myco/code_tools/AST/InvokeMethod.my.rb
|
207
|
+
- lib/myco/code_tools/AST/KeywordAssembly.my
|
208
|
+
- lib/myco/code_tools/AST/KeywordAssembly.my.rb
|
209
|
+
- lib/myco/code_tools/AST/LocalVariableAccessAmbiguous.my
|
210
|
+
- lib/myco/code_tools/AST/LocalVariableAccessAmbiguous.my.rb
|
211
|
+
- lib/myco/code_tools/AST/LocalVariableAssignment.my
|
212
|
+
- lib/myco/code_tools/AST/LocalVariableAssignment.my.rb
|
213
|
+
- lib/myco/code_tools/AST/MycoModuleScope.my
|
214
|
+
- lib/myco/code_tools/AST/MycoModuleScope.my.rb
|
215
|
+
- lib/myco/code_tools/AST/Node.my
|
216
|
+
- lib/myco/code_tools/AST/Node.my.rb
|
217
|
+
- lib/myco/code_tools/AST/ParameterAssembly.my
|
218
|
+
- lib/myco/code_tools/AST/ParameterAssembly.my.rb
|
219
|
+
- lib/myco/code_tools/AST/Quest.my
|
220
|
+
- lib/myco/code_tools/AST/Quest.my.rb
|
221
|
+
- lib/myco/code_tools/AST/Script.my
|
222
|
+
- lib/myco/code_tools/AST/Script.my.rb
|
223
|
+
- lib/myco/code_tools/AST/SplatValue.my
|
224
|
+
- lib/myco/code_tools/AST/SplatValue.my.rb
|
225
|
+
- lib/myco/code_tools/AST/StringLiteral.my
|
226
|
+
- lib/myco/code_tools/AST/StringLiteral.my.rb
|
227
|
+
- lib/myco/code_tools/AST/SymbolLiteral.my
|
228
|
+
- lib/myco/code_tools/AST/SymbolLiteral.my.rb
|
229
|
+
- lib/myco/code_tools/AST/ToRuby.my
|
230
|
+
- lib/myco/code_tools/AST/ToRuby.my.rb
|
231
|
+
- lib/myco/code_tools/AST/misc.my
|
232
|
+
- lib/myco/code_tools/AST/misc.my.rb
|
233
|
+
- lib/myco/code_tools/parser.rb
|
234
|
+
- lib/myco/code_tools/parser/peg_parser.rb
|
204
235
|
- lib/myco/command.my
|
205
236
|
- lib/myco/command.my.rb
|
206
237
|
- lib/myco/command/inoculate.my
|
@@ -221,29 +252,6 @@ files:
|
|
221
252
|
- lib/myco/core/Switch.my.rb
|
222
253
|
- lib/myco/eval.rb
|
223
254
|
- lib/myco/misc.rb
|
224
|
-
- lib/myco/parser.rb
|
225
|
-
- lib/myco/parser/ast.rb
|
226
|
-
- lib/myco/parser/ast/ToRuby.my
|
227
|
-
- lib/myco/parser/ast/ToRuby.my.rb
|
228
|
-
- lib/myco/parser/ast/argument_assembly.rb
|
229
|
-
- lib/myco/parser/ast/array_assembly.rb
|
230
|
-
- lib/myco/parser/ast/branch_operator.rb
|
231
|
-
- lib/myco/parser/ast/constant_access.rb
|
232
|
-
- lib/myco/parser/ast/constant_define.rb
|
233
|
-
- lib/myco/parser/ast/constant_reopen.rb
|
234
|
-
- lib/myco/parser/ast/declare_category.rb
|
235
|
-
- lib/myco/parser/ast/declare_decorator.rb
|
236
|
-
- lib/myco/parser/ast/declare_file.rb
|
237
|
-
- lib/myco/parser/ast/declare_meme.rb
|
238
|
-
- lib/myco/parser/ast/declare_object.rb
|
239
|
-
- lib/myco/parser/ast/declare_string.rb
|
240
|
-
- lib/myco/parser/ast/invoke.rb
|
241
|
-
- lib/myco/parser/ast/invoke_method.rb
|
242
|
-
- lib/myco/parser/ast/local_variable_access_ambiguous.rb
|
243
|
-
- lib/myco/parser/ast/misc.rb
|
244
|
-
- lib/myco/parser/ast/myco_module_scope.rb
|
245
|
-
- lib/myco/parser/ast/quest.rb
|
246
|
-
- lib/myco/parser/peg_parser.rb
|
247
255
|
- lib/myco/tools/BasicCommand.my
|
248
256
|
- lib/myco/tools/BasicCommand.my.rb
|
249
257
|
- lib/myco/tools/mycompile.my
|
@@ -1,76 +0,0 @@
|
|
1
|
-
|
2
|
-
module CodeTools::AST
|
3
|
-
|
4
|
-
module BuilderMethods
|
5
|
-
def argass loc, body
|
6
|
-
ArgumentAssembly.new loc.line, body
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
class ArgumentAssembly < Node
|
11
|
-
attr_accessor :body, :block
|
12
|
-
|
13
|
-
def initialize(line, body, block=nil)
|
14
|
-
@line = line
|
15
|
-
@body = body
|
16
|
-
|
17
|
-
# TODO: error for multiple block arguments
|
18
|
-
@block = body.pop if body.last.is_a?(BlockPass)
|
19
|
-
end
|
20
|
-
|
21
|
-
# All items before the first SplatValue
|
22
|
-
def pre_group
|
23
|
-
@body.take_while { |item| !item.is_a?(SplatValue) }
|
24
|
-
end
|
25
|
-
|
26
|
-
# All items after and including the first SplatValue
|
27
|
-
def post_group
|
28
|
-
@body.drop_while { |item| !item.is_a?(SplatValue) }
|
29
|
-
end
|
30
|
-
|
31
|
-
# Symbol of bytecode operation to use for send
|
32
|
-
def send_op
|
33
|
-
if @body.detect { |item| item.is_a?(SplatValue) }
|
34
|
-
:send_with_splat
|
35
|
-
elsif @block
|
36
|
-
:send_with_block
|
37
|
-
else
|
38
|
-
:send
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
# Number of arguments to use for send operation
|
43
|
-
def send_count
|
44
|
-
pre_group.size
|
45
|
-
end
|
46
|
-
|
47
|
-
def splat_bytecode(g)
|
48
|
-
ArrayAssembly.new(@line, post_group).bytecode(g)
|
49
|
-
end
|
50
|
-
|
51
|
-
def block_bytecode(g)
|
52
|
-
@block ? @block.bytecode(g) : g.push_nil
|
53
|
-
end
|
54
|
-
|
55
|
-
def bytecode(g)
|
56
|
-
pos(g)
|
57
|
-
|
58
|
-
pre_group.each { |item| item.bytecode(g) }
|
59
|
-
|
60
|
-
case send_op
|
61
|
-
when :send_with_splat
|
62
|
-
splat_bytecode(g)
|
63
|
-
block_bytecode(g)
|
64
|
-
when :send_with_block
|
65
|
-
block_bytecode(g)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def to_sexp
|
70
|
-
sexp = [:arglist] + @body.map(&:to_sexp)
|
71
|
-
sexp.push(@block.to_sexp) if @block
|
72
|
-
sexp
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
|
2
|
-
module CodeTools::AST
|
3
|
-
|
4
|
-
module BuilderMethods
|
5
|
-
def arrass loc, body
|
6
|
-
ArrayAssembly.new loc.line, body
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
class ArrayAssembly < Node
|
11
|
-
attr_accessor :body
|
12
|
-
|
13
|
-
def initialize(line, body)
|
14
|
-
@line = line
|
15
|
-
@body = body
|
16
|
-
end
|
17
|
-
|
18
|
-
def bytecode(g)
|
19
|
-
pos(g)
|
20
|
-
|
21
|
-
if @body.empty?
|
22
|
-
g.make_array(0)
|
23
|
-
return
|
24
|
-
end
|
25
|
-
|
26
|
-
# Group the @body into chunks of splats and non-splats
|
27
|
-
chunked = @body.chunk { |item| item.is_a?(SplatValue) }
|
28
|
-
|
29
|
-
# Each SplatValue outputs the bytecode of a single array
|
30
|
-
# Non-SplatValues are grouped to output the bytecode of
|
31
|
-
# a single array for each contiguous group. Along the way, the
|
32
|
-
# arrays are concatenated to form one final array on the stack.
|
33
|
-
first_bytecode = true
|
34
|
-
chunked.each do |is_splat_group, group|
|
35
|
-
if is_splat_group
|
36
|
-
group.each { |item|
|
37
|
-
item.bytecode(g)
|
38
|
-
g.send(:concat, 1) unless first_bytecode
|
39
|
-
first_bytecode = false
|
40
|
-
}
|
41
|
-
else
|
42
|
-
group.each { |item|
|
43
|
-
item.bytecode(g)
|
44
|
-
}
|
45
|
-
g.make_array(group.size)
|
46
|
-
g.send(:concat, 1) unless first_bytecode
|
47
|
-
first_bytecode = false
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def to_sexp
|
53
|
-
[:array] + @body.map(&:to_sexp)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
@@ -1,73 +0,0 @@
|
|
1
|
-
|
2
|
-
module CodeTools::AST
|
3
|
-
|
4
|
-
module BuilderMethods
|
5
|
-
def branch_op loc, type, left, right
|
6
|
-
BranchOperator.new loc.line, type, left, right
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
class BranchOperator < Node
|
11
|
-
attr_accessor :type
|
12
|
-
attr_accessor :left
|
13
|
-
attr_accessor :right
|
14
|
-
|
15
|
-
def initialize line, type, left, right
|
16
|
-
@line = line
|
17
|
-
@type = type
|
18
|
-
@left = left
|
19
|
-
@right = right
|
20
|
-
end
|
21
|
-
|
22
|
-
def bytecode g
|
23
|
-
pos(g)
|
24
|
-
|
25
|
-
done_label = g.new_label
|
26
|
-
right_label = g.new_label
|
27
|
-
can_push_void = false
|
28
|
-
|
29
|
-
@left.bytecode(g)
|
30
|
-
|
31
|
-
case type
|
32
|
-
when :"&&"
|
33
|
-
g.dup_top
|
34
|
-
g.send :false?, 0
|
35
|
-
g.goto_if_true done_label
|
36
|
-
g.pop
|
37
|
-
when :"||"
|
38
|
-
g.dup_top
|
39
|
-
g.send :false?, 0
|
40
|
-
g.goto_if_false done_label
|
41
|
-
g.pop
|
42
|
-
when :"??"
|
43
|
-
g.dup_top
|
44
|
-
g.send :void?, 0
|
45
|
-
g.goto_if_false done_label
|
46
|
-
g.pop
|
47
|
-
when :"&?"
|
48
|
-
g.send :false?, 0
|
49
|
-
g.goto_if_false right_label
|
50
|
-
otherwise_push_void = true
|
51
|
-
when :"|?"
|
52
|
-
g.send :false?, 0
|
53
|
-
g.goto_if_true right_label
|
54
|
-
otherwise_push_void = true
|
55
|
-
end
|
56
|
-
|
57
|
-
if otherwise_push_void
|
58
|
-
g.push_void
|
59
|
-
g.goto done_label
|
60
|
-
|
61
|
-
right_label.set!
|
62
|
-
end
|
63
|
-
|
64
|
-
@right.bytecode(g)
|
65
|
-
done_label.set!
|
66
|
-
end
|
67
|
-
|
68
|
-
def to_sexp
|
69
|
-
[:branch_op, @type, @left.to_sexp, @right.to_sexp]
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
|
2
|
-
module CodeTools::AST
|
3
|
-
# Monkey patch original to use ::Myco to look up constants
|
4
|
-
class ConstantAccess
|
5
|
-
def bytecode(g)
|
6
|
-
pos(g)
|
7
|
-
|
8
|
-
g.push_cpath_top
|
9
|
-
g.find_const :Myco
|
10
|
-
g.push_literal @name
|
11
|
-
g.push_scope
|
12
|
-
g.send :find_constant, 2
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
|
2
|
-
module CodeTools::AST
|
3
|
-
|
4
|
-
module BuilderMethods
|
5
|
-
def cdefn loc, name, object
|
6
|
-
ConstantDefine.new loc.line, name, object
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
class ConstantDefine < Node
|
11
|
-
attr_accessor :name, :object
|
12
|
-
|
13
|
-
def initialize line, name, object
|
14
|
-
@line = line
|
15
|
-
@name = name
|
16
|
-
@object = object
|
17
|
-
@object.create = false
|
18
|
-
end
|
19
|
-
|
20
|
-
def to_sexp
|
21
|
-
[:cdefn, @name.name, @object.to_sexp]
|
22
|
-
end
|
23
|
-
|
24
|
-
def implementation
|
25
|
-
ConstantAssignment.new @line, @name, @object
|
26
|
-
end
|
27
|
-
|
28
|
-
def bytecode g
|
29
|
-
pos(g)
|
30
|
-
|
31
|
-
implementation.bytecode g
|
32
|
-
|
33
|
-
g.dup_top
|
34
|
-
g.push_literal @name.name
|
35
|
-
g.send :__name__=, 1
|
36
|
-
g.pop
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
|
2
|
-
require_relative 'myco_module_scope'
|
3
|
-
|
4
|
-
|
5
|
-
module CodeTools::AST
|
6
|
-
|
7
|
-
module BuilderMethods
|
8
|
-
def copen loc, name, body
|
9
|
-
ConstantReopen.new loc.line, name, body
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
class ConstantReopenScope < MycoModuleScope
|
14
|
-
def body_bytecode g
|
15
|
-
g.push_scope
|
16
|
-
g.send :set_myco_component, 0
|
17
|
-
g.pop
|
18
|
-
|
19
|
-
@body.bytecode g
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
class ConstantReopen < Node
|
24
|
-
attr_accessor :name, :body
|
25
|
-
|
26
|
-
def initialize line, name, body
|
27
|
-
@line = line
|
28
|
-
@name = name
|
29
|
-
@body = body
|
30
|
-
end
|
31
|
-
|
32
|
-
def to_sexp
|
33
|
-
[:copen, @name.name, @body.to_sexp]
|
34
|
-
end
|
35
|
-
|
36
|
-
def bytecode g
|
37
|
-
pos(g)
|
38
|
-
|
39
|
-
scope = ConstantReopenScope.new @line, @body
|
40
|
-
|
41
|
-
@name.bytecode g
|
42
|
-
scope.bytecode g
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|