Class: AsmJIT::BaseEmitter

Inherits:
Object
  • Object
show all
Defined in:
ext/asmjit/asmjit.cc

Direct Known Subclasses

X86::Assembler

Instance Method Summary collapse

Instance Method Details

#_emit(*args) ⇒ Object

[View source]

308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
# File 'ext/asmjit/asmjit.cc', line 308

VALUE base_emitter_emit(int argc, VALUE* argv, VALUE self) {
    BaseEmitterWrapper *wrapper;
    TypedData_Get_Struct(self, BaseEmitterWrapper, &base_emitter_type, wrapper);

    BaseEmitter *emitter = wrapper->emitter;

    if (argc < 1) return Qnil;
    if (argc > 7) return Qnil;

    VALUE insn_name = argv[0];
    Check_Type(insn_name, T_STRING);
    InstId inst_id = InstAPI::stringToInstId(emitter->arch(), RSTRING_PTR(insn_name), RSTRING_LEN(insn_name));

    Operand operands[6];
    for (int i = 0; i < argc - 1; i++) {
        operands[i] = parse_operand(argv[i + 1]);
    }

    emitter->emitOpArray(inst_id, &operands[0], argc - 1);

    return self;
}

#bind(labelv) ⇒ Object

[View source]

293
294
295
296
297
298
299
300
301
302
303
304
305
306
# File 'ext/asmjit/asmjit.cc', line 293

VALUE base_emitter_bind(VALUE self, VALUE labelv) {
    BaseEmitterWrapper *wrapper;
    TypedData_Get_Struct(self, BaseEmitterWrapper, &base_emitter_type, wrapper);
    BaseEmitter *emitter = wrapper->emitter;

    Label label = label_get(labelv);

    int err = emitter->bind(label);
    if (err) {
        rb_raise(rb_eAsmJITError, "error binding label");
    }

    return labelv;
}

#new_labelObject

[View source]

284
285
286
287
288
289
290
291
# File 'ext/asmjit/asmjit.cc', line 284

VALUE base_emitter_new_label(VALUE self) {
    BaseEmitterWrapper *wrapper;
    TypedData_Get_Struct(self, BaseEmitterWrapper, &base_emitter_type, wrapper);
    BaseEmitter *emitter = wrapper->emitter;

    Label label = emitter->newLabel();
    return build_label(label);
}