-
Notifications
You must be signed in to change notification settings - Fork 3
/
error_compiler.cpp
71 lines (57 loc) · 1.61 KB
/
error_compiler.cpp
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
#include "error_compiler.h"
#include "runtime_error.h"
using namespace asmjit;
void vaiven::ErrorCompiler::intTypeError() {
cc.jmp(intTypeErrorLabel);
hasIntTypeError = true;
}
void vaiven::ErrorCompiler::boolTypeError() {
cc.jmp(boolTypeErrorLabel);
hasBoolTypeError = true;
}
void vaiven::ErrorCompiler::stringTypeError() {
cc.jmp(stringTypeErrorLabel);
hasStringTypeError = true;
}
void vaiven::ErrorCompiler::noFuncError() {
cc.jmp(noFuncErrorLabel);
hasNoFuncError = true;
}
void vaiven::ErrorCompiler::noVarError() {
cc.jmp(noVarErrorLabel);
hasNoVarError = true;
}
void vaiven::ErrorCompiler::dupVarError() {
cc.jmp(dupVarErrorLabel);
hasDupVarError = true;
}
void vaiven::ErrorCompiler::generateTypeErrorEpilog() {
if (hasIntTypeError) {
cc.bind(intTypeErrorLabel);
cc.call((size_t) &expectedInt, FuncSignature0<void>());
}
if (hasDoubleConvertableTypeError) {
cc.bind(doubleConvertableTypeErrorLabel);
cc.call((size_t) &expectedIntOrDouble, FuncSignature0<void>());
}
if (hasBoolTypeError) {
cc.bind(boolTypeErrorLabel);
cc.call((size_t) &expectedBool, FuncSignature0<void>());
}
if (hasStringTypeError) {
cc.bind(stringTypeErrorLabel);
cc.call((size_t) &expectedStr, FuncSignature0<void>());
}
if (hasNoFuncError) {
cc.bind(noFuncErrorLabel);
cc.call((size_t) &noSuchFunction, FuncSignature0<void>());
}
if (hasNoVarError) {
cc.bind(noVarErrorLabel);
cc.call((size_t) &noSuchVar, FuncSignature0<void>());
}
if (hasDupVarError) {
cc.bind(dupVarErrorLabel);
cc.call((size_t) &duplicateVar, FuncSignature0<void>());
}
}