public override CodePiece GenerateCode_SetToStackVal(CodeGenEnvironment env, bool reversed) { if (IsConstant) { throw new ConstantValueChangedException(Position, Identifier); } return(CodePieceStore.WriteArrayFromStack(env, CodeDeclarationPos, reversed)); }
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 GenerateCodeAssignment(CodeGenEnvironment env, SourceCodePosition pos, Expression source, ExpressionValuePointer target, bool reversed) { CodePiece p = new CodePiece(); BTypeArray type = target.GetResultType() as BTypeArray; ExpressionDirectValuePointer vPointer = target as ExpressionDirectValuePointer; if (reversed) { p.AppendLeft(source.GenerateCode(env, reversed)); p.AppendLeft(CodePieceStore.WriteArrayFromStack(env, vPointer.Target.CodeDeclarationPos, reversed)); p.NormalizeX(); } else { p.AppendRight(source.GenerateCode(env, reversed)); p.AppendRight(CodePieceStore.WriteArrayFromStack(env, vPointer.Target.CodeDeclarationPos, reversed)); p.NormalizeX(); } return(p); }
public override CodePiece GenerateCodeWriteFromStackToGrid(CodeGenEnvironment env, SourceCodePosition pos, VarDeclarationPosition gridPos, bool reversed) { return(CodePieceStore.WriteArrayFromStack(env, gridPos, reversed)); }