diff options
Diffstat (limited to 'src/main/java')
| -rw-r--r-- | src/main/java/org/shedlang/compiler/shid/ShidCodeGen.java | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/main/java/org/shedlang/compiler/shid/ShidCodeGen.java b/src/main/java/org/shedlang/compiler/shid/ShidCodeGen.java index 8c9d5f96..59a5bc87 100644 --- a/src/main/java/org/shedlang/compiler/shid/ShidCodeGen.java +++ b/src/main/java/org/shedlang/compiler/shid/ShidCodeGen.java @@ -10,6 +10,7 @@ import org.shedlang.compiler.types.*; import org.shedlang.compiler.util.Iterables; import org.shedlang.compiler.util.P; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.List; @@ -578,9 +579,7 @@ public class ShidCodeGen { var structType = node.typeOrConstructor().toType(); for (var methodNode : node.methods()) { - var shidFunctionName = context.generateLocalNameForVariable( - "$methods__" + String.join("_", structType.namespaceName().parts()) + "__" + structType.name() + "__" + methodNode.name() - ); + var shidFunctionName = methodToShidLocalName(structType, methodNode.name()); context = compileFunction( shidFunctionName, methodNode.signature().params(), @@ -610,6 +609,18 @@ public class ShidCodeGen { return context; } + private static String methodToShidLocalName( + SimpleStructType structType, + String methodName + ) { + return MessageFormat.format( + "$methods__{0}__{1}__{2}", + String.join("_", structType.namespaceName().parts()), + structType.name(), + methodName + ); + } + private static Context compileSumTypeDefinition( TypedSumTypeDefinitionNode node, Context context |
