Class: Idl::BuiltinVariableAst

Inherits:
AstNode
  • Object
show all
Defined in:
lib/idl/ast.rb

Instance Method Summary collapse

Constructor Details

#initialize(input, interval) ⇒ BuiltinVariableAst

Returns a new instance of BuiltinVariableAst.



3265
3266
3267
# File 'lib/idl/ast.rb', line 3265

def initialize(input, interval)
  super(input, interval, EMPTY_ARRAY)
end

Instance Method Details

#nameObject



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

def name = text_value

#to_idlObject



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

def to_idl = name

#type(symtab) ⇒ Object



3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
# File 'lib/idl/ast.rb', line 3273

def type(symtab)
  case name
  when "$encoding"
    sz = symtab.get("__instruction_encoding_size")
    internal_error "Forgot to set __instruction_encoding_size" if sz.nil?
    Type.new(:bits, width: sz.value, qualifiers: [:const])
  when "$pc"
    if symtab.mxlen == 32
      Bits32Type
    else
      Bits64Type
    end
  end
end

#type_check(symtab) ⇒ Object



3269
3270
3271
# File 'lib/idl/ast.rb', line 3269

def type_check(symtab)
  type_error "Not a builtin variable" unless ["$pc", "$encoding"].include?(name)
end

#value(symtab) ⇒ Object



3288
3289
3290
# File 'lib/idl/ast.rb', line 3288

def value(symtab)
  value_error "Cannot know the value of pc or encoding"
end