mutant-melbourne 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +25 -0
- data/README.md +69 -0
- data/Rakefile +14 -0
- data/ext/melbourne/.gitignore +3 -0
- data/ext/melbourne/bstring-license.txt +29 -0
- data/ext/melbourne/bstrlib.c +2687 -0
- data/ext/melbourne/bstrlib.h +267 -0
- data/ext/melbourne/encoding_compat.cpp +188 -0
- data/ext/melbourne/encoding_compat.hpp +57 -0
- data/ext/melbourne/extconf.rb +87 -0
- data/ext/melbourne/grammar18.cpp +11280 -0
- data/ext/melbourne/grammar18.hpp +13 -0
- data/ext/melbourne/grammar18.y +6088 -0
- data/ext/melbourne/grammar19.cpp +12420 -0
- data/ext/melbourne/grammar19.hpp +11 -0
- data/ext/melbourne/grammar19.y +7113 -0
- data/ext/melbourne/lex.c.blt +152 -0
- data/ext/melbourne/lex.c.tab +136 -0
- data/ext/melbourne/local_state.hpp +43 -0
- data/ext/melbourne/melbourne.cpp +88 -0
- data/ext/melbourne/melbourne.hpp +19 -0
- data/ext/melbourne/node18.hpp +262 -0
- data/ext/melbourne/node19.hpp +271 -0
- data/ext/melbourne/node_types.rb +304 -0
- data/ext/melbourne/node_types18.cpp +255 -0
- data/ext/melbourne/node_types18.hpp +129 -0
- data/ext/melbourne/node_types19.cpp +249 -0
- data/ext/melbourne/node_types19.hpp +126 -0
- data/ext/melbourne/parser_state18.hpp +181 -0
- data/ext/melbourne/parser_state19.hpp +251 -0
- data/ext/melbourne/quark.cpp +42 -0
- data/ext/melbourne/quark.hpp +45 -0
- data/ext/melbourne/symbols.cpp +224 -0
- data/ext/melbourne/symbols.hpp +119 -0
- data/ext/melbourne/var_table18.cpp +83 -0
- data/ext/melbourne/var_table18.hpp +33 -0
- data/ext/melbourne/var_table19.cpp +65 -0
- data/ext/melbourne/var_table19.hpp +35 -0
- data/ext/melbourne/visitor18.cpp +963 -0
- data/ext/melbourne/visitor18.hpp +12 -0
- data/ext/melbourne/visitor19.cpp +960 -0
- data/ext/melbourne/visitor19.hpp +15 -0
- data/lib/compiler/ast/constants.rb +81 -0
- data/lib/compiler/ast/control_flow.rb +290 -0
- data/lib/compiler/ast/data.rb +14 -0
- data/lib/compiler/ast/definitions.rb +749 -0
- data/lib/compiler/ast/encoding.rb +18 -0
- data/lib/compiler/ast/exceptions.rb +138 -0
- data/lib/compiler/ast/file.rb +11 -0
- data/lib/compiler/ast/grapher.rb +89 -0
- data/lib/compiler/ast/literals.rb +207 -0
- data/lib/compiler/ast/node.rb +362 -0
- data/lib/compiler/ast/operators.rb +106 -0
- data/lib/compiler/ast/self.rb +15 -0
- data/lib/compiler/ast/sends.rb +615 -0
- data/lib/compiler/ast/transforms.rb +298 -0
- data/lib/compiler/ast/values.rb +88 -0
- data/lib/compiler/ast/variables.rb +351 -0
- data/lib/compiler/ast.rb +20 -0
- data/lib/compiler/locals.rb +109 -0
- data/lib/melbourne/processor.rb +651 -0
- data/lib/melbourne/version.rb +3 -0
- data/lib/melbourne.rb +143 -0
- metadata +112 -0
data/lib/compiler/ast.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: us-ascii -*-
|
2
|
+
|
3
|
+
base = File.expand_path "../", __FILE__
|
4
|
+
|
5
|
+
require base + "/ast/node"
|
6
|
+
require base + "/ast/self"
|
7
|
+
require base + "/ast/constants"
|
8
|
+
require base + "/ast/control_flow"
|
9
|
+
require base + "/ast/data"
|
10
|
+
require base + "/ast/definitions"
|
11
|
+
require base + "/ast/encoding"
|
12
|
+
require base + "/ast/exceptions"
|
13
|
+
require base + "/ast/file"
|
14
|
+
require base + "/ast/grapher"
|
15
|
+
require base + "/ast/literals"
|
16
|
+
require base + "/ast/operators"
|
17
|
+
require base + "/ast/sends"
|
18
|
+
require base + "/ast/values"
|
19
|
+
require base + "/ast/variables"
|
20
|
+
require base + "/ast/transforms"
|
@@ -0,0 +1,109 @@
|
|
1
|
+
# -*- encoding: us-ascii -*-
|
2
|
+
|
3
|
+
module Rubinius
|
4
|
+
class Compiler
|
5
|
+
module LocalVariables
|
6
|
+
def variables
|
7
|
+
@variables ||= {}
|
8
|
+
end
|
9
|
+
|
10
|
+
def local_count
|
11
|
+
variables.size
|
12
|
+
end
|
13
|
+
|
14
|
+
def local_names
|
15
|
+
names = []
|
16
|
+
eval_names = []
|
17
|
+
variables.each_pair do |name, var|
|
18
|
+
case var
|
19
|
+
when EvalLocalVariable
|
20
|
+
eval_names << name
|
21
|
+
when LocalVariable
|
22
|
+
names[var.slot] = name
|
23
|
+
# We ignore NestedLocalVariables because they're
|
24
|
+
# tagged as existing only in their source scope.
|
25
|
+
end
|
26
|
+
end
|
27
|
+
names += eval_names
|
28
|
+
end
|
29
|
+
|
30
|
+
def allocate_slot
|
31
|
+
variables.size
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class LocalVariable
|
36
|
+
attr_reader :slot
|
37
|
+
|
38
|
+
def initialize(slot)
|
39
|
+
@slot = slot
|
40
|
+
end
|
41
|
+
|
42
|
+
def reference
|
43
|
+
LocalReference.new @slot
|
44
|
+
end
|
45
|
+
|
46
|
+
def nested_reference
|
47
|
+
NestedLocalReference.new @slot
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
class NestedLocalVariable
|
52
|
+
attr_reader :depth, :slot
|
53
|
+
|
54
|
+
def initialize(depth, slot)
|
55
|
+
@depth = depth
|
56
|
+
@slot = slot
|
57
|
+
end
|
58
|
+
|
59
|
+
def reference
|
60
|
+
NestedLocalReference.new @slot, @depth
|
61
|
+
end
|
62
|
+
|
63
|
+
alias_method :nested_reference, :reference
|
64
|
+
end
|
65
|
+
|
66
|
+
class EvalLocalVariable
|
67
|
+
attr_reader :name
|
68
|
+
|
69
|
+
def initialize(name)
|
70
|
+
@name = name
|
71
|
+
end
|
72
|
+
|
73
|
+
def reference
|
74
|
+
EvalLocalReference.new @name
|
75
|
+
end
|
76
|
+
|
77
|
+
alias_method :nested_reference, :reference
|
78
|
+
end
|
79
|
+
|
80
|
+
class LocalReference
|
81
|
+
attr_reader :slot
|
82
|
+
|
83
|
+
def initialize(slot)
|
84
|
+
@slot = slot
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
class NestedLocalReference
|
89
|
+
attr_accessor :depth
|
90
|
+
attr_reader :slot
|
91
|
+
|
92
|
+
def initialize(slot, depth=0)
|
93
|
+
@slot = slot
|
94
|
+
@depth = depth
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
class EvalLocalReference
|
99
|
+
|
100
|
+
# Ignored, but simplifies duck-typing references
|
101
|
+
attr_accessor :depth
|
102
|
+
|
103
|
+
def initialize(name)
|
104
|
+
@name = name
|
105
|
+
@depth = 0
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|