Skip to content

Commit

Permalink
Merge 28e0520 into cd9fb4a
Browse files Browse the repository at this point in the history
  • Loading branch information
deavmi committed May 14, 2024
2 parents cd9fb4a + 28e0520 commit 1658ea9
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 2 deletions.
52 changes: 52 additions & 0 deletions source/tlang/compiler/parsing/core.d
Original file line number Diff line number Diff line change
Expand Up @@ -2017,6 +2017,48 @@ public final class Parser

parentToContainer(container, [binOpExp.getLeftExpression(), binOpExp.getRightExpression()]);
}
/**
* If we have an `UnaryOperatorExpression`
* then we want to parent its inner
* expression
*/
else if(cast(UnaryOperatorExpression)statement)
{
UnaryOperatorExpression unaryOp = cast(UnaryOperatorExpression)statement;
Expression opExpr = unaryOp.getExpression();

parentToContainer(container, [opExpr]);
}
/**
* If we have an `ArrayIndex` then
* we will want to parent its inner
* expression which is what the
* index itself is formed out of.
*
* We will also want to parent the
* expression being indexed itself.
*/
else if(cast(ArrayIndex)statement)
{
ArrayIndex indexOp = cast(ArrayIndex)statement;
Expression indexedExpr = indexOp.getIndexed();
Expression indexExpr = indexOp.getIndex();

parentToContainer(container, [indexedExpr, indexExpr]);
}
/**
* If we have an `ArrayAssignment` then
* we will want to parent its inner
* index-expression
*/
else if(cast(ArrayAssignment)statement)
{
ArrayAssignment arrAss = cast(ArrayAssignment)statement;
Expression indexExpr = arrAss.getArrayLeft();
Expression assExpr = arrAss.getAssignmentExpression();

parentToContainer(container, [indexExpr, assExpr]);
}
/**
* If we have a `VariableAssignmentStdAlone`
* then we must parent its expression
Expand Down Expand Up @@ -2055,6 +2097,16 @@ public final class Parser
Expression[] actualArguments = funcCall.getCallArguments();
parentToContainer(container, cast(Statement[])actualArguments);
}
/**
* If we have a `CastedExpression`
*/
else if(cast(CastedExpression)statement)
{
CastedExpression castExpr = cast(CastedExpression)statement;

Expression toCast = castExpr.getEmbeddedExpression();
parentToContainer(container, [toCast]);
}
/**
* If we have a `ReturnStmt`
* then we must process its
Expand Down
6 changes: 4 additions & 2 deletions source/tlang/compiler/typecheck/dependency/core.d
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,8 @@ public class DNodeGenerator
WARN("expressionPass(Exp): Processing "~exp.toString());
DEBUG("expressionPass(Exp): Context coming in "~to!(string)(context));

// TODO: Automatic dnode.getStatement().context = context?

/* TODO: Add pooling */

/**
Expand All @@ -617,7 +619,7 @@ public class DNodeGenerator
DEBUG("FuncCall: "~funcCall.getName());

/* TODO: We need to fetch the cached function definition here and call it */
Entity funcEntity = resolver.resolveBest(context.container, funcCall.getName());
Entity funcEntity = resolver.resolveBest(funcCall.parentOf(), funcCall.getName());
assert(funcEntity);

// FIXME: The below is failing (we probably need a forward look ahead?)
Expand Down Expand Up @@ -716,7 +718,7 @@ public class DNodeGenerator
varExp.setContext(context);

// Resolve the entity the name refers to
Entity namedEntity = tc.getResolver().resolveBest(context.getContainer(), nearestName);
Entity namedEntity = tc.getResolver().resolveBest(varExp.parentOf(), nearestName);


/* If the entity was found */
Expand Down

0 comments on commit 1658ea9

Please sign in to comment.