-
Notifications
You must be signed in to change notification settings - Fork 4
/
builtins.mpl
156 lines (145 loc) · 9.84 KB
/
builtins.mpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# Copyright (C) 2021 Matway Burkow
#
# This repository and all its contents belong to Matway Burkow (referred here and below as "the owner").
# The content is for demonstration purposes only.
# It is forbidden to use the content or any part of it for any purpose without explicit permission from the owner.
# By contributing to the repository, contributors acknowledge that ownership of their work transfers to the owner.
"String" use
"control" use
"Block" use
"Var" use
"builtinImpl" use
"codeNode" use
"defaultImpl" use
"processor" use
builtins: (
{name: "!" ; impl: @mplBuiltinExclamation ;}
{name: "&" ; impl: @mplBuiltinStrCat ;}
{name: "*" ; impl: @mplBuiltinMul ;}
{name: "+" ; impl: @mplBuiltinAdd ;}
{name: "-" ; impl: @mplBuiltinSub ;}
{name: "/" ; impl: @mplBuiltinDiv ;}
{name: "<" ; impl: @mplBuiltinLess ;}
{name: "=" ; impl: @mplBuiltinEqual ;}
{name: ">" ; impl: @mplBuiltinGreater ;}
{name: "@" ; impl: @mplBuiltinAt ;}
{name: "COMPILER_VERSION" ; impl: @mplBuiltinCompilerVersion ;}
{name: "DEBUG" ; impl: @mplBuiltinDebug ;}
{name: "FALSE" ; impl: @mplBuiltinFalse ;}
{name: "LF" ; impl: @mplBuiltinLF ;}
{name: "TRUE" ; impl: @mplBuiltinTrue ;}
{name: "^" ; impl: @mplBuiltinPow ;}
{name: "addressToReference" ; impl: @mplBuiltinAddressToReference ;}
{name: "alignment" ; impl: @mplBuiltinAlignment ;}
{name: "and" ; impl: @mplBuiltinAnd ;}
{name: "array" ; impl: @mplBuiltinArray ;}
{name: "attribute" ; impl: @mplBuiltinAttribute ;}
{name: "call" ; impl: @mplBuiltinCall ;}
{name: "callField" ; impl: @mplBuiltinCallField ;}
{name: "cast" ; impl: @mplBuiltinCast ;}
{name: "ceil" ; impl: @mplBuiltinCeil ;}
{name: "code?" ; impl: @mplBuiltinCodeQuestion ;}
{name: "codeRef" ; impl: @mplBuiltinCodeRef ;}
{name: "codeRef?" ; impl: @mplBuiltinCodeRefQuestion ;}
{name: "codeTokenCount" ; impl: @mplBuiltinCodeTokenCount ;}
{name: "codeTokenRead" ; impl: @mplBuiltinCodeTokenRead ;}
{name: "compileOnce" ; impl: @mplBuiltinCompileOnce ;}
{name: "const" ; impl: @mplBuiltinConst ;}
{name: "cos" ; impl: @mplBuiltinCos ;}
{name: "def" ; impl: @mplBuiltinDef ;}
{name: "dynamic" ; impl: @mplBuiltinDynamic ;}
{name: "exportFunction" ; impl: @mplBuiltinExportFunction ;}
{name: "exportVariable" ; impl: @mplBuiltinExportVariable ;}
{name: "failProc" ; impl: @mplBuiltinFailProc ;}
{name: "fieldCount" ; impl: @mplBuiltinFieldCount ;}
{name: "fieldIndex" ; impl: @mplBuiltinFieldIndex ;}
{name: "fieldIsRef" ; impl: @mplBuiltinFieldIsRef ;}
{name: "fieldIsVirtual" ; impl: @mplBuiltinFieldIsVirtual ;}
{name: "fieldName" ; impl: @mplBuiltinFieldName ;}
{name: "fieldRead" ; impl: @mplBuiltinFieldRead ;}
{name: "fieldWrite" ; impl: @mplBuiltinFieldWrite ;}
{name: "floor" ; impl: @mplBuiltinFloor ;}
{name: "getCallTrace" ; impl: @mplBuiltinGetCallTrace ;}
{name: "has" ; impl: @mplBuiltinHas ;}
{name: "if" ; impl: @mplBuiltinIf ;}
{name: "importFunction" ; impl: @mplBuiltinImportFunction ;}
{name: "importVariable" ; impl: @mplBuiltinImportVariable ;}
{name: "is" ; impl: @mplBuiltinIs ;}
{name: "isCombined" ; impl: @mplBuiltinIsCombined ;}
{name: "isConst" ; impl: @mplBuiltinIsConst ;}
{name: "isDirty" ; impl: @mplBuiltinIsDirty ;}
{name: "isDynamic" ; impl: @mplBuiltinIsDynamic ;}
{name: "isRef" ; impl: @mplBuiltinIsRef ;}
{name: "isStatic" ; impl: @mplBuiltinIsStatic ;}
{name: "log" ; impl: @mplBuiltinLog ;}
{name: "log10" ; impl: @mplBuiltinLog10 ;}
{name: "loop" ; impl: @mplBuiltinLoop ;}
{name: "lshift" ; impl: @mplBuiltinLShift ;}
{name: "manuallyDestroyVariable" ; impl: @mplBuiltinManuallyDestroyVariable ;}
{name: "manuallyInitVariable" ; impl: @mplBuiltinManuallyInitVariable ;}
{name: "mod" ; impl: @mplBuiltinMod ;}
{name: "neg" ; impl: @mplBuiltinNeg ;}
{name: "new" ; impl: @mplBuiltinNew ;}
{name: "newVarOfTheSameType" ; impl: @mplBuiltinNewVarOfTheSameType ;}
{name: "or" ; impl: @mplBuiltinOr ;}
{name: "overload" ; impl: @mplBuiltinOverload ;}
{name: "printCompilerMaxAllocationSize"; impl: @mplPrintCompilerMaxAllocationSize ;}
{name: "printCompilerMessage" ; impl: @mplBuiltinPrintCompilerMessage ;}
{name: "printMatchingTree" ; impl: @mplBuiltinPrintMatchingTree ;}
{name: "printShadowEvents" ; impl: @mplBuiltinPrintShadowEvents ;}
{name: "printStack" ; impl: @mplBuiltinPrintStack ;}
{name: "printStackTrace" ; impl: @mplBuiltinPrintStackTrace ;}
{name: "private" ; impl: @mplBuiltinPrivate ;}
{name: "raiseStaticError" ; impl: @mplBuiltinRaiseStaticError ;}
{name: "recursive" ; impl: @mplBuiltinRecursive ;}
{name: "rshift" ; impl: @mplBuiltinRShift ;}
{name: "same" ; impl: @mplBuiltinSame ;}
{name: "schemaName" ; impl: @mplBuiltinSchemaName ;}
{name: "set" ; impl: @mplBuiltinSet ;}
{name: "sin" ; impl: @mplBuiltinSin ;}
{name: "sqrt" ; impl: @mplBuiltinSqrt ;}
{name: "static" ; impl: @mplBuiltinStatic ;}
{name: "storageAddress" ; impl: @mplBuiltinStorageAddress ;}
{name: "storageSize" ; impl: @mplBuiltinStorageSize ;}
{name: "textSize" ; impl: @mplBuiltinTextSize ;}
{name: "textSplit" ; impl: @mplBuiltinTextSplit ;}
{name: "ucall" ; impl: @mplBuiltinUcall ;}
{name: "uif" ; impl: @mplBuiltinUif ;}
{name: "unconst" ; impl: @mplBuiltinUnconst ;}
{name: "use" ; impl: @mplBuiltinUse ;}
{name: "virtual" ; impl: @mplBuiltinVirtual ;}
{name: "virtual?" ; impl: @mplBuiltinVirtualQuestion ;}
{name: "xor" ; impl: @mplBuiltinXor ;}
{name: "~" ; impl: @mplBuiltinNot ;}
);
builtinFirst: [0 static];
builtinLast: [builtins fieldCount 0 cast 2 /];
addBuiltin: [
id: new;
name:;
nameId: @name makeStringView @[email protected];
bvar: @id VarBuiltin @processor @block createVariable Virtual @processor @block makeStaticity;
{
addNameCase: NameCaseLocal;
refToVar: bvar new;
nameInfo: nameId new;
file: 0 processor.files.at.get;
} @processor @block addNameInfo
];
initBuiltins: [
processor:;
codeNode: 0 @[email protected];
block: @codeNode;
overload failProc: processor block FailProcForProcessor;
builtins fieldCount dynamic [
i builtins @ .name makeStringView i addBuiltin
] times
];
{block: Block Ref; processor: Processor Ref; index: Int32;} () {} [
block:;
processor:;
overload failProc: processor block FailProcForProcessor;
index: new;
builtinFunc: index builtins @ .@impl;
@block @processor @builtinFunc call
] "callBuiltin" exportFunction