cast_off 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +40 -19
- data/README.en +0 -1
- data/bin/CastOff +7 -6
- data/cast_off.gemspec +2 -2
- data/ext/cast_off/cast_off.c.rb +118 -21
- data/ext/cast_off/depend +68 -39
- data/ext/cast_off/generated_c_include/iter_api.h +1 -1
- data/ext/cast_off/generated_c_include/vm_api.h +90 -7
- data/ext/cast_off/ruby_source/1.9.2/debug.h +36 -0
- data/ext/cast_off/ruby_source/1.9.2/eval_intern.h +232 -0
- data/ext/cast_off/ruby_source/1.9.2/gc.h +77 -0
- data/ext/cast_off/ruby_source/1.9.2/id.h +170 -0
- data/ext/cast_off/ruby_source/{insns.inc → 1.9.2/insns.inc} +0 -0
- data/ext/cast_off/ruby_source/{insns_info.inc → 1.9.2/insns_info.inc} +0 -0
- data/ext/cast_off/ruby_source/1.9.2/iseq.h +104 -0
- data/ext/cast_off/ruby_source/{manual_update.h → 1.9.2/manual_update.h} +0 -0
- data/ext/cast_off/ruby_source/1.9.2/method.h +103 -0
- data/ext/cast_off/ruby_source/1.9.2/node.h +483 -0
- data/ext/cast_off/ruby_source/1.9.2/thread_pthread.h +27 -0
- data/ext/cast_off/ruby_source/1.9.2/thread_win32.h +33 -0
- data/ext/cast_off/ruby_source/1.9.2/vm_core.h +707 -0
- data/ext/cast_off/ruby_source/1.9.2/vm_exec.h +184 -0
- data/ext/cast_off/ruby_source/1.9.2/vm_insnhelper.c +1721 -0
- data/ext/cast_off/ruby_source/1.9.2/vm_insnhelper.h +208 -0
- data/ext/cast_off/ruby_source/1.9.2/vm_opts.h +51 -0
- data/ext/cast_off/ruby_source/{atomic.h → 1.9.3/atomic.h} +0 -0
- data/ext/cast_off/ruby_source/{constant.h → 1.9.3/constant.h} +0 -0
- data/ext/cast_off/ruby_source/{debug.h → 1.9.3/debug.h} +0 -0
- data/ext/cast_off/ruby_source/{eval_intern.h → 1.9.3/eval_intern.h} +0 -0
- data/ext/cast_off/ruby_source/{gc.h → 1.9.3/gc.h} +0 -0
- data/ext/cast_off/ruby_source/{id.h → 1.9.3/id.h} +0 -0
- data/ext/cast_off/ruby_source/1.9.3/insns.inc +179 -0
- data/ext/cast_off/ruby_source/1.9.3/insns_info.inc +695 -0
- data/ext/cast_off/ruby_source/{internal.h → 1.9.3/internal.h} +0 -0
- data/ext/cast_off/ruby_source/{iseq.h → 1.9.3/iseq.h} +0 -0
- data/ext/cast_off/ruby_source/1.9.3/manual_update.h +135 -0
- data/ext/cast_off/ruby_source/{method.h → 1.9.3/method.h} +0 -0
- data/ext/cast_off/ruby_source/{node.h → 1.9.3/node.h} +0 -0
- data/ext/cast_off/ruby_source/{thread_pthread.h → 1.9.3/thread_pthread.h} +0 -0
- data/ext/cast_off/ruby_source/{thread_win32.h → 1.9.3/thread_win32.h} +0 -0
- data/ext/cast_off/ruby_source/{vm_core.h → 1.9.3/vm_core.h} +0 -0
- data/ext/cast_off/ruby_source/{vm_exec.h → 1.9.3/vm_exec.h} +0 -0
- data/ext/cast_off/ruby_source/{vm_insnhelper.c → 1.9.3/vm_insnhelper.c} +0 -0
- data/ext/cast_off/ruby_source/{vm_insnhelper.h → 1.9.3/vm_insnhelper.h} +0 -0
- data/ext/cast_off/ruby_source/{vm_opts.h → 1.9.3/vm_opts.h} +0 -0
- data/lib/cast_off/compile.rb +118 -68
- data/lib/cast_off/compile/basicblock.rb +3 -1
- data/lib/cast_off/compile/cfg.rb +0 -2
- data/lib/cast_off/compile/code_manager.rb +36 -7
- data/lib/cast_off/compile/configuration.rb +18 -13
- data/lib/cast_off/compile/dependency.rb +32 -11
- data/lib/cast_off/compile/information.rb +10 -6
- data/lib/cast_off/compile/instruction.rb +0 -11
- data/lib/cast_off/compile/ir/call_ir.rb +27 -5
- data/lib/cast_off/compile/ir/operand.rb +54 -34
- data/lib/cast_off/compile/ir/simple_ir.rb +6 -8
- data/lib/cast_off/compile/translator.rb +9 -0
- metadata +41 -25
- data/ext/cast_off/cast_off.h +0 -24
@@ -136,7 +136,9 @@ module CastOff::Compiler
|
|
136
136
|
end
|
137
137
|
|
138
138
|
def to_s()
|
139
|
-
"
|
139
|
+
pstr = "#{@pre.map{|b| "BB#{b.number}"}.join(", ")}"
|
140
|
+
nstr = "#{@next.map{|b| "BB#{b.number}"}.join(", ")}"
|
141
|
+
"(#{pstr})BB#{@number}-#{@iseq}(#{nstr})"
|
140
142
|
end
|
141
143
|
end
|
142
144
|
end
|
data/lib/cast_off/compile/cfg.rb
CHANGED
@@ -14,6 +14,8 @@ module CastOff
|
|
14
14
|
|
15
15
|
CastOffDir = "#{ENV["HOME"]}/.CastOff"
|
16
16
|
FileUtils.mkdir(CastOffDir) unless File.exist?(CastOffDir)
|
17
|
+
BaseDir = "#{CastOffDir}/#{File.expand_path(__FILE__).gsub(/\.|\/|-|:/, "_")}"
|
18
|
+
FileUtils.mkdir(BaseDir) unless File.exist?(BaseDir)
|
17
19
|
|
18
20
|
@@program_name = File.expand_path($PROGRAM_NAME)
|
19
21
|
CastOff::Compiler.class_eval do
|
@@ -23,7 +25,7 @@ module CastOff
|
|
23
25
|
end
|
24
26
|
|
25
27
|
def self.program_dir()
|
26
|
-
dir = "#{
|
28
|
+
dir = "#{BaseDir}/#{@@program_name.gsub(/\.|\/|-|:/, "_")}"
|
27
29
|
FileUtils.mkdir(dir) unless File.exist?(dir)
|
28
30
|
dir
|
29
31
|
end
|
@@ -35,14 +37,35 @@ module CastOff
|
|
35
37
|
dir
|
36
38
|
end
|
37
39
|
|
40
|
+
def self.delete_from_compiled(entry)
|
41
|
+
compiled = load_autocompiled()
|
42
|
+
return false unless compiled
|
43
|
+
return false unless compiled.delete(entry)
|
44
|
+
dump_auto_compiled(compiled)
|
45
|
+
return true
|
46
|
+
end
|
47
|
+
|
48
|
+
@@compiled_methods_fetch_str = nil
|
49
|
+
@@compiled_methods_load_str = nil
|
38
50
|
def self.load_autocompiled()
|
39
51
|
begin
|
40
52
|
dir = program_dir()
|
41
|
-
|
53
|
+
# fetch classes
|
54
|
+
path = "#{dir}/.compiled_methods"
|
55
|
+
return nil unless File.exist?(path)
|
56
|
+
if !@@compiled_methods_fetch_str
|
57
|
+
@@compiled_methods_fetch_str = File.open(path, 'rb:us-ascii').read()
|
58
|
+
@@compiled_methods_fetch_str.untaint # FIXME
|
59
|
+
end
|
60
|
+
Marshal.load(@@compiled_methods_fetch_str)
|
61
|
+
# load compiled methods information
|
62
|
+
path = "#{dir}/compiled_methods"
|
42
63
|
return nil unless File.exist?(path)
|
43
|
-
|
44
|
-
|
45
|
-
|
64
|
+
if !@@compiled_methods_load_str
|
65
|
+
@@compiled_methods_load_str = File.open(path, 'rb:us-ascii').read()
|
66
|
+
@@compiled_methods_load_str.untaint # FIXME
|
67
|
+
end
|
68
|
+
Marshal.load(@@compiled_methods_load_str)
|
46
69
|
rescue ArgumentError, NameError
|
47
70
|
false
|
48
71
|
end
|
@@ -50,10 +73,16 @@ module CastOff
|
|
50
73
|
|
51
74
|
def self.dump_auto_compiled(compiled)
|
52
75
|
dir = program_dir()
|
53
|
-
path = "#{dir}
|
76
|
+
path = "#{dir}/.compiled_methods"
|
77
|
+
File.open("#{path}", 'wb:us-ascii') do |f|
|
78
|
+
Marshal.dump(compiled.map{|c| c.first}, f) # dump only classes
|
79
|
+
end
|
80
|
+
@@compiled_methods_fetch_str = nil
|
81
|
+
path = "#{dir}/compiled_methods"
|
54
82
|
File.open("#{path}", 'wb:us-ascii') do |f|
|
55
83
|
Marshal.dump(compiled, f)
|
56
84
|
end
|
85
|
+
@@compiled_methods_load_str = nil
|
57
86
|
load_autocompiled()
|
58
87
|
end
|
59
88
|
|
@@ -97,7 +126,7 @@ module CastOff
|
|
97
126
|
@depfile = "#{@signiture}.mdep"
|
98
127
|
@deppath = "#{@dstdir}/#{@depfile}"
|
99
128
|
@conffile = "#{@signiture}.conf"
|
100
|
-
@base_configuration_path = "#{@dstdir}/#{
|
129
|
+
@base_configuration_path = "#{@dstdir}/#{base_sign}.base.conf"
|
101
130
|
@annotation_path = "#{@dstdir}/#{@signiture}.ann"
|
102
131
|
@development_mark_file = "development"
|
103
132
|
@development_mark_path = "#{@dstdir}/#{@development_mark_file}"
|
@@ -110,7 +110,7 @@ o = Object
|
|
110
110
|
end
|
111
111
|
|
112
112
|
def hash()
|
113
|
-
|
113
|
+
BindingWrapper.hash
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
@@ -2157,19 +2157,24 @@ Currently, CastOff doesn't support object, which cannot marshal dump (e.g. STDIN
|
|
2157
2157
|
[Float, :phase, :class],
|
2158
2158
|
]
|
2159
2159
|
DIRECT_CALL_TARGETS.map! do |(obj, mid, t)|
|
2160
|
-
|
2161
|
-
|
2162
|
-
|
2163
|
-
|
2164
|
-
|
2165
|
-
|
2166
|
-
|
2167
|
-
|
2168
|
-
|
2169
|
-
|
2170
|
-
|
2160
|
+
begin
|
2161
|
+
case t
|
2162
|
+
when :class
|
2163
|
+
bug() unless obj.instance_of?(Class)
|
2164
|
+
MethodWrapper.new(ClassWrapper.new(obj, true), mid)
|
2165
|
+
when :module
|
2166
|
+
bug() unless obj.instance_of?(Module)
|
2167
|
+
MethodWrapper.new(ModuleWrapper.new(obj), mid)
|
2168
|
+
when :singleton
|
2169
|
+
MethodWrapper.new(ClassWrapper.new(obj, false), mid)
|
2170
|
+
else
|
2171
|
+
bug()
|
2172
|
+
end
|
2173
|
+
rescue CompileError # method not found
|
2174
|
+
vlog("method not found #{obj} #{mid}")
|
2171
2175
|
end
|
2172
2176
|
end
|
2177
|
+
DIRECT_CALL_TARGETS.compact!
|
2173
2178
|
|
2174
2179
|
def should_be_call_directly?(klass, mid)
|
2175
2180
|
bug() unless klass.is_a?(ClassWrapper)
|
@@ -2237,7 +2242,7 @@ Currently, CastOff doesn't support object, which cannot marshal dump (e.g. STDIN
|
|
2237
2242
|
:@@enable_inline_api => [true, true, false],
|
2238
2243
|
:@@inject_guard => [true, true, false],
|
2239
2244
|
:@@array_conservative => [true, true, false],
|
2240
|
-
:@@
|
2245
|
+
:@@reuse_compiled_code => [true, false, true],
|
2241
2246
|
:@@allow_builtin_variable_incompatibility => [false, true, false],
|
2242
2247
|
:@@prefetch_constant => [true, true, false],
|
2243
2248
|
:@@deoptimize => [false, true, false],
|
@@ -81,7 +81,13 @@ module CastOff
|
|
81
81
|
dep = @@singleton_method_dependency[obj]
|
82
82
|
return false unless dep
|
83
83
|
return false unless dep.include?(mid)
|
84
|
-
|
84
|
+
unless @@singleton_method_dependency_initializers[[obj, mid]]
|
85
|
+
if mid == :method_added || mid == :singleton_method_added
|
86
|
+
return []
|
87
|
+
else
|
88
|
+
bug()
|
89
|
+
end
|
90
|
+
end
|
85
91
|
@@singleton_method_dependency_initializers[[obj, mid]]
|
86
92
|
end
|
87
93
|
|
@@ -121,19 +127,20 @@ Currently, CastOff doesn't support object, which cannot marshal dump (e.g. STDIN
|
|
121
127
|
end
|
122
128
|
|
123
129
|
def add(klass, mid, strong_p)
|
124
|
-
# TODO
|
130
|
+
# TODO include で継承関係が変わったのを検出
|
125
131
|
bug() unless klass.instance_of?(ClassWrapper)
|
126
132
|
targets = [klass]
|
127
133
|
if not klass.singleton?
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
134
|
+
klass.each_method_search_target(mid) do |cm|
|
135
|
+
next if cm == klass.contain_class
|
136
|
+
case cm
|
137
|
+
when Class
|
138
|
+
targets << ClassWrapper.new(cm, true)
|
139
|
+
when Module
|
140
|
+
targets << ModuleWrapper.new(cm)
|
141
|
+
else
|
142
|
+
bug()
|
143
|
+
end
|
137
144
|
end
|
138
145
|
end
|
139
146
|
targets.each do |t|
|
@@ -186,17 +193,31 @@ Currently, CastOff doesn't support object, which cannot marshal dump (e.g. STDIN
|
|
186
193
|
end
|
187
194
|
end
|
188
195
|
|
196
|
+
begin
|
197
|
+
singleton_method_added = o.method(:singleton_method_added)
|
198
|
+
rescue NameError
|
199
|
+
singleton_method_added = nil
|
200
|
+
end
|
201
|
+
begin
|
202
|
+
method_added = o.method(:method_added)
|
203
|
+
rescue NameError
|
204
|
+
method_added = nil
|
205
|
+
end
|
189
206
|
define_method(:method_added) do |mid|
|
190
207
|
if self == o && !Dependency.ignore_overridden?(self, mid)
|
191
208
|
if Dependency.singleton_method_added?
|
192
209
|
CastOff.dlog("singleton method added #{o}.#{mid}")
|
193
210
|
CastOff.delete_original_singleton_method_iseq(self, mid)
|
194
211
|
override_singleton_method(o, mid, :added)
|
212
|
+
singleton_method_added.call(mid) if singleton_method_added
|
195
213
|
else
|
196
214
|
CastOff.dlog("method added #{o}##{mid}")
|
197
215
|
CastOff.delete_original_instance_method_iseq(self, mid)
|
198
216
|
override_method(o, mid, :added)
|
217
|
+
method_added.call(mid) if method_added
|
199
218
|
end
|
219
|
+
elsif o == BasicObject && method_added && !Dependency.singleton_method_added?
|
220
|
+
method_added.call(mid)
|
200
221
|
end
|
201
222
|
super(mid) rescue NoMethodError
|
202
223
|
end
|
@@ -165,6 +165,8 @@ module CastOff::Compiler
|
|
165
165
|
ret |= var.is_dynamic()
|
166
166
|
when Pointer, Argument
|
167
167
|
ret |= var.is_dynamic()
|
168
|
+
when Self
|
169
|
+
bug() if var.undefined?
|
168
170
|
else
|
169
171
|
bug(var)
|
170
172
|
end
|
@@ -181,7 +183,7 @@ module CastOff::Compiler
|
|
181
183
|
ds = @variable_definition.select{|d| var == d.result_variable }
|
182
184
|
if @undefs.include?(var) || ds.empty?
|
183
185
|
case var
|
184
|
-
when TmpBuffer, Pointer, Argument
|
186
|
+
when TmpBuffer, Pointer, Argument, Self
|
185
187
|
return false
|
186
188
|
else
|
187
189
|
bug(var)
|
@@ -739,22 +741,24 @@ module CastOff::Compiler
|
|
739
741
|
@guards.freeze()
|
740
742
|
@variable_definition.freeze()
|
741
743
|
end
|
744
|
+
|
745
|
+
def to_s()
|
746
|
+
@guards.map{|g| "#{g.to_debug_string()}"}.join(", ")
|
747
|
+
end
|
742
748
|
end
|
743
749
|
|
744
750
|
def inject_guards()
|
745
751
|
vars = all_variable()
|
746
752
|
ptrs = all_pointer()
|
747
|
-
|
753
|
+
vars.freeze()
|
754
|
+
ptrs.freeze()
|
748
755
|
@blocks.each do |b|
|
749
756
|
b.irs.map! do |ir|
|
750
757
|
g = ir.generate_guard(vars)
|
751
|
-
guards << g
|
752
758
|
g ? [g, ir] : ir
|
753
759
|
end
|
754
760
|
b.irs.flatten!
|
755
761
|
end
|
756
|
-
guards.compact()
|
757
|
-
guards.freeze()
|
758
762
|
|
759
763
|
bug() if @blocks.find{|b| not b.information.frozen?}
|
760
764
|
@blocks.each{|b| b.in_guards = Guards.new(b, b.information, [], ptrs)}
|
@@ -763,7 +767,7 @@ module CastOff::Compiler
|
|
763
767
|
change = false
|
764
768
|
@blocks.each do |b0|
|
765
769
|
next if b0.entry_point?
|
766
|
-
in_guards = b0.pre.inject(Guards.new(b0, b0.information,
|
770
|
+
in_guards = b0.pre.inject(Guards.new(b0, b0.information, vars, ptrs)){|in_g, b1| in_g & b1.in_guards.final_state()}
|
767
771
|
change = true if b0.in_guards != in_guards
|
768
772
|
b0.in_guards = in_guards
|
769
773
|
end
|
@@ -13,17 +13,6 @@ module CastOff::Compiler
|
|
13
13
|
VM_CALL_SUPER_BIT = (0x01 << 7)
|
14
14
|
VM_CALL_OPT_SEND_BIT = (0x01 << 8)
|
15
15
|
|
16
|
-
DEFINED_IVAR = 1
|
17
|
-
DEFINED_IVAR2 = 2
|
18
|
-
DEFINED_GVAR = 3
|
19
|
-
DEFINED_CVAR = 4
|
20
|
-
DEFINED_CONST = 5
|
21
|
-
DEFINED_METHOD = 6
|
22
|
-
DEFINED_YIELD = 7
|
23
|
-
DEFINED_REF = 8
|
24
|
-
DEFINED_ZSUPER = 9
|
25
|
-
DEFINED_FUNC = 10
|
26
|
-
|
27
16
|
SupportInstruction = [
|
28
17
|
:trace, :nop, :putnil, :getdynamic, :send, :leave, :putobject, :putself, :putstring, :newrange,
|
29
18
|
:newarray, :duparray, :tostring, :concatstrings, :setdynamic, :newhash, :branchunless, :branchif, :toregexp,
|
@@ -1104,6 +1104,14 @@ If you want to use these variables, use CastOff.allow_builtin_variable_incompati
|
|
1104
1104
|
#{@return_value} = #{@needstr ? 'rb_str_new2("method")' : 'Qtrue'};
|
1105
1105
|
} else {
|
1106
1106
|
#{@return_value} = Qnil;
|
1107
|
+
}
|
1108
|
+
EOS
|
1109
|
+
when DEFINED_CONST
|
1110
|
+
ret << <<-EOS
|
1111
|
+
if (cast_off_const_defined(#{val}, #{@id})) {
|
1112
|
+
#{@return_value} = #{@needstr ? 'rb_str_new2("constant")' : 'Qtrue'};
|
1113
|
+
} else {
|
1114
|
+
#{@return_value} = Qnil;
|
1107
1115
|
}
|
1108
1116
|
EOS
|
1109
1117
|
else
|
@@ -1405,7 +1413,8 @@ Call site is (#{@insn}).
|
|
1405
1413
|
%bug() unless param.size > 0
|
1406
1414
|
{
|
1407
1415
|
int argc = <%= @argc - 1 %>;
|
1408
|
-
VALUE
|
1416
|
+
VALUE buf[<%= SPLATCALL_LIMIT %>]; /* FIXME */
|
1417
|
+
VALUE *argv = buf;
|
1409
1418
|
%splat_param = param.last()
|
1410
1419
|
%normal_param = param.slice(0, param.size() - 1)
|
1411
1420
|
VALUE ary = <%= splat_param %>;
|
@@ -1432,7 +1441,11 @@ Call site is (#{@insn}).
|
|
1432
1441
|
ptr = RARRAY_PTR(tmp);
|
1433
1442
|
argc += len;
|
1434
1443
|
if (UNLIKELY(argc > <%= SPLATCALL_LIMIT %>)) {
|
1435
|
-
|
1444
|
+
VALUE *newbuf = ALLOCA_N(VALUE, argc);
|
1445
|
+
%normal_param.size.times do |i|
|
1446
|
+
newbuf[i] = argv[i];
|
1447
|
+
%end
|
1448
|
+
argv = newbuf;
|
1436
1449
|
}
|
1437
1450
|
for (i = 0; i < len; i++) {
|
1438
1451
|
argv[<%= normal_param.size %> + i] = ptr[i];
|
@@ -1615,7 +1628,8 @@ You should not use #{@method_id} method in compilation target of CastOff.
|
|
1615
1628
|
%bug() unless param.size > 0
|
1616
1629
|
{
|
1617
1630
|
int argc = <%= argc - 2 %>;
|
1618
|
-
VALUE
|
1631
|
+
VALUE buf[<%= SPLATCALL_LIMIT %>];
|
1632
|
+
VALUE *argv = buf;
|
1619
1633
|
%splat_param = param.last()
|
1620
1634
|
%normal_param = param.slice(0, param.size() - 1)
|
1621
1635
|
VALUE ary = <%= splat_param %>;
|
@@ -1642,7 +1656,11 @@ You should not use #{@method_id} method in compilation target of CastOff.
|
|
1642
1656
|
ptr = RARRAY_PTR(tmp);
|
1643
1657
|
argc += len;
|
1644
1658
|
if (UNLIKELY(argc > <%= SPLATCALL_LIMIT %>)) {
|
1645
|
-
|
1659
|
+
VALUE *newbuf = ALLOCA_N(VALUE, argc);
|
1660
|
+
%normal_param.size.times do |i|
|
1661
|
+
newbuf[i] = argv[i];
|
1662
|
+
%end
|
1663
|
+
argv = newbuf;
|
1646
1664
|
}
|
1647
1665
|
for (i = 0; i < len; i++) {
|
1648
1666
|
argv[<%= normal_param.size %> + i] = ptr[i];
|
@@ -1919,7 +1937,11 @@ You should not use #{@method_id} method in compilation target of CastOff.
|
|
1919
1937
|
if @translator.reciever_class && @translator.reciever_class.size() == 1
|
1920
1938
|
same_class = true if recv.is_just?(@translator.reciever_class[0])
|
1921
1939
|
end
|
1922
|
-
|
1940
|
+
recv_defn = param_irs.first.get_definition(recv)
|
1941
|
+
if recv_defn.size == 1 && (@translator.inline_block? || @insn.iseq.root?)
|
1942
|
+
recv_defn = recv_defn.first
|
1943
|
+
same_class |= recv_defn.is_a?(SubIR) && recv_defn.src.is_a?(Self)
|
1944
|
+
end
|
1923
1945
|
if same_class && mid == @translator.mid
|
1924
1946
|
true
|
1925
1947
|
else
|
@@ -161,18 +161,7 @@ module CastOff::Compiler
|
|
161
161
|
end
|
162
162
|
|
163
163
|
def reset()
|
164
|
-
|
165
|
-
case @state
|
166
|
-
when :undefined
|
167
|
-
bug()
|
168
|
-
when :initialized, :dynamic
|
169
|
-
@types = []
|
170
|
-
@state = :undefined
|
171
|
-
when :static
|
172
|
-
# nothing to do
|
173
|
-
else
|
174
|
-
bug()
|
175
|
-
end
|
164
|
+
bug()
|
176
165
|
end
|
177
166
|
|
178
167
|
def not_initialized()
|
@@ -563,11 +552,55 @@ module CastOff::Compiler
|
|
563
552
|
end
|
564
553
|
end
|
565
554
|
|
566
|
-
class
|
555
|
+
class Variable < TypeContainer
|
556
|
+
def initialize()
|
557
|
+
super()
|
558
|
+
@isclassexact = false
|
559
|
+
end
|
560
|
+
|
561
|
+
def class_exact?
|
562
|
+
@isclassexact
|
563
|
+
end
|
564
|
+
|
565
|
+
def is_class_exact()
|
566
|
+
bug() if @isclassexact
|
567
|
+
@isclassexact = true
|
568
|
+
end
|
569
|
+
|
570
|
+
def has_undefined_path()
|
571
|
+
# nothing to do
|
572
|
+
end
|
573
|
+
|
574
|
+
def declare?
|
575
|
+
self.is_a?(LocalVariable) || self.is_a?(TmpVariable) || self.is_a?(Pointer)
|
576
|
+
end
|
577
|
+
|
578
|
+
def reset()
|
579
|
+
@ignore.clear()
|
580
|
+
case @state
|
581
|
+
when :undefined
|
582
|
+
bug()
|
583
|
+
when :initialized, :dynamic
|
584
|
+
@types = []
|
585
|
+
@state = :undefined
|
586
|
+
when :static
|
587
|
+
# nothing to do
|
588
|
+
else
|
589
|
+
bug()
|
590
|
+
end
|
591
|
+
end
|
592
|
+
end
|
593
|
+
|
594
|
+
class Self < Variable
|
567
595
|
include CastOff::Util
|
568
596
|
|
569
|
-
|
597
|
+
attr_reader :iseq
|
598
|
+
|
599
|
+
def initialize(translator, iseq)
|
570
600
|
super()
|
601
|
+
@iseq = iseq
|
602
|
+
@translator = translator
|
603
|
+
bug() unless @iseq.is_a?(Iseq)
|
571
604
|
reciever_class = translator.reciever_class
|
572
605
|
if reciever_class
|
573
606
|
#is_static(reciever_class)
|
@@ -591,7 +624,10 @@ module CastOff::Compiler
|
|
591
624
|
end
|
592
625
|
|
593
626
|
def eql?(v)
|
594
|
-
v.is_a?(Self)
|
627
|
+
#v.is_a?(Self)
|
628
|
+
return false unless v.is_a?(Self)
|
629
|
+
return true if @translator.inline_block?
|
630
|
+
@iseq == v.iseq
|
595
631
|
end
|
596
632
|
|
597
633
|
def ==(v)
|
@@ -601,30 +637,14 @@ module CastOff::Compiler
|
|
601
637
|
def hash
|
602
638
|
self.to_name.hash
|
603
639
|
end
|
604
|
-
end
|
605
640
|
|
606
|
-
|
607
|
-
|
608
|
-
super()
|
609
|
-
@isclassexact = false
|
610
|
-
end
|
611
|
-
|
612
|
-
def class_exact?
|
613
|
-
@isclassexact
|
614
|
-
end
|
615
|
-
|
616
|
-
def is_class_exact()
|
617
|
-
bug() if @isclassexact
|
618
|
-
@isclassexact = true
|
641
|
+
def to_debug_string
|
642
|
+
"#{super}(#{@iseq})"
|
619
643
|
end
|
620
644
|
|
621
|
-
def
|
645
|
+
def reset()
|
622
646
|
# nothing to do
|
623
647
|
end
|
624
|
-
|
625
|
-
def declare?
|
626
|
-
self.is_a?(LocalVariable) || self.is_a?(TmpVariable) || self.is_a?(Pointer)
|
627
|
-
end
|
628
648
|
end
|
629
649
|
|
630
650
|
class TmpVariable < Variable
|