-
Notifications
You must be signed in to change notification settings - Fork 0
/
typeChecker.ahk
49 lines (44 loc) · 1.32 KB
/
typeChecker.ahk
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
checkType(val, typeChecking, errMsg := 0) {
if (val = 0 || val = "") {
return
}
if(typeChecking is Array) {
for t in typeChecking {
if (val is t) {
return
} else {
continue
}
}
throw TypeError(Format("{1}; `n`nCurrent Type: {2}", errMsg, Type(val)))
}
if (!(val is typeChecking)) {
throw TypeError(Format("{1}; `n`nCurrent Type: {2}", errMsg, Type(val)))
}
}
checkTypeDepend(depend) {
if (depend = 0) {
return
}
errMsg := "Forth(depend signal) parameter is not a Signal or an array containing Signals"
if (depend is Array) {
for item in depend {
if (!(item is signal || item is computed)) {
throw TypeError(Format("{1}; `n`nCurrent Type: {2}", errMsg, Type(depend)))
}
}
} else if (!(depend is signal || depend is computed)) {
throw TypeError(Format("{1}; `n`nCurrent Type: {2}", errMsg, Type(depend)))
}
}
checkTypeEvent(e) {
if (e = 0) {
return
}
errMsg := "Fifth(event) parameter is not an [ event, callback ] array."
if (e is Array && e.Length != 2) {
throw TypeError(errMsg)
} else {
checkType(e, Array, errMsg)
}
}