Module: Rucc::Type::Check

Included in:
Rucc::Type
Defined in:
lib/rucc/type/check.rb

Instance Method Summary collapse

Instance Method Details

#is_arithtype(ty) ⇒ Boolean

Parameters:

Returns:

  • (Boolean)


6
7
8
# File 'lib/rucc/type/check.rb', line 6

def is_arithtype(ty)
  is_inttype(ty) || is_flotype(ty)
end

#is_flotype(ty) ⇒ Boolean

Parameters:

Returns:

  • (Boolean)


23
24
25
26
27
28
29
30
# File 'lib/rucc/type/check.rb', line 23

def is_flotype(ty)
  case ty.kind
  when Kind::FLOAT, Kind::DOUBLE, Kind::LDOUBLE
    true
  else
    false
  end
end

#is_inttype(ty) ⇒ Boolean

Parameters:

Returns:

  • (Boolean)


12
13
14
15
16
17
18
19
# File 'lib/rucc/type/check.rb', line 12

def is_inttype(ty)
  case ty.kind
  when Kind::BOOL, Kind::CHAR, Kind::SHORT, Kind::INT, Kind::LONG, Kind::LLONG
    true
  else
    false
  end
end

#is_string(ty) ⇒ Boolean

Parameters:

Returns:

  • (Boolean)


34
35
36
# File 'lib/rucc/type/check.rb', line 34

def is_string(ty)
  ty.kind == Kind::ARRAY && ty.ptr.kind == Kind::CHAR
end