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_TYPE_H
10#define MAL_TYPE_H
11#include "mal.h"
12
13/* #define DEBUG_MAL_TYPE 1 */
14
15#define TMPMARKER '_'
16#define REFMARKER 'X'
17#define REFMARKERC 'C'
18
19#define newBatType(T) (1<<16 | (T & 0377) )
20#define getBatType(X) ((X) & 0377 )
21#define isaBatType(X) ((1<<16) & (X) && (X)!= TYPE_any)
22
23#define isAnyExpression(X) ((X) >> 17)
24#define isPolymorphic(X) (isAnyExpression(X) || (X)== TYPE_any)
25
26#define setTypeIndex(X,I) X |= ((I & 017)<<18);
27#define getTypeIndex(X) (((X)>>18) & 017)
28
29#define isPolyType(X) (isAnyExpression(X) && getTypeIndex(X)>0)
30/*
31 * The symbol/instruction kinds are introduced here instead of reusing the defines
32 * derived from the parser to avoid a loop in the define-structure.
33 */
34
35#define RAISEsymbol 21 /* flow of control modifiers */
36#define CATCHsymbol 22
37#define RETURNsymbol 23
38#define BARRIERsymbol 24
39#define REDOsymbol 25
40#define LEAVEsymbol 26
41#define YIELDsymbol 27
42#define EXITsymbol 29
43
44#define ASSIGNsymbol 40 /* interpreter entry points */
45#define ENDsymbol 41
46#define NOOPsymbol 43 /* no operation required */
47
48#define COMMANDsymbol 61 /* these tokens should be the last group !! */
49#define FUNCTIONsymbol 62 /* the designate the signature start */
50#define FACTORYsymbol 63 /* the co-routine infrastructure */
51#define PATTERNsymbol 64 /* the MAL self-reflection commands */
52
53#define FCNcall 50 /* internal symbols */
54#define FACcall 51
55#define CMDcall 52
56#define THRDcall 53
57#define PATcall 54 /* pattern call */
58
59#define REMsymbol 99 /* commentary to be retained */
60
61mal_export str getTypeName(malType tpe);
62mal_export str getTypeIdentifier(malType tpe);
63mal_export int getAtomIndex(const char *nme, size_t len, int deftpe);
64#define idcmp(n, m) strcmp(n, m)
65mal_export int isIdentifier(str s);
66mal_export int findGDKtype(int type); /* used in src/mal/mal_interpreter.c */
67
68#endif /* MAL_TYPE_H */
69