Merge branch 'vardec_varass_dependency' into feature/universal_coercion

This commit is contained in:
Tristan B. Velloza Kildaire 2023-07-17 17:02:17 +02:00
commit 88134e8cab
5 changed files with 55 additions and 13 deletions

View File

@ -104,7 +104,7 @@ public final class DCodeEmitter : CodeEmitter
// return "KAK TODO";
}
gprintln("Type transform unimplemented");
gprintln("Type transform unimplemented for type '"~to!(string)(typeIn)~"'", DebugType.ERROR);
assert(false);
// return stringRepr;
}

View File

@ -252,9 +252,13 @@ public class Struct : Type, Container, MCloneable
* fresh copy of all its members and the struct
* itself.
*
* Param:
* newParent = the `Container` to re-parent the
* cloned `Statement`'s self to
*
* Returns: the cloned `Statement`
*/
public override Statement clone()
public override Statement clone(Container newParent = null)
{
Struct clonedStruct = new Struct(this.name);

View File

@ -520,9 +520,13 @@ public class Variable : TypedEntity, MStatementSearchable, MStatementReplaceable
* including its assigned value (`VariableAssignment`)
* if any.
*
* Param:
* newParent = the `Container` to re-parent the
* cloned `Statement`'s self to
*
* Returns: the cloned `Statement`
*/
public override Statement clone()
public override Statement clone(Container newParent = null)
{
Variable clonedVarDec;
@ -531,7 +535,7 @@ public class Variable : TypedEntity, MStatementSearchable, MStatementReplaceable
if(this.assignment)
{
// Clone the assignment
clonedVarAss = cast(VariableAssignment)this.assignment.clone();
clonedVarAss = cast(VariableAssignment)this.assignment.clone(); // TODO: If needs be we must re-parent manually
}
@ -544,6 +548,8 @@ public class Variable : TypedEntity, MStatementSearchable, MStatementReplaceable
clonedVarDec.assignment = clonedVarAss;
clonedVarDec.container = this.container;
// Parent outselves to the given parent
clonedVarDec.parentTo(newParent);
return clonedVarDec;
}
@ -643,9 +649,13 @@ public class VariableAssignment : Statement, MStatementSearchable, MStatementRep
* Clones this variable assignment by recursively cloning
* the fields within (TODO: finish description)
*
* Param:
* newParent = the `Container` to re-parent the
* cloned `Statement`'s self to
*
* Returns: the cloned `Statement`
*/
public override Statement clone()
public override Statement clone(Container newParent = null)
{
// FIXME: Investigate if `Variable`? Must be cloned
// ... would cuase infinite recursion and it isn't
@ -660,11 +670,14 @@ public class VariableAssignment : Statement, MStatementSearchable, MStatementRep
if(cast(MCloneable)this.expression)
{
MCloneable cloneableExpression = cast(MCloneable)this.expression;
clonedExpression = cast(Expression)cloneableExpression.clone();
clonedExpression = cast(Expression)cloneableExpression.clone(); // NOTE: Manually re-parent if
}
VariableAssignment clonedVarAss = new VariableAssignment(clonedExpression);
// Parent outselves to the given parent
clonedVarAss.parentTo(newParent);
return clonedVarAss;
}
}

View File

@ -158,9 +158,13 @@ public class BinaryOperatorExpression : OperatorExpression, MStatementSearchable
* returning a fresh new copy of itself and its
* left and right operands
*
* Param:
* newParent = the `Container` to re-parent the
* cloned `Statement`'s self to
*
* Returns: the cloned `Statement`
*/
public override Statement clone()
public override Statement clone(Container newParent = null)
{
BinaryOperatorExpression clonedBinaryOp;
@ -169,7 +173,7 @@ public class BinaryOperatorExpression : OperatorExpression, MStatementSearchable
if(cast(MCloneable)this.lhs)
{
MCloneable cloneableExpression = cast(MCloneable)this.lhs;
clonedLeftOperandExpression = cast(Expression)cloneableExpression.clone();
clonedLeftOperandExpression = cast(Expression)cloneableExpression.clone(); // NOTE: We must parent it if needs be
}
// Clone the left-hand operand expression (if supported, TODO: throw an error if not)
@ -177,12 +181,15 @@ public class BinaryOperatorExpression : OperatorExpression, MStatementSearchable
if(cast(MCloneable)this.rhs)
{
MCloneable cloneableExpression = cast(MCloneable)this.rhs;
clonedRightOperandExpression = cast(Expression)cloneableExpression.clone();
clonedRightOperandExpression = cast(Expression)cloneableExpression.clone(); // NOTE: We must parent it if needs be
}
// Clone ourselves
clonedBinaryOp = new BinaryOperatorExpression(this.operator, clonedLeftOperandExpression, clonedRightOperandExpression);
// Parent outselves to the given parent
clonedBinaryOp.parentTo(newParent);
return clonedBinaryOp;
}
}
@ -218,14 +225,21 @@ public class IntegerLiteral : NumberLiteral, MCloneable
/**
* Clones this integer literal
*
* Param:
* newParent = the `Container` to re-parent the
* cloned `Statement`'s self to
*
* Returns: the cloned `Statement`
*/
public override Statement clone()
public override Statement clone(Container newParent = null)
{
IntegerLiteral clonedIntegerLiteral;
clonedIntegerLiteral = new IntegerLiteral(this.numberLiteral, this.encoding);
// Parent outselves to the given parent
clonedIntegerLiteral.parentTo(newParent);
return clonedIntegerLiteral;
}
}
@ -311,9 +325,13 @@ public final class CastedExpression : Expression, MCloneable
* Clones this casted expression recursively
* and returns a fresh copy of it
*
* Param:
* newParent = the `Container` to re-parent the
* cloned `Statement`'s self to
*
* Returns: the cloned `Statement`
*/
public override Statement clone()
public override Statement clone(Container newParent = null)
{
CastedExpression clonedCastedExpression;
@ -322,11 +340,14 @@ public final class CastedExpression : Expression, MCloneable
if(cast(MCloneable)this.uncastedExpression)
{
MCloneable cloneableExpression = cast(MCloneable)this.uncastedExpression;
clonedUncastedExpression = cast(Expression)cloneableExpression.clone();
clonedUncastedExpression = cast(Expression)cloneableExpression.clone(); // NOTE: We must parent it if needs be
}
clonedCastedExpression = new CastedExpression(this.toType, clonedUncastedExpression);
// Parent outselves to the given parent
clonedCastedExpression.parentTo(newParent);
return clonedCastedExpression;
}
}

View File

@ -60,7 +60,11 @@ public interface MCloneable
* Returns a `Statement` which is a clone of this one
* itself
*
* Param:
* newParent = the `Container` to re-parent the
* cloned `Statement`'s self to
*
* Returns: the cloned `Statement`
*/
public Statement clone();
public Statement clone(Container newParent = null);
}