Example #1
0
        internal override IEnumerable <NameExpression> Walk()
        {
            ArgumentVariables = new List <Variable>();
            for (int i = 0; i < Arguments.Length; i++)
            {
                ArgumentVariables.Add(new Variable
                {
                    Temporary = true
                });
            }

            List <NameExpression> freeVariables = new List <NameExpression>();

            if (Callee == null)
            {
                freeVariables.Add(FunctionName);
            }
            else
            {
                freeVariables.AddRange(Callee.Walk());
            }

            foreach (Expression argument in Arguments)
            {
                freeVariables.AddRange(argument.Walk());
            }
            return(freeVariables);
        }
        private void InnerInvoke(IWampRawRpcOperationRouterCallback caller, InvocationDetails options, object[] arguments)
        {
            long requestId =
                mHandler.RegisterInvocation(this, caller, options, arguments);

            Callee.Invocation(requestId, RegistrationId, options, arguments);
        }
            public async Task BatchDmlAbortsTwice()
            {
                var spannerClientMock = SpannerClientHelpers
                                        .CreateMockClient(Logger.DefaultLogger, MockBehavior.Strict)
                                        .SetupBatchCreateSessionsAsync()
                                        .SetupBeginTransactionAsync()
                                        .SetupExecuteBatchDmlAsync_Fails(failures: 2, statusCode: StatusCode.Aborted)
                                        .SetupCommitAsync()
                                        .SetupRollbackAsync();

                SpannerConnection connection = BuildSpannerConnection(spannerClientMock);

                var scheduler = (FakeScheduler)connection.Builder.SessionPoolManager.SpannerSettings.Scheduler;
                var time0     = scheduler.Clock.GetCurrentDateTimeUtc();
                var callee    = new Callee(scheduler);

                await scheduler.RunAsync(async() =>
                {
                    var result = await connection.RunWithRetriableTransactionAsync(transaction => callee.DatabaseWorkAsync(connection, transaction));
                    Assert.Equal(3, result);
                });

                callee.AssertBackoffTimesInRange(time0);
                callee.AssertLastCallTime(scheduler.Clock.GetCurrentDateTimeUtc());
            }
            public async Task CommitFailsOtherThanAborted()
            {
                var spannerClientMock = SpannerClientHelpers
                                        .CreateMockClient(Logger.DefaultLogger, MockBehavior.Strict)
                                        .SetupBatchCreateSessionsAsync()
                                        .SetupBeginTransactionAsync()
                                        .SetupExecuteBatchDmlAsync()
                                        .SetupCommitAsync_Fails(failures: 1, StatusCode.Unknown)
                                        .SetupRollbackAsync();

                SpannerConnection connection = BuildSpannerConnection(spannerClientMock);

                var scheduler = (FakeScheduler)connection.Builder.SessionPoolManager.SpannerSettings.Scheduler;
                var time0     = scheduler.Clock.GetCurrentDateTimeUtc();
                var callee    = new Callee(scheduler);

                await scheduler.RunAsync(async() =>
                {
                    var exception = await Assert.ThrowsAsync <SpannerException>(
                        () => connection.RunWithRetriableTransactionAsync(
                            transaction => callee.DatabaseWorkAsync(connection, transaction)));
                    Assert.Contains("Bang!", exception.InnerException.Message);
                });

                callee.AssertBackoffTimesInRange(time0);
                callee.AssertLastCallTime(scheduler.Clock.GetCurrentDateTimeUtc());
            }
