コード例 #1
0
ファイル: BrackScript.cs プロジェクト: Lockethot/LockeCS
        public object ExecuteScript(BrackRuntimeData brd, object[] arguments, BrackPositionData bpd = null)
        {
            if (brd == null)
            {
                throw new ArgumentNullException("brd");
            }
            if (arguments == null)
            {
                throw new ArgumentNullException("arguments");
            }
            if (arguments.Length != ArgumentCount)
            {
                throw new BrackScriptArgumentCountException(ScriptName, ArgumentCount, arguments.Length, bpd?.FileName, bpd?.StatementID);
            }
            Return ret = null;

            brd.AddLocalMemory();
            for (var i = 0; i < ArgumentCount; i++)
            {
                brd.SetLocalVar(_ArgumentNames[i], arguments[i]);
            }
            ret = (Return)BrackRunner.Execute(brd, FileName, new Type[1] {
                typeof(Return)
            }, null, StatementID);
            brd.RemoveLocalMemory();
            return(ret?.Data);
        }
コード例 #2
0
ファイル: BrackOperator.cs プロジェクト: Lockethot/LockeCS
 public virtual object Execute(BrackRuntimeData brd, BrackPositionData bpd, object[] args)
 {
     if (!IsParamOperator)
     {
         if (args.Length != _ArgumentTypes.Length)
         {
             throw new BrackOperatorArgumentCountException(ArgumentCount, args.Length, OpName, bpd.FileName, bpd.StatementID);
         }
         for (var i = 0; i < ArgumentCount; i++)
         {
             if (args[i].GetType() != _ArgumentTypes[i])
             {
                 throw new BrackOperatorArgumentTypeException(args[i].GetType(), _ArgumentTypes[i], i, OpName, bpd.FileName, bpd.StatementID);
             }
         }
     }
     else //if (IsParamOperator)
     {
         for (var i = 0; i < args.Length; i++)
         {
             if (args[i].GetType() != _ParamType)
             {
                 throw new BrackOperatorArgumentTypeException(args[i].GetType(), _ParamType, i, OpName, bpd.FileName, bpd.StatementID);
             }
         }
     }
     return(null);
 }
コード例 #3
0
ファイル: BrackOperator.cs プロジェクト: Lockethot/LockeCS
 public override object Execute(BrackRuntimeData brd, BrackPositionData bpd, object[] args)
 {
     base.Execute(brd, bpd, args);
     T[] final = new T[args.Length];
     for (var i = 0; i < args.Length; i++)
     {
         final[i] = (T)args[i];
     }
     return(((BrackParamDelegate <T>)_OperatorDelegate)(brd, bpd, final));
 }
コード例 #4
0
ファイル: BrackScriptSet.cs プロジェクト: Lockethot/LockeCS
 public object ExecuteScript(BrackRuntimeData brd, string scriptName, object[] arguments, BrackPositionData bpd = null)
 {
     try
     {
         return(_Scripts[scriptName].ExecuteScript(brd, arguments, bpd));
     }
     catch (KeyNotFoundException)
     {
         if (bpd == null)
         {
             throw new BrackScriptUndeclaredException(scriptName);
         }
         else
         {
             throw new BrackScriptUndeclaredException(scriptName, bpd.FileName, bpd.StatementID);
         }
     }
 }
コード例 #5
0
        public static object Execute(BrackRuntimeData brd, string path = null, Type[] returnTypes = null, SpecialTypes[] specialReturnTypes = null, int[] statementID = null)
        {
            BrackPositionData bpd = new BrackPositionData()
            {
                FileName         = path,
                BrackRuntimeData = brd
            };

            object[][] statements = BrackSerialization.ReadBrack(path);
            for (var i = 0; i < statements.Length; i++)
            {
                bpd.NextStatement();
                var ret = brd.ExecuteOperator(statements[i], bpd);
                if ((returnTypes != null && returnTypes.Contains(ret.GetType())) || (specialReturnTypes != null & (ret is SpecialTypes && specialReturnTypes.Contains((SpecialTypes)ret))))
                {
                    return(ret);
                }
            }
            return(null);
        }
コード例 #6
0
 public object ExecuteOperator(BrackRuntimeData brd, string name, object[] arguments, BrackPositionData bpd)
 {
     return(_Operators[name].Execute(brd, bpd, arguments));
 }
コード例 #7
0
 public object ExecuteOperator(BrackRuntimeData brd, object[] statement, BrackPositionData bpd)
 {
     return(_Operators[statement[0].ToString()].Execute(brd, bpd, statement.Skip(1).ToArray()));
 }
コード例 #8
0
ファイル: BrackOperator.cs プロジェクト: Lockethot/LockeCS
 public override object Execute(BrackRuntimeData brd, BrackPositionData bpd, object[] args)
 {
     base.Execute(brd, bpd, args);
     return(((BrackDelegate)_OperatorDelegate)(brd, bpd));
 }