public override void CaseAOperatorDecl(AOperatorDecl node)
 {
     InAOperatorDecl(node);
     if (node.GetBlock() != null)
     {
         node.GetBlock().Apply(this);
     }
     {
         Object[] temp = new Object[node.GetFormals().Count];
         node.GetFormals().CopyTo(temp, 0);
         for (int i = temp.Length - 1; i >= 0; i--)
         {
             ((PLocalDecl)temp[i]).Apply(this);
         }
     }
     if (node.GetOperator() != null)
     {
         node.GetOperator().Apply(this);
     }
     if (node.GetToken() != null)
     {
         node.GetToken().Apply(this);
     }
     if (node.GetReturnType() != null)
     {
         node.GetReturnType().Apply(this);
     }
     if (node.GetStatic() != null)
     {
         node.GetStatic().Apply(this);
     }
     if (node.GetVisibilityModifier() != null)
     {
         node.GetVisibilityModifier().Apply(this);
     }
     OutAOperatorDecl(node);
 }
示例#2
0
        public override void CaseAOperatorDecl(AOperatorDecl node)
        {
            if (node.GetFormals().Count != 2)
                errors.Add(new ErrorCollection.Error(node.GetToken(), LocRM.GetString("ErrorText182")));
            Token token = null;
            if (node.GetOperator() is APlusBinop)
                token = ((APlusBinop)node.GetOperator()).GetToken();
            else if (node.GetOperator() is AMinusBinop)
                token = ((AMinusBinop)node.GetOperator()).GetToken();
            else if (node.GetOperator() is ADivideBinop)
                token = ((ADivideBinop)node.GetOperator()).GetToken();
            else if (node.GetOperator() is ATimesBinop)
                token = ((ATimesBinop)node.GetOperator()).GetToken();
            else if (node.GetOperator() is AModuloBinop)
                token = ((AModuloBinop)node.GetOperator()).GetToken();
            else if (node.GetOperator() is AEqBinop)
                token = ((AEqBinop)node.GetOperator()).GetToken();
            else if (node.GetOperator() is ANeBinop)
                token = ((ANeBinop)node.GetOperator()).GetToken();
            else if (node.GetOperator() is ALtBinop)
                token = ((ALtBinop)node.GetOperator()).GetToken();
            else if (node.GetOperator() is ALeBinop)
                token = ((ALeBinop)node.GetOperator()).GetToken();
            else if (node.GetOperator() is AGtBinop)
                token = ((AGtBinop)node.GetOperator()).GetToken();
            else if (node.GetOperator() is AGeBinop)
                token = ((AGeBinop)node.GetOperator()).GetToken();
            else if (node.GetOperator() is AGtBinop)
                token = ((AGtBinop)node.GetOperator()).GetToken();
            else if (node.GetOperator() is AAndBinop)
                token = ((AAndBinop)node.GetOperator()).GetToken();
            else if (node.GetOperator() is AOrBinop)
                token = ((AOrBinop)node.GetOperator()).GetToken();
            else if (node.GetOperator() is AXorBinop)
                token = ((AXorBinop)node.GetOperator()).GetToken();
            else if (node.GetOperator() is ALBitShiftBinop)
                token = ((ALBitShiftBinop)node.GetOperator()).GetToken();
            else if (node.GetOperator() is ARBitShiftBinop)
                token = ((ARBitShiftBinop)node.GetOperator()).GetToken();

            AMethodDecl replacer = new AMethodDecl(node.GetVisibilityModifier(), null, node.GetStatic(), null, null,
                                                   null, node.GetReturnType(),
                                                   new TIdentifier(token.Text, token.Line, token.Pos), new ArrayList(),
                                                   node.GetBlock());
            while (node.GetFormals().Count > 0)
                replacer.GetFormals().Add(node.GetFormals()[0]);

            node.ReplaceBy(replacer);
            replacer.Apply(this);
        }