Class: JIT::Constant

Inherits:
Object
  • Object
show all
Defined in:
lib/libjit/constant.rb

Class Method Summary (collapse)

Class Method Details

+ (Object) create(function, val, *type)

Creates a new constant.

Parameters:

  • function (Function)

    the function to which the constant will belong.

  • val (Number)

    the number to be represented by the constant.

  • *type (Type)

    the type of the constant.



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/libjit/constant.rb', line 9

def self.create(function, val, *type)
  raise ArgumentError.new "function can't be nil" if function.nil?
  
  type = Type.create *type
  if type.bool?
    BoolConstant.new(function, val, type)
  elsif type.floating_point?
    FloatConstant.new(function, val, type)
  else
    IntConstant.new(function, val, type)
  end
end