Class: Idl::StringLiteralAst

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

Overview

represents a string literal

Examples:

">= 1.0"
"by_byte"

Instance Method Summary collapse

Constructor Details

#initialize(input, interval) ⇒ StringLiteralAst

Returns a new instance of StringLiteralAst.



4268
4269
4270
4271
# File 'lib/idl/ast.rb', line 4268

def initialize(input, interval)
  super(input, interval, EMPTY_ARRAY)
  @type = Type.new(:string, width: value(nil).length, qualifiers: [:const])
end

Instance Method Details

#to_idlObject



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

def to_idl = text_value

#type(symtab) ⇒ Object



4276
4277
4278
# File 'lib/idl/ast.rb', line 4276

def type(symtab)
  @type
end

#type_check(_symtab) ⇒ void

This method returns an undefined value.

type check this node and all children

Calls to #type and/or #value may depend on type_check being called first with the same symtab. If not, those functions may raise an AstNode::InternalError

Parameters:

Raises:



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

def type_check(_symtab); end

#value(_symtab) ⇒ Object

Return the compile-time-known value of the node



4281
4282
4283
# File 'lib/idl/ast.rb', line 4281

def value(_symtab)
  text_value.gsub('"', "")
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