Class: Idl::PostDecrementExpressionAst

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

Overview

represents a post-decrement expression

for example:

i--

Instance Method Summary collapse

Constructor Details

#initialize(input, interval, rval) ⇒ PostDecrementExpressionAst

Returns a new instance of PostDecrementExpressionAst.



3199
3200
3201
# File 'lib/idl/ast.rb', line 3199

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



3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
# File 'lib/idl/ast.rb', line 3213

def execute(symtab)
  var = symtab.get(rval.text_value)
  value_result = value_try do
    internal_error "No symbol #{rval.text_value}" if var.nil?

    value_error "value of variable '#{rval.text_value}' not know" if var.value.nil?

    var.value = var.value - 1
  end
  value_else(value_result) do
    var.value = nil
    value_error "value of variable '#{rval.text_value}' not know"
  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



3229
3230
3231
# File 'lib/idl/ast.rb', line 3229

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

#rvalObject



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

def rval = @children[0]

#to_idlObject



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

def to_idl = "#{rval.to_idl}--"

#type(symtab) ⇒ Object



3208
3209
3210
# File 'lib/idl/ast.rb', line 3208

def type(symtab)
  rval.type(symtab)
end

#type_check(symtab) ⇒ Object



3203
3204
3205
3206
# File 'lib/idl/ast.rb', line 3203

def type_check(symtab)
  rval.type_check(symtab)
  type_error "Post decement must be integral" unless rval.type(symtab).integral?
end