diff options
| author | Michael Williamson <mike@zwobble.org> | 2024-12-22 10:06:48 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2024-12-22 10:06:48 +0000 |
| commit | 17d8c3a77c635c2646002d506fa1027a16564ec5 (patch) | |
| tree | 4b0602303994151d1d8da288cac96b4185399ff4 /src/main/java | |
| parent | 867dd179530e90ae16fe481c0abc58dc8f023f94 (diff) | |
Extract methodToShidLocalName()
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 |
