This is an old revision of the document!
A Guide to Using ACT Data Structures
Getting Started
Initialization
Act files are read in automatically when the library is initialized as:
Act::Init(&argc, &argv);
where argc
and argv
are the usual command-line options to main()
. This should be the first function call before any other ACT functions are used.
When this call is executed, the file provided in the command-line is read in and processed to create the internal act data structures.
Typically, the next step is to create an Act
pointer to the data structure:
Act *a; a = new Act (argv[1]);
Referencing a process
Once the act pointer has been created, a process (provided in the command-line arguments) within the file can be accessed and expanded:
Process *p = a->findProcess (argv[2]); p = p->Expand (ActNamespace::Global(), p->CurScope(), 0, NULL);
Referencing the languages body
The languages body can be accessed from the process pointer:
act_languages *lang; lang = p->getlang();
Referencing a particular language body
A language body can be accessed from the languages pointer. For example, for the chp body:
act_chp *chp; chp = lang->getchp();
Finally, to get a pointer to the actual object that stores the chp data structure:
act_chp_lang_t *chp_lang; chp_lang = chp->c;
The CHP data structure
The act_chp_lang_t
object is an object of the act_chp_lang
structure (definition in lang.h
). It contains an integer type
, which says what type of ACT_CHP
token it is. Two other members label
and space
are typically NULL
. The final member u
is an object that contains the actual CHP statement. For example, any given u
can be a loop, doloop, assignment statement, communication action, etc. Each of these have their own structure and the object is a union
of these. One of the possibilities: a comma or semicolon separated list of statements is stored as a list_t
linked list semi_comma.cmd
.
The statement list data structure
The linked list list_t
contains elements of type list_item_t
. See list.h
or list.c
for details. This is used to store lists of statements. To get the actual statement stored in the list of statements, call list_value
on the required listitem_t
of the list:
act_chp_lang_t *c; // contains the overall chp body act_chp_lang_t *stmt; list_t *stmt_list; listitem_t *li; stmt_list = c->u.semi_comma.cmd; // returns the linked list for (li = list_first (stmt_list); li; li = list_next (li)) { stmt = (act_chp_lang_t *)(list_value(li)); // do something here }