Ejemplo n.º 1
0
        public override Base VisitAssignment([NotNull] GolangParser.AssignmentContext context)
        {
            var left  = context.expression_list(0).Accept(this) as ExpressionList;
            var right = context.expression_list(1).Accept(this) as ExpressionList;
            var type  = context.assign_op().Accept(this) as AssignmentTypeWrapper;

            var ret = new StatementList();

            if (type.Type == AssignmentType.Normal && left.NumChildren() > 1 && right.NumChildren() == 1 && right.GetChild(0) is InvocationExpression)
            {
                ret.AddChild(
                    new ReturnAssignment(
                        left,
                        right.GetChild <InvocationExpression>(0)));
            }
            else
            {
                while (left.NumChildren() > 0)
                {
                    ret.AddChild(
                        new Assignment(
                            left.GetChild <Expression>(0),
                            right.GetChild <Expression>(0),
                            type.Type));
                }
            }

            return(ret);
        }
Ejemplo n.º 2
0
        public override void ExitAssignment(GolangParser.AssignmentContext context)
        {
            // assignment
            //     : expressionList assign_op expressionList

            if (ExpressionLists.TryGetValue(context.expressionList(0), out string[] leftOperands) && ExpressionLists.TryGetValue(context.expressionList(1), out string[] rightOperands))