예제 #1
0
        public override SLValue VisitAssignment(AssignmentContext ctx)
        {
            SLValue newVal = this.Visit(ctx.expression());

            if (ctx.indexes() != null)
            {
                SLValue val = _scope.resolve(ctx.Identifier().GetText());
                List <ExpressionContext> exps = ctx.indexes().expression().ToList();
                if (val == null)
                {
                    throw new EvalException(ctx);
                }
                SetAtIndex(ctx, exps, val, newVal);
            }
            else
            {
                String id = ctx.Identifier().GetText();
                _scope.GlobalAssign(id, newVal);
            }
            return(SLValue.VOID);
        }