2 action.c - MaLa actions implementation
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.
22 #include "mala_types.h"
24 #include "stringlist.h"
31 mala_action_acogc_initize (void* o
)
33 MalaAction self
= (MalaAction
)o
;
35 llist_init (&self
->childs
);
36 llist_init (&self
->cldnode
);
37 llist_init (&self
->stknode
);
39 self
->data_alloc_type
= ACOGC_UNSET
;
43 mala_action_acogc_finalize (void* o
)
45 MalaAction self
= (MalaAction
)o
;
46 llist_unlink (&self
->childs
);
47 llist_unlink (&self
->cldnode
);
48 llist_unlink (&self
->stknode
);
49 if (self
->data_alloc_type
== ACOGC_ALLOC
)
54 mala_action_acogc_mark (void* o
)
56 MalaAction self
= (MalaAction
)o
;
58 TODO("profile marking order maybe lastmark name instead of program");
60 TODO("iterative marker");
61 LLIST_FOREACH (&self
->childs
, node
)
62 acogc_object_mark (LLIST_TO_STRUCTP (node
, mala_action
, cldnode
));
64 LLIST_FOREACH (&self
->stknode
, node
)
65 acogc_object_mark (LLIST_TO_STRUCTP (node
, mala_action
, stknode
));
67 if (self
->data_alloc_type
== ACOGC_GC
)
68 acogc_object_mark (self
->data
);
70 acogc_object_lastmark (self
->name
);
76 mala_action_new (MalaString name
,
77 MalaParserFunc parser
,
79 acogc_alloc_type data_alloc
,
82 MalaAction self
= acogc_factory_alloc (&engine
->gcfactory_actions
);
85 self
->parser
= parser
;
87 self
->data_alloc_type
= data_alloc
;
88 llist_init (&self
->childs
);
91 mala_action_attach (self
, name
);
97 mala_action_attach (MalaAction self
, MalaString name
)
102 llist_insert_after (&self
->stknode
, &name
->action
->stknode
);
107 assert (name
->user_alloc_type
== ACOGC_UNSET
);
108 name
->user_alloc_type
= ACOGC_GC
;
114 mala_action_new_actioninit (MalaActionInit init
, MalaEngine engine
)
116 ACOGC_STACK_ENTER (&engine
->gcroot
);
117 ACOGC_STACK_PTR (MalaString
, name
);
118 ACOGC_STACK_PTR (MalaAction
, self
);
120 name
.ptr
= mala_string_new_cstr (init
->name
, engine
->words
);
122 self
.ptr
= mala_action_new (name
.ptr
, init
->parser
, NULL
, ACOGC_UNSET
, engine
);
126 case MALA_DATA_STRINGLIST
:
127 self
.ptr
->list
= mala_stringlist_new (engine
);
128 self
.ptr
->data_alloc_type
= ACOGC_GC
;
129 mala_stringlist_append_literal_cstrs (self
.ptr
->list
, -1, init
->data
, engine
);
131 case MALA_DATA_STRINGPOINTER
:
132 self
.ptr
->string
= mala_string_new_literal_cstr (init
->data
, engine
->words
);
133 self
.ptr
->data_alloc_type
= ACOGC_GC
;
135 //case MALA_DATA_UNUSED:
137 self
.ptr
->data
= init
->data
;
138 self
.ptr
->data_alloc_type
= init
->data
? ACOGC_STATIC
: ACOGC_UNSET
;
144 MalaString str
= mala_stringbucket_find (engine
->words
, init
->parent
);
146 mala_action_attach_child (str
->action
, self
.ptr
);
148 mala_action_attach_child (engine
->common_string
[MALA_STRING_WORLD
]->action
, self
.ptr
);
157 // c-file-style: "gnu"
159 // arch-tag: 5b3b4c3c-09f4-4f2e-a737-1ea6c5df59e9