home *** CD-ROM | disk | FTP | other *** search
- # include "MakeStaA.h"
- # include "yyMSarra.w"
- # include <stdio.h>
- # if defined __STDC__ | defined __cplusplus
- # include <stdlib.h>
- # else
- extern void exit ();
- # endif
- # include "Tree.h"
- # include "Definiti.h"
-
- # ifndef NULL
- # define NULL 0L
- # endif
- # ifndef false
- # define false 0
- # endif
- # ifndef true
- # define true 1
- # endif
-
- # ifdef yyInline
- # define yyALLOC(tree, free, max, alloc, nodesize, make, ptr, kind) \
- if ((ptr = (tree) free) >= (tree) max) ptr = alloc (); \
- free += nodesize [kind]; \
- ptr->yyHead.yyMark = 0; \
- ptr->Kind = kind;
- # else
- # define yyALLOC(tree, free, max, alloc, nodesize, make, ptr, kind) ptr = make (kind);
- # endif
-
- # define yyWrite(s) (void) fputs (s, yyf)
- # define yyWriteNl (void) fputc ('\n', yyf)
-
- # line 38 "MakeStaticArrays.puma"
-
-
- # include <stdio.h>
- # include "Idents.h"
- # include "StringMe.h"
- # include "Types.h"
- # include "Expressi.h" /* MakeSliceExp */
- # include "Transfor.h" /* ReplaceDECL */
- # include "Dalib.h" /* MakeVarDeclA */
-
- tIdent global_unitname;
-
-
-
- static FILE * yyf = stdout;
-
- static void yyAbort
- # ifdef __cplusplus
- (char * yyFunction)
- # else
- (yyFunction) char * yyFunction;
- # endif
- {
- (void) fprintf (stderr, "Error: module MakeStaticArrays, routine %s failed\n", yyFunction);
- exit (1);
- }
-
- void MakeStatic ARGS((tTree t, tIdent unitname));
- static tTree MakeStaticDecls ARGS((tTree t));
- static tTree MakeStaticArray ARGS((tTree val, int rank, tTree comptype));
- static tTree MakeStaticDIMVars ARGS((int rank, tIdent name, tTree t, tTree f));
- tTree InsertStaticDecls ARGS((tIdent name, int rank, tTree type, tTree end_decls));
- static tTree MakeStaticACF ARGS((tTree t));
- static void MakeStaticIndexing ARGS((tTree t));
- tTree MakeInitialStatic ARGS((tIdent name, tTree lb, tTree ub, int overlap));
- static tTree MakeAllocateStatic ARGS((tTree t));
- static tTree MakeStaticDimensions ARGS((tTree t, tIdent name, int n));
- static tTree MakeStaticDimExp ARGS((tTree t, tIdent name, int n));
- static tTree MakeStaticOffset ARGS((tTree t, tIdent name));
- static tTree MakeStaticOffsetAdd ARGS((tTree t, tIdent name, int n));
- static tTree MakeStaticCheck ARGS((tIdent name, int n));
- static void ChangeFullIndexExpression ARGS((tTree index, tTree var));
- static void ChangeLastIndexExpression ARGS((tTree index, tTree var));
- static tTree MakeStaticIndexExpression ARGS((tTree index, tTree var, int n));
- static tTree MakeDimExp ARGS((tTree exp, tIdent name, int n));
-
- void MakeStatic
- # if defined __STDC__ | defined __cplusplus
- (register tTree t, register tIdent unitname)
- # else
- (t, unitname)
- register tTree t;
- register tIdent unitname;
- # endif
- {
- if (t == NoTree) return;
- if (t->Kind == kBODY_NODE) {
- # line 81 "MakeStaticArrays.puma"
- {
- # line 82 "MakeStaticArrays.puma"
- global_unitname = unitname;
- t->BODY_NODE.DECLS = MakeStaticDecls (t->BODY_NODE.DECLS);
- t->BODY_NODE.STATS = MakeStaticACF (t->BODY_NODE.STATS);
-
- }
- return;
-
- }
- ;
- }
-
- static tTree MakeStaticDecls
- # if defined __STDC__ | defined __cplusplus
- (register tTree t)
- # else
- (t)
- register tTree t;
- # endif
- {
- # line 98 "MakeStaticArrays.puma"
-
- tTree newdecl;
- tObject Obj;
-
- if (t->Kind == kDECL_LIST) {
- # line 103 "MakeStaticArrays.puma"
- {
- # line 104 "MakeStaticArrays.puma"
- newdecl = MakeStaticDecls (t->DECL_LIST.Elem);
- t->DECL_LIST.Next = MakeStaticDecls (t->DECL_LIST.Next);
- newdecl = ReplaceDECL (t, newdecl, t->DECL_LIST.Next);
-
- }
- return newdecl;
-
- }
- if (t->Kind == kVAR_DECL) {
- if (t->VAR_DECL.VAL->Kind == kARRAY_TYPE) {
- # line 111 "MakeStaticArrays.puma"
- {
- # line 115 "MakeStaticArrays.puma"
- Obj = GetLocalDecl (t->VAR_DECL.Name);
- # line 117 "MakeStaticArrays.puma"
- if (! ((IsVarAllocatable (Obj) == true))) goto yyL2;
- {
- # line 118 "MakeStaticArrays.puma"
- if (! ((array_kind == STATIC_ARRAYS))) goto yyL2;
- }
- }
- return MakeStaticArray (t, VarRank (Obj), ArrayCompType (Obj));
- yyL2:;
-
- }
- }
- # line 123 "MakeStaticArrays.puma"
- return t;
-
- }
-
- static tTree MakeStaticArray
- # if defined __STDC__ | defined __cplusplus
- (register tTree val, register int rank, register tTree comptype)
- # else
- (val, rank, comptype)
- register tTree val;
- register int rank;
- register tTree comptype;
- # endif
- {
- if (val->Kind == kVAR_DECL) {
- # line 141 "MakeStaticArrays.puma"
- {
- tTree new_var;
- tTree new_decl;
- {
- # line 143 "MakeStaticArrays.puma"
-
- # line 144 "MakeStaticArrays.puma"
-
- # line 146 "MakeStaticArrays.puma"
- new_decl = InsertStaticDecls (val->VAR_DECL.Name, rank, mINTEGER_TYPE (4), NoTree);
-
-
-
-
-
- new_var = mINDEX_TYPE (MakeConstant (1),
- MakeConstant (StaticArraySize));
-
- new_var = mARRAY_TYPE (mTYPE_LIST (new_var, mTYPE_EMPTY()), comptype);
-
- new_var = mVAR_DECL (val->VAR_DECL.Name, val->VAR_DECL.Pos, new_var);
-
- new_decl = mDECL_LIST (new_var, new_decl);
-
-
- }
- {
- return new_decl;
- }
- }
-
- }
- yyAbort ("MakeStaticArray");
- }
-
- static tTree MakeStaticDIMVars
- # if defined __STDC__ | defined __cplusplus
- (register int rank, register tIdent name, register tTree t, register tTree f)
- # else
- (rank, name, t, f)
- register int rank;
- register tIdent name;
- register tTree t;
- register tTree f;
- # endif
- {
- # line 181 "MakeStaticArrays.puma"
-
- tTree newdecl;
- char s [10];
-
- if (equalint (rank, 0)) {
- # line 186 "MakeStaticArrays.puma"
- return f;
-
- }
- # line 190 "MakeStaticArrays.puma"
- {
- # line 191 "MakeStaticArrays.puma"
- sprintf (s, "_DIM%d", rank);
- newdecl = MakeVarDeclA (name, s, t);
- newdecl = mDECL_LIST (newdecl, f);
-
- }
- return MakeStaticDIMVars (rank - 1, name, t, newdecl);
-
- }
-
- tTree InsertStaticDecls
- # if defined __STDC__ | defined __cplusplus
- (register tIdent name, register int rank, register tTree type, register tTree end_decls)
- # else
- (name, rank, type, end_decls)
- register tIdent name;
- register int rank;
- register tTree type;
- register tTree end_decls;
- # endif
- {
- # line 213 "MakeStaticArrays.puma"
- {
- tTree new_decls;
- {
- # line 215 "MakeStaticArrays.puma"
-
- # line 217 "MakeStaticArrays.puma"
- new_decls = mDECL_LIST (MakeVarDeclA (name, "_OFS", type), end_decls);
- new_decls = MakeStaticDIMVars (rank, name, type, new_decls);
-
- }
- {
- return new_decls;
- }
- }
-
- }
-
- static tTree MakeStaticACF
- # if defined __STDC__ | defined __cplusplus
- (register tTree t)
- # else
- (t)
- register tTree t;
- # endif
- {
-
- switch (t->Kind) {
- case kACF_LIST:
- # line 236 "MakeStaticArrays.puma"
- {
- tTree newacf;
- {
- # line 237 "MakeStaticArrays.puma"
-
- # line 238 "MakeStaticArrays.puma"
- newacf = MakeStaticACF (t->ACF_LIST.Elem);
- t->ACF_LIST.Next = MakeStaticACF (t->ACF_LIST.Next);
- newacf = ReplaceACF (t, newacf, t->ACF_LIST.Next);
-
- }
- {
- return newacf;
- }
- }
-
- case kACF_EMPTY:
- # line 245 "MakeStaticArrays.puma"
- return t;
-
- case kACF_DUMMY:
- # line 249 "MakeStaticArrays.puma"
- return t;
-
- case kACF_IF:
- # line 253 "MakeStaticArrays.puma"
- {
- # line 254 "MakeStaticArrays.puma"
- t->ACF_IF.IF_EXP = MakeStaticACF (t->ACF_IF.IF_EXP);
- t->ACF_IF.THEN_PART = MakeStaticACF (t->ACF_IF.THEN_PART);
- t->ACF_IF.ELSE_PART = MakeStaticACF (t->ACF_IF.ELSE_PART);
-
- }
- return t;
-
- case kACF_WHILE:
- # line 261 "MakeStaticArrays.puma"
- {
- # line 262 "MakeStaticArrays.puma"
- t->ACF_WHILE.WHILE_EXP = MakeStaticACF (t->ACF_WHILE.WHILE_EXP);
- t->ACF_WHILE.WHILE_BODY = MakeStaticACF (t->ACF_WHILE.WHILE_BODY);
-
- }
- return t;
-
- case kACF_WHERE:
- # line 268 "MakeStaticArrays.puma"
- {
- # line 269 "MakeStaticArrays.puma"
- t->ACF_WHERE.WHERE_EXP = MakeStaticACF (t->ACF_WHERE.WHERE_EXP);
- t->ACF_WHERE.TRUE_PART = MakeStaticACF (t->ACF_WHERE.TRUE_PART);
- t->ACF_WHERE.FALSE_PART = MakeStaticACF (t->ACF_WHERE.FALSE_PART);
-
- }
- return t;
-
- case kACF_DOLOCAL:
- # line 276 "MakeStaticArrays.puma"
- {
- # line 277 "MakeStaticArrays.puma"
- t->ACF_DOLOCAL.DOLOCAL_RANGE = MakeStaticACF (t->ACF_DOLOCAL.DOLOCAL_RANGE);
- t->ACF_DOLOCAL.DOLOCAL_BODY = MakeStaticACF (t->ACF_DOLOCAL.DOLOCAL_BODY);
-
- }
- return t;
-
- case kACF_DO:
- # line 283 "MakeStaticArrays.puma"
- {
- # line 284 "MakeStaticArrays.puma"
- t->ACF_DO.DO_RANGE = MakeStaticACF (t->ACF_DO.DO_RANGE);
- t->ACF_DO.DO_BODY = MakeStaticACF (t->ACF_DO.DO_BODY);
-
- }
- return t;
-
- case kACF_DOVEC:
- # line 290 "MakeStaticArrays.puma"
- {
- # line 291 "MakeStaticArrays.puma"
- t->ACF_DOVEC.DOVEC_RANGE = MakeStaticACF (t->ACF_DOVEC.DOVEC_RANGE);
- t->ACF_DOVEC.DOVEC_BODY = MakeStaticACF (t->ACF_DOVEC.DOVEC_BODY);
-
- }
- return t;
-
- case kACF_CASE:
- # line 297 "MakeStaticArrays.puma"
- {
- # line 298 "MakeStaticArrays.puma"
- t->ACF_CASE.CASE_EXP = MakeStaticACF (t->ACF_CASE.CASE_EXP);
- t->ACF_CASE.CASE_ALTS = MakeStaticACF (t->ACF_CASE.CASE_ALTS);
- t->ACF_CASE.CASE_OTHERWISE = MakeStaticACF (t->ACF_CASE.CASE_OTHERWISE);
-
- }
- return t;
-
- case kSELECTED_ACF_LIST:
- # line 305 "MakeStaticArrays.puma"
- {
- # line 306 "MakeStaticArrays.puma"
- t->SELECTED_ACF_LIST.Elem = MakeStaticACF (t->SELECTED_ACF_LIST.Elem);
- t->SELECTED_ACF_LIST.Next = MakeStaticACF (t->SELECTED_ACF_LIST.Next);
-
- }
- return t;
-
- case kSELECTED_ACF_NODE:
- # line 312 "MakeStaticArrays.puma"
- {
- # line 313 "MakeStaticArrays.puma"
- t->SELECTED_ACF_NODE.SELECT_LIST = MakeStaticACF (t->SELECTED_ACF_NODE.SELECT_LIST);
- t->SELECTED_ACF_NODE.SELECT_ACFS = MakeStaticACF (t->SELECTED_ACF_NODE.SELECT_ACFS);
-
- }
- return t;
-
- case kACF_BASIC:
- if (t->ACF_BASIC.BASIC_STMT->Kind == kALLOCATE_STMT) {
- # line 325 "MakeStaticArrays.puma"
- {
- # line 329 "MakeStaticArrays.puma"
- if (! ((array_kind == STATIC_ARRAYS))) goto yyL13;
- }
- return MakeAllocateStatic (t->ACF_BASIC.BASIC_STMT->ALLOCATE_STMT.PARAMS);
- yyL13:;
-
- # line 333 "MakeStaticArrays.puma"
- return t;
-
- }
- if (t->ACF_BASIC.BASIC_STMT->Kind == kDEALLOCATE_STMT) {
- # line 338 "MakeStaticArrays.puma"
- {
- # line 340 "MakeStaticArrays.puma"
- if (! ((array_kind == STATIC_ARRAYS))) goto yyL15;
- }
- return NoTree;
- yyL15:;
-
- # line 344 "MakeStaticArrays.puma"
- return t;
-
- }
- # line 349 "MakeStaticArrays.puma"
- {
- # line 350 "MakeStaticArrays.puma"
- t->ACF_BASIC.BASIC_STMT = MakeStaticACF (t->ACF_BASIC.BASIC_STMT);
- }
- return t;
-
- case kASSIGN_STMT:
- # line 360 "MakeStaticArrays.puma"
- {
- # line 361 "MakeStaticArrays.puma"
- t->ASSIGN_STMT.ASSIGN_VAR = MakeStaticACF (t->ASSIGN_STMT.ASSIGN_VAR);
- t->ASSIGN_STMT.ASSIGN_EXP = MakeStaticACF (t->ASSIGN_STMT.ASSIGN_EXP);
-
- }
- return t;
-
- case kFORMAT_STMT:
- # line 367 "MakeStaticArrays.puma"
- return t;
-
- case kSTOP_STMT:
- # line 371 "MakeStaticArrays.puma"
- return t;
-
- case kCALL_STMT:
- # line 375 "MakeStaticArrays.puma"
- {
- # line 376 "MakeStaticArrays.puma"
- t->CALL_STMT.CALL_PARAMS = MakeStaticACF (t->CALL_STMT.CALL_PARAMS);
- }
- return t;
-
- case kIO_STMT:
- # line 380 "MakeStaticArrays.puma"
- {
- # line 381 "MakeStaticArrays.puma"
- t->IO_STMT.IO_ITEMS = MakeStaticACF (t->IO_STMT.IO_ITEMS);
- }
- return t;
-
- case kRETURN_STMT:
- # line 385 "MakeStaticArrays.puma"
- return t;
-
- case kGOTO_STMT:
- # line 389 "MakeStaticArrays.puma"
- return t;
-
- case kCOMP_GOTO_STMT:
- # line 393 "MakeStaticArrays.puma"
- return t;
-
- case kCOMP_IF_STMT:
- # line 397 "MakeStaticArrays.puma"
- return t;
-
- case kBTP_LIST:
- # line 407 "MakeStaticArrays.puma"
- {
- # line 408 "MakeStaticArrays.puma"
- t->BTP_LIST.Elem = MakeStaticACF (t->BTP_LIST.Elem);
- t->BTP_LIST.Next = MakeStaticACF (t->BTP_LIST.Next);
-
- }
- return t;
-
- case kBTP_EMPTY:
- # line 414 "MakeStaticArrays.puma"
- return t;
-
- case kVAR_PARAM:
- # line 418 "MakeStaticArrays.puma"
- {
- # line 419 "MakeStaticArrays.puma"
- t->VAR_PARAM.V = MakeStaticACF (t->VAR_PARAM.V);
- }
- return t;
-
- case kPROC_PARAM:
- # line 423 "MakeStaticArrays.puma"
- return t;
-
- case kVALUE_PARAM:
- # line 432 "MakeStaticArrays.puma"
- {
- # line 433 "MakeStaticArrays.puma"
- t->VALUE_PARAM.E = MakeStaticACF (t->VALUE_PARAM.E);
- }
- return t;
-
- case kFUNC_PARAM:
- # line 437 "MakeStaticArrays.puma"
- return t;
-
- case kBTE_LIST:
- # line 451 "MakeStaticArrays.puma"
- {
- # line 452 "MakeStaticArrays.puma"
- t->BTE_LIST.Elem = MakeStaticACF (t->BTE_LIST.Elem);
- t->BTE_LIST.Next = MakeStaticACF (t->BTE_LIST.Next);
-
- }
- return t;
-
- case kBTE_EMPTY:
- # line 458 "MakeStaticArrays.puma"
- return t;
-
- case kARRAY_EXP:
- # line 462 "MakeStaticArrays.puma"
- {
- # line 463 "MakeStaticArrays.puma"
- t->ARRAY_EXP.ELEMENTS = MakeStaticACF (t->ARRAY_EXP.ELEMENTS);
- }
- return t;
-
- case kADDR:
- # line 467 "MakeStaticArrays.puma"
- {
- # line 468 "MakeStaticArrays.puma"
- t->ADDR.E = MakeStaticACF (t->ADDR.E);
- }
- return t;
-
- case kDUMMY_EXP:
- # line 472 "MakeStaticArrays.puma"
- return t;
-
- case kCONST_EXP:
- # line 476 "MakeStaticArrays.puma"
- return t;
-
- case kSLICE_EXP:
- # line 480 "MakeStaticArrays.puma"
- {
- # line 481 "MakeStaticArrays.puma"
- t->SLICE_EXP.START = MakeStaticACF (t->SLICE_EXP.START);
- t->SLICE_EXP.STOP = MakeStaticACF (t->SLICE_EXP.STOP);
- t->SLICE_EXP.INC = MakeStaticACF (t->SLICE_EXP.INC);
-
- }
- return t;
-
- case kOP_EXP:
- # line 488 "MakeStaticArrays.puma"
- {
- # line 489 "MakeStaticArrays.puma"
- t->OP_EXP.OPND1 = MakeStaticACF (t->OP_EXP.OPND1);
- t->OP_EXP.OPND2 = MakeStaticACF (t->OP_EXP.OPND2);
-
- }
- return t;
-
- case kOP1_EXP:
- # line 495 "MakeStaticArrays.puma"
- {
- # line 496 "MakeStaticArrays.puma"
- t->OP1_EXP.OPND = MakeStaticACF (t->OP1_EXP.OPND);
- }
- return t;
-
- case kVAR_EXP:
- # line 500 "MakeStaticArrays.puma"
- {
- # line 501 "MakeStaticArrays.puma"
- t->VAR_EXP.V = MakeStaticACF (t->VAR_EXP.V);
- }
- return t;
-
- case kFUNC_CALL_EXP:
- # line 505 "MakeStaticArrays.puma"
- {
- # line 506 "MakeStaticArrays.puma"
- t->FUNC_CALL_EXP.FUNC_PARAMS = MakeStaticACF (t->FUNC_CALL_EXP.FUNC_PARAMS);
- }
- return t;
-
- case kDO_EXP:
- # line 510 "MakeStaticArrays.puma"
- {
- # line 511 "MakeStaticArrays.puma"
- t->DO_EXP.RANGE = MakeStaticACF (t->DO_EXP.RANGE);
- t->DO_EXP.BODY = MakeStaticACF (t->DO_EXP.BODY);
-
- }
- return t;
-
- case kUSED_VAR:
- # line 524 "MakeStaticArrays.puma"
- return t;
-
- case kLOOP_VAR:
- # line 528 "MakeStaticArrays.puma"
- return t;
-
- case kSUBSTRING_VAR:
- # line 532 "MakeStaticArrays.puma"
- {
- # line 533 "MakeStaticArrays.puma"
- t->SUBSTRING_VAR.IND_VAR = MakeStaticACF (t->SUBSTRING_VAR.IND_VAR);
- t->SUBSTRING_VAR.IND_EXP = MakeStaticACF (t->SUBSTRING_VAR.IND_EXP);
-
- }
- return t;
-
- case kINDEXED_VAR:
- if (t->INDEXED_VAR.IND_VAR->Kind == kUSED_VAR) {
- # line 539 "MakeStaticArrays.puma"
- {
- # line 541 "MakeStaticArrays.puma"
- t->INDEXED_VAR.IND_EXPS = MakeStaticACF (t->INDEXED_VAR.IND_EXPS);
- MakeStaticIndexing (t);
-
- }
- return t;
-
- }
- break;
- case kDO_VAR:
- # line 547 "MakeStaticArrays.puma"
- {
- # line 548 "MakeStaticArrays.puma"
- t->DO_VAR.RANGE = MakeStaticACF (t->DO_VAR.RANGE);
- t->DO_VAR.BODY = MakeStaticACF (t->DO_VAR.BODY);
-
- }
- return t;
-
- case kBTV_LIST:
- # line 554 "MakeStaticArrays.puma"
- {
- # line 555 "MakeStaticArrays.puma"
- t->BTV_LIST.Elem = MakeStaticACF (t->BTV_LIST.Elem);
- t->BTV_LIST.Next = MakeStaticACF (t->BTV_LIST.Next);
-
- }
- return t;
-
- case kBTV_EMPTY:
- # line 561 "MakeStaticArrays.puma"
- return t;
-
- }
-
- # line 565 "MakeStaticArrays.puma"
- {
- # line 566 "MakeStaticArrays.puma"
- failure_protocol ("MakeStaticArrays", "MakeStaticACF", t);
- }
- return NoTree;
-
- }
-
- static void MakeStaticIndexing
- # if defined __STDC__ | defined __cplusplus
- (register tTree t)
- # else
- (t)
- register tTree t;
- # endif
- {
- if (t == NoTree) return;
- if (t->Kind == kINDEXED_VAR) {
- if (t->INDEXED_VAR.IND_VAR->Kind == kUSED_VAR) {
- # line 588 "MakeStaticArrays.puma"
- {
- # line 589 "MakeStaticArrays.puma"
- if (! ((IsVarAllocatable (t->INDEXED_VAR.IND_VAR->USED_VAR.VARNAME->VAR_OBJ.Object) == true))) goto yyL1;
- {
- # line 590 "MakeStaticArrays.puma"
- if (! ((array_kind == STATIC_ARRAYS))) goto yyL1;
- {
- # line 591 "MakeStaticArrays.puma"
- ChangeFullIndexExpression (t->INDEXED_VAR.IND_EXPS, t->INDEXED_VAR.IND_VAR);
- }
- }
- }
- return;
- yyL1:;
-
- # line 604 "MakeStaticArrays.puma"
- {
- # line 605 "MakeStaticArrays.puma"
- if (! ((IsVarAllocatable (t->INDEXED_VAR.IND_VAR->USED_VAR.VARNAME->VAR_OBJ.Object) != true))) goto yyL2;
- {
- # line 606 "MakeStaticArrays.puma"
- if (! ((IsVarDummy (t->INDEXED_VAR.IND_VAR->USED_VAR.VARNAME->VAR_OBJ.Object) != true))) goto yyL2;
- {
- # line 607 "MakeStaticArrays.puma"
- if (! ((TreeDistribution (t->INDEXED_VAR.IND_VAR) == 1))) goto yyL2;
- {
- # line 608 "MakeStaticArrays.puma"
- ChangeLastIndexExpression (t->INDEXED_VAR.IND_EXPS, t->INDEXED_VAR.IND_VAR);
- }
- }
- }
- }
- return;
- yyL2:;
-
- }
- }
- ;
- }
-
- tTree MakeInitialStatic
- # if defined __STDC__ | defined __cplusplus
- (register tIdent name, register tTree lb, register tTree ub, register int overlap)
- # else
- (name, lb, ub, overlap)
- register tIdent name;
- register tTree lb;
- register tTree ub;
- register int overlap;
- # endif
- {
- # line 625 "MakeStaticArrays.puma"
-
- tTree var, exp, stmt, newacf;
-
- # line 629 "MakeStaticArrays.puma"
- {
- # line 630 "MakeStaticArrays.puma"
- var = MakeUsedVarA (name, "_OFS");
- exp = mOP_EXP (mOP_MINUS(), MakeConstant (1), CopyTree (lb));
- stmt = mACF_BASIC (mASSIGN_STMT (var, exp));
- newacf = mACF_LIST (stmt, NoTree);
- var = MakeUsedVarA (name, "_DIM1");
- exp = mOP_EXP (mOP_MINUS (), ub, lb);
- exp = mOP_EXP (mOP_PLUS (), exp, MakeConstant (1+overlap));
- stmt = mACF_BASIC (mASSIGN_STMT (var, exp));
- newacf = mACF_LIST (stmt, newacf);
-
- }
- return newacf;
-
- }
-
- static tTree MakeAllocateStatic
- # if defined __STDC__ | defined __cplusplus
- (register tTree t)
- # else
- (t)
- register tTree t;
- # endif
- {
- if (t->Kind == kBTP_LIST) {
- if (t->BTP_LIST.Elem->Kind == kVAR_PARAM) {
- # line 660 "MakeStaticArrays.puma"
- return CombineACF (MakeAllocateStatic (t->BTP_LIST.Elem->VAR_PARAM.V), MakeAllocateStatic (t->BTP_LIST.Next));
-
- }
- }
- if (t->Kind == kBTP_EMPTY) {
- # line 665 "MakeStaticArrays.puma"
- return NoTree;
-
- }
- if (t->Kind == kINDEXED_VAR) {
- if (t->INDEXED_VAR.IND_VAR->Kind == kUSED_VAR) {
- if (Definitions_IsType (t->INDEXED_VAR.IND_VAR->USED_VAR.VARNAME->VAR_OBJ.Object, kObject)) {
- # line 669 "MakeStaticArrays.puma"
- return CombineACF (CombineACF (MakeStaticDimensions (t->INDEXED_VAR.IND_EXPS, t->INDEXED_VAR.IND_VAR->USED_VAR.VARNAME->VAR_OBJ.Ident, 1), MakeStaticOffset (t->INDEXED_VAR.IND_EXPS, t->INDEXED_VAR.IND_VAR->USED_VAR.VARNAME->VAR_OBJ.Ident)),
- MakeStaticCheck (t->INDEXED_VAR.IND_VAR->USED_VAR.VARNAME->VAR_OBJ.Ident, TreeListLength (t->INDEXED_VAR.IND_EXPS)));
-
- }
- }
- }
- yyAbort ("MakeAllocateStatic");
- }
-
- static tTree MakeStaticDimensions
- # if defined __STDC__ | defined __cplusplus
- (register tTree t, register tIdent name, register int n)
- # else
- (t, name, n)
- register tTree t;
- register tIdent name;
- register int n;
- # endif
- {
- # line 684 "MakeStaticArrays.puma"
-
- tTree var, exp, newacf;
- char s [20];
-
- if (t->Kind == kBTE_LIST) {
- # line 689 "MakeStaticArrays.puma"
- {
- # line 690 "MakeStaticArrays.puma"
- sprintf (s, "_DIM%d", n);
- var = MakeUsedVarA (name, s);
- exp = MakeStaticDimExp (t->BTE_LIST.Elem, name, n);
- newacf = mACF_BASIC (mASSIGN_STMT (var, exp));
- newacf = CombineACF (newacf, MakeStaticDimensions (t->BTE_LIST.Next, name, n+1));
-
- }
- return newacf;
-
- }
- if (t->Kind == kBTE_EMPTY) {
- # line 699 "MakeStaticArrays.puma"
- return NoTree;
-
- }
- yyAbort ("MakeStaticDimensions");
- }
-
- static tTree MakeStaticDimExp
- # if defined __STDC__ | defined __cplusplus
- (register tTree t, register tIdent name, register int n)
- # else
- (t, name, n)
- register tTree t;
- register tIdent name;
- register int n;
- # endif
- {
- # line 705 "MakeStaticArrays.puma"
-
- tTree exp, var;
- char s [20];
-
- if (t->Kind == kSLICE_EXP) {
- # line 710 "MakeStaticArrays.puma"
- return MakeDimExp (MakeSliceExp (t->SLICE_EXP.START, t->SLICE_EXP.STOP), name, n - 1);
-
- }
- # line 715 "MakeStaticArrays.puma"
- return MakeDimExp (t, name, n - 1);
-
- }
-
- static tTree MakeStaticOffset
- # if defined __STDC__ | defined __cplusplus
- (register tTree t, register tIdent name)
- # else
- (t, name)
- register tTree t;
- register tIdent name;
- # endif
- {
- # line 732 "MakeStaticArrays.puma"
-
- tTree var, exp, newacf;
-
- # line 736 "MakeStaticArrays.puma"
- {
- # line 737 "MakeStaticArrays.puma"
- var = MakeUsedVarA (name, "_OFS");
- exp = MakeConstant (1);
- exp = mOP_EXP (mOP_MINUS (), exp, MakeStaticOffsetAdd (t, name, 0));
- newacf = mASSIGN_STMT (var, exp);
- newacf = mACF_BASIC (newacf);
- newacf = mACF_LIST (newacf, NoTree);
-
- }
- return newacf;
-
- }
-
- static tTree MakeStaticOffsetAdd
- # if defined __STDC__ | defined __cplusplus
- (register tTree t, register tIdent name, register int n)
- # else
- (t, name, n)
- register tTree t;
- register tIdent name;
- register int n;
- # endif
- {
- if (t->Kind == kBTE_LIST) {
- if (t->BTE_LIST.Elem->Kind == kSLICE_EXP) {
- if (t->BTE_LIST.Next->Kind == kBTE_EMPTY) {
- # line 749 "MakeStaticArrays.puma"
- return MakeDimExp (t->BTE_LIST.Elem->SLICE_EXP.START, name, n);
-
- }
- # line 754 "MakeStaticArrays.puma"
- return mOP_EXP (mOP_PLUS (), MakeDimExp (t->BTE_LIST.Elem->SLICE_EXP.START, name, n), MakeStaticOffsetAdd (t->BTE_LIST.Next, name, n + 1));
-
- }
- }
- # line 760 "MakeStaticArrays.puma"
- {
- # line 761 "MakeStaticArrays.puma"
- printf ("MakeStaticOffsetAdd failed\n");
- # line 762 "MakeStaticArrays.puma"
- WriteTree (stdout, t);
- # line 763 "MakeStaticArrays.puma"
- kill_in_protocol ();
- }
- return NoTree;
-
- }
-
- static tTree MakeStaticCheck
- # if defined __STDC__ | defined __cplusplus
- (register tIdent name, register int n)
- # else
- (name, n)
- register tIdent name;
- register int n;
- # endif
- {
- # line 777 "MakeStaticArrays.puma"
-
- tTree var, exp, newacf, p, specs, items;
- tStringRef sc;
- char s[30], msg[100], uname[30];
-
- # line 783 "MakeStaticArrays.puma"
- {
- # line 784 "MakeStaticArrays.puma"
- sprintf (s, "_DIM%d", n);
- var = MakeUsedVarA (name, s);
- exp = MakeConstant (StaticArraySize);
- exp = mOP_EXP (mOP_GT(), mVAR_EXP(var), exp);
- p = mPROC_OBJ (MakeIdent ("PRINT", 5));
- specs = mVAR_PARAM (mADDR (mDUMMY_EXP()));
- specs = mBTP_LIST (specs, mBTP_EMPTY());
- GetString (name, s);
- GetString (global_unitname, uname);
- sprintf (msg, "%s: %s is out of memory, needs : ", uname, s);
- sc = PutString (msg, strlen (msg));
- items = mCONST_EXP (mSTRING_CONSTANT (sc));
- items = mBTP_LIST (mVAR_PARAM (mADDR (items)),
- mBTP_LIST (mVAR_PARAM (var), mBTP_EMPTY()));
- newacf = mACF_LIST (mACF_BASIC (mIO_STMT (p, specs, items)),
- mACF_EMPTY());
- newacf = mACF_IF (exp, newacf, mACF_EMPTY());
- newacf = mACF_LIST (newacf, NoTree);
-
- }
- return newacf;
-
- }
-
- static void ChangeFullIndexExpression
- # if defined __STDC__ | defined __cplusplus
- (register tTree index, register tTree var)
- # else
- (index, var)
- register tTree index;
- register tTree var;
- # endif
- {
- if (index == NoTree) return;
- if (var == NoTree) return;
- if (var->Kind == kUSED_VAR) {
- # line 819 "MakeStaticArrays.puma"
- {
- # line 820 "MakeStaticArrays.puma"
- ChangeFullIndexExpression (index, var->USED_VAR.VARNAME);
- }
- return;
-
- }
- if (index->Kind == kBTE_LIST) {
- if (var->Kind == kVAR_OBJ) {
- # line 823 "MakeStaticArrays.puma"
- {
- # line 824 "MakeStaticArrays.puma"
- index->BTE_LIST.Elem = MakeStaticIndexExpression (index, var, 0);
- index->BTE_LIST.Next = mBTE_EMPTY ();
-
- }
- return;
-
- }
- }
- # line 829 "MakeStaticArrays.puma"
- {
- # line 830 "MakeStaticArrays.puma"
- printf ("ChangeFullIndexExpression failed\n");
- # line 831 "MakeStaticArrays.puma"
- FileUnparse (stdout, index);
- # line 832 "MakeStaticArrays.puma"
- WriteTree (stdout, index);
- # line 833 "MakeStaticArrays.puma"
- exit (- 1);
- }
- return;
-
- ;
- }
-
- static void ChangeLastIndexExpression
- # if defined __STDC__ | defined __cplusplus
- (register tTree index, register tTree var)
- # else
- (index, var)
- register tTree index;
- register tTree var;
- # endif
- {
- if (index == NoTree) return;
- if (var == NoTree) return;
- if (var->Kind == kUSED_VAR) {
- # line 849 "MakeStaticArrays.puma"
- {
- # line 850 "MakeStaticArrays.puma"
- ChangeLastIndexExpression (index, var->USED_VAR.VARNAME);
- }
- return;
-
- }
- if (index->Kind == kBTE_LIST) {
- if (index->BTE_LIST.Next->Kind == kBTE_EMPTY) {
- if (var->Kind == kVAR_OBJ) {
- # line 853 "MakeStaticArrays.puma"
- {
- # line 854 "MakeStaticArrays.puma"
- index->BTE_LIST.Elem = MakeStaticIndexExpression (index, var, 0);
- }
- return;
-
- }
- }
- if (var->Kind == kVAR_OBJ) {
- # line 857 "MakeStaticArrays.puma"
- {
- # line 859 "MakeStaticArrays.puma"
- ChangeLastIndexExpression (index->BTE_LIST.Next, var);
- }
- return;
-
- }
- }
- # line 862 "MakeStaticArrays.puma"
- {
- # line 863 "MakeStaticArrays.puma"
- printf ("ChangeLastIndexExpression failed\n");
- # line 864 "MakeStaticArrays.puma"
- FileUnparse (stdout, index);
- # line 865 "MakeStaticArrays.puma"
- WriteTree (stdout, index);
- # line 866 "MakeStaticArrays.puma"
- exit (- 1);
- }
- return;
-
- ;
- }
-
- static tTree MakeStaticIndexExpression
- # if defined __STDC__ | defined __cplusplus
- (register tTree index, register tTree var, register int n)
- # else
- (index, var, n)
- register tTree index;
- register tTree var;
- register int n;
- # endif
- {
- if (index->Kind == kBTE_LIST) {
- if (var->Kind == kVAR_OBJ) {
- # line 871 "MakeStaticArrays.puma"
- return mOP_EXP (mOP_PLUS (), MakeStaticIndexExpression (index->BTE_LIST.Next, var, n + 1), MakeDimExp (index->BTE_LIST.Elem, var->VAR_OBJ.Ident, n));
-
- }
- }
- if (index->Kind == kBTE_EMPTY) {
- if (var->Kind == kVAR_OBJ) {
- # line 878 "MakeStaticArrays.puma"
- return mVAR_EXP (MakeUsedVarA (var->VAR_OBJ.Ident, "_OFS"));
-
- }
- }
- yyAbort ("MakeStaticIndexExpression");
- }
-
- static tTree MakeDimExp
- # if defined __STDC__ | defined __cplusplus
- (register tTree exp, register tIdent name, register int n)
- # else
- (exp, name, n)
- register tTree exp;
- register tIdent name;
- register int n;
- # endif
- {
- # line 892 "MakeStaticArrays.puma"
-
- char dimid [10];
- tTree newexp;
- int val;
- bool found;
-
- # line 899 "MakeStaticArrays.puma"
- {
- # line 900 "MakeStaticArrays.puma"
- if (! ((n <= 0))) goto yyL1;
- }
- return exp;
- yyL1:;
-
- # line 903 "MakeStaticArrays.puma"
- {
- # line 904 "MakeStaticArrays.puma"
- sprintf (dimid, "_DIM%d", n);
- newexp = mVAR_EXP (MakeUsedVarA (name, dimid));
- GetIntConstValue (exp, &found, &val);
- if (found && (val == 0))
- newexp = exp;
- else if (found && (val == 1))
- newexp = newexp;
- else
- newexp = mOP_EXP (mOP_TIMES (), exp, newexp);
-
- }
- return newexp;
-
- }
-
- void BeginMakeStaticArrays ()
- {
- }
-
- void CloseMakeStaticArrays ()
- {
- }