mirror of
https://github.com/irmen/prog8.git
synced 2025-01-28 17:33:13 +00:00
tiny tweak of typecasting str to uword
This commit is contained in:
parent
2b43353eb4
commit
e876008427
@ -170,6 +170,12 @@ internal class BeforeAsmGenerationAstChanger(val program: Program, val errors: E
|
||||
AddressOf(typecast.expression as IdentifierReference, typecast.position),
|
||||
parent
|
||||
))
|
||||
} else if(typecast.expression is IFunctionCall) {
|
||||
return listOf(IAstModification.ReplaceNode(
|
||||
typecast,
|
||||
typecast.expression,
|
||||
parent
|
||||
))
|
||||
}
|
||||
} else {
|
||||
errors.err("cannot cast pass-by-reference value to type ${typecast.type} (only to UWORD)", typecast.position)
|
||||
|
@ -274,22 +274,23 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen
|
||||
when (valueDt) {
|
||||
in ByteDatatypes -> {
|
||||
assignExpressionToRegister(value, RegisterOrPair.A)
|
||||
return assignTypeCastedRegisters(target.asmVarname, targetDt, RegisterOrPair.A, valueDt)
|
||||
assignTypeCastedRegisters(target.asmVarname, targetDt, RegisterOrPair.A, valueDt)
|
||||
}
|
||||
in WordDatatypes -> {
|
||||
assignExpressionToRegister(value, RegisterOrPair.AY)
|
||||
return assignTypeCastedRegisters(target.asmVarname, targetDt, RegisterOrPair.AY, valueDt)
|
||||
assignTypeCastedRegisters(target.asmVarname, targetDt, RegisterOrPair.AY, valueDt)
|
||||
}
|
||||
DataType.FLOAT -> {
|
||||
assignExpressionToRegister(value, RegisterOrPair.FAC1)
|
||||
return assignTypecastedFloatFAC1(target.asmVarname, targetDt)
|
||||
assignTypecastedFloatFAC1(target.asmVarname, targetDt)
|
||||
}
|
||||
in PassByReferenceDatatypes -> {
|
||||
// str/array value cast (most likely to UWORD, take address-of)
|
||||
return assignExpressionToVariable(value, target.asmVarname, targetDt, null) // TODO test this cast
|
||||
assignExpressionToVariable(value, target.asmVarname, targetDt, null)
|
||||
}
|
||||
else -> throw AssemblyError("strange dt in typecast assign to var: $valueDt --> $targetDt")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// give up, do it via eval stack
|
||||
|
@ -12,26 +12,28 @@ main {
|
||||
uword uw
|
||||
byte bb
|
||||
ubyte ub
|
||||
str string1 = "irmen"
|
||||
uword[] array = [1111,2222,3333]
|
||||
|
||||
|
||||
fl = 9997.999
|
||||
ww = (fl+1.1) as word
|
||||
uw = (fl+1.1) as uword
|
||||
fl = 97.999
|
||||
bb = (fl+1.1) as byte
|
||||
ub = (fl+1.1) as ubyte
|
||||
|
||||
txt.print_w(ww)
|
||||
uw = string1 as uword
|
||||
txt.print_uwhex(uw,1)
|
||||
txt.chrout('\n')
|
||||
txt.print_uw(uw)
|
||||
uw = array as uword
|
||||
txt.print_uwhex(uw,1)
|
||||
txt.chrout('\n')
|
||||
txt.print_b(bb)
|
||||
uw = name() as uword
|
||||
txt.print_uwhex(uw,1)
|
||||
txt.chrout('\n')
|
||||
txt.print_ub(ub)
|
||||
uw = name()
|
||||
txt.print_uwhex(uw,1)
|
||||
txt.chrout('\n')
|
||||
|
||||
|
||||
test_stack.test()
|
||||
|
||||
}
|
||||
|
||||
sub name() -> str {
|
||||
return "irmen"
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user