예제 #1
0
 public override void AppendStructure(StringBuilder b, Bindings bindings)
 {
     b.Append("(");
     child.AppendStructure(b, bindings);
     b.Append(")");
 }
예제 #2
0
 public override bool IsReadOnly(Bindings bindings, ELContext context)
 {
     return(true);
 }
예제 #3
0
 public abstract ValueReference GetValueReference(Bindings bindings, ELContext context);
예제 #4
0
 public abstract object Eval(Bindings bindings, ELContext context);
예제 #5
0
 public abstract MethodInfo GetMethodInfo(Bindings bindings, ELContext context, Type returnType, Type[] paramTypes);
예제 #6
0
 public abstract bool IsReadOnly(Bindings bindings, ELContext context);
예제 #7
0
 public override void AppendStructure(StringBuilder b, Bindings bindings)
 {
     b.Append(bindings != null && bindings.IsFunctionBound(index) ? "<fn>" : name);
     @params.AppendStructure(b, bindings);
 }
예제 #8
0
 public override void SetValue(Bindings bindings, ELContext context, object value)
 {
     child.SetValue(bindings, context, value);
 }
예제 #9
0
 public override void AppendStructure(StringBuilder builder, Bindings bindings)
 {
     property.AppendStructure(builder, bindings);
     @params.AppendStructure(builder, bindings);
 }
예제 #10
0
 public override object Eval(Bindings bindings, ELContext context)
 {
     return(Invoke(bindings, context, null, null, null));
 }
예제 #11
0
 public sealed override ValueReference GetValueReference(Bindings bindings, ELContext context)
 {
     return(null);
 }
예제 #12
0
 public override MethodInfo GetMethodInfo(Bindings bindings, ELContext context, Type returnType, Type[] paramTypes)
 {
     return(null);
 }
예제 #13
0
 public override void SetValue(Bindings bindings, ELContext context, object value)
 {
     throw new ELException(LocalMessages.Get("error.value.set.rvalue", GetStructuralId(bindings)));
 }
예제 #14
0
 public override Type GetType(Bindings bindings, ELContext context)
 {
     return(child.GetType(bindings, context));
 }
예제 #15
0
 /// <summary>
 /// Invoke method. </summary>
 /// <param name="bindings"> </param>
 /// <param name="context"> </param>
 /// <param name="base"> </param>
 /// <param name="method"> </param>
 /// <returns> method result </returns>
 /// <exception cref="TargetInvocationException"> </exception>
 /// <exception cref="AccessViolationException"> </exception>
 protected internal virtual object Invoke(Bindings bindings, ELContext context, object @base, MethodInfo method)
 {
     Type[]   types   = method.GetParameters().Select(c => c.ParameterType).ToArray();
     object[] @params = null;
     if (types.Length > 0)
     {
         @params = new object[types.Length];
         //if (varargs && method.GetParameters().Any())
         if (method.ContainsGenericParameters && method.GetParameters().Any())
         {
             for (int i = 0; i < @params.Length - 1; i++)
             {
                 object param = GetParam(i).Eval(bindings, context);
                 if (param != null || types[i].IsPrimitive)
                 {
                     @params[i] = bindings.Convert <object>(param, types[i]);
                 }
             }
             int    varargIndex = types.Length - 1;
             Type   varargType  = types[varargIndex];
             int    length      = ParamCount - varargIndex;
             object array       = null;
             if (length == 1)
             {                     // special: eventually use argument as is
                 object param = GetParam(varargIndex).Eval(bindings, context);
                 if (param != null && param.GetType().IsArray)
                 {
                     if (types[varargIndex].IsInstanceOfType(param))
                     {
                         array = param;
                     }
                     else
                     {                             // coerce array elements
                         //length = Array.GetLength(param);
                         //array = Array.CreateInstance(varargType, length);
                         //for (int i = 0; i < length; i++)
                         //{
                         //	object elem = Array.Get(param, i);
                         //	if (elem != null || varargType.IsPrimitive)
                         //	{
                         //		((System.Array)array).SetValue(bindings.Convert(elem, varargType), i);
                         //	}
                         //}
                     }
                 }
                 else
                 {                         // single element array
                     array = Array.CreateInstance(varargType, 1);
                     if (param != null || varargType.IsPrimitive)
                     {
                         ((System.Array)array).SetValue(bindings.Convert <object>(param, varargType), 0);
                     }
                 }
             }
             else
             {
                 array = Array.CreateInstance(varargType, length);
                 for (int i = 0; i < length; i++)
                 {
                     object param = GetParam(varargIndex + i).Eval(bindings, context);
                     if (param != null || varargType.IsPrimitive)
                     {
                         ((System.Array)array).SetValue(bindings.Convert <object>(param, varargType), i);
                     }
                 }
             }
             @params[varargIndex] = array;
         }
         else
         {
             for (int i = 0; i < @params.Length; i++)
             {
                 object param = GetParam(i).Eval(bindings, context);
                 if (param != null || types[i].IsPrimitive)
                 {
                     @params[i] = bindings.Convert <object>(param, types[i]);
                 }
             }
         }
     }
     return(method.Invoke(@base, @params));
 }
예제 #16
0
 public override bool IsReadOnly(Bindings bindings, ELContext context)
 {
     return(child.IsReadOnly(bindings, context));
 }
예제 #17
0
 protected internal override object GetProperty(Bindings bindings, ELContext context)
 {
     return(property);
 }
예제 #18
0
 public abstract object Invoke(Bindings bindings, ELContext context, Type returnType, Type[] paramTypes, object[] paramValues);
예제 #19
0
 public override void AppendStructure(StringBuilder b, Bindings bindings)
 {
     ((AstDot)GetChild(0)).AppendStructure(b, bindings);
     b.Append(".");
     b.Append(property);
 }
예제 #20
0
 public abstract void SetValue(Bindings bindings, ELContext context, object value);
예제 #21
0
 public override ValueReference GetValueReference(Bindings bindings, ELContext context)
 {
     return(child.GetValueReference(bindings, context));
 }
예제 #22
0
 public abstract Type GetType(Bindings bindings, ELContext context);
예제 #23
0
 public override void AppendStructure(StringBuilder b, Bindings bindings)
 {
     b.Append(deferred ? "#{" : "${");
     child.AppendStructure(b, bindings);
     b.Append("}");
 }
예제 #24
0
 public abstract void AppendStructure(StringBuilder builder, Bindings bindings);
예제 #25
0
 public override MethodInfo GetMethodInfo(Bindings bindings, ELContext context, Type returnType, Type[] paramTypes)
 {
     return(child.GetMethodInfo(bindings, context, returnType, paramTypes));
 }
예제 #26
0
 public override object Eval(Bindings bindings, ELContext context)
 {
     return(child.Eval(bindings, context));
 }
예제 #27
0
 public override object Invoke(Bindings bindings, ELContext context, Type returnType, Type[] paramTypes, object[] paramValues)
 {
     return(child.Invoke(bindings, context, returnType, paramTypes, paramValues));
 }
예제 #28
0
 public override void AppendStructure(StringBuilder b, Bindings bindings)
 {
     b.Append(bindings != null && bindings.IsVariableBound(index) ? "<var>" : name);
 }
예제 #29
0
 public override Type GetType(Bindings bindings, ELContext context)
 {
     return(null);
 }