Class: Idl::SignCastAst
- Includes:
- Rvalue
- Defined in:
- lib/idl/ast.rb
Instance Method Summary collapse
- #expression ⇒ Object
-
#initialize(input, interval, exp) ⇒ SignCastAst
constructor
A new instance of SignCastAst.
-
#to_idl ⇒ String
Return valid IDL representation of the node (and its subtree).
-
#type(symtab) ⇒ Type
Given a specific symbol table, return the type of this node.
-
#type_check(symtab) ⇒ void
type check this node and all children.
-
#value(symtab) ⇒ Object
Return the compile-time-known value of the node.
-
#values(symtab) ⇒ Array<Integer>, ...
included
from Rvalue
Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined.
Constructor Details
#initialize(input, interval, exp) ⇒ SignCastAst
Returns a new instance of SignCastAst.
2524 |
# File 'lib/idl/ast.rb', line 2524 def initialize(input, interval, exp) = super(input, interval, [exp]) |
Instance Method Details
#expression ⇒ Object
2522 |
# File 'lib/idl/ast.rb', line 2522 def expression = @children[0] |
#to_idl ⇒ String
Return valid IDL representation of the node (and its subtree)
2549 |
# File 'lib/idl/ast.rb', line 2549 def to_idl = "$signed(#{expression.to_idl})" |
#type(symtab) ⇒ Type
Given a specific symbol table, return the type of this node.
Should not be called until #type_check is called with the same arguments
2532 |
# File 'lib/idl/ast.rb', line 2532 def type(symtab) = expression.type(symtab).clone.make_signed |
#type_check(symtab) ⇒ void
2527 2528 2529 |
# File 'lib/idl/ast.rb', line 2527 def type_check(symtab) expression.type_check(symtab) end |
#value(symtab) ⇒ Object
Return the compile-time-known value of the node
2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 |
# File 'lib/idl/ast.rb', line 2535 def value(symtab) t = expression.type(symtab) internal_error "Expecting a bits type" unless t.kind == :bits v = expression.value(symtab) if ((v >> (t.width - 1)) & 1) == 1 # twos compliment negate the value -(2**t.width - v) else v end end |
#values(symtab) ⇒ Array<Integer>, ... Originally defined in module Rvalue
Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined
For most AstNodes, this will just be a single-entry array