2 program.h - MaLa program descriptor
4 Copyright (C) 2004, Christian Thaeter <chth@gmx.net>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License version 2 as
8 published by the Free Software Foundation.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, contact me.
20 #ifndef MALA_PROGRAM_H
21 #define MALA_PROGRAM_H
24 #include "mala_types.h"
25 #include "stringlist.h"
27 struct mala_program_struct
29 MalaStringList program
; // list containing the actual program
30 MalaStringList pptr
; // points to the position *before* the next to be evaluated string
37 extern const char * mala_program_states
[];
40 mala_program_acogc_initize (void* o
);
43 mala_program_acogc_mark (void* o
);
46 mala_program_new_cstr (const char * cmd
, MalaEngine engine
);
49 mala_program_copy (MalaProgram source
);
52 mala_program_run (MalaProgram self
, mala_state dest
);
55 mala_program_eval_arg (MalaProgram self
, int n
, mala_state dest
, MalaStringList_ref dst
);
58 mala_program_exists_arg (MalaProgram self
, int n
)
60 return !!llist_get_nth_stop (&self
->pptr
->node
, n
, llist_get_prev (&self
->program
->node
));
63 static inline mala_state
64 mala_program_commonexception (MalaProgram self
, mala_common_string idx
)
66 mala_stringlist_insert_after (self
->pptr
,
67 mala_stringlist_node_new (self
->engine
->common_string
[idx
],
69 return self
->state
= MALA_EXCEPTION
;
72 static inline mala_state
73 mala_program_state_get (MalaProgram self
);
76 mala_program_step (MalaProgram self
);
79 mala_program_action_done (MalaProgram prg
, int args
);
81 static inline MalaAction
82 mala_program_pptr_action (MalaProgram self
);
90 static inline mala_state
91 mala_program_state_get (MalaProgram self
)
93 return self
? self
->state
: MALA_EINVALID
;
97 mala_program_action_done (MalaProgram prg
, int args
)
101 TODO("assert not delete over end of program");
102 mala_stringlist_remove (mala_stringlist_next (prg
->pptr
));
108 static inline MalaAction
109 mala_program_pptr_action (MalaProgram self
)
111 return mala_stringlist_next (self
->pptr
)->string
->action
;
114 #endif /*MALA_PROGRAM_H*/
118 // c-file-style: "gnu"
120 // arch-tag: 0c5dbf2d-8ae2-4e00-874d-d47c8251f709