Class: Rubycc::Front::AST::BuiltinOverflow

Inherits:
Data
  • Object
show all
Defined in:
lib/rubycc/front/ast.rb

Overview

"__builtin_add/sub/mul_overflow ( a , b , res )": computes "a op b" with infinite precision, stores the result converted to the type res points at (wrapping or truncating like any integer conversion), and yields int 1 when that conversion lost the value and 0 when it did not. op is :add, :sub or :mul and args holds the three argument expressions as written. The parser checks only the argument count; the operand types (both integers, res a pointer to an integer) need resolved types and are the generator's to diagnose. token is the builtin keyword.

The two operands keep their own types — no usual arithmetic conversion runs between them, which is the whole point of the builtin: "int -1" plus "unsigned 1" is 0 in infinite precision, not UINT_MAX.

Instance Attribute Summary collapse

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args

Returns:

  • (Object)

    the current value of args



417
418
419
# File 'lib/rubycc/front/ast.rb', line 417

def args
  @args
end

#opObject (readonly)

Returns the value of attribute op

Returns:

  • (Object)

    the current value of op



417
418
419
# File 'lib/rubycc/front/ast.rb', line 417

def op
  @op
end

#tokenObject (readonly)

Returns the value of attribute token

Returns:

  • (Object)

    the current value of token



417
418
419
# File 'lib/rubycc/front/ast.rb', line 417

def token
  @token
end