Class: Idl::DontCareReturnAst

Inherits:
AstNode
  • Object
show all
Includes:
Rvalue
Defined in:
lib/idl/ast.rb

Overview

represents a don’t care return value

for exaple:

return -;

Instance Method Summary collapse

Constructor Details

#initialize(input, interval) ⇒ DontCareReturnAst

Returns a new instance of DontCareReturnAst.



3827
3828
3829
# File 'lib/idl/ast.rb', line 3827

def initialize(input, interval)
  super(input, interval, EMPTY_ARRAY)
end

Instance Method Details

#set_expected_type(t) ⇒ Object



3855
3856
3857
# File 'lib/idl/ast.rb', line 3855

def set_expected_type(t)
  @expected_type = t
end

#to_idlObject



3859
# File 'lib/idl/ast.rb', line 3859

def to_idl = "-"

#type(_symtab) ⇒ Type

Return the type of this node

Parameters:

Returns:

  • (Type)

    The type of the node



3837
3838
3839
# File 'lib/idl/ast.rb', line 3837

def type(_symtab)
  Type.new(:dontcare)
end

#type_check(_symtab) ⇒ Object



3832
3833
3834
# File 'lib/idl/ast.rb', line 3832

def type_check(_symtab)
  # nothing to do!
end

#value(_symtab) ⇒ Integer, Boolean

Return the compile-time-known value of the node

Parameters:

Returns:

  • (Integer)

    if the compile-time-known value is an integer

  • (Boolean)

    if the compile-time-known value is a boolean

Raises:



3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
# File 'lib/idl/ast.rb', line 3842

def value(_symtab)
  internal_error "Must call set_expected_type first" if @expected_type.nil?

  case @expected_type.kind
  when :bits
    0
  when :boolean
    false
  else
    internal_error "Unhandled expected type"
  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

Parameters:

  • symtab (SymbolTable)

    The context for the evaulation

Returns:

  • (Array<Integer>)

    The complete list of compile-time-known values, when they are integral

  • (Array<Boolean>)

    The complete list of compile-time-known values, when they are booleans

  • (AstNode::ValueError)

    if the list of values is not knowable at compile time