Class: Idl::FieldAssignmentAst
- Includes:
- Executable
- Defined in:
- lib/idl/ast.rb
Overview
represents a bitfield or struct assignement
for example:
Sv39PageTableEntry entry;
entry.PPN = 0
Instance Method Summary collapse
-
#execute(symtab) ⇒ void
“execute” the statement by updating the variables in the symbol table.
-
#execute_unknown(symtab) ⇒ void
“execute” the statement, forcing any variable assignments to an unknown state This is used down unknown conditional paths.
- #field_access ⇒ Object
-
#initialize(input, interval, field_access, write_value) ⇒ FieldAssignmentAst
constructor
A new instance of FieldAssignmentAst.
-
#to_idl ⇒ String
Return valid IDL representation of the node (and its subtree).
-
#type(symtab) ⇒ Type
Given a specific symbol table, return the type of this node.
-
#type_check(symtab) ⇒ void
type check this node and all children.
- #write_value ⇒ Object
Constructor Details
#initialize(input, interval, field_access, write_value) ⇒ FieldAssignmentAst
Returns a new instance of FieldAssignmentAst.
1962 1963 1964 |
# File 'lib/idl/ast.rb', line 1962 def initialize(input, interval, field_access, write_value) super(input, interval, [field_access, write_value]) end |
Instance Method Details
#execute(symtab) ⇒ void
This method returns an undefined value.
“execute” the statement by updating the variables in the symbol table
1984 1985 1986 1987 1988 1989 1990 1991 1992 |
# File 'lib/idl/ast.rb', line 1984 def execute(symtab) if field_access.type(symtab).kind == :struct struct_val = field_access.obj.value(symtab) struct_val[field_access.field_name] = write_value.value(symtab) symtab.add(field_access.obj.name, Var.new(field_access.obj.name, field_access.obj.type(symtab), struct_val)) else value_error "TODO: Field assignement execution" 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.
1995 1996 1997 |
# File 'lib/idl/ast.rb', line 1995 def execute_unknown(symtab) symtab.add(field_access.obj.name, Var.new(field_access.obj.name, field_access.obj.type(symtab), nil)) end |
#field_access ⇒ Object
1959 |
# File 'lib/idl/ast.rb', line 1959 def field_access = @children[0] |
#to_idl ⇒ String
Return valid IDL representation of the node (and its subtree)
2000 |
# File 'lib/idl/ast.rb', line 2000 def to_idl = "#{field_access.to_idl} = #{write_value.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
1967 1968 1969 |
# File 'lib/idl/ast.rb', line 1967 def type(symtab) field_access.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
1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 |
# File 'lib/idl/ast.rb', line 1972 def type_check(symtab) field_access.type_check(symtab) type_error "Cannot write const variable" if field_access.type(symtab).const? write_value.type_check(symtab) return if write_value.type(symtab).convertable_to?(type(symtab)) type_error "Incompatible type in assignment (#{type(symtab)}, #{write_value.type(symtab)})" end |
#write_value ⇒ Object
1960 |
# File 'lib/idl/ast.rb', line 1960 def write_value = @children[1] |