Exemple #1
0
 public void Visit(VarFuncCallNode n)
 {
     PrintDOTIDLabel(n, n.CallType.ToString());
     PrintDOTParentChild(n);
     foreach (var child in n.GetChildren())
     {
         child.Accept(this);
     }
 }
Exemple #2
0
        public void Visit(VarFuncCallNode n)
        {
            var children = n.GetChildren();

            foreach (var child in children)
            {
                child.SymTable = n.SymTable;
                child.Accept(this);
            }
        }
        public void Visit(VarFuncCallNode n)
        {
            var children = n.GetChildren();

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

            var table = (FunctionSymbolTableEntry)n.SymTable;
            var last  = children.Last();
            var size  = Utils.GetTypeFullSize(_globalSymbolTable, last.ExprType);

            n.TemporaryVariableName    = table.MemoryLayout.AddTemporaryVariable(size);
            n._CallchainAddressVarName = table.MemoryLayout.AddTemporaryVariable();
        }
Exemple #4
0
        public void Visit(VarFuncCallNode n)
        {
            var children = n.GetChildren();

            var first = children.First();

            first.SymTable          = n.SymTable;
            first.SecondarySymTable = n.SymTable;
            first.CallerTable       = n.SymTable;
            first.Accept(this);

            var currentScopeSpec = first.ScopeSpec;

            foreach (var node in children.Skip(1))
            {
                if (!string.IsNullOrEmpty(currentScopeSpec))
                {
                    var classTable = _globalTable.GetClassSymbolTableByName(currentScopeSpec);
                    if (classTable == null)
                    {
                        _errorStream.WriteLine($"ScopeSpec \"{currentScopeSpec}\" refers to a non existing class.");
                        Console.WriteLine($"Error: ScopeSpec \"{currentScopeSpec}\" refers to a non existing class.");
                        break;
                    }

                    node.SymTable          = classTable;
                    node.SecondarySymTable = n.SymTable;
                }
                else
                {
                    node.SymTable          = first.SymTable;
                    node.SecondarySymTable = n.SymTable;
                }

                node.Accept(this);
                currentScopeSpec = node.ScopeSpec;
            }

            n.ExprType = children.Last().ExprType;
        }
        public void Visit(VarFuncCallNode n)
        {
            var children = n.GetChildren();
            var table    = (FunctionSymbolTableEntry)n.SymTable;

            _writer.WriteComment("Var Func Call");

            var callchainAddrOffset = table.MemoryLayout.GetOffset(n._CallchainAddressVarName);

            _writer.WriteInstruction(Instructions.Sw, $"{callchainAddrOffset}({FSPReg})", Registers.R12);
            WriteCallchainCode(children, FSPReg);

            // r12 points to value, crate local copy
            var valSize       = Utils.GetTypeFullSize(_globalSymbolTable, n.ExprType);
            var destVarName   = n.TemporaryVariableName;
            var destVarOffset = table.MemoryLayout.GetOffset(destVarName);
            var srcAddrReg    = Registers.R12;
            var destAddrReg   = PopRegister();
            var valSizeReg    = PopRegister();

            _writer.WriteInstruction(Instructions.Addi, valSizeReg, valSizeReg, $"{valSize}");
            _writer.WriteInstruction(Instructions.Add, destAddrReg, destAddrReg, FSPReg);
            _writer.WriteInstruction(Instructions.Addi, destAddrReg, destAddrReg, $"{destVarOffset}");

            if (!n._ReturnRawAddress)
            {
                WriteMultiByteCopy(srcAddrReg, destAddrReg, valSizeReg); // Copy value to destination
            }
            else
            {
                _writer.WriteInstruction(Instructions.Sw, $"0({destAddrReg})", srcAddrReg); // Copy address to destination
            }

            _writer.WriteInstruction(Instructions.Lw, Registers.R12, $"{callchainAddrOffset}({FSPReg})");

            PushRegister(valSizeReg);
            PushRegister(destAddrReg);
        }