Update release

This commit is contained in:
Zihan Chen
2019-01-29 16:18:36 -08:00
parent 92861b2030
commit 10c1178920
14 changed files with 1017 additions and 483 deletions
+44 -13
View File
@@ -24159,6 +24159,8 @@ namespace vl
typedef WfInstruction Ins;
#define INSTRUCTION(X) context.AddInstruction(node, X)
#define FILL_LABEL_TO_INS(LABEL, INS) context.assembly->instructions[LABEL].indexParameter = INS
#define FILL_LABEL_TO_CURRENT(LABEL) FILL_LABEL_TO_INS(LABEL, context.assembly->instructions.Count())
/***********************************************************************
GenerateTypeCastInstructions
@@ -24168,6 +24170,17 @@ GenerateTypeCastInstructions
{
if (expectedType->GetTypeDescriptor() != GetTypeDescriptor<Value>())
{
vint fillElseIndex = -1;
vint fillEndIndex = -1;
if (expectedType->GetDecorator() == ITypeInfo::Nullable)
{
INSTRUCTION(Ins::Duplicate(0));
INSTRUCTION(Ins::LoadValue(Value()));
INSTRUCTION(Ins::CompareReference());
fillElseIndex = INSTRUCTION(Ins::JumpIf(-1));
}
if (strongCast)
{
switch (expectedType->GetDecorator())
@@ -24202,6 +24215,14 @@ GenerateTypeCastInstructions
break;
}
}
if (fillElseIndex != -1)
{
fillEndIndex = INSTRUCTION(Ins::Jump(-1));
FILL_LABEL_TO_CURRENT(fillElseIndex);
INSTRUCTION(Ins::LoadValue(Value()));
FILL_LABEL_TO_CURRENT(fillEndIndex);
}
}
}
@@ -24236,7 +24257,7 @@ GetInstructionTypeArgument
}
/***********************************************************************
GenerateTypeCastInstructions
GetInstructionTypeArgument
***********************************************************************/
runtime::WfInsType GetInstructionTypeArgument(Ptr<reflection::description::ITypeInfo> expectedType)
@@ -24373,6 +24394,8 @@ GenerateAssembly
}
#undef CALLBACK
#undef FILL_LABEL_TO_CURRENT
#undef FILL_LABEL_TO_INS
#undef INSTRUCTION
/***********************************************************************
@@ -24987,6 +25010,8 @@ namespace vl
typedef WfInstruction Ins;
#define INSTRUCTION(X) context.AddInstruction(node, X)
#define FILL_LABEL_TO_INS(LABEL, INS) context.assembly->instructions[LABEL].indexParameter = INS
#define FILL_LABEL_TO_CURRENT(LABEL) FILL_LABEL_TO_INS(LABEL, context.assembly->instructions.Count())
/***********************************************************************
GenerateInstructions(Expression)
@@ -25461,10 +25486,10 @@ GenerateInstructions(Expression)
INSTRUCTION(Ins::UninstallTry(1));
vint finishInstruction = INSTRUCTION(Ins::Jump(-1));
context.assembly->instructions[trapInstruction].indexParameter = context.assembly->instructions.Count();
FILL_LABEL_TO_CURRENT(trapInstruction);
GenerateExpressionInstructions(context, node->second, result.type);
context.assembly->instructions[finishInstruction].indexParameter = context.assembly->instructions.Count();
FILL_LABEL_TO_CURRENT(finishInstruction);
}
else
{
@@ -25617,9 +25642,9 @@ GenerateInstructions(Expression)
vint fillTrueIndex = INSTRUCTION(Ins::JumpIf(-1));
GenerateExpressionInstructions(context, node->falseBranch, result.type);
vint fillEndIndex = INSTRUCTION(Ins::Jump(-1));
context.assembly->instructions[fillTrueIndex].indexParameter = context.assembly->instructions.Count();
FILL_LABEL_TO_CURRENT(fillTrueIndex);
GenerateExpressionInstructions(context, node->trueBranch, result.type);
context.assembly->instructions[fillEndIndex].indexParameter = context.assembly->instructions.Count();
FILL_LABEL_TO_CURRENT(fillEndIndex);
}
void Visit(WfRangeExpression* node)override
@@ -26123,6 +26148,8 @@ GenerateInstructions(Expression)
}
};
#undef FILL_LABEL_TO_CURRENT
#undef FILL_LABEL_TO_INS
#undef INSTRUCTION
Ptr<reflection::description::ITypeInfo> GenerateExpressionInstructions(WfCodegenContext& context, Ptr<WfExpression> expression, Ptr<reflection::description::ITypeInfo> expectedType)
@@ -26433,6 +26460,8 @@ namespace vl
typedef WfInstruction Ins;
#define INSTRUCTION(X) context.AddInstruction(node, X)
#define FILL_LABEL_TO_INS(LABEL, INS) context.assembly->instructions[LABEL].indexParameter = INS
#define FILL_LABEL_TO_CURRENT(LABEL) FILL_LABEL_TO_INS(LABEL, context.assembly->instructions.Count())
#define EXIT_CODE(X) context.AddExitInstruction(node, X)
/***********************************************************************
@@ -26577,13 +26606,13 @@ GenerateInstructions(Statement)
INSTRUCTION(Ins::StoreLocalVar(variableIndex));
}
vint fillEndIndex = INSTRUCTION(Ins::Jump(-1));
context.assembly->instructions[fillElseIndex].indexParameter = context.assembly->instructions.Count();
FILL_LABEL_TO_CURRENT(fillElseIndex);
if (node->falseBranch)
{
GenerateStatementInstructions(context, node->falseBranch);
}
context.assembly->instructions[fillEndIndex].indexParameter = context.assembly->instructions.Count();
FILL_LABEL_TO_CURRENT(fillEndIndex);
}
void Visit(WfWhileStatement* node)override
@@ -26604,11 +26633,11 @@ GenerateInstructions(Statement)
FOREACH(vint, index, loopContext->continueInstructions)
{
context.assembly->instructions[index].indexParameter = continueLabelIndex;
FILL_LABEL_TO_INS(index, continueLabelIndex);
}
FOREACH(vint, index, loopContext->breakInstructions)
{
context.assembly->instructions[index].indexParameter = breakLabelIndex;
FILL_LABEL_TO_INS(index, breakLabelIndex);
}
context.functionContext->PopScopeContext();
}
@@ -26655,7 +26684,7 @@ GenerateInstructions(Statement)
void GenerateTrap(WfTryStatement* node, vint variableIndex, Pair<vint, vint> trap)
{
context.assembly->instructions[trap.key].indexParameter = context.assembly->instructions.Count();
FILL_LABEL_TO_CURRENT(trap.key);
INSTRUCTION(Ins::LoadException());
INSTRUCTION(Ins::StoreLocalVar(variableIndex));
}
@@ -26697,10 +26726,10 @@ GenerateInstructions(Statement)
}
// finally
context.assembly->instructions[trap1.value].indexParameter = context.assembly->instructions.Count();
FILL_LABEL_TO_CURRENT(trap1.value);
if (trap2.value != -1)
{
context.assembly->instructions[trap2.value].indexParameter = context.assembly->instructions.Count();
FILL_LABEL_TO_CURRENT(trap2.value);
}
if (node->finallyStatement)
{
@@ -26726,7 +26755,7 @@ GenerateInstructions(Statement)
vint breakLabelIndex = context.assembly->instructions.Count();
FOREACH(vint, index, blockContext->breakInstructions)
{
context.assembly->instructions[index].indexParameter = breakLabelIndex;
FILL_LABEL_TO_INS(index, breakLabelIndex);
}
context.functionContext->PopScopeContext();
}
@@ -26774,6 +26803,8 @@ GenerateInstructions(Statement)
};
#undef EXIT_CODE
#undef FILL_LABEL_TO_CURRENT
#undef FILL_LABEL_TO_INS
#undef INSTRUCTION
void GenerateStatementInstructions(WfCodegenContext& context, Ptr<WfStatement> statement)