1 /* private stuff for gretl CMD structure */ 2 3 #ifndef CMD_PRIVATE_H 4 #define CMD_PRIVATE_H 5 6 #include "gretl_restrict.h" 7 #include "gretl_func.h" 8 9 typedef enum { 10 CMD_IGNORE = 1 << 0, /* line should be ignored */ 11 CMD_SUBST = 1 << 1, /* string substitution has been done on command */ 12 CMD_PROG = 1 << 2, /* command is in context of progressive loop */ 13 CMD_CATCH = 1 << 3, /* error from command should be "caught" */ 14 CMD_NOSUB = 1 << 4, /* no @-substitution called for (pre-checked) */ 15 CMD_ENDFUN = 1 << 5 /* line terminates a function definition */ 16 } CmdFlags; 17 18 #define cmd_ignore(c) (c->flags & CMD_IGNORE) 19 #define cmd_subst(c) (c->flags & CMD_SUBST) 20 #define cmd_nosub(c) (c->flags & CMD_NOSUB) 21 22 typedef struct cmd_token_ cmd_token; 23 24 struct CMD_ { 25 int ci; /* current command index */ 26 int err; /* error code */ 27 int context; /* for block commands, index of current context */ 28 int ciflags; /* see CIFlags in tokenizer.c */ 29 gretlopt opt; /* option(s) for command */ 30 CmdFlags flags; /* status flags for command invocation */ 31 GretlType gtype; /* specified type for "genr" */ 32 int order; /* lag order, where appropriate */ 33 int auxint; /* auxiliary int (e.g. VECM rank) */ 34 int cstart; /* token index of start of 'real' command */ 35 int ntoks; /* number of tokens actually used */ 36 int nt_alloced; /* number of tokens allocated */ 37 cmd_token *toks; /* tokens */ 38 const char *vstart; /* pointer to where in line varargs or expr start */ 39 char *param; /* basic parameter string */ 40 char *parm2; /* second parameter string */ 41 int *list; /* list of series and/or control integers */ 42 int *auxlist; /* needed for "gappy" lag lists */ 43 char savename[MAXSAVENAME]; /* for object-saving mechanism */ 44 }; 45 46 typedef int (*EXEC_CALLBACK) (ExecState *, void *, GretlObjType type); 47 48 struct ExecState_ { 49 ExecFlags flags; 50 CMD *cmd; 51 PRN *prn; 52 char *line; 53 char *more; 54 char runfile[MAXLEN]; 55 MODEL *model; /* "workspace" model */ 56 MODEL *pmod; /* set if new model is estimated */ 57 equation_system *sys; 58 gretl_restriction *rset; 59 GRETL_VAR *var; 60 void *prev_model; 61 GretlObjType prev_type; 62 int prev_model_count; 63 char *submask; /* record of incoming sub-sample for functions */ 64 int padded; /* record of incoming panel padding, if any */ 65 int in_comment; 66 EXEC_CALLBACK callback; 67 }; 68 69 struct OpenOp_ { 70 char fname[MAXLEN]; 71 int quiet; 72 int http; 73 int dbdata; 74 int ftype; 75 }; 76 77 typedef struct OpenOp_ OpenOp; 78 79 void gretl_exec_state_init (ExecState *s, 80 ExecFlags flags, 81 char *line, 82 CMD *cmd, 83 MODEL *model, 84 PRN *prn); 85 86 void function_state_init (CMD *cmd, ExecState *state, int *indent0); 87 88 void gretl_exec_state_set_callback (ExecState *s, EXEC_CALLBACK callback, 89 gretlopt opt); 90 91 EXEC_CALLBACK get_gui_callback (void); 92 93 void set_gui_callback (EXEC_CALLBACK callback); 94 95 void gretl_exec_state_clear (ExecState *s); 96 97 void gretl_exec_state_destroy (ExecState *s); 98 99 void gretl_exec_state_uncomment (ExecState *s); 100 101 void gretl_exec_state_transcribe_flags (ExecState *s, CMD *cmd); 102 103 void gretl_exec_state_set_model (ExecState *s, MODEL *pmod); 104 105 int process_command_error (ExecState *s, int err); 106 107 int maybe_exec_line (ExecState *s, DATASET *dset, int *loopstart); 108 109 int plausible_genr_start (const char *s, const DATASET *dset); 110 111 #endif /* CMD_PRIVATE_H */ 112