コード例 #1
0
        public List <SyntaxToken> FormatReturnType(OperatorSyntax syntax)
        {
            string             identifier = syntax.GetIdentifier();
            List <SyntaxToken> tokens     = new List <SyntaxToken>();

            if (identifier == "op_Explicit")
            {
                tokens.Add(Constants.KeywordExplicit);
            }
            else if (identifier == "op_Implicit")
            {
                tokens.Add(Constants.KeywordImplicit);
            }
            else
            {
                tokens.AddRange(this.FormatTypeDetails(syntax.GetReturnType()));
            }

            return(tokens);
        }
コード例 #2
0
        public List <SyntaxToken> FormatName(OperatorSyntax syntax)
        {
            string representation = string.Empty;

            switch (syntax.GetIdentifier())
            {
            // Equality overloads
            case "op_Equality": representation = "=="; break;

            case "op_Inequality": representation = "!="; break;

            case "op_GreaterThan": representation = ">"; break;

            case "op_LessThan": representation = "<"; break;

            case "op_GreaterThanOrEqual": representation = ">="; break;

            case "op_LessThanOrEqual": representation = "<="; break;

            // Unary overloads
            case "op_UnaryPlus": representation = "+"; break;

            case "op_UnaryNegation": representation = "-"; break;

            case "op_LogicalNot": representation = "!"; break;

            case "op_OnesComplement": representation = "~"; break;

            case "op_Increment": representation = "++"; break;

            case "op_Decrement": representation = "--"; break;

            case "op_True": representation = "true"; break;

            case "op_False": representation = "false"; break;

            // Binary Overloads
            case "op_Addition": representation = "+"; break;

            case "op_Subtraction": representation = "-"; break;

            case "op_Multiply": representation = "*"; break;

            case "op_Division": representation = "/"; break;

            case "op_Modulus": representation = "%"; break;

            case "op_BitwiseAnd": representation = "&"; break;

            case "op_BitwiseOr": representation = "|"; break;

            case "op_ExclusiveOr": representation = "^"; break;

            case "op_LeftShift": representation = "<<"; break;

            case "op_RightShift": representation = ">>"; break;

            // Concatenation operator is & in a visual basic library - cant be overloaded in C#
            case "op_Concatenate": representation = "+"; break;

            case "op_Implicit": return(this.FormatTypeDetails(syntax.GetReturnType()));

            case "op_Explicit": return(this.FormatTypeDetails(syntax.GetReturnType()));

            default:
                throw new NotImplementedException(
                          "Formatting not implemented for operator '" + syntax.GetIdentifier() + "'."
                          );
            }

            return(new List <SyntaxToken>()
            {
                new SyntaxToken(representation, SyntaxTokens.Text)
            });
        }
コード例 #3
0
 public List <SyntaxToken> FormatReturnType(OperatorSyntax syntax)
 {
     return(FormatTypeDetails(syntax.GetReturnType()));
 }