Class: YTLJit::VM::Node::LiteralNode
- Includes:
- TypeListWithoutSignature
- Defined in:
- lib/ytljit/vm.rb
Overview
Literal
Constant Summary
Constants included from AbsArch
AbsArch::AL, AbsArch::BL, AbsArch::CL, AbsArch::DL, AbsArch::FUNC_ARG, AbsArch::FUNC_ARG_YTL, AbsArch::FUNC_FLOAT_ARG, AbsArch::FUNC_FLOAT_ARG_YTL, AbsArch::INDIRECT_BPR, AbsArch::INDIRECT_RETR, AbsArch::INDIRECT_SPR, AbsArch::INDIRECT_TMPR, AbsArch::INDIRECT_TMPR2, AbsArch::INDIRECT_TMPR3
Constants included from SSE
SSE::XMM0, SSE::XMM1, SSE::XMM2, SSE::XMM3, SSE::XMM4, SSE::XMM5, SSE::XMM6, SSE::XMM7
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Attributes inherited from BaseNode
#code_space, #debug_info, #element_node_list, #id, #is_escape, #parent, #ti_observee, #ti_observer, #type
Instance Method Summary collapse
- #collect_candidate_type(context) ⇒ Object
- #compile(context) ⇒ Object
- #get_constant_value ⇒ Object
-
#initialize(parent, val) ⇒ LiteralNode
constructor
A new instance of LiteralNode.
Methods included from TypeListWithoutSignature
#add_type, #set_type_list, #type_list, #type_list_initvar
Methods inherited from BaseNode
#add_element_node, #collect_info, #decide_type, #decide_type_core, #decide_type_once, #gen_type_inference_proc, #inference_type, #merge_type, #same_type, #ti_add_observer, #ti_changed, #ti_del_link, #ti_reset, #ti_update
Methods included from TypeListWithSignature
#add_type, #set_type_list, #type_list, #type_list_initvar
Methods included from Inspect
Constructor Details
#initialize(parent, val) ⇒ LiteralNode
Returns a new instance of LiteralNode.
1909 1910 1911 1912 1913 |
# File 'lib/ytljit/vm.rb', line 1909 def initialize(parent, val) super(parent) @value = val @type = RubyType::BaseType.from_object(val) end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
1915 1916 1917 |
# File 'lib/ytljit/vm.rb', line 1915 def value @value end |
Instance Method Details
#collect_candidate_type(context) ⇒ Object
1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 |
# File 'lib/ytljit/vm.rb', line 1917 def collect_candidate_type(context) # ??? if @type == nil then @type = RubyType::BaseType.from_object(@value) end sig = context.to_signature case @value when Array add_type(sig, @type) @value.each do |ele| etype = RubyType::BaseType.from_object(ele) @element_node_list[0][1].add_type(sig, etype) end when Range @type = @type.to_box add_type(sig, @type) else add_type(sig, @type) end context end |
#compile(context) ⇒ Object
1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 |
# File 'lib/ytljit/vm.rb', line 1943 def compile(context) context = super(context) decide_type_once(context.to_signature) case @value when Fixnum val = @value if @type.boxed then val = val.boxing end context.ret_node = self context.ret_reg = OpImmidiateMachineWord.new(val) when Float val = @value if @type.boxed then val = val.boxing context.ret_reg = OpImmidiateMachineWord.new(val) else offm4 = OpIndirect.new(SPR, -AsmType::DOUBLE.size) asm = context.assembler asm.with_retry do asm.mov64(offm4, val.unboxing) asm.movsd(XMM0, offm4) end context.ret_reg = XMM0 end context.ret_node = self context.set_reg_content(context.ret_reg, self) else if @var_value == nil then add = lambda { @value.address } @var_value = OpVarImmidiateAddress.new(add) end context.ret_node = self context.ret_reg = @var_value context = @type.gen_copy(context) context.set_reg_content(context.ret_reg, self) end context end |
#get_constant_value ⇒ Object
1988 1989 1990 |
# File 'lib/ytljit/vm.rb', line 1988 def get_constant_value [@value] end |