diff --git a/bytecode/src/main/kotlin/gay/pizza/pork/bytecode/SymbolInfo.kt b/bytecode/src/main/kotlin/gay/pizza/pork/bytecode/SymbolInfo.kt index 5ce0895..bfca5e7 100644 --- a/bytecode/src/main/kotlin/gay/pizza/pork/bytecode/SymbolInfo.kt +++ b/bytecode/src/main/kotlin/gay/pizza/pork/bytecode/SymbolInfo.kt @@ -4,7 +4,10 @@ import kotlinx.serialization.Serializable @Serializable data class SymbolInfo( - val id: String, + val slab: String, + val symbol: String, val offset: UInt, val size: UInt -) +) { + val commonSymbolIdentity: String by lazy { "$slab $symbol" } +} diff --git a/compiler/src/main/kotlin/gay/pizza/pork/compiler/CompilableSymbol.kt b/compiler/src/main/kotlin/gay/pizza/pork/compiler/CompilableSymbol.kt index a03f085..3ee381b 100644 --- a/compiler/src/main/kotlin/gay/pizza/pork/compiler/CompilableSymbol.kt +++ b/compiler/src/main/kotlin/gay/pizza/pork/compiler/CompilableSymbol.kt @@ -28,7 +28,7 @@ class CompilableSymbol(val compilableSlab: CompilableSlab, val scopeSymbol: Scop } val id: String - get() = "${compilableSlab.slab.location.commonFriendlyName} ${scopeSymbol.symbol.id}" + get() = "${compilableSlab.slab.location.commonLocationIdentity} ${scopeSymbol.symbol.id}" - override fun toString(): String = "${compilableSlab.slab.location.commonFriendlyName} ${scopeSymbol.symbol.id}" + override fun toString(): String = "${compilableSlab.slab.location.commonLocationIdentity} ${scopeSymbol.symbol.id}" } diff --git a/compiler/src/main/kotlin/gay/pizza/pork/compiler/CompiledWorldLayout.kt b/compiler/src/main/kotlin/gay/pizza/pork/compiler/CompiledWorldLayout.kt index ec713e8..fa996b2 100644 --- a/compiler/src/main/kotlin/gay/pizza/pork/compiler/CompiledWorldLayout.kt +++ b/compiler/src/main/kotlin/gay/pizza/pork/compiler/CompiledWorldLayout.kt @@ -11,7 +11,12 @@ class CompiledWorldLayout(val compiler: Compiler) : StubResolutionContext { val start = allStubOps.size val result = symbol.compiledStubOps val stubOps = result.ops - symbolTable[symbol] = SymbolInfo(symbol.id, start.toUInt(), stubOps.size.toUInt()) + symbolTable[symbol] = SymbolInfo( + slab = symbol.compilableSlab.slab.location.commonLocationIdentity, + symbol = symbol.id, + offset = start.toUInt(), + size = stubOps.size.toUInt() + ) allStubOps.addAll(stubOps) allStubAnnotations.addAll(result.annotations) } diff --git a/compiler/src/main/kotlin/gay/pizza/pork/compiler/Compiler.kt b/compiler/src/main/kotlin/gay/pizza/pork/compiler/Compiler.kt index 4527b2d..88dd8c6 100644 --- a/compiler/src/main/kotlin/gay/pizza/pork/compiler/Compiler.kt +++ b/compiler/src/main/kotlin/gay/pizza/pork/compiler/Compiler.kt @@ -19,7 +19,7 @@ class Compiler { fun resolve(scopeSymbol: ScopeSymbol): CompilableSymbol = resolveOrNull(scopeSymbol) ?: throw RuntimeException( "Unable to resolve scope symbol: " + - "${scopeSymbol.slabScope.slab.location.commonFriendlyName} ${scopeSymbol.symbol.id}") + "${scopeSymbol.slabScope.slab.location.commonLocationIdentity} ${scopeSymbol.symbol.id}") fun contributeCompiledSymbols( into: MutableSet, diff --git a/evaluator/src/main/kotlin/gay/pizza/pork/evaluator/FunctionContext.kt b/evaluator/src/main/kotlin/gay/pizza/pork/evaluator/FunctionContext.kt index a15046c..3356f38 100644 --- a/evaluator/src/main/kotlin/gay/pizza/pork/evaluator/FunctionContext.kt +++ b/evaluator/src/main/kotlin/gay/pizza/pork/evaluator/FunctionContext.kt @@ -4,7 +4,7 @@ import gay.pizza.pork.ast.gen.FunctionDefinition import gay.pizza.pork.execution.ArgumentList class FunctionContext(val slabContext: SlabContext, val node: FunctionDefinition) : CallableFunction { - val name: String by lazy { "${slabContext.slab.location.commonFriendlyName} ${node.symbol.id}" } + val name: String by lazy { "${slabContext.slab.location.commonLocationIdentity} ${node.symbol.id}" } private fun resolveMaybeNative(): CallableFunction? = if (node.nativeFunctionDescriptor == null) { null diff --git a/evaluator/src/main/kotlin/gay/pizza/pork/evaluator/SlabContext.kt b/evaluator/src/main/kotlin/gay/pizza/pork/evaluator/SlabContext.kt index 1470b88..f4fa90f 100644 --- a/evaluator/src/main/kotlin/gay/pizza/pork/evaluator/SlabContext.kt +++ b/evaluator/src/main/kotlin/gay/pizza/pork/evaluator/SlabContext.kt @@ -7,8 +7,8 @@ import gay.pizza.pork.ast.gen.visit import gay.pizza.pork.frontend.Slab class SlabContext(val slab: Slab, val evaluator: Evaluator, rootScope: Scope) { - val internalScope = rootScope.fork("internal ${slab.location.commonFriendlyName}") - val externalScope = rootScope.fork("external ${slab.location.commonFriendlyName}") + val internalScope = rootScope.fork("internal ${slab.location.commonLocationIdentity}") + val externalScope = rootScope.fork("external ${slab.location.commonLocationIdentity}") init { processAllDefinitions() diff --git a/frontend/src/main/kotlin/gay/pizza/pork/frontend/SourceLocation.kt b/frontend/src/main/kotlin/gay/pizza/pork/frontend/SourceLocation.kt index 3969f52..bd8be1e 100644 --- a/frontend/src/main/kotlin/gay/pizza/pork/frontend/SourceLocation.kt +++ b/frontend/src/main/kotlin/gay/pizza/pork/frontend/SourceLocation.kt @@ -3,7 +3,7 @@ package gay.pizza.pork.frontend import gay.pizza.pork.tokenizer.SourceIndex data class SourceLocation(val form: String, val filePath: String, val index: SourceIndex? = null) { - val commonFriendlyName: String by lazy { "$form $filePath" } + val commonLocationIdentity: String by lazy { "$form $filePath" } fun withSourceIndex(index: SourceIndex): SourceLocation = SourceLocation(form, filePath, index) diff --git a/tool/src/main/kotlin/gay/pizza/pork/tool/CompileCommand.kt b/tool/src/main/kotlin/gay/pizza/pork/tool/CompileCommand.kt index e8d9b67..4b4cf5f 100644 --- a/tool/src/main/kotlin/gay/pizza/pork/tool/CompileCommand.kt +++ b/tool/src/main/kotlin/gay/pizza/pork/tool/CompileCommand.kt @@ -21,7 +21,7 @@ class CompileCommand : CliktCommand(help = "Compile Pork to Bytecode", name = "c val compiledWorld = compiler.compile(compiledMain) for (symbol in compiledWorld.symbolTable.symbols) { val code = compiledWorld.code.subList(symbol.offset.toInt(), (symbol.offset + symbol.size).toInt()) - println(symbol.id) + println(symbol.commonSymbolIdentity) for ((index, op) in code.withIndex()) { var annotation = "" val annotations = compiledWorld.annotations.filter { it.inst == (symbol.offset + index.toUInt()) } diff --git a/tool/src/main/kotlin/gay/pizza/pork/tool/ScopeAnalysisCommand.kt b/tool/src/main/kotlin/gay/pizza/pork/tool/ScopeAnalysisCommand.kt index f0ad523..53666bf 100644 --- a/tool/src/main/kotlin/gay/pizza/pork/tool/ScopeAnalysisCommand.kt +++ b/tool/src/main/kotlin/gay/pizza/pork/tool/ScopeAnalysisCommand.kt @@ -20,7 +20,7 @@ class ScopeAnalysisCommand : CliktCommand(help = "Run Scope Analysis", name = "s "symbol ${visibleScopeSymbol.scopeSymbol.symbol.id} " + "type=${visibleScopeSymbol.scopeSymbol.definition.type.name} " + "internal=${visibleScopeSymbol.isInternalSymbol} " + - "slab=${visibleScopeSymbol.scopeSymbol.slabScope.slab.location.commonFriendlyName}" + "slab=${visibleScopeSymbol.scopeSymbol.slabScope.slab.location.commonLocationIdentity}" ) } }