2005-05-01 11:48:36 +00:00
|
|
|
#ifndef __Instruction_h
|
|
|
|
#define __Instruction_h
|
|
|
|
#include "SchemeObject.h"
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
LABEL,
|
|
|
|
PUSH,
|
|
|
|
POP,
|
|
|
|
MAKECLOSURE,
|
|
|
|
MAKECONT,
|
|
|
|
LOADENV,
|
|
|
|
LOADLITS,
|
|
|
|
MAKEENV,
|
2005-05-08 03:44:18 +00:00
|
|
|
POPENV,
|
2005-05-01 11:48:36 +00:00
|
|
|
GET,
|
|
|
|
SET,
|
2005-05-06 23:25:06 +00:00
|
|
|
SETREST,
|
|
|
|
SETSTACK,
|
2005-05-01 11:48:36 +00:00
|
|
|
GETLINK,
|
|
|
|
GETGLOBAL,
|
2005-05-06 23:25:06 +00:00
|
|
|
SETGLOBAL,
|
2005-05-01 11:48:36 +00:00
|
|
|
CALL,
|
2005-05-06 23:25:06 +00:00
|
|
|
RETURN,
|
|
|
|
IFFALSE,
|
|
|
|
GOTO
|
2005-05-01 11:48:36 +00:00
|
|
|
} opcode_e;
|
|
|
|
|
|
|
|
struct instruction_s {
|
|
|
|
opcode_e opcode;
|
|
|
|
integer operand;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct instruction_s instruction_t;
|
|
|
|
|
|
|
|
@interface Instruction: SchemeObject
|
|
|
|
{
|
|
|
|
opcode_e opcode;
|
|
|
|
integer operand, offset;
|
|
|
|
Instruction label;
|
|
|
|
}
|
|
|
|
+ (id) opcode: (opcode_e) oc;
|
|
|
|
+ (id) opcode: (opcode_e) oc operand: (integer) op;
|
|
|
|
+ (id) opcode: (opcode_e) oc label: (Instruction) l;
|
|
|
|
- (id) initWithOpcode: (opcode_e) oc operand: (integer) op label: (Instruction) l;
|
|
|
|
- (void) offset: (integer) ofs;
|
|
|
|
- (integer) offset;
|
|
|
|
- (opcode_e) opcode;
|
|
|
|
- (void) emitStruct: (instruction_t []) program;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
#endif //__Instruction_h
|