2012-08-16 01:00:30 +01:00
|
|
|
#ifndef OPCODE_H
|
|
|
|
#define OPCODE_H
|
2012-08-22 19:05:53 +01:00
|
|
|
#include <assert.h>
|
|
|
|
|
2012-08-16 01:00:30 +01:00
|
|
|
typedef enum {
|
|
|
|
#define OP(name, imm, in, out) name,
|
|
|
|
#include "opcode_list.h"
|
|
|
|
#undef OP
|
|
|
|
} opcode;
|
|
|
|
|
|
|
|
enum {
|
|
|
|
NUM_OPCODES =
|
|
|
|
#define OP(name, imm, in, out) +1
|
|
|
|
#include "opcode_list.h"
|
|
|
|
#undef OP
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
OP_HAS_CONSTANT = 2,
|
|
|
|
OP_HAS_VARIABLE = 4,
|
|
|
|
OP_HAS_BRANCH = 8,
|
|
|
|
OP_HAS_SYMBOL = 16,
|
2012-08-21 12:35:36 +01:00
|
|
|
OP_HAS_CFUNC = 32,
|
|
|
|
OP_HAS_UFUNC = 64,
|
2012-08-21 18:14:13 +01:00
|
|
|
OP_IS_CALL_PSEUDO = 128,
|
|
|
|
OP_HAS_VARIABLE_LENGTH_ARGLIST = 256,
|
|
|
|
OP_HAS_BLOCK = 512,
|
|
|
|
OP_HAS_BINDING = 1024,
|
2012-08-16 01:00:30 +01:00
|
|
|
};
|
|
|
|
struct opcode_description {
|
|
|
|
opcode op;
|
|
|
|
const char* name;
|
2012-08-22 19:05:53 +01:00
|
|
|
|
2012-08-16 01:00:30 +01:00
|
|
|
int flags;
|
2012-08-22 19:05:53 +01:00
|
|
|
|
|
|
|
// length in 16-bit units
|
|
|
|
int length;
|
|
|
|
|
2012-08-16 01:00:30 +01:00
|
|
|
int stack_in, stack_out;
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct opcode_description* opcode_describe(opcode op);
|
|
|
|
|
|
|
|
static inline int opcode_length(opcode op) {
|
2012-08-22 19:05:53 +01:00
|
|
|
return opcode_describe(op)->length;
|
2012-08-16 01:00:30 +01:00
|
|
|
}
|
2012-08-22 19:05:53 +01:00
|
|
|
|
2012-08-16 01:00:30 +01:00
|
|
|
#endif
|