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.
2528 |
# File 'lib/idl/ast.rb', line 2528 def initialize(input, interval, exp) = super(input, interval, [exp]) |
Instance Method Details
#expression ⇒ Object
2526 |
# File 'lib/idl/ast.rb', line 2526 def expression = @children[0] |
#to_idl ⇒ String
Return valid IDL representation of the node (and its subtree)
2553 |
# File 'lib/idl/ast.rb', line 2553 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
2536 |
# File 'lib/idl/ast.rb', line 2536 def type(symtab) = expression.type(symtab).clone.make_signed |
#type_check(symtab) ⇒ void
2531 2532 2533 |
# File 'lib/idl/ast.rb', line 2531 def type_check(symtab) expression.type_check(symtab) end |
#value(symtab) ⇒ Object
Return the compile-time-known value of the node
2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 |
# File 'lib/idl/ast.rb', line 2539 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