public override ScriptNumber Calc(CALC c) { switch (c) { case CALC.PRE_INCREMENT: this.m_Value++; break; case CALC.POST_INCREMENT: double num; this.m_Value = (num = this.m_Value) + 1.0; return(new ScriptNumberDouble(base.m_Script, num)); case CALC.PRE_DECREMENT: this.m_Value--; break; case CALC.POST_DECREMENT: double num2; this.m_Value = (num2 = this.m_Value) - 1.0; return(new ScriptNumberDouble(base.m_Script, num2)); default: return(this); } return(this); }
public override ScriptNumber Calc(CALC c) { switch (c) { case CALC.PRE_INCREMENT: this.m_Value += 1L; break; case CALC.POST_INCREMENT: long num; this.m_Value = (num = this.m_Value) + 1L; return(new ScriptNumberLong(base.m_Script, num)); case CALC.PRE_DECREMENT: this.m_Value -= 1L; break; case CALC.POST_DECREMENT: long num2; this.m_Value = (num2 = this.m_Value) - 1L; return(new ScriptNumberLong(base.m_Script, num2)); default: return(this); } return(this); }
public void CastChartTest() { CALC target = new CALC(); // TODO: 初始化为适当的值 DateTime dt = new System.DateTime(2014, 3, 25, 14, 12, 13); target.ciCore = new AstroCSharpLib.Model.ChartInfo { mon = dt.Month, day = dt.Day, yea = dt.Year, tim = Math.Round((dt.Hour + dt.Minute / 60.0), 2), dst = 0.0, zon = -8.0, lon = 116.42, lat = 39.93, nam = "", loc = "" }; bool fDate = true; // TODO: 初始化为适当的值 double expected = 0F; // TODO: 初始化为适当的值 double actual; actual = target.CastChart(fDate); using (StreamWriter sw = new StreamWriter("D:\\456")) { //fprintf(file, "@0203 ; %s chart positions.\n", szAppName); //fprintf(file, "%czi \"%s\" \"%s\"\n", chSwitch, ciMain.nam, ciMain.loc); for (int i = 1; i <= 32; i++) { double rT = 0; if (i >= 24 && i <= 29) { rT = target.cp.cusp[i - 20]; } else { rT = target.cp.obj[i]; } int j = (int)rT; sw.Write("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t,", i, j % 30, (j / 30 + 1), Math.Round((RFract(rT) * 60.0), 9), (int)target.cp.alt[i], Math.Round((RFract(Math.Abs(target.cp.alt[i])) * 60.0), 9)); if (false) { rT = Math.Sqrt(target.spacex[i] * target.spacex[i] + target.spacey[i] * target.spacey[i] + target.spacez[i] * target.spacez[i]); } sw.WriteLine("{0}\t{1}", Math.Round(target.DFromR(target.cp.dir[i]), 9), Math.Round(rT, 9)); } } Assert.AreEqual(expected, actual); Assert.Inconclusive("验证此测试方法的正确性。"); }
public override ScriptNumber Calc(CALC c) { switch (c) { case CALC.PRE_INCREMENT: ++m_Value; break; case CALC.PRE_DECREMENT: --m_Value; break; case CALC.POST_INCREMENT: return new ScriptNumberDouble(m_Script, m_Value++); case CALC.POST_DECREMENT: return new ScriptNumberDouble(m_Script, m_Value--); default: return this; } return this; }
public override ScriptNumber Calc(CALC c) { switch (c) { case CALC.PRE_INCREMENT: ++m_Value; break; case CALC.PRE_DECREMENT: --m_Value; break; case CALC.POST_INCREMENT: return(Script.CreateDouble(m_Value++)); case CALC.POST_DECREMENT: return(Script.CreateDouble(m_Value--)); } return(this); }
public override ScriptNumber Calc(CALC c) { switch (c) { case CALC.PRE_INCREMENT: this.m_Value++; break; case CALC.POST_INCREMENT: return(new ScriptNumberInt(base.m_Script, this.m_Value++)); case CALC.PRE_DECREMENT: this.m_Value--; break; case CALC.POST_DECREMENT: return(new ScriptNumberInt(base.m_Script, this.m_Value--)); default: return(this); } return(this); }
public abstract ScriptNumber Calc(CALC c);
private CodeObject GetOneObject() { CodeObject parent = null; Token token = this.ReadToken(); bool flag = false; bool flag2 = false; bool flag3 = false; CALC nONE = CALC.NONE; while (true) { if (token.Type == Scorpio.Compiler.TokenType.Not) { flag = true; } else if (token.Type == Scorpio.Compiler.TokenType.Minus) { flag2 = true; } else { if (token.Type != Scorpio.Compiler.TokenType.Negative) { break; } flag3 = true; } token = this.ReadToken(); } if (token.Type == Scorpio.Compiler.TokenType.Increment) { nONE = CALC.PRE_INCREMENT; token = this.ReadToken(); } else if (token.Type == Scorpio.Compiler.TokenType.Decrement) { nONE = CALC.PRE_DECREMENT; token = this.ReadToken(); } switch (token.Type) { case Scorpio.Compiler.TokenType.LeftBrace: this.UndoToken(); parent = this.GetTable(); break; case Scorpio.Compiler.TokenType.LeftPar: parent = new CodeRegion(this.GetObject()); this.ReadRightParenthesis(); break; case Scorpio.Compiler.TokenType.LeftBracket: this.UndoToken(); parent = this.GetArray(); break; case Scorpio.Compiler.TokenType.Function: this.UndoToken(); parent = new CodeFunction(this.ParseFunctionDeclaration(false)); break; case Scorpio.Compiler.TokenType.Boolean: case Scorpio.Compiler.TokenType.Number: case Scorpio.Compiler.TokenType.String: case Scorpio.Compiler.TokenType.SimpleString: parent = new CodeScriptObject(this.m_script, token.Lexeme); break; case Scorpio.Compiler.TokenType.Null: parent = new CodeScriptObject(this.m_script, null); break; case Scorpio.Compiler.TokenType.Eval: parent = this.GetEval(); break; case Scorpio.Compiler.TokenType.Identifier: parent = new CodeMember((string)token.Lexeme); break; default: throw new ParserException("Object起始关键字错误 ", token); } parent.StackInfo = new StackInfo(this.m_strBreviary, token.SourceLine); parent = this.GetVariable(parent); parent.Not = flag; parent.Minus = flag2; parent.Negative = flag3; if (parent is CodeMember) { if (nONE != CALC.NONE) { ((CodeMember)parent).Calc = nONE; return(parent); } Token token2 = this.ReadToken(); if (token2.Type == Scorpio.Compiler.TokenType.Increment) { nONE = CALC.POST_INCREMENT; } else if (token2.Type == Scorpio.Compiler.TokenType.Decrement) { nONE = CALC.POST_DECREMENT; } else { this.UndoToken(); } if (nONE != CALC.NONE) { ((CodeMember)parent).Calc = nONE; } return(parent); } if (nONE != CALC.NONE) { throw new ParserException("++ 或者 -- 只支持变量的操作", token); } return(parent); }
public virtual ScriptNumber Calc(CALC c) { throw new ExecutionException(base.m_Script, "数字类型不支持Calc函数"); }
//获得单一变量 private CodeObject GetOneObject() { CodeObject ret = null; Token token = ReadToken(); bool not = false; bool minus = false; bool negative = false; CALC calc = CALC.NONE; while (true) { if (token.Type == TokenType.Not) { not = true; } else if (token.Type == TokenType.Minus) { minus = true; } else if (token.Type == TokenType.Negative) { negative = true; } else { break; } token = ReadToken(); } if (token.Type == TokenType.Increment) { calc = CALC.PRE_INCREMENT; token = ReadToken(); } else if (token.Type == TokenType.Decrement) { calc = CALC.PRE_DECREMENT; token = ReadToken(); } switch (token.Type) { case TokenType.Identifier: ret = new CodeMember((string)token.Lexeme); break; case TokenType.Function: UndoToken(); ret = new CodeFunction(ParseFunctionDeclaration(false)); break; case TokenType.LeftPar: ret = new CodeRegion(GetObject()); ReadRightParenthesis(); break; case TokenType.LeftBracket: UndoToken(); ret = GetArray(); break; case TokenType.LeftBrace: UndoToken(); ret = GetTable(); break; case TokenType.Eval: ret = GetEval(); break; case TokenType.Null: ret = new CodeScriptObject(m_script, null); break; case TokenType.Boolean: case TokenType.Number: case TokenType.String: case TokenType.SimpleString: ret = new CodeScriptObject(m_script, token.Lexeme); break; default: throw new ParserException("Object起始关键字错误 ", token); } ret.StackInfo = new StackInfo(m_strBreviary, token.SourceLine); ret = GetVariable(ret); ret.Not = not; ret.Minus = minus; ret.Negative = negative; if (ret is CodeMember) { if (calc != CALC.NONE) { ((CodeMember)ret).Calc = calc; } else { Token peek = ReadToken(); if (peek.Type == TokenType.Increment) { calc = CALC.POST_INCREMENT; } else if (peek.Type == TokenType.Decrement) { calc = CALC.POST_DECREMENT; } else { UndoToken(); } if (calc != CALC.NONE) { ((CodeMember)ret).Calc = calc; } } } else if (calc != CALC.NONE) { throw new ParserException("++ 或者 -- 只支持变量的操作", token); } return(ret); }
public virtual ScriptNumber Calc(CALC c) { //数字计算 throw new ExecutionException(m_Script, "数字类型不支持Calc函数"); }