Class: Idl::CsrWriteAst
- Includes:
- Executable
- Defined in:
- lib/idl/ast.rb
Instance Method Summary collapse
- #csr_def(symtab) ⇒ Object
-
#execute(symtab) ⇒ void
“execute” the statement by updating the variables in the symbol table.
-
#execute_unknown(symtab) ⇒ Object
nothing to do for a function call.
- #idx ⇒ Object
-
#initialize(input, interval, idx) ⇒ CsrWriteAst
constructor
A new instance of CsrWriteAst.
- #name(symtab) ⇒ Object
-
#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.
Constructor Details
#initialize(input, interval, idx) ⇒ CsrWriteAst
Returns a new instance of CsrWriteAst.
6117 6118 6119 |
# File 'lib/idl/ast.rb', line 6117 def initialize(input, interval, idx) super(input, interval, [idx]) end |
Instance Method Details
#csr_def(symtab) ⇒ Object
6133 6134 6135 6136 6137 6138 6139 6140 |
# File 'lib/idl/ast.rb', line 6133 def csr_def(symtab) if idx.is_a?(IntLiteralAst) # make sure this value is a defined CSR symtab.cfg_arch.csrs.find { |csr| csr.address == idx.text_value.to_i } else symtab.cfg_arch.csr(idx.text_value) end end |
#execute(symtab) ⇒ void
This method returns an undefined value.
“execute” the statement by updating the variables in the symbol table
6152 6153 6154 |
# File 'lib/idl/ast.rb', line 6152 def execute(symtab) value_error "CSR write" end |
#execute_unknown(symtab) ⇒ Object
nothing to do for a function call
6157 |
# File 'lib/idl/ast.rb', line 6157 def execute_unknown(symtab); end |
#idx ⇒ Object
6115 |
# File 'lib/idl/ast.rb', line 6115 def idx = @children[0] |
#name(symtab) ⇒ Object
6147 6148 6149 |
# File 'lib/idl/ast.rb', line 6147 def name(symtab) csr_def(symtab).name end |
#to_idl ⇒ String
Return valid IDL representation of the node (and its subtree)
6160 |
# File 'lib/idl/ast.rb', line 6160 def to_idl = "CSR[#{idx.text_value}]" |
#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
6143 6144 6145 |
# File 'lib/idl/ast.rb', line 6143 def type(symtab) CsrType.new(csr_def(symtab), symtab.cfg_arch) 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
6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 |
# File 'lib/idl/ast.rb', line 6122 def type_check(symtab) if idx.is_a?(IntLiteralAst) # make sure this value is a defined CSR index = symtab.cfg_arch.csrs.index { |csr| csr.address == idx.value(symtab) } type_error "No csr number '#{idx.value(symtab)}' was found" if index.nil? else csr = symtab.cfg_arch.csr(idx.text_value) type_error "No csr named '#{idx.text_value}' was found" if csr.nil? end end |