Class: Idl::BitfieldFieldDefinitionAst
- Defined in:
- lib/idl/ast.rb
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
The field name.
Instance Method Summary collapse
-
#initialize(input, interval, name, msb, lsb) ⇒ BitfieldFieldDefinitionAst
constructor
A new instance of BitfieldFieldDefinitionAst.
-
#range(symtab) ⇒ Object
Range The field’s location in the bitfield.
- #to_idl ⇒ Object
-
#type_check(symtab) ⇒ void
type check this node and all children.
Constructor Details
#initialize(input, interval, name, msb, lsb) ⇒ BitfieldFieldDefinitionAst
Returns a new instance of BitfieldFieldDefinitionAst.
1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 |
# File 'lib/idl/ast.rb', line 1168 def initialize(input, interval, name, msb, lsb) if lsb.nil? super(input, interval, [msb]) else super(input, interval, [msb, lsb]) end @name = name @lsb = lsb @msb = msb end |
Instance Attribute Details
#name ⇒ String (readonly)
Returns The field name.
1166 1167 1168 |
# File 'lib/idl/ast.rb', line 1166 def name @name end |
Instance Method Details
#range(symtab) ⇒ Object
Returns Range The field’s location in the bitfield.
1203 1204 1205 1206 1207 1208 1209 |
# File 'lib/idl/ast.rb', line 1203 def range(symtab) if @lsb.nil? @msb.value(symtab)..@msb.value(symtab) else @lsb.value(symtab)..@msb.value(symtab) end end |
#to_idl ⇒ Object
1211 1212 1213 1214 1215 1216 1217 |
# File 'lib/idl/ast.rb', line 1211 def to_idl if @lsb.nil? "#{@name} #{@msb.to_idl}" else "#{@name} #{@msb.to_idl}-#{@lsb.to_idl}" end 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
1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 |
# File 'lib/idl/ast.rb', line 1181 def type_check(symtab) @msb.type_check(symtab) value_result = value_try do @msb.value(symtab) end value_else(value_result) do @msb.type_error "Bitfield position must be compile-time-known" end return if @lsb.nil? @lsb.type_check(symtab) value_result = value_try do @lsb.value(symtab) end value_else(value_result) do @lsb.type_error "Bitfield position must be compile-time-known" end end |