1 #include "codegen/Mangling.h"
8 void Mangler::MangleCanonicalName(std::string_view name) {
9 for(
unsigned i = 0; i < name.size(); i++) {
10 unsigned partSize = 0;
11 for(
unsigned j = i; j < name.size() && name[j] !=
'.'; j++, partSize++)
13 ss << partSize << name.substr(i, partSize);
20 if(ty->isPrimitive()) {
21 auto* bt = cast<ast::BuiltInType>(ty);
22 switch(bt->getKind()) {
23 case ast::BuiltInType::Kind::Boolean:
26 case ast::BuiltInType::Kind::Char:
29 case ast::BuiltInType::Kind::Short:
32 case ast::BuiltInType::Kind::Int:
35 case ast::BuiltInType::Kind::Byte:
38 case ast::BuiltInType::Kind::String:
42 assert(
false &&
"None type not supported");
44 }
else if(ty->isArray()) {
46 MangleType(cast<ast::ArrayType>(ty)->getElementType());
50 if(rt == NR.GetJavaLang().String) {
52 }
else if(rt == NR.GetJavaLang().Object) {
56 MangleCanonicalName(rt->getCanonicalName());
61 void Mangler::MangleFunctionName(ast::MethodDecl
const* decl) {
63 if(!decl->modifiers().isStatic()) ss <<
"C";
67 if(decl->returnTy().type)
68 MangleType(decl->returnTy().type);
71 for(
auto* param : decl->parameters()) {
72 MangleType(param->type());