public GenericForStatementGenerator(GeneratorFactory factory, BlockGenerator block, GenericForBlockSyntaxNode stat) { //Create a wrapper block. //Actually this is not necessary with the current design. We could add everything to parent block. //But let's still have a separation. //Note that this block does not contain any upvals and statements and won't be used in emit step. _forBlock = new BlockGenerator(factory, block.Stack, stat); var v1g = factory.Function.Locals[stat.HiddenVariableF]; var v2g = factory.Function.Locals[stat.HiddenVariableS]; var v3g = factory.Function.Locals[stat.HiddenVariableV]; //To calculate the f,s,var tuple. //This will be inserted as the first statement of _forBlock. _assignment = new AssignmentStatementGenerator(factory, _forBlock, new() { v1g, v2g, v3g }, stat.ExpressionList); //Store the stack slot for f and var1. var ctrlVarOnStack = v1g.TryGetFromStack(out _hiddenVariableStack); Debug.Assert(ctrlVarOnStack); var var1OnStack = factory.Function.Locals[stat.LoopVariables[0]].TryGetFromStack(out _firstLoopVarStack); Debug.Assert(var1OnStack); //Get the return sig type. var sigWriter = new SignatureWriter(); foreach (var loopVar in stat.LoopVariables) { factory.Function.Locals[loopVar].WritSig(sigWriter); } (_loopVarSigType, _loopVarSig) = sigWriter.GetSignature(factory.Function.SignatureManager); }
public override void WritSig(SignatureWriter writer) { if (_isVararg) { writer.AppendVararg(_type); } else { writer.AppendFixed(_type); } }
//For all expressions: write its type to writer. Vararg expr should write vararg. //This is called before the emit stage. public virtual void WritSig(SignatureWriter writer) { writer.AppendFixed(GetSingleType()); }