Example #5
0
        public ActionResult DeleteConfirmed(int?CalleeId)
        {
            Callee callee = db.Callees.Find(CalleeId);

            db.Callees.Remove(callee);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #6
0
        public Caller()
        {
            Console.WriteLine("New");
            Callee c = new Callee();

            caller = c;
            caller.registerCallback(new WeakReference <CallBack>(this));
        }
Example #7
0
        private void imgFire_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
        {
            Callee defaultCallee = new Callee();

            defaultCallee.PhoneNumber = Constants.FireBrigadeContact;
            defaultCallee.DisplayName = "Fire Brigade";
            Utility.InitiateCall(defaultCallee);
        }
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Callee != null ? Callee.GetHashCode() : 0);
         return(hashCode);
     }
 }
    static void Main(string[] args)
    {
        Callee        callee = new Callee();
        List <String> s      = new List <String>();

        callee.DoSomething(ref s);

        Console.WriteLine(s.Count);     // Prints out 0
    }
        private long InnerInvoke(IWampRawRpcOperationRouterCallback caller, InvocationDetails options)
        {
            long requestId =
                mHandler.RegisterInvocation(this, caller, options);

            Callee.Invocation(requestId, RegistrationId, options);

            return(requestId);
        }
Example #11
0
 public ActionResult Edit([Bind(Include = "phoneNumber,firstName,lastName,Address,City,zipCode,isInterested,dayToCall,timeToCall")] Callee callee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(callee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(callee));
 }
        private long InnerInvoke(IWampRawRpcOperationRouterCallback caller, InvocationDetails options, object[] arguments,
                                 IDictionary <string, object> argumentsKeywords)
        {
            long requestId =
                mHandler.RegisterInvocation(this, caller, options, arguments, argumentsKeywords);

            Callee.Invocation(requestId, RegistrationId, options, arguments, argumentsKeywords);

            return(requestId);
        }
        public async System.Threading.Tasks.Task <ActionResult> SendTextAsync(Phone phone)
        {
            Callee callee           = db.Callees.Where(c => c.CalleeId == phone.CalleeId).Single();
            TwilioWrapperClient sms = new TwilioWrapperClient(APIKeys.sID, APIKeys.AuthToken);

            await sms.SendSmsAsync("+14143107982", "+12629332309", phone.outgoingText);


            return(RedirectToAction("Index"));
        }
        public async System.Threading.Tasks.Task <ActionResult> DialAsync(Phone phone)
        {
            System.Console.WriteLine("CALLEE ID: " + phone.CalleeId);
            Callee callee            = db.Callees.Where(c => c.CalleeId == phone.CalleeId).Single();
            TwilioWrapperClient test = new TwilioWrapperClient(APIKeys.sID, APIKeys.AuthToken);
            await test.CallAsync("+14143107982", callee.phoneNumber, "Goodbye");


            return(RedirectToAction("Index"));
        }
Example #15
0
        public void Configure()
        {
            var calleeICMS = new Callee(this._conn);

            var res = calleeICMS.Run(new CalleeRequest <CalculoICMSRetorno, CalculoICMSParametro>
            {
                NomeMetodo = "br.com.techweek.service.icms.calc",
                Run        = new Calcular().Run
            });
        }
