diff --git a/prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/pbs/lowering/PbsExecutableBodyLowerer.java b/prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/pbs/lowering/PbsExecutableBodyLowerer.java index 9500ddf1..0a3ca1fe 100644 --- a/prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/pbs/lowering/PbsExecutableBodyLowerer.java +++ b/prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/pbs/lowering/PbsExecutableBodyLowerer.java @@ -173,23 +173,36 @@ final class PbsExecutableBodyLowerer { reportUnsupportedLowering("path assignment lowering is not supported in executable lowering v1", assignStatement.span(), context); return false; } - final var targetSlot = context.resolveLocalSlot(target.rootName()); - if (targetSlot == null) { - reportUnsupportedLowering("assignment target is not a known local: " + target.rootName(), assignStatement.span(), context); + final var targetLocalSlot = context.resolveLocalSlot(target.rootName()); + final var targetGlobalSlot = targetLocalSlot == null ? context.resolveGlobalSlot(target.rootName()) : null; + if (targetLocalSlot == null && targetGlobalSlot == null) { + reportUnsupportedLowering("assignment target is not a known local or global: " + target.rootName(), assignStatement.span(), context); return false; } if (assignStatement.operator() == PbsAst.AssignOperator.ASSIGN) { final var localOwner = callsiteEmitter.resolveExpressionOwnerForLowering(assignStatement.value(), context); lowerExpression(assignStatement.value(), context); - context.bindLocalOwner(target.rootName(), localOwner); - emitSetLocal(targetSlot, assignStatement.span(), context); + if (targetLocalSlot != null) { + context.bindLocalOwner(target.rootName(), localOwner); + emitSetLocal(targetLocalSlot, assignStatement.span(), context); + } else { + emitSetGlobal(targetGlobalSlot, assignStatement.span(), context); + } return false; } - emitGetLocal(targetSlot, assignStatement.span(), context); + if (targetLocalSlot != null) { + emitGetLocal(targetLocalSlot, assignStatement.span(), context); + } else { + emitGetGlobal(targetGlobalSlot, assignStatement.span(), context); + } lowerExpression(assignStatement.value(), context); emitBinaryOperatorInstruction(compoundAssignBinaryOperator(assignStatement.operator()), assignStatement.span(), context); - context.bindLocalOwner(target.rootName(), ""); - emitSetLocal(targetSlot, assignStatement.span(), context); + if (targetLocalSlot != null) { + context.bindLocalOwner(target.rootName(), ""); + emitSetLocal(targetLocalSlot, assignStatement.span(), context); + } else { + emitSetGlobal(targetGlobalSlot, assignStatement.span(), context); + } return false; } @@ -446,6 +459,53 @@ final class PbsExecutableBodyLowerer { final var slot = context.localSlotByNameId().get(context.nameTable().register(identifierExpr.name())); if (slot != null) { emitGetLocal(slot, identifierExpr.span(), context); + return; + } + final var globalSlot = context.resolveGlobalSlot(identifierExpr.name()); + if (globalSlot != null) { + emitGetGlobal(globalSlot, identifierExpr.span(), context); + return; + } + final var constDecl = context.resolveConstDecl(identifierExpr.name()); + if (constDecl != null && constDecl.initializer() != null) { + lowerConstExpression(constDecl.initializer(), context); + } + } + + private void lowerConstExpression( + final PbsAst.Expression expression, + final PbsExecutableLoweringContext context) { + if (expression == null) { + return; + } + switch (expression) { + case PbsAst.IntLiteralExpr intLiteralExpr -> lowerIntLiteral(intLiteralExpr, context); + case PbsAst.BoundedLiteralExpr boundedLiteralExpr -> + lowerIntLiteral(new PbsAst.IntLiteralExpr(boundedLiteralExpr.value(), boundedLiteralExpr.span()), context); + case PbsAst.StringLiteralExpr stringLiteralExpr -> emitPushConst(stringLiteralExpr.value(), stringLiteralExpr.span(), context); + case PbsAst.BoolLiteralExpr boolLiteralExpr -> emitPushBool(boolLiteralExpr.value(), boolLiteralExpr.span(), context); + case PbsAst.GroupExpr groupExpr -> lowerConstExpression(groupExpr.expression(), context); + case PbsAst.UnaryExpr unaryExpr -> { + lowerConstExpression(unaryExpr.expression(), context); + emitUnaryOperatorInstruction(unaryExpr.operator(), unaryExpr.span(), context); + } + case PbsAst.BinaryExpr binaryExpr -> { + lowerConstExpression(binaryExpr.left(), context); + lowerConstExpression(binaryExpr.right(), context); + emitBinaryOperatorInstruction(binaryExpr.operator(), binaryExpr.span(), context); + } + case PbsAst.IdentifierExpr identifierExpr -> { + final var referenced = context.resolveConstDecl(identifierExpr.name()); + if (referenced != null && referenced.initializer() != null) { + lowerConstExpression(referenced.initializer(), context); + } else { + reportUnsupportedLowering("const identifier is not lowerable: " + identifierExpr.name(), identifierExpr.span(), context); + } + } + default -> reportUnsupportedLowering( + "const expression is not lowerable in executable lowering v1", + expression.span(), + context); } } @@ -585,6 +645,24 @@ final class PbsExecutableBodyLowerer { span)); } + private void emitSetGlobal( + final int slot, + final p.studio.compiler.source.Span span, + final PbsExecutableLoweringContext context) { + context.instructions().add(new IRBackendExecutableFunction.Instruction( + IRBackendExecutableFunction.InstructionKind.SET_GLOBAL, + ModuleId.none(), + "", + null, + null, + null, + "", + "", + slot, + null, + span)); + } + private String compoundAssignBinaryOperator(final PbsAst.AssignOperator operator) { return switch (operator) { case ADD_ASSIGN -> "+"; @@ -681,6 +759,24 @@ final class PbsExecutableBodyLowerer { span)); } + private void emitGetGlobal( + final int slot, + final p.studio.compiler.source.Span span, + final PbsExecutableLoweringContext context) { + context.instructions().add(new IRBackendExecutableFunction.Instruction( + IRBackendExecutableFunction.InstructionKind.GET_GLOBAL, + ModuleId.none(), + "", + null, + null, + null, + "", + "", + slot, + null, + span)); + } + private void reportUnsupportedLowering( final String message, final p.studio.compiler.source.Span span, diff --git a/prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/pbs/lowering/PbsExecutableCallsiteEmitter.java b/prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/pbs/lowering/PbsExecutableCallsiteEmitter.java index c5b40327..f2882cc7 100644 --- a/prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/pbs/lowering/PbsExecutableCallsiteEmitter.java +++ b/prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/pbs/lowering/PbsExecutableCallsiteEmitter.java @@ -361,7 +361,9 @@ final class PbsExecutableCallsiteEmitter { final PbsExecutableLoweringContext context) { return switch (receiver) { case PbsAst.CallExpr ignored -> true; - case PbsAst.IdentifierExpr identifierExpr -> context.resolveLocalSlot(identifierExpr.name()) != null; + case PbsAst.IdentifierExpr identifierExpr -> + context.resolveLocalSlot(identifierExpr.name()) != null + || context.resolveGlobalSlot(identifierExpr.name()) != null; case PbsAst.GroupExpr groupExpr -> receiverProducesRuntimeValue(groupExpr.expression(), context); default -> false; }; diff --git a/prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/pbs/lowering/PbsExecutableLoweringContext.java b/prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/pbs/lowering/PbsExecutableLoweringContext.java index 3551029d..8bb642a6 100644 --- a/prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/pbs/lowering/PbsExecutableLoweringContext.java +++ b/prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/pbs/lowering/PbsExecutableLoweringContext.java @@ -58,6 +58,14 @@ final class PbsExecutableLoweringContext { return metadataIndex.builtinConstOwnerByNameId(); } + Map globalSlotByNameId() { + return metadataIndex.globalSlotByNameId(); + } + + Map constDeclByNameId() { + return metadataIndex.constDeclByNameId(); + } + Map builtinCanonicalBySourceType() { return metadataIndex.builtinCanonicalBySourceType(); } @@ -118,6 +126,20 @@ final class PbsExecutableLoweringContext { return localSlotByNameId.get(nameTable.register(localName)); } + Integer resolveGlobalSlot(final String globalName) { + if (globalName == null || globalName.isBlank()) { + return null; + } + return globalSlotByNameId().get(nameTable.register(globalName)); + } + + p.studio.compiler.pbs.ast.PbsAst.ConstDecl resolveConstDecl(final String constName) { + if (constName == null || constName.isBlank()) { + return null; + } + return constDeclByNameId().get(nameTable.register(constName)); + } + int declareLocalSlot(final String localName) { final var nameId = nameTable.register(localName); final var existing = localSlotByNameId.get(nameId); diff --git a/prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/pbs/lowering/PbsExecutableLoweringModels.java b/prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/pbs/lowering/PbsExecutableLoweringModels.java index e75b7828..7bc353b1 100644 --- a/prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/pbs/lowering/PbsExecutableLoweringModels.java +++ b/prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/pbs/lowering/PbsExecutableLoweringModels.java @@ -44,6 +44,8 @@ public class PbsExecutableLoweringModels { Map> hostByMethodName, Map builtinCanonicalBySourceType, Map builtinConstOwnerByNameId, + Map globalSlotByNameId, + Map constDeclByNameId, Map> intrinsicByOwnerAndMethod, Map intrinsicReturnOwnerByCanonical) { } diff --git a/prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/pbs/lowering/PbsExecutableMetadataIndexFactory.java b/prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/pbs/lowering/PbsExecutableMetadataIndexFactory.java index 9249bf81..a189bebd 100644 --- a/prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/pbs/lowering/PbsExecutableMetadataIndexFactory.java +++ b/prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/pbs/lowering/PbsExecutableMetadataIndexFactory.java @@ -27,6 +27,8 @@ final class PbsExecutableMetadataIndexFactory { final var hostByMethodName = indexHostBindingsByMethodName(reservedMetadata, nameTable); final var builtinCanonicalBySourceType = indexBuiltinCanonicalBySourceType(reservedMetadata); final var builtinConstOwnerByNameId = indexBuiltinConstOwners(reservedMetadata, nameTable); + final var globalSlotByNameId = indexGlobalSlots(ast, nameTable); + final var constDeclByNameId = indexConstDecls(ast, nameTable); final var builtinSignatureByOwnerAndMethod = indexBuiltinSignatures( ast, supplementalTopDecls, @@ -44,6 +46,8 @@ final class PbsExecutableMetadataIndexFactory { hostByMethodName, builtinCanonicalBySourceType, builtinConstOwnerByNameId, + globalSlotByNameId, + constDeclByNameId, intrinsicByOwnerAndMethod, intrinsicReturnOwnerByCanonical); } @@ -81,6 +85,33 @@ final class PbsExecutableMetadataIndexFactory { return builtinConstOwnerByNameId; } + private Map indexGlobalSlots( + final PbsAst.File ast, + final NameTable nameTable) { + final var globalSlotByNameId = new HashMap(); + var nextSlot = 0; + for (final var topDecl : ast.topDecls()) { + if (!(topDecl instanceof PbsAst.GlobalDecl globalDecl)) { + continue; + } + globalSlotByNameId.putIfAbsent(nameTable.register(globalDecl.name()), nextSlot++); + } + return globalSlotByNameId; + } + + private Map indexConstDecls( + final PbsAst.File ast, + final NameTable nameTable) { + final var constDeclByNameId = new HashMap(); + for (final var topDecl : ast.topDecls()) { + if (!(topDecl instanceof PbsAst.ConstDecl constDecl)) { + continue; + } + constDeclByNameId.putIfAbsent(nameTable.register(constDecl.name()), constDecl); + } + return constDeclByNameId; + } + private Map indexBuiltinSignatures( final PbsAst.File ast, final ReadOnlyList supplementalTopDecls, diff --git a/prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/pbs/lowering/PbsExecutableStackAnalyzer.java b/prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/pbs/lowering/PbsExecutableStackAnalyzer.java index 42216581..10cea500 100644 --- a/prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/pbs/lowering/PbsExecutableStackAnalyzer.java +++ b/prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/pbs/lowering/PbsExecutableStackAnalyzer.java @@ -38,8 +38,8 @@ final class PbsExecutableStackAnalyzer { var outHeight = incomingHeightByInstruction.get(index); switch (instruction.kind()) { - case PUSH_I32, PUSH_BOOL, PUSH_CONST, GET_LOCAL -> outHeight += 1; - case POP, SET_LOCAL -> { + case PUSH_I32, PUSH_BOOL, PUSH_CONST, GET_LOCAL, GET_GLOBAL -> outHeight += 1; + case POP, SET_LOCAL, SET_GLOBAL -> { if (outHeight <= 0) { throw new ExecutableLoweringAnalysisException( "stack underflow at " + instruction.kind().name().toLowerCase() + ": need=1 have=" + outHeight); diff --git a/prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/pbs/semantics/PbsFlowAssignmentAnalyzer.java b/prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/pbs/semantics/PbsFlowAssignmentAnalyzer.java index 706a6118..e5235ddd 100644 --- a/prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/pbs/semantics/PbsFlowAssignmentAnalyzer.java +++ b/prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/pbs/semantics/PbsFlowAssignmentAnalyzer.java @@ -108,6 +108,11 @@ final class PbsFlowAssignmentAnalyzer { return new AssignmentTargetResolution(localType, true); } + final var globalType = model.globalTypes.get(rootName); + if (globalType != null) { + return new AssignmentTargetResolution(globalType, true); + } + if (isKnownNonAssignableRoot(rootName, model)) { Diagnostics.error(diagnostics, PbsSemanticsErrors.E_SEM_ASSIGN_TARGET_NOT_ASSIGNABLE.name(), @@ -138,6 +143,8 @@ final class PbsFlowAssignmentAnalyzer { final var localType = scope.resolve(rootName); if (localType != null) { currentType = localType; + } else if (model.globalTypes.containsKey(rootName)) { + currentType = model.globalTypes.get(rootName); } else if (model.serviceSingletons.containsKey(rootName)) { currentType = model.serviceSingletons.get(rootName); } else if (model.constTypes.containsKey(rootName)) { diff --git a/prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/services/PBSFrontendPhaseService.java b/prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/services/PBSFrontendPhaseService.java index 91ff0df0..a293e925 100644 --- a/prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/services/PBSFrontendPhaseService.java +++ b/prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/java/p/studio/compiler/services/PBSFrontendPhaseService.java @@ -253,6 +253,8 @@ public class PBSFrontendPhaseService implements FrontendPhaseService { callableSignatures.add(new CallableSignatureRef(entryPointModuleId, entryPointCallableName, 0, "() -> unit")); final var instructions = new ArrayList(); instructions.add(getGlobalInstruction(bootGuardSlot, frameExecutable.span())); + instructions.add(pushBoolInstruction(true, frameExecutable.span())); + instructions.add(eqInstruction(frameExecutable.span())); instructions.add(jumpIfTrueInstruction("bootstrap_done", frameExecutable.span())); for (final var moduleId : sortedModuleIds) { final var moduleInitCallableId = moduleInitCallableIds.get(moduleId); @@ -297,7 +299,7 @@ public class PBSFrontendPhaseService implements FrontendPhaseService { 0, 0, 0, - 1, + 2, ReadOnlyList.wrap(instructions), frameExecutable.span())); @@ -459,6 +461,16 @@ public class PBSFrontendPhaseService implements FrontendPhaseService { span); } + private IRBackendExecutableFunction.Instruction eqInstruction(final Span span) { + return new IRBackendExecutableFunction.Instruction( + IRBackendExecutableFunction.InstructionKind.EQ, + "", + null, + null, + null, + span); + } + private IRBackendExecutableFunction.Instruction labelInstruction( final String label, final Span span) { diff --git a/prometeu-compiler/frontends/prometeu-frontend-pbs/src/test/java/p/studio/compiler/pbs/PbsFrontendCompilerTest.java b/prometeu-compiler/frontends/prometeu-frontend-pbs/src/test/java/p/studio/compiler/pbs/PbsFrontendCompilerTest.java index 8b11df44..fcc0f99a 100644 --- a/prometeu-compiler/frontends/prometeu-frontend-pbs/src/test/java/p/studio/compiler/pbs/PbsFrontendCompilerTest.java +++ b/prometeu-compiler/frontends/prometeu-frontend-pbs/src/test/java/p/studio/compiler/pbs/PbsFrontendCompilerTest.java @@ -134,6 +134,59 @@ class PbsFrontendCompilerTest { i.kind() == p.studio.compiler.models.IRBackendExecutableFunction.InstructionKind.CALL_FUNC)); } + @Test + void shouldLowerGlobalReadsAndWritesInExecutableBodies() { + final var source = """ + declare global tile_id: int = 0; + + fn tick() -> int { + tile_id = tile_id + 1; + if (tile_id > 7) { + tile_id = 0; + } + return tile_id; + } + """; + + final var diagnostics = DiagnosticSink.empty(); + final var compiler = new PbsFrontendCompiler(); + final var fileBackend = compiler.compileFile(new FileId(46), source, diagnostics); + + assertTrue(diagnostics.isEmpty(), diagnostics.stream().map(d -> d.getCode() + ":" + d.getMessage()).toList().toString()); + final var executableTick = fileBackend.executableFunctions().stream() + .filter(fn -> fn.callableName().equals("tick")) + .findFirst() + .orElseThrow(); + assertTrue(executableTick.instructions().stream().anyMatch(i -> + i.kind() == p.studio.compiler.models.IRBackendExecutableFunction.InstructionKind.GET_GLOBAL)); + assertTrue(executableTick.instructions().stream().anyMatch(i -> + i.kind() == p.studio.compiler.models.IRBackendExecutableFunction.InstructionKind.SET_GLOBAL)); + } + + @Test + void shouldLowerUserConstIdentifiersInExecutableBodies() { + final var source = """ + declare const MAX_FRAMES: int = 10; + + fn tick(frame_counter: int) -> bool { + return frame_counter > MAX_FRAMES; + } + """; + + final var diagnostics = DiagnosticSink.empty(); + final var compiler = new PbsFrontendCompiler(); + final var fileBackend = compiler.compileFile(new FileId(47), source, diagnostics); + + assertTrue(diagnostics.isEmpty(), diagnostics.stream().map(d -> d.getCode() + ":" + d.getMessage()).toList().toString()); + final var executableTick = fileBackend.executableFunctions().stream() + .filter(fn -> fn.callableName().equals("tick")) + .findFirst() + .orElseThrow(); + assertTrue(executableTick.instructions().stream().anyMatch(i -> + i.kind() == p.studio.compiler.models.IRBackendExecutableFunction.InstructionKind.PUSH_I32 + && "10".equals(i.label()))); + } + @Test void shouldClassifyCallableCallEvenWhenNameLooksHostLike() { final var source = """ diff --git a/prometeu-compiler/frontends/prometeu-frontend-pbs/src/test/java/p/studio/compiler/pbs/semantics/PbsSemanticsAssignmentTest.java b/prometeu-compiler/frontends/prometeu-frontend-pbs/src/test/java/p/studio/compiler/pbs/semantics/PbsSemanticsAssignmentTest.java index ce627a17..d9f43448 100644 --- a/prometeu-compiler/frontends/prometeu-frontend-pbs/src/test/java/p/studio/compiler/pbs/semantics/PbsSemanticsAssignmentTest.java +++ b/prometeu-compiler/frontends/prometeu-frontend-pbs/src/test/java/p/studio/compiler/pbs/semantics/PbsSemanticsAssignmentTest.java @@ -42,6 +42,28 @@ class PbsSemanticsAssignmentTest { d.getCode().equals(PbsSemanticsErrors.E_SEM_FIELD_WRITE_ACCESS_DENIED.name()))); } + @Test + void shouldAllowGlobalAssignments() { + final var source = """ + declare global tile_id: int = 0; + + fn tick(next: int) -> int { + tile_id = tile_id + next; + return tile_id; + } + """; + final var diagnostics = DiagnosticSink.empty(); + + new PbsFrontendCompiler().compileFile(new FileId(0), source, diagnostics); + + assertFalse(diagnostics.stream().anyMatch(d -> + d.getCode().equals(PbsSemanticsErrors.E_SEM_ASSIGN_TARGET_UNRESOLVED.name()))); + assertFalse(diagnostics.stream().anyMatch(d -> + d.getCode().equals(PbsSemanticsErrors.E_SEM_ASSIGN_TARGET_NOT_ASSIGNABLE.name()))); + assertFalse(diagnostics.stream().anyMatch(d -> + d.getCode().equals(PbsSemanticsErrors.E_SEM_ASSIGN_TYPE_MISMATCH.name()))); + } + @Test void shouldRejectUnresolvedImmutableAndTypeMismatchedAssignments() { final var source = """ diff --git a/prometeu-compiler/frontends/prometeu-frontend-pbs/src/test/java/p/studio/compiler/services/PBSFrontendPhaseServiceTest.java b/prometeu-compiler/frontends/prometeu-frontend-pbs/src/test/java/p/studio/compiler/services/PBSFrontendPhaseServiceTest.java index 411c9f75..6cf98622 100644 --- a/prometeu-compiler/frontends/prometeu-frontend-pbs/src/test/java/p/studio/compiler/services/PBSFrontendPhaseServiceTest.java +++ b/prometeu-compiler/frontends/prometeu-frontend-pbs/src/test/java/p/studio/compiler/services/PBSFrontendPhaseServiceTest.java @@ -381,16 +381,18 @@ class PBSFrontendPhaseServiceTest { .filter(function -> irBackend.getEntryPointCallableName().equals(function.callableName())) .findFirst() .orElseThrow(); - assertEquals(9, wrapper.instructions().size()); + assertEquals(11, wrapper.instructions().size()); assertEquals(p.studio.compiler.models.IRBackendExecutableFunction.InstructionKind.GET_GLOBAL, wrapper.instructions().get(0).kind()); - assertEquals(p.studio.compiler.models.IRBackendExecutableFunction.InstructionKind.JMP_IF_TRUE, wrapper.instructions().get(1).kind()); - assertTrue(wrapper.instructions().get(2).calleeCallableName().startsWith("__pbs.module_init$m")); - assertTrue(wrapper.instructions().get(3).calleeCallableName().startsWith("__pbs.project_init$m")); - assertEquals(p.studio.compiler.models.IRBackendExecutableFunction.InstructionKind.PUSH_BOOL, wrapper.instructions().get(4).kind()); - assertEquals(p.studio.compiler.models.IRBackendExecutableFunction.InstructionKind.SET_GLOBAL, wrapper.instructions().get(5).kind()); - assertEquals(p.studio.compiler.models.IRBackendExecutableFunction.InstructionKind.LABEL, wrapper.instructions().get(6).kind()); - assertEquals("frame", wrapper.instructions().get(7).calleeCallableName()); - assertEquals(p.studio.compiler.models.IRBackendExecutableFunction.InstructionKind.RET, wrapper.instructions().get(8).kind()); + assertEquals(p.studio.compiler.models.IRBackendExecutableFunction.InstructionKind.PUSH_BOOL, wrapper.instructions().get(1).kind()); + assertEquals(p.studio.compiler.models.IRBackendExecutableFunction.InstructionKind.EQ, wrapper.instructions().get(2).kind()); + assertEquals(p.studio.compiler.models.IRBackendExecutableFunction.InstructionKind.JMP_IF_TRUE, wrapper.instructions().get(3).kind()); + assertTrue(wrapper.instructions().get(4).calleeCallableName().startsWith("__pbs.module_init$m")); + assertTrue(wrapper.instructions().get(5).calleeCallableName().startsWith("__pbs.project_init$m")); + assertEquals(p.studio.compiler.models.IRBackendExecutableFunction.InstructionKind.PUSH_BOOL, wrapper.instructions().get(6).kind()); + assertEquals(p.studio.compiler.models.IRBackendExecutableFunction.InstructionKind.SET_GLOBAL, wrapper.instructions().get(7).kind()); + assertEquals(p.studio.compiler.models.IRBackendExecutableFunction.InstructionKind.LABEL, wrapper.instructions().get(8).kind()); + assertEquals("frame", wrapper.instructions().get(9).calleeCallableName()); + assertEquals(p.studio.compiler.models.IRBackendExecutableFunction.InstructionKind.RET, wrapper.instructions().get(10).kind()); } @Test diff --git a/prometeu-compiler/prometeu-build-pipeline/src/test/java/p/studio/compiler/backend/irvm/LowerToIRVMServiceTest.java b/prometeu-compiler/prometeu-build-pipeline/src/test/java/p/studio/compiler/backend/irvm/LowerToIRVMServiceTest.java index cae2b32a..bcfef43f 100644 --- a/prometeu-compiler/prometeu-build-pipeline/src/test/java/p/studio/compiler/backend/irvm/LowerToIRVMServiceTest.java +++ b/prometeu-compiler/prometeu-build-pipeline/src/test/java/p/studio/compiler/backend/irvm/LowerToIRVMServiceTest.java @@ -87,6 +87,8 @@ class LowerToIRVMServiceTest { fn("frame", "app", 20, ReadOnlyList.from(ret())), fn("__pbs.frame_wrapper$m0", "app", 40, ReadOnlyList.from( getGlobal(0), + pushBool(true), + eq(), jmpIfTrue("bootstrap_done"), callFunc("app", "__pbs.module_init$m0", 31), callFunc("app", "__pbs.project_init$m0", 32), @@ -101,13 +103,15 @@ class LowerToIRVMServiceTest { assertEquals("__pbs.frame_wrapper$m0", lowered.module().functions().get(0).name()); assertEquals(IRVMOp.GET_GLOBAL, lowered.module().functions().get(0).instructions().get(0).op()); - assertEquals(IRVMOp.JMP_IF_TRUE, lowered.module().functions().get(0).instructions().get(1).op()); - assertEquals(IRVMOp.CALL, lowered.module().functions().get(0).instructions().get(2).op()); - assertEquals(IRVMOp.CALL, lowered.module().functions().get(0).instructions().get(3).op()); - assertEquals(IRVMOp.PUSH_BOOL, lowered.module().functions().get(0).instructions().get(4).op()); - assertEquals(IRVMOp.SET_GLOBAL, lowered.module().functions().get(0).instructions().get(5).op()); - assertEquals(IRVMOp.CALL, lowered.module().functions().get(0).instructions().get(6).op()); - assertEquals(IRVMOp.RET, lowered.module().functions().get(0).instructions().get(7).op()); + assertEquals(IRVMOp.PUSH_BOOL, lowered.module().functions().get(0).instructions().get(1).op()); + assertEquals(IRVMOp.EQ, lowered.module().functions().get(0).instructions().get(2).op()); + assertEquals(IRVMOp.JMP_IF_TRUE, lowered.module().functions().get(0).instructions().get(3).op()); + assertEquals(IRVMOp.CALL, lowered.module().functions().get(0).instructions().get(4).op()); + assertEquals(IRVMOp.CALL, lowered.module().functions().get(0).instructions().get(5).op()); + assertEquals(IRVMOp.PUSH_BOOL, lowered.module().functions().get(0).instructions().get(6).op()); + assertEquals(IRVMOp.SET_GLOBAL, lowered.module().functions().get(0).instructions().get(7).op()); + assertEquals(IRVMOp.CALL, lowered.module().functions().get(0).instructions().get(8).op()); + assertEquals(IRVMOp.RET, lowered.module().functions().get(0).instructions().get(9).op()); assertEquals(IRVMOp.RET, lowered.module().functions().stream() .filter(function -> "frame".equals(function.name())) .findFirst() @@ -645,4 +649,14 @@ class LowerToIRVMServiceTest { null, Span.none()); } + + private static IRBackendExecutableFunction.Instruction eq() { + return new IRBackendExecutableFunction.Instruction( + IRBackendExecutableFunction.InstructionKind.EQ, + "", + null, + null, + null, + Span.none()); + } } diff --git a/test-projects/main/assets/.prometeu/cache.json b/test-projects/main/assets/.prometeu/cache.json index 228347b0..ea9a28f6 100644 --- a/test-projects/main/assets/.prometeu/cache.json +++ b/test-projects/main/assets/.prometeu/cache.json @@ -7,7 +7,7 @@ "relative_path" : "confirm.png", "mime_type" : "image/png", "size" : 137, - "last_modified" : 1773571367191, + "last_modified" : 1774359768919, "fingerprint" : "aa7d241deabcebe29a6096e14eaf16fdc06cf06380c11a507620b00fc7bff094", "metadata" : { }, "diagnostics" : [ { @@ -21,7 +21,7 @@ "relative_path" : "right-palette copy 10.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772403, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -39,7 +39,7 @@ "relative_path" : "right-palette copy 11.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772405, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -57,7 +57,7 @@ "relative_path" : "right-palette copy 12.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772406, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -75,7 +75,7 @@ "relative_path" : "right-palette copy 13.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772408, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -93,7 +93,7 @@ "relative_path" : "right-palette copy 14.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772409, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -111,7 +111,7 @@ "relative_path" : "right-palette copy 15.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772411, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -129,7 +129,7 @@ "relative_path" : "right-palette copy 16.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772412, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -147,7 +147,7 @@ "relative_path" : "right-palette copy 17.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772413, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -165,7 +165,7 @@ "relative_path" : "right-palette copy 18.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772415, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -183,7 +183,7 @@ "relative_path" : "right-palette copy 19.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772416, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -201,7 +201,7 @@ "relative_path" : "right-palette copy 2.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772417, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -219,7 +219,7 @@ "relative_path" : "right-palette copy 20.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772418, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -237,7 +237,7 @@ "relative_path" : "right-palette copy 21.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772420, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -255,7 +255,7 @@ "relative_path" : "right-palette copy 22.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772421, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -273,7 +273,7 @@ "relative_path" : "right-palette copy 23.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772423, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -291,7 +291,7 @@ "relative_path" : "right-palette copy 24.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772424, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -309,7 +309,7 @@ "relative_path" : "right-palette copy 25.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772425, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -327,7 +327,7 @@ "relative_path" : "right-palette copy 26.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772426, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -345,7 +345,7 @@ "relative_path" : "right-palette copy 27.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772428, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -363,7 +363,7 @@ "relative_path" : "right-palette copy 28.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772429, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -381,7 +381,7 @@ "relative_path" : "right-palette copy 29.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772430, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -399,7 +399,7 @@ "relative_path" : "right-palette copy 3.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772431, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -417,7 +417,7 @@ "relative_path" : "right-palette copy 30.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772432, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -435,7 +435,7 @@ "relative_path" : "right-palette copy 31.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772433, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -453,7 +453,7 @@ "relative_path" : "right-palette copy 32.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772435, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -471,7 +471,7 @@ "relative_path" : "right-palette copy 33.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772436, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -489,7 +489,7 @@ "relative_path" : "right-palette copy 34.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772437, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -507,7 +507,7 @@ "relative_path" : "right-palette copy 35.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772438, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -525,7 +525,7 @@ "relative_path" : "right-palette copy 36.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772439, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -543,7 +543,7 @@ "relative_path" : "right-palette copy 37.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772441, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -561,7 +561,7 @@ "relative_path" : "right-palette copy 38.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772442, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -579,7 +579,7 @@ "relative_path" : "right-palette copy 39.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772443, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -597,7 +597,7 @@ "relative_path" : "right-palette copy 4.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772444, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -615,7 +615,7 @@ "relative_path" : "right-palette copy 40.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772445, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -633,7 +633,7 @@ "relative_path" : "right-palette copy 41.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772448, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -651,7 +651,7 @@ "relative_path" : "right-palette copy 42.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772449, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -669,7 +669,7 @@ "relative_path" : "right-palette copy 43.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772450, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -687,7 +687,7 @@ "relative_path" : "right-palette copy 44.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772452, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -705,7 +705,7 @@ "relative_path" : "right-palette copy 45.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772453, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -723,7 +723,7 @@ "relative_path" : "right-palette copy 46.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772454, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -741,7 +741,7 @@ "relative_path" : "right-palette copy 47.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772455, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -759,7 +759,7 @@ "relative_path" : "right-palette copy 48.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772456, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -777,7 +777,7 @@ "relative_path" : "right-palette copy 49.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772458, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -795,7 +795,7 @@ "relative_path" : "right-palette copy 5.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772459, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -813,7 +813,7 @@ "relative_path" : "right-palette copy 50.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772460, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -831,7 +831,7 @@ "relative_path" : "right-palette copy 51.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772461, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -849,7 +849,7 @@ "relative_path" : "right-palette copy 52.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772463, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -867,7 +867,7 @@ "relative_path" : "right-palette copy 53.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772464, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -885,7 +885,7 @@ "relative_path" : "right-palette copy 54.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772465, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -903,7 +903,7 @@ "relative_path" : "right-palette copy 55.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772467, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -921,7 +921,7 @@ "relative_path" : "right-palette copy 56.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772468, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -939,7 +939,7 @@ "relative_path" : "right-palette copy 57.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772470, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -957,7 +957,7 @@ "relative_path" : "right-palette copy 58.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772474, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -975,7 +975,7 @@ "relative_path" : "right-palette copy 59.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772476, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -993,7 +993,7 @@ "relative_path" : "right-palette copy 6.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772478, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -1011,7 +1011,7 @@ "relative_path" : "right-palette copy 60.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772479, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -1029,7 +1029,7 @@ "relative_path" : "right-palette copy 61.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772481, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -1047,7 +1047,7 @@ "relative_path" : "right-palette copy 62.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772482, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -1065,7 +1065,7 @@ "relative_path" : "right-palette copy 63.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772483, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -1083,7 +1083,7 @@ "relative_path" : "right-palette copy 64.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772484, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -1101,7 +1101,7 @@ "relative_path" : "right-palette copy 65.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772485, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -1119,7 +1119,7 @@ "relative_path" : "right-palette copy 66.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772487, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -1137,7 +1137,7 @@ "relative_path" : "right-palette copy 67.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772488, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -1155,7 +1155,7 @@ "relative_path" : "right-palette copy 68.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772489, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -1173,7 +1173,7 @@ "relative_path" : "right-palette copy 69.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772491, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -1191,7 +1191,7 @@ "relative_path" : "right-palette copy 7.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772492, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -1209,7 +1209,7 @@ "relative_path" : "right-palette copy 8.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772493, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -1227,7 +1227,7 @@ "relative_path" : "right-palette copy 9.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772494, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -1245,7 +1245,7 @@ "relative_path" : "right-palette copy.png", "mime_type" : "image/png", "size" : 172, - "last_modified" : 1773913054715, + "last_modified" : 1774359772495, "fingerprint" : "eeb7cc665386299403b7be1c272375d5077f3647c587f8033aa8c9275f840562", "metadata" : { "tile" : { @@ -1263,7 +1263,7 @@ "relative_path" : "right-palette.png", "mime_type" : "image/png", "size" : 327, - "last_modified" : 1773932799598, + "last_modified" : 1774359773932, "fingerprint" : "0526996900bdeef23c72fe987fb45800f11895946dcd5f0f7f8390c879069a37", "metadata" : { "tile" : { @@ -1281,7 +1281,7 @@ "relative_path" : "wrong-palette.png", "mime_type" : "image/png", "size" : 248, - "last_modified" : 1773911050482, + "last_modified" : 1774359771814, "fingerprint" : "15850f68547775866b01a0fe0b0012bb0243dec303ce1f9c3e02220e05b593e6", "metadata" : { }, "diagnostics" : [ { @@ -1311,7 +1311,7 @@ "relative_path" : "confirm.png", "mime_type" : "image/png", "size" : 137, - "last_modified" : 1773253076764, + "last_modified" : 1774359768918, "fingerprint" : "aa7d241deabcebe29a6096e14eaf16fdc06cf06380c11a507620b00fc7bff094", "metadata" : { "tile" : { @@ -1341,7 +1341,7 @@ "relative_path" : "flag00.png", "mime_type" : "image/png", "size" : 507, - "last_modified" : 1774025407014, + "last_modified" : 1774359777378, "fingerprint" : "6ca635a7906067b6a2a8460a8562718c445783e6df18b9f2c80c83c5ac569db6", "metadata" : { "tile" : { @@ -1365,7 +1365,7 @@ "relative_path" : "flag01.png", "mime_type" : "image/png", "size" : 766, - "last_modified" : 1774025460662, + "last_modified" : 1774359777379, "fingerprint" : "79257d8437747a68e9e8eb8f43fced7aa55940dc8eca98f95767994abbacdd81", "metadata" : { }, "diagnostics" : [ { @@ -1379,7 +1379,7 @@ "relative_path" : "flag02.png", "mime_type" : "image/png", "size" : 684, - "last_modified" : 1774025485085, + "last_modified" : 1774359777379, "fingerprint" : "5fd43c447cf6dd9b164458860239427d2f4544ff6e007814731b50c17ffe75bf", "metadata" : { }, "diagnostics" : [ { @@ -1393,7 +1393,7 @@ "relative_path" : "flag03.png", "mime_type" : "image/png", "size" : 669, - "last_modified" : 1774025730144, + "last_modified" : 1774359777380, "fingerprint" : "7feab8c868bb446afd3dd7250e70504fb0ca228f463650d2dd7c525144e0b321", "metadata" : { "tile" : { @@ -1411,7 +1411,7 @@ "relative_path" : "link00.png", "mime_type" : "image/png", "size" : 497, - "last_modified" : 1774024641031, + "last_modified" : 1774359777381, "fingerprint" : "c363f3ef7f32d9b249c7dc8babdb3eb5aae68c524099e5e97290202b054dda71", "metadata" : { "tile" : { @@ -1429,7 +1429,7 @@ "relative_path" : "link01.png", "mime_type" : "image/png", "size" : 500, - "last_modified" : 1774024641031, + "last_modified" : 1774359777382, "fingerprint" : "e2130efbb9643b41a4fb62619f2713402f9622c7db040fe18d929609ef70b89a", "metadata" : { "tile" : { @@ -1447,7 +1447,7 @@ "relative_path" : "link02.png", "mime_type" : "image/png", "size" : 517, - "last_modified" : 1774024641031, + "last_modified" : 1774359777383, "fingerprint" : "9216dfc6a6226fac398e9f781550d23fbfaa65bd377cdda69187149beca114ec", "metadata" : { "tile" : { @@ -1465,7 +1465,7 @@ "relative_path" : "link03.png", "mime_type" : "image/png", "size" : 507, - "last_modified" : 1774024641031, + "last_modified" : 1774359777383, "fingerprint" : "ebc4b7ca7bb1455288681c5d71424f60f658a44cb343d0c3934329cec676c867", "metadata" : { "tile" : { @@ -1483,7 +1483,7 @@ "relative_path" : "link04.png", "mime_type" : "image/png", "size" : 497, - "last_modified" : 1774024641031, + "last_modified" : 1774359777384, "fingerprint" : "c363f3ef7f32d9b249c7dc8babdb3eb5aae68c524099e5e97290202b054dda71", "metadata" : { "tile" : { @@ -1501,7 +1501,7 @@ "relative_path" : "link05.png", "mime_type" : "image/png", "size" : 495, - "last_modified" : 1774024641032, + "last_modified" : 1774359777384, "fingerprint" : "1ba8ce75c445396334737143e0cfa56c87a1fb64cca8ad0962192594849249eb", "metadata" : { "tile" : { @@ -1519,7 +1519,7 @@ "relative_path" : "link06.png", "mime_type" : "image/png", "size" : 518, - "last_modified" : 1774024641032, + "last_modified" : 1774359777385, "fingerprint" : "5e0954447699c6d5eac7550f1a10cf520efcddad0b9fbd9a716434da9d9550d4", "metadata" : { "tile" : { @@ -1537,7 +1537,7 @@ "relative_path" : "link07.png", "mime_type" : "image/png", "size" : 517, - "last_modified" : 1774024641032, + "last_modified" : 1774359777385, "fingerprint" : "6104ba7f216a937994d478ed07766ec28f48ad72fdd6620508535a1f877b8ddb", "metadata" : { "tile" : { @@ -1555,7 +1555,7 @@ "relative_path" : "t1381s1.png", "mime_type" : "image/png", "size" : 4970, - "last_modified" : 1774023262790, + "last_modified" : 1774359777386, "fingerprint" : "c8b667527b32436ab97fd57b3215917f7065d6d1b7f6d71be1827351bdc61fa6", "metadata" : { }, "diagnostics" : [ { @@ -1569,7 +1569,7 @@ "relative_path" : "t1489s1.png", "mime_type" : "image/png", "size" : 6489, - "last_modified" : 1774023316667, + "last_modified" : 1774359777387, "fingerprint" : "678c6f48c6d1fcd1209c9d0ab1c46f20eea4871946135263b7363488cceb74f0", "metadata" : { }, "diagnostics" : [ { diff --git a/test-projects/main/cartridge/program.pbx b/test-projects/main/cartridge/program.pbx index 438842ce..7ad9ccf9 100644 Binary files a/test-projects/main/cartridge/program.pbx and b/test-projects/main/cartridge/program.pbx differ diff --git a/test-projects/main/src/main.pbs b/test-projects/main/src/main.pbs index 9e53bacc..f22c4558 100644 --- a/test-projects/main/src/main.pbs +++ b/test-projects/main/src/main.pbs @@ -4,20 +4,27 @@ import { Log } from @sdk:log; import { Input } from @sdk:input; import { Gfx } from @sdk:gfx; +declare global frame_counter: int = 0; +declare global tile_id: int = 0; +declare const MAX_FRAMES: int = 4; + [Frame] fn frame() -> void { let touch = Input.touch(); - let tile_id = 0; - let hold = 0; - let counter = 0; + + if (touch.button().released()) + { + frame_counter = 0; + tile_id = 0; + } if (touch.button().down()) { - hold = touch.button().hold() / 6; - while (counter < hold) + frame_counter = frame_counter + 1; + if (frame_counter > MAX_FRAMES) { - counter = counter + 1; + frame_counter = 0; tile_id = tile_id + 1; if (tile_id > 7) {