mirror of https://github.com/tbklang/tlang.git
Function argument support #52
Labels
No Label
dependency
emit
hashmapper
lebanonmapper
lexer
meta
needsfix
parser
qol
question
resolution
typing
No Milestone
No project
No Assignees
1 Participants
Notifications
Total Time Spent: 2 hours 54 minutes
Due Date
deavmi
2 hours 54 minutes
No due date set.
Blocks
#42 Function definitions
tlang/tlang
Reference: tlang/tlang#52
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?
Currently there is no support for the function arguments, they are not found in lookups. We need to make them known of and somehow declared but not in a way that emits them as stack variables WITHIN the body of the function (as they are not that).
Idea 1
We may need to somehow add it to the
getStatements()
function as the lookups on any class that inherits fromContainer
would have such a method, as do the sub-classFunction
.Now we would have to be careful because remember, the way instructions (at the end of the day) get emitted for the body of a function is that the
dependency/core.d
'sgeneralPass()
will callgetStatements()
on theContainer
-typeFunction
. We, don't want to by mistake when we get to:And then start adding to the fucntion's DNode a bunch of
StaticVariableDeclaration
objects. We should probably make some sort of either boolean flag of sub-type ofVariable
, that is then checked before a dnode addition is done. This will then avoid any declarations that would be generated by thetypechecker/core.d
when it runs through all the DNode's and produces Instructions.We effectively just want them in
getStatements()
so that lookups work!I think the sub-type option is nicer, we must then be sure to add that as a
cast(VariableParameter)entity
BEFORE thecast(Variable)
in the check and just have something like this:We could also do the check as the first in the
cast(Variable)entity
branch as well - might be a good idea for more concise code.vardec_varass_dependencyto function_parameters_fixLooks like we will need to look at the typechecking stuff, I am getting a
checkContainerCollision()
error it seems:I wonder, is it not related to maybe theese not having a container?
Line 126 is the following in the resolver:
And because these are run through by the typechecker in collision detection stage (because we have added these
VariableParameter[]
to thebodyStatements
/getStatements()
,therefore they will be checked and resolution too).Note Resolution is NOT required but occurs as we have the lines(in the
checkCollision()
method):It requires that we have a container as
parentOf()
is called by resolver as we want a full path resolution and hence theVariableParemeter
s need a parent so resolver can climb and generate the full path.We are getting an error, where the node is not visited as it is pooled on the spot in the branch:
The reason for this is the variable declaration
Variable
pass only happens later and should be pooled first. This is easy fix, we won't do weird weight changes, although we could. In fact the better option is this:Now that that works, we need to add a seperate DNode branch thing to not add dnodes for the
VariableParameter
(s)Currently this returns
null
in thedependency/core.d
:Aight the above is fixed with using the correct variable type in poolt to spwawn the correct
DNode
kind-of (must beVariableNode
as that is whatexpressionPass()
will cast too and if not, like just straightDNode
then the cats fails andnull
is returned in thatexpressionPass()
code):Next is the symbol mapping of the arguments in the function signature, this must be done in the emitting process...
A simple update to
generateSignature(Function)
worked:This has all been implemented with commit
8972a277f3f4b718667e457755cbed16f93c59b9/functions_parameters_fix
on branchfunctions_parameters_fix
Idk why this is opened but it is done
function_parameters_fixto vardec_varass_dependencyClosing now as this works, you will see now on
vardec_varass_dependency
for sure