generalStatement() #77

Closed
opened 2023-01-08 10:38:11 +00:00 by deavmi · 5 comments
Owner

Problem we have

Currently when implementing for-loop processing in dependency/core.d we need to effectievly do a generalPass() but on a single entity which isn't possible.

Solution: generalStatementPass()

I suggest, therefore, that we introduce a metho called generalStatementPass(Container, Context, Statement) which can do exactly this. Then we move the body code out of generalPass and into this, and make a call to generalStatementPass() from the for-each loop in generalPass().

## Problem we have Currently when implementing for-loop processing in `dependency/core.d` we need to effectievly do a `generalPass()` but on a single entity which isn't possible. ## Solution: `generalStatementPass()` I suggest, therefore, that we introduce a metho called `generalStatementPass(Container, Context, Statement)` which can do exactly this. Then we move the body code out of `generalPass` and into this, and make a call to `generalStatementPass()` from the for-each loop in `generalPass()`.
deavmi added reference loops 2023-01-08 10:39:48 +00:00
deavmi added this to the Dependency tree, type-checking and codegen project 2023-01-08 10:39:52 +00:00
deavmi self-assigned this 2023-01-08 10:39:55 +00:00
deavmi added this to the Basics milestone 2023-01-08 10:39:58 +00:00
deavmi added the
dependency
label 2023-01-08 10:40:01 +00:00
deavmi added the due date 2023-01-10 2023-01-08 10:40:12 +00:00
Author
Owner

Okay, just did this now and it seems to work

Okay, just did this now and it seems to work
Author
Owner

NO! It isn't what I want!

NO! It isn't what I want!
Author
Owner

Solution found

We pass various of the test cases which is good.

Okay, it is now what I want. What we have done is the following.

## Solution found ✅ We pass various of the test cases which is good. Okay, it is **now** what I want. What we have done is the following.
Author
Owner

Solution found

We pass various of the test cases which is good.

Updates to generalPass()

We now have the following loop:

foreach(Statement entity; entities)
{
    gprintln("generalPass(): Processing entity: "~entity.toString());
    Entity ent = cast(Entity)entity;

    DNode statementDNode = generalStatement(c, context, entity);
    if(statementDNode is null)
    {
    	gprintln("Not adding dependency '"~to!(string)(statementDNode)~"' as it is null");
    }
    else
    {
    	node.needs(statementDNode);
    }
}

The added code is:

DNode statementDNode = generalStatement(c, context, entity);
if(statementDNode is null)
{
	gprintln("Not adding dependency '"~to!(string)(statementDNode)~"' as it is null");
}
else
{
	node.needs(statementDNode);
}

This will check if there is a dependency node returned, and only if so then add it to the COntainer's DNode, node. We do this as sometimes there are either unimplemented checks or simply a DNode is not meant to be returned, see VariableParameter and Functiond efinitions for example. This fits in with what we were doing previously but is now neater.

## Solution found ✅ We pass various of the test cases which is good. ### Updates to `generalPass()` We now have the following loop: ```d foreach(Statement entity; entities) { gprintln("generalPass(): Processing entity: "~entity.toString()); Entity ent = cast(Entity)entity; DNode statementDNode = generalStatement(c, context, entity); if(statementDNode is null) { gprintln("Not adding dependency '"~to!(string)(statementDNode)~"' as it is null"); } else { node.needs(statementDNode); } } ``` The added code is: ```d DNode statementDNode = generalStatement(c, context, entity); if(statementDNode is null) { gprintln("Not adding dependency '"~to!(string)(statementDNode)~"' as it is null"); } else { node.needs(statementDNode); } ``` This will check if there is a dependency node returned, and only if so then add it to the COntainer's DNode, `node`. We do this as sometimes there are either _unimplemented checks_ or simply a DNode is not meant to be returned, see `VariableParameter` and Functiond efinitions for example. This fits in with what we were doing previously but is now neater.
Author
Owner

This was completed as of commit ec7d8cf4240b24a2f6fdbd8071195c9efe08d573 on branch loops

This was completed as of commit `ec7d8cf4240b24a2f6fdbd8071195c9efe08d573` on branch `loops`
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

2023-01-10

Dependencies

No dependencies set.

Reference: tlang/tlang#77
No description provided.