mirror of
https://github.com/irmen/prog8.git
synced 2024-07-26 20:29:55 +00:00
working on codegen fixes
This commit is contained in:
parent
117d848466
commit
48c9349ce9
@ -71,7 +71,8 @@ internal class BuiltinFunctionsAsmGen(private val program: PtProgram,
|
|||||||
"callrom" -> funcCallRom(fcall)
|
"callrom" -> funcCallRom(fcall)
|
||||||
else -> throw AssemblyError("missing asmgen for builtin func ${fcall.name}")
|
else -> throw AssemblyError("missing asmgen for builtin func ${fcall.name}")
|
||||||
}
|
}
|
||||||
TODO("return correct function result type")
|
|
||||||
|
return BuiltinFunctions.getValue(fcall.name).returnType
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun funcRsave() {
|
private fun funcRsave() {
|
||||||
|
@ -59,7 +59,12 @@ fun PtExpression.isSimple(): Boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal fun PtIdentifier.targetStatement(program: PtProgram): PtNode? {
|
internal fun PtIdentifier.targetStatement(program: PtProgram): PtNode? {
|
||||||
TODO("Not yet implemented")
|
TODO("Not yet implemented target stmt for ${this.name}")
|
||||||
|
// if(nameInSource.size==1 && nameInSource[0] in program.builtinFunctions.names)
|
||||||
|
// BuiltinFunctionPlaceholder(nameInSource[0], position, parent)
|
||||||
|
// else
|
||||||
|
// definingScope.lookup(nameInSource)
|
||||||
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun PtIdentifier.targetVarDecl(program: PtProgram): PtVariable? =
|
internal fun PtIdentifier.targetVarDecl(program: PtProgram): PtVariable? =
|
||||||
|
@ -2,10 +2,7 @@ package prog8.codegen.cpu6502.assignment
|
|||||||
|
|
||||||
import prog8.code.ast.*
|
import prog8.code.ast.*
|
||||||
import prog8.code.core.*
|
import prog8.code.core.*
|
||||||
import prog8.codegen.cpu6502.AsmGen
|
import prog8.codegen.cpu6502.*
|
||||||
import prog8.codegen.cpu6502.asConstInteger
|
|
||||||
import prog8.codegen.cpu6502.returnsWhatWhere
|
|
||||||
import prog8.codegen.cpu6502.targetSubroutine
|
|
||||||
|
|
||||||
|
|
||||||
internal enum class TargetStorageKind {
|
internal enum class TargetStorageKind {
|
||||||
@ -57,7 +54,9 @@ internal class AsmAssignTarget(val kind: TargetStorageKind,
|
|||||||
with(assign.target) {
|
with(assign.target) {
|
||||||
when {
|
when {
|
||||||
identifier != null -> {
|
identifier != null -> {
|
||||||
val parameter: PtSubroutineParameter = TODO("search subroutine parameter that it may refer to ${assign.target.identifier!!.name}") // identifier!!.targetVarDecl(program)?.subroutineParameter
|
val paramName = identifier!!.targetVarDecl(program)?.name
|
||||||
|
val parameter = identifier!!.targetStatement(program)?.definingSub()?.parameters?.singleOrNull { it.name===paramName }
|
||||||
|
println("assign to ${identifier!!.name} param=$parameter") // TODO WEG
|
||||||
if (parameter!=null) {
|
if (parameter!=null) {
|
||||||
val sub = parameter.definingAsmSub()
|
val sub = parameter.definingAsmSub()
|
||||||
if (sub!=null) {
|
if (sub!=null) {
|
||||||
|
@ -5,8 +5,13 @@
|
|||||||
main {
|
main {
|
||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
ubyte @shared ub = asmfoo(42)
|
rsavex()
|
||||||
ub = normalfoo(42)
|
|
||||||
|
ubyte @shared ub
|
||||||
|
void asmfoo(42)
|
||||||
|
main.asmfoo.arg = 42
|
||||||
|
main.normalfoo.arg=99
|
||||||
|
; normalfoo(42)
|
||||||
somelabel:
|
somelabel:
|
||||||
ub++
|
ub++
|
||||||
txt.print_ub(ub)
|
txt.print_ub(ub)
|
||||||
|
Loading…
Reference in New Issue
Block a user