aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-12-20 17:07:02 +0000
committerMichael Williamson <mike@zwobble.org>2023-12-20 17:08:49 +0000
commitfc115476216f364d947804cce2202b428d8afd6f (patch)
treeaa106a2639d127486d90cc40170bae3a7b30a221 /src/main/java
parentc4b8cef3e2cc580f9f74dfdfb061d8d6dd49ca0f (diff)
Rename PatioCodeGen to ShidToPatio
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/shedlang/compiler/backends/PatioTextBackend.java8
-rw-r--r--src/main/java/org/shedlang/compiler/backends/llvm/LlvmBackend.java12
-rw-r--r--src/main/java/org/shedlang/compiler/backends/wasm/WasmBackend.java12
-rw-r--r--src/main/java/org/shedlang/compiler/patio/PatioCodeGenClosures.java78
-rw-r--r--src/main/java/org/shedlang/compiler/patio/PatioCodeGenResult.java4
-rw-r--r--src/main/java/org/shedlang/compiler/patio/ShidToPatio.java (renamed from src/main/java/org/shedlang/compiler/patio/PatioCodeGen.java)210
-rw-r--r--src/main/java/org/shedlang/compiler/patio/ShidToPatioCompilationUnitElementSpace.java (renamed from src/main/java/org/shedlang/compiler/patio/PatioCodeGenCompilationUnitElementSpace.java)4
-rw-r--r--src/main/java/org/shedlang/compiler/patio/ShidToPatioContext.java (renamed from src/main/java/org/shedlang/compiler/patio/PatioCodeGenContext.java)114
-rw-r--r--src/main/java/org/shedlang/compiler/patio/ShidToPatioEffects.java (renamed from src/main/java/org/shedlang/compiler/patio/PatioCodeGenEffects.java)92
-rw-r--r--src/main/java/org/shedlang/compiler/patio/ShidToPatioFunctions.java (renamed from src/main/java/org/shedlang/compiler/patio/PatioCodeGenFunctions.java)18
-rw-r--r--src/main/java/org/shedlang/compiler/patio/ShidToPatioGc.java (renamed from src/main/java/org/shedlang/compiler/patio/PatioCodeGenGc.java)44
-rw-r--r--src/main/java/org/shedlang/compiler/patio/ShidToPatioInts.java (renamed from src/main/java/org/shedlang/compiler/patio/PatioCodeGenInts.java)48
-rw-r--r--src/main/java/org/shedlang/compiler/patio/ShidToPatioLocalSpace.java (renamed from src/main/java/org/shedlang/compiler/patio/PatioCodeGenLocalSpace.java)4
-rw-r--r--src/main/java/org/shedlang/compiler/patio/ShidToPatioNamespaces.java (renamed from src/main/java/org/shedlang/compiler/patio/PatioCodeGenNamespaces.java)44
-rw-r--r--src/main/java/org/shedlang/compiler/patio/ShidToPatioResult.java4
-rw-r--r--src/main/java/org/shedlang/compiler/patio/ShidToPatioStrings.java (renamed from src/main/java/org/shedlang/compiler/patio/PatioCodeGenStrings.java)22
-rw-r--r--src/main/java/org/shedlang/compiler/patio/ShidToPatioStructs.java (renamed from src/main/java/org/shedlang/compiler/patio/PatioCodeGenStructs.java)42
-rw-r--r--src/main/java/org/shedlang/compiler/patio/ShidToPatioTuples.java (renamed from src/main/java/org/shedlang/compiler/patio/PatioCodeGenTuples.java)32
-rw-r--r--src/main/java/org/shedlang/compiler/patio/ShidToPatioTypes.java (renamed from src/main/java/org/shedlang/compiler/patio/PatioCodeGenTypes.java)4
-rw-r--r--src/main/java/org/shedlang/compiler/patio/ShidToPatioVars.java (renamed from src/main/java/org/shedlang/compiler/patio/PatioCodeGenVars.java)24
20 files changed, 410 insertions, 410 deletions
diff --git a/src/main/java/org/shedlang/compiler/backends/PatioTextBackend.java b/src/main/java/org/shedlang/compiler/backends/PatioTextBackend.java
index 7bc2e925..bff63368 100644
--- a/src/main/java/org/shedlang/compiler/backends/PatioTextBackend.java
+++ b/src/main/java/org/shedlang/compiler/backends/PatioTextBackend.java
@@ -2,8 +2,8 @@ package org.shedlang.compiler.backends;
import org.shedlang.compiler.backends.paths.TargetDir;
import org.shedlang.compiler.config.ProjectConfig;
-import org.shedlang.compiler.patio.PatioCodeGen;
-import org.shedlang.compiler.patio.PatioCodeGenContext;
+import org.shedlang.compiler.patio.ShidToPatio;
+import org.shedlang.compiler.patio.ShidToPatioContext;
import org.shedlang.compiler.patio.ast.PatioSerializer;
import org.shedlang.compiler.shid.ShidNamespace;
import org.shedlang.compiler.typechecker.TypeInfos;
@@ -24,10 +24,10 @@ public class PatioTextBackend implements Backend {
TypeInfos typeInfos,
TargetDir targetDir
) throws IOException {
- var context = PatioCodeGenContext.forTypeInfos(typeInfos);
+ var context = ShidToPatioContext.forTypeInfos(typeInfos);
for (var namespace : namespaces) {
- var compilationUnit = PatioCodeGen.generateNamespace(
+ var compilationUnit = ShidToPatio.generateNamespace(
namespace,
context
);
diff --git a/src/main/java/org/shedlang/compiler/backends/llvm/LlvmBackend.java b/src/main/java/org/shedlang/compiler/backends/llvm/LlvmBackend.java
index 83a27345..4d628d75 100644
--- a/src/main/java/org/shedlang/compiler/backends/llvm/LlvmBackend.java
+++ b/src/main/java/org/shedlang/compiler/backends/llvm/LlvmBackend.java
@@ -15,8 +15,8 @@ import org.shedlang.compiler.backends.llvm.ir.ast.types.LlvmTypes;
import org.shedlang.compiler.backends.paths.TargetDir;
import org.shedlang.compiler.config.ProjectConfig;
import org.shedlang.compiler.filesystem.ShedCompilerFiles;
-import org.shedlang.compiler.patio.PatioCodeGen;
-import org.shedlang.compiler.patio.PatioCodeGenContext;
+import org.shedlang.compiler.patio.ShidToPatio;
+import org.shedlang.compiler.patio.ShidToPatioContext;
import org.shedlang.compiler.shid.ShidNamespace;
import org.shedlang.compiler.sources.Sources;
import org.shedlang.compiler.typechecker.TypeInfos;
@@ -54,9 +54,9 @@ public class LlvmBackend implements Backend {
var globalContext = PatioToLlvmGlobalContext.EMPTY;
for (var namespace : namespaces) {
- var patioCompilationUnit = PatioCodeGen.generateNamespace(
+ var patioCompilationUnit = ShidToPatio.generateNamespace(
namespace,
- PatioCodeGenContext.forTypeInfos(typeInfos)
+ ShidToPatioContext.forTypeInfos(typeInfos)
);
var llvmModuleResult = PatioToLlvm.generateCompilationUnit(
@@ -109,9 +109,9 @@ public class LlvmBackend implements Backend {
// TODO: use more appropriate source
var source = Sources.NULL;
- var context = PatioCodeGenContext.forTypeInfos(typeInfos);
+ var context = ShidToPatioContext.forTypeInfos(typeInfos);
- var generateMainResult = PatioCodeGen.generateMain(main, source, context);
+ var generateMainResult = ShidToPatio.generateMain(main, source, context);
var mainFunctionName = generateMainResult.value();
context = generateMainResult.context();
diff --git a/src/main/java/org/shedlang/compiler/backends/wasm/WasmBackend.java b/src/main/java/org/shedlang/compiler/backends/wasm/WasmBackend.java
index b4af6a7c..a3e376c3 100644
--- a/src/main/java/org/shedlang/compiler/backends/wasm/WasmBackend.java
+++ b/src/main/java/org/shedlang/compiler/backends/wasm/WasmBackend.java
@@ -12,8 +12,8 @@ import org.shedlang.compiler.backends.wasm.structure.ast.modules.WasmFunction;
import org.shedlang.compiler.backends.wasm.structure.ast.modules.WasmModule;
import org.shedlang.compiler.config.ProjectConfig;
import org.shedlang.compiler.filesystem.ShedCompilerFiles;
-import org.shedlang.compiler.patio.PatioCodeGen;
-import org.shedlang.compiler.patio.PatioCodeGenContext;
+import org.shedlang.compiler.patio.ShidToPatio;
+import org.shedlang.compiler.patio.ShidToPatioContext;
import org.shedlang.compiler.shid.ShidNamespace;
import org.shedlang.compiler.sources.Sources;
import org.shedlang.compiler.typechecker.TypeInfos;
@@ -46,9 +46,9 @@ public class WasmBackend implements Backend {
) throws IOException, InterruptedException {
var objectFilePaths = new ArrayList<Path>();
for (var namespace : namespaces) {
- var patioCompilationUnit = PatioCodeGen.generateNamespace(
+ var patioCompilationUnit = ShidToPatio.generateNamespace(
namespace,
- PatioCodeGenContext.forTypeInfos(typeInfos)
+ ShidToPatioContext.forTypeInfos(typeInfos)
);
var wasmModule = PatioToWasm.generateCompilationUnit(patioCompilationUnit);
@@ -92,9 +92,9 @@ public class WasmBackend implements Backend {
// TODO: set appropriate source
var source = Sources.NULL;
- var context = PatioCodeGenContext.forTypeInfos(typeInfos);
+ var context = ShidToPatioContext.forTypeInfos(typeInfos);
- var generateMainResult = PatioCodeGen.generateMain(main, source, context);
+ var generateMainResult = ShidToPatio.generateMain(main, source, context);
var mainFunctionName = generateMainResult.value();
context = generateMainResult.context();
diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenClosures.java b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenClosures.java
index 593d76fe..3171e750 100644
--- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenClosures.java
+++ b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenClosures.java
@@ -23,14 +23,14 @@ import java.util.stream.Stream;
import static org.shedlang.compiler.util.Iterables.sortedBy;
-class PatioCodeGenClosures {
+class ShidToPatioClosures {
public static final PatioType CLOSURE_POINTER_TYPE = PatioTypes.DATA_POINTER;
- public static final PatioType CLOSURE_TYPE = PatioCodeGenTypes.VALUE_TYPE;
+ public static final PatioType CLOSURE_TYPE = ShidToPatioTypes.VALUE_TYPE;
- private PatioCodeGenClosures() {}
+ private ShidToPatioClosures() {}
private static PatioDataLayout closureDataLayoutForCall() {
- return PatioCodeGenGc.gcObjectDataLayout(PatioDataLayouts.struct(List.of(
+ return ShidToPatioGc.gcObjectDataLayout(PatioDataLayouts.struct(List.of(
PatioDataLayouts.FUNCTION_POINTER
)));
}
@@ -38,9 +38,9 @@ class PatioCodeGenClosures {
static PatioDataLayout closureDataLayout(
PatioDataLayout additional,
FreeVariables freeVariables,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
- return PatioCodeGenGc.gcObjectDataLayout(PatioDataLayouts.struct(List.of(
+ return ShidToPatioGc.gcObjectDataLayout(PatioDataLayouts.struct(List.of(
PatioDataLayouts.FUNCTION_POINTER,
additional,
PatioDataLayouts.struct(
@@ -54,25 +54,25 @@ class PatioCodeGenClosures {
}
static final List<Integer> FUNCTION_POINTER_OFFSET
- = PatioCodeGenGc.gcObjectOffset(List.of(0));
+ = ShidToPatioGc.gcObjectOffset(List.of(0));
static List<Integer> additionalOffset(List<Integer> offset) {
- return PatioCodeGenGc.gcObjectOffset(P.vector(1).plusAll(offset));
+ return ShidToPatioGc.gcObjectOffset(P.vector(1).plusAll(offset));
}
private static List<Integer> freeVariableOffset(
FreeVariable freeVariable
) {
- return PatioCodeGenGc.gcObjectOffset(List.of(2, freeVariable.index()));
+ return ShidToPatioGc.gcObjectOffset(List.of(2, freeVariable.index()));
}
private static final List<Integer> GC_CHILDREN_OFFSET =
- PatioCodeGenGc.gcObjectOffset(List.of(2));
+ ShidToPatioGc.gcObjectOffset(List.of(2));
- static PatioCodeGenContext defineParams(
+ static ShidToPatioContext defineParams(
List<ShidDefineFunction.Param> positionalParams,
List<ShidDefineFunction.Param> namedParams,
- PatioCodeGenContext bodyContext
+ ShidToPatioContext bodyContext
) {
var orderedNamedParams = sortedBy(namedParams, param -> param.name());
var shidParams = Stream.concat(positionalParams.stream(), orderedNamedParams.stream()).toList();
@@ -84,18 +84,18 @@ class PatioCodeGenClosures {
return bodyContext;
}
- static PatioCodeGenContext create(
+ static ShidToPatioContext create(
PatioLocalRef target,
- PatioCodeGenCompilationUnitElementSpace functionElementSpace,
+ ShidToPatioCompilationUnitElementSpace functionElementSpace,
String name,
List<ShidDefineFunction.Param> positionalParams,
List<ShidDefineFunction.Param> namedParams,
PatioDataLayout layout,
- BiFunction<PatioLocalRef, PatioCodeGenContext, PatioCodeGenContext> storeAdditional,
+ BiFunction<PatioLocalRef, ShidToPatioContext, ShidToPatioContext> storeAdditional,
FreeVariables freeVariables,
- BiFunction<PatioLocalRef, PatioCodeGenContext, PatioCodeGenContext> generateBody,
+ BiFunction<PatioLocalRef, ShidToPatioContext, ShidToPatioContext> generateBody,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
var fullNameResult = context.allocateCompilationUnitElementName(
functionElementSpace,
@@ -105,10 +105,10 @@ class PatioCodeGenClosures {
context = fullNameResult.context();
var bodyContextParent = context;
- context = context.createFunction(fullName, PatioVisibility.PRIVATE, PatioCodeGenTypes.VALUE_TYPE, source, bodyContext -> {
+ context = context.createFunction(fullName, PatioVisibility.PRIVATE, ShidToPatioTypes.VALUE_TYPE, source, bodyContext -> {
var closurePointerResult = bodyContext.allocateParam(
- PatioCodeGenLocalSpace.CLOSURE_POINTER,
- PatioCodeGenClosures.CLOSURE_POINTER_TYPE
+ ShidToPatioLocalSpace.CLOSURE_POINTER,
+ ShidToPatioClosures.CLOSURE_POINTER_TYPE
);
var closurePointer = closurePointerResult.value();
bodyContext = closurePointerResult.context();
@@ -124,14 +124,14 @@ class PatioCodeGenClosures {
bodyContextParent
);
- bodyContext = PatioCodeGenGc.saveGcRootStack(source, bodyContext);
+ bodyContext = ShidToPatioGc.saveGcRootStack(source, bodyContext);
bodyContext = generateBody.apply(closurePointer, bodyContext);
return bodyContext;
});
- context = PatioCodeGenClosures.alloc(
+ context = ShidToPatioClosures.alloc(
target,
name,
fullName,
@@ -145,25 +145,25 @@ class PatioCodeGenClosures {
return context;
}
- static PatioCodeGenContext alloc(
+ static ShidToPatioContext alloc(
PatioLocalRef target,
String name,
String functionName,
PatioDataLayout layout,
- BiFunction<PatioLocalRef, PatioCodeGenContext, PatioCodeGenContext> storeAdditional,
+ BiFunction<PatioLocalRef, ShidToPatioContext, ShidToPatioContext> storeAdditional,
FreeVariables freeVariables,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
var closurePointerResult = context.allocateVal(
- PatioCodeGenLocalSpace.CLOSURE_POINTER,
+ ShidToPatioLocalSpace.CLOSURE_POINTER,
name,
PatioTypes.DATA_POINTER
);
var closurePointer = closurePointerResult.value();
context = closurePointerResult.context();
- context = PatioCodeGenGc.alloc(
+ context = ShidToPatioGc.alloc(
closurePointer,
layout,
GC_CHILDREN_OFFSET,
@@ -199,12 +199,12 @@ class PatioCodeGenClosures {
return context;
}
- static PatioCodeGenContext storeFreeVariables(
+ static ShidToPatioContext storeFreeVariables(
FreeVariables freeVariables,
PatioLocalRef closurePointer,
PatioDataLayout closureLayout,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
for (var freeVariable : freeVariables) {
context = context.onceShidLocalDefined(
@@ -221,13 +221,13 @@ class PatioCodeGenClosures {
return context;
}
- static PatioCodeGenContext loadFreeVariables(
+ static ShidToPatioContext loadFreeVariables(
FreeVariables freeVariables,
PatioLocalRef closurePointer,
PatioDataLayout closureLayout,
Source source,
- PatioCodeGenContext bodyContext,
- PatioCodeGenContext bodyContextParent
+ ShidToPatioContext bodyContext,
+ ShidToPatioContext bodyContextParent
) {
for (var freeVariable : freeVariables) {
var freeVariableLocalResult = bodyContext.declareShidVal(
@@ -250,24 +250,24 @@ class PatioCodeGenClosures {
return bodyContext;
}
- static PatioCodeGenContext beforeExit(
+ static ShidToPatioContext beforeExit(
List<PatioOperand> escapees,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
- return PatioCodeGenGc.restoreGcRootStack(escapees, source, context);
+ return ShidToPatioGc.restoreGcRootStack(escapees, source, context);
}
- static PatioCodeGenContext call(
+ static ShidToPatioContext call(
PatioLocalRef target,
PatioLocalRef closure,
List<PatioLocalRef> positionalArgs,
List<Map.Entry<String, PatioLocalRef>> namedArgsByName,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
var closurePointerResult = context.allocateVal(
- PatioCodeGenLocalSpace.CLOSURE_POINTER,
+ ShidToPatioLocalSpace.CLOSURE_POINTER,
CLOSURE_POINTER_TYPE
);
var closurePointer = closurePointerResult.value();
@@ -280,7 +280,7 @@ class PatioCodeGenClosures {
));
var functionPointerResult = context.allocateVal(
- PatioCodeGenLocalSpace.CALL_FUNCTION_POINTER,
+ ShidToPatioLocalSpace.CALL_FUNCTION_POINTER,
PatioTypes.FUNCTION_POINTER
);
var functionPointer = functionPointerResult.value();
diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenResult.java b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenResult.java
deleted file mode 100644
index 5644a3b1..00000000
--- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenResult.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package org.shedlang.compiler.patio;
-
-public record PatioCodeGenResult<T>(T value, PatioCodeGenContext context) {
-}
diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGen.java b/src/main/java/org/shedlang/compiler/patio/ShidToPatio.java
index ccacdf8e..49fd0e03 100644
--- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGen.java
+++ b/src/main/java/org/shedlang/compiler/patio/ShidToPatio.java
@@ -18,21 +18,21 @@ import java.util.function.Function;
import static org.shedlang.compiler.config.MainFunction.MAIN_FUNCTION_NAME;
-public class PatioCodeGen {
- private PatioCodeGen() {}
+public class ShidToPatio {
+ private ShidToPatio() {}
/**
* Generate a main function by importing the given namespace and calling the
* {@code main} field with no arguments. Callers are responsible for
* ensuring that such a field exists.
*/
- public static PatioCodeGenResult<String> generateMain(
+ public static ShidToPatioResult<String> generateMain(
NamespaceName main,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
var mainFunctionNameResult = context.allocateCompilationUnitElementName(
- PatioCodeGenCompilationUnitElementSpace.MAIN
+ ShidToPatioCompilationUnitElementSpace.MAIN
);
var mainFunctionName = mainFunctionNameResult.value();
context = mainFunctionNameResult.context();
@@ -44,13 +44,13 @@ public class PatioCodeGen {
source,
mainContext -> {
var namespaceValueResult = mainContext.allocateVal(
- PatioCodeGenLocalSpace.NAMESPACE_VALUE,
- PatioCodeGenTypes.VALUE_TYPE
+ ShidToPatioLocalSpace.NAMESPACE_VALUE,
+ ShidToPatioTypes.VALUE_TYPE
);
var namespaceValue = namespaceValueResult.value();
mainContext = namespaceValueResult.context();
- mainContext = PatioCodeGenNamespaces.importValue(
+ mainContext = ShidToPatioNamespaces.importValue(
namespaceValue,
main,
source,
@@ -58,13 +58,13 @@ public class PatioCodeGen {
);
var mainFieldResult = mainContext.allocateVal(
- PatioCodeGenLocalSpace.MAIN,
- PatioCodeGenTypes.VALUE_TYPE
+ ShidToPatioLocalSpace.MAIN,
+ ShidToPatioTypes.VALUE_TYPE
);
var mainField = mainFieldResult.value();
mainContext = mainFieldResult.context();
- mainContext = PatioCodeGenNamespaces.fieldLoad(
+ mainContext = ShidToPatioNamespaces.fieldLoad(
mainField,
namespaceValue,
main,
@@ -74,13 +74,13 @@ public class PatioCodeGen {
);
var exitCodeResult = mainContext.allocateVal(
- PatioCodeGenLocalSpace.MAIN,
- PatioCodeGenTypes.VALUE_TYPE
+ ShidToPatioLocalSpace.MAIN,
+ ShidToPatioTypes.VALUE_TYPE
);
var exitCode = exitCodeResult.value();
mainContext = exitCodeResult.context();
- mainContext = PatioCodeGenClosures.call(
+ mainContext = ShidToPatioClosures.call(
exitCode,
mainField,
List.of(),
@@ -102,9 +102,9 @@ public class PatioCodeGen {
public static PatioCompilationUnit generateNamespace(
ShidNamespace shidNamespace,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
- context = PatioCodeGenNamespaces.define(
+ context = ShidToPatioNamespaces.define(
shidNamespace.namespaceName(),
initContext ->
generateBlockNoResults(shidNamespace.body(), initContext),
@@ -115,9 +115,9 @@ public class PatioCodeGen {
return context.toCompilationUnit(Sources.NULL);
}
- public static PatioCodeGenContext generateInstructions(
+ public static ShidToPatioContext generateInstructions(
List<ShidInstruction> shidInstructions,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
for (var shidInstruction : shidInstructions) {
context = generateInstruction(shidInstruction, context);
@@ -126,9 +126,9 @@ public class PatioCodeGen {
return context;
}
- public static PatioCodeGenContext generateInstruction(
+ public static ShidToPatioContext generateInstruction(
ShidInstruction shidInstruction,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
return switch (shidInstruction) {
case ShidBlock shidBlock -> {
@@ -151,9 +151,9 @@ public class PatioCodeGen {
var namedArgsByName = new ArrayList<Map.Entry<String, PatioLocalRef>>();
for (var argName : call.namedArgNames().reversed()) {
var argResult = context.allocateVal(
- PatioCodeGenLocalSpace.CALL_ARG_NAMED,
+ ShidToPatioLocalSpace.CALL_ARG_NAMED,
argName,
- PatioCodeGenTypes.VALUE_TYPE
+ ShidToPatioTypes.VALUE_TYPE
);
var arg = argResult.value();
context = argResult.context();
@@ -169,9 +169,9 @@ public class PatioCodeGen {
var positionalArgs = new ArrayList<PatioLocalRef>();
for (var i = 0; i < call.positionalArgCount(); i++) {
var argResult = context.allocateVal(
- PatioCodeGenLocalSpace.CALL_ARG_POSITIONAL,
+ ShidToPatioLocalSpace.CALL_ARG_POSITIONAL,
Integer.toString(call.positionalArgCount() - i - 1),
- PatioCodeGenTypes.VALUE_TYPE
+ ShidToPatioTypes.VALUE_TYPE
);
var arg = argResult.value();
context = argResult.context();
@@ -186,8 +186,8 @@ public class PatioCodeGen {
Collections.reverse(positionalArgs);
var receiverResult = context.allocateVal(
- PatioCodeGenLocalSpace.RECEIVER,
- PatioCodeGenTypes.VALUE_TYPE
+ ShidToPatioLocalSpace.RECEIVER,
+ ShidToPatioTypes.VALUE_TYPE
);
var receiver = receiverResult.value();
context = receiverResult.context();
@@ -198,13 +198,13 @@ public class PatioCodeGen {
);
var targetResult = context.allocateVal(
- PatioCodeGenLocalSpace.TEMPORARY,
- PatioCodeGenTypes.VALUE_TYPE
+ ShidToPatioLocalSpace.TEMPORARY,
+ ShidToPatioTypes.VALUE_TYPE
);
var target = targetResult.value();
context = targetResult.context();
- yield PatioCodeGenClosures.call(
+ yield ShidToPatioClosures.call(
target,
receiver,
positionalArgs,
@@ -216,14 +216,14 @@ public class PatioCodeGen {
case ShidDefineEffect defineEffect -> {
var targetResult = context.allocateVal(
- PatioCodeGenLocalSpace.USER_DEFINED_EFFECT,
+ ShidToPatioLocalSpace.USER_DEFINED_EFFECT,
defineEffect.effect().name(),
- PatioCodeGenTypes.VALUE_TYPE
+ ShidToPatioTypes.VALUE_TYPE
);
var target = targetResult.value();
context = targetResult.context();
- context = PatioCodeGenEffects.createUserDefinedEffect(
+ context = ShidToPatioEffects.createUserDefinedEffect(
target,
defineEffect.effect(),
defineEffect.source(),
@@ -237,19 +237,19 @@ public class PatioCodeGen {
case ShidDefineFunction defineFunction -> {
var targetResult = context.allocateVal(
- PatioCodeGenLocalSpace.CLOSURE,
+ ShidToPatioLocalSpace.CLOSURE,
defineFunction.name(),
- PatioCodeGenTypes.VALUE_TYPE
+ ShidToPatioTypes.VALUE_TYPE
);
var target = targetResult.value();
context = targetResult.context();
- Function<PatioCodeGenContext, PatioCodeGenContext> generateBody = functionContext -> {
+ Function<ShidToPatioContext, ShidToPatioContext> generateBody = functionContext -> {
return generateBlockNoResults(defineFunction.body(), functionContext);
};
context = switch (defineFunction.variant()) {
- case EFFECT_HANDLER_METHOD -> PatioCodeGenEffects.createEffectHandlerMethod(
+ case EFFECT_HANDLER_METHOD -> ShidToPatioEffects.createEffectHandlerMethod(
target,
defineFunction.name(),
defineFunction.positionalParams(),
@@ -259,7 +259,7 @@ public class PatioCodeGen {
defineFunction.source(),
context
);
- case FUNCTION -> PatioCodeGenFunctions.create(
+ case FUNCTION -> ShidToPatioFunctions.create(
target,
defineFunction.name(),
defineFunction.positionalParams(),
@@ -278,14 +278,14 @@ public class PatioCodeGen {
case ShidDefineStruct defineStruct -> {
var targetResult = context.allocateVal(
- PatioCodeGenLocalSpace.STRUCT_TYPE,
+ ShidToPatioLocalSpace.STRUCT_TYPE,
defineStruct.type().name(),
- PatioCodeGenTypes.VALUE_TYPE
+ ShidToPatioTypes.VALUE_TYPE
);
var target = targetResult.value();
context = targetResult.context();
- context = PatioCodeGenStructs.createType(
+ context = ShidToPatioStructs.createType(
target,
defineStruct.type(),
defineStruct.fields(),
@@ -314,7 +314,7 @@ public class PatioCodeGen {
var value = valueResult.value();
context = valueResult.context();
- context = PatioCodeGenEffects.break_(
+ context = ShidToPatioEffects.break_(
effectHandlerBreak.effect(),
value,
effectHandlerBreak.source(),
@@ -330,16 +330,16 @@ public class PatioCodeGen {
context = receiverResult.context();
var targetResult = context.allocateVal(
- PatioCodeGenLocalSpace.TEMPORARY,
+ ShidToPatioLocalSpace.TEMPORARY,
fieldLoad.fieldName(),
- PatioCodeGenTypes.VALUE_TYPE
+ ShidToPatioTypes.VALUE_TYPE
);
var target = targetResult.value();
context = targetResult.context();
switch (fieldLoad.receiver()) {
case ShidFieldLoad.Receiver.Effect receiverEffect -> {
- context = PatioCodeGenEffects.fieldLoad(
+ context = ShidToPatioEffects.fieldLoad(
target,
receiver,
receiverEffect.effect(),
@@ -350,7 +350,7 @@ public class PatioCodeGen {
}
case ShidFieldLoad.Receiver.Namespace receiverNamespace -> {
- context = PatioCodeGenNamespaces.fieldLoad(
+ context = ShidToPatioNamespaces.fieldLoad(
target,
receiver,
receiverNamespace.name(),
@@ -361,7 +361,7 @@ public class PatioCodeGen {
}
case ShidFieldLoad.Receiver.Struct receiverStruct -> {
- context = PatioCodeGenStructs.fieldLoad(
+ context = ShidToPatioStructs.fieldLoad(
target,
receiver,
receiverStruct.type(),
@@ -386,8 +386,8 @@ public class PatioCodeGen {
for (var i = 0; i < if_.resultCount(); i++) {
var targetResult = context.allocateVal(
- PatioCodeGenLocalSpace.TEMPORARY,
- PatioCodeGenTypes.VALUE_TYPE
+ ShidToPatioLocalSpace.TEMPORARY,
+ ShidToPatioTypes.VALUE_TYPE
);
var target = targetResult.value();
context = targetResult.context();
@@ -421,7 +421,7 @@ public class PatioCodeGen {
case ShidIntAdd intAdd ->
generateBinaryOperation(
(target, left, right, operationContext) ->
- PatioCodeGenInts.add(
+ ShidToPatioInts.add(
target,
left,
right,
@@ -434,7 +434,7 @@ public class PatioCodeGen {
case ShidIntEquals intEquals ->
generateComparison(
(target, left, right, operationContext) ->
- PatioCodeGenInts.equals(
+ ShidToPatioInts.equals(
target,
left,
right,
@@ -448,7 +448,7 @@ public class PatioCodeGen {
case ShidIntNotEqual intNotEqual ->
generateComparison(
(target, left, right, operationContext) ->
- PatioCodeGenInts.notEqual(
+ ShidToPatioInts.notEqual(
target,
left,
right,
@@ -462,7 +462,7 @@ public class PatioCodeGen {
case ShidIntSub intSub ->
generateBinaryOperation(
(target, left, right, operationContext) ->
- PatioCodeGenInts.sub(
+ ShidToPatioInts.sub(
target,
left,
right,
@@ -517,7 +517,7 @@ public class PatioCodeGen {
var fieldValue = fieldValueResult.value();
context = fieldValueResult.context();
- context = PatioCodeGenNamespaces.fieldStore(
+ context = ShidToPatioNamespaces.fieldStore(
namespaceFieldStore.namespaceName(),
namespaceFieldStore.fieldName(),
fieldValue,
@@ -530,13 +530,13 @@ public class PatioCodeGen {
case ShidNamespaceImport namespaceImport -> {
var namespaceValueResult = context.allocateVal(
- PatioCodeGenLocalSpace.NAMESPACE_VALUE,
- PatioCodeGenNamespaces.NAMESPACE_VALUE_TYPE
+ ShidToPatioLocalSpace.NAMESPACE_VALUE,
+ ShidToPatioNamespaces.NAMESPACE_VALUE_TYPE
);
var namespaceValue = namespaceValueResult.value();
context = namespaceValueResult.context();
- context = PatioCodeGenNamespaces.importValue(
+ context = ShidToPatioNamespaces.importValue(
namespaceValue,
namespaceImport.namespaceName(),
namespaceImport.source(),
@@ -553,13 +553,13 @@ public class PatioCodeGen {
case ShidPushInt pushInt -> {
var targetResult = context.allocateVal(
- PatioCodeGenLocalSpace.INT,
- PatioCodeGenInts.INT_TYPE
+ ShidToPatioLocalSpace.INT,
+ ShidToPatioInts.INT_TYPE
);
var target = targetResult.value();
context = targetResult.context();
- context = PatioCodeGenInts.storeConst(
+ context = ShidToPatioInts.storeConst(
target,
pushInt.value(),
pushInt.source(),
@@ -573,7 +573,7 @@ public class PatioCodeGen {
case ShidPushString pushString -> {
- var stringPtrOperandResult = PatioCodeGenStrings.define(
+ var stringPtrOperandResult = ShidToPatioStrings.define(
pushString.value(),
pushString.source(),
context
@@ -582,8 +582,8 @@ public class PatioCodeGen {
context = stringPtrOperandResult.context();
var stringPtrResult = context.allocateVal(
- PatioCodeGenLocalSpace.STRING,
- PatioCodeGenTypes.VALUE_TYPE
+ ShidToPatioLocalSpace.STRING,
+ ShidToPatioTypes.VALUE_TYPE
);
var stringPtr = stringPtrResult.value();
context = stringPtrResult.context();
@@ -607,13 +607,13 @@ public class PatioCodeGen {
var value = valueResult.value();
context = valueResult.context();
- context = PatioCodeGenClosures.beforeExit(
+ context = ShidToPatioClosures.beforeExit(
List.of(value),
resume.source(),
context
);
- yield PatioCodeGenEffects.resume(value, resume.source(), context);
+ yield ShidToPatioEffects.resume(value, resume.source(), context);
}
case ShidReturn return_ -> {
@@ -626,7 +626,7 @@ public class PatioCodeGen {
}
- context = PatioCodeGenClosures.beforeExit(
+ context = ShidToPatioClosures.beforeExit(
List.of(value),
return_.source(),
context
@@ -638,7 +638,7 @@ public class PatioCodeGen {
case ShidStringAdd stringAdd ->
generateBinaryOperation(
(target, left, right, operationContext) ->
- PatioCodeGenStrings.add(
+ ShidToPatioStrings.add(
target,
left,
right,
@@ -650,8 +650,8 @@ public class PatioCodeGen {
case ShidSwitch switch_ -> {
var targetResult = context.allocateVal(
- PatioCodeGenLocalSpace.TEMPORARY,
- PatioCodeGenTypes.VALUE_TYPE
+ ShidToPatioLocalSpace.TEMPORARY,
+ ShidToPatioTypes.VALUE_TYPE
);
var target = targetResult.value();
context = targetResult.context();
@@ -661,13 +661,13 @@ public class PatioCodeGen {
context = valueResult.context();
var tagResult = context.allocateVal(
- PatioCodeGenLocalSpace.SWITCH_TAG,
- PatioCodeGenTypes.TAG_TYPE
+ ShidToPatioLocalSpace.SWITCH_TAG,
+ ShidToPatioTypes.TAG_TYPE
);
var tag = tagResult.value();
context = tagResult.context();
- context = PatioCodeGenStructs.tagLoad(
+ context = ShidToPatioStructs.tagLoad(
tag,
value,
switch_.source(),
@@ -722,13 +722,13 @@ public class PatioCodeGen {
}
var targetResult = context.allocateVal(
- PatioCodeGenLocalSpace.TEMPORARY,
- PatioCodeGenTypes.VALUE_TYPE
+ ShidToPatioLocalSpace.TEMPORARY,
+ ShidToPatioTypes.VALUE_TYPE
);
var target = targetResult.value();
context = targetResult.context();
- context = PatioCodeGenEffects.try_(
+ context = ShidToPatioEffects.try_(
target,
try_.handledEffect(),
handlerMethodsByName,
@@ -748,9 +748,9 @@ public class PatioCodeGen {
for (var elementIndex = tupleCreate.elementCount(); elementIndex --> 0;) {
var tupleElementResult = context.allocateVal(
- PatioCodeGenLocalSpace.TUPLE_ELEMENT,
+ ShidToPatioLocalSpace.TUPLE_ELEMENT,
Integer.toString(elementIndex),
- PatioCodeGenTypes.VALUE_TYPE
+ ShidToPatioTypes.VALUE_TYPE
);
var tupleElement = tupleElementResult.value();
context = tupleElementResult.context();
@@ -762,7 +762,7 @@ public class PatioCodeGen {
Collections.reverse(elements);
- var tupleResult = PatioCodeGenTuples.create(elements, tupleCreate.source(), context);
+ var tupleResult = ShidToPatioTuples.create(elements, tupleCreate.source(), context);
var tuple = tupleResult.value();
context = tupleResult.context();
@@ -774,7 +774,7 @@ public class PatioCodeGen {
var tuple = tupleResult.value();
context = tupleResult.context();
- var targetResult = PatioCodeGenTuples.get(
+ var targetResult = ShidToPatioTuples.get(
tuple,
tupleGet.elementIndex(),
tupleGet.elementCount(),
@@ -789,14 +789,14 @@ public class PatioCodeGen {
case ShidVarLoad varLoad -> {
var varValueResult = context.allocateVal(
- PatioCodeGenLocalSpace.VAR_VALUE,
+ ShidToPatioLocalSpace.VAR_VALUE,
varLoad.name(),
- PatioCodeGenTypes.VALUE_TYPE
+ ShidToPatioTypes.VALUE_TYPE
);
var varValue = varValueResult.value();
context = varValueResult.context();
- context = PatioCodeGenVars.load(
+ context = ShidToPatioVars.load(
varValue,
varLoad.name(),
varLoad.source(),
@@ -813,7 +813,7 @@ public class PatioCodeGen {
var value = valueResult.value();
context = valueResult.context();
- context = PatioCodeGenVars.store(
+ context = ShidToPatioVars.store(
varStore.name(),
value,
varStore.source(),
@@ -826,23 +826,23 @@ public class PatioCodeGen {
}
interface BinaryOperationCodeGen {
- PatioCodeGenContext generate(
+ ShidToPatioContext generate(
PatioLocalRef target,
PatioOperand left,
PatioOperand right,
- PatioCodeGenContext context
+ ShidToPatioContext context
);
}
- private static PatioCodeGenContext generateComparison(
+ private static ShidToPatioContext generateComparison(
BinaryOperationCodeGen binaryOperationCodeGen,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
return generateBinaryOperation(
(target, left, right, operationContext) -> {
var targetBoolResult = operationContext.allocateVal(
- PatioCodeGenLocalSpace.TEMPORARY,
+ ShidToPatioLocalSpace.TEMPORARY,
PatioTypes.INT
);
var targetBool = targetBoolResult.value();
@@ -867,9 +867,9 @@ public class PatioCodeGen {
);
}
- private static PatioCodeGenContext generateBinaryOperation(
+ private static ShidToPatioContext generateBinaryOperation(
BinaryOperationCodeGen binaryOperationCodeGen,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
var rightResult = context.temporaryPop();
var right = rightResult.value();
@@ -880,8 +880,8 @@ public class PatioCodeGen {
context = leftResult.context();
var targetResult = context.allocateVal(
- PatioCodeGenLocalSpace.BINARY_OP_RESULT,
- PatioCodeGenTypes.VALUE_TYPE
+ ShidToPatioLocalSpace.BINARY_OP_RESULT,
+ ShidToPatioTypes.VALUE_TYPE
);
var target = targetResult.value();
context = targetResult.context();
@@ -894,9 +894,9 @@ public class PatioCodeGen {
).temporaryPush(target);
}
- private static PatioCodeGenContext generateBlockNoResults(
+ private static ShidToPatioContext generateBlockNoResults(
ShidBlock shidBlock,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
// TODO: just use a block in Patio instructions even where there are no targets?
var blockResult = generateBlock(shidBlock, context);
@@ -915,9 +915,9 @@ public class PatioCodeGen {
return context;
}
- private static PatioCodeGenResult<PatioBlock> generateBlock(
+ private static ShidToPatioResult<PatioBlock> generateBlock(
ShidBlock shidBlock,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
context = context.enterBlock();
@@ -942,12 +942,12 @@ public class PatioCodeGen {
));
}
- private static PatioCodeGenResult<PatioLocalRef> generateCondition(
+ private static ShidToPatioResult<PatioLocalRef> generateCondition(
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
var conditionIntResult = context.allocateVal(
- PatioCodeGenLocalSpace.TEMPORARY,
+ ShidToPatioLocalSpace.TEMPORARY,
"conditionInt",
PatioTypes.INT
);
@@ -957,7 +957,7 @@ public class PatioCodeGen {
context = context.temporaryPopIntoLocal(conditionInt, source);
var conditionBoolResult = context.allocateVal(
- PatioCodeGenLocalSpace.TEMPORARY,
+ ShidToPatioLocalSpace.TEMPORARY,
"conditionBool",
PatioTypes.BOOL
);
@@ -973,9 +973,9 @@ public class PatioCodeGen {
return context.toResult(conditionBool);
}
- private static PatioCodeGenContext declareShidVariables(
+ private static ShidToPatioContext declareShidVariables(
ShidBlock body,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
for (var boundVariable : body.boundVariables()) {
switch (boundVariable.variant()) {
@@ -985,11 +985,11 @@ public class PatioCodeGen {
case VAL -> {
context = context.declareShidVal(
boundVariable.name(),
- PatioCodeGenTypes.VALUE_TYPE
+ ShidToPatioTypes.VALUE_TYPE
).context();
}
case VAR -> {
- context = PatioCodeGenVars.alloc(
+ context = ShidToPatioVars.alloc(
boundVariable.name(),
// TODO: proper source (probably by storing variables on the function/namespace)
Sources.NULL,
@@ -1001,8 +1001,8 @@ public class PatioCodeGen {
return context;
}
- private static PatioCodeGenContext pushValue(int value, Source source, PatioCodeGenContext context) {
- var localResult = context.allocateVal(PatioCodeGenLocalSpace.TEMPORARY, PatioCodeGenTypes.VALUE_TYPE);
+ private static ShidToPatioContext pushValue(int value, Source source, ShidToPatioContext context) {
+ var localResult = context.allocateVal(ShidToPatioLocalSpace.TEMPORARY, ShidToPatioTypes.VALUE_TYPE);
var local = localResult.value();
context = localResult.context();
diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenCompilationUnitElementSpace.java b/src/main/java/org/shedlang/compiler/patio/ShidToPatioCompilationUnitElementSpace.java
index b39d2a37..3b95e99a 100644
--- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenCompilationUnitElementSpace.java
+++ b/src/main/java/org/shedlang/compiler/patio/ShidToPatioCompilationUnitElementSpace.java
@@ -1,6 +1,6 @@
package org.shedlang.compiler.patio;
-public enum PatioCodeGenCompilationUnitElementSpace {
+public enum ShidToPatioCompilationUnitElementSpace {
EFFECT_HANDLER_METHOD("effectHandlerMethod"),
FUNCTION("function"),
MAIN("main"),
@@ -8,7 +8,7 @@ public enum PatioCodeGenCompilationUnitElementSpace {
private final String name;
- PatioCodeGenCompilationUnitElementSpace(String name) {
+ ShidToPatioCompilationUnitElementSpace(String name) {
this.name = name;
}
diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenContext.java b/src/main/java/org/shedlang/compiler/patio/ShidToPatioContext.java
index 9aaf2666..dfbcaf77 100644
--- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenContext.java
+++ b/src/main/java/org/shedlang/compiler/patio/ShidToPatioContext.java
@@ -24,7 +24,7 @@ import java.util.List;
import java.util.Optional;
import java.util.function.Function;
-public record PatioCodeGenContext(
+public record ShidToPatioContext(
GlobalContext globalContext,
CompilationUnitContext compilationUnitContext,
PStack<FunctionContext> blockStack,
@@ -135,7 +135,7 @@ public record PatioCodeGenContext(
@CheckReturnValue
public Result<String> allocateCompilationUnitName(
- PatioCodeGenCompilationUnitElementSpace space,
+ ShidToPatioCompilationUnitElementSpace space,
Optional<String> name
) {
var fullName = NameAllocator.allocateName(
@@ -186,7 +186,7 @@ public record PatioCodeGenContext(
PVector<PatioInstruction> instructions,
OrderedPMap<String, PatioLocal> localsByName,
PMap<String, PatioLocalRef> shidNameToLocal,
- PMap<String, PVector<Function<PatioCodeGenContext, PatioCodeGenContext>>> waitingForShidLocal,
+ PMap<String, PVector<Function<ShidToPatioContext, ShidToPatioContext>>> waitingForShidLocal,
Optional<PatioOperand> stashedEffectHandler,
Optional<PatioOperand> stashedGcRootStackIndex,
PStack<PatioInstruction> onReturn
@@ -260,7 +260,7 @@ public record PatioCodeGenContext(
@CheckReturnValue
public Result<PatioLocalRef> allocateLocal(
- PatioCodeGenLocalSpace space,
+ ShidToPatioLocalSpace space,
Optional<String> name,
Function<String, PatioLocal> createLocal
) {
@@ -297,7 +297,7 @@ public record PatioCodeGenContext(
var fullName = NameAllocator.allocateFixedName(
this.localsByName::containsKey,
- PatioCodeGenLocalSpace.LOCAL,
+ ShidToPatioLocalSpace.LOCAL,
name
);
@@ -322,7 +322,7 @@ public record PatioCodeGenContext(
}
@CheckReturnValue
- public FunctionContext.Result<PVector<Function<PatioCodeGenContext, PatioCodeGenContext>>> initShidLocal(String name) {
+ public FunctionContext.Result<PVector<Function<ShidToPatioContext, ShidToPatioContext>>> initShidLocal(String name) {
var context = new FunctionContext(
this.temporaryStack,
this.instructions,
@@ -370,7 +370,7 @@ public record PatioCodeGenContext(
@CheckReturnValue
public FunctionContext addWaitingForShidLocal(
String name,
- Function<PatioCodeGenContext, PatioCodeGenContext> func
+ Function<ShidToPatioContext, ShidToPatioContext> func
) {
return new FunctionContext(
this.temporaryStack,
@@ -464,7 +464,7 @@ public record PatioCodeGenContext(
public record Result<T>(T value, FunctionContext context) {}
}
- public static final PatioCodeGenContext EMPTY = new PatioCodeGenContext(
+ public static final ShidToPatioContext EMPTY = new ShidToPatioContext(
GlobalContext.EMPTY,
CompilationUnitContext.EMPTY,
P.stack(),
@@ -472,8 +472,8 @@ public record PatioCodeGenContext(
);
@CheckReturnValue
- public static PatioCodeGenContext forTypeInfos(TypeInfos typeInfos) {
- return new PatioCodeGenContext(
+ public static ShidToPatioContext forTypeInfos(TypeInfos typeInfos) {
+ return new ShidToPatioContext(
GlobalContext.forTypeInfos(typeInfos),
CompilationUnitContext.EMPTY,
P.stack(),
@@ -507,8 +507,8 @@ public record PatioCodeGenContext(
}
@CheckReturnValue
- public PatioCodeGenResult<String> allocateCompilationUnitElementName(
- PatioCodeGenCompilationUnitElementSpace space,
+ public ShidToPatioResult<String> allocateCompilationUnitElementName(
+ ShidToPatioCompilationUnitElementSpace space,
String name
) {
return withCompilationUnitContextResult(
@@ -520,8 +520,8 @@ public record PatioCodeGenContext(
}
@CheckReturnValue
- public PatioCodeGenResult<String> allocateCompilationUnitElementName(
- PatioCodeGenCompilationUnitElementSpace space
+ public ShidToPatioResult<String> allocateCompilationUnitElementName(
+ ShidToPatioCompilationUnitElementSpace space
) {
return withCompilationUnitContextResult(
this.compilationUnitContext.allocateCompilationUnitName(
@@ -532,13 +532,13 @@ public record PatioCodeGenContext(
}
@CheckReturnValue
- public PatioCodeGenContext addDataElementMutable(String name, PatioDataValue initialValue, Source source) {
+ public ShidToPatioContext addDataElementMutable(String name, PatioDataValue initialValue, Source source) {
var dataElement = new PatioDataElementMutable(name, initialValue, source);
return addCompilationUnitElement(dataElement);
}
@CheckReturnValue
- public PatioCodeGenContext addCompilationUnitElement(
+ public ShidToPatioContext addCompilationUnitElement(
PatioCompilationUnitElement element
) {
return withCompilationUnitContext(
@@ -547,7 +547,7 @@ public record PatioCodeGenContext(
}
@CheckReturnValue
- public PatioCodeGenContext ensureCompilationUnitElement(
+ public ShidToPatioContext ensureCompilationUnitElement(
PatioCompilationUnitElement element
) {
return withCompilationUnitContext(
@@ -556,42 +556,42 @@ public record PatioCodeGenContext(
}
@CheckReturnValue
- public PatioCodeGenResult<PatioOperand> temporaryPop() {
+ public ShidToPatioResult<PatioOperand> temporaryPop() {
var result = this.functionContext.temporaryPop();
return withFunctionContextResult(result);
}
@CheckReturnValue
- public PatioCodeGenContext temporaryPopIntoLocal(PatioLocalRef target, Source source) {
+ public ShidToPatioContext temporaryPopIntoLocal(PatioLocalRef target, Source source) {
var result = this.functionContext.temporaryPop();
- return new PatioCodeGenContext(this.globalContext, this.compilationUnitContext, this.blockStack, result.context)
+ return new ShidToPatioContext(this.globalContext, this.compilationUnitContext, this.blockStack, result.context)
.addInstruction(new PatioLocalStore(target, result.value, source));
}
@CheckReturnValue
- public PatioCodeGenResult<List<PatioOperand>> temporaryPopAll() {
+ public ShidToPatioResult<List<PatioOperand>> temporaryPopAll() {
var result = this.functionContext.temporaryPopAll();
return withFunctionContextResult(result);
}
@CheckReturnValue
- public PatioCodeGenContext temporaryPush(PatioOperand value) {
+ public ShidToPatioContext temporaryPush(PatioOperand value) {
var result = this.functionContext.temporaryPush(value);
return withFunctionContext(result);
}
@CheckReturnValue
- public PatioCodeGenContext addInstruction(PatioInstruction instruction) {
+ public ShidToPatioContext addInstruction(PatioInstruction instruction) {
return withFunctionContext(this.functionContext.addInstruction(instruction));
}
@CheckReturnValue
- public PatioCodeGenResult<PatioLocalRef> allocateParam(
- PatioCodeGenLocalSpace space,
+ public ShidToPatioResult<PatioLocalRef> allocateParam(
+ ShidToPatioLocalSpace space,
PatioType type
) {
var result = this.functionContext.allocateLocal(
@@ -604,8 +604,8 @@ public record PatioCodeGenContext(
}
@CheckReturnValue
- public PatioCodeGenResult<PatioLocalRef> allocateVal(
- PatioCodeGenLocalSpace space,
+ public ShidToPatioResult<PatioLocalRef> allocateVal(
+ ShidToPatioLocalSpace space,
PatioType type
) {
var result = this.functionContext.allocateLocal(
@@ -618,8 +618,8 @@ public record PatioCodeGenContext(
}
@CheckReturnValue
- public PatioCodeGenResult<PatioLocalRef> allocateVal(
- PatioCodeGenLocalSpace space,
+ public ShidToPatioResult<PatioLocalRef> allocateVal(
+ ShidToPatioLocalSpace space,
String name,
PatioType type
) {
@@ -633,21 +633,21 @@ public record PatioCodeGenContext(
}
@CheckReturnValue
- public PatioCodeGenContext defineShidParam(String name) {
+ public ShidToPatioContext defineShidParam(String name) {
return declareShidParam(name).initShidLocal(name);
}
@CheckReturnValue
- private PatioCodeGenContext declareShidParam(String name) {
+ private ShidToPatioContext declareShidParam(String name) {
return declareShidLocal(
name,
- PatioCodeGenTypes.VALUE_TYPE,
+ ShidToPatioTypes.VALUE_TYPE,
PatioLocalType.PARAM
).context();
}
@CheckReturnValue
- public PatioCodeGenResult<PatioLocalRef> declareShidVal(String name, PatioType type) {
+ public ShidToPatioResult<PatioLocalRef> declareShidVal(String name, PatioType type) {
return declareShidLocal(
name,
type,
@@ -656,7 +656,7 @@ public record PatioCodeGenContext(
}
@CheckReturnValue
- public PatioCodeGenResult<PatioLocalRef> declareShidLocal(
+ public ShidToPatioResult<PatioLocalRef> declareShidLocal(
String name,
PatioType type,
PatioLocalType patioLocalType
@@ -669,7 +669,7 @@ public record PatioCodeGenContext(
}
@CheckReturnValue
- public PatioCodeGenContext initShidLocal(String name) {
+ public ShidToPatioContext initShidLocal(String name) {
var result = this.functionContext.initShidLocal(name);
var context = withFunctionContext(result.context);
@@ -681,9 +681,9 @@ public record PatioCodeGenContext(
}
@CheckReturnValue
- public PatioCodeGenContext onceShidLocalDefined(
+ public ShidToPatioContext onceShidLocalDefined(
String name,
- Function<PatioCodeGenContext, PatioCodeGenContext> func
+ Function<ShidToPatioContext, ShidToPatioContext> func
) {
var local = this.functionContext.shidLocalNameToLocalOrNone(name);
@@ -716,14 +716,14 @@ public record PatioCodeGenContext(
}
@CheckReturnValue
- public PatioCodeGenContext createFunction(
+ public ShidToPatioContext createFunction(
String name,
PatioVisibility visibility,
PatioType returnType,
Source source,
- Function<PatioCodeGenContext, PatioCodeGenContext> createBody
+ Function<ShidToPatioContext, ShidToPatioContext> createBody
) {
- var bodyContext = new PatioCodeGenContext(
+ var bodyContext = new ShidToPatioContext(
this.globalContext,
this.compilationUnitContext,
P.stack(),
@@ -734,7 +734,7 @@ public record PatioCodeGenContext(
var locals = bodyContext.functionContext.localsByName.values().stream().toList();
- return new PatioCodeGenContext(
+ return new ShidToPatioContext(
this.globalContext,
bodyContext.compilationUnitContext.addElement(new PatioFunctionDefinition(
name,
@@ -750,8 +750,8 @@ public record PatioCodeGenContext(
}
@CheckReturnValue
- public PatioCodeGenContext enterBlock() {
- return new PatioCodeGenContext(
+ public ShidToPatioContext enterBlock() {
+ return new ShidToPatioContext(
this.globalContext,
this.compilationUnitContext,
this.blockStack.plus(this.functionContext),
@@ -769,12 +769,12 @@ public record PatioCodeGenContext(
}
@CheckReturnValue
- public PatioCodeGenResult<List<PatioInstruction>> exitBlock() {
+ public ShidToPatioResult<List<PatioInstruction>> exitBlock() {
if (!this.functionContext.temporaryStack.isEmpty()) {
throw new RuntimeException("temporary stack must be empty at the end of a block");
}
- return new PatioCodeGenContext(
+ return new ShidToPatioContext(
this.globalContext,
this.compilationUnitContext,
this.blockStack.minus(0),
@@ -792,7 +792,7 @@ public record PatioCodeGenContext(
}
@CheckReturnValue
- public PatioCodeGenContext stashEffectHandler(PatioOperand effectHandler) {
+ public ShidToPatioContext stashEffectHandler(PatioOperand effectHandler) {
return withFunctionContext(this.functionContext.stashEffectHandler(effectHandler));
}
@@ -808,7 +808,7 @@ public record PatioCodeGenContext(
}
@CheckReturnValue
- public PatioCodeGenContext stashGcRootStackIndex(PatioOperand gcRootStackIndex) {
+ public ShidToPatioContext stashGcRootStackIndex(PatioOperand gcRootStackIndex) {
return withFunctionContext(this.functionContext.stashGcRootStackIndex(gcRootStackIndex));
}
@@ -818,12 +818,12 @@ public record PatioCodeGenContext(
}
@CheckReturnValue
- public PatioCodeGenContext pushOnReturn(PatioInstruction onReturn) {
+ public ShidToPatioContext pushOnReturn(PatioInstruction onReturn) {
return withFunctionContext(this.functionContext.pushOnReturn(onReturn));
}
@CheckReturnValue
- public PatioCodeGenContext popOnReturn() {
+ public ShidToPatioContext popOnReturn() {
return withFunctionContext(this.functionContext.popOnReturn());
}
@@ -833,28 +833,28 @@ public record PatioCodeGenContext(
}
@CheckReturnValue
- private PatioCodeGenContext withCompilationUnitContext(CompilationUnitContext compilationUnitContext) {
- return new PatioCodeGenContext(this.globalContext, compilationUnitContext, this.blockStack, this.functionContext);
+ private ShidToPatioContext withCompilationUnitContext(CompilationUnitContext compilationUnitContext) {
+ return new ShidToPatioContext(this.globalContext, compilationUnitContext, this.blockStack, this.functionContext);
}
@CheckReturnValue
- private <T> PatioCodeGenResult<T> withCompilationUnitContextResult(CompilationUnitContext.Result<T> result) {
+ private <T> ShidToPatioResult<T> withCompilationUnitContextResult(CompilationUnitContext.Result<T> result) {
return withCompilationUnitContext(result.context).toResult(result.value);
}
@CheckReturnValue
- private PatioCodeGenContext withFunctionContext(FunctionContext functionContext) {
- return new PatioCodeGenContext(this.globalContext, this.compilationUnitContext, this.blockStack, functionContext);
+ private ShidToPatioContext withFunctionContext(FunctionContext functionContext) {
+ return new ShidToPatioContext(this.globalContext, this.compilationUnitContext, this.blockStack, functionContext);
}
@CheckReturnValue
- private <T> PatioCodeGenResult<T> withFunctionContextResult(FunctionContext.Result<T> result) {
+ private <T> ShidToPatioResult<T> withFunctionContextResult(FunctionContext.Result<T> result) {
return withFunctionContext(result.context).toResult(result.value);
}
@CheckReturnValue
- public <T> PatioCodeGenResult<T> toResult(T value) {
- return new PatioCodeGenResult<>(value, this);
+ public <T> ShidToPatioResult<T> toResult(T value) {
+ return new ShidToPatioResult<>(value, this);
}
@CheckReturnValue
diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenEffects.java b/src/main/java/org/shedlang/compiler/patio/ShidToPatioEffects.java
index d5ef5f0e..6ea11694 100644
--- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenEffects.java
+++ b/src/main/java/org/shedlang/compiler/patio/ShidToPatioEffects.java
@@ -24,18 +24,18 @@ import java.util.Optional;
import java.util.function.Function;
import java.util.stream.IntStream;
-public class PatioCodeGenEffects {
+public class ShidToPatioEffects {
private static final PatioType EFFECT_TAG_TYPE = PatioTypes.INT;
private static final PatioType EFFECT_METHOD_INDEX_TYPE = PatioTypes.INT;
private static final PatioType EFFECT_HANDLER_TYPE = PatioTypes.DATA_POINTER;
private static final PatioType EFFECT_HANDLER_METHOD_POINTER_TYPE = PatioTypes.DATA_POINTER;
- private static final PatioType EFFECT_HANDLER_METHOD_TYPE = PatioCodeGenTypes.VALUE_TYPE;
+ private static final PatioType EFFECT_HANDLER_METHOD_TYPE = ShidToPatioTypes.VALUE_TYPE;
private static PatioDataLayout effectHandlerMethodDataLayout(
FreeVariables freeVariables,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
- return PatioCodeGenClosures.closureDataLayout(
+ return ShidToPatioClosures.closureDataLayout(
PatioDataLayouts.struct(List.of(PatioDataLayouts.DATA_POINTER)),
freeVariables,
context
@@ -43,25 +43,25 @@ public class PatioCodeGenEffects {
}
private static final List<Integer> CLOSURE_EFFECT_HANDLER_OFFSET
- = PatioCodeGenClosures.additionalOffset(List.of(0));
+ = ShidToPatioClosures.additionalOffset(List.of(0));
private static PatioDataLayout userDefinedEffectLayout(
UserDefinedEffect effect,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
var effectInfo = context.userDefinedEffectInfo(effect);
- return PatioCodeGenGc.gcObjectDataLayout(PatioDataLayouts.struct(Lists.repeat(
- PatioDataLayouts.fromType(PatioCodeGenClosures.CLOSURE_TYPE),
+ return ShidToPatioGc.gcObjectDataLayout(PatioDataLayouts.struct(Lists.repeat(
+ PatioDataLayouts.fromType(ShidToPatioClosures.CLOSURE_TYPE),
effectInfo.methodCount()
)));
}
private static List<Integer> userDefinedEffectMethodOffset(int methodIndex) {
- return PatioCodeGenGc.gcObjectOffset(List.of(methodIndex));
+ return ShidToPatioGc.gcObjectOffset(List.of(methodIndex));
}
private static final List<Integer> USER_DEFINED_EFFECT_GC_CHILDREN_OFFSET =
- PatioCodeGenGc.gcObjectOffset(List.of());
+ ShidToPatioGc.gcObjectOffset(List.of());
private static final PatioFunctionDeclaration FIND_HANDLER_METHOD_DECLARATION = new PatioFunctionDeclaration(
"shed__runtime__effects_find_handler_method",
@@ -115,23 +115,23 @@ public class PatioCodeGenEffects {
Sources.RUNTIME
);
- private PatioCodeGenEffects() {
+ private ShidToPatioEffects() {
}
- public static PatioCodeGenContext createUserDefinedEffect(
+ public static ShidToPatioContext createUserDefinedEffect(
PatioLocalRef target,
UserDefinedEffect effect,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
context = context.addCompilationUnitElement(new PatioExceptionTypeDefinition(
context.exceptionTypeName(effect),
- PatioCodeGenTypes.VALUE_TYPE,
+ ShidToPatioTypes.VALUE_TYPE,
source
));
var effectPointerResult = context.allocateVal(
- PatioCodeGenLocalSpace.USER_DEFINED_EFFECT_POINTER,
+ ShidToPatioLocalSpace.USER_DEFINED_EFFECT_POINTER,
effect.name(),
PatioTypes.DATA_POINTER
);
@@ -142,7 +142,7 @@ public class PatioCodeGenEffects {
var effectInfo = context.userDefinedEffectInfo(effect);
- context = PatioCodeGenGc.alloc(
+ context = ShidToPatioGc.alloc(
effectPointer,
effectLayout,
USER_DEFINED_EFFECT_GC_CHILDREN_OFFSET,
@@ -153,9 +153,9 @@ public class PatioCodeGenEffects {
for (var method : effectInfo.methods()) {
var effectMethodResult = context.allocateVal(
- PatioCodeGenLocalSpace.USER_DEFINED_EFFECT_METHOD,
+ ShidToPatioLocalSpace.USER_DEFINED_EFFECT_METHOD,
method.name(),
- PatioCodeGenClosures.CLOSURE_TYPE
+ ShidToPatioClosures.CLOSURE_TYPE
);
var effectMethod = effectMethodResult.value();
context = effectMethodResult.context();
@@ -165,7 +165,7 @@ public class PatioCodeGenEffects {
.mapToObj(paramIndex -> new ShidDefineFunction.Param("arg" + paramIndex, source))
.toList();
- context = PatioCodeGenFunctions.create(
+ context = ShidToPatioFunctions.create(
effectMethod,
method.name(),
positionalParams,
@@ -177,7 +177,7 @@ public class PatioCodeGenEffects {
bodyContext = bodyContext.ensureCompilationUnitElement(FIND_HANDLER_METHOD_DECLARATION);
var handlerMethodResult = bodyContext.allocateVal(
- PatioCodeGenLocalSpace.EFFECT_HANDLER_METHOD,
+ ShidToPatioLocalSpace.EFFECT_HANDLER_METHOD,
EFFECT_HANDLER_METHOD_TYPE
);
var handlerMethod = handlerMethodResult.value();
@@ -194,14 +194,14 @@ public class PatioCodeGenEffects {
));
var returnValueResult = bodyContext.allocateVal(
- PatioCodeGenLocalSpace.TEMPORARY,
- PatioCodeGenTypes.VALUE_TYPE
+ ShidToPatioLocalSpace.TEMPORARY,
+ ShidToPatioTypes.VALUE_TYPE
);
var returnValue = returnValueResult.value();
bodyContext = returnValueResult.context();
var bodyContextArgs = bodyContext;
- bodyContext = PatioCodeGenClosures.call(
+ bodyContext = ShidToPatioClosures.call(
returnValue,
handlerMethod,
positionalParams.stream()
@@ -244,16 +244,16 @@ public class PatioCodeGenEffects {
return context;
}
- public static PatioCodeGenContext fieldLoad(
+ public static ShidToPatioContext fieldLoad(
PatioLocalRef target,
PatioOperand receiver,
UserDefinedEffect effect,
String fieldName,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
var effectPointerResult = context.allocateVal(
- PatioCodeGenLocalSpace.USER_DEFINED_EFFECT_POINTER,
+ ShidToPatioLocalSpace.USER_DEFINED_EFFECT_POINTER,
PatioTypes.DATA_POINTER
);
var effectPointer = effectPointerResult.value();
@@ -281,13 +281,13 @@ public class PatioCodeGenEffects {
return context;
}
- public static PatioCodeGenContext try_(
+ public static ShidToPatioContext try_(
PatioLocalRef target,
UserDefinedEffect effect,
Map<String, PatioOperand> handlerMethodsByName,
- Function<PatioCodeGenContext, PatioCodeGenResult<PatioBlock>> generateBody,
+ Function<ShidToPatioContext, ShidToPatioResult<PatioBlock>> generateBody,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
var effectInfo = context.userDefinedEffectInfo(effect);
@@ -297,7 +297,7 @@ public class PatioCodeGenEffects {
.ensureCompilationUnitElement(POP_HANDLER_DECLARATION);
var effectHandlerResult = context.allocateVal(
- PatioCodeGenLocalSpace.EFFECT_HANDLER,
+ ShidToPatioLocalSpace.EFFECT_HANDLER,
EFFECT_HANDLER_TYPE
);
var effectHandler = effectHandlerResult.value();
@@ -342,8 +342,8 @@ public class PatioCodeGenEffects {
context = context.popOnReturn();
var exceptionValueResult = context.allocateVal(
- PatioCodeGenLocalSpace.TEMPORARY,
- PatioCodeGenTypes.VALUE_TYPE
+ ShidToPatioLocalSpace.TEMPORARY,
+ ShidToPatioTypes.VALUE_TYPE
);
var exceptionValue = exceptionValueResult.value();
context = exceptionValueResult.context();
@@ -369,15 +369,15 @@ public class PatioCodeGenEffects {
return context;
}
- public static PatioCodeGenContext createEffectHandlerMethod(
+ public static ShidToPatioContext createEffectHandlerMethod(
PatioLocalRef target,
String name,
List<ShidDefineFunction.Param> positionalParams,
List<ShidDefineFunction.Param> namedParams,
FreeVariables freeVariables,
- Function<PatioCodeGenContext, PatioCodeGenContext> generateBody,
+ Function<ShidToPatioContext, ShidToPatioContext> generateBody,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
context = context
.ensureCompilationUnitElement(GET_HANDLER_DECLARATION)
@@ -385,16 +385,16 @@ public class PatioCodeGenEffects {
var layout = effectHandlerMethodDataLayout(freeVariables, context);
- return PatioCodeGenClosures.create(
+ return ShidToPatioClosures.create(
target,
- PatioCodeGenCompilationUnitElementSpace.EFFECT_HANDLER_METHOD,
+ ShidToPatioCompilationUnitElementSpace.EFFECT_HANDLER_METHOD,
name,
positionalParams,
namedParams,
layout,
(closurePointer, allocContext) -> {
var effectHandlerResult = allocContext.allocateVal(
- PatioCodeGenLocalSpace.EFFECT_HANDLER_CURRENT,
+ ShidToPatioLocalSpace.EFFECT_HANDLER_CURRENT,
EFFECT_HANDLER_TYPE
);
var effectHandler = effectHandlerResult.value();
@@ -415,7 +415,7 @@ public class PatioCodeGenEffects {
freeVariables,
(closurePointer, bodyContext) -> {
var previousEffectHandlerResult = bodyContext.allocateVal(
- PatioCodeGenLocalSpace.EFFECT_HANDLER,
+ ShidToPatioLocalSpace.EFFECT_HANDLER,
EFFECT_HANDLER_METHOD_POINTER_TYPE
);
var previousEffectHandler = previousEffectHandlerResult.value();
@@ -426,7 +426,7 @@ public class PatioCodeGenEffects {
bodyContext = bodyContext.stashEffectHandler(previousEffectHandler);
var effectHandlerResult = bodyContext.allocateVal(
- PatioCodeGenLocalSpace.EFFECT_HANDLER,
+ ShidToPatioLocalSpace.EFFECT_HANDLER,
EFFECT_HANDLER_METHOD_POINTER_TYPE
);
var effectHandler = effectHandlerResult.value();
@@ -456,10 +456,10 @@ public class PatioCodeGenEffects {
);
}
- public static PatioCodeGenContext resume(
+ public static ShidToPatioContext resume(
PatioOperand value,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
context = context.addInstruction(new PatioCall(
Optional.empty(),
@@ -473,11 +473,11 @@ public class PatioCodeGenEffects {
return context;
}
- public static PatioCodeGenContext break_(
+ public static ShidToPatioContext break_(
UserDefinedEffect effect,
PatioOperand value,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
var exceptionTypeName = context.exceptionTypeName(effect);
@@ -490,10 +490,10 @@ public class PatioCodeGenEffects {
return context;
}
- private static PatioCodeGenContext getCurrentEffectHandler(
+ private static ShidToPatioContext getCurrentEffectHandler(
PatioLocalRef target,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
return context.addInstruction(new PatioCall(
Optional.of(target),
diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenFunctions.java b/src/main/java/org/shedlang/compiler/patio/ShidToPatioFunctions.java
index eefdd4f5..77da6a10 100644
--- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenFunctions.java
+++ b/src/main/java/org/shedlang/compiler/patio/ShidToPatioFunctions.java
@@ -10,36 +10,36 @@ import org.shedlang.compiler.sources.Source;
import java.util.List;
import java.util.function.Function;
-public class PatioCodeGenFunctions {
- private PatioCodeGenFunctions() {
+public class ShidToPatioFunctions {
+ private ShidToPatioFunctions() {
}
private static PatioDataLayout functionDataLayout(
FreeVariables freeVariables,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
- return PatioCodeGenClosures.closureDataLayout(
+ return ShidToPatioClosures.closureDataLayout(
PatioDataLayouts.struct(List.of()),
freeVariables,
context
);
}
- public static PatioCodeGenContext create(
+ public static ShidToPatioContext create(
PatioLocalRef target,
String name,
List<ShidDefineFunction.Param> positionalParams,
List<ShidDefineFunction.Param> namedParams,
FreeVariables freeVariables,
- Function<PatioCodeGenContext, PatioCodeGenContext> generateBody,
+ Function<ShidToPatioContext, ShidToPatioContext> generateBody,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
var layout = functionDataLayout(freeVariables, context);
- return PatioCodeGenClosures.create(
+ return ShidToPatioClosures.create(
target,
- PatioCodeGenCompilationUnitElementSpace.FUNCTION,
+ ShidToPatioCompilationUnitElementSpace.FUNCTION,
name,
positionalParams,
namedParams,
diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenGc.java b/src/main/java/org/shedlang/compiler/patio/ShidToPatioGc.java
index 530472fc..809d9076 100644
--- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenGc.java
+++ b/src/main/java/org/shedlang/compiler/patio/ShidToPatioGc.java
@@ -14,9 +14,9 @@ import org.shedlang.compiler.util.Lists;
import java.util.List;
import java.util.Optional;
-public class PatioCodeGenGc {
+public class ShidToPatioGc {
// TODO: garbage collect after throws, and the end of blocks (especially for loops)
- private PatioCodeGenGc() {
+ private ShidToPatioGc() {
}
public static PatioDataLayout gcObjectDataLayout(PatioDataLayout valueLayout) {
@@ -64,10 +64,10 @@ public class PatioCodeGenGc {
Sources.RUNTIME
);
- public static PatioCodeGenContext getGcRootStackIndex(
+ public static ShidToPatioContext getGcRootStackIndex(
PatioLocalRef target,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
return context
.ensureCompilationUnitElement(GET_GC_ROOT_STACK_INDEX)
@@ -86,10 +86,10 @@ public class PatioCodeGenGc {
Sources.RUNTIME
);
- public static PatioCodeGenContext setGcRootStackIndex(
+ public static ShidToPatioContext setGcRootStackIndex(
PatioOperand gcRootIndex,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
return context
.ensureCompilationUnitElement(SET_GC_ROOT_STACK_INDEX)
@@ -103,15 +103,15 @@ public class PatioCodeGenGc {
private static final PatioFunctionDeclaration PUSH_GC_ROOT = new PatioFunctionDeclaration(
"shed__runtime__gc_push_root",
- List.of(PatioLocal.param("gc_root", PatioCodeGenTypes.VALUE_TYPE)),
+ List.of(PatioLocal.param("gc_root", ShidToPatioTypes.VALUE_TYPE)),
PatioTypes.VOID,
Sources.RUNTIME
);
- public static PatioCodeGenContext pushGcRoot(
+ public static ShidToPatioContext pushGcRoot(
PatioOperand escapee,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
return context
.ensureCompilationUnitElement(PUSH_GC_ROOT)
@@ -125,13 +125,13 @@ public class PatioCodeGenGc {
// == Allocation ==
- public static PatioCodeGenContext alloc(
+ public static ShidToPatioContext alloc(
PatioLocalRef target,
PatioDataLayout layout,
List<Integer> childrenOffset,
int childrenCount,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
return context.addInstruction(new PatioAllocHeap(
target,
@@ -151,9 +151,9 @@ public class PatioCodeGenGc {
Sources.RUNTIME
);
- public static PatioCodeGenContext collect(
+ public static ShidToPatioContext collect(
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
return context
.ensureCompilationUnitElement(COLLECT)
@@ -167,15 +167,15 @@ public class PatioCodeGenGc {
// == Save/Restore ==
- static PatioCodeGenContext saveGcRootStack(Source source, PatioCodeGenContext context) {
+ static ShidToPatioContext saveGcRootStack(Source source, ShidToPatioContext context) {
var gcRootStackIndexResult = context.allocateVal(
- PatioCodeGenLocalSpace.GC_ROOT_STACK_INDEX,
- PatioCodeGenGc.GC_ROOT_STACK_INDEX_TYPE
+ ShidToPatioLocalSpace.GC_ROOT_STACK_INDEX,
+ ShidToPatioGc.GC_ROOT_STACK_INDEX_TYPE
);
var gcRootStackIndex = gcRootStackIndexResult.value();
context = gcRootStackIndexResult.context();
- context = PatioCodeGenGc.getGcRootStackIndex(
+ context = ShidToPatioGc.getGcRootStackIndex(
gcRootStackIndex,
source,
context
@@ -186,22 +186,22 @@ public class PatioCodeGenGc {
return context;
}
- static PatioCodeGenContext restoreGcRootStack(
+ static ShidToPatioContext restoreGcRootStack(
List<PatioOperand> escapees,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
- context = PatioCodeGenGc.setGcRootStackIndex(
+ context = ShidToPatioGc.setGcRootStackIndex(
context.stashedGcRootStackIndex(),
source,
context
);
for (var escapee : escapees) {
- context = PatioCodeGenGc.pushGcRoot(escapee, source, context);
+ context = ShidToPatioGc.pushGcRoot(escapee, source, context);
}
- context = PatioCodeGenGc.collect(source, context);
+ context = ShidToPatioGc.collect(source, context);
return context;
}
diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenInts.java b/src/main/java/org/shedlang/compiler/patio/ShidToPatioInts.java
index b4b480ab..378a2cc5 100644
--- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenInts.java
+++ b/src/main/java/org/shedlang/compiler/patio/ShidToPatioInts.java
@@ -15,41 +15,41 @@ import java.math.BigInteger;
import java.util.List;
import java.util.Optional;
-public class PatioCodeGenInts {
+public class ShidToPatioInts {
public static final PatioFunctionDeclaration INT_CREATE_DECLARATION = new PatioFunctionDeclaration(
"shed__runtime__int_create",
List.of(
PatioLocal.param("value", PatioTypes.INT)
),
- PatioCodeGenTypes.VALUE_TYPE,
+ ShidToPatioTypes.VALUE_TYPE,
Sources.RUNTIME
);
public static final PatioFunctionDeclaration INT_ADD_DECLARATION = new PatioFunctionDeclaration(
"shed__runtime__int_add",
List.of(
- PatioLocal.param("left", PatioCodeGenTypes.VALUE_TYPE),
- PatioLocal.param("right", PatioCodeGenTypes.VALUE_TYPE)
+ PatioLocal.param("left", ShidToPatioTypes.VALUE_TYPE),
+ PatioLocal.param("right", ShidToPatioTypes.VALUE_TYPE)
),
- PatioCodeGenTypes.VALUE_TYPE,
+ ShidToPatioTypes.VALUE_TYPE,
Sources.RUNTIME
);
public static final PatioFunctionDeclaration INT_SUB_DECLARATION = new PatioFunctionDeclaration(
"shed__runtime__int_sub",
List.of(
- PatioLocal.param("left", PatioCodeGenTypes.VALUE_TYPE),
- PatioLocal.param("right", PatioCodeGenTypes.VALUE_TYPE)
+ PatioLocal.param("left", ShidToPatioTypes.VALUE_TYPE),
+ PatioLocal.param("right", ShidToPatioTypes.VALUE_TYPE)
),
- PatioCodeGenTypes.VALUE_TYPE,
+ ShidToPatioTypes.VALUE_TYPE,
Sources.RUNTIME
);
public static final PatioFunctionDeclaration INT_EQUALS_DECLARATION = new PatioFunctionDeclaration(
"shed__runtime__int_equals",
List.of(
- PatioLocal.param("left", PatioCodeGenTypes.VALUE_TYPE),
- PatioLocal.param("right", PatioCodeGenTypes.VALUE_TYPE)
+ PatioLocal.param("left", ShidToPatioTypes.VALUE_TYPE),
+ PatioLocal.param("right", ShidToPatioTypes.VALUE_TYPE)
),
PatioTypes.BOOL,
Sources.RUNTIME
@@ -58,23 +58,23 @@ public class PatioCodeGenInts {
public static final PatioFunctionDeclaration INT_NOT_EQUAL_DECLARATION = new PatioFunctionDeclaration(
"shed__runtime__int_not_equal",
List.of(
- PatioLocal.param("left", PatioCodeGenTypes.VALUE_TYPE),
- PatioLocal.param("right", PatioCodeGenTypes.VALUE_TYPE)
+ PatioLocal.param("left", ShidToPatioTypes.VALUE_TYPE),
+ PatioLocal.param("right", ShidToPatioTypes.VALUE_TYPE)
),
PatioTypes.BOOL,
Sources.RUNTIME
);
- public static final PatioType INT_TYPE = PatioCodeGenTypes.VALUE_TYPE;
+ public static final PatioType INT_TYPE = ShidToPatioTypes.VALUE_TYPE;
- private PatioCodeGenInts() {
+ private ShidToPatioInts() {
}
- public static PatioCodeGenContext storeConst(
+ public static ShidToPatioContext storeConst(
PatioLocalRef target,
BigInteger value,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
return context
.ensureCompilationUnitElement(INT_CREATE_DECLARATION)
@@ -86,12 +86,12 @@ public class PatioCodeGenInts {
));
}
- public static PatioCodeGenContext add(
+ public static ShidToPatioContext add(
PatioLocalRef target,
PatioOperand left,
PatioOperand right,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
return context
.ensureCompilationUnitElement(INT_ADD_DECLARATION)
@@ -103,12 +103,12 @@ public class PatioCodeGenInts {
));
}
- public static PatioCodeGenContext sub(
+ public static ShidToPatioContext sub(
PatioLocalRef target,
PatioOperand left,
PatioOperand right,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
return context
.ensureCompilationUnitElement(INT_SUB_DECLARATION)
@@ -120,12 +120,12 @@ public class PatioCodeGenInts {
));
}
- public static PatioCodeGenContext equals(
+ public static ShidToPatioContext equals(
PatioLocalRef target,
PatioOperand left,
PatioOperand right,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
return context
.ensureCompilationUnitElement(INT_EQUALS_DECLARATION)
@@ -137,12 +137,12 @@ public class PatioCodeGenInts {
));
}
- public static PatioCodeGenContext notEqual(
+ public static ShidToPatioContext notEqual(
PatioLocalRef target,
PatioOperand left,
PatioOperand right,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
return context
.ensureCompilationUnitElement(INT_NOT_EQUAL_DECLARATION)
diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenLocalSpace.java b/src/main/java/org/shedlang/compiler/patio/ShidToPatioLocalSpace.java
index 54337eb4..48a6a9c6 100644
--- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenLocalSpace.java
+++ b/src/main/java/org/shedlang/compiler/patio/ShidToPatioLocalSpace.java
@@ -1,6 +1,6 @@
package org.shedlang.compiler.patio;
-public enum PatioCodeGenLocalSpace {
+public enum ShidToPatioLocalSpace {
BINARY_OP_RESULT("binaryOpResult"),
CALL_ARG_POSITIONAL("callArgPositional"),
CALL_ARG_NAMED("callArgNamed"),
@@ -37,7 +37,7 @@ public enum PatioCodeGenLocalSpace {
private final String name;
- PatioCodeGenLocalSpace(String name) {
+ ShidToPatioLocalSpace(String name) {
this.name = name;
}
diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenNamespaces.java b/src/main/java/org/shedlang/compiler/patio/ShidToPatioNamespaces.java
index 2285b408..e04b58af 100644
--- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenNamespaces.java
+++ b/src/main/java/org/shedlang/compiler/patio/ShidToPatioNamespaces.java
@@ -18,15 +18,15 @@ import java.util.List;
import java.util.Optional;
import java.util.function.Function;
-public class PatioCodeGenNamespaces {
- public static final PatioType NAMESPACE_VALUE_TYPE = PatioCodeGenTypes.VALUE_TYPE;
+public class ShidToPatioNamespaces {
+ public static final PatioType NAMESPACE_VALUE_TYPE = ShidToPatioTypes.VALUE_TYPE;
- private PatioCodeGenNamespaces() {}
+ private ShidToPatioNamespaces() {}
- public static PatioCodeGenContext define(
+ public static ShidToPatioContext define(
NamespaceName namespaceName,
- Function<PatioCodeGenContext, PatioCodeGenContext> generateInitBody,
- PatioCodeGenContext context
+ Function<ShidToPatioContext, ShidToPatioContext> generateInitBody,
+ ShidToPatioContext context
) {
// TODO: proper source. Probably wrap up stack namespace in a data structure with a source?
var source = Sources.NULL;
@@ -53,13 +53,13 @@ public class PatioCodeGenNamespaces {
source,
initContext -> {
var namespaceValueResult = initContext.allocateVal(
- PatioCodeGenLocalSpace.NAMESPACE_VALUE,
+ ShidToPatioLocalSpace.NAMESPACE_VALUE,
PatioTypes.DATA_POINTER
);
var namespaceValue = namespaceValueResult.value();
initContext = namespaceValueResult.context();
- initContext = PatioCodeGenGc.alloc(
+ initContext = ShidToPatioGc.alloc(
namespaceValue,
layout,
GC_CHILDREN_OFFSET,
@@ -99,7 +99,7 @@ public class PatioCodeGenNamespaces {
source,
importContext -> {
var isInitedResult = importContext.allocateVal(
- PatioCodeGenLocalSpace.TEMPORARY,
+ ShidToPatioLocalSpace.TEMPORARY,
PatioTypes.BOOL
);
var isInited = isInitedResult.value();
@@ -137,7 +137,7 @@ public class PatioCodeGenNamespaces {
));
var namespaceValuePointerResult = importContext.allocateVal(
- PatioCodeGenLocalSpace.NAMESPACE_POINTER,
+ ShidToPatioLocalSpace.NAMESPACE_POINTER,
NAMESPACE_VALUE_TYPE
);
var namespaceValuePointer = namespaceValuePointerResult.value();
@@ -152,7 +152,7 @@ public class PatioCodeGenNamespaces {
));
var namespaceValueResult = importContext.allocateVal(
- PatioCodeGenLocalSpace.NAMESPACE_VALUE,
+ ShidToPatioLocalSpace.NAMESPACE_VALUE,
NAMESPACE_VALUE_TYPE
);
var namespaceValue = namespaceValueResult.value();
@@ -176,11 +176,11 @@ public class PatioCodeGenNamespaces {
return context;
}
- public static PatioCodeGenContext importValue(
+ public static ShidToPatioContext importValue(
PatioLocalRef target,
NamespaceName namespaceName,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
context = context.addCompilationUnitElement(new PatioFunctionDeclaration(
globalNameNamespaceImport(namespaceName),
@@ -199,19 +199,19 @@ public class PatioCodeGenNamespaces {
return context;
}
- public static PatioCodeGenContext fieldLoad(
+ public static ShidToPatioContext fieldLoad(
PatioLocalRef target,
PatioOperand receiver,
NamespaceName namespaceName,
String fieldName,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
var namespaceTypeInfo = context.namespaceTypeInfo(namespaceName);
var layout = namespaceDataLayout(namespaceTypeInfo);
var namespacePointerResult = context.allocateVal(
- PatioCodeGenLocalSpace.NAMESPACE_POINTER,
+ ShidToPatioLocalSpace.NAMESPACE_POINTER,
namespaceNameToPatioIdentifier(namespaceName),
PatioTypes.DATA_POINTER
);
@@ -235,18 +235,18 @@ public class PatioCodeGenNamespaces {
return context;
}
- public static PatioCodeGenContext fieldStore(
+ public static ShidToPatioContext fieldStore(
NamespaceName namespaceName,
String fieldName,
PatioOperand fieldValue,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
var namespaceTypeInfo = context.namespaceTypeInfo(namespaceName);
var layout = namespaceDataLayout(namespaceTypeInfo);
var namespaceValueResult = context.allocateVal(
- PatioCodeGenLocalSpace.NAMESPACE_VALUE,
+ ShidToPatioLocalSpace.NAMESPACE_VALUE,
PatioTypes.DATA_POINTER
);
var namespaceValue = namespaceValueResult.value();
@@ -272,7 +272,7 @@ public class PatioCodeGenNamespaces {
}
private static PatioDataLayout namespaceDataLayout(NamespaceTypeInfo namespaceTypeInfo) {
- return PatioCodeGenGc.gcObjectDataLayout(PatioDataLayouts.struct(
+ return ShidToPatioGc.gcObjectDataLayout(PatioDataLayouts.struct(
Lists.repeat(
PatioDataLayouts.INT,
namespaceTypeInfo.fieldCount()
@@ -281,11 +281,11 @@ public class PatioCodeGenNamespaces {
}
private static List<Integer> fieldOffset(int fieldIndex) {
- return PatioCodeGenGc.gcObjectOffset(List.of(fieldIndex));
+ return ShidToPatioGc.gcObjectOffset(List.of(fieldIndex));
}
private static final List<Integer> GC_CHILDREN_OFFSET =
- PatioCodeGenGc.gcObjectOffset(List.of());
+ ShidToPatioGc.gcObjectOffset(List.of());
// TODO: allocate names through context
private static String globalNameNamespaceValue(NamespaceName namespaceName) {
diff --git a/src/main/java/org/shedlang/compiler/patio/ShidToPatioResult.java b/src/main/java/org/shedlang/compiler/patio/ShidToPatioResult.java
new file mode 100644
index 00000000..ed5abcdd
--- /dev/null
+++ b/src/main/java/org/shedlang/compiler/patio/ShidToPatioResult.java
@@ -0,0 +1,4 @@
+package org.shedlang.compiler.patio;
+
+public record ShidToPatioResult<T>(T value, ShidToPatioContext context) {
+}
diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenStrings.java b/src/main/java/org/shedlang/compiler/patio/ShidToPatioStrings.java
index 3269057b..8294e699 100644
--- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenStrings.java
+++ b/src/main/java/org/shedlang/compiler/patio/ShidToPatioStrings.java
@@ -18,23 +18,23 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
-public class PatioCodeGenStrings {
+public class ShidToPatioStrings {
public static final PatioFunctionDeclaration STRING_ADD_DECLARATION = new PatioFunctionDeclaration(
"shed__runtime__string_add",
List.of(
- PatioLocal.param("left", PatioCodeGenTypes.VALUE_TYPE),
- PatioLocal.param("right", PatioCodeGenTypes.VALUE_TYPE)
+ PatioLocal.param("left", ShidToPatioTypes.VALUE_TYPE),
+ PatioLocal.param("right", ShidToPatioTypes.VALUE_TYPE)
),
- PatioCodeGenTypes.VALUE_TYPE,
+ ShidToPatioTypes.VALUE_TYPE,
Sources.RUNTIME
);
- private PatioCodeGenStrings() {}
+ private ShidToPatioStrings() {}
- public static PatioCodeGenResult<PatioDataPtr> define(
+ public static ShidToPatioResult<PatioDataPtr> define(
String value,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
var codeUnits = value.getBytes(StandardCharsets.UTF_8);
@@ -43,13 +43,13 @@ public class PatioCodeGenStrings {
codeUnitsDataValues.add(PatioDataValues.byte_(codeUnit));
}
- var dataValue = PatioCodeGenGc.gcObjectStaticDataValue(PatioDataValues.struct(List.of(
+ var dataValue = ShidToPatioGc.gcObjectStaticDataValue(PatioDataValues.struct(List.of(
PatioDataValues.int_(codeUnits.length),
PatioDataValues.array(PatioDataLayouts.BYTE, codeUnitsDataValues)
)));
var elementNameResult = context.allocateCompilationUnitElementName(
- PatioCodeGenCompilationUnitElementSpace.STRING
+ ShidToPatioCompilationUnitElementSpace.STRING
);
var elementName = elementNameResult.value();
context = elementNameResult.context();
@@ -63,12 +63,12 @@ public class PatioCodeGenStrings {
return context.toResult(new PatioDataPtr(elementName));
}
- public static PatioCodeGenContext add(
+ public static ShidToPatioContext add(
PatioLocalRef target,
PatioOperand left,
PatioOperand right,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
context = context.ensureCompilationUnitElement(STRING_ADD_DECLARATION);
diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenStructs.java b/src/main/java/org/shedlang/compiler/patio/ShidToPatioStructs.java
index c02f0998..cc1e79f0 100644
--- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenStructs.java
+++ b/src/main/java/org/shedlang/compiler/patio/ShidToPatioStructs.java
@@ -16,18 +16,18 @@ import org.shedlang.compiler.util.Lists;
import java.util.List;
-public class PatioCodeGenStructs {
- private PatioCodeGenStructs() {
+public class ShidToPatioStructs {
+ private ShidToPatioStructs() {
}
- public static PatioCodeGenContext createType(
+ public static ShidToPatioContext createType(
PatioLocalRef target,
StructType type,
List<ShidDefineStruct.Field> fields,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
- return PatioCodeGenFunctions.create(
+ return ShidToPatioFunctions.create(
target,
type.name(),
List.of(),
@@ -37,7 +37,7 @@ public class PatioCodeGenStructs {
FreeVariables.empty(),
bodyContext -> {
var valuePointerResult = bodyContext.allocateVal(
- PatioCodeGenLocalSpace.STRUCT_VALUE_POINTER,
+ ShidToPatioLocalSpace.STRUCT_VALUE_POINTER,
PatioTypes.DATA_POINTER
);
var valuePointer = valuePointerResult.value();
@@ -45,7 +45,7 @@ public class PatioCodeGenStructs {
var structDataLayout = structDataLayout(type, context);
- bodyContext = PatioCodeGenGc.alloc(
+ bodyContext = ShidToPatioGc.alloc(
valuePointer,
structDataLayout,
GC_CHILDREN_OFFSET,
@@ -77,8 +77,8 @@ public class PatioCodeGenStructs {
}
var valueResult = bodyContext.allocateVal(
- PatioCodeGenLocalSpace.STRUCT_VALUE,
- PatioCodeGenTypes.VALUE_TYPE
+ ShidToPatioLocalSpace.STRUCT_VALUE,
+ ShidToPatioTypes.VALUE_TYPE
);
var value = valueResult.value();
bodyContext = valueResult.context();
@@ -98,16 +98,16 @@ public class PatioCodeGenStructs {
);
}
- public static PatioCodeGenContext fieldLoad(
+ public static ShidToPatioContext fieldLoad(
PatioLocalRef target,
PatioOperand receiver,
StructType type,
String fieldName,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
var valuePointerResult = context.allocateVal(
- PatioCodeGenLocalSpace.STRUCT_VALUE_POINTER,
+ ShidToPatioLocalSpace.STRUCT_VALUE_POINTER,
PatioTypes.DATA_POINTER
);
var valuePointer = valuePointerResult.value();
@@ -135,14 +135,14 @@ public class PatioCodeGenStructs {
return context;
}
- public static PatioCodeGenContext tagLoad(
+ public static ShidToPatioContext tagLoad(
PatioLocalRef target,
PatioOperand receiver,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
var valuePointerResult = context.allocateVal(
- PatioCodeGenLocalSpace.STRUCT_VALUE_POINTER,
+ ShidToPatioLocalSpace.STRUCT_VALUE_POINTER,
PatioTypes.DATA_POINTER
);
var valuePointer = valuePointerResult.value();
@@ -168,18 +168,18 @@ public class PatioCodeGenStructs {
}
private static PatioDataLayout unknownStructDataLayout() {
- return PatioCodeGenGc.gcObjectDataLayout(PatioDataLayouts.struct(List.of(
+ return ShidToPatioGc.gcObjectDataLayout(PatioDataLayouts.struct(List.of(
PatioDataLayouts.INT
)));
}
private static PatioDataLayout structDataLayout(
StructType type,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
var structTypeInfo = context.structTypeInfo(type);
- return PatioCodeGenGc.gcObjectDataLayout(PatioDataLayouts.struct(List.of(
+ return ShidToPatioGc.gcObjectDataLayout(PatioDataLayouts.struct(List.of(
PatioDataLayouts.INT,
PatioDataLayouts.struct(Lists.repeat(
PatioDataLayouts.INT,
@@ -189,12 +189,12 @@ public class PatioCodeGenStructs {
}
private static final List<Integer> TAG_OFFSET
- = PatioCodeGenGc.gcObjectOffset(List.of(0));
+ = ShidToPatioGc.gcObjectOffset(List.of(0));
private static List<Integer> fieldOffset(int fieldIndex) {
- return PatioCodeGenGc.gcObjectOffset(List.of(1, fieldIndex));
+ return ShidToPatioGc.gcObjectOffset(List.of(1, fieldIndex));
}
private static final List<Integer> GC_CHILDREN_OFFSET =
- PatioCodeGenGc.gcObjectOffset(List.of(1));
+ ShidToPatioGc.gcObjectOffset(List.of(1));
}
diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenTuples.java b/src/main/java/org/shedlang/compiler/patio/ShidToPatioTuples.java
index a99689ff..7bfbaeb8 100644
--- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenTuples.java
+++ b/src/main/java/org/shedlang/compiler/patio/ShidToPatioTuples.java
@@ -12,18 +12,18 @@ import org.shedlang.compiler.util.Lists;
import java.util.List;
-public class PatioCodeGenTuples {
- private PatioCodeGenTuples() {
+public class ShidToPatioTuples {
+ private ShidToPatioTuples() {
}
- public static PatioCodeGenResult<PatioLocalRef> create(
+ public static ShidToPatioResult<PatioLocalRef> create(
List<PatioOperand> elements,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
var tupleResult = context.allocateVal(
- PatioCodeGenLocalSpace.TUPLE,
- PatioCodeGenTypes.VALUE_TYPE
+ ShidToPatioLocalSpace.TUPLE,
+ ShidToPatioTypes.VALUE_TYPE
);
var tuple = tupleResult.value();
context = tupleResult.context();
@@ -39,7 +39,7 @@ public class PatioCodeGenTuples {
}
var tuplePointerResult = context.allocateVal(
- PatioCodeGenLocalSpace.TUPLE_POINTER,
+ ShidToPatioLocalSpace.TUPLE_POINTER,
PatioTypes.DATA_POINTER
);
var tuplePointer = tuplePointerResult.value();
@@ -47,7 +47,7 @@ public class PatioCodeGenTuples {
var tupleLayout = tupleDataLayout(elements.size());
- context = PatioCodeGenGc.alloc(
+ context = ShidToPatioGc.alloc(
tuplePointer,
tupleLayout,
GC_CHILDREN_OFFSET,
@@ -77,15 +77,15 @@ public class PatioCodeGenTuples {
return context.toResult(tuple);
}
- public static PatioCodeGenResult<PatioLocalRef> get(
+ public static ShidToPatioResult<PatioLocalRef> get(
PatioOperand tuple,
int elementIndex,
int elementCount,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
var tuplePointerResult = context.allocateVal(
- PatioCodeGenLocalSpace.TUPLE,
+ ShidToPatioLocalSpace.TUPLE,
PatioTypes.DATA_POINTER
);
var tuplePointer = tuplePointerResult.value();
@@ -98,9 +98,9 @@ public class PatioCodeGenTuples {
));
var targetResult = context.allocateVal(
- PatioCodeGenLocalSpace.TUPLE_ELEMENT,
+ ShidToPatioLocalSpace.TUPLE_ELEMENT,
Integer.toString(elementIndex),
- PatioCodeGenTypes.VALUE_TYPE
+ ShidToPatioTypes.VALUE_TYPE
);
var target = targetResult.value();
context = targetResult.context();
@@ -117,16 +117,16 @@ public class PatioCodeGenTuples {
}
private static PatioDataLayout tupleDataLayout(int elementCount) {
- return PatioCodeGenGc.gcObjectDataLayout(PatioDataLayouts.struct(Lists.repeat(
+ return ShidToPatioGc.gcObjectDataLayout(PatioDataLayouts.struct(Lists.repeat(
PatioDataLayouts.INT,
elementCount
)));
}
private static List<Integer> elementOffset(int elementIndex) {
- return PatioCodeGenGc.gcObjectOffset(List.of(elementIndex));
+ return ShidToPatioGc.gcObjectOffset(List.of(elementIndex));
}
private static final List<Integer> GC_CHILDREN_OFFSET =
- PatioCodeGenGc.gcObjectOffset(List.of());
+ ShidToPatioGc.gcObjectOffset(List.of());
}
diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenTypes.java b/src/main/java/org/shedlang/compiler/patio/ShidToPatioTypes.java
index 26d164fe..0035d210 100644
--- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenTypes.java
+++ b/src/main/java/org/shedlang/compiler/patio/ShidToPatioTypes.java
@@ -3,8 +3,8 @@ package org.shedlang.compiler.patio;
import org.shedlang.compiler.patio.ast.types.PatioType;
import org.shedlang.compiler.patio.ast.types.PatioTypes;
-public class PatioCodeGenTypes {
- private PatioCodeGenTypes() {}
+public class ShidToPatioTypes {
+ private ShidToPatioTypes() {}
public static final PatioType TAG_TYPE = PatioTypes.INT;
public static final PatioType VALUE_TYPE = PatioTypes.INT;
diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenVars.java b/src/main/java/org/shedlang/compiler/patio/ShidToPatioVars.java
index 72218531..18854fd0 100644
--- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenVars.java
+++ b/src/main/java/org/shedlang/compiler/patio/ShidToPatioVars.java
@@ -11,21 +11,21 @@ import org.shedlang.compiler.sources.Source;
import java.util.List;
-public class PatioCodeGenVars {
- private PatioCodeGenVars() {
+public class ShidToPatioVars {
+ private ShidToPatioVars() {
}
private static final PatioDataLayout VAR_DATA_LAYOUT =
- PatioCodeGenGc.gcObjectDataLayout(PatioDataLayouts.fromType(PatioCodeGenTypes.VALUE_TYPE));
+ ShidToPatioGc.gcObjectDataLayout(PatioDataLayouts.fromType(ShidToPatioTypes.VALUE_TYPE));
- private static final List<Integer> VALUE_OFFSET = PatioCodeGenGc.gcObjectOffset(List.of());
- private static final List<Integer> GC_CHILDREN_OFFSET = PatioCodeGenGc.gcObjectOffset(List.of());
+ private static final List<Integer> VALUE_OFFSET = ShidToPatioGc.gcObjectOffset(List.of());
+ private static final List<Integer> GC_CHILDREN_OFFSET = ShidToPatioGc.gcObjectOffset(List.of());
private static final int GC_CHILDREN_COUNT = 1;
- public static PatioCodeGenContext alloc(
+ public static ShidToPatioContext alloc(
String shidName,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
var patioLocalResult = context.declareShidVal(
shidName,
@@ -34,7 +34,7 @@ public class PatioCodeGenVars {
var patioLocal = patioLocalResult.value();
context = patioLocalResult.context();
- context = PatioCodeGenGc.alloc(
+ context = ShidToPatioGc.alloc(
patioLocal,
VAR_DATA_LAYOUT,
GC_CHILDREN_OFFSET,
@@ -48,11 +48,11 @@ public class PatioCodeGenVars {
return context;
}
- public static PatioCodeGenContext store(
+ public static ShidToPatioContext store(
String shidName,
PatioOperand value,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
return context.addInstruction(new PatioMemoryStore(
context.shidLocalNameToLocal(shidName),
@@ -63,11 +63,11 @@ public class PatioCodeGenVars {
));
}
- public static PatioCodeGenContext load(
+ public static ShidToPatioContext load(
PatioLocalRef target,
String shidName,
Source source,
- PatioCodeGenContext context
+ ShidToPatioContext context
) {
return context.addInstruction(new PatioMemoryLoad(
target,