Ejemplo n.º 1
0
 public void Visit(BoolExpressionNode n)
 {
     foreach (var node in n.GetChildren())
     {
         node.SymTable = n.SymTable;
         node.Accept(this);
     }
 }
Ejemplo n.º 2
0
 public void Visit(BoolExpressionNode n)
 {
     PrintDOTIDLabel(n);
     PrintDOTParentChild(n);
     foreach (var child in n.GetChildren())
     {
         child.Accept(this);
     }
 }
Ejemplo n.º 3
0
        public void Visit(BoolExpressionNode n)
        {
            var children = n.GetChildren();

            foreach (var child in children)
            {
                child.SymTable = n.SymTable;
                child.Accept(this);
            }
        }
        public void Visit(BoolExpressionNode n)
        {
            var table = (FunctionSymbolTableEntry)n.SymTable;

            n.TemporaryVariableName = table.MemoryLayout.AddTemporaryVariable();

            var children = n.GetChildren();

            foreach (var child in children)
            {
                child.Accept(this);
            }
        }
Ejemplo n.º 5
0
        public void Visit(BoolExpressionNode n)
        {
            var table = (FunctionSymbolTableEntry)n.SymTable;

            var children = n.GetChildren();

            foreach (var child in children)
            {
                child.Accept(this);
            }

            var          compareOp = ((CompareOpNode)children[1]).CompareOpType;
            Instructions instruction;

            switch (compareOp)
            {
            case CompareOpType.Equals:
                instruction = Instructions.Ceq;
                break;

            case CompareOpType.NotEquals:
                instruction = Instructions.Cne;
                break;

            case CompareOpType.GreaterThan:
                instruction = Instructions.Cgt;
                break;

            case CompareOpType.LessThan:
                instruction = Instructions.Clt;
                break;

            case CompareOpType.GreaterThanEqual:
                instruction = Instructions.Cge;
                break;

            case CompareOpType.LessThanEqual:
                instruction = Instructions.Clt;
                break;

            default:
                throw new InvalidOperationException("Unknown boolexpr op");
            }

            var lhsVar    = children[0].TemporaryVariableName;
            var rhsVar    = children[2].TemporaryVariableName;
            var resultVar = n.TemporaryVariableName;

            var lhsOffset    = table.MemoryLayout.GetOffset(lhsVar);
            var rhsOffset    = table.MemoryLayout.GetOffset(rhsVar);
            var resultOffset = table.MemoryLayout.GetOffset(resultVar);

            _writer.WriteComment($"CompareOp ({compareOp})");
            var lhsReg    = PopRegister();
            var rhsReg    = PopRegister();
            var resultReg = PopRegister();

            _writer.WriteInstruction(Instructions.Lw, lhsReg, $"{lhsOffset}({FSPReg})");
            _writer.WriteInstruction(Instructions.Lw, rhsReg, $"{rhsOffset}({FSPReg})");
            _writer.WriteInstruction(instruction, resultReg, lhsReg, rhsReg);
            _writer.WriteInstruction(Instructions.Sw, $"{resultOffset}({FSPReg})", resultReg);

            PushRegister(resultReg);
            PushRegister(rhsReg);
            PushRegister(lhsReg);
        }