quakeforge/ruamoko/scheme/Instruction.r

60 lines
1,023 B
R
Raw Normal View History

#include "Instruction.h"
#include "defs.h"
@implementation Instruction
+ (id) opcode: (opcode_e) oc
{
2011-01-14 03:07:40 +00:00
return [[self alloc] initWithOpcode: oc operand: 0 label: nil];
}
+ (id) opcode: (opcode_e) oc operand: (integer) op
{
2011-01-14 03:07:40 +00:00
return [[self alloc] initWithOpcode: oc operand: op label: nil];
}
2011-02-14 13:39:43 +00:00
+ (id) opcode: (opcode_e) oc label: (Instruction *) l
{
return [[self alloc] initWithOpcode: oc operand: 0 label: l];
}
2011-02-14 13:39:43 +00:00
- (id) initWithOpcode: (opcode_e) oc operand: (integer) op label: (Instruction *) l
{
self = [super init];
opcode = oc;
operand = op;
label = l;
return self;
}
- (void) offset: (integer) ofs
{
offset = ofs;
}
- (integer) offset
{
return offset;
}
- (opcode_e) opcode
{
return opcode;
}
2011-02-14 13:39:43 +00:00
- (void) emitStruct: (instruction_t *) program
{
program[offset].opcode = opcode;
if (label) {
program[offset].operand = [label offset];
} else {
program[offset].operand = operand;
}
}
- (void) markReachable
{
[label mark];
}
@end