Class: CastOff::Compiler::Translator::CFG::Guards
- Inherits:
-
Object
- Object
- CastOff::Compiler::Translator::CFG::Guards
show all
- Includes:
- SimpleIR, Util
- Defined in:
- lib/cast_off/compile/information.rb
Constant Summary
Constants included
from SimpleIR
SimpleIR::SPLATCALL_LIMIT, SimpleIR::SupportLoopInstruction
Constants included
from Instruction
Instruction::BlockSeparator, Instruction::BranchInstruction, Instruction::IgnoreInstruction, Instruction::JumpOrReturnInstruction, Instruction::SupportInstruction, Instruction::TypeInfoUser, Instruction::VM_CALL_ARGS_BLOCKARG_BIT, Instruction::VM_CALL_ARGS_SPLAT_BIT, Instruction::VM_CALL_FCALL_BIT, Instruction::VM_CALL_OPT_SEND_BIT, Instruction::VM_CALL_SUPER_BIT, Instruction::VM_CALL_TAILCALL_BIT, Instruction::VM_CALL_TAILRECURSION_BIT, Instruction::VM_CALL_VCALL_BIT
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from SimpleIR
#block_argument_is_unsupported, #generate_ir
Methods included from Util
#bug, #dlog, #todo, #vlog
Constructor Details
#initialize(b, d, g, ptrs) ⇒ Guards
Returns a new instance of Guards.
754
755
756
757
758
759
|
# File 'lib/cast_off/compile/information.rb', line 754
def initialize(b, d, g, ptrs)
@block = b
@definition = d
@guards = g
@ptrs = ptrs
end
|
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block.
752
753
754
|
# File 'lib/cast_off/compile/information.rb', line 752
def block
@block
end
|
#guards ⇒ Object
Returns the value of attribute guards.
752
753
754
|
# File 'lib/cast_off/compile/information.rb', line 752
def guards
@guards
end
|
Instance Method Details
#&(other) ⇒ Object
765
766
767
768
|
# File 'lib/cast_off/compile/information.rb', line 765
def &(other)
bug() unless other.instance_of?(Guards)
Guards.new(@block, @definition.dup(), @guards & other.guards, @ptrs)
end
|
#==(other) ⇒ Object
776
777
778
|
# File 'lib/cast_off/compile/information.rb', line 776
def ==(other)
eql?(other)
end
|
#dup ⇒ Object
761
762
763
|
# File 'lib/cast_off/compile/information.rb', line 761
def dup()
Guards.new(@block, @definition.dup(), @guards.dup(), @ptrs)
end
|
#eql?(other) ⇒ Boolean
770
771
772
773
774
|
# File 'lib/cast_off/compile/information.rb', line 770
def eql?(other)
bug() unless other.instance_of?(Guards)
bug() unless other.block == @block
@guards == other.guards
end
|
#final_state ⇒ Object
780
781
782
783
784
|
# File 'lib/cast_off/compile/information.rb', line 780
def final_state()
g = dup()
@block.irs.each{|ir| g.step(ir)}
g
end
|
#freeze ⇒ Object
816
817
818
819
820
821
|
# File 'lib/cast_off/compile/information.rb', line 816
def freeze()
super()
@guards.freeze()
@definition.freeze()
self
end
|
#redundant?(ir) ⇒ Boolean
790
791
792
|
# File 'lib/cast_off/compile/information.rb', line 790
def redundant?(ir)
ir.is_a?(StandardGuard) ? @guards.include?(ir.guard_value) : false
end
|
#step(ir) ⇒ Object
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
|
# File 'lib/cast_off/compile/information.rb', line 794
def step(ir)
case ir
when StandardGuard
guard_value = ir.guard_value
bug() unless guard_value.is_a?(Variable)
@guards | [guard_value]
@guards |= @definition.find_same_variables(guard_value)
when SubIR
src = ir.src
dst = ir.dst
if @guards.include?(src)
@guards |= [dst]
else
@guards -= [dst]
end
when CallIR
@guards -= [ir.return_value]
@guards -= @ptrs if ir.dispatch_method?
end
@definition.step(ir)
end
|
#to_s ⇒ Object
823
824
825
|
# File 'lib/cast_off/compile/information.rb', line 823
def to_s()
@guards.map{|g| "#{g.to_debug_string()}"}.join(", ")
end
|
#validate_final ⇒ Object
786
787
788
|
# File 'lib/cast_off/compile/information.rb', line 786
def validate_final()
@definition.validate_final()
end
|