Class: Idl::PostIncrementExpressionAst

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

Overview

represents a post-increment expression

for example:

i++

Instance Method Summary collapse

Constructor Details

#initialize(input, interval, rval) ⇒ PostIncrementExpressionAst

Returns a new instance of PostIncrementExpressionAst.

[View source]

3310
3311
3312
# File 'lib/idl/ast.rb', line 3310

def initialize(input, interval, rval)
  super(input, interval, [rval])
end

Instance Method Details

#execute(symtab) ⇒ void

This method returns an undefined value.

“execute” the statement by updating the variables in the symbol table

Parameters:

  • symtab (SymbolTable)

    The symbol table for the context

Raises:

  • ValueError if some part of the statement cannot be executed at compile time

[View source]

3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
# File 'lib/idl/ast.rb', line 3327

def execute(symtab)
  var = symtab.get(rval.text_value)

  value_result = value_try do
    internal_error "No symbol named '#{rval.text_value}'" if var.nil?

    value_error "#{rval.text_value} is not compile-time-known" if var.value.nil?

    var.value = var.value + 1
  end
  value_else(value_result) do
    var.value = nil
    value_error "#{rval.text_value} is not compile-time-known" if var.value.nil?
  end
end

#execute_unknown(symtab) ⇒ void

This method returns an undefined value.

“execute” the statement, forcing any variable assignments to an unknown state This is used down unknown conditional paths.

Parameters:

  • symtab (SymbolTable)

    The symbol table for the context

Raises:

  • ValueError if some part of the statement cannot be executed at compile time

[View source]

3344
3345
3346
# File 'lib/idl/ast.rb', line 3344

def execute_unknown(symtab)
  symtab.get(rval.text_value).value = nil
end

#rvalObject

[View source]

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

def rval = @children[0]

#to_idlString

Return valid IDL representation of the node (and its subtree)

Returns:

  • (String)

    IDL code for the node

[View source]

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

def to_idl = "#{rval.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

Parameters:

Returns:

  • (Type)

    The type of the node

Raises:

[View source]

3322
3323
3324
# File 'lib/idl/ast.rb', line 3322

def type(symtab)
  rval.type(symtab)
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:

[View source]

3315
3316
3317
3318
3319
# File 'lib/idl/ast.rb', line 3315

def type_check(symtab)
  rval.type_check(symtab)
  var = symtab.get(rval.text_value)
  type_error "Post increment variable must be integral" unless var.type.integral?
end