myco 0.1.7 → 0.1.8
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/add_method.rb +38 -0
- data/lib/myco/bootstrap/component.rb +43 -21
- data/lib/myco/bootstrap/find_constant.rb +73 -25
- data/lib/myco/bootstrap/instance.rb +96 -25
- data/lib/myco/bootstrap/meme.rb +18 -12
- data/lib/myco/bootstrap/tuple.rb +13 -0
- data/lib/myco/bootstrap/undefined.rb +9 -0
- data/lib/myco/bootstrap/void.rb +5 -4
- data/lib/myco/bootstrap.my +24 -13
- data/lib/myco/bootstrap.my.rb +41 -4
- data/lib/myco/bootstrap.rb +4 -0
- data/lib/myco/code_loader.rb +11 -9
- data/lib/myco/code_tools/AST/Block.my.rb +2 -2
- data/lib/myco/code_tools/AST/ConstantAccess.my.rb +4 -4
- data/lib/myco/code_tools/AST/ConstantAssignment.my.rb +4 -4
- data/lib/myco/code_tools/AST/Invoke.my +1 -1
- data/lib/myco/code_tools/AST/Invoke.my.rb +1 -1
- data/lib/myco/code_tools/AST/Node.my +2 -4
- data/lib/myco/code_tools/AST/Node.my.rb +3 -3
- data/lib/myco/code_tools/AST/PipeOperator.my.rb +1 -1
- data/lib/myco/code_tools/AST/ToRuby.my.rb +8 -8
- data/lib/myco/code_tools/AST/misc.my.rb +1 -1
- data/lib/myco/code_tools/Parser.my +8 -15
- data/lib/myco/code_tools/Parser.my.rb +8 -14
- data/lib/myco/code_tools/parser/MycoBuilder.my +3 -4
- data/lib/myco/code_tools/parser/MycoBuilder.my.rb +5 -6
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeHelpers.my +8 -4
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeHelpers.my.rb +5 -5
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeInstructions.my +2 -2
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeInstructions.my.rb +12 -12
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeParser.my +54 -44
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/BytecodeParser.my.rb +69 -83
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Grammar.my +18 -8
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Grammar.my.rb +24 -10
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Machine.my.rb +1 -1
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Parser.my +1 -1
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Parser.my.rb +1 -2
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Patterns.my +1 -1
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Patterns.my.rb +1 -1
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Processor.my +3 -3
- data/lib/myco/code_tools/parser/pegleromyces/lib/pegleromyces/Processor.my.rb +5 -6
- data/lib/myco/code_tools/parser/pegleromyces/spec/BasicSpec.my +35 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/BasicSpec.my.rb +35 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Builder.test.my +10 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Builder.test.my.rb +9 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/BytecodeInstructions.test.my +10 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/BytecodeInstructions.test.my.rb +9 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/BytecodeParser.test.my +81 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/BytecodeParser.test.my.rb +209 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Constructions.test.my +229 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Constructions.test.my.rb +663 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Grammar.test.my +10 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Grammar.test.my.rb +9 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Instructions.test.my +10 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Instructions.test.my.rb +9 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Machine.test.my +13 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Machine.test.my.rb +20 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Parser.test.my +54 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Parser.test.my.rb +215 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Patterns.test.my +156 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Patterns.test.my.rb +334 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Processor.test.my +10 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/Processor.test.my.rb +9 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/run.my +20 -0
- data/lib/myco/code_tools/parser/pegleromyces/spec/run.my.rb +16 -0
- data/lib/myco/core/BasicDecorators.my +19 -11
- data/lib/myco/core/BasicDecorators.my.rb +24 -20
- data/lib/myco/core/BasicObject.my +12 -7
- data/lib/myco/core/BasicObject.my.rb +50 -44
- data/lib/myco/core/Category.my +12 -2
- data/lib/myco/core/Category.my.rb +15 -7
- data/lib/myco/core/Decorator.my +1 -1
- data/lib/myco/core/Decorator.my.rb +8 -10
- data/lib/myco/core/FileToplevel.my +3 -3
- data/lib/myco/core/FileToplevel.my.rb +4 -6
- data/lib/myco/core/Object.my +7 -10
- data/lib/myco/core/Object.my.rb +11 -17
- data/lib/myco/core/Ruby.my +6 -0
- data/lib/myco/core/Ruby.my.rb +16 -0
- data/lib/myco/core/Switch.my +1 -1
- data/lib/myco/core/Switch.my.rb +1 -1
- data/lib/myco/core.my +4 -0
- data/lib/myco/core.my.rb +7 -0
- data/lib/myco/dev/call_sites.rb +39 -0
- data/lib/myco/dev/counter.rb +26 -0
- data/lib/myco/dev.rb +3 -0
- data/lib/myco/eval.rb +1 -1
- data/lib/myco/tools/BasicCommand.my.rb +1 -1
- data/lib/myco/version.rb +1 -1
- data/lib/myco.rb +2 -3
- metadata +53 -20
- data/lib/myco/bootstrap/evaluator.rb +0 -58
@@ -1,46 +1,52 @@
|
|
1
1
|
|
2
2
|
::Myco::Component.new([::Myco::FileToplevel], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
3
|
-
.tap { |__c__| __c__.__last__ = __c__.component_eval {(
|
4
|
-
::Myco
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
use_strategy =
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
)}
|
44
|
-
|
45
|
-
::Myco
|
46
|
-
)}
|
3
|
+
.tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco::BasicObject.component_eval {(
|
4
|
+
declare_meme(:if, [], nil, ::Myco.cscope.dup) { |cond, &blk| (::Myco.branch_op(:"&&", cond) {blk.call})}
|
5
|
+
declare_meme(:unless, [], nil, ::Myco.cscope.dup) { |cond, &blk| (::Myco.branch_op(:"||", cond) {blk.call})}
|
6
|
+
declare_meme(:case, [], nil, ::Myco.cscope.dup) { |input, *rest| (
|
7
|
+
use_strategy = ::Myco.branch_op(:"&&", rest.size.__send__(:odd?)) {rest.pop}
|
8
|
+
rest.each_slice(2).detect { |test_value, strategy| (::Myco.branch_op(:"&&", test_value.__send__(
|
9
|
+
:==,
|
10
|
+
input
|
11
|
+
)) {(
|
12
|
+
use_strategy = strategy
|
13
|
+
true
|
14
|
+
)})}
|
15
|
+
::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", use_strategy) {::Myco.branch_op(:"??", (Rubinius::Type.object_respond_to?(use_strategy, :call).false? ? ::Myco::Void : use_strategy.call(input))) {use_strategy}}) {self.raise("No match for case(#{input})")}
|
16
|
+
)}
|
17
|
+
declare_meme(:cond, [], nil, ::Myco.cscope.dup) { |*rest| (
|
18
|
+
use_strategy = ::Myco.branch_op(:"&&", rest.size.__send__(:odd?)) {rest.pop}
|
19
|
+
rest.each_slice(2).detect { |test_value, strategy| (::Myco.branch_op(:"&&", ::Myco.branch_op(:"??", (Rubinius::Type.object_respond_to?(test_value, :call).false? ? ::Myco::Void : test_value.call)) {test_value}) {(
|
20
|
+
use_strategy = strategy
|
21
|
+
true
|
22
|
+
)})}
|
23
|
+
::Myco.branch_op(:"??", ::Myco.branch_op(:"&?", use_strategy) {::Myco.branch_op(:"??", (Rubinius::Type.object_respond_to?(use_strategy, :call).false? ? ::Myco::Void : use_strategy.call)) {use_strategy}}) {self.raise("No match for cond")}
|
24
|
+
)}
|
25
|
+
declare_meme(:switch, [], nil, ::Myco.cscope.dup) { |input, comparator=:==| (::Myco.find_constant(:Switch).new({
|
26
|
+
:input => input,
|
27
|
+
:comparator => comparator
|
28
|
+
}))}
|
29
|
+
declare_meme(:raise, [], nil, ::Myco.cscope.dup) { |*args| (::Object.__send__(
|
30
|
+
:raise,
|
31
|
+
*args
|
32
|
+
))}
|
33
|
+
declare_meme(:loop, [], nil, ::Myco.cscope.dup) { |&block| (::Object.__send__(
|
34
|
+
:loop,
|
35
|
+
&block
|
36
|
+
))}
|
37
|
+
declare_meme(:break, [], nil, ::Myco.cscope.dup) { |*| (self.raise(::Object::StopIteration))}
|
38
|
+
declare_meme(:send, [], nil, ::Myco.cscope.dup) { |*args, &block| (self.__send__(
|
39
|
+
*args,
|
40
|
+
&block
|
41
|
+
))}
|
42
|
+
declare_meme(:kind_of?, [], nil, ::Myco.cscope.dup) { |mod| (self.__kind_of__(mod))}
|
43
|
+
declare_meme(:is_a?, [], nil, ::Myco.cscope.dup) { |mod| (self.__kind_of__(mod))}
|
44
|
+
declare_meme(:class, [], nil, ::Myco.cscope.dup) { |*| (self.__class__)}
|
45
|
+
declare_meme(:dup, [], nil, ::Myco.cscope.dup) { |*| (self.__dup__)}
|
46
|
+
declare_meme(:puts, [], nil, ::Myco.cscope.dup) { |*args| (::Myco.find_constant(:STDOUT).puts(*args))}
|
47
|
+
declare_meme(:p, [], nil, ::Myco.cscope.dup) { |*args| (::Myco.find_constant(:STDOUT).puts(args.map { |a| (a.inspect)}.join(", ")))}
|
48
|
+
declare_meme(:ruby_require, [], nil, ::Myco.cscope.dup) { |arg| (::Object.send(
|
49
|
+
:require,
|
50
|
+
arg
|
51
|
+
))}
|
52
|
+
)})}}.instance
|
data/lib/myco/core/Category.my
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
|
2
|
-
::Myco::Category
|
2
|
+
::Myco::Category << {
|
3
3
|
# Forward unknown methods to parent
|
4
|
-
method_missing: |sym, *a, &b| parent.
|
4
|
+
method_missing: |sym, *a, &b| parent.__send__(sym, *a, &b)
|
5
|
+
|
6
|
+
# TODO: make DRY with respect to BasicObject.my (or remove these methods entirely...)
|
7
|
+
send: |*args, &block| __send__(*args, &block)
|
8
|
+
|
9
|
+
kind_of?: |mod| __kind_of__(mod)
|
10
|
+
is_a?: |mod| __kind_of__(mod)
|
11
|
+
|
12
|
+
class: __class__ # TODO: consider removing
|
13
|
+
|
14
|
+
dup: __dup__ # TODO: remove
|
5
15
|
}
|
@@ -1,9 +1,17 @@
|
|
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::Category
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
))}
|
9
|
-
|
3
|
+
.tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco::Category.component_eval {(
|
4
|
+
declare_meme(:method_missing, [], nil, ::Myco.cscope.dup) { |sym, *a, &b| (self.parent.__send__(
|
5
|
+
sym,
|
6
|
+
*a,
|
7
|
+
&b
|
8
|
+
))}
|
9
|
+
declare_meme(:send, [], nil, ::Myco.cscope.dup) { |*args, &block| (self.__send__(
|
10
|
+
*args,
|
11
|
+
&block
|
12
|
+
))}
|
13
|
+
declare_meme(:kind_of?, [], nil, ::Myco.cscope.dup) { |mod| (self.__kind_of__(mod))}
|
14
|
+
declare_meme(:is_a?, [], nil, ::Myco.cscope.dup) { |mod| (self.__kind_of__(mod))}
|
15
|
+
declare_meme(:class, [], nil, ::Myco.cscope.dup) { |*| (self.__class__)}
|
16
|
+
declare_meme(:dup, [], nil, ::Myco.cscope.dup) { |*| (self.__dup__)}
|
17
|
+
)})}}.instance
|
data/lib/myco/core/Decorator.my
CHANGED
@@ -1,33 +1,31 @@
|
|
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::Decorator
|
4
|
-
.tap { |__c__| __c__.__last__ = __c__.component_eval {(
|
3
|
+
.tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco::Decorator.component_eval {(
|
5
4
|
declare_meme(:apply, [], nil, ::Myco.cscope.dup) { |meme, *args| nil}
|
6
5
|
__category__(:transforms).component_eval {(declare_meme(:apply, [], nil, ::Myco.cscope.dup) { |meme, *args| (
|
7
|
-
(
|
6
|
+
(Rubinius::Type.object_respond_to?(self, :target).false? ? ::Myco::Void : self.target(meme)).tap { |x| (meme.__send__(
|
8
7
|
:target=,
|
9
8
|
x
|
10
9
|
))}
|
11
|
-
(
|
10
|
+
(Rubinius::Type.object_respond_to?(self, :name).false? ? ::Myco::Void : self.name(meme)).tap { |x| (meme.__send__(
|
12
11
|
:name=,
|
13
12
|
x
|
14
13
|
))}
|
15
|
-
(
|
14
|
+
(Rubinius::Type.object_respond_to?(self, :body).false? ? ::Myco::Void : self.body(meme)).tap { |x| (meme.__send__(
|
16
15
|
:body=,
|
17
16
|
x
|
18
17
|
))}
|
19
|
-
(
|
18
|
+
(Rubinius::Type.object_respond_to?(self, :cache).false? ? ::Myco::Void : self.cache(meme)).tap { |x| (meme.__send__(
|
20
19
|
:cache=,
|
21
20
|
x
|
22
21
|
))}
|
23
|
-
(
|
22
|
+
(Rubinius::Type.object_respond_to?(self, :var).false? ? ::Myco::Void : self.var(meme)).tap { |x| (meme.__send__(
|
24
23
|
:var=,
|
25
24
|
x
|
26
25
|
))}
|
27
|
-
(
|
26
|
+
(Rubinius::Type.object_respond_to?(self, :expose).false? ? ::Myco::Void : self.expose(meme)).tap { |x| (meme.__send__(
|
28
27
|
:expose=,
|
29
28
|
x
|
30
29
|
))}
|
31
30
|
)})}
|
32
|
-
)}}
|
33
|
-
.tap { |__c__| __c__.__name__ = :Decorator })}}.instance
|
31
|
+
)})}}.instance
|
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
::Myco::FileToplevel
|
2
|
+
::Myco::FileToplevel << {
|
3
3
|
# TODO: don't use instance_variable_get
|
4
4
|
dirname: component.instance_variable_get("@dirname")
|
5
5
|
basename: component.instance_variable_get("@basename")
|
@@ -9,7 +9,7 @@
|
|
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
|
-
|
12
|
+
const import: Decorator {
|
13
13
|
apply: |meme| {
|
14
14
|
load_paths = [meme.target.instance.dirname]
|
15
15
|
scope = meme.target.constant_scope
|
@@ -25,7 +25,7 @@
|
|
25
25
|
}
|
26
26
|
# Force an import to assign to a constant in the current namespace
|
27
27
|
# instead of being included into the current namespace.
|
28
|
-
|
28
|
+
const as: Decorator {
|
29
29
|
apply: |meme, given| meme.metadata[:as] = given
|
30
30
|
}
|
31
31
|
}
|
@@ -1,12 +1,11 @@
|
|
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::FileToplevel
|
4
|
-
.tap { |__c__| __c__.__last__ = __c__.component_eval {(
|
3
|
+
.tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco::FileToplevel.component_eval {(
|
5
4
|
declare_meme(:dirname, [], nil, ::Myco.cscope.dup) { |*| (self.component.instance_variable_get("@dirname"))}
|
6
5
|
declare_meme(:basename, [], nil, ::Myco.cscope.dup) { |*| (self.component.instance_variable_get("@basename"))}
|
7
6
|
declare_meme(:filename, [], nil, ::Myco.cscope.dup) { |*| (self.component.instance_variable_get("@filename"))}
|
8
7
|
__category__(:decorators).component_eval {(
|
9
|
-
declare_meme(:import, [[:
|
8
|
+
declare_meme(:import, [[:const, []]], nil, ::Myco.cscope.dup) { |*| (::Myco::Component.new([::Myco.find_constant(:Decorator)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
10
9
|
.tap { |__c__| __c__.__last__ = __c__.component_eval {(declare_meme(:apply, [], nil, ::Myco.cscope.dup) { |meme| (
|
11
10
|
load_paths = [meme.target.instance.dirname]
|
12
11
|
scope = meme.target.constant_scope
|
@@ -25,12 +24,11 @@
|
|
25
24
|
component
|
26
25
|
)}) {meme.target.include(component)}
|
27
26
|
)})}}.instance)}
|
28
|
-
declare_meme(:as, [[:
|
27
|
+
declare_meme(:as, [[:const, []]], nil, ::Myco.cscope.dup) { |*| (::Myco::Component.new([::Myco.find_constant(:Decorator)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
29
28
|
.tap { |__c__| __c__.__last__ = __c__.component_eval {(declare_meme(:apply, [], nil, ::Myco.cscope.dup) { |meme, given| (meme.metadata.__send__(
|
30
29
|
:[]=,
|
31
30
|
:as,
|
32
31
|
given
|
33
32
|
))})}}.instance)}
|
34
33
|
)}
|
35
|
-
)}}
|
36
|
-
.tap { |__c__| __c__.__name__ = :FileToplevel })}}.instance
|
34
|
+
)})}}.instance
|
data/lib/myco/core/Object.my
CHANGED
@@ -3,22 +3,19 @@
|
|
3
3
|
# Send the named signal to all handlers for this object
|
4
4
|
__signal__: |name, *args, &block| {
|
5
5
|
component.ancestors.reverse.each |other| {
|
6
|
-
other
|
7
|
-
|
8
|
-
|
9
|
-
meme.result_for(self, *args, &block)
|
10
|
-
}
|
11
|
-
)
|
6
|
+
other.?__signal_handlers__(name).each |meme| {
|
7
|
+
meme.result_for(self, *args, &block)
|
8
|
+
}
|
12
9
|
}
|
13
10
|
}
|
14
11
|
|
12
|
+
static storage __signal_handlers__: []
|
13
|
+
|
15
14
|
[decorators]
|
16
15
|
|
17
16
|
# Register a named signal handler
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
apply: |meme| signal_handlers(meme.name).push(meme)
|
17
|
+
const on: Decorator {
|
18
|
+
apply: |meme| meme.target.__signal_handlers__(meme.name).push(meme)
|
22
19
|
|
23
20
|
[transforms]
|
24
21
|
expose: false
|
data/lib/myco/core/Object.my.rb
CHANGED
@@ -2,24 +2,18 @@
|
|
2
2
|
::Myco::Component.new([::Myco::FileToplevel], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
3
3
|
.tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco::Object = ::Myco::Component.new([::Myco::BasicObject], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
4
4
|
.tap { |__c__| __c__.__last__ = __c__.component_eval {(
|
5
|
-
declare_meme(:__signal__, [], nil, ::Myco.cscope.dup) { |name, *args, &block| (self.component.ancestors.reverse.each { |other| (::
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
*args,
|
16
|
-
&block
|
17
|
-
))}
|
18
|
-
)})})}
|
19
|
-
__category__(:decorators).component_eval {(declare_meme(:on, [[:var, []]], nil, ::Myco.cscope.dup) { |*| (::Myco::Component.new([::Myco.find_constant(:Decorator)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
5
|
+
declare_meme(:__signal__, [], nil, ::Myco.cscope.dup) { |name, *args, &block| (self.component.ancestors.reverse.each { |other| ((Rubinius::Type.object_respond_to?(other, :__signal_handlers__).false? ? ::Myco::Void : other.__signal_handlers__(name)).each { |meme| (meme.result_for(
|
6
|
+
self,
|
7
|
+
*args,
|
8
|
+
&block
|
9
|
+
))})})}
|
10
|
+
declare_meme(:__signal_handlers__, [
|
11
|
+
[:storage, []],
|
12
|
+
[:static, []]
|
13
|
+
], nil, ::Myco.cscope.dup) { |*| ([])}
|
14
|
+
__category__(:decorators).component_eval {(declare_meme(:on, [[:const, []]], nil, ::Myco.cscope.dup) { |*| (::Myco::Component.new([::Myco.find_constant(:Decorator)], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
20
15
|
.tap { |__c__| __c__.__last__ = __c__.component_eval {(
|
21
|
-
declare_meme(:
|
22
|
-
declare_meme(:apply, [], nil, ::Myco.cscope.dup) { |meme| (self.signal_handlers(meme.name).push(meme))}
|
16
|
+
declare_meme(:apply, [], nil, ::Myco.cscope.dup) { |meme| (meme.target.__signal_handlers__(meme.name).push(meme))}
|
23
17
|
__category__(:transforms).component_eval {(declare_meme(:expose, [], nil, ::Myco.cscope.dup) { |*| (false)})}
|
24
18
|
)}}.instance)})}
|
25
19
|
)}}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
|
2
|
+
::Myco::Component.new([::Myco::FileToplevel], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
3
|
+
.tap { |__c__| __c__.__last__ = __c__.component_eval {(::Myco::Ruby = ::Myco::Component.new([
|
4
|
+
::Object::Object,
|
5
|
+
::Myco::BasicObject
|
6
|
+
], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
7
|
+
.tap { |__c__| __c__.__last__ = __c__.component_eval {(
|
8
|
+
declare_meme(:eval, [[:static, []]], nil, ::Myco.cscope.dup) { |*a, &b| (::Myco.find_constant(:Kernel).eval(
|
9
|
+
*a,
|
10
|
+
&b
|
11
|
+
))}
|
12
|
+
::Myco.cscope.for_method_definition::Eval = ::Myco::Component.new([::Myco::EmptyObject], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
13
|
+
.tap { |__c__| __c__.__last__ = __c__.component_eval {(declare_meme(:from_string, [], nil, ::Myco.cscope.dup) { |string| (::Myco.find_constant(:Ruby).eval(string))})}}
|
14
|
+
.tap { |__c__| __c__.__name__ = :Eval }
|
15
|
+
)}}
|
16
|
+
.tap { |__c__| __c__.__name__ = :Ruby })}}.instance
|
data/lib/myco/core/Switch.my
CHANGED
data/lib/myco/core/Switch.my.rb
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
declare_meme(:matched, [[:var, []]], nil, ::Myco.cscope.dup) { |*| (false)}
|
8
8
|
declare_meme(:comparator, [[:var, []]], nil, ::Myco.cscope.dup) { |*| (:==)}
|
9
9
|
declare_meme(:when, [], nil, ::Myco.cscope.dup) { |expected, &blk| (
|
10
|
-
::Myco.branch_op(:"||", self.matched) {::Myco.branch_op(:"&&", self.input.
|
10
|
+
::Myco.branch_op(:"||", self.matched) {::Myco.branch_op(:"&&", self.input.__send__(
|
11
11
|
self.comparator,
|
12
12
|
expected
|
13
13
|
)) {::Myco.branch_op(:"&&", self.__send__(
|
data/lib/myco/core.my
ADDED
data/lib/myco/core.my.rb
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
|
2
|
+
::Myco::Component.new([::Myco::FileToplevel], ::Myco.cscope.for_method_definition, __FILE__, __LINE__)
|
3
|
+
.tap { |__c__| __c__.__last__ = __c__.component_eval {(
|
4
|
+
declare_meme(:"core/Object.my", [[:import, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
5
|
+
declare_meme(:"core/Switch.my", [[:import, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
6
|
+
declare_meme(:"core/Ruby.my", [[:import, []]], nil, ::Myco.cscope.dup) { |*| nil}
|
7
|
+
)}}.instance
|
@@ -0,0 +1,39 @@
|
|
1
|
+
|
2
|
+
module Myco
|
3
|
+
module DEV
|
4
|
+
class CallSites
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def report(*modules)
|
8
|
+
list = []
|
9
|
+
if modules.empty?
|
10
|
+
ObjectSpace.each_object(Module) { |mod| analyze_module(mod, list) }
|
11
|
+
else
|
12
|
+
modules.each { |mod| analyze_module(mod, list) }
|
13
|
+
end
|
14
|
+
list.uniq.sort
|
15
|
+
end
|
16
|
+
|
17
|
+
def report!(*args, count: 2000)
|
18
|
+
list = report(*args)
|
19
|
+
list = list[-count..-1] if list.size > count
|
20
|
+
list.each { |item| p item }
|
21
|
+
end
|
22
|
+
|
23
|
+
def analyze_module(mod, list)
|
24
|
+
mod.method_table.each_entry do |name, executable, _|
|
25
|
+
if executable.respond_to?(:call_sites)
|
26
|
+
executable.call_sites.each do |cache|
|
27
|
+
called = "#{cache.stored_module}##{cache.method.name}" rescue "#{cache.name}"
|
28
|
+
caller = "#{mod}##{name}"
|
29
|
+
location = "#{executable.active_path}:#{executable.line_from_ip(0)}"
|
30
|
+
|
31
|
+
list.push [cache.hits, "#{called} in #{caller} near #{location}"]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
module Myco
|
3
|
+
module DEV
|
4
|
+
class Counter
|
5
|
+
class << self
|
6
|
+
def coll
|
7
|
+
@coll ||= begin
|
8
|
+
at_exit { print! }
|
9
|
+
Hash.new(0)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def count(*items)
|
14
|
+
coll[items] += 1
|
15
|
+
end
|
16
|
+
|
17
|
+
def print!
|
18
|
+
STDOUT.puts "#{self} report:"
|
19
|
+
coll.to_a.sort_by { |x| x.last }.each do |key,val|
|
20
|
+
STDOUT.puts " #{val} : #{key.inspect}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/myco/dev.rb
ADDED
data/lib/myco/eval.rb
CHANGED
@@ -10,7 +10,7 @@ module Myco
|
|
10
10
|
end
|
11
11
|
|
12
12
|
# TODO: deprecate with proper import set of functions
|
13
|
-
def self.eval_file path, load_paths=nil, get_last=true, scope=nil
|
13
|
+
def self.eval_file path, load_paths=nil, get_last=true, scope=Rubinius::ConstantScope.new(::Myco, nil)
|
14
14
|
load_paths ||= [File.dirname(Rubinius::VM.backtrace(1).first.file)]
|
15
15
|
file_toplevel = CodeLoader.load(path, load_paths, cscope:scope, call_depth:1)
|
16
16
|
get_last ? file_toplevel.component.__last__ : file_toplevel.component
|
@@ -42,7 +42,7 @@
|
|
42
42
|
)
|
43
43
|
args = [
|
44
44
|
name,
|
45
|
-
::Myco.branch_op(:"??", (
|
45
|
+
::Myco.branch_op(:"??", (Rubinius::Type.object_respond_to?(self, :argument).false? ? ::Myco::Void : self.argument)) {nil},
|
46
46
|
self.long_form,
|
47
47
|
self.description
|
48
48
|
]
|
data/lib/myco/version.rb
CHANGED
data/lib/myco.rb
CHANGED
@@ -3,6 +3,7 @@ require_relative 'myco/version'
|
|
3
3
|
Myco.activate_required_gems
|
4
4
|
|
5
5
|
Myco::SingletonClass = Myco.singleton_class
|
6
|
+
require_relative 'myco/dev'
|
6
7
|
|
7
8
|
require_relative 'myco/code_loader'
|
8
9
|
require_relative 'myco/eval'
|
@@ -11,9 +12,6 @@ require_relative 'myco/backtrace'
|
|
11
12
|
require_relative 'myco/bootstrap'
|
12
13
|
|
13
14
|
|
14
|
-
# TODO: remove this hack after 0.1.7 gem release
|
15
|
-
::Ruby = ::Object
|
16
|
-
|
17
15
|
# Detect whether a second pass is necessary (when no bytecode is available)
|
18
16
|
# TODO: recursively check mtime for all rbc files as well,
|
19
17
|
# to be sure that core implementation files don't need to be recompiled.
|
@@ -33,6 +31,7 @@ stages.each do |toolset_name|
|
|
33
31
|
# TODO: be more clever here communicating the load path for bootstrapping
|
34
32
|
Myco::CoreLoadPath = File.expand_path('myco', File.dirname(__FILE__))
|
35
33
|
Myco.eval_file 'myco/bootstrap.my'
|
34
|
+
Myco.eval_file 'myco/core.my'
|
36
35
|
end
|
37
36
|
|
38
37
|
require "rubinius/compiler"
|