public override void VisitBinOpNode(BinOpNode binop) { base.VisitBinOpNode(binop); if (binop.Left is IntNumNode left && binop.Right is IntNumNode right) { var num = 0; switch (binop.Op) { case "+": num = left.Num + right.Num; break; case "-": num = left.Num - right.Num; break; case "*": num = left.Num * right.Num; break; case "/": num = left.Num / right.Num; break; } var newInt = new IntNumNode(num); ReplaceExpr(binop, newInt); } }
public override void PostVisit(Node n) { // Algebraic expressions of the form: 2 * 3 => 6 if (n is BinOpNode binop && binop.Left is IntNumNode && binop.Right is IntNumNode) { if (binop.Left is IntNumNode && binop.Right is IntNumNode) { var result = new IntNumNode(0); switch (binop.Op) { case OpType.PLUS: result.Num = (binop.Left as IntNumNode).Num + (binop.Right as IntNumNode).Num; break; case OpType.MINUS: result.Num = (binop.Left as IntNumNode).Num - (binop.Right as IntNumNode).Num; break; case OpType.DIV: result.Num = (binop.Left as IntNumNode).Num / (binop.Right as IntNumNode).Num; break; case OpType.MULT: result.Num = (binop.Left as IntNumNode).Num * (binop.Right as IntNumNode).Num; break; } ReplaceExpr(binop, result); } else { base.VisitBinOpNode(binop); } } }
public override void PostVisit(Node node) { // Algebraic expressions of the form: 2 * 3 => 6 if (node is BinOpNode binop && binop.Left is IntNumNode intNumLeft && binop.Right is IntNumNode intNumRight) { var result = new IntNumNode(0); switch (binop.Op) { case OpType.PLUS: result.Num = intNumLeft.Num + intNumRight.Num; break; case OpType.MINUS: result.Num = intNumLeft.Num - intNumRight.Num; break; case OpType.DIV: result.Num = intNumLeft.Num / intNumRight.Num; break; case OpType.MULT: result.Num = intNumLeft.Num * intNumRight.Num; break; default: return; } ReplaceExpr(binop, result); } }
public override void VisitIntNumNode(IntNumNode num) { if (depth == 0) { compList.Add(sum); } }
public override void VisitIntNumNode(IntNumNode node) { var literal = LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(node.Value)); literal = GetNodeWithAnnotation(literal, node.Location) as LiteralExpressionSyntax; expressions.Push(literal); }
public override void VisitIntNumNode(IntNumNode num) { num.Parent = st.Peek(); st.Push(num); base.VisitIntNumNode(num); st.Pop(); }
public void Visit(IntNumNode n) { foreach (var node in n.GetChildren()) { node.SymTable = n.SymTable; node.Accept(this); } }
public override void VisitIntNumNode(IntNumNode num) { var line = new ThreeAddrLine(); line.Accum = num.Num.ToString(); line.Label = GenNewLabel(); line.OpType = ThreeAddrOpType.Nop; Data.Add(line); }
public void Visit(IntNumNode n) { PrintDOTIDLabel(n, n.Value.ToString()); PrintDOTParentChild(n); foreach (var child in n.GetChildren()) { child.Accept(this); } }
public void Visit(IntNumNode n) { var children = n.GetChildren(); foreach (var child in children) { child.SymTable = n.SymTable; child.Accept(this); } }
public override void VisitIntNumNode(IntNumNode id) { if (CurrNestExprs > 0) { if (CurrNest == 0) { list.Add(0); } } }
public void Visit(IntNumNode n) { var table = (FunctionSymbolTableEntry)n.SymTable; var tempVar = n.TemporaryVariableName; var offset = table.MemoryLayout.GetOffset(tempVar); _writer.WriteComment($"Init const int value {n.Value} ({n.Token.StartLine}:{n.Token.StartColumn})"); var reg = PopRegister(); _writer.WriteInstruction(Instructions.Addi, reg, reg, n.Value.ToString()); _writer.WriteInstruction(Instructions.Sw, $"{offset}({FSPReg})", reg); PushRegister(reg); }
public override void VisitIntNumNode(IntNumNode num) => Text += num.Num.ToString(CultureInfo.CurrentCulture);
public virtual void VisitIntNumNode(IntNumNode num) { }
public override void VisitIntNumNode(IntNumNode num) { genc.Emit(OpCodes.Ldc_I4, num.Num); }
public override void VisitIntNumNode(IntNumNode num) { throw new NotImplementedException(); }
public void VisitIntNumNode(IntNumNode a) { string label = Mark(a); _nodes.AppendLine($"{label} [label = \"Int: {a.Num}\"]"); }
/// <summary> /// Посещение IntNumNode /// </summary> /// <param name="num">Узел IntNumNode</param> public virtual void VisitIntNumNode(IntNumNode num) { Text += num.Num.ToString(); }
public abstract void VisitIntNumNode(IntNumNode num);
public override void Visit(IntNumNode node) { OnEnter(node); base.Visit(node); OnExit(node); }
public void Visit(IntNumNode n) { var table = (FunctionSymbolTableEntry)n.SymTable; n.TemporaryVariableName = table.MemoryLayout.AddTemporaryVariable(); }
public override void VisitIntNumNode(IntNumNode num) { throw new Exception("Logic error"); }
public virtual void Visit(IntNumNode node) { }
public override void VisitIntNumNode(IntNumNode num) { Text.Append(num.Num.ToString()); }
public override void VisitIntNumNode(IntNumNode num) { Text += num.Num.ToString(); }
public override void Visit(IntNumNode node) { ProgramBuilder.Append(node.Num); }