-
Notifications
You must be signed in to change notification settings - Fork 46
/
lib.bal
60 lines (54 loc) · 1.9 KB
/
lib.bal
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
import wso2/nballerina.types as t;
type LangLibFunction [LangLibModuleName, string, readonly & t:SemType[], t:SemType];
type LangLibModuleName "boolean"|"int"|"float"|"decimal"|"string"|"error"|"array"|"map";
final readonly & LangLibFunction[] langLibFunctions = [
["string", "length", [t:STRING], t:INT],
["array", "length", [t:LIST], t:INT],
["array", "push", [t:LIST, t:VAL], t:NIL],
["map", "length", [t:MAPPING], t:INT],
["int", "toHexString", [t:INT], t:STRING],
["error", "message", [t:ERROR], t:STRING]
];
function getLangLibFunction(string mod, string func) returns t:FunctionSignature? {
foreach var [moduleName, functionName, paramTypes, returnType] in langLibFunctions {
if moduleName == mod && functionName == func {
return { returnType, paramTypes };
}
}
return ();
}
final readonly & map<t:FunctionSignature> ioLibFunctions = {
println: { paramTypes: [t:LIST], returnType: t:NIL, restParamType: t:VAL }
};
type ModuleExportSemtypes readonly & map<t:SemType>;
final readonly & map<Import> autoImportPrefixes = {
"int": {
moduleId: {org: "ballerina", names: ["lang", "int"]},
defns: {
Signed8: t:intWidthSigned(8),
Signed16: t:intWidthSigned(16),
Signed32: t:intWidthSigned(32),
Unsigned8: t:BYTE,
Unsigned16: t:intWidthUnsigned(16),
Unsigned32: t:intWidthUnsigned(32)
},
partial: true
},
"string": {
moduleId: {org: "ballerina", names: ["lang", "string"]},
defns: {
Char: t:STRING_CHAR
},
partial: true
},
"xml": {
moduleId: {org: "ballerina", names: ["lang", "xml"]},
defns: {
Element: t:XML_ELEMENT,
Comment: t:XML_COMMENT,
Text: t:XML_TEXT,
ProcessingInstruction: t:XML_PI
},
partial: true
}
};