| 1 | /* |
| 2 | * This Source Code Form is subject to the terms of the Mozilla Public |
| 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 5 | * |
| 6 | * Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V. |
| 7 | */ |
| 8 | |
| 9 | #ifndef _MAL_STACK_H_ |
| 10 | #define _MAL_STACK_H_ |
| 11 | #include "mal.h" |
| 12 | |
| 13 | #define stackSize(CNT) (sizeof(ValRecord)*(CNT) + offsetof(MalStack, stk)) |
| 14 | |
| 15 | mal_export MalStkPtr newGlobalStack(int size); |
| 16 | mal_export MalStkPtr reallocGlobalStack(MalStkPtr s, int cnt); |
| 17 | mal_export void freeStack(MalStkPtr stk); |
| 18 | mal_export void clearStack(MalStkPtr s); |
| 19 | |
| 20 | #define getStkRecord(S,P,I) &(S)->stk[(P)->argv[I]] |
| 21 | #define getStkValue(S,P,I) ( getStkType(S,P,I)== TYPE_str? \ |
| 22 | getStkRecord(S,P,I)->val.sval :\ |
| 23 | getStkRecord(S,P,I)->val.pval ) |
| 24 | #define getStkType(S,P,I) (S)->stk[(P)->argv[I]].vtype |
| 25 | #define setStkType(S,P,I,T) (S)->stk[(P)->argv[I]].vtype = T |
| 26 | #endif /* _MAL_STACK_H_ */ |
| 27 | |