Ejemplo n.º 1
0
        YExpr ProcessExpr(AssignmentExpressionSyntax assignmentExpression)
        {
            YExpr left  = ProcessExpr(assignmentExpression.Left);
            YExpr right = ProcessExpr(assignmentExpression.Right);

            return(new YAssign(left, right));
        }
Ejemplo n.º 2
0
        YStatement ProcessStatement(IfStatementSyntax ifStatement)
        {
            YExpr      condition     = ProcessExpr(ifStatement.Condition);
            YStatement statement     = ProcessStatement(ifStatement.Statement);
            YStatement elseStatement = ProcessStatement(ifStatement.Else.Statement);

            return(new YIf(condition, statement, elseStatement));
        }
Ejemplo n.º 3
0
        YExpr ProcessExpr(MemberAccessExpressionSyntax memberAccessExpression)
        {
            YExpr expr = ProcessExpr(memberAccessExpression.Expression);

            return(new YMemberAccessExpr(
                       expr,
                       memberAccessExpression.Name.Identifier.ToString()
                       ));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Unwrap expression to string.
        /// </summary>
        static public void AppendEx(this StringBuilder builder, YExpr expr)
        {
            if (expr is YConstExpr)
            {
                builder.Append("" + expr);
            }
            else if (expr is YThisExpr)
            {
                builder.Append("this");
            }
            else if (expr is YMemberAccessExpr)
            {
                var memberAccess = (YMemberAccessExpr)expr;

                AppendEx(builder, memberAccess.Expression);
                builder.Append("->"); // But what with "this."?
                builder.Append(memberAccess.Name);
            }
            else if (expr is YIdentifierExpr)
            {
                builder.Append(((YIdentifierExpr)expr).Name);
            }
            else if (expr is YBinaryExpr)
            {
                var binary = (YBinaryExpr)expr;

                AppendEx(builder, binary.Left);
                builder.Append(" ");
                AppendEx(builder, binary.Operator);
                builder.Append(" ");
                AppendEx(builder, binary.Right);
            }
            else if (expr is YLiteralExpr)
            {
                var literal = (YLiteralExpr)expr;
                if (literal == YLiteralExpr.Null)
                {
                    builder.Append("nullptr");
                }
                else
                {
                    builder.Append(literal.Value);
                }
            }
            else if (expr is YPrefixUnaryExpr)
            {
                var prefixUnari = (YPrefixUnaryExpr)expr;

                AppendEx(builder, prefixUnari.Operator);
                AppendEx(builder, prefixUnari.Operand);
            }
            else if (expr is YInvocation)
            {
                var invocation = (YInvocation)expr;

                AppendEx(builder, invocation.Expression);

                // no arguments
                builder.Append("()");
            }
            else if (expr is YAssign)
            {
                var assign = (YAssign)expr;

                AppendEx(builder, assign.Left);
                builder.Append("=");
                AppendEx(builder, assign.Right);
            }
        }
Ejemplo n.º 5
0
 public YMemberAccessExpr(YExpr expression, string name)
 {
     Expression = expression;
     Name       = name;
 }
Ejemplo n.º 6
0
 public YIf(YExpr condition, YStatement statement, YStatement elseStatement)
 {
     Condition     = condition;
     Statement     = statement;
     ElseStatement = elseStatement;
 }
Ejemplo n.º 7
0
 public YAssign(YExpr left, YExpr right)
 {
     Left  = left;
     Right = right;
 }
Ejemplo n.º 8
0
 public YPrefixUnaryExpr(YOperator @operator, YExpr operand)
 {
     Operator = @operator;
     Operand  = operand;
 }
Ejemplo n.º 9
0
 public YInvocation(YExpr expression)
 {
     Expression = expression;
 }
Ejemplo n.º 10
0
 public YBinaryExpr(YExpr left, YExpr right, YOperator operation)
 {
     Left     = left;
     Right    = right;
     Operator = operation;
 }
Ejemplo n.º 11
0
 public YReturn(YExpr value)
 {
     Value = value;
 }
Ejemplo n.º 12
0
 public YExprStatement(YExpr expression)
 {
     Expression = expression;
 }