public DefaultHumanFinishRuleAsserter(int? slot, Execution e, List<Execution> others) { this._slot = slot; this._userAction = e.Result; this._workItem = e; this._allOtherWorkItems = others; }
public override void Compile(Execution.VM.ByteCode bc) { m_Function.Compile(bc); int argslen = m_Arguments.Count; if (!string.IsNullOrEmpty(m_Name)) { bc.Emit_Copy(0); bc.Emit_Index(DynValue.NewString(m_Name), true); bc.Emit_Swap(0, 1); ++argslen; } for (int i = 0; i < m_Arguments.Count; i++) m_Arguments[i].Compile(bc); if (!string.IsNullOrEmpty(m_Name)) { bc.Emit_ThisCall(argslen, m_DebugErr); } else { bc.Emit_Call(argslen, m_DebugErr); } }
public override object Execute(Execution.RTExecutionContext context) { RTScope func = context.CurrentScope; bool hasError = false; var caller = context.CurrentScope.Parent.Creator as RTFunction; if (caller != null && !caller.Metadata.CanDefineVariable) { context.Errors.Add(new Execution.RTExecutionError(func, RTErrorCode.SysFuncError, ErrorMessages.Function_Def_Caller_No_Scope)); hasError = true; } var symbol = func.GetArg(0) as RTVariable; if (symbol == null) { context.Errors.Add(new Execution.RTExecutionError(func, RTErrorCode.SysFuncError, ErrorMessages.Function_Def_Arg0)); hasError = true; } else { context.DefiningSymbol = symbol; } if (!hasError) { object value = this.EvaluateArg(1, context); context.CurrentScope.Parent.SetValueLocal(symbol.Name, value); } context.DefiningSymbol = null; return RTVoid.Singleton; }
public override void Compile(Execution.VM.ByteCode bc) { foreach (var exp in expressions) exp.Compile(bc); if (expressions.Count > 1) bc.Emit_MkTuple(expressions.Count); }
public Skill( string name, int? doerNum, int? targetNum, Execution getEvent, bool aliveOnly = true ) { this.Name = name; this.DoerNum = doerNum; this.TargetNum = targetNum; this.getEvent = getEvent; this.aliveOnly = aliveOnly; }
public override void Compile(Execution.VM.ByteCode bc) { bc.Emit_Clean(m_StackFrame); Address = bc.GetJumpPointForLastInstruction(); foreach (var gotostat in m_Gotos) gotostat.SetAddress(this.Address); }
public override void Compile(Execution.VM.ByteCode bc) { if (m_Statements != null) { foreach (Statement s in m_Statements) { s.Compile(bc); } } }
public override void Compile(Execution.VM.ByteCode bc) { using(bc.EnterSource(m_Do)) bc.Emit_Enter(m_StackFrame); m_Block.Compile(bc); using (bc.EnterSource(m_End)) bc.Emit_Leave(m_StackFrame); }
public override object Execute(Execution.RTExecutionContext context) { RTScope func = context.CurrentScope; var index = (int)RTConverter.Singleton.ToNumber(EvaluateArg(0, context)); if (index < 0) return null; RTScope root = context.RootScope; IRTMatch match = root.GetValueLocal(RTSysSymbols.MATCH_INPUT) as IRTMatch; if (index >= match.Count) return null; return match.GetItem(index); }
public override void Compile(Execution.VM.ByteCode bc) { using (bc.EnterSource(m_Ref)) { if (m_Expression != null) { m_Expression.Compile(bc); bc.Emit_Ret(1); } else { bc.Emit_Ret(0); } } }
public override object Execute(Execution.RTExecutionContext context) { RTScope scope = context.CurrentScope; //check if (scope.ArgCount < 2) { context.Errors.Add(new RTExecutionError(scope, RTErrorCode.Metadata_Not_Enough_Args, string.Format(ErrorMessages.Metadata_Not_Enough_Args, 2, scope.ArgCount))); } if (scope.ArgCount > 3) { context.Errors.Add(new RTExecutionError(scope, RTErrorCode.Metadata_Too_Many_Args, string.Format(ErrorMessages.Metadata_Too_Many_Args, 3, scope.ArgCount))); } var condition = EvaluateArg(0, context); var conditionScope = condition as RTScope; if (conditionScope == null) { bool? cond = RTConverter.Singleton.ToBoolean(condition); if (cond.HasValue) { if (cond.Value) { return EvaluateArg(1, context); } else { if (scope.ArgCount < 3) return RTVoid.Singleton; else return EvaluateArg(2, context); } } else { context.Errors.Add(new RTExecutionError(scope, RTErrorCode.SysFuncError, ErrorMessages.Function_If_Null_Condition)); return RTVoid.Singleton; } } else { scope.AddArg(condition); scope.AddArg(EvaluateArg(1, context)); if (scope.Creator.Args.Count > 2) scope.AddArg(EvaluateArg(2, context)); return scope; } }
private ContractQuotes( Uid uid, IEnumerable<Quote> bids, IEnumerable<Quote> offers, IEnumerable<Execution> executions, Execution? lastExecution, PriceType priceType, QuantityType quantityType) { _uid = uid; _bids = GetQuoteDict(bids, Price.BidOrder); _offers = GetQuoteDict(offers, Price.OfferOrder); _executions = new List<Execution>(executions); _lastExecution = lastExecution; _priceType = priceType; _quantityType = quantityType; }
public override void Compile(Execution.VM.ByteCode bc) { Instruction meta = bc.Emit_Meta("<chunk-root>", OpCodeMetadataType.ChunkEntrypoint); int metaip = bc.GetJumpPointForLastInstruction(); bc.Emit_BeginFn(m_StackFrame); bc.Emit_Args(m_VarArgs); bc.Emit_Load(SymbolRef.Upvalue(WellKnownSymbols.ENV, 0)); bc.Emit_Store(m_Env, 0, 0); bc.Emit_Pop(); m_Block.Compile(bc); bc.Emit_Ret(0); meta.NumVal = bc.GetJumpPointForLastInstruction() - metaip; }
public override void Compile(Execution.VM.ByteCode bc) { Instruction meta = bc.Emit_FuncMeta("<chunk-root>"); int metaip = bc.GetJumpPointForLastInstruction(); bc.Emit_BeginFn(m_StackFrame); bc.Emit_Args(m_VarArgs); bc.Emit_Literal(DynValue.NewTable(m_GlobalEnv)); bc.Emit_Store(m_Env, 0, 0); bc.Emit_Pop(); m_Block.Compile(bc); bc.Emit_Ret(0); meta.NumVal = bc.GetJumpPointForLastInstruction() - metaip; }
public Execution AsyncBeginApply(Migration migration, Instance instance) { ProjectHistoryStep historyStep = new ProjectHistoryStep(); historyStep.Description = string.Format("Applying migration {0} ({1}) on instance {2}.", migration.Id, migration.Description, instance.FullName); historyStep.At = clock.Now; historyStep.By = appContext.FullUserName; historyStep.Project = migration.AuditProject; historyStep.Create(); Execution execution = new Execution(); execution.At = clock.Now; execution.By = appContext.FullUserName; execution.Migration = migration; execution.Instance = instance; execution.ExecutionState = ExecutionState.Pending; execution.AppendLog("Starting migration {0}({1}) on {2}...", migration.Id, migration.Description, instance.FullName); execution.CreateAndFlush(); try { migrationTablesManager.CheckAndCreateMigrationTable(instance, execution); execution.UpdateAndFlush(); if (!migrationTablesManager.IsMigrationAlreadyApplied(migration, instance, execution)) { ThreadPool.QueueUserWorkItem(new WaitCallback(delegate(object arg) { SyncApplyMigration(migration, instance, execution); })); } else { execution.ExecutionState = ExecutionState.Completed; execution.UpdateAndFlush(); } } catch (Exception ex) { execution.AppendLogException(ex); execution.UpdateAndFlush(); } return execution; }
public override void Compile(Execution.VM.ByteCode bc) { var envVal = DynValue.NewTable(m_GlobalEnv); Instruction meta = bc.Emit_Meta("<chunk-root>", OpCodeMetadataType.ChunkEntrypoint, envVal); int metaip = bc.GetJumpPointForLastInstruction(); bc.Emit_BeginFn(m_StackFrame); bc.Emit_Args(m_VarArgs); bc.Emit_Literal(envVal); bc.Emit_Store(m_Env, 0, 0); bc.Emit_Pop(); m_Block.Compile(bc); bc.Emit_Ret(0); meta.NumVal = bc.GetJumpPointForLastInstruction() - metaip; }
public override void Compile(Execution.VM.ByteCode bc) { List<Instruction> endJumps = new List<Instruction>(); Instruction lastIfJmp = null; foreach (var ifblock in m_Ifs) { using (bc.EnterSource(ifblock.Source)) { if (lastIfJmp != null) lastIfJmp.NumVal = bc.GetJumpPointForNextInstruction(); ifblock.Exp.Compile(bc); lastIfJmp = bc.Emit_Jump(OpCode.Jf, -1); bc.Emit_Enter(ifblock.StackFrame); ifblock.Block.Compile(bc); } using (bc.EnterSource(m_End)) bc.Emit_Leave(ifblock.StackFrame); endJumps.Add(bc.Emit_Jump(OpCode.Jump, -1)); } lastIfJmp.NumVal = bc.GetJumpPointForNextInstruction(); if (m_Else != null) { using (bc.EnterSource(m_Else.Source)) { bc.Emit_Enter(m_Else.StackFrame); m_Else.Block.Compile(bc); } using (bc.EnterSource(m_End)) bc.Emit_Leave(m_Else.StackFrame); } foreach(var endjmp in endJumps) endjmp.NumVal = bc.GetJumpPointForNextInstruction(); }
public void CheckAndCreateMigrationTable(Instance instance, Execution currentExecution) { currentExecution.AppendLog("Checking migration tables on {0}...", instance.FullName); using (SqlConnection connection = new SqlConnection(connectionStringProvider.GetConnectionString(instance))) { connection.Open(); using (SqlCommand cmd = new SqlCommand(@"SELECT COUNT(*) FROM sys.objects WHERE name='DBAppliedMigrations' AND type_desc = 'USER_TABLE'", connection)) { int count = (int)cmd.ExecuteScalar(); if (count == 0) { currentExecution.AppendLog("No migrations tables detected. Installing...", instance.FullName); cmd.CommandText = @"CREATE TABLE [DBAppliedMigrations]( [Id] [int] IDENTITY(1,1) NOT NULL, [Executed_at] [datetime] NULL, [Executed_by] [nvarchar](255) NULL, [MigrateScript] [ntext] NULL, [RollbackScript] [ntext] NULL, [Migration_id] [int] NULL, PRIMARY KEY CLUSTERED ( [Id] ASC ) )"; cmd.ExecuteNonQuery(); currentExecution.AppendLog("Migrations tables installed.", instance.FullName); } else { currentExecution.AppendLog("Migration tables already installed on {0}.", instance.FullName); } } } }
public override object Execute(Execution.RTExecutionContext context) { RTScope func = context.CurrentScope; int step = 1; string retval = string.Empty; var varname = func.GetArg(0) as RTVariable; var from = (int)RTConverter.Singleton.ToNumber(EvaluateArg(1, context)); var to = (int)RTConverter.Singleton.ToNumber(EvaluateArg(2, context)); if (from > to) step = -1; var body = func.GetArg(3) as RTExpression; for (int i = from; step == -1 ? i >= to : i <= to; i += step) { context.CurrentScope.SetValueLocal(varname.Name, (double)i); var result = body.Execute(context); if (!(result is RTVoid)) { retval += RTConverter.Singleton.ToString(result); } } return retval; }
protected override TrsTermBase ApplySubstitution(Execution.Substitution substitution) { if (substitution.Variable.Equals(this)) return substitution.SubstitutionTerm; else return this; }
static void Main(string[] args) { try { // Create CacheFactory using the settings from the gfcpp.properties file by default. CacheFactory cacheFactory = CacheFactory.CreateCacheFactory(); Cache cache = cacheFactory.SetSubscriptionEnabled(true) .AddServer("localhost", 40404) .AddServer("localhost", 50505) .Create(); Console.WriteLine("Created the GemFire Cache"); Region region = cache.CreateRegionFactory(RegionShortcut.CACHING_PROXY) .Create("partition_region"); Console.WriteLine("Created the partition_region."); for (int i = 0; i < 34; i++) { region.Put("KEY--" + i, "VALUE--" + i); } IGFSerializable[] routingObj = new IGFSerializable[17]; int j = 0; for (int i = 0; i < 34; i++) { if (i % 2 == 0) { continue; } routingObj[j] = new CacheableString("KEY--" + i); j++; } Console.WriteLine("routingObj count= {0}.", routingObj.Length); //test data dependant function execution // test get function with result Boolean getResult = true; IGFSerializable args0 = new CacheableBoolean(true); Execution exc = FunctionService.OnRegion(region); IResultCollector rc = exc.WithArgs(args0).WithFilter(routingObj).Execute( getFuncName, getResult); IGFSerializable[] executeFunctionResult = rc.GetResult(); Console.WriteLine("on region: result count= {0}.", executeFunctionResult.Length); List <IGFSerializable> resultList = new List <IGFSerializable>(); for (int pos = 0; pos < executeFunctionResult.Length; pos++) { CacheableArrayList resultItem = executeFunctionResult[pos] as CacheableArrayList; foreach (IGFSerializable item in resultItem) { resultList.Add(item); } } Console.WriteLine("on region: result count= {0}.", resultList.Count); for (int i = 0; i < resultList.Count; i++) { Console.WriteLine("on region:get:result[{0}]={1}.", i, (resultList[i] as CacheableString).Value); } getResult = true; //test date independant fucntion execution on one server // test get function with result exc = FunctionService.OnServer(cache); CacheableVector args1 = new CacheableVector(); for (int i = 0; i < routingObj.Length; i++) { Console.WriteLine("routingObj[{0}]={1}.", i, (routingObj[i] as CacheableString).Value); args1.Add(routingObj[i]); } rc = exc.WithArgs(args1).Execute( getFuncIName, getResult); executeFunctionResult = rc.GetResult(); Console.WriteLine("on one server: result count= {0}.", executeFunctionResult.Length); List <IGFSerializable> resultList1 = new List <IGFSerializable>(); for (int pos = 0; pos < executeFunctionResult.Length; pos++) { CacheableArrayList resultItem = executeFunctionResult[pos] as CacheableArrayList; foreach (IGFSerializable item in resultItem) { resultList1.Add(item); } } for (int i = 0; i < resultList1.Count; i++) { Console.WriteLine("on one server:get:result[{0}]={1}.", i, (resultList1[i] as CacheableString).Value); } //test date independant fucntion execution on all servers // test get function with result exc = FunctionService.OnServers(cache); rc = exc.WithArgs(args1).Execute(getFuncIName, getResult); executeFunctionResult = rc.GetResult(); Console.WriteLine("on all servers: result count= {0}.", executeFunctionResult.Length); List <IGFSerializable> resultList2 = new List <IGFSerializable>(); for (int pos = 0; pos < executeFunctionResult.Length; pos++) { CacheableArrayList resultItem = executeFunctionResult[pos] as CacheableArrayList; foreach (IGFSerializable item in resultItem) { resultList2.Add(item); } } if (resultList2.Count != 34) { Console.WriteLine("result count check failed on all servers"); } for (int i = 0; i < resultList2.Count; i++) { Console.WriteLine("on all servers:result[{0}]={1}.", i, (resultList2[i] as CacheableString).Value); } //test withCollector MyResultCollector myRC = new MyResultCollector(); rc = exc.WithArgs(args1).WithCollector(myRC).Execute(getFuncIName, getResult); executeFunctionResult = rc.GetResult(); Console.WriteLine("add result count= {0}.", myRC.GetAddResultCount()); Console.WriteLine("get result count= {0}.", myRC.GetGetResultCount()); Console.WriteLine("end result count= {0}.", myRC.GetEndResultCount()); Console.WriteLine("on all servers with collector: result count= {0}.", executeFunctionResult.Length); // Close the GemFire Cache. cache.Close(); Console.WriteLine("Closed the GemFire Cache"); } // An exception should not occur catch (GemFireException gfex) { Console.WriteLine("ExecuteFunctions GemFire Exception: {0}", gfex.Message); } }
public PositionEventArgs(Execution.Position position) { this.Position = position; }
//! [contractdetailsend] //! [execdetails] public virtual void execDetails(int reqId, Contract contract, Execution execution) { Output.WriteLine("ExecDetails. " + reqId + " - " + contract.Symbol + ", " + contract.SecType + ", " + contract.Currency + " - " + execution.ExecId + ", " + execution.OrderId + ", " + execution.Shares); }
protected override TrsTermBase ApplySubstitution(Execution.Substitution substitution) { // Atoms do not contain variables. return this; }
public void Memoize1_throws_exception_when_null_is_passed_as_function() { Assert.Throws <ArgumentNullException>(() => Execution.Memoize1((Func <int, int>)null)); }
public override void Compile(Execution.VM.ByteCode bc) { throw new InvalidOperationException(); }
public void Repeat_throws_exception_if_action_is_null() { Assert.Throws <ArgumentNullException>(() => Execution.Repeat(12, (Action)null)); }
public ListCommand(Execution executionLevel) { _executionLevel = executionLevel; }
public virtual string Unpause(Execution execution) { if (CanExecute(execution)) return CallServer(); return null; }
public virtual string RemoveData(Execution execution) { if (CanExecute(execution)) return CallServer(); return null; }
/// <summary> /// They different framework models will process the new provided insight. /// The <see cref="IPortfolioConstructionModel"/> will create targets, /// the <see cref="IRiskManagementModel"/> will adjust the targets /// and the <see cref="IExecutionModel"/> will execute the <see cref="IPortfolioTarget"/> /// </summary> /// <param name="insights">The insight to process</param> private void ProcessInsights(Insight[] insights) { // construct portfolio targets from insights var targets = PortfolioConstruction.CreateTargets(this, insights).ToArray(); // set security targets w/ those generated via portfolio construction module foreach (var target in targets) { var security = Securities[target.Symbol]; security.Holdings.Target = target; } if (DebugMode) { // debug printing of generated targets if (targets.Length > 0) { Log($"{Time}: PORTFOLIO: {string.Join(" | ", targets.Select(t => t.ToString()).OrderBy(t => t))}"); } } var riskTargetOverrides = RiskManagement.ManageRisk(this, targets).ToArray(); // override security targets w/ those generated via risk management module foreach (var target in riskTargetOverrides) { var security = Securities[target.Symbol]; security.Holdings.Target = target; } if (DebugMode) { // debug printing of generated risk target overrides if (riskTargetOverrides.Length > 0) { Log($"{Time}: RISK: {string.Join(" | ", riskTargetOverrides.Select(t => t.ToString()).OrderBy(t => t))}"); } } // execute on the targets, overriding targets for symbols w/ risk targets var riskAdjustedTargets = riskTargetOverrides.Concat(targets).DistinctBy(pt => pt.Symbol).ToArray(); if (DebugMode) { // only log adjusted targets if we've performed an adjustment if (riskTargetOverrides.Length > 0) { Log($"{Time}: RISK ADJUSTED TARGETS: {string.Join(" | ", riskAdjustedTargets.Select(t => t.ToString()).OrderBy(t => t))}"); } } if (riskAdjustedTargets.Length > 0 && Execution.GetType() != typeof(NullExecutionModel) && BrokerageModel.AccountType == AccountType.Cash) { throw new InvalidOperationException($"Non null {nameof(IExecutionModel)} and {nameof(IPortfolioConstructionModel)} are currently unsuitable for Cash Modeled brokerages (e.g. GDAX) and may result in unexpected trades." + " To prevent possible user error we've restricted them to Margin trading. You can select margin account types with" + $" SetBrokerage( ... AccountType.Margin). Or please set them to {nameof(NullExecutionModel)}, {nameof(NullPortfolioConstructionModel)}"); } Execution.Execute(this, riskAdjustedTargets); }
public override void Compile(Execution.VM.ByteCode bc) { bc.Emit_Load(m_Ref); }
public void CompileAssignment(Execution.VM.ByteCode bc, int stackofs, int tupleidx) { bc.Emit_Store(m_Ref, stackofs, tupleidx); }
public override void Compile(Execution.VM.ByteCode bc) { bc.Emit_NewTable(m_Shared); foreach (var kvp in m_CtorArgs) { kvp.Key.Compile(bc); kvp.Value.Compile(bc); bc.Emit_TblInitN(); } for (int i = 0; i < m_PositionalValues.Count; i++ ) { m_PositionalValues[i].Compile(bc); bc.Emit_TblInitI(i == m_PositionalValues.Count - 1); } }
public override void Compile(Execution.VM.ByteCode bc) { m_Exp1.Compile(bc); if (m_Operator == Operator.Or) { Instruction i = bc.Emit_Jump(OpCode.JtOrPop, -1); m_Exp2.Compile(bc); i.NumVal = bc.GetJumpPointForNextInstruction(); return; } if (m_Operator == Operator.And) { Instruction i = bc.Emit_Jump(OpCode.JfOrPop, -1); m_Exp2.Compile(bc); i.NumVal = bc.GetJumpPointForNextInstruction(); return; } if (m_Exp2 != null) { m_Exp2.Compile(bc); } bc.Emit_Operator(OperatorToOpCode(m_Operator)); if (ShouldInvertBoolean(m_Operator)) bc.Emit_Operator(OpCode.Not); }
protected override void Run(Execution <HandleContext> execution) { store.Append(execution.Context.Message); }