view src/ploki/op.h @ 9574:031e330a96b3

<hppavilion[1]> le/rn theseus/Theseus was a Greek inventor who was charged with impossible-to-detect murder. He was represented by Protagoras and found not guilty. He changed his name to escape the publicity and has continued inventing to this day.
author HackBot
date Mon, 31 Oct 2016 01:10:06 +0000
parents ac0403686959
children
line wrap: on
line source

#ifndef OP_H_
#define OP_H_

#include "IO.h"
#include "Str.h"
#include "expr.h"

#include <stddef.h>

enum t_op {
	OP_NOP,
	OP_ASSIGN,
	OP_CALL,
	OP_CALL_BACK,
	OP_CALL_DYN,
	OP_CLOSE,
	OP_ELSE,
	OP_EXIT,
	OP_FI,
	OP_FLUSH,
	OP_GOBACK,
	OP_GOTO,
	OP_HANG,
	OP_IF,
	OP_MODIFY,
	OP_PRINT,
	OP_PUTC,
	OP_RESET,
	OP_RETURN,
	OP_SET_VAL,
	OP_SYSTEM,
	OP_TEMP,
	OP_THROW
};

struct op {
	enum t_op type;
	struct expr *arg;
	union {
		struct expr *expr;
		struct op *op;
	} arh;
	struct op *next;
	String txt;
	size_t line;
};

void op_init(struct op *);
void op_end(struct op *);
void op_getop(struct op *);

#define OP_1ARG_P(op)                                             \
(                                                                 \
 (op) == OP_CALL   || (op) == OP_CALL_DYN || (op) == OP_CLOSE  || \
 (op) == OP_EXIT   || (op) == OP_FLUSH    || (op) == OP_GOTO   || \
 (op) == OP_IF     || (op) == OP_RESET    || (op) == OP_RETURN || \
 (op) == OP_SYSTEM || (op) == OP_THROW                            \
)

#define OP_2ARG_P(op)                                               \
(                                                                   \
 (op) == OP_ASSIGN || (op) == OP_CALL_BACK || (op) == OP_MODIFY  || \
 (op) == OP_PRINT  || (op) == OP_PUTC      || (op) == OP_SET_VAL || \
 (op) == OP_TEMP                                                    \
)

#endif /* OP_H_ */