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.
6081 6082 6083 |
# File 'lib/idl/ast.rb', line 6081 def initialize(input, interval, idx) super(input, interval, [idx]) end |
Instance Method Details
#csr_def(symtab) ⇒ Object
6097 6098 6099 6100 6101 6102 6103 6104 |
# File 'lib/idl/ast.rb', line 6097 def csr_def(symtab) if idx.is_a?(IntLiteralAst) # make sure this value is a defined CSR symtab.archdef.csrs.find { |csr| csr.address == idx.text_value.to_i } else symtab.archdef.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
6116 6117 6118 |
# File 'lib/idl/ast.rb', line 6116 def execute(symtab) value_error "CSR write" end |
#execute_unknown(symtab) ⇒ Object
nothing to do for a function call
6121 |
# File 'lib/idl/ast.rb', line 6121 def execute_unknown(symtab); end |
#idx ⇒ Object
6079 |
# File 'lib/idl/ast.rb', line 6079 def idx = @children[0] |
#name(symtab) ⇒ Object
6111 6112 6113 |
# File 'lib/idl/ast.rb', line 6111 def name(symtab) csr_def(symtab).name end |
#to_idl ⇒ String
Return valid IDL representation of the node (and its subtree)
6124 |
# File 'lib/idl/ast.rb', line 6124 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
6107 6108 6109 |
# File 'lib/idl/ast.rb', line 6107 def type(symtab) CsrType.new(csr_def(symtab), symtab.archdef) 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
6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 |
# File 'lib/idl/ast.rb', line 6086 def type_check(symtab) if idx.is_a?(IntLiteralAst) # make sure this value is a defined CSR index = symtab.archdef.csrs.index { |csr| csr.address == idx.value(symtab) } type_error "No csr number '#{idx.value(symtab)}' was found" if index.nil? else csr = symtab.archdef.csr(idx.text_value) type_error "No csr named '#{idx.text_value}' was found" if csr.nil? end end |