コード例 #1
0
 public virtual object Execute(NamedArgumentList arguments)
 {
     ToolScriptFunctionArgs args = new ToolScriptFunctionArgs(arguments);
     if(Invoked != null)
         Invoked(this, args);
     return args.ReturnValue;
 }
コード例 #2
0
ファイル: MethodWraper.cs プロジェクト: langpavel/LPS-old
 public object Execute(NamedArgumentList arguments)
 {
     //List<MethodInfo> try_again = new List<MethodInfo>(Methods.Length);
     foreach(MethodInfo method in Methods)
     {
         ParameterInfo[] aparams = method.GetParameters();
         if(aparams.Length != arguments.Count)
             continue;
         object[] vals = new object[aparams.Length];
         for(int i = 0; i < aparams.Length; i++)
         {
             object val = arguments.GetValue(aparams[i].Name, i);
             vals[i] = val;
             Type m_type = aparams[i].ParameterType;
             if(val != null)
             {
                 Type p_type = val.GetType();
                 if(!(m_type == p_type || p_type.IsSubclassOf(m_type)))
                     goto NextMethod;
             }
             else
             {
                 if(m_type.IsValueType)
                     goto NextMethod;
             }
         }
         using(Log.Scope("Trying invoke {0}", method))
         {
             try
             {
                 return method.Invoke(Instance, vals);
             }
             catch(TargetInvocationException err)
             {
                 // unwrap exception
                 if(err.InnerException != null)
                     throw err.InnerException;
                 else
                     throw err;
             }
         }
     NextMethod:		;
     }
     StringBuilder sb = new StringBuilder("Patřičná metoda nebyla nalezena. Varianty ");
     sb.AppendLine(Methods.Length.ToString());
     foreach(MethodInfo method in Methods)
         sb.AppendLine(method.ToString());
     throw new InvalidOperationException(sb.ToString());
 }
コード例 #3
0
 public object Execute(NamedArgumentList arguments)
 {
     try
     {
         Parameters.InitVariables(this.Context, arguments);
         Body.Run(this.Context);
         return SpecialValue.Void;
     }
     catch(IterationTermination info)
     {
         if(info.Reason == TerminationReason.Return)
             return info.ReturnValue;
         else
             throw new InvalidOperationException("volání funkce bylo přerušeno jiným důvodem než return: " + info.Reason.ToString());
     }
 }
コード例 #4
0
ファイル: NewExpression.cs プロジェクト: langpavel/LPS-old
 public NewExpression(QualifiedName TypeName, NamedArgumentList Arguments)
 {
     this.TypeName = TypeName;
     this.Arguments = Arguments;
 }
コード例 #5
0
 public ToolScriptFunctionArgs(NamedArgumentList Args)
 {
     this.Args = Args;
     this.ReturnValue = SpecialValue.Void;
 }
コード例 #6
0
 public FunctionExpression(string name, NamedArgumentList parameters, IStatement body)
 {
     this.Name = name;
     this.Parameters = parameters;
     this.Body = body;
 }
コード例 #7
0
ファイル: FunctionCall.cs プロジェクト: langpavel/LPS-old
 public FunctionCall(IExpression Function, NamedArgumentList Args)
 {
     this.Function = Function;
     this.Args = Args; // can be null
 }