forked from ovr/StaticScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcpp.mangler.ts
More file actions
23 lines (20 loc) · 786 Bytes
/
cpp.mangler.ts
File metadata and controls
23 lines (20 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import * as ts from 'typescript';
export class CPPMangler {
static getFunctionName(name: string, parameters: ts.NodeArray<ts.ParameterDeclaration>): string {
return '_Z' + name.length + name + parameters.map(
(parameter) => {
if (parameter.type) {
switch (parameter.type.kind) {
case ts.SyntaxKind.NumberKeyword:
return 'd';
default:
throw new Error(
`Unsupported mangling parameter type: ${parameter.type.kind}`
);
}
}
throw new Error('Unsupported mangling without type');
}
);
}
}