mirror of
https://github.com/GayPizzaSpecifications/pork.git
synced 2025-08-03 21:21:33 +00:00
global: a working virtual machine for some of the use cases. APIs and validation still WIP.
This commit is contained in:
@ -13,4 +13,9 @@ class CompilableSlab(val compiler: Compiler, val slab: Slab) {
|
||||
fun resolve(symbol: Symbol): CompilableSymbol? = compilableSymbols.firstOrNull {
|
||||
it.scopeSymbol.symbol == symbol
|
||||
}
|
||||
|
||||
fun resolveVisible(symbol: Symbol): CompilableSymbol? {
|
||||
val scopeSymbol = slab.scope.resolve(symbol) ?: return null
|
||||
return compiler.resolveOrNull(scopeSymbol)
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ class LocalState(val symbol: CompilableSymbol) {
|
||||
return Loadable(stubVar = found)
|
||||
}
|
||||
}
|
||||
val found = this.symbol.compilableSlab.resolve(symbol)
|
||||
val found = this.symbol.compilableSlab.resolveVisible(symbol)
|
||||
if (found != null) {
|
||||
return Loadable(call = found)
|
||||
}
|
||||
|
@ -285,7 +285,9 @@ class StubOpEmitter(val compiler: Compiler, val symbol: CompilableSymbol) : Func
|
||||
code.emit(Opcode.Constant, listOf(defConstant))
|
||||
}
|
||||
val formConstant = compiler.constantPool.assign(ConstantTag.String, node.form.id.toByteArray())
|
||||
code.emit(Opcode.Native, listOf(formConstant, node.definitions.size.toUInt()))
|
||||
val functionDefinition = symbol.scopeSymbol.definition as FunctionDefinition
|
||||
val functionArgumentCount = functionDefinition.arguments.size
|
||||
code.emit(Opcode.Native, listOf(formConstant, node.definitions.size.toUInt(), functionArgumentCount.toUInt()))
|
||||
}
|
||||
|
||||
private fun load(callOrStubVar: Loadable) {
|
||||
|
Reference in New Issue
Block a user