Ejemplo n.º 1
0
        public override Expression Optimize(OptimizationParams op)
        {
            Expression opt_rvalue = rvalue.Optimize(op);

            if (lvalue is Name)
            {
                Name     nm  = lvalue as Name;
                Accessor acc = op.GetAccessor(nm.name);
                if (acc == null)
                {
                    return(this);
                }
                else
                {
                    return(new OptimizedExpression((VM vm) =>
                    {
                        HeronValue x = opt_rvalue.Eval(vm);
                        acc.Set(x);
                        return x;
                    }));
                }
            }
            else
            {
                return(new Assignment(lvalue.Optimize(op), opt_rvalue));
            }
        }
Ejemplo n.º 2
0
        public override Expression Optimize(OptimizationParams op)
        {
            Accessor acc = op.GetAccessor(name);

            if (acc == null)
            {
                return(this);
            }
            return(new OptimizedExpression((VM vm) => acc.Get()));
        }