Class: YTLJit::Runtime::TypedDataArena

Inherits:
Object
  • Object
show all
Defined in:
lib/ytljit/arena.rb

Instance Method Summary collapse

Constructor Details

#initialize(type, arena, origin) ⇒ TypedDataArena

Returns a new instance of TypedDataArena.



12
13
14
15
16
# File 'lib/ytljit/arena.rb', line 12

def initialize(type, arena, origin)
  @type = type
  @arena = arena
  @origin = origin
end

Instance Method Details

#[](*arg) ⇒ Object



18
19
20
# File 'lib/ytljit/arena.rb', line 18

def [](*arg)
  TypedDataArena.new(@type[*arg], @arena, @origin)
end

#addressObject



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ytljit/arena.rb', line 26

def address
  case @type
  when AsmType::Scalar, 
       AsmType::Pointer, 
       AsmType::Array, 
       AsmType::Struct
    @arena.address + @origin
    
  when AsmType::StructMember, AsmType::PointedData
    @arena.address + @origin + @type.offset

  end
end

#cast(otype) ⇒ Object



22
23
24
# File 'lib/ytljit/arena.rb', line 22

def cast(otype)
  TypedDataArena.new(otype, @arena, @origin)
end

#refObject



40
41
42
43
44
45
46
47
48
49
# File 'lib/ytljit/arena.rb', line 40

def ref
  case @type
  when AsmType::Scalar, AsmType::Pointer, AsmType::Array
    @arena[@origin]
    
  when AsmType::StructMember, AsmType::PointedData
    @arena[@origin + @type.offset / AsmType::MACHINE_WORD.size]

  end
end

#ref=(val) ⇒ Object



51
52
53
54
55
56
57
58
59
60
# File 'lib/ytljit/arena.rb', line 51

def ref=(val)
  case @type
  when AsmType::Scalar, AsmType::Pointer, AsmType::Array
    @arena[@origin] = val
    
  when AsmType::StructMember, AsmType::PointedData
    @arena[@origin + @type.offset / AsmType::MACHINE_WORD.size] = val

  end
end