1 /* op.h 2 * Copyright (C) 2001-2007, Parrot Foundation. 3 * Overview: 4 * Header file for op functions. 5 * Data Structure and Algorithms: 6 * History: 7 * Notes: 8 * References: 9 */ 10 11 #ifndef PARROT_OP_H_GUARD 12 #define PARROT_OP_H_GUARD 13 14 #include "parrot/config.h" 15 16 #define PARROT_MAX_ARGS 16 17 18 typedef enum { 19 PARROT_INLINE_OP, 20 PARROT_FUNCTION_OP 21 } op_type_t; 22 23 typedef enum { 24 PARROT_ARG_IC = PARROT_ARG_INTVAL | PARROT_ARG_CONSTANT, 25 PARROT_ARG_NC = PARROT_ARG_FLOATVAL | PARROT_ARG_CONSTANT, 26 PARROT_ARG_PC = PARROT_ARG_PMC | PARROT_ARG_CONSTANT, 27 PARROT_ARG_SC = PARROT_ARG_STRING | PARROT_ARG_CONSTANT, 28 PARROT_ARG_NAME_SC = PARROT_ARG_NAME | PARROT_ARG_STRING | PARROT_ARG_CONSTANT, 29 30 PARROT_ARG_KEYED = 0x20, 31 PARROT_ARG_KC = PARROT_ARG_PC | PARROT_ARG_KEYED, 32 PARROT_ARG_KIC = PARROT_ARG_IC | PARROT_ARG_KEYED, 33 34 PARROT_ARG_I = PARROT_ARG_INTVAL, 35 PARROT_ARG_N = PARROT_ARG_FLOATVAL, 36 PARROT_ARG_P = PARROT_ARG_PMC, 37 PARROT_ARG_S = PARROT_ARG_STRING, 38 PARROT_ARG_K = PARROT_ARG_P | PARROT_ARG_KEYED, 39 PARROT_ARG_KI = PARROT_ARG_I | PARROT_ARG_KEYED 40 } arg_type_t; 41 42 typedef enum { 43 PARROT_ARGDIR_IGNORED, 44 45 PARROT_ARGDIR_IN, 46 PARROT_ARGDIR_OUT, 47 PARROT_ARGDIR_INOUT 48 } arg_dir_t; 49 50 /* See lib/Parrot/OpsFile.pm if the names of these values change */ 51 typedef enum { 52 PARROT_JUMP_RELATIVE = 1 53 } op_jump_t; 54 55 /* NOTE: Sure wish we could put the types here... */ 56 57 typedef opcode_t *(*op_func_t)(opcode_t *, PARROT_INTERP); 58 59 60 /* 61 ** op_info_t 62 ** 63 ** Collects all the information we know about an op, except for 64 ** its op function (since we may not be using op functions). 65 */ 66 67 typedef struct op_info_t { 68 const char *name; 69 const char *full_name; 70 const char *func_name; 71 unsigned short jump; 72 short op_count; /* Includes opcode as one arg */ 73 arg_type_t types[PARROT_MAX_ARGS]; /* arg_type_t, 0 = 1st arg */ 74 arg_dir_t dirs[PARROT_MAX_ARGS]; /* arg_dir_t 0 = 1st arg */ 75 char labels[PARROT_MAX_ARGS]; /* 0/1 0 = 1st arg */ 76 struct op_lib_t *lib; 77 } op_info_t; 78 79 #define OP_INFO_OPNUM(oi) ((oi) - (oi)->lib->op_info_table) 80 #define OP_INFO_OPFUNC(oi) ((oi)->lib->op_func_table[OP_INFO_OPNUM(oi)]) 81 82 #define OPCODE_IS(interp, seg, opnum, lib, oplibnum) \ 83 ((seg)->op_func_table[(opnum)] == (lib)->op_func_table[(oplibnum)]) 84 85 #endif /* PARROT_OP_H_GUARD */ 86 87 /* 88 * Local variables: 89 * c-file-style: "parrot" 90 * End: 91 * vim: expandtab shiftwidth=4 cinoptions='\:2=2' : 92 */ 93