Reorganized file structure
authorRobert Brunner <rbrunner@uiuc.edu>
Mon, 5 Jun 1995 18:52:05 +0000 (18:52 +0000)
committerRobert Brunner <rbrunner@uiuc.edu>
Mon, 5 Jun 1995 18:52:05 +0000 (18:52 +0000)
12 files changed:
src/xlat/xl-Decisions.doc [new file with mode: 0755]
src/xlat/xl-dag.c [new file with mode: 0644]
src/xlat/xl-lex.c [new file with mode: 0644]
src/xlat/xl-lex.h [new file with mode: 0644]
src/xlat/xl-main.c [new file with mode: 0644]
src/xlat/xl-outh.c [new file with mode: 0644]
src/xlat/xl-parse.c [new file with mode: 0644]
src/xlat/xl-rdtok.c [new file with mode: 0644]
src/xlat/xl-srch.c [new file with mode: 0644]
src/xlat/xl-str.c [new file with mode: 0644]
src/xlat/xl-sym.c [new file with mode: 0644]
src/xlat/xl-sym.h [new file with mode: 0644]

diff --git a/src/xlat/xl-Decisions.doc b/src/xlat/xl-Decisions.doc
new file mode 100755 (executable)
index 0000000..b83e2b6
--- /dev/null
@@ -0,0 +1,76 @@
+
+July 10, 1991
+
+1. The enumerated form of the sizes array for CkAllocMsg & CkAllocPrioMsg :
+   The enumeration should be complete - that is, the number of parameters
+   supplied must match the number of varSize fields in the message.
+
+2. Syntax for varSize :
+
+   <varSize-field> ::= <Type-Identifier> <Identifier> [ varSize ] ;
+                           ||
+   * Change * ===============
+
+3. packIDs : M4 will insert _CK_9_EPtoPackID[<EP]
+   wherever packID is needed. <EP> is the appropriate entry-point argument.
+   
+   _CK_9_EPtoPackID is a table that maps entrypoints to packIDs of the message
+   expected at that  entry point.
+
+   _CK_9_PackFunctionTable and _CK_9_UnPackFunctionTable will be appropriately
+   set.
+
+   Following the above "naming," the global function table  (for public and
+   module level functions)  will be called _CK_9_GlobalFunctionTable.
+
+-----
+
+July 11, 1991
+
+4.  There is an EPtoMessageNumber Table. There is a PackFunction table.
+    There is a count MessagePackCount which represents the number of messages
+    that have pack functions. (MessagePackCount is a run-time variable). Another
+    variable, TotalMessages, gives the number of total msgs. PackOffset
+    denotes TotalMessages-MessagePackCount.
+
+    Message Number for a message is in the range 
+    1..PackOffset if the message has no pack function 
+    else the Message Number is greater than PackOffset.
+
+    The run-time system compares the message number (obtained from the EPtoMsg#
+    table) with MessagePackCount and indexes the PackFunction table with
+    index = messagenumber - PackOffset - 1 iff message number > PackOffset.
+
+    If MessageNumber<=PackOffset, there is no valid packID. Message Number 0 
+    also implies that the corresponding entry point takes NO message. 
+    The "no message" bit is discussed below.
+
+5.  An EP that takes no message looks like
+    entry <identifier>  : ( ) { <body> }
+  
+    [This goes for DataInit,ChareInit and QUIESCENCE.]
+
+    The translator inserts a dummy pointer and a dummy free statement. This
+    should work. The user provides NULL instead of msgptr, the run time 
+    system passes the envelope which is freed just before leaving the entry
+    point.
+
+    Since the current system sends nothing to the DataInit,ChareInit, and
+    QUIESCENCE, I shall translate them so as not to expect any envelope.
+
+6.  Note that the single EPtoPackID table consists of two types of
+    entry-points : Chare EP points, with indices in the range
+    0 ..  ChareEPCount-1, and Branch EP points, with indices in the
+    range ChareEPCount .. ChareEPCount+BranchEPCount-1.
+
+    The  indices for the  Chare EP points are in the range
+    0 .. ChareEPCount-1, while those for the BranchEP points are
+    in the range 0 .. BranchEPCount - 1. As a result, when a branch
+    EP is encountered, to obtain the proper index in the EPtoPackId
+    table, the branch EP index should be added ChareEPCount (available
+    as a global variable) : This has to be done at run time, for each
+    call involving a branch EP.
+
+    [ This was from Wednesday's discussion.]
+
+-----
diff --git a/src/xlat/xl-dag.c b/src/xlat/xl-dag.c
new file mode 100644 (file)
index 0000000..a8adc70
--- /dev/null
@@ -0,0 +1,1379 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-05 18:52:05  brunner
+ * Reorganized file structure
+ *
+ * Revision 1.2  1995/05/04  21:26:44  milind
+ * *** empty log message ***
+ *
+ * Revision 1.1  1994/11/03  17:41:33  brunner
+ * Initial revision
+ *
+ * Revision 1.1  1994/11/03  17:41:33  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+static char ident[] = "@(#)$Header$";
+#include <stdio.h>
+extern int InPass1;
+extern char *CkLocalPtr;
+extern char *DataSuffix;
+extern char *AssignMyDataPtr;
+extern char *CkMyData;
+char *Map();
+int  writeoutput(),WriteReturn();
+
+static reverse_elist();
+static reverse_clist();
+static init_code();
+static entry_header_code();
+static declare_lptr();
+static assign_lptr();
+static emit_expect_code();
+static fill_charenum();
+/* static emit_epconv(); */
+
+#define PRINT_BUFFER 256
+
+/* defined in dagger.h and dag.h also */
+#define _dag3_WLIMIT 8 
+/* define in dagger.h also */ 
+#define DAG_NOREF   0
+
+#define NULL 0
+#define TRUE 1
+#define FALSE 0
+#define NOFREE 0
+#define EXIT 1
+
+#define MATCH    1
+#define MULTIPLE 2
+#define ANY      4
+#define AUTOFREE 8
+
+#define IS_MULTIPLE(eptr)      (eptr->etype & MULTIPLE)
+#define IS_MATCHING(eptr)      (eptr->etype & MATCH)
+#define IS_MATCHING_WHEN(wptr) (wptr->wtype & MATCH)
+#define IS_ANY(wptr)           (wptr->wtype & ANY)
+
+struct S_DLIST {  /* list of dag chares */
+    struct S_ELIST *e_list;
+    struct S_WLIST *w_list;
+    struct S_CLIST *c_list;
+    int   numofwhen;
+    int   numofentry;
+    int   is_a_chare;
+    char  *charename;
+    struct S_DLIST *next;
+};
+
+struct S_ELIST {  /* list of entry points */
+    char  *name;
+    char  *msgname;
+    char  *varname;
+    char  *msgtype;
+    int   eno;
+    int   etype;            /* MATCH/NONMATCH,MULTIPLE/ORDINARY */
+    int   numofwhen;
+    struct S_EWLIST *wlist;
+    struct S_ELIST *next;
+};
+
+/* list of when nodes that contains the enrypoint */
+struct S_EWLIST {
+    int             position; 
+    struct S_WLIST  *wnode;
+    struct S_EWLIST *next;
+};
+
+/* list of when blocks */
+struct S_WLIST {
+    int      wno;
+    int      wtype;           /* ANY,MATCHING,OTHER */
+    int      count;
+    int      position_count;
+    struct S_WCONDLIST *clist;
+    struct S_WLIST    *next;
+};
+
+
+/* list of conditions in the when  block */
+struct S_WCONDLIST {
+    int      position;
+    int      isentry;               /*  ENTRY/CONDITIONVAR */
+    void     *eptr;
+    struct S_WCONDLIST *next;
+}; 
+
+/* list of condition variables */
+struct S_CLIST {
+    char     *name;
+    int      cno;
+    struct S_EWLIST *wlist;
+    struct S_CLIST *next;
+};
+
+
+typedef struct S_DLIST DLIST;
+typedef struct S_ELIST ELIST;
+typedef struct S_WLIST WLIST;
+typedef struct S_CLIST CLIST;
+typedef struct S_EWLIST EWLIST;
+typedef struct S_WCONDLIST WCONDLIST;
+
+
+
+ELIST *is_entry();
+CLIST *insert_cond();
+
+
+char *wcounter="_dag3_wcounter";
+char *wcount="_dag3_wcount";
+char *etype="_dag3_etype";
+char *epbuffer="_dag3_ep_buffer";
+char *rl="_dag3_rl";
+char *current_refnum = "_dag3_myrefnum";
+char *condvar_fptr = "_dag3_cv_fptr";
+char *efunc_fptr   = "_dag3_epf_fptr";
+char *wswitch_fptr = "_dag3_wswitch_fptr";
+char *ischare      = "_dag3_ischare";
+char *activator    = "_dag3_activator";
+char *penum        = "_dag3_penum";
+char *cid          = "_dag3_cid";
+char *epconv       = "_dag3_epconv";
+char *flist        = "_dag3_flist";
+#ifdef STRACE
+char *mw_fptr       = "_dag3_mw_fptr";
+#endif
+static char modulename[256];
+static char *charenum,trace_charename[512];
+
+DLIST *d_list_head,*d_list_tail;
+ELIST *e_list;
+WLIST *w_list_head, *w_list_tail;
+CLIST *c_list; 
+DLIST *current_dag;
+WLIST *current_when;
+int   current_wno,current_eno,current_cno;
+char  temp[PRINT_BUFFER];
+char  base_name[PRINT_BUFFER];
+ELIST *savedeptr;
+int   first_cond_flag;
+
+_dag_init(mname)
+char *mname;
+{
+      if (!InPass1) return;
+      d_list_head = d_list_tail = NULL;
+      strcpy(modulename,mname);
+}
+
+
+_dag_begindag(charename,is_a_chare)
+char *charename;
+int is_a_chare;
+{  
+      DLIST *dag;
+
+      if (!InPass1) return;
+
+      dag       = (DLIST *)malloc(sizeof(DLIST));
+      dag->next = NULL;
+      dag->charename = (char *)malloc(strlen(charename)+1);
+      strcpy(dag->charename,charename);
+      if (d_list_head == NULL) 
+         d_list_head = d_list_tail = dag;
+      else {
+         d_list_tail->next = dag;
+         d_list_tail = dag;
+      }
+      e_list      = (ELIST *) NULL;
+      w_list_head = w_list_tail = (WLIST *) NULL;
+      c_list      = (CLIST *) NULL;
+      current_wno = current_eno = current_cno = 0;
+      dag->numofwhen = dag->numofentry = 0;
+      dag->is_a_chare = is_a_chare;
+}
+
+_dag_enddag()
+{
+      if (!InPass1) return;
+      d_list_tail->e_list = e_list;
+      d_list_tail->c_list = c_list;
+      d_list_tail->w_list = w_list_head;
+      d_list_tail->numofentry= current_eno;
+      d_list_tail->numofwhen = current_wno;
+}
+
+_dag_newentry(name)
+char *name;
+{
+     ELIST *new_entry;
+     int   size;
+
+     if (!InPass1) return;
+     new_entry       = (ELIST *)malloc(sizeof(ELIST));
+     new_entry->next = e_list;
+     e_list          = new_entry;
+     size            = strlen(name)+1;
+     e_list->name    = (char *)malloc(strlen(name)+1);
+     strcpy(e_list->name,name);
+     e_list->wlist   = NULL;
+     e_list->eno     = current_eno++;
+     e_list->etype   = NULL;
+     e_list->wlist   = (EWLIST *) NULL;
+     e_list->numofwhen = 0;
+     if (e_list->eno == 0) sprintf(base_name,"%s",name);
+}
+
+_dag_entrytype(varname)
+char *varname;
+{
+     int size;
+
+     if (!InPass1) return;
+     if (varname != NULL) {
+         size = strlen(varname) + 1;
+         e_list->varname = (char*) malloc(size);
+         strcpy(e_list->varname,varname); 
+         e_list->etype |= MULTIPLE;
+        }
+     else 
+        e_list->varname = NULL; 
+}
+
+      
+
+_dag_entrymsg(msgtype,msgname)
+char *msgtype,*msgname;
+{    int size;
+     if (!InPass1) return;
+     size            = strlen(msgname)+1;
+     e_list->msgname = (char *)malloc(size);
+     strcpy(e_list->msgname,msgname);
+     size            = strlen(msgtype) + 1;
+     e_list->msgtype = (char *)malloc(size);
+     strcpy(e_list->msgtype,msgtype);
+}
+
+
+_dag_entry_match(flag)
+int flag;
+{ 
+    if (!InPass1) return;
+    if (flag) e_list->etype |= MATCH; 
+}
+
+_dag_entry_free(flag)
+{
+    if (!InPass1) return;
+    if (flag) e_list->etype |= AUTOFREE;
+}
+
+_dag_newwhen()
+{
+     WLIST *new_when; 
+     if (!InPass1) return;
+     new_when = (WLIST *) malloc(sizeof(WLIST));
+     if (w_list_head == NULL) 
+        w_list_head = w_list_tail = new_when;
+     else {
+        w_list_tail->next =  new_when;
+        w_list_tail = new_when;
+     } 
+     new_when->clist = NULL;
+     new_when->position_count = 0;
+     new_when->wno   = current_wno++;
+     new_when->wtype = NULL;
+     new_when->count = 0;
+     first_cond_flag = TRUE;
+}    
+
+
+
+
+_dag_when_cond(condname)
+char *condname;
+{
+     WCONDLIST *cond;
+     ELIST *eptr;
+     CLIST *cptr;
+     EWLIST *temp2;
+
+     if (!InPass1) return;
+
+     cond = (WCONDLIST *) malloc(sizeof(WCONDLIST));
+     cond->next = w_list_tail->clist;
+     w_list_tail->clist = cond;
+     w_list_tail->count++;
+     if (eptr = is_entry(condname)) {
+        cond->isentry = TRUE;
+        cond->eptr  = (void *) eptr;
+        cond->position = w_list_tail->position_count++;
+        temp2 = (EWLIST *) malloc(sizeof(EWLIST));
+        temp2->next = eptr->wlist;
+        temp2->wnode= w_list_tail;
+        temp2->position = cond->position;
+        eptr->wlist = temp2;
+        if ( !IS_ANY(w_list_tail) )  eptr->numofwhen++;
+        if ( IS_MATCHING(eptr) ) {
+           if (first_cond_flag)
+              w_list_tail->wtype |= MATCH;
+           else if ( !IS_MATCHING_WHEN(w_list_tail) )
+              printf("dag:error : mixed entry points\n"); 
+          }
+        if (first_cond_flag) first_cond_flag = FALSE;
+        }
+     else {
+        cond->isentry = FALSE;
+        cptr = insert_cond(condname);
+        cond->eptr = (void *) cptr;
+        temp2 = (EWLIST *) malloc(sizeof(EWLIST));
+        temp2->next = cptr->wlist;
+        temp2->wnode= w_list_tail;
+        cptr->wlist = temp2;
+     }
+}
+
+
+_dag_when_any(any)
+int any;
+{
+     if (!InPass1) return;
+     if (any) w_list_tail->wtype |= ANY;
+} 
+
+
+
+_dag2_begindag()
+{
+    /* set the current dag chare */
+    if (InPass1) return;
+    current_dag = d_list_head;
+    current_when = NULL;
+    if (current_dag == NULL) {
+       error("dag: error\n",EXIT);
+    }
+    d_list_head = d_list_head->next;
+    reverse_elist();
+    reverse_clist();
+    fill_charenum(current_dag->charename);
+#ifdef STRACE
+    write_depn();
+#endif
+}
+
+
+
+
+_dag2_decl()
+{
+
+    if (InPass1) return;
+
+    /* declare control data */
+    sprintf(temp,"int %s[%d];",etype,current_dag->numofentry);
+    writeoutput(temp,NOFREE);
+    sprintf(temp,"_dag3_BUFFER *%s[%d];",epbuffer,current_dag->numofentry);
+    writeoutput(temp,NOFREE); WriteReturn();
+    sprintf(temp,"int %s[%d];",epconv,current_dag->numofentry);
+    writeoutput(temp,NOFREE); WriteReturn();
+    sprintf(temp,"int %s[%d];",wcount,current_dag->numofwhen);
+    writeoutput(temp,NOFREE);
+    sprintf(temp,"_dag3_COUNT *%s[%d];",wcounter,current_dag->numofwhen);
+    writeoutput(temp,NOFREE); WriteReturn();
+    sprintf(temp,"_dag3_RL %s;",rl);
+    writeoutput(temp,NOFREE);  WriteReturn();
+    sprintf(temp,"int %s;",current_refnum);
+    writeoutput(temp,NOFREE);  WriteReturn();
+    sprintf(temp,"int (*%s)(),(*%s)(), (*%s)();",
+            condvar_fptr,efunc_fptr,wswitch_fptr);
+    writeoutput(temp,NOFREE); WriteReturn(); 
+#ifdef STRACE
+    sprintf(temp,"int (*%s)();",mw_fptr);
+    writeoutput(temp,NOFREE); WriteReturn();
+#endif
+    sprintf(temp,"int %s,%s; _dag3_FREELIST %s;",ischare,activator,flist);
+    writeoutput(temp,NOFREE); 
+    sprintf(temp,"ChareIDType %s;",cid);
+    writeoutput(temp,NOFREE); WriteReturn();
+    if (!current_dag->is_a_chare) {
+       sprintf(temp,"int %s;",penum);
+       writeoutput(temp,NOFREE); WriteReturn();
+    }
+}
+
+_dag2_cond_code()
+{
+    CLIST *cond;
+    EWLIST *when_set;
+
+    if (InPass1) return;
+
+    cond = current_dag->c_list;
+    sprintf(temp,"static _dag7%s(%s,var,flag,refnum)",current_dag->charename,CkLocalPtr); 
+    writeoutput(temp,NOFREE);WriteReturn();
+    declare_lptr();
+    writeoutput("_dag3_DAGVAR *var; int flag,refnum;{",NOFREE); WriteReturn();
+    writeoutput("_dag3_COUNT *counter; int dispatched;",NOFREE); WriteReturn();
+#ifdef STRACE
+    writeoutput("unsigned int t2;",NOFREE); WriteReturn();
+#endif
+    assign_lptr();
+
+#ifdef STRACE
+    writeoutput("t2=dag_timer();",NOFREE); WriteReturn();
+#endif
+
+    writeoutput("if (flag == 0) --var->counter;",NOFREE); WriteReturn();
+    writeoutput("if (flag == 1 || var->counter==0) {",NOFREE); WriteReturn();
+    writeoutput("dispatched = 0;",NOFREE); WriteReturn();
+
+
+    writeoutput("  switch (var->index) {",NOFREE); WriteReturn();
+    while(cond) {  
+      sprintf(temp,"     case %d : ",cond->cno);
+      writeoutput(temp,NOFREE); WriteReturn();
+      when_set = cond->wlist;
+      while(when_set) {
+      
+        writeoutput ("if (flag == 0)",NOFREE);
+        sprintf(temp,"counter = _dag4_nonmfc(&(%s%s),%s%s,%s%s,%d);",
+                CkMyData,flist,
+                CkMyData,wcount,CkMyData,wcounter,when_set->wnode->wno);
+        writeoutput(temp,NOFREE); WriteReturn();
+
+        sprintf(temp,"else counter = _dag4_mfc(&(%s%s),%s%s,%s%s,%d,refnum);",
+                CkMyData,flist,
+                CkMyData,wcount,CkMyData,wcounter,when_set->wnode->wno);
+        writeoutput(temp,NOFREE); WriteReturn();
+
+        writeoutput("if (--(counter->value) == 0){",NOFREE);
+        /* refnum field was zero, if doesn't work , undo it */
+        sprintf(temp," _dag4_update_rl(&(%s%s),&(%s%s),%d,%d,refnum,counter);",
+                 CkMyData,flist,
+                 CkMyData,rl,when_set->wnode->wno,when_set->wnode->wtype);
+        writeoutput(temp,NOFREE); WriteReturn();
+        writeoutput("dispatched = 1;}",NOFREE); WriteReturn();
+        when_set = when_set->next;
+      } 
+      writeoutput("    break;",NOFREE); WriteReturn();
+      cond = cond->next; 
+    }
+    writeoutput(" }",NOFREE); WriteReturn();
+    sprintf(temp,"if (dispatched && (%s%s == 0) ) _dag10%s(%s);",
+                 CkMyData,activator,current_dag->charename,CkLocalPtr);
+    writeoutput(temp,NOFREE); WriteReturn();
+    writeoutput("}",NOFREE); WriteReturn();
+
+#ifdef STRACE
+   /* for historical reasons , change the refnum to -1 if it is zero */
+   /* remember, zero means no-reference number                       */
+   /* however, simulator requires -1 for this part only              */
+   sprintf(temp,"t2=dag_timer()-t2;_dag_s_r(&(%s%s),%s,var->index,((refnum==0)?-1:refnum),t2);",
+           CkMyData,cid,charenum);
+   writeoutput(temp,NOFREE); WriteReturn();
+#endif
+
+    writeoutput("}",NOFREE); WriteReturn();
+
+#ifdef STRACE
+    emit_mwset();
+#endif
+}
+
+
+_dag2_entry_code(modulename,charename)
+char *modulename,*charename;
+{
+    ELIST *eptr;
+    char  *map_ename;
+    int   init_flag,init_entry;
+
+    if (InPass1) return;
+
+    init_flag = init_entry = FALSE;
+    eptr = current_dag->e_list;
+
+    while (eptr) {
+
+      map_ename = Map(modulename,charename,eptr->name); 
+      entry_header_code(eptr->msgtype,map_ename,charename);
+      writeoutput("_dag3_BUFFER *buffer;int dispatched;",NOFREE); WriteReturn();
+      /* if init entry, emit initialization code */
+      if (strcmp(eptr->name,"init") == 0) {
+         if (init_flag) printf("dag: init error\n",EXIT);
+         init_flag = init_entry = TRUE;
+         init_code();
+      }
+
+
+      /* get the buffer pointer */
+      if (IS_MATCHING(eptr))
+          sprintf(temp,"buffer=_dag4_mfb(&(%s%s),%s%s,%d,GetRefNumber(msg));",
+                  CkMyData,flist,CkMyData,epbuffer,eptr->eno);
+      else
+          sprintf(temp,"buffer = _dag4_nonmfb(&(%s%s),%s%s,%d);",
+                  CkMyData,flist,CkMyData,epbuffer,eptr->eno);
+      writeoutput(temp,NOFREE);
+      WriteReturn();
+
+      /* if a new buffer, initialize it */
+      writeoutput("if(buffer->ecount == -1){",NOFREE);
+      if ( IS_MULTIPLE(eptr) ) 
+        sprintf(temp,"  buffer->ecount=%s%s;",CkMyData,eptr->varname);
+      else
+        sprintf(temp,"  buffer->ecount=1;");
+      writeoutput(temp,NOFREE);
+      sprintf(temp,"  buffer->free_count=%d;}",eptr->numofwhen);
+      writeoutput(temp,NOFREE); WriteReturn();
+
+      /* put the message */
+      if ( IS_MULTIPLE(eptr) )
+          sprintf(temp,"_dag4_mpm(buffer,msg,%s%s);",CkMyData,eptr->varname);
+      else
+          sprintf(temp,"_dag4_opm(buffer,msg);");
+      writeoutput(temp,NOFREE);
+      WriteReturn();
+
+      if (init_entry) {
+         writeoutput("buffer->expect=1;",NOFREE);
+         writeoutput("buffer->refnum=0;",NOFREE);      /* Added 7/21/94 Ed K. */
+                       /* The above initialization gets rid of a Purify UMR error - E.K. */
+         WriteReturn();
+      }
+
+      /* call the entry function */
+      writeoutput("if ( (buffer->expect) )",NOFREE);
+      sprintf(temp,"dispatched=_dag5_1%s(%s,%d,buffer->refnum,buffer->ecount,%d,0,buffer);",
+        current_dag->charename,CkLocalPtr,eptr->eno,IS_MULTIPLE(eptr)?1:0);
+      writeoutput(temp,NOFREE); WriteReturn();
+
+      /* emit code to check ready list */
+      sprintf(temp," if (dispatched) _dag4_process_rl(&(%s%s),%s,&(%s%s),%s%s,&(%s%s));",
+              CkMyData,flist,
+              CkLocalPtr,CkMyData,rl,CkMyData,wswitch_fptr,
+              CkMyData,activator);
+      writeoutput(temp,NOFREE); 
+      writeoutput("}",NOFREE); WriteReturn();
+  
+      init_entry = FALSE; 
+      eptr=eptr->next;
+    }  
+
+    emit_expect_code();
+     
+}
+
+_dag2_efunction_code()
+{
+      EWLIST *when_set;
+      ELIST  *eptr;
+
+      if (InPass1) return;
+
+      eptr = current_dag->e_list;
+
+      /* function header */
+      sprintf(temp,"static int _dag5_1%s(%s,index,refnum,ecount,msgcount,from_expect,buffer)",
+              current_dag->charename,CkLocalPtr);
+      writeoutput(temp,NOFREE);WriteReturn();
+      declare_lptr();
+      writeoutput("int index,refnum,ecount,msgcount,from_expect;",NOFREE); 
+      WriteReturn();
+      writeoutput("_dag3_BUFFER *buffer;",NOFREE); WriteReturn();
+      writeoutput("{int dispatched;_dag3_COUNT *counter;",NOFREE);
+      WriteReturn(); 
+      assign_lptr();
+
+      writeoutput("dispatched=0;",NOFREE); WriteReturn();
+
+
+      writeoutput("switch (index) {",NOFREE); WriteReturn();
+
+      while(eptr) {
+
+         when_set = eptr->wlist;
+         sprintf(temp,"   case %d:",eptr->eno);
+         writeoutput(temp,NOFREE); WriteReturn();
+
+         while(when_set) {
+
+           /* if it is a when of type ANY, don't create a count node */
+           /* just dispatch it, since only one ANY condition allowed */
+           
+           if ( IS_ANY(when_set->wnode) )
+            sprintf(temp,"if (msgcount > 0) dispatched|=_dag4_cci(&(%s%s),%d,%d,&(%s%s),msgcount,refnum,buffer);",
+                    CkMyData,flist,when_set->wnode->wno,when_set->wnode->wtype,
+                    CkMyData,rl);
+           else {
+            writeoutput("if (ecount==0) {",NOFREE); WriteReturn();
+            writeoutput("dispatched |= ",NOFREE); 
+            if ( IS_MATCHING_WHEN(when_set->wnode) )
+              sprintf(temp,"_dag4_ccm(&(%s%s),%d,%s%s,%s%s,%d,%d,&(%s%s),refnum,buffer);",
+                      CkMyData,flist,when_set->position,
+                      CkMyData,wcount,CkMyData,wcounter,
+                      when_set->wnode->wno,when_set->wnode->wtype,
+                      CkMyData,rl);
+            else
+              sprintf(temp,"_dag4_ccn(&(%s%s),%d,%s%s,%s%s,%d,%d,&(%s%s),refnum,buffer);",
+                      CkMyData,flist,when_set->position,
+                      CkMyData,wcount,CkMyData,wcounter,
+                      when_set->wnode->wno,when_set->wnode->wtype,
+                      CkMyData,rl);
+            writeoutput(temp,NOFREE); WriteReturn();
+
+            if (IS_MULTIPLE(eptr)) {
+              sprintf(temp,"buffer->ecount = %d;}",MULTIPLE);
+              writeoutput(temp,NOFREE);
+              }
+            else
+              writeoutput("}",NOFREE);
+            WriteReturn();
+           }
+
+           when_set = when_set->next;
+         }
+         writeoutput(" break;",NOFREE); WriteReturn();
+         eptr = eptr->next;
+      }
+
+      writeoutput("}",NOFREE); WriteReturn();
+      sprintf(temp,"if (from_expect && (%s%s == 0) && dispatched )",
+              CkMyData,activator);
+      writeoutput(temp,NOFREE);
+      sprintf(temp,"_dag10%s(%s);", current_dag->charename,CkLocalPtr); 
+      writeoutput(temp,NOFREE); WriteReturn();
+      writeoutput("return dispatched;}",NOFREE); WriteReturn();
+}
+
+
+
+
+
+_dag2_conv0()
+{
+     if (InPass1) return;
+     sprintf(temp,"static _dag11%s(%s,epconv) int epconv[];",
+             current_dag->charename,CkLocalPtr);
+     writeoutput(temp,NOFREE); WriteReturn();
+     declare_lptr();
+     writeoutput("{",NOFREE); 
+     assign_lptr();
+     savedeptr = current_dag->e_list;
+}
+
+
+_dag2_conv1()
+{
+    if (InPass1) return;
+    writeoutput("}",NOFREE); WriteReturn();
+    /* emit_epconv(); */
+}
+
+_dag2_conv2()
+{
+    if (InPass1) return;
+    sprintf(temp,"%s%s[%d] = ",CkMyData,epconv,savedeptr->eno);
+    writeoutput(temp,NOFREE);
+}
+
+_dag2_conv3()
+{
+    if (InPass1) return;
+    writeoutput(";",NOFREE);
+    savedeptr = savedeptr->next;
+}
+
+
+static emit_expect_code()
+{
+
+
+    sprintf(temp,"static _dag5%s(%s,ep,refnum)",
+               current_dag->charename,CkLocalPtr);
+    writeoutput(temp,NOFREE);WriteReturn();
+    declare_lptr();
+    writeoutput("int ep,refnum;{int index,ecount,msgcount;_dag3_BUFFER *buffer;",NOFREE);
+#ifdef STRACE
+writeoutput("unsigned int t2;",NOFREE);
+#endif
+    WriteReturn();
+    assign_lptr();
+
+#ifdef STRACE
+    writeoutput("t2 = dag_timer();",NOFREE); WriteReturn();
+#endif
+
+    sprintf(temp,"index = _dag4_epconv(ep,%s%s,%d);",
+        CkMyData,epconv,current_dag->numofentry);
+    writeoutput(temp,NOFREE);WriteReturn();
+
+
+    sprintf(temp,"buffer=_dag4_fb(&(%s%s),%s%s,index,%s%s[index],refnum,&msgcount);",
+        CkMyData,flist,CkMyData,epbuffer,CkMyData,etype);
+    writeoutput(temp,NOFREE); WriteReturn();
+
+    sprintf(temp,"_dag5_1%s(%s,index,refnum,buffer->ecount,msgcount,1,buffer);",
+        current_dag->charename,CkLocalPtr); WriteReturn();
+    writeoutput(temp,NOFREE); WriteReturn();
+
+#ifdef STRACE
+   sprintf(temp,"t2=dag_timer()-t2;_dag_s_e(&(%s%s),%s,ep,refnum,t2);",
+           CkMyData,cid,charenum);
+   writeoutput(temp,NOFREE); WriteReturn();
+#endif
+
+   writeoutput("}",NOFREE); WriteReturn();
+
+
+
+
+}
+
+#ifdef STRACE 
+static emit_mwset()
+{
+    ELIST *eptr;
+    EWLIST *ewptr;
+
+    if (InPass1) return;
+    sprintf(temp,"static _dag8%s(%s)",current_dag->charename,CkLocalPtr);
+    writeoutput(temp,NOFREE);WriteReturn();
+    declare_lptr();
+    writeoutput("{",NOFREE); WriteReturn();
+    assign_lptr();
+    eptr = current_dag->e_list; 
+    while(eptr) {
+       if (IS_MULTIPLE(eptr) ) {
+          ewptr = eptr->wlist;
+          while(ewptr) {
+          /*   if (!IS_ANY(ewptr->wnode)) { */
+             
+                sprintf(temp,"_dag_s_mset(%d,%s%s);",ewptr->wnode->wno,
+                              CkMyData,eptr->varname);
+                writeoutput(temp,NOFREE); WriteReturn();
+         /*    } */
+             ewptr = ewptr->next;
+          }
+       }
+       eptr = eptr->next;
+    }
+    writeoutput("}",NOFREE); WriteReturn();
+} 
+
+
+#endif
+
+
+
+
+/*
+static emit_epconv()
+{
+    if (InPass1) return;
+    sprintf(temp,"static _dag8%s(ep,epconv,n) int ep,epconv[],n;",
+                  current_dag->charename);
+    writeoutput(temp,NOFREE); WriteReturn();
+    writeoutput("{int i; for(i=0;i<n;i++) if(epconv[i] == ep)return i;",NOFREE);
+    WriteReturn();
+    writeoutput("CkPrintf(\"dag: invalid entry point\\n\");}",NOFREE);
+    WriteReturn();
+}
+*/
+
+
+_dag2_send_act(i)
+int i;
+{
+     if (InPass1) return;
+     switch(i) {
+        case 0: /* begininning part */
+            sprintf(temp,"static _dag10%s(%s)",
+                    current_dag->charename,CkLocalPtr);
+            writeoutput(temp,NOFREE); WriteReturn();
+            declare_lptr();
+            writeoutput("{_dag3_MSG *msg;",NOFREE); WriteReturn();
+            assign_lptr();
+            writeoutput(" msg = (_dag3_MSG *) GenericCkAlloc(",NOFREE);
+            break;
+        case 1:
+            writeoutput(",sizeof(_dag3_MSG),0);",NOFREE); WriteReturn(); 
+            if (current_dag->is_a_chare) 
+               writeoutput("SendMsg(",NOFREE);
+            else
+            writeoutput("_CK_SendMsgBranch(",NOFREE);
+            break;
+        case 2:
+            if (current_dag->is_a_chare)
+                sprintf(temp,",msg,&(%s%s));",CkMyData,cid);
+            else {
+                writeoutput(",msg,_CK_MyBocNum(_CK_4mydata),",NOFREE);
+                sprintf(temp,"%s%s);",CkMyData,penum);
+            }
+            writeoutput(temp,NOFREE); WriteReturn();
+            sprintf(temp,"%s%s = 1;}",CkMyData,activator);
+            writeoutput(temp,NOFREE); WriteReturn();
+     } 
+}
+
+
+
+
+
+_dag2_activator(modulename,charename)
+char *modulename,*charename;
+{
+    char *map_ename;
+    if (InPass1) return ;
+    map_ename = Map(modulename,charename,"_dag9"); 
+    entry_header_code("_dag3_MSG",map_ename,charename);
+
+    sprintf(temp,"%s%s = 0;",CkMyData,activator);
+    writeoutput(temp,NOFREE); WriteReturn();
+    sprintf(temp,"_dag4_process_rl(&(%s%s),%s,&(%s%s),%s%s,&(%s%s));",
+            CkMyData,flist,
+            CkLocalPtr,CkMyData,rl,CkMyData,wswitch_fptr,
+            CkMyData,activator);
+    writeoutput(temp,NOFREE);WriteReturn();
+    writeoutput("CkFreeMsg(msg);}",NOFREE); WriteReturn();
+}
+
+
+_dag2_set_current_when()
+{
+    if (InPass1) return;
+    if (current_when == NULL) 
+        current_when = current_dag->w_list;
+    else
+        current_when = current_when->next;
+}
+
+    
+
+_dag2_when_header(CurrentTable)
+void *CurrentTable;
+{
+    WLIST *wptr;
+    WCONDLIST *ent_cond;
+
+    if (InPass1) return;
+
+    wptr = current_when;
+
+      /* write when function */
+      sprintf(temp,"static  _dag6%s%d(%s",
+              current_dag->charename,wptr->wno,CkLocalPtr);
+      writeoutput(temp,NOFREE);
+      ent_cond = wptr->clist;
+      while (ent_cond) {
+          if (ent_cond->isentry) {
+             writeoutput(",",NOFREE);
+             writeoutput(((ELIST *)ent_cond->eptr)->msgname,NOFREE); 
+          }
+          ent_cond = ent_cond->next;
+      }
+      writeoutput(") ",NOFREE);
+      WriteReturn();
+      ent_cond = wptr->clist;
+      declare_lptr();
+      while(ent_cond) {
+         if(ent_cond->isentry) {
+             sprintf(temp,"%s *%s",
+                 ((ELIST*)ent_cond->eptr)->msgtype,
+                 ((ELIST*)ent_cond->eptr)->msgname);
+             writeoutput(temp,NOFREE);
+             Insert(((ELIST*)ent_cond->eptr)->msgname,CurrentTable);
+             if (  IS_MULTIPLE(((ELIST*)ent_cond->eptr))  &&
+                   !IS_ANY(wptr) )
+                writeoutput("[]",NOFREE); 
+             writeoutput(";",NOFREE); WriteReturn();
+         }
+         ent_cond = ent_cond->next;
+      }
+      
+
+}
+
+
+_dag2_whenswitch()
+{
+     WLIST *wptr;
+     WCONDLIST *ent_cond;
+     int i,j,flag,numofp;
+
+     if (InPass1) return;
+
+     /* write the switch function for when blocks */
+     wptr = current_dag->w_list;
+     sprintf(temp,"static _dag4%s(%s,rlnode)",
+             current_dag->charename,CkLocalPtr);
+     writeoutput(temp,NOFREE); WriteReturn();
+     declare_lptr();
+     writeoutput("_dag3_RLNODE *rlnode; ",NOFREE); WriteReturn();
+     writeoutput("{ ",NOFREE); WriteReturn();
+     assign_lptr();
+     writeoutput(" switch (rlnode->value) {",NOFREE); WriteReturn();
+     while(wptr) {
+
+        ent_cond = wptr->clist; i = 0;
+
+        if (!ent_cond) error("Empty when condition list",EXIT);
+        sprintf(temp,"   case %d :{",wptr->wno);
+        writeoutput(temp,NOFREE); WriteReturn();
+     
+        while(ent_cond) {
+           if (ent_cond->isentry) i++; 
+           ent_cond = ent_cond->next;
+        }
+
+        if ( numofp=i > _dag3_WLIMIT ) 
+            error("dag: too many entries in a when condition list. Increase _dag3_WLIMIT\n",EXIT);
+
+        /* declare parameters */
+        if (i) {
+
+
+           writeoutput("void *p0",NOFREE);
+           for(j=1; j<i; j++) {
+              sprintf(temp,",*p%d",j);
+              writeoutput(temp,NOFREE);
+           }
+           writeoutput(";",NOFREE); WriteReturn();
+     
+          
+           /* assign parameters */ 
+           ent_cond = wptr->clist; i=0;
+           while(ent_cond) {
+              if (ent_cond->isentry) {
+                  flag = 0;
+                  sprintf(temp,"p%d=_dag4_gb(rlnode,%d,%d,",i++,
+                          ent_cond->position, 
+                          ((ELIST *)ent_cond->eptr)->eno); 
+                  writeoutput(temp,NOFREE);
+                  if ( IS_MULTIPLE(((ELIST *)ent_cond->eptr)) )flag |= MULTIPLE;
+                  if ( IS_ANY(wptr) ) flag |= ANY;
+                  sprintf(temp,"%d);",flag);
+                  writeoutput(temp,NOFREE);
+                  WriteReturn();
+              }
+              ent_cond = ent_cond->next;
+           }
+           WriteReturn();  
+        }
+
+
+#ifdef STRACE
+   sprintf(temp,"_dag_s_wb(&(%s%s),%s,%d,rlnode->refnum);",
+           CkMyData,cid,charenum,wptr->wno);
+   writeoutput(temp,NOFREE); WriteReturn();
+#endif
+        /* call the when function */
+        ent_cond = wptr->clist; i = 0;
+        /* first, set the current_refnum var */
+        sprintf(temp,"%s%s = rlnode->refnum\n;",CkMyData,current_refnum);
+        writeoutput(temp,NOFREE); WriteReturn(); 
+        sprintf(temp,"_dag6%s%d(%s",
+                current_dag->charename,wptr->wno,CkLocalPtr);
+        writeoutput(temp,NOFREE);
+        while(ent_cond) {
+           if (ent_cond->isentry) {
+               sprintf(temp,",p%d",i++);
+               writeoutput(temp,NOFREE);
+           }
+           ent_cond = ent_cond->next;
+        }
+        writeoutput(");",NOFREE);
+
+#ifdef STRACE
+   writeoutput("_dag_s_we();",NOFREE); WriteReturn();
+#endif
+
+        /* free the buffer and messages if necessary */
+
+        if ( !IS_ANY(wptr)  )  {
+           /* code to free the buffers. get_buffer decrements
+              the free_count (except when stmts of ANY type 
+              if free_count is zero, that buffer and messsages
+              can be freed */
+       
+           writeoutput("_dag4_freebuffer",NOFREE);
+           sprintf(temp,"(&(%s%s),rlnode);",CkMyData,flist);
+           writeoutput(temp,NOFREE);WriteReturn();
+
+/*
+           ent_cond = wptr->clist;
+           while(ent_cond) {
+             if (ent_cond->isentry) {
+                if ( IS_MULTIPLE(((ELIST *)ent_cond->eptr)) )
+                   writeoutput("_dag4_m_freebuffer",NOFREE);
+                else
+                   writeoutput("_dag4_freebuffer",NOFREE);
+                sprintf(temp,"(&(%s%s),rlnode);",CkMyData,flist);
+                writeoutput(temp,NOFREE);WriteReturn();
+             }
+             ent_cond = ent_cond->next;  
+           }
+*/
+        }
+            
+           
+        writeoutput("} break;",NOFREE); WriteReturn();
+    
+        wptr = wptr->next;
+     }
+
+     writeoutput("} }",NOFREE);WriteReturn();
+}
+
+
+
+
+static reverse_elist()
+{
+    ELIST *prev,*current,*next;
+
+    if (current_dag->e_list == (ELIST *) NULL) return;
+    if (current_dag->e_list->next == (ELIST *) NULL) return;
+
+
+    prev = (ELIST *) NULL;
+    current = current_dag->e_list;
+    while(current) {
+       next = current->next;
+       current->next = prev;
+       prev = current;
+       current = next;
+    }
+    current_dag->e_list = prev; 
+}   
+
+
+static reverse_clist()
+{
+    CLIST *prev,*current,*next;
+
+    if (current_dag->c_list == (CLIST *) NULL) return;
+    if (current_dag->c_list->next == (CLIST *) NULL) return;
+    
+
+    prev = (CLIST *) NULL;
+    current = current_dag->c_list;
+    while(current) {
+       next = current->next;
+       current->next = prev;
+       prev = current;
+       current = next;
+    }
+    current_dag->c_list = prev;
+}
+
+        
+       
+static ELIST *is_entry(condname)
+char *condname;
+{
+     ELIST *ptr;
+     ptr = e_list;
+     while(ptr!= NULL) 
+        if(strcmp(condname,ptr->name) == 0) 
+          return ptr;
+        else
+          ptr = ptr->next;
+     return NULL;
+}
+
+static CLIST *insert_cond(condname)
+char *condname;
+{
+     CLIST *ptr,*cond;
+     ptr = c_list;
+     while(ptr != NULL)
+        if(strcmp(condname,ptr->name) == 0) 
+           return ptr;
+        else
+           ptr = ptr->next;
+     cond = (CLIST *) malloc(sizeof(CLIST));
+     cond->wlist = NULL;
+     cond->cno = current_cno++;
+     cond->next = c_list;
+     c_list = cond;
+     c_list->name = (char *) malloc(strlen(condname)+1);
+     strcpy(c_list->name,condname);
+     return cond;
+}
+
+
+
+
+
+
+static init_code()
+{
+   ELIST *eptr;
+   WLIST *wptr;
+   CLIST *cond;
+   int flag;
+
+
+    sprintf(temp,"int _dag4%s(),_dag5%s(),_dag7%s();",
+         current_dag->charename,current_dag->charename,current_dag->charename);
+    writeoutput(temp,NOFREE); WriteReturn();
+
+#ifdef STRACE
+    sprintf(temp,"int _dag8%s();",current_dag->charename);
+    writeoutput(temp,NOFREE); WriteReturn();
+#endif
+
+   /* emit code to initiaalize condtrol data */
+   sprintf(temp,"%s%s.head = %s%s.tail = (_dag3_RLNODE *) NULL;",
+           CkMyData,rl,CkMyData,rl);   
+   writeoutput(temp,NOFREE); WriteReturn();
+
+   
+   eptr = current_dag->e_list;
+   while(eptr) {
+      sprintf(temp,"%s%s[%d] = %d;",CkMyData,etype,eptr->eno,eptr->etype);
+      writeoutput(temp,NOFREE); WriteReturn();
+      sprintf(temp,"%s%s[%d] = (_dag3_BUFFER *) NULL;",
+              CkMyData,epbuffer,eptr->eno);
+      writeoutput(temp,NOFREE); WriteReturn();
+      eptr = eptr->next;
+   }
+
+   wptr = current_dag->w_list;
+   while(wptr) {
+      sprintf(temp,"%s%s[%d] = %d;",CkMyData,wcount,wptr->wno,wptr->count);
+      writeoutput(temp,NOFREE); WriteReturn();
+      sprintf(temp,"%s%s[%d] = (_dag3_COUNT *) NULL;",
+              CkMyData,wcounter,wptr->wno);
+      writeoutput(temp,NOFREE); WriteReturn();
+      wptr = wptr->next;
+   } 
+
+   cond = current_dag->c_list;
+   while(cond) {
+      sprintf(temp,"%s%s.index = %d;",CkMyData,cond->name,cond->cno);
+      writeoutput(temp,NOFREE); WriteReturn();
+      cond = cond->next;
+   }
+
+   sprintf(temp,"%s%s = _dag7%s;",
+           CkMyData,condvar_fptr,current_dag->charename);
+   writeoutput(temp,NOFREE); WriteReturn();
+#ifdef STRACE
+   sprintf(temp,"%s%s = _dag8%s;",
+           CkMyData,mw_fptr,current_dag->charename);
+   writeoutput(temp,NOFREE); WriteReturn();
+#endif 
+   sprintf(temp,"%s%s = _dag5%s;",CkMyData,efunc_fptr,current_dag->charename);
+   writeoutput(temp,NOFREE); WriteReturn();
+   sprintf(temp,"%s%s=_dag4%s;",CkMyData,wswitch_fptr,current_dag->charename);
+   writeoutput(temp,NOFREE); WriteReturn();
+   sprintf(temp,"%s%s = 0;",CkMyData,activator);
+   writeoutput(temp,NOFREE); WriteReturn();
+   sprintf(temp,"%s%s = %d;",CkMyData,ischare,current_dag->is_a_chare);
+   writeoutput(temp,NOFREE); WriteReturn();
+   sprintf(temp,"%s%s.dagexit = 0;",CkMyData,rl);
+   writeoutput(temp,NOFREE); WriteReturn();
+   sprintf(temp,"%s%s.bcount = %s%s.ccount = 0;",
+                CkMyData,flist,CkMyData,flist,CkMyData,flist);
+   writeoutput(temp,NOFREE); WriteReturn();
+   sprintf(temp,"%s%s.b = 0;%s%s.c = 0;",
+                CkMyData,flist,CkMyData,flist,CkMyData,flist);
+   writeoutput(temp,NOFREE); WriteReturn();
+   if (current_dag->is_a_chare) 
+      sprintf(temp,"MyChareID(&(%s%s));",CkMyData,cid);
+   else {
+       sprintf(temp,"_CK_MyBranchID(&(%s%s),%s);",CkMyData,cid,CkLocalPtr);
+       writeoutput(temp,NOFREE); WriteReturn();
+       sprintf(temp,"%s%s = McMyPeNum();",CkMyData,penum);
+   }
+   writeoutput(temp,NOFREE); WriteReturn();
+   
+   sprintf(temp,"_dag11%s(%s,%s%s);",
+           current_dag->charename,CkLocalPtr,CkMyData,epconv);
+   writeoutput(temp,NOFREE);
+   sprintf(temp,"%s%s = %d;",CkMyData,current_refnum,DAG_NOREF);
+   writeoutput(temp,NOFREE); WriteReturn();
+
+#ifdef STRACE
+   WriteReturn();
+   sprintf(temp,"_dag_s_init(&(%s%s),%s,%d,%s%s,\"%s\");",
+           CkMyData,cid,charenum,current_dag->numofentry,CkMyData,epconv,
+           trace_charename);
+   writeoutput(temp,NOFREE); WriteReturn();
+
+#endif
+
+}
+
+
+
+
+
+
+static entry_header_code(msgtype,map_ename,charename)
+char  *map_ename,*charename,*msgtype;
+{
+      char *ename; 
+    
+      writeoutput("void static ",NOFREE);
+      writeoutput(map_ename,NOFREE);
+      writeoutput("(msg,",NOFREE);
+      writeoutput(CkLocalPtr,NOFREE);
+      writeoutput(")",NOFREE);
+      WriteReturn();
+      declare_lptr();
+      writeoutput(msgtype,NOFREE);
+      writeoutput(" *msg;",NOFREE);
+      WriteReturn();
+      writeoutput("{ ",NOFREE);
+      assign_lptr();
+}
+
+
+
+
+
+
+static declare_lptr()
+{
+      writeoutput("void *",NOFREE);
+      writeoutput(CkLocalPtr,NOFREE);
+      writeoutput(";",NOFREE);
+      WriteReturn();
+}
+
+
+static assign_lptr()
+{
+      writeoutput(current_dag->charename,NOFREE);
+      writeoutput(DataSuffix,NOFREE);
+      writeoutput(AssignMyDataPtr,NOFREE);
+      writeoutput(current_dag->charename,NOFREE);
+      writeoutput(DataSuffix,NOFREE);
+      writeoutput(" *)",NOFREE);
+      writeoutput(CkLocalPtr,NOFREE);
+      writeoutput(";",NOFREE);
+      WriteReturn();
+}
+
+static fill_charenum(chare)
+char  *chare;
+{
+     extern char *CkPrefix_, *Prefix();
+     charenum = Prefix(chare,modulename,CkPrefix_);
+     sprintf(trace_charename,"%s %s",modulename,chare);
+}
+
+#ifdef STRACE
+
+static write_depn()
+{
+    ELIST     *eptr;
+    CLIST     *cptr;
+    WLIST     *wptr;
+    EWLIST    *weptr;
+    WCONDLIST *clist;
+    int       count,count2;
+   
+    FILE *fp;
+
+    if ( (fp = fopen("dag_depn","a")) == NULL ) {
+       printf("can't open dag_depn for append\n");
+       return; 
+    }
+
+    fprintf(fp,"b %s %s ",modulename,current_dag->charename);
+    eptr = current_dag->e_list;
+    for(count=0; (eptr) ; eptr=eptr->next) count++;
+    fprintf(fp,"%d ",count);
+    cptr = current_dag->c_list;
+    for(count=0; (cptr) ; cptr=cptr->next) count++;
+    fprintf(fp,"%d ",count);
+    wptr = current_dag->w_list;
+    for(count=0; (wptr) ; wptr=wptr->next) count++;
+    fprintf(fp,"%d\n",count);
+
+    eptr = current_dag->e_list;
+    while (eptr) {
+       fprintf(fp,"e %d ",eptr->eno); 
+       weptr = eptr->wlist;
+       for(count=0; (weptr) ; weptr=weptr->next) count++;
+       fprintf(fp,"%d\n",count); 
+       weptr = eptr->wlist;
+       while (weptr) {
+          fprintf(fp,"%d\n",weptr->wnode->wno);
+          weptr = weptr->next;
+       }
+       eptr = eptr->next;      
+    }
+
+    cptr = current_dag->c_list;
+    while (cptr) {
+       fprintf(fp,"c %d ",cptr->cno);
+       weptr = cptr->wlist;
+       for(count = 0; (weptr) ; weptr=weptr->next) count++;
+       fprintf(fp,"%d\n",count);
+       weptr = cptr->wlist;
+       while (weptr) {
+           fprintf(fp,"%d\n",weptr->wnode->wno);
+           weptr=weptr->next;
+       }
+       cptr = cptr->next;
+    }
+
+    wptr = current_dag->w_list;
+    while (wptr) {
+       fprintf(fp,"w %d ",wptr->wno);
+       if (IS_ANY(wptr) )  {
+           count = 1;
+           count2 = -1;
+          }
+       else {
+          clist = wptr->clist;
+          count = 0;
+          count2 = 0;
+          while (clist) {
+             if (clist->isentry) {
+                  count ++;
+                  if ( IS_MULTIPLE(((ELIST *)clist->eptr)) ) 
+                     count2++;
+                  else
+                     if (strcmp(((ELIST *)clist->eptr)->name,"init")) count ++;
+                }
+             else 
+                count++;
+             clist = clist->next;
+         }
+      }
+      fprintf(fp,"%d %d\n",count,count2);
+      if (count2>0) {
+          clist = wptr->clist;
+          while(clist) {
+              if (clist->isentry)
+                     if ( IS_MULTIPLE(((ELIST *)clist->eptr)) ) 
+                     fprintf(fp,"%d\n",((ELIST *)clist->eptr)->eno);
+              clist = clist->next;
+          }
+      }
+      wptr = wptr->next; 
+    }
+
+    fclose(fp);
+} 
+#endif
diff --git a/src/xlat/xl-lex.c b/src/xlat/xl-lex.c
new file mode 100644 (file)
index 0000000..c0085e8
--- /dev/null
@@ -0,0 +1,151 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-05 18:52:05  brunner
+ * Reorganized file structure
+ *
+ * Revision 1.1  1994/11/03  17:41:36  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+static char ident[] = "@(#)$Header$";
+
+#include <stdio.h>
+#include "xl-lex.h"
+#include "xl-sym.h"
+#include <string.h>
+
+extern int OUTPUTOFF;
+extern char *calloc();
+extern char *Map();
+extern int IMPORTFLAG,ImportStruct,ImportLevel;
+
+extern FILE *outh0,*outh,*outh1,*outh2;
+OUTPTR OUT0,OUT1,OUT2,OUT,CurrentOut;
+
+OUTPTR GetOutStruct(fptr)
+FILE *fptr;
+{ OUTPTR dummy;
+
+  dummy=(OUTPTR)calloc(1,sizeof(struct outstruct));
+  dummy->lineno=dummy->linelength=0;
+  dummy->file=fptr;
+  return(dummy);
+}
+
+dummycall(){} 
+
+void error(message,exitflag)
+int exitflag;
+char *message;
+{ if (!exitflag&&InPass1) return;
+  if (exitflag) dummycall();
+
+  fprintf(stderr,"\"%s\", line %d: ",CurrentFileName,CurrentInputLineNo);
+  PutOnScreen(message);
+  if (exitflag) { fprintf(stderr,"** Stop.\n");
+                 exit(1);
+               }
+}
+
+void warning(message)
+char *message;
+{ if (InPass1) return;
+  fprintf(stderr,"\"%s\", line %d: warning:",CurrentFileName,
+          CurrentInputLineNo);
+  PutOnScreen(message);
+}
+
+char *Prefix(to,by,prefix)
+char *to,*by,*prefix;
+{ char *temp;
+  int bylength;
+  
+  temp=calloc(strlen(to)+(bylength=strlen(by))+2+strlen(prefix),
+               sizeof (char));
+  if (temp==NULL) error("Out of Memory in Prefix()",EXIT);
+  strcpy(temp,prefix);strcat(temp,by);strcat(temp,".");strcat(temp,to);
+  return(temp);
+}
+
+char *ModuleCharePrefix(module,chare,name)
+char *module,*chare,*name;
+{ char *temp,*dummy;
+
+  temp=CharePrefix(chare,name);
+  dummy=ModulePrefix(module,temp);
+  free(temp);
+  return(dummy);
+}
+
+char *MyModuleCharePrefix(module,chare,name)
+char *module,*chare,*name;
+{ char *temp,*dummy;
+
+  temp=CharePrefix(chare,name);
+  dummy=MyModulePrefix(module,temp);
+  free(temp);
+  return(dummy);
+}
+
+void writeinbuffer(string,flag)
+int flag;
+char *string;
+{ int size;
+
+  size = strlen(string);
+  if (buffer.count+size >= 1000)
+       { error("Buffer Overflow",EXIT); exit(1); }
+  strcpy(&(buffer.a[buffer.count]),string);
+  buffer.count += size;
+  if (flag) free(string);
+}
+
+void WriteReturn()
+{ if ((OUTPUTOFF)||(InPass1)) return;
+  if (CurrentOut==NULL) return;
+  if (BUFFEROUTPUT) { writeinbuffer("\n",0); return; }
+  fprintf(CurrentOut->file,"\n"); CurrentOut->lineno++; CurrentOut->linelength=0; 
+}
+
+void writeoutput(string,freeflag)
+char *string;
+int freeflag;
+{ int length;
+
+  if ((CurrentOut==NULL)||(OUTPUTOFF)||(InPass1))
+       { if (freeflag) free(string);
+         return;
+       }
+
+  if (BUFFEROUTPUT) { writeinbuffer(string,freeflag); return; }
+
+/* Removed on Nov. 12, 1991 - discussion with Sanjay. 
+
+  if (((ImportLevel==0)&&(IMPORTFLAG))||(ImportStruct))
+       string=Map(CurrentModule->name,(ImportStruct)?"_CKTYPE":"0",string);
+*/
+  length = strlen(string);
+  if (CurrentOut->linelength+length >= MAXLINELENGTH)
+       WriteReturn();
+  CurrentOut->linelength += length;
+  if (CurrentInputLineNo != CurrentOut->lineno)
+       { CurrentOut->lineno = CurrentInputLineNo;
+       /* Assuming that when I & O fall out, \n has been inserted! */
+         fprintf(CurrentOut->file,"\n# line %d \"%s\"\n",CurrentInputLineNo,CurrentFileName);
+       }
+  WriteString(string);
+  if (freeflag) free(string);
+}
+
diff --git a/src/xlat/xl-lex.h b/src/xlat/xl-lex.h
new file mode 100644 (file)
index 0000000..d62677c
--- /dev/null
@@ -0,0 +1,131 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-05 18:52:05  brunner
+ * Reorganized file structure
+ *
+ * Revision 1.2  1994/11/11  05:32:33  brunner
+ * Removed ident added by accident with RCS header
+ *
+ * Revision 1.1  1994/11/07  15:40:59  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+#include <stdio.h>
+
+#define free myfree
+
+extern char *CkPrefix; /* defined in outh.c */
+extern char *CkPrefix_;        /* defined in outh.c */
+extern char *CKMAINDATAFUNCTION;       /* defined in outh.c */
+extern char *CKMAINCHAREFUNCTION;      /* defined in outh.c */
+extern char *CKMAINQUIESCENCEFUNCTION; /* defined in outh.c */
+extern char *REFSUFFIX;                        /* defined in outh.c */
+
+extern char *CkMyData; /* defined in yaccspec */
+
+#define FILENAMELENGTH 1000
+
+#define UNDEFINED 1000
+               /* UNDEFINED also defined in symtab.h */
+#define NOEXIT 0
+#define EXIT 1
+
+#define NOFREE 0
+#define FREE   1
+
+#define PutOnScreen(message)   fprintf(stderr,"%s",message)
+#define memory_error error
+
+extern char *MakeString();
+
+typedef struct token
+{ char *name;
+  int  tokenvalue;
+} USELESS_TOKEN;
+
+extern struct token *TokenArray;
+extern struct token *KeyArray;
+extern int TotalTokens;
+
+extern int CurrentInputLineNo,CurrentOutputLineNo,OutputLineLength;
+extern char CurrentFileName[];
+extern FILE *outfile;
+
+extern void error(/*char *message,int exitflag*/);
+extern void warning(/*char *message*/);
+
+extern int IsKey(/* char *tokenstring */);     /* in readtokens.c */
+
+/* *** Following are required for yacc *** */
+
+typedef struct ysn
+{ char *string;
+  char *modstring;
+  struct listnode *listptr;
+  int idtype;
+  struct typenode *type;
+  struct ysn *ysn;
+  struct symtabnode *table;
+  int count;
+} YaccStackNode,*YSNPTR;
+
+typedef struct listnode
+{ YSNPTR ysn;
+  struct listnode *next;
+  struct listnode *prev;
+} LISTNODE,*LISTPTR;
+
+extern int TypeID(/* char *name */);
+extern LISTPTR GetListNode(/* YSNPTR eleptr */);
+extern void InsertNode(/*  LISTPTR listptr, YSNPTR eleptr */);
+extern YSNPTR GetYSN();
+
+/* *** Following for writeoutput *** */
+extern int IMPORTFLAG;
+#define MAXLINELENGTH 254
+#define WriteString(string)    fprintf(CurrentOut->file,"%s",string)
+
+#define MyModulePrefix(module,name)    Prefix(name,module,CkPrefix_)
+#define ModulePrefix(module,name)      Prefix(name,module,CkPrefix)
+#define CharePrefix(chare,name)                Prefix(name,chare,CkPrefix)
+
+extern void WriteReturn();
+extern void writeoutput(/* char *string, int freeflag */);
+extern char *ModuleCharePrefix(/* char *module, char *chare, char *name */);
+extern char *MyModuleCharePrefix(/* char *module, char *chare, char *name */);
+extern char *Prefix(/* char *to, char *by , char *prefix */);
+
+extern int InPass1;
+extern int MESSAGEON;
+
+extern char *GetMem();
+
+typedef struct outstruct
+{ FILE *file;
+  int lineno;
+  int linelength;
+} *OUTPTR;
+
+extern OUTPTR GetOutStruct(/* fptr */);
+extern OUTPTR OUT0,OUT1,OUT2,OUT,CurrentOut;
+
+typedef struct
+{ char a[1000];
+  int  count;
+} BUFFERTYPE;
+
+extern BUFFERTYPE buffer;
+
+extern int BUFFEROUTPUT;
diff --git a/src/xlat/xl-main.c b/src/xlat/xl-main.c
new file mode 100644 (file)
index 0000000..a27f794
--- /dev/null
@@ -0,0 +1,213 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-05 18:52:05  brunner
+ * Reorganized file structure
+ *
+ * Revision 1.1  1994/11/03  17:41:41  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+static char ident[] = "@(#)$Header$";
+
+#include <stdio.h>
+#include <string.h>
+#include "xl-sym.h"
+#include "xl-lex.h"
+
+extern BUFFERTYPE buffer;
+
+#define EXIT 1
+#define NAMELIMIT 100
+char ModuleName[NAMELIMIT];
+
+extern yyparse();
+extern void ReadTokens();
+extern void ReadKeys();
+
+extern int yylineno;
+extern int CurrentInputLineNo;
+extern char CurrentFileName[],*MakeString();
+extern FILE *yyin,*outfile,*outh1,*outh2,*outh0;
+extern int SavedLineNo;
+extern char SavedFileName[];
+
+extern void GenerateOuth();
+extern void InitMapHead();
+
+char outhfilename[FILENAMELENGTH];
+int InPass1=0;
+
+void ParseCommandLine(argc,argv)
+int argc;
+char *argv[];
+{ if (argc!=3) { fprintf(stderr,"usage: translate <InFile> <OutFile>. Stop\n"); 
+                exit(1); }
+  strcpy(CurrentFileName,argv[1]);
+  yyin = fopen(CurrentFileName,"r");
+  outfile = fopen(argv[2],"w");
+  strcpy(outhfilename,argv[2]);strcat(outhfilename,".0.h");
+  outh0 = fopen(outhfilename,"w");
+  strcpy(outhfilename,argv[2]);strcat(outhfilename,".1.h");
+  outh1 = fopen(outhfilename,"w");
+  strcpy(outhfilename,argv[2]);strcat(outhfilename,".2.h");
+  outh2 = fopen(outhfilename,"w");
+  if ((yyin==NULL)||(outfile==NULL)||(outh1==NULL)||(outh2==NULL)||(outh0==NULL))
+       { fprintf(stderr,"Cannot open file. Stop\n"); exit(1); }
+  strcpy(outhfilename,argv[2]);
+}
+
+void InitOutputFile()
+{ fprintf(outfile,"#include \"ckdefs.h\"\n"); 
+  fprintf(outfile,"#include \"trans_externs.h\"\n"); 
+  fprintf(outfile,"#include \"%s.0.h\"\n",outhfilename);
+  fprintf(outfile,"#include \"%s.1.h\"\n",outhfilename);
+  OUT0=GetOutStruct(outh0);
+  OUT1=GetOutStruct(outh1);
+  OUT=GetOutStruct(outfile);
+  CurrentOut=NULL;
+}
+
+void ReInitializeParameters()
+{ yylineno=1;
+  RealDummy(SavedLineNo);
+  CurrentInputLineNo=SavedLineNo-1;
+  strcpy(CurrentFileName,SavedFileName);
+}
+
+main(argc,argv)
+int argc;
+char *argv[];
+{ ParseCommandLine(argc,argv);
+  InitMapHead();
+  ReadTokens();ReadKeys();
+  InitSymTable(); 
+  CreateTempFile();    /* temp file = outh2 */
+  fclose(yyin);fclose(outh2);
+  yyin=fopen(CurrentFileName,"r");             /* read temp file */
+  if (yyin==NULL)  error("Can't open input file for first pass",EXIT);
+  InitOutputFile();
+  InPass1=0;
+  buffer.count=0;
+  yyparse();
+  fclose(yyin);
+  strcat(outhfilename,".2.h");
+  yyin=fopen(outhfilename,"r");
+  strcpy(outhfilename,argv[2]);
+  if (yyin==NULL)
+         error("Can't open input for second pass",EXIT);
+  ReInitializeParameters();
+  yyparse();
+  fclose(yyin);
+  fprintf(outfile,"#include \"%s.2.h\"\n",outhfilename);
+  fclose(outfile);
+  strcat(outhfilename,".2.h");
+  outh2=fopen(outhfilename,"w");
+  if (outh2==NULL)
+       error("Cannot Open File For Generating Translator Functions",EXIT);
+  GenerateOuth();
+  fclose(outh0);fclose(outh1);fclose(outh2);
+
+  exit(0);
+}
+
+#define IsModule 1
+#define IsInterface 2
+
+CreateTempFile()
+{ char ch;
+  int filechar;
+
+  ch=filechar=getc(yyin);
+  while (filechar!=EOF)
+  { if ((ch!='i')&&(ch!='m'))
+       ch=filechar=getc(yyin);
+    else switch (NextToken(ch))
+        { case IsModule : CopyFile(); return;
+          case IsInterface : SkipInterface();
+          default      : ch=filechar=getc(yyin);
+       }
+  }
+  error("Unexpected End of File",EXIT);
+}
+
+IsToken(token)
+char *token;
+{ int i,length;
+  char ch;
+
+  length=strlen(token);
+  for (i=0;i<length;i++)
+       { ch=getc(yyin);
+         if (ch!= *token) return(0); else token++; 
+       }
+  ch=getc(yyin);
+  if ((ch==' ')||(ch=='\t')||(ch=='\n')) return(1);
+  return(0);    
+}
+
+NextToken(ch)
+char ch;
+{ if (ch=='m')
+       { if (IsToken("odule")) return(IsModule); else return(0); }
+  else         { if (IsToken("nterface")) return(IsInterface); else return(0); }
+}
+
+CopyFile()
+{ char ch;
+  int index=0;
+  int filechar;
+
+  fprintf(outh2,"module ");
+  ch=filechar=getc(yyin);
+  while ((ch==' ')||(ch=='\t')||(ch=='\n'))
+       { putc(ch,outh2); ch=filechar=getc(yyin); }
+
+  while (!((ch==' ')||(ch=='\t')||(ch=='\n')))
+       { putc(ch,outh2); ModuleName[index++]=ch; 
+          if (index==NAMELIMIT) index--;
+          if (filechar==EOF)
+               { ModuleName[index]='\0'; return; }
+          ch=filechar=getc(yyin);
+       }
+  ModuleName[index]='\0';
+  while (filechar!=EOF)
+       { putc(ch,outh2); ch=filechar=getc(yyin); }
+}
+
+SkipInterface()
+{ int count;
+  char ch;
+  int filechar;
+  
+  ch=filechar=getc(yyin);
+  while ((filechar!=EOF)&&(ch!='{')) ch=filechar=getc(yyin);
+  count=1;
+  while ((count)&&(filechar!=EOF))
+       { ch=filechar=getc(yyin);
+         if (ch=='{') count++;
+         if (ch=='}') count--;
+       }
+  if (count) error("Unexpected End of File",EXIT);
+}
+
+#undef free
+
+myfree(ptr)
+char *ptr;
+{/* free(ptr); */}
+
+RealDummy(a)
+{}
+
diff --git a/src/xlat/xl-outh.c b/src/xlat/xl-outh.c
new file mode 100644 (file)
index 0000000..1325177
--- /dev/null
@@ -0,0 +1,944 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-05 18:52:05  brunner
+ * Reorganized file structure
+ *
+ * Revision 1.5  1995/05/04  21:26:15  milind
+ * Cleaned Up
+ *
+ * Revision 1.4  1995/04/26  22:19:09  milind
+ * Fixed initialization bug.
+ *
+ * Revision 1.3  1995/04/23  18:06:27  milind
+ * Fixed the jacobi bug.
+ *
+ * Revision 1.2  1995/02/13  17:28:11  milind
+ * Modified to register objects in accordance with the run-time system.
+ *
+ * Revision 1.1  1995/02/13  17:19:04  milind
+ * Initial revision
+ *
+ * Revision 1.1  1994/11/03  17:41:48  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+static char     ident[] = "@(#)$Header$";
+#include "xl-lex.h"
+#include "xl-sym.h"
+
+SYMTABPTR       GlobalEntryFind();
+
+extern char    *itoa();
+extern char    *AppendMap();
+extern char    *AppendMapIndex();
+#define IMPORTINITCODE 2
+#define MSGFILLCODE 11
+#define EPTOPACKIDCODE 12
+#define CHARECOUNT 14
+#define BOCCOUNT 15
+#define CHAREINITCODE 16
+#define READBUFFERCODE 17
+#define WRITEBUFFERCODE 18
+#define BUFFERSIZECODE 19
+#define PSEUDOCOUNT 22
+#define PSEUDOINITCODE 23
+
+/*
+ * code 4 for localptr, code 9 for function tables, code 3 for "main" table
+ * and structure init. calls, code 5 for "main" function and EP counts, code
+ * 13 for required variables. code 20,21 is reserved for global vars.
+ * 
+ * _CKx, where x is in 0..9 is for internally generated functions, x an alphabet
+ * signifies module name for structs. x=_ is ALWAYS followed by one of the
+ * above codes.
+ */
+
+/***** IMPORTANT NOTE : _CK_4localptr is CkLocalPtr in yaccspec *****/
+
+extern SYMTABPTR ImportModule, ModuleDefined;
+extern char    *Map();
+
+void            GenerateStruct();
+void            InitializeStruct();
+
+char           *CEPVAR = "_CK_13ChareEPCount";
+char           *TOTMSG = "_CK_13TotalMsgCount";
+char           *PACKMSG = "_CK_13PackMsgCount";
+char           *PACKOFFSET = "_CK_13PackOffset";
+char           *CkGenericAlloc = "GenericCkAlloc";
+char           *CkVarSizeAlloc = "MsgToStructTable";
+char           *REFSUFFIX = "_ref";
+char           *CkReadMsgTable = "_CK_ReadMsgTable";
+
+char           *CkSizeArray = "_CK_13SizeArray";
+char           *CkSizeArrayIndex = "_CK_13SizeArrayIndex";
+char           *CkCopyFromBuffer = "_CK_13CopyFromBuffer";
+char           *CkCopyToBuffer = "_CK_13CopyToBuffer";
+
+char           *CkPrefix = "_CK_";
+char           *CkPrefix_ = "_CK";
+char           *CkMainTable = "void _CK_3mainTable(ft,fi,cet,cei,bet,bei,cetimp,betimp,cetname,betname,cetchare,betchare)\nint *fi,*bei,*cei,*cetimp,*betimp;\nFNPTRTYPE ft,cet,bet;\nchar *cetname[], *betname[];\nint cetchare[], betchare[];\n";
+char           *CkMainMsgTableInit = "void _CK_3mainMessageTableInit(mt,emt,bocemt)\nMSG_STRUCT mt[];\nint emt[];\nint bocemt[];";
+char           *CkMainMsgPUAInit = "void _CK_3mainmsgpuainit(mt)\nMSG_STRUCT mt[];";
+char           *CkCallMsgFill = "_CK_3mainmsgpuainit(mt)";
+char           *CkMainEPtoMsgNo = "void _CK_3mainEPtoMsgNo(ept, bocept)\nint ept[], bocept[];";
+char           *CkCallEPFill = "_CK_3mainEPtoMsgNo(emt, bocemt)";
+char           *CkMainDataInit = "void _CK_3maindatainit()";
+char           *CkMainChareInit = "void _CK_3mainChareInit(ct,cname)\nint ct[];\nchar *cname[];\n";
+char           *CkMainPseudoInit = "void _CK_3mainPseudoInit(amt)\nPSEUDO_STRUCT amt[];";
+
+char           *CkMainCopyFromBuffer = "void _CK_3mainCopyFromBuffer()";
+char           *CkMainCopyToBuffer = "void _CK_3mainCopyToBuffer()";
+char           *CkMainBufferSize = "int _CK_5mainBufferSize(i)";
+/*
+ * char *CkMainDataInit="void _CK_3maindatainit(_CK_4localptr)\nvoid
+ * *dataptr;";
+ */
+char           *CkMainFCount = "int _CK_5mainFunctionCount()";
+char           *CkMainCECount = "int _CK_5mainChareEPCount()";
+char           *CkMainMainCECount = "int _CK_5mainMainChareEPCount()";
+char           *CkMainBECount = "int _CK_5mainBranchEPCount()";
+char           *CkMainMsgCount = "int _CK_5mainMessageCount()";
+char           *CkMainChareCount = "int _CK_5mainChareCount()";
+char           *CkMainPseudoCount = "int _CK_5mainPseudoCount()";
+char           *CkMainQEP = "int _CK_5mainQuiescenceEP()";
+char           *CkMainDataSize = "int _CK_5mainDataSize()\n{ return sizeof(main_Data); }\n\n";
+char           *CkMainCharm = "void _CK_3mainCharm(_CK_4NULL,_CK_4localptr,argc,argv)\nvoid *_CK_4NULL,*_CK_4localptr;\nint argc;\nchar *argv[];";
+char           *CkMainQuiescence = "void _CK_3mainQuiescence(_CK_4NULL,_CK_4localptr)\nvoid *_CK_4localptr,*_CK_4NULL;";
+char           *CKMAINDATAFUNCTION = "(_CK_4NULL,_CK_4localptr,argc,argv)";
+char           *CKMAINCHAREFUNCTION = "(_CK_4NULL,_CK_4localptr,argc,argv)";
+char           *CKMAINQUIESCENCEFUNCTION = "(_CK_4NULL,_CK_4localptr)";
+char           *FunctionType = "FUNCTION_PTR";
+char           *VoidFnPtr = "VOIDFNPTR";
+char           *FunctionPtrType = "FNPTRTYPE";
+
+FILE           *outh1, *outh2;
+FILE           *outh, *outh0;
+
+int             ALLMESSAGES;
+
+static int EmitComma;
+
+void 
+Indent(level)
+int             level;
+{
+       int             tabs, spaces, i;
+       outh = outh1;
+       tabs = level / 4;
+       spaces = level % 4;
+       for (i = 0; i < tabs; i++)
+               fprintf(outh, "\t");
+       for (i = 0; i < spaces; i++)
+               fprintf(outh, "  ");
+}
+
+void 
+RecursiveGenerateStruct(table, level)
+SYMTABPTR       table;
+int             level;
+{
+       if (table == NULL)
+               return;
+       RecursiveGenerateStruct(table->left, level);
+       RecursiveGenerateStruct(table->right, level);
+       if (!strcmp(table->name, " "))
+               return;
+       outh = outh1;
+       switch (table->idtype)
+       {
+       case BOCNAME:
+       case CHARENAME:
+               GenerateStruct(table->name, table->type->table, TRUE,
+                              CkPrefix, level);
+               Indent(level);
+               fprintf(outh, "int %s;\n", table->name);
+               break;
+       case PRIVATEFNNAME:
+               break;
+       case ACCNAME:
+       case MONONAME:
+       case MESSAGENAME:
+       case PUBLICFNNAME:
+       case ENTRYNAME:
+               Indent(level);
+               fprintf(outh, "int %s;\n", table->name);
+               break;
+       case FNNAME:
+               Indent(level);
+               fprintf(outh, "%s %s;\n", FunctionType, table->name);
+               Indent(level);
+               fprintf(outh, "int %s%s;\n", table->name, REFSUFFIX);
+       default:
+               break;
+       }
+}
+
+void 
+RecursiveInitializeStruct(table, level)
+SYMTABPTR       table;
+int             level;
+{
+       if (table == NULL)
+               return;
+       RecursiveInitializeStruct(table->left, level);
+       RecursiveInitializeStruct(table->right, level);
+       if (!strcmp(table->name, " "))
+               return;
+       outh = outh1;
+       switch (table->idtype)
+       {
+       case BOCNAME:
+       case CHARENAME:
+               InitializeStruct(table->name, table->type->table, TRUE,
+                              CkPrefix, level);
+               if(EmitComma)
+                       fprintf(outh,",");
+               fprintf(outh, "0 ");
+               EmitComma = 1;
+               break;
+       case PRIVATEFNNAME:
+               break;
+       case ACCNAME:
+       case MONONAME:
+       case MESSAGENAME:
+       case PUBLICFNNAME:
+       case ENTRYNAME:
+               if(EmitComma)
+                       fprintf(outh,",");
+               fprintf(outh, "0 ");
+               EmitComma = 1;
+               break;
+       case FNNAME:
+               if(EmitComma)
+                       fprintf(outh,",");
+               fprintf(outh, "_CkNullFunc, ");
+               fprintf(outh, "0 ");
+               EmitComma = 1;
+       default:
+               break;
+       }
+}
+
+void 
+GenerateStruct(name, table, ownflag, prefix, level)
+SYMTABPTR       table;
+int             ownflag;
+char           *prefix;
+int             level;
+{
+       if ((InPass1) || (table == NULL))
+               return;
+       outh = outh1;
+       if (!ownflag)
+               fprintf(outh, "extern ");
+       Indent(level);
+       if(level==0 && ownflag)
+               fprintf(outh, "struct %s%s_type {\n", prefix,name);
+       else
+               fprintf(outh, "struct {\n");
+
+       RecursiveGenerateStruct(table, level + 1);
+       Indent(level);
+       if(level==0 && ownflag)
+               fprintf(outh, "};\n", prefix, name);
+       else
+               fprintf(outh, "} %s%s;\n", prefix, name);
+       if (level == 0)
+               fprintf(outh, "\n");
+}
+
+/* added by milind 5/2/95 */
+void 
+InitializeStruct(name, table, ownflag, prefix, level)
+SYMTABPTR       table;
+int             ownflag;
+char           *prefix;
+int             level;
+{
+       if ((InPass1) || (table == NULL))
+               return;
+       outh = outh1;
+       if (!ownflag)
+               return;
+       if(level==0)
+       {
+               fprintf(outh,"extern _CkNullFunc();\n");
+               fprintf(outh,"struct %s%s_type %s%s  = {",prefix,name,
+                               prefix,name);
+               EmitComma = 0;
+       }
+       else
+       {
+               if(EmitComma)
+                       fprintf(outh,",");
+               fprintf(outh,"{");
+               EmitComma = 0;
+       }
+       RecursiveInitializeStruct(table, level + 1);
+       fprintf(outh, "}");
+       EmitComma = 1;
+       if (level == 0)
+               fprintf(outh, ";\n");
+}
+
+void 
+CreateStructures(table)
+SYMTABPTR       table;
+{
+       GenerateStruct(ModuleDefined->name, ModuleDefined->type->table, 1, CkPrefix_, 0);
+       InitializeStruct(ModuleDefined->name, ModuleDefined->type->table, 1, CkPrefix_, 0);
+}
+
+void 
+ImportStructInit(table, module)
+SYMTABPTR       table;
+char           *module;
+{
+       char           *temp, *dummy;
+       if (table == NULL)
+               return;
+
+       ImportStructInit(table->left, module);
+       ImportStructInit(table->right, module);
+       outh = outh2;
+       switch (table->idtype)
+       {
+       case BOCNAME:
+       case CHARENAME:
+               ImportStructInit(table->type->table, module);
+               break;
+       case FNNAME:
+               temp = ModulePrefix(module, table->name);
+               fprintf(outh, "  %s%s = ", temp, REFSUFFIX);
+               dummy = MyModulePrefix(module, table->name);
+               fprintf(outh, "%s%s;\n", dummy, REFSUFFIX);
+               fprintf(outh, "  %s = %s;\n", temp, dummy);
+               free(temp);
+               free(dummy);
+               break;
+       case PRIVATEFNNAME:
+               break;
+       case PUBLICFNNAME:
+       case ENTRYNAME:
+               temp = ModuleCharePrefix(module, table->charename->name,
+                                        table->name);
+               fprintf(outh, "  %s = ", temp);
+               free(temp);
+               temp = MyModuleCharePrefix(module, table->charename->name,
+                                          table->name);
+               fprintf(outh, "%s;\n", temp);
+               free(temp);
+               break;
+       default:
+               break;
+       }
+}
+
+void 
+CreateImportInitFunction()
+{
+       if (ModuleDefined == NULL)
+               error("Module Undefined? Something Wrong!", EXIT);
+       outh = outh2;
+       fprintf(outh, "void %s%d%s()\n{\n", CkPrefix, IMPORTINITCODE,
+               ModuleDefined->name);
+       ImportStructInit(ImportModule, ModuleDefined->name);
+       fprintf(outh, "}\n\n");
+}
+
+/* added by milind */
+
+void CreateImportModuleComponentFill();
+
+void 
+CreateOwnImportInitFunction()
+{
+       if (ModuleDefined == NULL)
+               error("Module Undefined? Something Wrong!", EXIT);
+       outh = outh2;
+       fprintf(outh, "void %s%s_struct_init()\n{\n", CkPrefix,
+               ModuleDefined->name);
+       ImportStructInit(ImportModule, ModuleDefined->name);
+       CreateImportModuleComponentFill(ImportModule, ModuleDefined->name, 
+                                       BOCNAME);
+       CreateImportModuleComponentFill(ImportModule, ModuleDefined->name, 
+                                       CHARENAME);
+       CreateImportModuleComponentFill(ImportModule, ModuleDefined->name, 
+                                       ENTRYNAME);
+       CreateImportModuleComponentFill(ImportModule, ModuleDefined->name, 
+                                       MESSAGENAME);
+       CreateImportModuleComponentFill(ImportModule, ModuleDefined->name, 
+                                       ACCNAME);
+       CreateImportModuleComponentFill(ImportModule, ModuleDefined->name, 
+                                       MONONAME);
+       CreateImportModuleComponentFill(ImportModule, ModuleDefined->name, 
+                                       TABLENAME);
+       CreateImportModuleComponentFill(ImportModule, ModuleDefined->name,
+                                       PRIVATEFNNAME);
+       CreateImportModuleComponentFill(ImportModule, ModuleDefined->name,
+                                       PUBLICFNNAME);
+       CreateImportModuleComponentFill(ImportModule, ModuleDefined->name,
+                                       FNNAME);
+       fprintf(outh, "}\n\n");
+}
+
+void 
+CallOtherModuleInits(table)
+SYMTABPTR       table;
+{
+       if (table == NULL)
+               return;
+       CallOtherModuleInits(table->left);
+       CallOtherModuleInits(table->right);
+       outh = outh2;
+       if ((table->idtype == MODULENAME) && (table->declflag == IMPORTED))
+       {
+               fprintf(outh, "\n  %s%s_init();", CkPrefix, table->name);
+       }
+}
+
+void
+CreateOwnMsgInitFunction(table, name)
+SYMTABPTR       table;
+char           *name;
+{
+       char           *temp;
+       if (table == NULL)
+               return;
+       CreateOwnMsgInitFunction(table->left, name);
+       CreateOwnMsgInitFunction(table->right, name);
+
+       if (table->idtype != MESSAGENAME)
+               return;
+       temp = MyModulePrefix(name, table->name);
+       fprintf(outh, "  %s = registerMsg(", temp);
+       fprintf(outh, "\"%s\",",table->name);
+       /* AllocFunction */
+       if (table->localid <= 0)
+       {
+               fprintf(outh, "(%s) %s,", FunctionType, CkGenericAlloc);
+       }
+       else
+       {
+               fprintf(outh, "(%s) %s,", FunctionType, 
+                       Map(name, table->name, "ALLOC"));
+       }
+       /* Pack and Unpack Functions */
+       if (table->localid == 0)
+       {
+               fprintf(outh, "NULL,NULL,");
+       }
+       else
+       {
+               fprintf(outh, "(%s) %s,", FunctionType,
+                       Map(name, itoa(table->msgno), "PACK"));
+               fprintf(outh, "(%s) %s,",
+                       FunctionType, Map(name, itoa(table->msgno), "UNPACK"));
+       }
+       fprintf(outh, "sizeof(%s)); \n", table->name);
+       free(temp);
+}
+
+void
+CreateOwnChareInitFunction(table)
+SYMTABPTR       table;
+{
+       char           *temp;
+
+       if (table == NULL)
+               return;
+
+       CreateOwnChareInitFunction(table->left);
+       CreateOwnChareInitFunction(table->right);
+
+       if ((table->idtype != CHARENAME) && (table->idtype != BOCNAME))
+               return;
+
+       temp = MyModulePrefix(table->modname->name, table->name);
+       fprintf(outh, "  %s = ", temp);
+       fprintf(outh, "registerChare(");
+       fprintf(outh, "\"%s\",", table->name);
+       fprintf(outh, "sizeof(%s_Data),",table->name);
+       fprintf(outh, "(%s) NULL);\n",FunctionType);
+       free(temp);
+}
+
+void
+CreateOwnEpInitFunction(table, module)
+SYMTABPTR       table;
+char           *module;
+{
+       char           *temp, *temp2;
+       SYMTABPTR       dummy;
+       char *eptype;
+
+       if (table == NULL)
+               return;
+
+       CreateOwnEpInitFunction(table->left, module);
+       CreateOwnEpInitFunction(table->right, module);
+
+       outh = outh2;
+
+       if((table->idtype == BOCNAME) || (table->idtype==CHARENAME))
+       {
+               CreateOwnEpInitFunction(table->type->table, module);
+               return;
+       }
+
+       if(table->idtype != ENTRYNAME)
+               return;
+
+       if (table->charename->idtype == BOCNAME)
+               eptype = "registerBocEp";
+       else
+               eptype = "registerEp";
+
+       temp = MyModuleCharePrefix(module,
+                      table->charename->name, table->name);
+       fprintf(outh, "%s = ", temp);
+       fprintf(outh, "%s(", eptype);
+       temp = Map(module, table->charename->name, table->name);
+       fprintf(outh, "\"%s\",", temp);
+       fprintf(outh, "(%s) %s,", FunctionType, temp);
+       fprintf(outh, "CHARM,");
+       /* put msg index here */
+       dummy = (SYMTABPTR) table->type;
+       if (dummy)
+       {
+               if(!strcmp(module, dummy->modname->name))
+                       temp2 = MyModulePrefix(module,dummy->name);
+               else
+                       temp2 = ModulePrefix(dummy->modname->name, dummy->name);
+       }
+       else
+               temp2 = "0";
+       fprintf(outh, "%s,", temp2);
+       /* put chare index here */
+       temp = MyModulePrefix(table->modname->name, table->charename->name);
+       fprintf(outh, "%s);\n",temp);
+       if(!dummy)
+       {
+               fprintf(outh, "\n /* Register Main Chare */\n");
+               fprintf(outh, "  registerMainChare(");
+               fprintf(outh, "%s,",temp);
+               temp = MyModuleCharePrefix(module,
+                               table->charename->name, table->name);
+               fprintf(outh, "%s,CHARM);\n",temp);
+       }
+       free(temp);
+}
+
+void
+CreateOwnFuncInitFunction(table, module)
+SYMTABPTR       table;
+char           *module;
+{
+       char           *temp, *temp2;
+
+       if (table == NULL)
+               return;
+
+       CreateOwnFuncInitFunction(table->left, module);
+       CreateOwnFuncInitFunction(table->right, module);
+
+       outh = outh2;
+
+       if((table->idtype == BOCNAME) || (table->idtype==CHARENAME))
+       {
+               CreateOwnFuncInitFunction(table->type->table, module);
+               return;
+       }
+       
+       if((table->idtype != FNNAME) && (table->idtype!=PUBLICFNNAME))
+               return;
+       if(table->idtype == FNNAME)
+       {
+               temp = MyModulePrefix(module, table->name);
+               fprintf(outh, "  %s%s = registerFunction(", temp, REFSUFFIX);
+               fprintf(outh, "(%s) %s);\n", FunctionType, table->name);
+               fprintf(outh, "  %s = (%s) %s;\n", temp, FunctionType,
+                       table->name);
+               free(temp);
+       }
+       else
+       {
+               temp = Map(module, table->charename->name, table->name);
+               temp2 = MyModuleCharePrefix(module, table->charename->name
+                                          ,table->name);
+               fprintf(outh, "  %s = registerFunction((%s) %s);\n", temp2,
+                       FunctionType, temp);
+               free(temp2);
+       }
+}
+
+FillOwnCopyFromBuffer(table, name)
+SYMTABPTR       table;
+char           *name;
+{
+       char           *temp;
+       if (table == NULL)
+               return;
+       FillOwnCopyFromBuffer(table->left, name);
+       FillOwnCopyFromBuffer(table->right, name);
+
+       if (table->idtype == READONLYVAR)
+               fprintf(outh, "  %s(&%s,sizeof(%s));\n",
+                       CkCopyFromBuffer, AppendMap(name, table->name), 
+                       AppendMap(name, table->name));
+       if (table->idtype == READONLYARRAY)
+               fprintf(outh, "  %s(%s,sizeof(%s));\n",
+                       CkCopyFromBuffer, AppendMap(name, table->name), 
+                       AppendMap(name, table->name));
+       if (table->idtype == READONLYMSG)
+       {
+               temp = MakeString(AppendMapIndex(name, table->name));
+               fprintf(outh, "  temp = (void **)&(%s);\n", 
+                       AppendMap(name, table->name));
+               fprintf(outh, "  *temp = _CK_ReadMsgTable[%s];\n", temp);
+               free(temp);
+       }
+}
+
+FillOwnCopyToBuffer(table, name)
+SYMTABPTR       table;
+char           *name;
+{
+       if (table == NULL)
+               return;
+       FillOwnCopyToBuffer(table->left, name);
+       FillOwnCopyToBuffer(table->right, name);
+
+       if (table->idtype == READONLYVAR)
+               fprintf(outh, "  %s(&%s,sizeof(%s));\n",
+                       CkCopyToBuffer, AppendMap(name, table->name), 
+                       AppendMap(name, table->name));
+       if (table->idtype == READONLYARRAY)
+               fprintf(outh, "  %s(%s,sizeof(%s));\n",
+                       CkCopyToBuffer, AppendMap(name, table->name), 
+                       AppendMap(name, table->name));
+}
+
+CreateOwnCopyFromBuffer()
+{
+       outh = outh2;
+
+       fprintf(outh, "%s%s_CopyFromBuffer(_CK_ReadMsgTable)\n",
+                       CkPrefix,
+                       ModuleDefined->name);
+       fprintf(outh, "void **_CK_ReadMsgTable;\n{\n");
+       fprintf(outh, "  void **temp;\n\n");
+       FillOwnCopyFromBuffer(ModuleDefined->type->table, ModuleDefined->name);
+       fprintf(outh, "}\n\n");
+}
+
+CreateOwnCopyToBuffer()
+{
+       outh = outh2;
+
+       fprintf(outh, "%s%s_CopyToBuffer()\n{\n",CkPrefix, ModuleDefined->name);
+       FillOwnCopyToBuffer(ModuleDefined->type->table, ModuleDefined->name);
+       fprintf(outh, "}\n\n");
+}
+
+FillOwnBufferSize(table, name)
+SYMTABPTR       table;
+char           *name;
+{
+       if (table == NULL)
+               return;
+       FillOwnBufferSize(table->left, name);
+       FillOwnBufferSize(table->right, name);
+
+       if ((table->idtype == READONLYVAR) || (table->idtype == READONLYARRAY))
+               fprintf(outh, "  count += sizeof(%s);\n", 
+                       AppendMap(name, table->name));
+
+       if (table->idtype == READONLYMSG)
+       {
+               fprintf(outh, "  %s = registerReadOnlyMsg();\n", 
+                       AppendMapIndex(name, table->name));
+               fprintf(outh1, "static int %s;\n", AppendMapIndex(name, table->name));
+       }
+}
+
+OwnPseudoTableFill(table)
+SYMTABPTR       table;
+{
+       char           *temp;
+       if (table == NULL)
+               return;
+       OwnPseudoTableFill(table->left);
+       OwnPseudoTableFill(table->right);
+
+       switch(table->idtype)
+       {
+       case ACCNAME:
+               temp = MyModulePrefix(table->modname->name, table->name);
+               fprintf(outh, "  %s = registerAccumulator(\"%s\",",temp,
+                               table->name);
+               fprintf(outh, "(%s)%s,",FunctionType,
+                   Map(table->modname->name, itoa(table->msgno), "INIT"));
+               fprintf(outh, "(%s)%s,",FunctionType, 
+                   Map(table->modname->name, itoa(table->msgno), "INCREMENT"));
+               fprintf(outh, "(%s)%s,",FunctionType, 
+                   Map(table->modname->name, itoa(table->msgno), "COMBINE"));
+               fprintf(outh, "CHARM);\n");
+               free(temp);
+               break;
+       case MONONAME:
+               temp = MyModulePrefix(table->modname->name, table->name);
+               fprintf(outh, "  %s = registerMonotonic(\"%s\",",temp,
+                               table->name);
+               fprintf(outh, "(%s)%s,", FunctionType,
+                       Map(table->modname->name, itoa(table->msgno), "INIT"));
+               fprintf(outh, "(%s)%s,",FunctionType, 
+                       Map(table->modname->name,itoa(table->msgno), "UPDATE"));
+               fprintf(outh, "CHARM);\n");
+               free(temp);
+               break;
+       case TABLENAME:
+               temp = AppendMap(CurrentModule->name, table->name);
+               fprintf(outh, "  %s = registerTable(", temp);
+               fprintf(outh, "\"%s\",(%s)NULL, (%s)", table->name, 
+                       FunctionType, FunctionType);
+               if(table->msgno)
+                       fprintf(outh, "%s);\n",
+                               Map(table->modname->name, itoa(table->msgno), 
+                                       "HASH"));
+               else
+                       fprintf(outh, "NULL);\n");
+               free(temp);
+               break;
+       default:
+               break;
+       }
+}
+
+void
+CreateOwnModuleInitFunction()
+{
+       outh = outh2;
+       fprintf(outh, "%s%s_init()\n",CkPrefix,ModuleDefined->name);
+       fprintf(outh, "{\n  static int visited=0;\n  int count;\n\n");
+       fprintf(outh, "  if (visited) return; else visited=1;\n");
+
+       fprintf(outh, "\n  /*Register Messages*/\n");
+       CreateOwnMsgInitFunction(ModuleDefined->type->table, 
+                       ModuleDefined->name);
+
+       fprintf(outh, "\n  /*Register Chares*/\n");
+       CreateOwnChareInitFunction(ModuleDefined->type->table);
+
+       fprintf(outh, "\n  /*Register EntryPoints*/\n");
+       CreateOwnEpInitFunction(ModuleDefined->type->table, 
+                               ModuleDefined->name);
+
+       fprintf(outh, "\n  /*Register Functions*/\n");
+       CreateOwnFuncInitFunction(ModuleDefined->type->table, 
+                               ModuleDefined->name);
+
+       fprintf(outh, "\n  /*Register Monotonics, Tables and Accumulators*/\n");
+       OwnPseudoTableFill(ModuleDefined->type->table);
+
+       fprintf(outh, "\n  /*Register Read Only Var & Msg*/\n");
+       fprintf(outh, "  count = 0;\n");
+       FillOwnBufferSize(ModuleDefined->type->table, ModuleDefined->name);
+       fprintf(outh, "  registerReadOnly(count,");
+       fprintf(outh, "(%s)%s%s_CopyFromBuffer,", FunctionType,CkPrefix,
+                       ModuleDefined->name);
+       fprintf(outh, "(%s)%s%s_CopyToBuffer);\n", FunctionType,CkPrefix,
+                       ModuleDefined->name);
+
+       fprintf(outh, "\n  /*Call own import struct Init*/\n");
+       fprintf(outh, "  %s%s_struct_init();\n", CkPrefix,
+               ModuleDefined->name);
+
+       fprintf(outh, "\n  /*Call Other module Inits*/\n");
+       CallOtherModuleInits(StackBase->tableptr);
+
+       fprintf(outh, "\n}\n\n");
+}
+
+/* end addition --milind */
+
+void 
+CreateImportModuleComponentFill(table, name, modcomponent)
+char           *name;
+SYMTABPTR       table;
+int             modcomponent;
+{
+       char           *temp1, *temp2;
+       if (table == NULL)
+               return;
+       CreateImportModuleComponentFill(table->left, name, modcomponent);
+       CreateImportModuleComponentFill(table->right, name, modcomponent);
+
+       if (table->idtype == modcomponent)
+       {
+               fprintf(outh, "  %s = %s;\n", temp1 = ModulePrefix(name, table->name),
+                       temp2 = MyModulePrefix(name, table->name));
+               free(temp1);
+               free(temp2);
+       }
+}
+
+void 
+GenerateOuth()
+{
+       CreateStructures(StackBase->tableptr);
+       CreatePUAFunctions(ModuleDefined->type->table);
+       CreateImportInitFunction();
+       /* addition by milind */
+       CreateOwnImportInitFunction();
+       CreateOwnCopyFromBuffer();
+       CreateOwnCopyToBuffer();
+       CreateOwnModuleInitFunction();
+       /* end addition -- milind */
+}
+
+/*****************************************************************************/
+/* Generating Alloc, Pack and Unpack Functions                      */
+/*****************************************************************************/
+
+CreatePUAFunctions(table)
+SYMTABPTR       table;
+{
+       if (table == NULL)
+               return;
+       CreatePUAFunctions(table->left);
+       CreatePUAFunctions(table->right);
+
+       if (!((table->idtype == MESSAGENAME) && (table->localid > 0)))
+               return;
+
+       CreateAllocFunction(table);
+       if (table->userpack == 0)
+       {
+               CreatePackFunction(table);
+               CreateUnPackFunction(table);
+       }
+}
+
+CreatePackFunction(table)
+SYMTABPTR       table;
+{
+       SYMTABPTR       sym, node;
+       char           *temp;
+       outh = outh2;
+       fprintf(outh, "static %s(in,out,len)\n", Map(table->modname->name, itoa(table->msgno), "PACK"));
+       fprintf(outh, "%s *in,**out;\nint *len;\n{ *len = 0;\n", table->name);
+       fprintf(outh, "  *out = in;\n");
+       sym = table->type->table->next;
+       while (sym != table->type->table)
+       {
+               if (sym->idtype == VARSIZENAME)
+               {
+                       node = (SYMTABPTR) sym->type;
+                       if ((node->idtype != SYSTEMTYPENAME) && (strcmp(node->modname->name,
+                                                     ModuleDefined->name)))
+                               temp = Map(node->modname->name, "0", node->name);
+                       else
+                               temp = node->name;
+                       fprintf(outh, "  in->%s = (%s *) ((char *)in->%s - ((char *)&(in->%s)));\n",
+                               sym->name, temp, sym->name, sym->name);
+               }
+               sym = sym->next;
+       }
+       fprintf(outh, "}\n\n");
+}
+
+CreateUnPackFunction(table)
+SYMTABPTR       table;
+{
+       SYMTABPTR       sym, node;
+       char           *temp;
+       outh = outh2;
+       fprintf(outh, "static %s(in,out)\n", Map(table->modname->name, itoa(table->msgno), "UNPACK"));
+       fprintf(outh, "%s *in,**out;\n{ *out = in;\n", table->name);
+       sym = table->type->table->next;
+       while (sym != table->type->table)
+       {
+               if (sym->idtype == VARSIZENAME)
+               {
+                       node = (SYMTABPTR) sym->type;
+                       if ((node->idtype != SYSTEMTYPENAME) && (strcmp(node->modname->name,
+                                                     ModuleDefined->name)))
+                               temp = Map(node->modname->name, "0", node->name);
+                       else
+                               temp = node->name;
+                       fprintf(outh, "  in->%s = (%s *) ((char *)(&(in->%s)) + (int)in->%s);\n",
+                               sym->name, temp, sym->name, sym->name);
+               }
+               sym = sym->next;
+       }
+       fprintf(outh, "}\n\n");
+}
+
+CreateAllocFunction(table)
+SYMTABPTR       table;
+{
+       SYMTABPTR       sym, node;
+       int             count = 0;
+       char           *name;
+       outh = outh2;
+       fprintf(outh, "static void *%s(msgno,size,prio,array)\nint msgno,size,prio,array[];\n",
+               Map(table->modname->name, table->name, "ALLOC"));
+       fprintf(outh, "{ int totsize=0;\n  int temp,dummy,sarray[%d];\n", table->localid);
+       fprintf(outh, "  %s *ptr;\n", table->name);
+       fprintf(outh, "\n  totsize = temp = (size%%_CK_VARSIZE_UNIT)?_CK_VARSIZE_UNIT*((size+_CK_VARSIZE_UNIT)/_CK_VARSIZE_UNIT):size;\n");
+       sym = table->type->table->next;
+       while (sym != table->type->table)
+       {
+               if (sym->idtype == VARSIZENAME)
+               {
+                       node = (SYMTABPTR) sym->type;
+                       if ((node->idtype != SYSTEMTYPENAME) && (strcmp(node->modname->name,
+                                                     ModuleDefined->name)))
+                               name = Map(node->modname->name, "0", node->name);
+                       else
+                               name = node->name;
+                       fprintf(outh, "  size = sizeof(%s)*array[%d];\n", name, count);
+                       fprintf(outh, "\n  dummy = (size%%_CK_VARSIZE_UNIT)?_CK_VARSIZE_UNIT*((size+_CK_VARSIZE_UNIT)/_CK_VARSIZE_UNIT):size;\n");
+                       fprintf(outh, "  sarray[%d]=dummy;\n", count++);
+                       fprintf(outh, "  totsize += dummy;\n");
+               }
+               sym = sym->next;
+       }
+       fprintf(outh, "  ptr = (%s *)%s(msgno,totsize,prio);\n", table->name, CkGenericAlloc);
+       sym = table->type->table->next;
+       count = 0;
+       fprintf(outh, "\n  dummy=temp;\n");
+       while (sym != table->type->table)
+       {
+               if (sym->idtype == VARSIZENAME)
+               {
+                       node = (SYMTABPTR) sym->type;
+                       if ((node->idtype != SYSTEMTYPENAME) && (strcmp(node->modname->name,
+                                                     ModuleDefined->name)))
+                               name = Map(node->modname->name, "0", node->name);
+                       else
+                               name = node->name;
+                       fprintf(outh, "  ptr->%s = (%s *)((char *)ptr + dummy);\n",
+                               sym->name, name);
+                       fprintf(outh, "  dummy += sarray[%d];\n", count++);
+               }
+               sym = sym->next;
+       }
+
+       fprintf(outh, "  return((void *)ptr);\n");
+       fprintf(outh, "}\n\n");
+}
diff --git a/src/xlat/xl-parse.c b/src/xlat/xl-parse.c
new file mode 100644 (file)
index 0000000..5f98d8a
--- /dev/null
@@ -0,0 +1,208 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-05 18:52:05  brunner
+ * Reorganized file structure
+ *
+ * Revision 1.1  1994/11/03  17:41:51  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+static char ident[] = "@(#)$Header$";
+
+#include "xl-lex.h"
+#include "xl-sym.h"
+
+extern char *calloc();
+SYMTABPTR CheckInsert();
+extern TYPEPTR SetType();
+
+char *GetMem(n)
+int n;
+{ char *dummy;
+
+  dummy=calloc(n,sizeof(char));
+  if (dummy==NULL) error("Out of Memory in GetMem()",EXIT);
+
+  return(dummy);
+}
+
+LISTPTR GetListNode(eleptr)
+YSNPTR eleptr;
+{ LISTPTR dummy;
+
+  dummy=(LISTPTR)calloc(1,sizeof(struct listnode));
+  if (dummy==NULL) error("Out of Memory in GetListNode()",EXIT);
+  
+  dummy->next=dummy->prev=dummy;
+  dummy->ysn=eleptr;
+  return(dummy);
+}
+
+void InsertNode(listptr,eleptr)
+LISTPTR listptr;
+YSNPTR eleptr;
+{ LISTPTR dummy;
+
+  if (listptr==NULL) error("InsertNode() : Following NULL",EXIT);
+  listptr->prev->next=dummy=GetListNode(eleptr);
+  dummy->next=listptr;
+  dummy->prev=listptr->prev;
+  listptr->prev=dummy;
+}
+
+YSNPTR GetYSN()
+{ YSNPTR dummy;
+
+  dummy=(YSNPTR)calloc(1,sizeof(struct ysn));
+  dummy->idtype=UNDEFINED;
+  dummy->listptr=NULL;
+  dummy->string=NULL;
+  dummy->ysn=NULL;
+  dummy->type=NULL;
+  dummy->table=NULL;
+  dummy->count=0;
+  dummy->modstring=NULL;
+  return(dummy);
+}
+
+typedef struct mapnode
+{ char *module;
+  char *chare;
+  char *name;
+  char *mappedname;
+  struct mapnode *next;
+  int  mapid;
+} *MAPPTR;
+
+MAPPTR MapHead;
+
+MAPPTR GetMapNode(module,chare,name)
+char *module,*chare,*name;
+{ MAPPTR dummy;
+
+  dummy=(MAPPTR)calloc(1,sizeof(struct mapnode));
+  if (dummy==NULL) error("Out of Memory in GetMapNode()",EXIT);
+
+  if (module!=NULL) dummy->module=MakeString(module); else dummy->module=NULL;
+  if (chare!=NULL) dummy->chare=MakeString(chare); else dummy->chare=NULL;
+  if (name!=NULL) dummy->name=MakeString(name); else dummy->name=NULL;
+  dummy->mappedname=NULL;
+  dummy->mapid = -1;dummy->next=NULL;
+
+  return(dummy);
+}
+
+void InitMapHead()
+{ MapHead=GetMapNode(NULL,NULL,NULL); }
+
+MAPPTR SearchMap(module,chare,name)
+{ MAPPTR dummy;
+
+  dummy=MapHead;
+  while (dummy!=NULL)
+  { if (samename(module,dummy->module) &&
+       (samename(chare,dummy->chare)) &&
+       (samename(name,dummy->name)))
+       return(dummy);
+    else dummy=dummy->next;
+  }
+  return(NULL);
+}
+
+int samename(s,t)
+char *s,*t;
+{ if (s==t) return(TRUE);
+  if ((s==NULL)||(t==NULL)) return(FALSE);
+  return(!strcmp(s,t));
+}
+
+MAPPTR NewMap(module,chare,name)
+char *module,*chare,*name;
+{ MAPPTR dummy;
+  char   string[2000];
+  dummy=GetMapNode(module,chare,name);
+  dummy->mapid=FUNCTIONCOUNT++;
+  sprintf(string,"%s%d%s",CkPrefix_,dummy->mapid,name);
+  dummy->mappedname=MakeString(string);
+  dummy->next=MapHead->next;MapHead->next=dummy;
+  return(dummy);
+}
+  
+char *Map(module,chare,name)
+char *module,*name,*chare;
+{ MAPPTR dummy;
+
+  dummy=SearchMap(module,chare,name);
+  if (dummy==NULL) dummy=NewMap(module,chare,name);
+  return(dummy->mappedname);
+}
+
+/* From end of yaccspec */
+
+
+void RestoreCurrentTable()
+{ if (StackTop!=StackBase) { CurrentTable=StackTop->tableptr; return; }
+  if (CurrentChare!=NULL)  { CurrentTable=CurrentChare->type->table; return; }
+  if (CurrentModule!=NULL) { CurrentTable=CurrentModule->type->table; return; } 
+  CurrentTable=NULL;
+}
+
+void SetIdList(type,listptr,name,localid)
+TYPEPTR type;
+LISTPTR listptr;
+int name,localid;
+{ LISTPTR ptr;
+  SYMTABPTR worksymtab;
+  int i=0;
+
+  ptr=listptr;
+  if ((type==NULL)||(ptr==NULL)) return;
+
+  do
+  { if (ptr->ysn->string!=NULL)
+       { worksymtab=CheckInsert(ptr->ysn->string,CurrentTable);
+         worksymtab->idtype=name;
+         worksymtab->localid=localid;
+         worksymtab->ysn=ptr->ysn;
+         if ((ptr->ysn->ysn!=NULL) &&(ptr->ysn->ysn->idtype==FUNCTIONTYPE))
+               worksymtab->idtype=FNNAME;
+         worksymtab->type=SetType(type);
+         if (type->declflag==NOTDECLARED)
+               { worksymtab->type=type->type;
+                 type->type=(TYPEPTR)worksymtab;
+               }
+       }
+    ptr=ptr->next;
+    if (i) free(ptr->prev); else i++;
+  } while (ptr!=listptr);
+  free(listptr);
+}
+
+int CheckDeclaration(newtable,oldtable)
+SYMTABPTR newtable,oldtable;
+{ int i;
+
+  if (oldtable==NULL) return(0);
+  if (CheckDeclaration(newtable,oldtable->left))
+       return(1);
+  if (CheckDeclaration(newtable,oldtable->right))
+       return(1);
+  
+  FindInTable(newtable,oldtable->name,&i);
+  return(i);
+}
+
diff --git a/src/xlat/xl-rdtok.c b/src/xlat/xl-rdtok.c
new file mode 100644 (file)
index 0000000..e2f102a
--- /dev/null
@@ -0,0 +1,276 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-05 18:52:05  brunner
+ * Reorganized file structure
+ *
+ * Revision 1.2  1995/04/23  18:30:18  milind
+ * Changed list of keywords to include Cmi functions.
+ *
+ * Revision 1.1  1994/11/03  17:41:53  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+static char ident[] = "@(#)$Header$";
+#include "xl-lex.h"
+#include "xl-sym.h"
+
+struct token TokenData[]={
+{ "chare", 257 },
+{ "main", 258 },
+{ "message", 259 },
+{ "entry", 260 },
+{ "private", 261 },
+{ "DataInit", 262 },
+{ "CharmInit", 263 },
+{ "QUIESCENCE", 264 },
+{ "module", 265 },
+{ "BranchOffice", 266 },
+{ "readonly", 267 },
+{ "monotonic", 268 },
+{ "table", 269 },
+{ "accumulator", 270 },
+{ "static", 271 },
+{ "pack", 272 },
+{ "unpack", 273 },
+{ "varSize", 274 },
+{ "function", 275 },
+{ "branch", 276 },
+{ "sizeof", 277 },
+{ "auto", 278 },
+{ "break", 279 },
+{ "case", 280 },
+{ "char", 281 },
+{ "const", 282 },
+{ "continue", 283 },
+{ "default", 284 },
+{ "do", 285 },
+{ "double", 286 },
+{ "else", 287 },
+{ "enum", 288 },
+{ "extern", 289 },
+{ "float", 290 },
+{ "for", 291 },
+{ "goto", 292 },
+{ "if", 293 },
+{ "int", 294 },
+{ "long", 295 },
+{ "register", 296 },
+{ "return", 297 },
+{ "short", 298 },
+{ "signed", 299 },
+{ "struct", 300 },
+{ "switch", 301 },
+{ "typedef", 302 },
+{ "union", 303 },
+{ "unsigned", 304 },
+{ "void", 305 },
+{ "while", 306 },
+{ "interface", 307 },
+{ "ChareIDType", 308 },
+{ "EntryPointType", 309 },
+{ "PeNumType", 310 },
+{ "PackIDType", 311 },
+{ "WriteOnceID", 312 },
+{ "PVECTOR", 313 },
+{ "ChareNumType", 314 },
+{ "EntryNumType", 315 },
+{ "BOOLEAN", 316 },
+{ "PrivateCall", 359 },
+{ "BranchCall", 360 },
+{ "public", 362 },
+{ "FunctionNameToRef", 363 },
+{ "CkAllocMsg", 364 },
+{ "CkAllocPrioMsg", 365 },
+{ "ReadMsgInit", 366 },
+{ "Accumulate", 367 },
+{ "NewValue", 368 },
+{ "NULL_VID", 0 },
+{ "NULL_PE", 0 },
+{ "AccIDType", 369 },
+{ "MonoIDType", 370 },
+{ "DummyMsg", 371 },
+{ "FunctionRefType", 372 },
+{ "FUNCTION_PTR", 373 },
+{ "FunctionRefToName", 374 },
+{ "implicit", 375 },
+{ "CkBlockedRecv", 376 },
+{ "dag", 377 },
+{ "MATCH", 378 },
+{ "AUTOFREE", 379 },
+{ "when", 380 },
+{ "ChareCall", 381 },
+{ "ChareNameType", 382 },
+{ "export_to_C", 383 },
+{ 0, 0 }
+};
+
+struct token KeyData[]={
+{ "extern", 0 },
+{ "auto", 0 },
+{ "register", 0 },
+{ "static", 0 },
+{ "function", 0 },
+{ "sizeof", 0 },
+{ "break", 0 },
+{ "case", 0 },
+{ "const", 0 },
+{ "continue", 0 },
+{ "default", 0 },
+{ "do", 0 },
+{ "else", 0 },
+{ "for", 0 },
+{ "goto", 0 },
+{ "if", 0 },
+{ "return", 0 },
+{ "switch", 0 },
+{ "while", 0 },
+{ "PrivateCall", 0 },
+{ "BranchCall", 0 },
+{ "ReadMsgInit", 0 },
+{ 0,0 }
+};
+
+char *SyscallData[]=
+{
+"_CK_CreateChare",
+"SendMsg",
+"MyChareID",
+"MyParentID",
+"MainChareID",
+"CkAlloc",
+"CkAllocMsg",
+"CkAllocPrioMsg",
+"CkFree",
+"CkFreeMsg",
+"CkPrintf",
+"CkScanf",
+"ChareExit",
+"CkTimer",
+"CkUTimer",
+"CkHTimer",
+"CkExit",
+"CkCopyMsg",
+"CmiTimer",
+"CmiNumPe",
+"CmiMyPe",
+"_CK_CreateBoc",
+"_CK_SendMsgBranch",
+"_CK_BroadcastMsgBranch",
+"_CK_MyBocNum",
+"ReadValue",
+"ReadInit",
+"_CK_MyBranchID",
+"_CK_CreateAcc",
+"_CK_CreateMono",
+"CollectValue",
+"MonoValue",
+"_CK_Find",
+"_CK_Delete",
+"_CK_Insert",
+"WriteOnce",
+"DerefWriteOnce",
+"CkPriorityPtr",
+"atoi",
+"itoa",
+"isalpha",
+"isdigit",
+"islower",
+"isspace",
+"isupper",
+"rand",
+"random",
+"srand",
+"srandom",
+"strcmp",
+"strlen",
+"strsave",
+"power",
+"lower",
+"CkAllocPrioBuffer",
+"CkAllocBuffer",
+"McUTimer",
+"McHTimer",
+"CkAllocPackBuffer",
+"CmiSpanTreeRoot",
+"CmiSpanTreeParent",
+"CmiSpanTreeChild",
+"CmiNumSpanTreeChildren",
+"fprintf",
+"fscanf",
+"fclose",
+"SetRefNumber",
+"GetRefNumber",
+"StartQuiescence",
+"IsChareLocal",
+"GetChareDataPtr",
+"McTotalNumPe",
+0
+};
+
+#define TRUE 1
+#define FALSE 0
+
+#define SYSCALLS 100
+
+struct token *TokenArray;
+int           TotalTokens=0;
+
+struct token *KeyArray;
+int           TotalKeys=0;
+
+void ReadTokens()
+{
+TokenArray = TokenData;
+for (TotalTokens=0; TokenArray[TotalTokens].name; TotalTokens++);
+}
+
+void ReadKeys()
+{
+KeyArray = KeyData;
+for (TotalKeys=0; KeyArray[TotalKeys].name; TotalKeys++);
+}
+
+void InsertSysCalls()
+{
+  int i;
+  SYMTABPTR worksymtab;
+
+  for (i=0; SyscallData[i]; i++)
+    {
+    worksymtab = Insert(SyscallData[i],CurrentTable);
+    worksymtab->idtype = SYSCALLNAME;
+    worksymtab->type = INTPTR;
+    }
+}
+
+int SearchKey(key)
+char *key;
+{ int i;
+
+  for (i=0;i<TotalTokens;i++)
+       if (!strcmp(key,TokenArray[i].name)) return(TokenArray[i].tokenvalue);
+  return(-1);
+}
+
+int IsKey(tokenstring)
+char *tokenstring;
+{ int i;
+
+  for (i=0;i<TotalKeys;i++)
+       if (!strcmp(tokenstring,KeyArray[i].name)) return(TRUE);
+  return(FALSE);
+}
+
+
diff --git a/src/xlat/xl-srch.c b/src/xlat/xl-srch.c
new file mode 100644 (file)
index 0000000..1bb7db4
--- /dev/null
@@ -0,0 +1,397 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-05 18:52:05  brunner
+ * Reorganized file structure
+ *
+ * Revision 1.1  1994/11/03  17:41:56  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+static char ident[] = "@(#)$Header$";
+#include "xl-lex.h"
+#include "xl-sym.h"
+
+extern int InPass1;
+extern int IMPORTFLAG,ImportLevel;
+char *CkGlobalFunctionTable="_CK_9_GlobalFunctionTable[";
+extern char *Map();
+extern char *REFSUFFIX;
+extern int FNNAMETOREFFLAG;
+extern int READMSGINITFLAG;
+
+char *AppendMap();
+char *AppendMapIndex();
+char *AppendedString();
+
+IsModule(node)
+SYMTABPTR node;
+{ return((node!=NULL)&&(node->idtype==MODULENAME)); }
+
+IsChare(node)
+SYMTABPTR node;
+{ return((node!=NULL)&&((node->idtype==CHARENAME)||(node->idtype==BOCNAME))); }
+
+IsEntry(node)
+SYMTABPTR node;
+{ return((node!=NULL)&&(node->idtype==ENTRYNAME)); }
+
+IsPublic(node)
+SYMTABPTR node;
+{ return((node!=NULL)&&(node->idtype==PUBLICFNNAME)); }
+
+IsPrivate(node)
+SYMTABPTR node;
+{ return((node!=NULL)&&(node->idtype==PRIVATEFNNAME)); }
+
+IsMessage(node)
+SYMTABPTR node;
+{ return((node!=NULL)&&(node->idtype==MESSAGENAME)); }
+
+IsFunction(node)
+SYMTABPTR node;
+{ return((node!=NULL)&&(node->idtype==FNNAME)); }
+
+IsReadOnly(node)
+SYMTABPTR node;
+{ return((node!=NULL)&&((node->idtype==READONLYVAR)||(node->idtype==READONLYMSG)
+        || (node->idtype==READONLYARRAY))); }
+
+IsAccumulator(node)
+SYMTABPTR node;
+{ return((node!=NULL)&&(node->idtype==ACCNAME)); }
+
+IsMonotonic(node)
+SYMTABPTR node;
+{ return((node!=NULL)&&(node->idtype==MONONAME)); }
+
+IsTable(node)
+SYMTABPTR node;
+{ return((node!=NULL)&&(node->idtype==TABLENAME)); }
+
+writefunction(node)
+SYMTABPTR node;
+{ char *temp,*dummy;
+
+  if (InPass1) return;
+  if (READMSGINITFLAG)
+       error("Bad ReadInitMsg",EXIT);
+  if (!strcmp(node->modname->name,CurrentModule->name))
+       { if (FNNAMETOREFFLAG)
+               temp=MyModulePrefix(node->modname->name,node->name);
+         else  temp=MakeString(node->name);
+       }
+  else  temp=ModulePrefix(node->modname->name,node->name);
+  if (FNNAMETOREFFLAG)
+       { dummy=GetMem(strlen(temp)+strlen(REFSUFFIX)+1);
+         strcpy(dummy,temp);strcat(dummy,REFSUFFIX);
+         writeoutput(dummy,FREE);
+       }
+  else  /*  put the else, Jan 16,1991 Attila */
+  writeoutput(temp,NOFREE);
+  free(temp);
+}
+
+writeentry(node)
+SYMTABPTR node;
+{ if (FNNAMETOREFFLAG)
+       error("Bad FnNameToRef",EXIT);
+  if (READMSGINITFLAG)
+       error("Bad ReadInitMsg",EXIT);
+  if (InPass1) return;
+  if (!strcmp(node->modname->name,CurrentModule->name))
+       writeoutput(MyModuleCharePrefix(node->modname->name,node->charename->name,
+               node->name),FREE); 
+  else writeoutput(ModuleCharePrefix(node->modname->name,node->charename->name,
+               node->name),FREE); 
+}
+
+writepublic(node)
+SYMTABPTR node;
+{ if (FNNAMETOREFFLAG)
+       { FNNAMETOREFFLAG=FALSE; writeentry(node); return; }
+  if (READMSGINITFLAG)
+       error("Bad ReadInitMsg",EXIT);
+  if (InPass1) return;
+  writeoutput(CkGlobalFunctionTable,NOFREE);
+  writeentry(node);
+  writeoutput("]",NOFREE);
+}
+
+writeprivate(node)
+SYMTABPTR node;
+{ if (FNNAMETOREFFLAG)
+       error("Bad FnNameToRef",EXIT);
+  if (READMSGINITFLAG)
+       error("Bad ReadInitMsg",EXIT);
+  if (InPass1) return;
+  writeoutput(Map(node->modname->name,node->charename->name,node->name),NOFREE);
+}
+
+writechare(node)
+SYMTABPTR node;
+{ if (FNNAMETOREFFLAG)
+       error("Bad FnNameToRef",EXIT);
+  if (READMSGINITFLAG)
+       error("Bad ReadInitMsg",EXIT);
+  if (InPass1) return;
+  if (!strcmp(node->modname->name,CurrentModule->name))
+       writeoutput(MyModulePrefix(node->modname->name,node->name),FREE); 
+  else writeoutput(ModulePrefix(node->modname->name,node->name),FREE); 
+}
+
+writereadonly(node)
+SYMTABPTR node;
+{ if (InPass1) return;
+  if (FNNAMETOREFFLAG)
+       error("Bad FnNameToRef",EXIT);
+  writeoutput(AppendMap(node->modname->name,node->name),NOFREE); 
+  if (READMSGINITFLAG)
+       { writeoutput(",",NOFREE);
+         writeoutput(AppendMapIndex(node->modname->name,node->name),NOFREE);
+       }
+}
+
+writeaccname(node)
+SYMTABPTR node;
+{ char *temp;
+
+  if (InPass1) return;
+  if (FNNAMETOREFFLAG)
+       error("Bad FnNameToRef",EXIT);
+  if (READMSGINITFLAG)
+       error("Bad Msg Init",EXIT);
+  if (!strcmp(node->modname->name,CurrentModule->name))
+       temp=MyModulePrefix(node->modname->name,node->name);
+  else         temp=ModulePrefix(node->modname->name,node->name);
+  writeoutput(temp,FREE);
+}
+
+writemononame(node)
+SYMTABPTR node;
+{ char *temp;
+
+  if (InPass1) return;
+  if (FNNAMETOREFFLAG)
+       error("Bad FnNameToRef",EXIT);
+  if (READMSGINITFLAG)
+       error("Bad Msg Init",EXIT);
+  if (!strcmp(node->modname->name,CurrentModule->name))
+       temp=MyModulePrefix(node->modname->name,node->name);
+  else         temp=ModulePrefix(node->modname->name,node->name);
+  writeoutput(temp,FREE);
+}
+
+writetable(node)
+SYMTABPTR node;
+{ if (InPass1) return;
+  if (FNNAMETOREFFLAG)
+       error("Bad FnNameToRef",EXIT);
+  if (READMSGINITFLAG)
+       error("Bad Msg Init",EXIT);
+  writeoutput(AppendMap(node->modname->name,node->name),NOFREE);
+}
+
+SYMTABPTR GlobalModuleSearch(name,modname)
+char *name,*modname;
+{ SYMTABPTR node,dummy;
+  int i;
+
+  node=GlobalFind(modname);
+  if (node==NULL) return(NULL);
+  dummy=FindInTable(node->type->table,name,&i);
+  if (i==0) return(dummy);
+  if (InPass1) return(NULL);
+  if (!strcmp(modname,Pass1Module->name))
+       { dummy=FindInTable(Pass1Module->type->table,name,&i);
+         if (i==0) return(dummy);
+       }
+  return(NULL);
+}
+
+SYMTABPTR GlobalEntryFind(entryname,charename,modname)
+char *charename,*entryname,*modname;
+{ SYMTABPTR node,dummy;
+  int i;
+
+  node=GlobalModuleSearch(charename,modname);
+  if (node==NULL) return(NULL);
+  dummy=FindInTable(node->type->table,entryname,&i);
+  if (i==0) return(dummy);
+  if (InPass1) return(NULL);
+  if (!strcmp(modname,Pass1Module->name))
+       { node=FindInTable(Pass1Module->type->table,charename,&i);
+         if (i!=0) return(NULL);
+         dummy=FindInTable(node->type->table,entryname,&i);
+         if (i==0) return(dummy);
+       }
+  return(NULL);
+}
+
+SYMTABPTR FindInTable(root,name,i)
+SYMTABPTR root;
+char *name;
+int *i;
+{ int temp;
+  if (root==NULL) error("Searching for identifier in emptiness",EXIT); 
+  temp=strcmp(name,root->name);
+  switch ((temp==0)?0:(temp<0)?-1:1)
+  { case  0 : *i=0;return(root);
+    case -1 : if (root->left==NULL)
+                  { *i = -1; return(root); }
+              else return(FindInTable(root->left,name,i));
+    case  1 : if (root->right==NULL)
+                  { *i = 1; return(root); }
+              else return(FindInTable(root->right,name,i));
+    default : error("What is this?",EXIT);
+  }
+}
+
+SYMTABPTR LocalFind(name)
+char *name;
+{ SYMTABPTR dummy;
+  STACKPTR current;
+  int i;
+
+  current=StackTop;
+  while (current!=StackBase)
+  { dummy=FindInTable(current->tableptr,name,&i);
+    if (i==0) return(dummy);
+    current=current->prev;
+  }
+  if (CurrentChare!=NULL)
+       { dummy=FindInTable(CurrentChare->type->table,name,&i);
+         if (i==0) return(dummy);
+       }
+  if (CurrentModule!=NULL)
+       { dummy=FindInTable(CurrentModule->type->table,name,&i);
+         if (i==0) return(dummy);
+       }
+  dummy=FindInTable(StackBase->tableptr,name,&i);
+  if (i==0) return(dummy);
+  return(NULL);
+}
+
+SYMTABPTR GlobalFind(name)
+char *name;
+{ SYMTABPTR dummy;
+  int i;
+
+  dummy=LocalFind(name);
+  if ((dummy==NULL)&&(Pass1Module!=NULL))
+       { if (CurrentChare!=NULL)
+               { dummy=FindInTable(Pass1Module->type->table,CurrentChare->name,
+                                       &i);
+                 if (i==0) dummy=FindInTable(dummy->type->table,name,&i);
+                 if (i==0) return(dummy);
+               }
+         dummy=FindInTable(Pass1Module->type->table,name,&i);
+         if (i==0) return(dummy); else return(NULL);
+       }
+  else return(dummy);
+}
+
+SYMTABPTR Insert(name,table)
+char *name;
+SYMTABPTR table;
+{ SYMTABPTR dummy,temp;
+  int i;
+
+  if (table==NULL) error("Trying to insert into NULL",EXIT);
+  dummy=FindInTable(table,name,&i);
+  if (i==0) { 
+             error("Duplicate Entry: ",NOEXIT); 
+              PutOnScreen(name);
+              PutOnScreen("\n");
+              return(dummy);
+             }
+  temp=GetSymTabNode(name);
+  if (i==1) dummy->right=temp; else dummy->left=temp;
+  temp->prev=table->prev;
+  table->prev=temp;
+  temp->next=table;
+  temp->prev->next=temp;
+  temp->modname=CurrentModule;
+  temp->charename=CurrentChare;
+  if (IMPORTFLAG) temp->level=ImportLevel;
+  return(temp);
+}
+
+int IDType(name)
+char *name;
+{ SYMTABPTR dummy;
+
+  dummy=LocalFind(name); 
+  if (dummy==NULL) return(0);
+  return(dummy->idtype);
+}
+
+InChareEnv(name,ptr)
+char *name;
+SYMTABPTR ptr;
+{ int i;
+  SYMTABPTR dummy;
+
+  if (CurrentChare==NULL) return(0);
+  dummy=FindInTable(CurrentChare->type->table,name,&i);
+  if ((!i)&&(dummy==ptr)) return(1); else return(0);
+}
+
+
+InModuleEnv(name,ptr)
+char *name;
+SYMTABPTR ptr;
+{ int i;
+  SYMTABPTR dummy;
+
+  if (CurrentModule==NULL) return(0);
+  dummy=FindInTable(CurrentModule->type->table,name,&i);
+  if ((!i)&&(dummy==ptr)) return(1); else return(0);
+}
+
+SYMTABPTR CheckInsert(name,table)
+{ SYMTABPTR dummy;
+  int i;
+
+  dummy=FindInTable(table,name,&i);
+  if (i==0) return(dummy);
+  return(Insert(name,table));
+}
+
+char *AppendMap(modname,name)
+char *modname,*name;
+{ return(AppendedString(modname,name,"20")); }
+
+char *AppendMapIndex(modname,name)
+char *modname,*name;
+{ return(AppendedString(modname,name,"21")); }
+
+char *AppendedString(modname,name,padding)
+char *modname,*name,*padding;
+{ static char *temp=NULL;
+  if (temp!=NULL) free(temp);
+
+  temp=GetMem(strlen(modname)+strlen(name)+2*strlen(CkPrefix)+1+strlen(padding));
+  strcpy(temp,CkPrefix);
+  strcat(temp,padding);
+  strcat(temp,modname);
+  strcat(temp,CkPrefix);
+  strcat(temp,name);
+  return(temp);
+}
diff --git a/src/xlat/xl-str.c b/src/xlat/xl-str.c
new file mode 100644 (file)
index 0000000..7651154
--- /dev/null
@@ -0,0 +1,64 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-05 18:52:05  brunner
+ * Reorganized file structure
+ *
+ * Revision 1.1  1994/11/03  17:41:58  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+static char ident[] = "@(#)$Header$";
+
+#include <stdio.h>
+#include <string.h>
+#include "xl-lex.h"
+#include "xl-sym.h"
+
+extern SYMTABPTR SavedFnNode;
+
+extern char *calloc();
+
+char *MakeString(string)
+char *string;
+{ char *dummy;
+
+  dummy=calloc((1+strlen(string)),sizeof(char));
+  if (dummy==NULL) memory_error("Out of Memory in MakeString()",EXIT);
+  if (!strcmp("sizesLEFT",string))
+       { printf ("0x%x dummy\n",dummy); }
+  strcpy(dummy,string);
+  return(dummy);
+}
+
+char *MakeString_n(a,n)
+char **a;
+int n;
+{ char *dummy;
+  int i=0;
+  int j,k;
+  
+  for (j=0;j<n;j++)    i += strlen(*(a+j));
+  dummy=calloc(i+1,sizeof(char));
+  if (dummy==NULL) memory_error("Out of Memory in MakeString()",EXIT);
+  k=0;
+  for (j=0;j<n;j++)
+       { strcpy(dummy+k,*(a+j)); k+=strlen(*(a+j)); }
+  return(dummy);
+}
+
+DestroyString(string)
+char *string;
+{ free(string); }
+       
diff --git a/src/xlat/xl-sym.c b/src/xlat/xl-sym.c
new file mode 100644 (file)
index 0000000..f6c9c33
--- /dev/null
@@ -0,0 +1,200 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-05 18:52:05  brunner
+ * Reorganized file structure
+ *
+ * Revision 1.1  1994/11/03  17:42:02  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+static char ident[] = "@(#)$Header$";
+
+#include "xl-sym.h"
+#include "xl-lex.h"
+
+extern SYMTABPTR ImportModule;
+SYMTABPTR SearchImportModule();
+
+SYMTABPTR CurrentTable=NULL;
+STACKPTR StackTop=NULL;
+STACKPTR StackBase=NULL;
+int CurrentLevel=0;
+SYMTABPTR CurrentModule=NULL;
+SYMTABPTR CurrentChare=NULL;
+TYPEPTR CHARPTR,INTPTR,SHORTPTR,LONGPTR,UNSIGNEDPTR,FLOATPTR,DOUBLEPTR,DUMMYPTR;
+TYPEPTR VOIDPTR,CHAREIDPTR,ENTRYPOINTPTR,PENUMPTR,PACKIDPTR,WRITEONCEIDPTR;
+TYPEPTR PVECTORPTR,CHARENAMEPTR,CHARENUMPTR,ENTRYNUMPTR,BOOLEANPTR;
+TYPEPTR FUNCTIONPTR,FUNCTIONREFPTR; /* Jan 17,1992 Added by Attila */
+
+SYMTABPTR GetSymTabNode(name)
+char *name;
+{ SYMTABPTR dummy;
+
+  dummy=(SYMTABPTR)calloc(1,sizeof(struct symtabnode));
+  if (dummy==NULL) memory_error("Out of Memory in GetSymTabNode()",EXIT);
+  dummy->left=dummy->right=NULL;dummy->prev=dummy->next=dummy;
+  dummy->modname=dummy->charename=NULL;
+  dummy->type=NULL;dummy->ysn=NULL;
+  dummy->localid=0;dummy->declflag=DECLARED;dummy->msgno=dummy->userpack=0;
+  if (strcmp(name,"")) dummy->name=MakeString(name);
+  return(dummy);
+}
+
+TYPEPTR GetTypeNode(count,size)
+int count,size;
+{ TYPEPTR dummy;
+
+  dummy=(TYPEPTR)calloc(1,sizeof(struct typenode));
+  if (dummy==NULL) memory_error("Out o Memory in GetTypeNode()",EXIT);
+  dummy->table=NULL;
+  dummy->count=count;
+  dummy->size=size;
+  dummy->type=NULL;
+  dummy->declflag=DECLARED;
+  return(dummy);
+}
+
+STACKPTR GetStackNode()
+{ STACKPTR dummy;
+
+  dummy = (STACKPTR)calloc(1,sizeof(struct stacknode));
+  if (dummy==NULL) memory_error("Out of Memory in GetStackNode()",EXIT);
+  dummy->prev=dummy->next=NULL;
+  dummy->tableptr=NULL;
+  return(dummy);
+}
+
+TYPEPTR SysGetTypeNode(count,size,name)
+int count,size;
+char *name;
+{ TYPEPTR dummy;
+
+  dummy=GetTypeNode(count,size);
+  dummy->table=GetSymTabNode(name);
+  dummy->table->idtype=SYSTEMTYPENAME;
+  return(dummy);
+}
+
+void InitBasicTypes()
+{ CHARPTR=SysGetTypeNode(1,CHARSIZE,"char");
+  SHORTPTR=SysGetTypeNode(1,SHORTSIZE,"short");
+  INTPTR=SysGetTypeNode(1,INTSIZE,"int");
+  FLOATPTR=SysGetTypeNode(1,FLOATSIZE,"float");
+  LONGPTR=SysGetTypeNode(1,LONGSIZE,"long");
+  DOUBLEPTR=SysGetTypeNode(1,DOUBLESIZE,"double");
+  UNSIGNEDPTR=SysGetTypeNode(1,UNSIGNEDSIZE,"unsigned");
+  DUMMYPTR=SysGetTypeNode(0,0,"dummy");
+  VOIDPTR=SysGetTypeNode(0,0,"void");
+  CHAREIDPTR=SysGetTypeNode(0,0,"ChareIDType");
+  ENTRYPOINTPTR=SysGetTypeNode(0,0,"EntryPointType");
+  PENUMPTR=SysGetTypeNode(0,0,"PeNumType");
+  PACKIDPTR=SysGetTypeNode(0,0,"PackIDType");
+  WRITEONCEIDPTR=SysGetTypeNode(0,0,"WriteOnceID");
+  PVECTORPTR=SysGetTypeNode(0,0,"PVECTOR");
+  CHARENAMEPTR=SysGetTypeNode(0,0,"ChareNameType");
+  CHARENUMPTR=SysGetTypeNode(0,0,"ChareNumType");
+  ENTRYNUMPTR=SysGetTypeNode(0,0,"EntryNumType");
+  BOOLEANPTR=SysGetTypeNode(0,0,"BOOLEAN");
+  /* Jan 17 1992, Added by Attila */
+  FUNCTIONPTR=SysGetTypeNode(0,0,"FUNCTION_PTR");
+  FUNCTIONREFPTR=SysGetTypeNode(0,0,"FunctionRefType");
+}
+
+void InitSymTable()
+{ StackBase=StackTop=GetStackNode();  
+  StackTop->level= ++CurrentLevel;
+  CurrentTable = StackTop->tableptr = GetSymTabNode(" ");
+  CurrentTable->next=CurrentTable->prev=CurrentTable;
+  InitBasicTypes();
+}
+
+void PushStack()
+{ StackTop->next=GetStackNode();
+  StackTop->next->prev=StackTop;
+  StackTop=StackTop->next;
+  StackTop->level = ++CurrentLevel;
+  CurrentTable = StackTop->tableptr = GetSymTabNode(" ");
+  CurrentTable->next=CurrentTable->prev=CurrentTable;
+}
+
+void PopStack(freeflag)
+int freeflag;
+{ if (freeflag) FreeTree(StackTop->tableptr);
+  StackTop=StackTop->prev;
+  free(StackTop->next);
+  StackTop->next=NULL;
+  CurrentLevel--;
+  CurrentTable=StackTop->tableptr;
+}
+
+void FreeTypeNode(type)
+TYPEPTR type;
+{ /*
+  if (type==NULL) return;
+  (type->count)--;
+  if (type->count) return;
+  if (type->basictype > POINTERTYPE)
+       FreeTree(type->table);
+  free(type);
+  */
+}
+  
+void FreeSymTabStruct(root)
+SYMTABPTR root;
+{ /*
+  if (root==NULL) return;
+  free(root->name); 
+  FreeTypeNode(root->type);
+  free(root);
+  */
+}
+
+void FreeTree(root)
+SYMTABPTR root;
+{ /*
+  if (root==NULL) return;
+  FreeTree(root->left);
+  FreeTree(root->right);
+  FreeSymTabStruct(root);
+  */
+}
+
+void FillSymTabNode(node,idtype,declflag,storageclass,basictype,
+                       count,typeflag,typeptr)
+SYMTABPTR node;
+TYPEPTR typeptr;
+int idtype,declflag,storageclass,basictype,count,typeflag;
+{ node->type=GetTypeNode(count,0);
+  node->type->basictype=basictype;
+  if (typeflag) { node->type->table=GetSymTabNode(" ");
+                 node->type->table->next=node->type->table->prev=
+                       node->type->table;
+               }
+  node->type->type=typeptr;
+  node->idtype=idtype;
+  node->declflag=declflag;
+  node->storageclass=storageclass;
+}
+
+/* test function */
+
+PrintTable(table)
+SYMTABPTR table;
+{ if (table==NULL) return;
+  PrintTable(table->left);
+  printf("%s\n",table->name);
+  PrintTable(table->right);
+}
+
diff --git a/src/xlat/xl-sym.h b/src/xlat/xl-sym.h
new file mode 100644 (file)
index 0000000..339714a
--- /dev/null
@@ -0,0 +1,175 @@
+/***************************************************************************
+ * RCS INFORMATION:
+ *
+ *     $RCSfile$
+ *     $Author$        $Locker$                $State$
+ *     $Revision$      $Date$
+ *
+ ***************************************************************************
+ * DESCRIPTION:
+ *
+ ***************************************************************************
+ * REVISION HISTORY:
+ *
+ * $Log$
+ * Revision 2.0  1995-06-05 18:52:05  brunner
+ * Reorganized file structure
+ *
+ * Revision 1.3  1994/11/11  21:15:12  brunner
+ * Put back the lines containing "ident" that I accidentally removed
+ *
+ * Revision 1.2  1994/11/11  05:32:34  brunner
+ * Removed ident added by accident with RCS header
+ *
+ * Revision 1.1  1994/11/07  15:41:01  brunner
+ * Initial revision
+ *
+ ***************************************************************************/
+#include <stdio.h>
+
+extern char *MakeString();             /* in "string.c" */
+
+#define free myfree
+
+#define TRUE 1
+#define FALSE 0
+
+#define ON 1
+#define OFF 0
+
+#define UNDEFINED 1000
+
+#define VARNAME 1
+#define FNNAME 2
+#define ENTRYNAME 3
+#define CHARENAME 4
+#define MODULENAME 5
+#define TYPENAME 6
+#define FIELDNAME 7
+#define ARRAYNAME 8
+#define STRUCTNAME 9
+#define UNIONNAME 10
+#define MESSAGENAME 11
+#define PRIVATEFNNAME 12
+#define BOCNAME 13
+#define SYSCALLNAME 14
+#define PUBLICFNNAME 15
+#define VARSIZENAME 16
+#define SYSTEMTYPENAME 17
+#define READONLYVAR 18
+#define READONLYARRAY 19
+#define READONLYPTR 20
+#define READONLYMSG 21
+#define ACCNAME 22
+#define MONONAME 23
+#define TABLENAME 24
+#define OTHERNAME 25
+#define ENUMNAME  26
+#define ENTRYNAMEIMP 27
+
+#define CHARTYPE 1
+#define SHORTTYPE 2
+#define INTTYPE 3
+#define LONGTYPE 4
+#define UNSIGNEDTYPE 5
+#define FLOATTYPE 6
+#define DOUBLETYPE 7
+#define POINTERTYPE 8
+#define STRUCTTYPE 9
+#define UNIONTYPE 10
+#define MESSAGETYPE 11
+#define FUNCTIONTYPE 12
+#define ARRAYTYPE 13
+#define ENUMTYPE 14
+
+#define DECLARED 1
+#define IMPORTED 2
+#define NOTDECLARED 3
+
+#define AUTO_SC 1
+#define STATIC_SC 2
+#define EXTERN_SC 3
+#define REGISTER_SC 4
+#define TYPEDEF_SC 5
+
+#define CHARSIZE 1
+#define SHORTSIZE 2
+#define INTSIZE 4
+#define LONGSIZE 4
+#define UNSIGNEDSIZE 4
+#define FLOATSIZE 4
+#define DOUBLESIZE 8
+
+typedef struct typenode
+{ int basictype;                       /* CHARTYPE .. MESSAGETYPE */
+  int count;                           /* how many times referenced */
+  int size;
+  int declflag;
+  struct typenode *type;               /* array or some such basic type */
+  struct symtabnode *table;            /* NULL unless message/struct/union */  
+} *TYPEPTR;
+
+typedef struct symtabnode
+{ char *name;                          /* name identifier */
+  int idtype;                          /* its type - VARNAME .. OTHERNAME */
+  struct symtabnode *modname;          /* module in which declared */
+  struct symtabnode *charename;                /* chare in which declared */
+  int level;                           /* level where declared */
+  int declflag;                                /* DECLARED or IMPORTED */
+  int storageclass;                    /* AUTO_SC .. TYPEDEF_SC */
+  struct typenode *type;               /* pointer to its type */
+  struct symtabnode *left,*right;      /* to support binary tree */
+  struct symtabnode *prev,*next;       /* to support doubly linked list */
+  struct ysn *ysn;
+  int localid;                         /* used with MESSAGES */
+  int msgno,userpack;
+  int implicit_entry;                  /* used with entrynames, */
+} *SYMTABPTR;
+
+typedef struct stacknode
+{ struct stacknode *prev,*next;
+  struct symtabnode *tableptr;
+  int level;
+} *STACKPTR;
+
+extern SYMTABPTR CurrentTable;
+extern STACKPTR StackTop;
+extern STACKPTR StackBase;
+extern int CurrentLevel;
+extern SYMTABPTR CurrentModule;
+extern SYMTABPTR CurrentChare;
+extern TYPEPTR CHARPTR,INTPTR,SHORTPTR,LONGPTR,UNSIGNEDPTR,FLOATPTR,DOUBLEPTR,
+       DUMMYPTR,VOIDPTR;
+extern TYPEPTR CHAREIDPTR,ENTRYPOINTPTR,PENUMPTR,PACKIDPTR,WRITEONCEIDPTR,
+               PVECTORPTR,CHARENAMEPTR,CHARENUMPTR,ENTRYNUMPTR,BOOLEANPTR;
+
+extern TYPEPTR FUNCTIONPTR, FUNCTIONREFPTR; /* Jan 17 1992, Added by Attila */
+
+extern int FUNCTIONCOUNT;
+
+extern SYMTABPTR GetSymTabNode(/*char *name*/);
+extern STACKPTR GetStackNode();
+extern TYPEPTR GetTypeNode(/*int count, int size */);
+
+extern void InitSymTable();
+extern void PushStack();
+extern void PopStack(/* int freeflag */);
+extern void FreeTree(/*SYMTABPTR root*/);
+
+extern SYMTABPTR FindInTable(/* SYMTABPTR root,char *name,int *i*/);
+
+extern SYMTABPTR LocalFind(/*char *name*/);
+extern SYMTABPTR GlobalFind(/*char *name*/);
+extern SYMTABPTR Insert(/*char *name*/);
+
+extern int TypeID(/* char *name */);   /* returns 0 iff name is not a typeid */
+
+extern void FillSymTabNode( /*         SYMTABPTR node,
+                               int idtype, int declflag,
+                               int storageclass, int basictype,
+                               int count, int tableflag,
+                               TYPEPTR typeptr */
+                         );
+
+extern SYMTABPTR ImportModule,ModuleDefined,Pass1Module;