예제 #1
0
        Expr Assign(VariableVisit variable, Expr value)
        {
            switch (variable.Type)
            {
            case VariableType.Identifier:
                ParamExpr local;
                if (scope.TryGetLocal(variable.Identifier, out local))
                {
                    return(Expr.Assign(local, value));
                }

                return(Expr.Dynamic(Context.DynamicCache.GetSetMemberBinder(variable.Identifier),
                                    typeof(object), Expr.Constant(context.Globals), value));

            case VariableType.MemberId:
                return(Expr.Dynamic(Context.DynamicCache.GetSetMemberBinder(variable.Identifier),
                                    typeof(object), variable.Object, value));

            case VariableType.MemberExpr:
                return(Expr.Dynamic(Context.DynamicCache.GetSetIndexBinder(), typeof(object),
                                    variable.Object, variable.Member, value));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
예제 #2
0
 VariableVisit IVariableVisitor <VariableVisit> .Visit(Variable.MemberExpr variable)
 {
     return(VariableVisit.CreateMemberExpr(
                variable.Prefix.Visit(this),
                variable.Member.Visit(this)));
 }
예제 #3
0
 VariableVisit IVariableVisitor <VariableVisit> .Visit(Variable.MemberId variable)
 {
     return(VariableVisit.CreateMemberId(
                variable.Prefix.Visit(this),
                variable.Member));
 }
예제 #4
0
 VariableVisit IVariableVisitor <VariableVisit> .Visit(Variable.Identifier variable)
 {
     return(VariableVisit.CreateIdentifier(variable.Value));
 }