aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-07-20 11:31:51 +0100
committerMichael Williamson <mike@zwobble.org>2023-07-20 11:32:10 +0100
commita43868cec3986d17da9987caf89ccc137e3a48d4 (patch)
tree0f13314b1546b1767f06210d1534a049d5624c00 /src/main/java
parent0fdcc84a6eaf3664e5305055e389dde33553ad5e (diff)
Rename PatioLocal to PatioLocalRef
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/shedlang/compiler/patio/PatioCodeGen.java6
-rw-r--r--src/main/java/org/shedlang/compiler/patio/PatioCodeGenClosures.java12
-rw-r--r--src/main/java/org/shedlang/compiler/patio/PatioCodeGenContext.java30
-rw-r--r--src/main/java/org/shedlang/compiler/patio/ast/PatioLocalRef.java (renamed from src/main/java/org/shedlang/compiler/patio/ast/PatioLocal.java)2
-rw-r--r--src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java28
-rw-r--r--src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioAlloc.java4
-rw-r--r--src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioCallPointer.java8
-rw-r--r--src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioFunctionPointerGet.java4
-rw-r--r--src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioIntGet.java4
-rw-r--r--src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioLocalCopy.java6
-rw-r--r--src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioMemoryLoad.java6
-rw-r--r--src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioMemoryStore.java6
-rw-r--r--src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioReturn.java4
13 files changed, 60 insertions, 60 deletions
diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGen.java b/src/main/java/org/shedlang/compiler/patio/PatioCodeGen.java
index ff0434dc..781cece5 100644
--- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGen.java
+++ b/src/main/java/org/shedlang/compiler/patio/PatioCodeGen.java
@@ -1,7 +1,7 @@
package org.shedlang.compiler.patio;
import org.shedlang.compiler.patio.ast.instructions.PatioIntGet;
-import org.shedlang.compiler.patio.ast.PatioLocal;
+import org.shedlang.compiler.patio.ast.PatioLocalRef;
import org.shedlang.compiler.patio.ast.instructions.PatioReturn;
import org.shedlang.compiler.sources.Source;
import org.shedlang.compiler.stackir.instructions.*;
@@ -33,7 +33,7 @@ public class PatioCodeGen {
) {
return switch (stackIrInstruction) {
case CallInstruction call -> {
- var namedArgsByName = new ArrayList<Map.Entry<String, PatioLocal>>();
+ var namedArgsByName = new ArrayList<Map.Entry<String, PatioLocalRef>>();
for (var argName : reversed(call.namedArgNames())) {
var argResult = context.allocateLocal(
PatioCodeGenLocalSpace.CALL_ARG_NAMED,
@@ -50,7 +50,7 @@ public class PatioCodeGen {
namedArgsByName.add(Map.entry(argName, arg));
}
- var positionalArgs = new ArrayList<PatioLocal>();
+ var positionalArgs = new ArrayList<PatioLocalRef>();
for (var i = 0; i < call.positionalArgCount(); i++) {
var argResult = context.allocateLocal(
PatioCodeGenLocalSpace.CALL_ARG_POSITIONAL,
diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenClosures.java b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenClosures.java
index 839a0067..6308c59a 100644
--- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenClosures.java
+++ b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenClosures.java
@@ -2,7 +2,7 @@ package org.shedlang.compiler.patio;
import org.shedlang.compiler.ast.typed.FreeVariables;
import org.shedlang.compiler.patio.ast.instructions.PatioCallPointer;
-import org.shedlang.compiler.patio.ast.PatioLocal;
+import org.shedlang.compiler.patio.ast.PatioLocalRef;
import org.shedlang.compiler.patio.ast.instructions.PatioMemoryLoad;
import org.shedlang.compiler.sources.Source;
import org.shedlang.compiler.stackir.instructions.DefineFunctionInstruction;
@@ -43,10 +43,10 @@ class PatioCodeGenClosures {
}
static PatioCodeGenContext call(
- PatioLocal target,
- PatioLocal closure,
- List<PatioLocal> positionalArgs,
- List<Map.Entry<String, PatioLocal>> namedArgsByName,
+ PatioLocalRef target,
+ PatioLocalRef closure,
+ List<PatioLocalRef> positionalArgs,
+ List<Map.Entry<String, PatioLocalRef>> namedArgsByName,
Source source,
PatioCodeGenContext context
) {
@@ -61,7 +61,7 @@ class PatioCodeGenClosures {
source
));
- var args = new ArrayList<PatioLocal>();
+ var args = new ArrayList<PatioLocalRef>();
args.add(closure);
diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenContext.java b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenContext.java
index 42287560..c4d14e2c 100644
--- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenContext.java
+++ b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenContext.java
@@ -7,7 +7,7 @@ import org.pcollections.PVector;
import org.shedlang.compiler.backends.llvm.NameAllocator;
import org.shedlang.compiler.patio.ast.PatioCompilationUnitElement;
import org.shedlang.compiler.patio.ast.PatioFunctionDefinition;
-import org.shedlang.compiler.patio.ast.PatioLocal;
+import org.shedlang.compiler.patio.ast.PatioLocalRef;
import org.shedlang.compiler.patio.ast.instructions.PatioInstruction;
import org.shedlang.compiler.patio.ast.instructions.PatioLocalCopy;
import org.shedlang.compiler.sources.Source;
@@ -54,10 +54,10 @@ public record PatioCodeGenContext(
}
public record FunctionContext(
- PStack<PatioLocal> temporaryStack,
+ PStack<PatioLocalRef> temporaryStack,
PVector<PatioInstruction> instructions,
NameAllocator<PatioCodeGenLocalSpace> localNames,
- PMap<String, PatioLocal> stackIrNameToLocal
+ PMap<String, PatioLocalRef> stackIrNameToLocal
) {
public static final FunctionContext EMPTY = new FunctionContext(
P.stack(),
@@ -66,7 +66,7 @@ public record PatioCodeGenContext(
P.map()
);
- public Result<PatioLocal> temporaryPop() {
+ public Result<PatioLocalRef> temporaryPop() {
return new FunctionContext(
this.temporaryStack.minus(0),
this.instructions,
@@ -75,7 +75,7 @@ public record PatioCodeGenContext(
).toResult(this.temporaryStack.get(0));
}
- public FunctionContext temporaryPush(PatioLocal value) {
+ public FunctionContext temporaryPush(PatioLocalRef value) {
return new FunctionContext(
this.temporaryStack.plus(value),
this.instructions,
@@ -93,7 +93,7 @@ public record PatioCodeGenContext(
);
}
- public Result<PatioLocal> allocateLocal(PatioCodeGenLocalSpace space, Optional<String> name) {
+ public Result<PatioLocalRef> allocateLocal(PatioCodeGenLocalSpace space, Optional<String> name) {
var result = this.localNames.allocateName(space, name);
return new FunctionContext(
@@ -101,10 +101,10 @@ public record PatioCodeGenContext(
this.instructions,
result.allocator(),
this.stackIrNameToLocal
- ).toResult(new PatioLocal(result.name()));
+ ).toResult(new PatioLocalRef(result.name()));
}
- public Result<PatioLocal> stackIrLocalNameToLocal(String name) {
+ public Result<PatioLocalRef> stackIrLocalNameToLocal(String name) {
var context = this;
if (!this.stackIrNameToLocal.containsKey(name)) {
@@ -114,7 +114,7 @@ public record PatioCodeGenContext(
this.temporaryStack,
this.instructions,
result.allocator(),
- this.stackIrNameToLocal.plus(name, new PatioLocal(result.name()))
+ this.stackIrNameToLocal.plus(name, new PatioLocalRef(result.name()))
);
}
@@ -145,20 +145,20 @@ public record PatioCodeGenContext(
);
}
- public PatioCodeGenResult<PatioLocal> temporaryPop() {
+ public PatioCodeGenResult<PatioLocalRef> temporaryPop() {
var result = this.functionContext.temporaryPop();
return withFunctionContextResult(result);
}
- public PatioCodeGenContext temporaryPopIntoLocal(PatioLocal target, Source source) {
+ public PatioCodeGenContext temporaryPopIntoLocal(PatioLocalRef target, Source source) {
var result = this.functionContext.temporaryPop();
return new PatioCodeGenContext(this.compilationUnitContext, result.context)
.addInstruction(new PatioLocalCopy(target, result.value, source));
}
- public PatioCodeGenContext temporaryPush(PatioLocal value) {
+ public PatioCodeGenContext temporaryPush(PatioLocalRef value) {
var result = this.functionContext.temporaryPush(value);
return withFunctionContext(result);
@@ -168,19 +168,19 @@ public record PatioCodeGenContext(
return withFunctionContext(this.functionContext.addInstruction(instruction));
}
- public PatioCodeGenResult<PatioLocal> allocateLocal(PatioCodeGenLocalSpace space, String name) {
+ public PatioCodeGenResult<PatioLocalRef> allocateLocal(PatioCodeGenLocalSpace space, String name) {
var result = this.functionContext.allocateLocal(space, Optional.of(name));
return withFunctionContextResult(result);
}
- public PatioCodeGenResult<PatioLocal> allocateLocal(PatioCodeGenLocalSpace space) {
+ public PatioCodeGenResult<PatioLocalRef> allocateLocal(PatioCodeGenLocalSpace space) {
var result = this.functionContext.allocateLocal(space, Optional.empty());
return withFunctionContextResult(result);
}
- public PatioCodeGenResult<PatioLocal> stackIrLocalNameToLocal(String name) {
+ public PatioCodeGenResult<PatioLocalRef> stackIrLocalNameToLocal(String name) {
var result = this.functionContext.stackIrLocalNameToLocal(name);
return withFunctionContextResult(result);
diff --git a/src/main/java/org/shedlang/compiler/patio/ast/PatioLocal.java b/src/main/java/org/shedlang/compiler/patio/ast/PatioLocalRef.java
index a5a7d9c5..1911ee04 100644
--- a/src/main/java/org/shedlang/compiler/patio/ast/PatioLocal.java
+++ b/src/main/java/org/shedlang/compiler/patio/ast/PatioLocalRef.java
@@ -1,4 +1,4 @@
package org.shedlang.compiler.patio.ast;
-public record PatioLocal(String name) {
+public record PatioLocalRef(String name) {
}
diff --git a/src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java b/src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java
index d915399a..3b4dfde5 100644
--- a/src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java
+++ b/src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java
@@ -59,18 +59,18 @@ public class PatioSerializer {
case PatioAlloc alloc ->
treeList(
treeIdentifier("alloc"),
- localToTree(alloc.target()),
+ localRefToTree(alloc.target()),
treeInt(alloc.bytes())
);
case PatioCallPointer callPointer ->
treeList(
treeIdentifier("call-pointer"),
- localToTree(callPointer.target()),
- localToTree(callPointer.functionPointer()),
+ localRefToTree(callPointer.target()),
+ localRefToTree(callPointer.functionPointer()),
treeList(
callPointer.args().stream()
- .map(arg -> localToTree(arg))
+ .map(arg -> localRefToTree(arg))
.toList()
)
);
@@ -78,44 +78,44 @@ public class PatioSerializer {
case PatioIntGet intGet ->
treeList(
treeIdentifier("int-get"),
- localToTree(intGet.target()),
+ localRefToTree(intGet.target()),
treeInt(intGet.value())
);
case PatioLocalCopy localCopy ->
treeList(
treeIdentifier("local-copy"),
- localToTree(localCopy.target()),
- localToTree(localCopy.value())
+ localRefToTree(localCopy.target()),
+ localRefToTree(localCopy.value())
);
case PatioMemoryLoad memoryLoad ->
treeList(
treeIdentifier("memory-load"),
- localToTree(memoryLoad.target()),
- treeNamed("pointer", localToTree(memoryLoad.pointer())),
+ localRefToTree(memoryLoad.target()),
+ treeNamed("pointer", localRefToTree(memoryLoad.pointer())),
treeNamed("offset", treeInt(memoryLoad.offset()))
);
case PatioMemoryStore memoryStore ->
treeList(
treeIdentifier("memory-store"),
- treeNamed("pointer", localToTree(memoryStore.pointer())),
+ treeNamed("pointer", localRefToTree(memoryStore.pointer())),
treeNamed("offset", treeInt(memoryStore.offset())),
- treeNamed("value", localToTree(memoryStore.value()))
+ treeNamed("value", localRefToTree(memoryStore.value()))
);
case PatioFunctionPointerGet functionPointerGet ->
treeList(
treeIdentifier("function-pointer-get"),
- localToTree(functionPointerGet.target()),
+ localRefToTree(functionPointerGet.target()),
treeString(functionPointerGet.name())
);
case PatioReturn return_ ->
treeList(
treeIdentifier("return"),
- localToTree(return_.value())
+ localRefToTree(return_.value())
);
};
}
@@ -127,7 +127,7 @@ public class PatioSerializer {
};
}
- private static Tree localToTree(PatioLocal local) {
+ private static Tree localRefToTree(PatioLocalRef local) {
return treeString(local.name());
}
}
diff --git a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioAlloc.java b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioAlloc.java
index 61e3a6fe..5dad5de6 100644
--- a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioAlloc.java
+++ b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioAlloc.java
@@ -1,11 +1,11 @@
package org.shedlang.compiler.patio.ast.instructions;
-import org.shedlang.compiler.patio.ast.PatioLocal;
+import org.shedlang.compiler.patio.ast.PatioLocalRef;
import org.shedlang.compiler.sources.Source;
/**
* Allocate the given number of bytes, and store the pointer to the allocated
* memory in the target local.
*/
-public record PatioAlloc(PatioLocal target, int bytes, Source source) implements PatioInstruction {
+public record PatioAlloc(PatioLocalRef target, int bytes, Source source) implements PatioInstruction {
}
diff --git a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioCallPointer.java b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioCallPointer.java
index f2e81241..a3e30c02 100644
--- a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioCallPointer.java
+++ b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioCallPointer.java
@@ -1,6 +1,6 @@
package org.shedlang.compiler.patio.ast.instructions;
-import org.shedlang.compiler.patio.ast.PatioLocal;
+import org.shedlang.compiler.patio.ast.PatioLocalRef;
import org.shedlang.compiler.sources.Source;
import java.util.List;
@@ -10,9 +10,9 @@ import java.util.List;
* arguments, and store the returned value in the target local.
*/
public record PatioCallPointer(
- PatioLocal target,
- PatioLocal functionPointer,
- List<PatioLocal> args,
+ PatioLocalRef target,
+ PatioLocalRef functionPointer,
+ List<PatioLocalRef> args,
Source source
) implements PatioInstruction {
}
diff --git a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioFunctionPointerGet.java b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioFunctionPointerGet.java
index 3ab85137..01c361cf 100644
--- a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioFunctionPointerGet.java
+++ b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioFunctionPointerGet.java
@@ -1,10 +1,10 @@
package org.shedlang.compiler.patio.ast.instructions;
-import org.shedlang.compiler.patio.ast.PatioLocal;
+import org.shedlang.compiler.patio.ast.PatioLocalRef;
import org.shedlang.compiler.sources.Source;
/**
* Store a pointer to the function with the given name in the target local.
*/
-public record PatioFunctionPointerGet(PatioLocal target, String name, Source source) implements PatioInstruction {
+public record PatioFunctionPointerGet(PatioLocalRef target, String name, Source source) implements PatioInstruction {
}
diff --git a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioIntGet.java b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioIntGet.java
index 2b92dd3d..89d6a82c 100644
--- a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioIntGet.java
+++ b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioIntGet.java
@@ -1,10 +1,10 @@
package org.shedlang.compiler.patio.ast.instructions;
-import org.shedlang.compiler.patio.ast.PatioLocal;
+import org.shedlang.compiler.patio.ast.PatioLocalRef;
import org.shedlang.compiler.sources.Source;
/**
* Store the given value in the target local.
*/
-public record PatioIntGet(PatioLocal target, int value, Source source) implements PatioInstruction {
+public record PatioIntGet(PatioLocalRef target, int value, Source source) implements PatioInstruction {
}
diff --git a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioLocalCopy.java b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioLocalCopy.java
index 0fccbce8..58dbe369 100644
--- a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioLocalCopy.java
+++ b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioLocalCopy.java
@@ -1,14 +1,14 @@
package org.shedlang.compiler.patio.ast.instructions;
-import org.shedlang.compiler.patio.ast.PatioLocal;
+import org.shedlang.compiler.patio.ast.PatioLocalRef;
import org.shedlang.compiler.sources.Source;
/**
* Copy the given value into the target local.
*/
public record PatioLocalCopy(
- PatioLocal target,
- PatioLocal value,
+ PatioLocalRef target,
+ PatioLocalRef value,
Source source
) implements PatioInstruction {
}
diff --git a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioMemoryLoad.java b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioMemoryLoad.java
index 793445a0..b11cb114 100644
--- a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioMemoryLoad.java
+++ b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioMemoryLoad.java
@@ -1,6 +1,6 @@
package org.shedlang.compiler.patio.ast.instructions;
-import org.shedlang.compiler.patio.ast.PatioLocal;
+import org.shedlang.compiler.patio.ast.PatioLocalRef;
import org.shedlang.compiler.sources.Source;
/**
@@ -8,8 +8,8 @@ import org.shedlang.compiler.sources.Source;
* target local.
*/
public record PatioMemoryLoad(
- PatioLocal target,
- PatioLocal pointer,
+ PatioLocalRef target,
+ PatioLocalRef pointer,
int offset,
Source source
) implements PatioInstruction {
diff --git a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioMemoryStore.java b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioMemoryStore.java
index 444cbf1d..79e2ebae 100644
--- a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioMemoryStore.java
+++ b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioMemoryStore.java
@@ -1,15 +1,15 @@
package org.shedlang.compiler.patio.ast.instructions;
-import org.shedlang.compiler.patio.ast.PatioLocal;
+import org.shedlang.compiler.patio.ast.PatioLocalRef;
import org.shedlang.compiler.sources.Source;
/**
* Store the given value at the given offset from the given pointer.
*/
public record PatioMemoryStore(
- PatioLocal pointer,
+ PatioLocalRef pointer,
int offset,
- PatioLocal value,
+ PatioLocalRef value,
Source source
) implements PatioInstruction {
}
diff --git a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioReturn.java b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioReturn.java
index 1d022275..d2fe33b8 100644
--- a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioReturn.java
+++ b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioReturn.java
@@ -1,10 +1,10 @@
package org.shedlang.compiler.patio.ast.instructions;
-import org.shedlang.compiler.patio.ast.PatioLocal;
+import org.shedlang.compiler.patio.ast.PatioLocalRef;
import org.shedlang.compiler.sources.Source;
/**
* Return with the given value from the current function.
*/
-public record PatioReturn(PatioLocal value, Source source) implements PatioInstruction {
+public record PatioReturn(PatioLocalRef value, Source source) implements PatioInstruction {
}