private void btnIgual_Click(object sender, EventArgs e) { segundo = double.Parse(txtIntroducir.Text); double SUM; double RES; double MUL; double DIV; switch (operador) { case "+": SUM = obj.Sumar((primero), (segundo)); txtIntroducir.Text = SUM.ToString(); break; case "-": RES = obj2.Restar((primero), (segundo)); txtIntroducir.Text = RES.ToString(); break; case "*": MUL = obj3.Multiplicar((primero), (segundo)); txtIntroducir.Text = MUL.ToString(); break; case "/": DIV = obj4.Dividir((primero), (segundo)); txtIntroducir.Text = DIV.ToString(); break; } }
public override Tag GetPageHtml(SpinneretPage page) { bool globmsg = Program.CurFile.GlobalErrorMessage != null && !(page as WebPage).IgnoreGlobalMessage; if (!globmsg) { return(base.GetPageHtml(page)); } else { Tag content = new DIV( new P(Program.Tr.GlobalMessage.Explanation.Fmt("AccountsWeb")), Program.CurFile.GlobalErrorMessage ); try { (page as WebPage).FullScreen = false; return(MakePage(page, Program.Tr.GlobalMessage.Title, content)); } catch (Exception e) { return(new DIV(content, new P(Program.Tr.GlobalMessage.AlsoException), e.SelectChain(ex => ex.InnerException) .Select(ex => new DIV { class_ = "exception" }._( new H3(ex.GetType().FullName), new P(ex.Message), new PRE(ex.StackTrace) )).InsertBetween(new HR()))); } } }
public override object GetContent() { DIV div = new DIV(); foreach (var ccy in Program.CurFile.Book.EnumCommodities().OrderBy(cmdty => cmdty.Identifier)) { div.Add(new H2(ccy.Identifier)); if (ccy.Identifier == Program.CurFile.Book.BaseCurrencyId) { div.Add(new P(Tr.PgExRates.BaseCurrencyMessage) { class_ = "aw-info-msg" }); } else { ReportTable tbl = new ReportTable(); tbl.AddCol(Tr.PgExRates.ColDate); tbl.AddCol(Tr.PgExRates.ColRate); tbl.AddCol(Tr.PgExRates.ColRateInverse); foreach (var pt in ccy.ExRate) { tbl.AddRow(null, pt.Key.ToShortDateString(), pt.Value.ToString("0.0000"), (1m / pt.Value).ToString("0.0000")); } div.Add(tbl.GetHtml()); } } return(div); }
public static void AssociateOpcodes() { instructions[0] = new NOP(); instructions[1] = new PRNT(); instructions[16] = new PUSH(); instructions[17] = new POP(); instructions[18] = new SAVE(); instructions[19] = new CPY(); instructions[20] = new RNDM(); instructions[21] = new EMPTY(); instructions[128] = new ADD(); instructions[129] = new SUB(); instructions[130] = new MUL(); instructions[131] = new DIV(); instructions[132] = new SUB2(); instructions[133] = new DIV2(); instructions[134] = new NEG(); instructions[135] = new ABS(); instructions[144] = new INC(); instructions[145] = new DEC(); instructions[64] = new JMP(); instructions[65] = new JGZ(); instructions[66] = new JLZ(); instructions[67] = new JEZ(); instructions[68] = new JNZ(); instructions[69] = new CALL(); instructions[70] = new RET(); instructions[71] = new LDLOC(); instructions[72] = new STLOC(); instructions[73] = new LDARG(); instructions[74] = new STARG(); instructions[0b10100100] = new CMP();
protected override void Visit_DIV(DIV node) { /* MOVE CODE HERE */ }
public override object GetContent() { GroupMonths = Request.GetValidated <int>("Group", 1, x => x >= 1, Tr.PgMonthly.Validation_1OrGreater); int pastYears = Request.GetValidated <int>("Years", 1, x => x >= 1, Tr.PgMonthly.Validation_1OrGreater); int pastGroups = (12 * pastYears) / GroupMonths + 1; // Default to the last N months such that we see M whole groups, where M = number of groups per year + 1 { var earliest = Program.CurFile.Book.EarliestDate; var toDefault = GroupMonths == 1 // exclude current month iff it's incomplete for all groupings other than single month ? DateTime.Today.EndOfMonth().AssumeUtc() : DateTime.Today == DateTime.Today.EndOfMonth() ? DateTime.Today : DateTime.Today.AddMonths(-1).EndOfMonth().AssumeUtc(); var frDefault = toDefault.AddMonths(1 - pastGroups * GroupMonths).StartOfMonth().AssumeUtc(); if (frDefault < earliest) { frDefault = earliest; } var fy = Request.GetValidated <int>("FrYr", frDefault.Year); var fm = Request.GetValidated <int>("FrMo", frDefault.Month, x => x >= 1 && x <= 12, Tr.PgMonthly.Validation_Between1and12); var ty = Request.GetValidated <int>("ToYr", toDefault.Year, x => x >= fy, Tr.PgMonthly.Validation_NotSmallerYear.Fmt(fy)); var tm = Request.GetValidated <int>("ToMo", toDefault.Month, x => x >= 1 && x <= 12 && (fy < ty || x >= fm), Tr.PgMonthly.Validation_Between1and12_NotSmallerMonth.Fmt(fm)); Interval = new DateInterval(fy, fm, 1, ty, tm, DateTime.DaysInMonth(ty, tm)); } MaxDepth = Request.GetValidated <int>("MaxDepth", -1, x => x >= 0, Tr.PgMonthly.Validation_NonNegative); Negate = Request.GetValidated <bool>("Neg", false); Account = GetAccount("Acct"); { var ccys = Program.CurFile.Book.EnumCommodities(); var ccy = Request.GetValidated <string>("Ccy", null, x => x == null || ccys.Any(c => c.Identifier == x), Tr.PgMonthly.Validation_OneOfCommodities.Fmt(ccys.Select(c => c.Identifier).Order().JoinString(", "))); ConvertTo = ccy == null ? null : ccys.Single(c => c.Identifier == ccy); } Report = new ReportAccounts(Account, Request, true, false); foreach (var interval in EnumIntervals()) { double months = interval.TotalMonths; string capt = (months <= 1) ? interval.Start.ToString("MMM\nyy") : (interval.Start.ToString("MMMyy\n") + Tr.PgMonthly.MonthGroupJoiner + interval.End.ToString("\nMMMyy")); if (months != GroupMonths) { capt += "\n({0:0.#} {1})".Fmt(months, Tr.PgMonthly.MoSuffix); } Report.AddCol(interval, capt); } doAccount(Account, 0); // MaxDepth UI var maxdepthUi = new List <object>(); { maxdepthUi.Add(Tr.PgMonthly.SubAcctsDepth); for (int i = 0; i <= 5; i++) { var label = i == 0 ? Tr.PgMonthly.SubAcctsNone.Translation : i.ToString(); if (MaxDepth == i) { maxdepthUi.Add(new SPAN(label) { class_ = "aw-current" }); } else { maxdepthUi.Add(new A(label) { href = Request.Url.WithQuery("MaxDepth", i.ToString()).ToHref() }); } maxdepthUi.Add(" · "); } if (MaxDepth == -1) { maxdepthUi.Add(new SPAN(Tr.PgMonthly.SubAcctsAll) { class_ = "aw-current" }); } else { maxdepthUi.Add(new A(Tr.PgMonthly.SubAcctsAll) { href = Request.Url.WithoutQuery("MaxDepth").ToHref() }); } } // Group months UI var groupMonthsUi = new List <object>(); { groupMonthsUi.Add(Tr.PgMonthly.GroupMonthsCount); foreach (var len in new[] { 1, 2, 3, 4, 6, 12 }) { if (len != 1) { groupMonthsUi.Add(" · "); } if (GroupMonths == len) { groupMonthsUi.Add(new SPAN(len) { class_ = "aw-current" }); } else if (len == 1) { groupMonthsUi.Add(new A(len) { href = Request.Url.WithoutQuery("Group").ToHref() }); } else { groupMonthsUi.Add(new A(len) { href = Request.Url.WithQuery("Group", len.ToString()).ToHref() }); } } } // Years to show UI var yearsUi = new List <object>(); { yearsUi.Add(Tr.PgMonthly.PastYears); foreach (var yrs in Enumerable.Range(1, (int)Math.Ceiling((DateTime.Now - Program.CurFile.Book.EarliestDate).TotalDays / 365))) { if (yrs != 1) { yearsUi.Add(" · "); } if (pastYears == yrs) { yearsUi.Add(new SPAN(Tr.PgMonthly.YearsMonths.Fmt(Tr.Ns, yrs, GroupMonths)) { class_ = "aw-current" }); } else if (yrs == 1) { yearsUi.Add(new A(yrs) { href = Request.Url.WithoutQuery("Years").ToHref() }); } else { yearsUi.Add(new A(yrs) { href = Request.Url.WithQuery("Years", yrs.ToString()).ToHref() }); } } } // ConvertTo currency UI var convertToUI = new List <object>(); { var ccys = Program.CurFile.Book.EnumCommodities().OrderBy(c => c.Identifier); convertToUI.Add(Program.Tr.PgMonthly.ConvertTo); foreach (var ccy in ((GncCommodity)null).Concat(ccys)) { if (ccy != null) { convertToUI.Add(" · "); } if (ConvertTo == ccy) { convertToUI.Add(new SPAN(ccy?.Identifier ?? Program.Tr.PgMonthly.ConvertToNone) { class_ = "aw-current" }); } else if (ccy == null) { convertToUI.Add(new A(Program.Tr.PgMonthly.ConvertToNone) { href = Request.Url.WithoutQuery("Ccy").ToHref() }); } else { convertToUI.Add(new A(ccy) { href = Request.Url.WithQuery("Ccy", ccy.Identifier).ToHref() }); } } } // Mode var modeUi = new List <object>(); { if (this is PageMonthlyTotals) { modeUi.Add(new SPAN(Tr.PgMonthly.ViewModeTotals) { class_ = "aw-current" }); } else { modeUi.Add(new A(Tr.PgMonthly.ViewModeTotals) { href = "/MonthlyTotals" + Request.Url.QueryString }); } modeUi.Add(" · "); if (this is PageMonthlyBalances) { modeUi.Add(new SPAN(Tr.PgMonthly.ViewModeBalances) { class_ = "aw-current" }); } else { modeUi.Add(new A(Tr.PgMonthly.ViewModeBalances) { href = "/MonthlyBalances" + Request.Url.QueryString }); } } var html = new DIV( new P(Tr.PgMonthly.CurAccount, GetAccountBreadcrumbs("Acct", Account)), new P(maxdepthUi), new P(groupMonthsUi, new RawTag(" "), yearsUi), new P(modeUi, new RawTag(" "), convertToUI), Report.GetHtml() ); return(html); }
protected virtual void Visit_DIV(DIV node) { }
/// <summary> /// Create a single component from XML data /// </summary> /// <param name="node">XML node containing component data</param> /// <returns>Created Component</returns> private static ComponentBase CreateComponent(XmlNode node) { ComponentBase component; switch (node.LocalName) { #region Basic case "Coil": Coil coil = new Coil(); coil.Mode = node.Attributes["Mode"].Value.ToEnum <Coil.CoilMode>(); coil.Type = node.Attributes["Type"].Value.ToEnum <Coil.CoilType>(); component = coil; break; case "Contact": Contact contact = new Contact(); contact.IsClosed = node.Attributes["IsClosed"].Value.ToBool(); contact.IsInverted = node.Attributes["IsInverted"].Value.ToBool(); contact.Type = node.Attributes["Type"].Value.ToEnum <Contact.ContactType>(); component = contact; break; case "SC": component = new SC(); break; case "OSF": component = new OSF(); break; case "OSR": component = new OSR(); break; #endregion Basic #region Compare Components case "EQU": component = new EQU(); break; case "GEQ": component = new GEQ(); break; case "GRT": component = new GRT(); break; case "LEG": component = new LEG(); break; case "LES": component = new LES(); break; case "NEQ": component = new NEQ(); break; #endregion Compare Components #region Counter Components case "CTC": component = new CTC(); break; case "CTD": component = new CTD(); break; case "CTU": component = new CTU(); break; case "RES": component = new RES(); break; #endregion Counter Components #region Math Components case "ADD": component = new ADD(); break; case "DIV": component = new DIV(); break; case "MUL": component = new MUL(); break; case "SUB": component = new SUB(); break; case "MOV": component = new MOV(); break; #endregion Math Components #region Analog Components case "ADC": ADC adc = new ADC(); adc.Destination = node.Attributes["Destination"].Value; component = adc; break; case "PWM": PWM pwm = new PWM(); pwm.DudyCycle = node.Attributes["DudyCycle"].Value; component = pwm; break; #endregion Analog Components #region Function Components case "ELF": ELF elf = new ELF(); elf.Name = node.Attributes["Name"].Value; elf.Code = node.InnerText; component = elf; break; #endregion Function Components default: throw new ArgumentException("Unknow Component", "node"); } component.Comment = node.Attributes["Comment"].Value; #region Extra Processing based on Components Base Class if (component is NameableComponent) { (component as NameableComponent).Name = node.Attributes["Name"].Value; } if (component is CompareComponent) { (component as CompareComponent).VarA = node.Attributes["VarA"].Value; (component as CompareComponent).VarB = node.Attributes["VarB"].Value; } else if (component is CounterComponent) { (component as CounterComponent).Limit = node.Attributes["Limit"].Value; } else if (component is MathComponent) { (component as MathComponent).Destination = node.Attributes["Destination"].Value; (component as MathComponent).VarA = node.Attributes["VarA"].Value; (component as MathComponent).VarB = node.Attributes["VarB"].Value; } #endregion Extra Processing based on Components Base Class return(component); }
private void initOperators() { setName(NEG, "-"); operators[NEG.operatorIndex()] = new[] { unary(NEG, TypeTag.INT, TypeTag.INT), unary(NEG, TypeTag.LONG, TypeTag.LONG), unary(NEG, TypeTag.FLOAT, TypeTag.DOUBLE), unary(NEG, TypeTag.DOUBLE, TypeTag.DOUBLE), }; setName(NOT, "!"); operators[NOT.operatorIndex()] = new[] { unary(NOT, TypeTag.BOOLEAN, TypeTag.BOOLEAN) }; setName(COMPL, "~"); operators[COMPL.operatorIndex()] = new[] { unary(COMPL, TypeTag.INT, TypeTag.INT), unary(COMPL, TypeTag.LONG, TypeTag.LONG) }; setName(PRE_INC, "++"); operators[PRE_INC.operatorIndex()] = new[] { unary(PRE_INC, TypeTag.INT, TypeTag.INT, LLVMAdd), unary(PRE_INC, TypeTag.LONG, TypeTag.LONG, LLVMAdd), unary(PRE_INC, TypeTag.FLOAT, TypeTag.FLOAT, LLVMFAdd), unary(PRE_INC, TypeTag.DOUBLE, TypeTag.DOUBLE, LLVMFAdd) }; setName(PRE_DEC, "--"); operators[PRE_DEC.operatorIndex()] = new[] { unary(PRE_DEC, TypeTag.INT, TypeTag.INT, LLVMSub), unary(PRE_DEC, TypeTag.LONG, TypeTag.LONG, LLVMSub), unary(PRE_DEC, TypeTag.FLOAT, TypeTag.FLOAT, LLVMFSub), unary(PRE_DEC, TypeTag.DOUBLE, TypeTag.DOUBLE, LLVMFSub) }; setName(POST_INC, "++"); operators[POST_INC.operatorIndex()] = new[] { unary(POST_INC, TypeTag.INT, TypeTag.INT, LLVMAdd), unary(POST_INC, TypeTag.LONG, TypeTag.LONG, LLVMAdd), unary(POST_INC, TypeTag.FLOAT, TypeTag.FLOAT, LLVMFAdd), unary(POST_INC, TypeTag.DOUBLE, TypeTag.DOUBLE, LLVMFAdd) }; setName(POST_DEC, "--"); operators[POST_DEC.operatorIndex()] = new[] { unary(POST_DEC, TypeTag.INT, TypeTag.INT, LLVMSub), unary(POST_DEC, TypeTag.LONG, TypeTag.LONG, LLVMSub), unary(POST_DEC, TypeTag.FLOAT, TypeTag.FLOAT, LLVMFSub), unary(POST_DEC, TypeTag.DOUBLE, TypeTag.DOUBLE, LLVMFSub) }; setName(OR, "||"); operators[OR.operatorIndex()] = new[] { binary(OR, TypeTag.BOOLEAN, TypeTag.BOOLEAN, TypeTag.BOOLEAN, LLVMOr), }; setName(AND, "&&"); operators[AND.operatorIndex()] = new[] { binary(AND, TypeTag.BOOLEAN, TypeTag.BOOLEAN, TypeTag.BOOLEAN, LLVMAnd), }; // Order of combination listing for binary operators matters for correct resolution // More assignable types must be listed after less assignable ones, // which is the order listed in the TypeTag enum. setName(BITOR, "|"); operators[BITOR.operatorIndex()] = new[] { binary(BITOR, TypeTag.BOOLEAN, TypeTag.BOOLEAN, TypeTag.BOOLEAN, LLVMOr), binary(BITOR, TypeTag.INT, TypeTag.INT, TypeTag.INT, LLVMOr), binary(BITOR, TypeTag.LONG, TypeTag.LONG, TypeTag.LONG, LLVMOr), }; setName(BITXOR, "^"); operators[BITXOR.operatorIndex()] = new[] { binary(BITXOR, TypeTag.BOOLEAN, TypeTag.BOOLEAN, TypeTag.BOOLEAN, LLVMXor), binary(BITXOR, TypeTag.INT, TypeTag.INT, TypeTag.INT, LLVMXor), binary(BITXOR, TypeTag.LONG, TypeTag.LONG, TypeTag.LONG, LLVMXor), }; setName(BITAND, "&"); operators[BITAND.operatorIndex()] = new[] { binary(BITAND, TypeTag.BOOLEAN, TypeTag.BOOLEAN, TypeTag.BOOLEAN, LLVMAnd), binary(BITAND, TypeTag.INT, TypeTag.INT, TypeTag.INT, LLVMAnd), binary(BITAND, TypeTag.LONG, TypeTag.LONG, TypeTag.LONG, LLVMAnd), }; setName(EQ, "=="); operators[EQ.operatorIndex()] = new[] { binary(EQ, TypeTag.BOOLEAN, TypeTag.BOOLEAN, TypeTag.BOOLEAN, LLVMICmp, LLVMIntEQ), binary(EQ, TypeTag.CHAR, TypeTag.CHAR, TypeTag.BOOLEAN, LLVMICmp, LLVMIntEQ), binary(EQ, TypeTag.INT, TypeTag.INT, TypeTag.BOOLEAN, LLVMICmp, LLVMIntEQ), binary(EQ, TypeTag.LONG, TypeTag.LONG, TypeTag.BOOLEAN, LLVMICmp, LLVMIntEQ), binary(EQ, TypeTag.FLOAT, TypeTag.FLOAT, TypeTag.BOOLEAN, LLVMFCmp, LLVMRealOEQ), binary(EQ, TypeTag.DOUBLE, TypeTag.DOUBLE, TypeTag.BOOLEAN, LLVMFCmp, LLVMRealOEQ), }; setName(NEQ, "!="); operators[NEQ.operatorIndex()] = new[] { binary(NEQ, TypeTag.BOOLEAN, TypeTag.BOOLEAN, TypeTag.BOOLEAN, LLVMICmp, LLVMIntNE), binary(NEQ, TypeTag.CHAR, TypeTag.CHAR, TypeTag.BOOLEAN, LLVMICmp, LLVMIntNE), binary(NEQ, TypeTag.INT, TypeTag.INT, TypeTag.BOOLEAN, LLVMICmp, LLVMIntNE), binary(NEQ, TypeTag.LONG, TypeTag.LONG, TypeTag.BOOLEAN, LLVMICmp, LLVMIntNE), binary(NEQ, TypeTag.FLOAT, TypeTag.FLOAT, TypeTag.BOOLEAN, LLVMFCmp, LLVMRealONE), binary(NEQ, TypeTag.DOUBLE, TypeTag.DOUBLE, TypeTag.BOOLEAN, LLVMFCmp, LLVMRealONE), }; setName(LT, "<"); operators[LT.operatorIndex()] = new[] { binary(LT, TypeTag.CHAR, TypeTag.CHAR, TypeTag.BOOLEAN, LLVMICmp, LLVMIntULT), binary(LT, TypeTag.INT, TypeTag.INT, TypeTag.BOOLEAN, LLVMICmp, LLVMIntSLT), binary(LT, TypeTag.LONG, TypeTag.LONG, TypeTag.BOOLEAN, LLVMICmp, LLVMIntSLT), binary(LT, TypeTag.FLOAT, TypeTag.FLOAT, TypeTag.BOOLEAN, LLVMFCmp, LLVMRealOLT), binary(LT, TypeTag.DOUBLE, TypeTag.DOUBLE, TypeTag.BOOLEAN, LLVMFCmp, LLVMRealOLT), }; setName(GT, ">"); operators[GT.operatorIndex()] = new[] { binary(GT, TypeTag.CHAR, TypeTag.CHAR, TypeTag.BOOLEAN, LLVMICmp, LLVMIntUGT), binary(GT, TypeTag.INT, TypeTag.INT, TypeTag.BOOLEAN, LLVMICmp, LLVMIntSGT), binary(GT, TypeTag.LONG, TypeTag.LONG, TypeTag.BOOLEAN, LLVMICmp, LLVMIntSGT), binary(GT, TypeTag.FLOAT, TypeTag.FLOAT, TypeTag.BOOLEAN, LLVMFCmp, LLVMRealOGT), binary(GT, TypeTag.DOUBLE, TypeTag.DOUBLE, TypeTag.BOOLEAN, LLVMFCmp, LLVMRealOGT), }; setName(LE, "<="); operators[LE.operatorIndex()] = new[] { binary(LE, TypeTag.CHAR, TypeTag.CHAR, TypeTag.BOOLEAN, LLVMICmp, LLVMIntULE), binary(LE, TypeTag.INT, TypeTag.INT, TypeTag.BOOLEAN, LLVMICmp, LLVMIntSLE), binary(LE, TypeTag.LONG, TypeTag.LONG, TypeTag.BOOLEAN, LLVMICmp, LLVMIntSLE), binary(LE, TypeTag.FLOAT, TypeTag.FLOAT, TypeTag.BOOLEAN, LLVMFCmp, LLVMRealOLE), binary(LE, TypeTag.DOUBLE, TypeTag.DOUBLE, TypeTag.BOOLEAN, LLVMFCmp, LLVMRealOLE), }; setName(GE, ">="); operators[GE.operatorIndex()] = new[] { binary(GE, TypeTag.CHAR, TypeTag.CHAR, TypeTag.BOOLEAN, LLVMICmp, LLVMIntUGE), binary(GE, TypeTag.INT, TypeTag.INT, TypeTag.BOOLEAN, LLVMICmp, LLVMIntSGE), binary(GE, TypeTag.LONG, TypeTag.LONG, TypeTag.BOOLEAN, LLVMICmp, LLVMIntSGE), binary(GE, TypeTag.FLOAT, TypeTag.FLOAT, TypeTag.BOOLEAN, LLVMFCmp, LLVMRealOGE), binary(GE, TypeTag.DOUBLE, TypeTag.DOUBLE, TypeTag.BOOLEAN, LLVMFCmp, LLVMRealOGE), }; setName(SHL, "<<"); operators[SHL.operatorIndex()] = new[] { binary(SHL, TypeTag.INT, TypeTag.INT, TypeTag.INT, LLVMShl), binary(SHL, TypeTag.INT, TypeTag.LONG, TypeTag.INT, LLVMShl), binary(SHL, TypeTag.LONG, TypeTag.INT, TypeTag.LONG, LLVMShl), binary(SHL, TypeTag.LONG, TypeTag.LONG, TypeTag.LONG, LLVMShl), }; setName(SHR, ">>"); operators[SHR.operatorIndex()] = new[] { binary(SHR, TypeTag.INT, TypeTag.INT, TypeTag.INT, LLVMLShr), binary(SHR, TypeTag.INT, TypeTag.LONG, TypeTag.INT, LLVMLShr), binary(SHR, TypeTag.LONG, TypeTag.INT, TypeTag.LONG, LLVMLShr), binary(SHR, TypeTag.LONG, TypeTag.LONG, TypeTag.LONG, LLVMLShr), }; setName(PLUS, "+"); operators[PLUS.operatorIndex()] = new[] { binary(PLUS, TypeTag.INT, TypeTag.INT, TypeTag.INT, LLVMAdd), binary(PLUS, TypeTag.LONG, TypeTag.LONG, TypeTag.LONG, LLVMAdd), binary(PLUS, TypeTag.FLOAT, TypeTag.FLOAT, TypeTag.FLOAT, LLVMFAdd), binary(PLUS, TypeTag.DOUBLE, TypeTag.DOUBLE, TypeTag.DOUBLE, LLVMFAdd), }; setName(MINUS, "-"); operators[MINUS.operatorIndex()] = new[] { binary(MINUS, TypeTag.INT, TypeTag.INT, TypeTag.INT, LLVMSub), binary(MINUS, TypeTag.LONG, TypeTag.LONG, TypeTag.LONG, LLVMSub), binary(MINUS, TypeTag.FLOAT, TypeTag.FLOAT, TypeTag.FLOAT, LLVMFSub), binary(MINUS, TypeTag.DOUBLE, TypeTag.DOUBLE, TypeTag.DOUBLE, LLVMFSub), }; setName(MUL, "*"); operators[MUL.operatorIndex()] = new[] { binary(MUL, TypeTag.INT, TypeTag.INT, TypeTag.INT, LLVMMul), binary(MUL, TypeTag.LONG, TypeTag.LONG, TypeTag.LONG, LLVMMul), binary(MUL, TypeTag.FLOAT, TypeTag.FLOAT, TypeTag.FLOAT, LLVMFMul), binary(MUL, TypeTag.DOUBLE, TypeTag.DOUBLE, TypeTag.DOUBLE, LLVMFMul), }; setName(DIV, "/"); operators[DIV.operatorIndex()] = new[] { binary(DIV, TypeTag.INT, TypeTag.INT, TypeTag.INT, LLVMSDiv), binary(DIV, TypeTag.LONG, TypeTag.LONG, TypeTag.LONG, LLVMSDiv), binary(DIV, TypeTag.FLOAT, TypeTag.FLOAT, TypeTag.FLOAT, LLVMFDiv), binary(DIV, TypeTag.DOUBLE, TypeTag.DOUBLE, TypeTag.DOUBLE, LLVMFDiv), }; setName(MOD, "%"); operators[MOD.operatorIndex()] = new[] { binary(MOD, TypeTag.INT, TypeTag.INT, TypeTag.INT, LLVMSRem), binary(MOD, TypeTag.LONG, TypeTag.LONG, TypeTag.LONG, LLVMSRem), binary(MOD, TypeTag.FLOAT, TypeTag.FLOAT, TypeTag.FLOAT, LLVMFRem), binary(MOD, TypeTag.DOUBLE, TypeTag.DOUBLE, TypeTag.DOUBLE, LLVMFRem), }; }
public void Math() { #region Startup var TestTable = new LadderDataTable(); Node PowerRail = new Node(); ADD add = new ADD(); add.LeftLide = PowerRail; add.Destination = "Dest"; add.VarA = "VarA"; add.VarB = "VarB"; add.DataTable = TestTable; DIV div = new DIV(); div.LeftLide = PowerRail; div.Destination = "Dest"; div.VarA = "VarA"; div.VarB = "VarB"; div.DataTable = TestTable; MOV mov = new MOV(); mov.LeftLide = PowerRail; mov.Destination = "Dest"; mov.VarA = "VarA"; mov.DataTable = TestTable; MUL mul = new MUL(); mul.LeftLide = PowerRail; mul.Destination = "Dest"; mul.VarA = "VarA"; mul.VarB = "VarB"; mul.DataTable = TestTable; SUB sub = new SUB(); sub.LeftLide = PowerRail; sub.Destination = "Dest"; sub.VarA = "VarA"; sub.VarB = "VarB"; sub.DataTable = TestTable; #endregion Startup #region ADD Trace.WriteLine("ADD", "Unit Test"); Trace.Indent(); Trace.WriteLine("StartUP", "ADD"); Trace.Indent(); TestTable.SetValue("Dest", (short)0); add.ValueA = 1; add.ValueB = 2; Trace.Unindent(); Trace.WriteLine("Input False", "ADD"); Trace.Indent(); PowerRail.LogicLevel = false; add.Execute(); Assert.IsFalse(add.InternalState); Assert.AreEqual(TestTable.GetValue("Dest"), (short)0); Trace.Unindent(); Trace.WriteLine("Input True", "ADD"); Trace.Indent(); PowerRail.LogicLevel = true; add.Execute(); Assert.IsTrue(add.InternalState); Assert.AreEqual(TestTable.GetValue("Dest"), (short)3); Trace.Unindent(); Trace.Unindent(); #endregion ADD #region DIV Trace.WriteLine("DIV", "Unit Test"); Trace.Indent(); Trace.WriteLine("StartUP", "DIV"); Trace.Indent(); TestTable.SetValue("Dest", (short)0); div.ValueA = 10; div.ValueB = 2; Trace.Unindent(); Trace.WriteLine("Input False", "DIV"); Trace.Indent(); PowerRail.LogicLevel = false; div.Execute(); Assert.IsFalse(div.InternalState); Assert.AreEqual(TestTable.GetValue("Dest"), (short)0); Trace.Unindent(); Trace.WriteLine("Input True", "DIV"); Trace.Indent(); PowerRail.LogicLevel = true; div.Execute(); Assert.IsTrue(div.InternalState); Assert.AreEqual(TestTable.GetValue("Dest"), (short)5); Trace.Unindent(); Trace.Unindent(); #endregion DIV #region MOV Trace.WriteLine("MOV", "Unit Test"); Trace.Indent(); Trace.WriteLine("StartUP", "MOV"); Trace.Indent(); TestTable.SetValue("Dest", (short)0); mov.ValueA = 10; Trace.Unindent(); Trace.WriteLine("Input False", "MOV"); Trace.Indent(); PowerRail.LogicLevel = false; mov.Execute(); Assert.IsFalse(mov.InternalState); Assert.AreEqual(TestTable.GetValue("Dest"), (short)0); Trace.Unindent(); Trace.WriteLine("Input True", "MOV"); Trace.Indent(); PowerRail.LogicLevel = true; mov.Execute(); Assert.IsTrue(mov.InternalState); Assert.AreEqual(TestTable.GetValue("Dest"), (short)10); Trace.Unindent(); Trace.Unindent(); #endregion MOV #region MUL Trace.WriteLine("MUL", "Unit Test"); Trace.Indent(); Trace.WriteLine("StartUP", "MUL"); Trace.Indent(); TestTable.SetValue("Dest", (short)0); mul.ValueA = 3; mul.ValueB = 6; Trace.Unindent(); Trace.WriteLine("Input False", "MUL"); Trace.Indent(); PowerRail.LogicLevel = false; mul.Execute(); Assert.IsFalse(mul.InternalState); Assert.AreEqual(TestTable.GetValue("Dest"), (short)0); Trace.Unindent(); Trace.WriteLine("Input True", "MUL"); Trace.Indent(); PowerRail.LogicLevel = true; mul.Execute(); Assert.IsTrue(mul.InternalState); Assert.AreEqual(TestTable.GetValue("Dest"), (short)18); Trace.Unindent(); Trace.Unindent(); #endregion MUL #region SUB Trace.WriteLine("SUB", "Unit Test"); Trace.Indent(); Trace.WriteLine("StartUP", "SUB"); Trace.Indent(); TestTable.SetValue("Dest", (short)0); sub.ValueA = 4; sub.ValueB = 6; Trace.Unindent(); Trace.WriteLine("Input False", "SUB"); Trace.Indent(); PowerRail.LogicLevel = false; sub.Execute(); Assert.IsFalse(sub.InternalState); Assert.AreEqual(TestTable.GetValue("Dest"), (short)0); Trace.Unindent(); Trace.WriteLine("Input True", "SUB"); Trace.Indent(); PowerRail.LogicLevel = true; sub.Execute(); Assert.IsTrue(sub.InternalState); Assert.AreEqual(TestTable.GetValue("Dest"), (short)-2); Trace.Unindent(); Trace.Unindent(); #endregion SUB }
public override object GetContent() { MaxDepth = Request.GetValidated <int>("MaxDepth", -1, x => x >= 0, Tr.PgMonthly.Validation_NonNegative); Account = GetAccount("Acct"); { var ccys = Program.CurFile.Book.EnumCommodities(); var ccy = Request.GetValidated <string>("Ccy", null, x => x == null || ccys.Any(c => c.Identifier == x), Tr.PgMonthly.Validation_OneOfCommodities.Fmt(ccys.Select(c => c.Identifier).Order().JoinString(", "))); ConvertTo = ccy == null ? null : ccys.Single(c => c.Identifier == ccy); } InitRequestOptions(); Report = new ReportAccounts(Account, Request, true, false); Report.AddCol(GetColumnCaption(), GetColumnCaption()); doAccount(Account, 0); // MaxDepth UI var maxdepthUi = new List <object>(); { maxdepthUi.Add(Tr.PgMonthly.SubAcctsDepth); for (int i = 0; i <= 5; i++) { var label = i == 0 ? Tr.PgMonthly.SubAcctsNone.Translation : i.ToString(); if (MaxDepth == i) { maxdepthUi.Add(new SPAN(label) { class_ = "aw-current" }); } else { maxdepthUi.Add(new A(label) { href = Request.Url.WithQuery("MaxDepth", i.ToString()).ToHref() }); } maxdepthUi.Add(" · "); } if (MaxDepth == -1) { maxdepthUi.Add(new SPAN(Tr.PgMonthly.SubAcctsAll) { class_ = "aw-current" }); } else { maxdepthUi.Add(new A(Tr.PgMonthly.SubAcctsAll) { href = Request.Url.WithoutQuery("MaxDepth").ToHref() }); } } // ConvertTo currency UI var convertToUI = new List <object>(); { var ccys = Program.CurFile.Book.EnumCommodities().OrderBy(c => c.Identifier); convertToUI.Add(Program.Tr.PgMonthly.ConvertTo); foreach (var ccy in ((GncCommodity)null).Concat(ccys)) { if (ccy != null) { convertToUI.Add(" · "); } if (ConvertTo == ccy) { convertToUI.Add(new SPAN(ccy?.Identifier ?? Program.Tr.PgMonthly.ConvertToNone) { class_ = "aw-current" }); } else if (ccy == null) { convertToUI.Add(new A(Program.Tr.PgMonthly.ConvertToNone) { href = Request.Url.WithoutQuery("Ccy").ToHref() }); } else { convertToUI.Add(new A(ccy) { href = Request.Url.WithQuery("Ccy", ccy.Identifier).ToHref() }); } } } var html = new DIV( new P(Tr.PgMonthly.CurAccount, GetAccountBreadcrumbs("Acct", Account)), new P(maxdepthUi), new P(convertToUI), Report.GetHtml() ); return(html); }