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.



3218
3219
3220
# File 'lib/idl/ast.rb', line 3218

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



3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
# File 'lib/idl/ast.rb', line 3232

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



3248
3249
3250
# File 'lib/idl/ast.rb', line 3248

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

#rvalObject



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

def rval = @children[0]

#to_idlObject



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

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

#type(symtab) ⇒ Object



3227
3228
3229
# File 'lib/idl/ast.rb', line 3227

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

#type_check(symtab) ⇒ Object



3222
3223
3224
3225
# File 'lib/idl/ast.rb', line 3222

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