Class: YTLJit::Runtime::Arena

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeArena

Returns a new instance of Arena.



4
5
6
# File 'lib/ytljit/arena.rb', line 4

def initialize
  @using = 0
end

Instance Attribute Details

#usingObject

Returns the value of attribute using.



8
9
10
# File 'lib/ytljit/arena.rb', line 8

def using
  @using
end

Instance Method Details

#[](offset) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'ext/memory.c', line 21

VALUE
ytl_arena_ref(VALUE self, VALUE offset)
{
  struct Arena *raw_arena;
  int raw_offset;

  raw_arena = (struct Arena *)DATA_PTR(self);
  raw_offset = FIX2INT(offset);

  return ULONG2NUM(raw_arena->body[raw_offset]);
}

#[]=(offset, src) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'ext/memory.c', line 33

VALUE
ytl_arena_emit(VALUE self, VALUE offset, VALUE src)
{
  struct Arena *raw_arena;

  int raw_offset;

  raw_arena = (struct Arena *)DATA_PTR(self);
  raw_offset = NUM2ULONG(offset);

  raw_arena->body[raw_offset] = FIX2INT(src);

  return src;
}

#addressObject



60
61
62
63
64
65
66
67
68
# File 'ext/memory.c', line 60

VALUE
ytl_arena_address(VALUE self)
{
  struct Arena *raw_arena;

  raw_arena = (struct Arena *)DATA_PTR(self);

  return ULONG2NUM((uintptr_t)raw_arena->body);
}

#sizeObject



48
49
50
51
52
53
54
55
56
57
58
# File 'ext/memory.c', line 48

VALUE
ytl_arena_size(VALUE self)
{
  struct Arena *raw_arena;

  int raw_offset;

  raw_arena = (struct Arena *)DATA_PTR(self);

  return INT2FIX(raw_arena->size);
}

#to_sObject



71
72
73
74
75
76
77
78
79
80
81
82
# File 'ext/memory.c', line 71

VALUE
ytl_arena_to_s(VALUE self)
{
  struct Arena *raw_arena;

  raw_arena = (struct Arena *)DATA_PTR(self);

  return rb_sprintf("#<Arena %p size=%d body=%p>", 
		    (void *)self, 
		    raw_arena->size,
		    (void *)raw_arena->body);
}