Example #16
0
        public ActionResult Create([Bind(Include = "phoneNumber,firstName,lastName,Address,City,zipCode")] Callee callee)
        {
            if (ModelState.IsValid)
            {
                db.Callees.Add(callee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(callee));
        }
        public ActionResult Create([Bind(Include = "Id")] Callee callee)
        {
            if (ModelState.IsValid)
            {
                db.Callees.Add(callee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(callee));
        }
Example #18
0
        public void SendCall_SendResult_Completed()
        {
            Callee callee = new Callee { Result = CallResult.Completed };
            int target = _runtime.AddActor (callee);
            Caller caller = new Caller { History = _history, Finished = _finishTest, Target = target };
            int callerId = _runtime.AddActor (caller);
            _runtime.SendMessage (callerId, Start, null, 0);
            _finishTest.WaitOne ();

            CollectionAssert.AreEquivalent (
                new string[] { "Completed 2 hi" },
                _history
            );
        }
Example #19
0
        // GET: Callees/Edit/5
        public ActionResult Edit(int?CalleeId)
        {
            if (CalleeId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Callee callee = db.Callees.Find(CalleeId);

            if (callee == null)
            {
                return(HttpNotFound());
            }
            return(View(callee));
        }
Example #20
0
 public override ByteBuffer ToBufferRaw(ByteBuffer buffer = null)
 {
     buffer = buffer ?? new ByteBuffer(ByteBuffer.LITTLE_ENDING);
     Fee.ToBuffer(buffer);
     Registrar.ToBuffer(buffer);
     Value.ToBuffer(buffer);
     buffer.WriteString(Code);
     Callee.ToBuffer(buffer);
     buffer.WriteArray(Extensions, (b, item) =>
     {
         if (!item.IsNull())
         {
             ;
         }
     });
     return(buffer);
 }
Example #21
0
        public override void Codegen(CIntermediateLang cil, IndentingStringBuilder sb)
        {
            var argTmps = new List <string>();

            foreach (var arg in Args)
            {
                arg.Codegen(cil, sb);
                argTmps.Add(cil.LastUsedVar);
            }
            Callee.Codegen(cil, sb);

            // This doesn't account for:
            //      calling a returned function pointer
            //      calling from an array subscript
            //      calling a member
            var callee      = cil.SymTable.LookupFunction(cil.LastUsedVar);
            var callRetType = callee.TryInferType(cil);

            sb.LineDecl(SourceInfo);
            if (callRetType == "void")
            {
                sb.Append(string.Format("{0}(", callee.Name));
                cil.LastUsedVar = null;
            }
            else
            {
                var tmp = NameGenerator.NewTemp();
                sb.Append(string.Format(
                              "{0} {1} = {2}(",
                              callee.TryInferType(cil),
                              tmp,
                              callee.Name));
                cil.LastUsedVar = tmp;
            }
            for (int i = 0; i < argTmps.Count; ++i)
            {
                sb.AppendNoIndent(argTmps[i]);
                if (i + 1 < argTmps.Count)
                {
                    sb.AppendNoIndent(", ");
                }
            }
            sb.AppendLineNoIndent(");");
        }
Example #22
0
        public void SendCall_SendResult_Timeout()
        {
            Callee callee = new Callee {
                Result = CallResult.Timeout
            };
            int    target = _runtime.AddActor(callee);
            Caller caller = new Caller {
                History = _history, Finished = _finishTest, Target = target
            };
            int callerId = _runtime.AddActor(caller);

            _runtime.SendMessage(callerId, Start, null, 0);
            _finishTest.WaitOne();

            CollectionAssert.AreEquivalent(
                new string[] { "Timeout 2" },
                _history
                );
        }
Example #23
0
        protected async void InitiateSosEventsAsync()
        {
            bool initiateSMS = false;

            if (!Globals.IsRegisteredUser || !Globals.IsDataNetworkAvailable)
            {
                initiateSMS = true;
            }
            else
            {
                try
                {
                    LocationServiceWrapper.PostMyLocationAsync(await Utility.GetLocationQuick(), null);
                }
                catch
                {
                    initiateSMS = true;
                }
            }
            if (initiateSMS)
            {
                await SendOfflineMessagesAsync();
            }

            try
            {
                if (App.MyBuddies.Buddies != null && App.MyBuddies.Buddies.Count > 0)
                {
                    Callee           defaultCallee = new Callee();
                    BuddyTableEntity buddyEntity   = App.MyBuddies.GetPrimeBuddy(Globals.CurrentProfile.ProfileId);
                    if (buddyEntity != null)
                    {
                        defaultCallee.PhoneNumber = buddyEntity.PhoneNumber;
                        defaultCallee.DisplayName = buddyEntity.Name;
                        Utility.InitiateCall(defaultCallee);
                    }
                }
            }
            catch
            {
                //Ignore if exception raised while calling the default caller
            }
        }
Example #24
0
        // GET: Callees/Details/5
        public ActionResult Details(int?CalleeId)
        {
            if (CalleeId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            using (ApplicationDbContext context = new ApplicationDbContext())
            {
                Callee callee = db.Callees
                                .Include("CalleeCampaign").Select(cp => cp)
                                .Include("CalleeFunds").Select(fu => fu)
                                .FirstOrDefault(co => co.CalleeId == CalleeId);

                if (callee == null)
                {
                    return(HttpNotFound());
                }
                return(View(callee));
            }
        }
            public async Task WorkFails()
            {
                var spannerClientMock = SpannerClientHelpers
                                        .CreateMockClient(Logger.DefaultLogger, MockBehavior.Strict)
                                        .SetupBatchCreateSessionsAsync()
                                        .SetupBeginTransactionAsync()
                                        .SetupRollbackAsync();

                SpannerConnection connection = BuildSpannerConnection(spannerClientMock);

                var scheduler = (FakeScheduler)connection.Builder.SessionPoolManager.SpannerSettings.Scheduler;
                var time0     = scheduler.Clock.GetCurrentDateTimeUtc();
                var callee    = new Callee(scheduler);

                await scheduler.RunAsync(async() =>
                {
                    var exception = await Assert.ThrowsAsync <InvalidOperationException>(() => connection.RunWithRetriableTransactionAsync(callee.Fails));
                    Assert.Contains("Bang!", exception.Message);
                });

                callee.AssertBackoffTimesInRange(time0);
                callee.AssertLastCallTime(scheduler.Clock.GetCurrentDateTimeUtc());
            }
Example #26
0
        public override LllType TryInferType(CIntermediateLang cil)
        {
            var extend = Callee as AstMemberAccess;

            if (extend != null)
            {
                var fromTy  = extend.From.TryInferType(cil);
                var member  = extend.MemberIdent;
                var extName = FixIdent(cil, string.Format("{0}_{1}", fromTy.Name, member));
                if (fromTy.Extensions.ContainsKey(extName))
                {
                    var ext = fromTy.Extensions[extName] as AstFunc;
                    if (ext.IsGeneric)
                    {
                        ext = CompileGeneric(cil, ext);
                    }
                    return(ext.GetRealReturnType());
                    //return LllCompiler.SymTable.LookupType(ext.ReturnType).Clone(ext.ReturnPtrDepth);
                }
            }
            var ident = Callee as AstIdent;

            if (ident != null)
            {
                var fixedIdent = FixIdent(cil, ident.Name);
                var func       = LllCompiler.SymTable.LookupSymbol(fixedIdent)?.Extra as AstFunc;
                if (func != null)
                {
                    if (func.IsGeneric)
                    {
                        func = CompileGeneric(cil, func);
                    }
                    return(func.GetRealReturnType());
                }
            }
            return(Callee.TryInferType(cil));
        }
            public async Task CommitAbortsAlways_RespectsOverallDeadline()
            {
                var spannerClientMock = SpannerClientHelpers
                                        .CreateMockClient(Logger.DefaultLogger, MockBehavior.Strict)
                                        .SetupBatchCreateSessionsAsync()
                                        .SetupBeginTransactionAsync()
                                        .SetupExecuteBatchDmlAsync()
                                        .SetupCommitAsync_FailsAlways(statusCode: StatusCode.Aborted)
                                        .SetupRollbackAsync();

                SpannerConnection connection = BuildSpannerConnection(spannerClientMock);

                var scheduler = (FakeScheduler)connection.Builder.SessionPoolManager.SpannerSettings.Scheduler;

                // This test needs a little bit more of real time, else it's flaky.
                scheduler.RealTimeTimeout = TimeSpan.FromSeconds(60);
                var time0  = scheduler.Clock.GetCurrentDateTimeUtc();
                var callee = new Callee(scheduler);

                await scheduler.RunAsync(async() =>
                {
                    var exception = await Assert.ThrowsAsync <SpannerException>(() => connection.RunWithRetriableTransactionAsync(transaction => callee.DatabaseWorkAsync(connection, transaction)));
                    Assert.True(exception.IsRetryable && !exception.SessionExpired);
                    Assert.Contains("Bang!", exception.InnerException.Message);
                });

                // The minimum calls that can be made (assuming maximum jitter always) in that time is 60 * 60 / 32 * 2 which is 56.25,
                // plus 1 because the first one has no delay.
                // The maximum number of calls that can be made in 1 hour:
                // - Given that 2^7 * 250 = 32000, the first 8 calls take, at a minimum 31_750ms, approx 32s.
                // - The rest will happen at most (60 * 60 - 32) / 32 which is 111.5
                callee.AssertCalledInRange(57, 120);
                // The overall deadline is of 1 hour. The maximum backoff delay is of 32s.
                // Because of jitter retries can stop at any time after 60mins - 64s, let's give it 2 minutes of range.
                Assert.InRange(scheduler.Clock.GetCurrentDateTimeUtc(), time0.AddMinutes(58), time0.AddMinutes(60));
            }
Example #28
0
 public RoutineReference(Context ctx, Callee callee)
 {
     Name    = callee.Routine;
     Unit    = callee.Unit == null ? null : new UnitReference(ctx, callee.Unit);
     Context = ctx;
 }
Example #29
0
 public void Registered(long registrationId)
 {
     Callee.Registered(this.RequestId, registrationId);
 }
Example #30
0
 public override string TryInferType(CIntermediateLang cil)
 {
     return(Callee.TryInferType(cil));
 }
Example #31
0
        /// <inheritdoc/>
        public override BlockCodegen Emit(BasicBlockBuilder BasicBlock)
        {
            if (Callee is DelegateBlock)
            {
                var deleg = (DelegateBlock)Callee;

                var targetAndBlock = EmitTarget(BasicBlock, deleg.Target);
                BasicBlock = targetAndBlock.BasicBlock;

                var argsAndBlock = EmitArguments(BasicBlock, targetAndBlock.Value, Arguments);
                BasicBlock = argsAndBlock.Item2;

                var calleeAndBlock = EmitCallee(BasicBlock, targetAndBlock.Value, deleg.Callee, deleg.Op);
                BasicBlock = calleeAndBlock.BasicBlock;

                return(EmitCall(BasicBlock, calleeAndBlock.Value, argsAndBlock.Item1));
            }
            else if (Callee is IntrinsicBlock)
            {
                var argsAndBlock = EmitArguments(BasicBlock, new LLVMValueRef(IntPtr.Zero), Arguments);
                BasicBlock = argsAndBlock.Item2;

                var intrinsicAndBlock = Callee.Emit(BasicBlock);
                BasicBlock = intrinsicAndBlock.BasicBlock;

                return(EmitCall(BasicBlock, intrinsicAndBlock.Value, argsAndBlock.Item1));
            }
            else
            {
                // To invoke a delegate, we first need to figure out if it includes
                // a context or not. If so, then we should prepend a context value
                // to the argument list.
                //
                // The code'll look more or less like this:
                //
                //     var delegate = ...;
                //     var args... = ...;
                //     void* fptr = delegate->fptr;
                //     if (delegate->has_context)
                //     {
                //         void* context = delegate->context;
                //         result1 = ((TRet(void*, TArgs...)*)fptr)(context, args...);
                //     }
                //     else
                //     {
                //         result2 = ((TRet(TArgs...)*)fptr)(args...);
                //     }
                //     result = phi(result1, result2);

                var delegateAndBlock = Callee.Emit(BasicBlock);
                BasicBlock = delegateAndBlock.BasicBlock;

                var argsAndBlock = EmitArguments(BasicBlock, default(LLVMValueRef), Arguments);
                BasicBlock = argsAndBlock.Item2;

                var contextfulCallBlock  = BasicBlock.CreateChildBlock("contextful_call");
                var contextlessCallBlock = BasicBlock.CreateChildBlock("contextless_call");
                var postCallBlock        = BasicBlock.CreateChildBlock("post_call");

                var funcPrototype = BasicBlock.FunctionBody.Module.DeclarePrototype(
                    methodSignature);

                var contextFuncPrototype =
                    methodSignature.IsStatic
                    ? FunctionType(
                        funcPrototype.GetReturnType(),
                        new LLVMTypeRef[] { PointerType(Int8Type(), 0) }
                        .Concat <LLVMTypeRef>(funcPrototype.GetParamTypes())
                        .ToArray <LLVMTypeRef>(),
                        funcPrototype.IsFunctionVarArg)
                    : funcPrototype;

                var contextlessFuncPrototype =
                    methodSignature.IsStatic
                    ? funcPrototype
                    : FunctionType(
                        funcPrototype.GetReturnType(),
                        funcPrototype.GetParamTypes()
                        .Skip <LLVMTypeRef>(1)
                        .ToArray <LLVMTypeRef>(),
                        funcPrototype.IsFunctionVarArg);

                var delegatePtr = BuildBitCast(
                    BasicBlock.Builder,
                    delegateAndBlock.Value,
                    PointerType(DelegateBlock.MethodTypeLayout, 0),
                    "delegate_ptr");

                var funcPtr = DelegateBlock.BuildLoadFunctionPointer(
                    BasicBlock.Builder, delegatePtr);

                var hasContext = DelegateBlock.BuildLoadHasContext(
                    BasicBlock.Builder, delegatePtr);

                BuildCondBr(
                    BasicBlock.Builder,
                    hasContext,
                    contextfulCallBlock.Block,
                    contextlessCallBlock.Block);

                // Write the contextful call block.
                var contextPtr = DelegateBlock.BuildLoadContextObject(
                    contextfulCallBlock.Builder, delegatePtr);

                var contextfulCallAndBlock = EmitCall(
                    contextfulCallBlock,
                    BuildBitCast(
                        contextfulCallBlock.Builder,
                        funcPtr,
                        PointerType(contextFuncPrototype, 0),
                        "contextful_fptr"),
                    new LLVMValueRef[] { contextPtr }
                    .Concat <LLVMValueRef>(argsAndBlock.Item1)
                    .ToArray <LLVMValueRef>());
                contextfulCallBlock = contextfulCallAndBlock.BasicBlock;

                BuildBr(contextfulCallBlock.Builder, postCallBlock.Block);

                // Write the contextless call block.
                var contextlessCallAndBlock = EmitCall(
                    contextlessCallBlock,
                    BuildBitCast(
                        contextlessCallBlock.Builder,
                        funcPtr,
                        PointerType(contextlessFuncPrototype, 0),
                        "contextless_fptr"),
                    argsAndBlock.Item1);
                contextlessCallBlock = contextlessCallAndBlock.BasicBlock;

                BuildBr(contextlessCallBlock.Builder, postCallBlock.Block);

                // Write a phi if the return type is non-void.
                if (contextfulCallAndBlock.HasValue)
                {
                    var resultPhi = BuildPhi(
                        postCallBlock.Builder,
                        contextfulCallAndBlock.Value.TypeOf(),
                        "result_phi");
                    resultPhi.AddIncoming(
                        new LLVMValueRef[]
                    {
                        contextfulCallAndBlock.Value,
                        contextlessCallAndBlock.Value
                    },
                        new LLVMBasicBlockRef[]
                    {
                        contextfulCallAndBlock.BasicBlock.Block,
                        contextlessCallAndBlock.BasicBlock.Block
                    },
                        2);
                    return(new BlockCodegen(postCallBlock, resultPhi));
                }
                else
                {
                    return(new BlockCodegen(postCallBlock));
                }
            }
        }