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); }
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); }
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)); }
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); } } }
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); }
public object ExecuteOperator(BrackRuntimeData brd, string name, object[] arguments, BrackPositionData bpd) { return(_Operators[name].Execute(brd, bpd, arguments)); }
public object ExecuteOperator(BrackRuntimeData brd, object[] statement, BrackPositionData bpd) { return(_Operators[statement[0].ToString()].Execute(brd, bpd, statement.Skip(1).ToArray())); }
public override object Execute(BrackRuntimeData brd, BrackPositionData bpd, object[] args) { base.Execute(brd, bpd, args); return(((BrackDelegate)_OperatorDelegate)(brd, bpd)); }