public override CodePiece GenerateCodeReturnFromMethodCall(CodeGenEnvironment env, SourceCodePosition pos, Expression value, bool reversed) { CodePiece p = new CodePiece(); if (reversed) { #region Reversed p.AppendLeft(value.GenerateCode(env, reversed)); // Switch ReturnValue (Array) and BackJumpAddr p.AppendLeft(CodePieceStore.WriteArrayFromStack(env, env.TMP_ARRFIELD_RETURNVAL, reversed)); p.AppendLeft(CodePieceStore.WriteValueToField(env.TMP_FIELD_JMP_ADDR, reversed)); p.AppendLeft(CodePieceStore.ReadArrayToStack(env, env.TMP_ARRFIELD_RETURNVAL, reversed)); p.AppendLeft(CodePieceStore.ReadValueFromField(env.TMP_FIELD_JMP_ADDR, reversed)); p.AppendLeft(BCHelper.Digit0); // Right Lane p.AppendLeft(BCHelper.PC_Up_tagged(new MethodCallVerticalExitTag())); #endregion } else { #region Normal p.AppendRight(value.GenerateCode(env, reversed)); // Switch ReturnValue (Array) and BackJumpAddr p.AppendRight(CodePieceStore.WriteArrayFromStack(env, env.TMP_ARRFIELD_RETURNVAL, reversed)); p.AppendRight(CodePieceStore.WriteValueToField(env.TMP_FIELD_JMP_ADDR, reversed)); p.AppendRight(CodePieceStore.ReadArrayToStack(env, env.TMP_ARRFIELD_RETURNVAL, reversed)); p.AppendRight(CodePieceStore.ReadValueFromField(env.TMP_FIELD_JMP_ADDR, reversed)); p.AppendRight(BCHelper.Digit0); // Right Lane p.AppendRight(BCHelper.PC_Up_tagged(new MethodCallVerticalExitTag())); #endregion } p.NormalizeX(); return(p); }
public override CodePiece GenerateCodeReadFromGridToStack(CodeGenEnvironment env, SourceCodePosition pos, VarDeclarationPosition gridPos, bool reversed) { return(CodePieceStore.ReadArrayToStack(env, gridPos, reversed)); }