mirror of https://github.com/tbklang/tlang.git
Casting support #87
Labels
No Label
dependency
emit
hashmapper
lebanonmapper
lexer
meta
needsfix
parser
qol
question
resolution
typing
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
Depends on
Reference: tlang/tlang#87
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What is this?
We want to add support for a
cast(<type>, <expression>)
or maybecast(<type>)<expression>
keyword such that we can easily change types. This will probably require some sort of new object to be made, like aCastedExpression
that wraps an existing expression of some sorts. Therefore the type can be persisted? Or something, we need to look at how we want to go about it.Example
Given a code like below:
We would have a mismatch.
Firstly the second line would push a
FetchValueInstr: j
onto the codequeue, and onto the type queue we would haveint
. We would therefore need to then do something like we have below:FetchValueVar: j
, then processing theCastUnaryOp
would pop it off and embed it into aCastUnaryInstr
(instead of a normalUnaryOpInstr
) - it should be a sub-type probably.CastedFetchInstruction
or whatever, so should we do a little hack where we don;t push aCastedFetchInstruction
onto the stack or what? I think the type situation is what matters most, but this instruction must be a value instruction and then ....getEmbeddedValueInstr()
from theCastedInstruction
suhc that we can perform that actual instruction and then we perform an emit for casting it (think movb etc. on lowest byte of an int).Progress
113386ebe2a6cf72b60767fa239b69a8d8ea217d
on branchcasting
The above code works correctly (and finds a type error when doing +myInt
instead of
bruh`). However, without braces on the cast operator, it doesn't complain, we may need to look at that.bbb9aaaa515be96748756a4bfae0e6c237e86429
on branchcasting
intovarass
now.2c912132492b4e3674dd44b2f128fd84727e9ebe
ofpointers
intovarass
now too.varass
intopointers
andcasting
to have them up to date and deduplicate.All done ✅
This was also improved by #110 - just an FYI 🪄
I'm going to close this for now, we can always make a new issue later - it seems pretty good now (casting support that is).
Also closed #110