From a43868cec3986d17da9987caf89ccc137e3a48d4 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Thu, 20 Jul 2023 11:31:51 +0100 Subject: Rename PatioLocal to PatioLocalRef --- .../org/shedlang/compiler/patio/PatioCodeGen.java | 6 ++--- .../compiler/patio/PatioCodeGenClosures.java | 12 ++++----- .../compiler/patio/PatioCodeGenContext.java | 30 +++++++++++----------- .../shedlang/compiler/patio/ast/PatioLocal.java | 4 --- .../shedlang/compiler/patio/ast/PatioLocalRef.java | 4 +++ .../compiler/patio/ast/PatioSerializer.java | 28 ++++++++++---------- .../patio/ast/instructions/PatioAlloc.java | 4 +-- .../patio/ast/instructions/PatioCallPointer.java | 8 +++--- .../ast/instructions/PatioFunctionPointerGet.java | 4 +-- .../patio/ast/instructions/PatioIntGet.java | 4 +-- .../patio/ast/instructions/PatioLocalCopy.java | 6 ++--- .../patio/ast/instructions/PatioMemoryLoad.java | 6 ++--- .../patio/ast/instructions/PatioMemoryStore.java | 6 ++--- .../patio/ast/instructions/PatioReturn.java | 4 +-- 14 files changed, 63 insertions(+), 63 deletions(-) delete mode 100644 src/main/java/org/shedlang/compiler/patio/ast/PatioLocal.java create mode 100644 src/main/java/org/shedlang/compiler/patio/ast/PatioLocalRef.java (limited to 'src/main/java') 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>(); + var namedArgsByName = new ArrayList>(); 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(); + var positionalArgs = new ArrayList(); 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 positionalArgs, - List> namedArgsByName, + PatioLocalRef target, + PatioLocalRef closure, + List positionalArgs, + List> namedArgsByName, Source source, PatioCodeGenContext context ) { @@ -61,7 +61,7 @@ class PatioCodeGenClosures { source )); - var args = new ArrayList(); + var args = new ArrayList(); 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 temporaryStack, + PStack temporaryStack, PVector instructions, NameAllocator localNames, - PMap stackIrNameToLocal + PMap stackIrNameToLocal ) { public static final FunctionContext EMPTY = new FunctionContext( P.stack(), @@ -66,7 +66,7 @@ public record PatioCodeGenContext( P.map() ); - public Result temporaryPop() { + public Result 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 allocateLocal(PatioCodeGenLocalSpace space, Optional name) { + public Result allocateLocal(PatioCodeGenLocalSpace space, Optional 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 stackIrLocalNameToLocal(String name) { + public Result 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 temporaryPop() { + public PatioCodeGenResult 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 allocateLocal(PatioCodeGenLocalSpace space, String name) { + public PatioCodeGenResult allocateLocal(PatioCodeGenLocalSpace space, String name) { var result = this.functionContext.allocateLocal(space, Optional.of(name)); return withFunctionContextResult(result); } - public PatioCodeGenResult allocateLocal(PatioCodeGenLocalSpace space) { + public PatioCodeGenResult allocateLocal(PatioCodeGenLocalSpace space) { var result = this.functionContext.allocateLocal(space, Optional.empty()); return withFunctionContextResult(result); } - public PatioCodeGenResult stackIrLocalNameToLocal(String name) { + public PatioCodeGenResult 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/PatioLocal.java deleted file mode 100644 index a5a7d9c5..00000000 --- a/src/main/java/org/shedlang/compiler/patio/ast/PatioLocal.java +++ /dev/null @@ -1,4 +0,0 @@ -package org.shedlang.compiler.patio.ast; - -public record PatioLocal(String name) { -} diff --git a/src/main/java/org/shedlang/compiler/patio/ast/PatioLocalRef.java b/src/main/java/org/shedlang/compiler/patio/ast/PatioLocalRef.java new file mode 100644 index 00000000..1911ee04 --- /dev/null +++ b/src/main/java/org/shedlang/compiler/patio/ast/PatioLocalRef.java @@ -0,0 +1,4 @@ +package org.shedlang.compiler.patio.ast; + +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 args, + PatioLocalRef target, + PatioLocalRef functionPointer, + List 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 { } -- cgit v1.2.3