public MessageSessionAsyncHandlerFactory(NamespaceContext context, ITaskSupervisor supervisor, ISessionReceiver receiver, IDeliveryTracker tracker, ISendEndpointProvider sendEndpointProvider, IPublishEndpointProvider publishEndpointProvider) { _context = context; _supervisor = supervisor; _receiver = receiver; _tracker = tracker; _sendEndpointProvider = sendEndpointProvider; _publishEndpointProvider = publishEndpointProvider; }
public Receiver(NamespaceContext context, ClientContext clientContext, IPipe<ReceiveContext> receivePipe, ClientSettings clientSettings, ITaskSupervisor supervisor, ISendEndpointProvider sendEndpointProvider, IPublishEndpointProvider publishEndpointProvider) { _context = context; _clientContext = clientContext; _receivePipe = receivePipe; _clientSettings = clientSettings; _sendEndpointProvider = sendEndpointProvider; _publishEndpointProvider = publishEndpointProvider; _tracker = new DeliveryTracker(DeliveryComplete); _participant = supervisor.CreateParticipant($"{TypeMetadataCache<Receiver>.ShortName} - {clientContext.InputAddress}", Stop); var options = new OnMessageOptions { AutoComplete = false, AutoRenewTimeout = clientSettings.AutoRenewTimeout, MaxConcurrentCalls = clientSettings.MaxConcurrentCalls }; options.ExceptionReceived += (sender, x) => { if (!(x.Exception is OperationCanceledException)) { if (_log.IsErrorEnabled) _log.Error($"Exception received on receiver: {clientContext.InputAddress} during {x.Action}", x.Exception); } if (_tracker.ActiveDeliveryCount == 0) { if (_log.IsDebugEnabled) _log.DebugFormat("Receiver shutdown completed: {0}", clientContext.InputAddress); _participant.SetComplete(); } }; clientContext.OnMessageAsync(OnMessage, options); _participant.SetReady(); }
Task Create(NamespaceContext context, TopicSubscription subscription) { return(context.CreateTopicSubscription(subscription.Subscription.SubscriptionDescription)); }
Task Delete(NamespaceContext context, QueueSubscription subscription) { return(context.DeleteTopicSubscription(subscription.Subscription.SubscriptionDescription)); }
Task Create(NamespaceContext context, Queue queue) { return(context.CreateQueue(queue.QueueDescription)); }
Task Create(NamespaceContext context, QueueSubscription subscription) { return(context.CreateTopicSubscription(subscription.Subscription.SubscriptionDescription, subscription.Subscription.Rule, subscription.Subscription.Filter)); }
public override bool VisitTopLevelFuncDef([NotNull] GamaParser.TopLevelFuncDefContext context) { var name = context.Symbol().GetText(); var fnlist = NamespaceContext.FindFunctionRef(name); var attrs = context.funcAttr(); // New function if (fnlist == null) { fnlist = new GamaFunctionList(name); var stplist = context.symbolTypePairList(); var parms = new GamaParamList(); var parmTypes = new GamaTypeRef[0]; var parmTypesNative = new LLVMTypeRef[0]; if (stplist != null) { var list = stplist.symbolTypePair(); parmTypes = new GamaTypeRef[list.Length]; parmTypesNative = new LLVMTypeRef[list.Length]; for (int i = 0; i < list.Length; i++) { var stp = list[i]; var sym = stp.Symbol(); var type = NamespaceContext.FindTypeRefGlobal(stp.typeName()); if (type == null) { GlobalContext.AddError(new ErrorTypeNotFound(stp.typeName())); return(false); } /* Since functions are not first-class types, we need to wrap them around with a pointer */ if (type is GamaFunction) { type = new GamaPointer(type); } if (!parms.Add(sym.GetText(), type)) { GlobalContext.AddError(new ErrorDuplicateParameter(stp)); return(false); // TODO: fix error library. } parmTypesNative[i] = type.UnderlyingType; parmTypes[i] = type; } } /* Determine type */ var rettypefqtn = context.typeName(); var retty = InstanceTypes.Void; // If function has a non-void type if (rettypefqtn != null) { // Find it retty = NamespaceContext.FindTypeRefGlobal(rettypefqtn); if (retty == null) { GlobalContext.AddError(new ErrorTypeNotFound(rettypefqtn)); return(false); } } /* LLVM */ var modty = new GamaFunction(retty, parmTypes, LLVMTypeRef.CreateFunction(retty.UnderlyingType, parmTypesNative)); var modfn = NamespaceContext.This.Context.Module.AddFunction(name, modty.UnderlyingType); var fn = new GamaFunctionRef(retty, parms, modty, modfn, false); var unit = new GamaFunctionCompiler(NamespaceContext, fn); /* Parameters are added to top frame of the target function, but they are not treated as conventional variables */ foreach (var p in parms.Parameters) { unit.Top.AddValue(p.Name, new GamaValueRef(p.Type, modfn.GetParam(p.Index), false)); } unit.Visit(context.block()); if (unit.Finish() == 0) { // First add ident, if it fails you fail too. if (attrs != null) { var attributes = new GamaAttributeCompiler(this).Visit(attrs); if (attributes != null) { fn.Attributes = attributes; } else { return(false); } } fnlist.AddFunction(fn); NamespaceContext.This.Functions.Add(fnlist); } else { ; // ?gnihtemos oD :ODOT (TODO:) } return(true); } // An override function else { var stplist = context.symbolTypePairList(); var parms = new GamaParamList(); if (stplist != null) { var list = stplist.symbolTypePair(); for (int i = 0; i < list.Length; i++) { var stp = list[i]; var sym = stp.Symbol(); var type = NamespaceContext.FindTypeRefGlobal(stp.typeName()); if (type == null) { GlobalContext.AddError(new ErrorTypeNotFound(stp.typeName())); return(false); } if (type is GamaFunction) { if (!parms.Add(sym.GetText(), new GamaPointer(type))) { GlobalContext.AddError(new ErrorDuplicateParameter(stp)); return(false); // TODO: fix error library. } continue; } if (!parms.Add(sym.GetText(), type)) { GlobalContext.AddError(new ErrorDuplicateParameter(stp)); return(false); } } } // Duplicate function if two functions have same type of parameters if (fnlist.FindFunction(parms) != null) { GlobalContext.AddError(new ErrorDuplicateFunction(context)); return(false); } /* Determine type */ var rettypefqtn = context.typeName(); var retty = InstanceTypes.Void; // If function has a non-void type if (rettypefqtn != null) { // Find it retty = NamespaceContext.FindTypeRefGlobal(rettypefqtn); if (retty == null) { GlobalContext.AddError(new ErrorTypeNotFound(rettypefqtn)); return(false); } } var modty = new GamaFunction(retty, parms.Parameters.Select(p => p.Type).ToArray(), LLVMTypeRef.CreateFunction(retty.UnderlyingType, parms.Parameters.Select(p => p.Type.UnderlyingType).ToArray())); var modfn = GlobalContext.Module.AddFunction(name, modty.UnderlyingType); var fn = new GamaFunctionRef(retty, parms, modty, modfn, false); var unit = new GamaFunctionCompiler(NamespaceContext, fn); unit.Visit(context.block()); if (unit.Finish() == 0) { if (attrs != null) { var attributes = new GamaAttributeCompiler(this).Visit(attrs); if (attributes != null) { fn.Attributes = attributes; } else { return(false); } } fnlist.AddFunction(fn); } else { ; // TODO: } return(true); } }
public SharedNamespaceContext(NamespaceContext context, CancellationToken cancellationToken) : base(new PayloadCacheScope(context), cancellationToken) { _context = context; }
public IDisposable Namespace(string name) { NamespaceContext nc = new NamespaceContext(this); ns = Qualify(name); return nc; }
public static void Parse(this CSharpParser.Namespace_member_declarationsContext context, NamespaceContext ns) { foreach ( CSharpParser.Namespace_member_declarationContext declarationContext in context.namespace_member_declaration()) { declarationContext.Parse(ns); } }
private ExprContext expr(int _p) { ParserRuleContext _parentctx = Context; int _parentState = State; ExprContext _localctx = new ExprContext(Context, _parentState); ExprContext _prevctx = _localctx; int _startState = 4; EnterRecursionRule(_localctx, 4, RULE_expr, _p); int _la; try { int _alt; EnterOuterAlt(_localctx, 1); { State = 129; switch ( Interpreter.AdaptivePredict(TokenStream,12,Context) ) { case 1: { _localctx = new SignContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 35; _la = TokenStream.La(1); if ( !(_la==T__14 || _la==T__15) ) { ErrorHandler.RecoverInline(this); } else { Consume(); } State = 36; expr(35); } break; case 2: { _localctx = new NegationContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 37; Match(T__25); State = 38; expr(29); } break; case 3: { _localctx = new FormulaeContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 39; Match(T__30); State = 40; expr(26); } break; case 4: { _localctx = new FunctionContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 41; Match(T__34); State = 42; Match(T__7); State = 44; _la = TokenStream.La(1); if (_la==T__53 || _la==ID) { { State = 43; formlist(); } } State = 46; Match(T__8); State = 47; expr(23); } break; case 5: { _localctx = new RepeatStatementContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 48; Match(T__42); State = 52; ErrorHandler.Sync(this); _la = TokenStream.La(1); while (_la==NL) { { { State = 49; Match(NL); } } State = 54; ErrorHandler.Sync(this); _la = TokenStream.La(1); } State = 55; expr(17); } break; case 6: { _localctx = new HelpContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 56; Match(T__43); State = 57; expr(16); } break; case 7: { _localctx = new CompoundContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 58; Match(T__35); State = 60; _la = TokenStream.La(1); if (_la==NL) { { State = 59; Match(NL); } } State = 62; exprlist(); State = 63; Match(T__36); } break; case 8: { _localctx = new IfStatementContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 65; Match(T__37); State = 66; Match(T__7); State = 67; expr(0); State = 68; Match(T__8); State = 70; _la = TokenStream.La(1); if (_la==NL) { { State = 69; Match(NL); } } State = 72; expr(0); } break; case 9: { _localctx = new IfElseStatementContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 74; Match(T__37); State = 75; Match(T__7); State = 76; expr(0); State = 77; Match(T__8); State = 79; _la = TokenStream.La(1); if (_la==NL) { { State = 78; Match(NL); } } State = 81; expr(0); State = 83; _la = TokenStream.La(1); if (_la==NL) { { State = 82; Match(NL); } } State = 85; Match(T__38); State = 87; _la = TokenStream.La(1); if (_la==NL) { { State = 86; Match(NL); } } State = 89; expr(0); } break; case 10: { _localctx = new ForEachStatementContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 91; Match(T__39); State = 92; Match(T__7); State = 93; Match(ID); State = 94; Match(T__40); State = 95; expr(0); State = 96; Match(T__8); State = 98; _la = TokenStream.La(1); if (_la==NL) { { State = 97; Match(NL); } } State = 100; expr(0); } break; case 11: { _localctx = new WhileStatementContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 102; Match(T__41); State = 103; Match(T__7); State = 104; expr(0); State = 105; Match(T__8); State = 107; _la = TokenStream.La(1); if (_la==NL) { { State = 106; Match(NL); } } State = 109; expr(0); } break; case 12: { _localctx = new NextStatementContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 111; Match(T__44); } break; case 13: { _localctx = new BreakStatementContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 112; Match(T__45); } break; case 14: { _localctx = new ParenthesizedContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 113; Match(T__7); State = 114; expr(0); State = 115; Match(T__8); } break; case 15: { _localctx = new IdentifierContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 117; Match(ID); } break; case 16: { _localctx = new StringLiteralContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 118; Match(STRING); } break; case 17: { _localctx = new HexLiteralContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 119; Match(HEX); } break; case 18: { _localctx = new IntLiteralContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 120; Match(INT); } break; case 19: { _localctx = new FloatLiteralContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 121; Match(FLOAT); } break; case 20: { _localctx = new ComplexLiteralContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 122; Match(COMPLEX); } break; case 21: { _localctx = new NullLiteralContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 123; Match(T__46); } break; case 22: { _localctx = new NAContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 124; Match(T__47); } break; case 23: { _localctx = new InfLiteralContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 125; Match(T__48); } break; case 24: { _localctx = new NanLiteralContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 126; Match(T__49); } break; case 25: { _localctx = new TrueLiteralContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 127; Match(T__50); } break; case 26: { _localctx = new FalseLiteralContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 128; Match(T__51); } break; } Context.Stop = TokenStream.Lt(-1); State = 185; ErrorHandler.Sync(this); _alt = Interpreter.AdaptivePredict(TokenStream,14,Context); while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.InvalidAltNumber ) { if ( _alt==1 ) { if ( ParseListeners!=null ) TriggerExitRuleEvent(); _prevctx = _localctx; { State = 183; switch ( Interpreter.AdaptivePredict(TokenStream,13,Context) ) { case 1: { _localctx = new NamespaceContext(new ExprContext(_parentctx, _parentState)); PushNewRecursionContext(_localctx, _startState, RULE_expr); State = 131; if (!(Precpred(Context, 38))) throw new FailedPredicateException(this, "Precpred(Context, 38)"); State = 132; _la = TokenStream.La(1); if ( !(_la==T__9 || _la==T__10) ) { ErrorHandler.RecoverInline(this); } else { Consume(); } State = 133; expr(39); } break; case 2: { _localctx = new MemberAccessContext(new ExprContext(_parentctx, _parentState)); PushNewRecursionContext(_localctx, _startState, RULE_expr); State = 134; if (!(Precpred(Context, 37))) throw new FailedPredicateException(this, "Precpred(Context, 37)"); State = 135; _la = TokenStream.La(1); if ( !(_la==T__11 || _la==T__12) ) { ErrorHandler.RecoverInline(this); } else { Consume(); } State = 136; expr(38); } break; case 3: { _localctx = new PowerContext(new ExprContext(_parentctx, _parentState)); PushNewRecursionContext(_localctx, _startState, RULE_expr); State = 137; if (!(Precpred(Context, 36))) throw new FailedPredicateException(this, "Precpred(Context, 36)"); State = 138; Match(T__13); State = 139; expr(37); } break; case 4: { _localctx = new SequenceContext(new ExprContext(_parentctx, _parentState)); PushNewRecursionContext(_localctx, _startState, RULE_expr); State = 140; if (!(Precpred(Context, 34))) throw new FailedPredicateException(this, "Precpred(Context, 34)"); State = 141; Match(T__16); State = 142; expr(35); } break; case 5: { _localctx = new UserOpContext(new ExprContext(_parentctx, _parentState)); PushNewRecursionContext(_localctx, _startState, RULE_expr); State = 143; if (!(Precpred(Context, 33))) throw new FailedPredicateException(this, "Precpred(Context, 33)"); State = 144; Match(USER_OP); State = 145; expr(34); } break; case 6: { _localctx = new MultiplicationContext(new ExprContext(_parentctx, _parentState)); PushNewRecursionContext(_localctx, _startState, RULE_expr); State = 146; if (!(Precpred(Context, 32))) throw new FailedPredicateException(this, "Precpred(Context, 32)"); State = 147; _la = TokenStream.La(1); if ( !(_la==T__17 || _la==T__18) ) { ErrorHandler.RecoverInline(this); } else { Consume(); } State = 148; expr(33); } break; case 7: { _localctx = new AdditionContext(new ExprContext(_parentctx, _parentState)); PushNewRecursionContext(_localctx, _startState, RULE_expr); State = 149; if (!(Precpred(Context, 31))) throw new FailedPredicateException(this, "Precpred(Context, 31)"); State = 150; _la = TokenStream.La(1); if ( !(_la==T__14 || _la==T__15) ) { ErrorHandler.RecoverInline(this); } else { Consume(); } State = 151; expr(32); } break; case 8: { _localctx = new ComparisonContext(new ExprContext(_parentctx, _parentState)); PushNewRecursionContext(_localctx, _startState, RULE_expr); State = 152; if (!(Precpred(Context, 30))) throw new FailedPredicateException(this, "Precpred(Context, 30)"); State = 153; _la = TokenStream.La(1); if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__19) | (1L << T__20) | (1L << T__21) | (1L << T__22) | (1L << T__23) | (1L << T__24))) != 0)) ) { ErrorHandler.RecoverInline(this); } else { Consume(); } State = 154; expr(31); } break; case 9: { _localctx = new LogicalAndContext(new ExprContext(_parentctx, _parentState)); PushNewRecursionContext(_localctx, _startState, RULE_expr); State = 155; if (!(Precpred(Context, 28))) throw new FailedPredicateException(this, "Precpred(Context, 28)"); State = 156; _la = TokenStream.La(1); if ( !(_la==T__26 || _la==T__27) ) { ErrorHandler.RecoverInline(this); } else { Consume(); } State = 157; expr(29); } break; case 10: { _localctx = new LogicalOrContext(new ExprContext(_parentctx, _parentState)); PushNewRecursionContext(_localctx, _startState, RULE_expr); State = 158; if (!(Precpred(Context, 27))) throw new FailedPredicateException(this, "Precpred(Context, 27)"); State = 159; _la = TokenStream.La(1); if ( !(_la==T__28 || _la==T__29) ) { ErrorHandler.RecoverInline(this); } else { Consume(); } State = 160; expr(28); } break; case 11: { _localctx = new FormulaeContext(new ExprContext(_parentctx, _parentState)); PushNewRecursionContext(_localctx, _startState, RULE_expr); State = 161; if (!(Precpred(Context, 25))) throw new FailedPredicateException(this, "Precpred(Context, 25)"); State = 162; Match(T__30); State = 163; expr(26); } break; case 12: { _localctx = new RightAssignmentContext(new ExprContext(_parentctx, _parentState)); PushNewRecursionContext(_localctx, _startState, RULE_expr); State = 164; if (!(Precpred(Context, 24))) throw new FailedPredicateException(this, "Precpred(Context, 24)"); State = 165; _la = TokenStream.La(1); if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__31) | (1L << T__32) | (1L << T__33))) != 0)) ) { ErrorHandler.RecoverInline(this); } else { Consume(); } State = 166; expr(25); } break; case 13: { _localctx = new ListAccessContext(new ExprContext(_parentctx, _parentState)); PushNewRecursionContext(_localctx, _startState, RULE_expr); State = 167; if (!(Precpred(Context, 41))) throw new FailedPredicateException(this, "Precpred(Context, 41)"); State = 168; Match(T__4); State = 169; sublist(); State = 170; Match(T__5); State = 171; Match(T__5); } break; case 14: { _localctx = new IndexContext(new ExprContext(_parentctx, _parentState)); PushNewRecursionContext(_localctx, _startState, RULE_expr); State = 173; if (!(Precpred(Context, 40))) throw new FailedPredicateException(this, "Precpred(Context, 40)"); State = 174; Match(T__6); State = 175; sublist(); State = 176; Match(T__5); } break; case 15: { _localctx = new FunctionCallContext(new ExprContext(_parentctx, _parentState)); PushNewRecursionContext(_localctx, _startState, RULE_expr); State = 178; if (!(Precpred(Context, 39))) throw new FailedPredicateException(this, "Precpred(Context, 39)"); State = 179; Match(T__7); State = 180; sublist(); State = 181; Match(T__8); } break; } } } State = 187; ErrorHandler.Sync(this); _alt = Interpreter.AdaptivePredict(TokenStream,14,Context); } } } catch (RecognitionException re) { _localctx.exception = re; ErrorHandler.ReportError(this, re); ErrorHandler.Recover(this, re); } finally { UnrollRecursionContexts(_parentctx); } return _localctx; }
public SharedNamespaceContext(NamespaceContext context, CancellationToken cancellationToken) : base(context) { _context = context; _cancellationToken = cancellationToken; }
public override string ToString() { string fullName = Name; return(Name == "" ? "Unknown" : (NamespaceContext.NamespaceHierarchy.Length == 0 ? fullName : NamespaceContext.ToString() + '.' + fullName)); }
public override string ToString() { string fullName = Name + '<' + string.Join(',', GenericParameters.GetEnumerator()) + '>'; return(Name == "" ? "Unknown" : (NamespaceContext.NamespaceHierarchy.Length == 0 ? fullName : NamespaceContext.ToString() + '.' + fullName)); }
async Task RemoveSubscriptions(NamespaceContext context) { await Task.WhenAll(_brokerTopology.QueueSubscriptions.Select(subscription => Delete(context, subscription))).ConfigureAwait(false); }
public static void Parse(this CSharpParser.Namespace_member_declarationContext context, NamespaceContext ns) { if (context.namespace_declaration() != null) { context.namespace_declaration().Parse(ns); } else if (context.type_declaration() != null) { context.type_declaration().Parse(); } else { throw new NotSupportedException("Unknown member type! " + context.GetText()); } }
Task Create(NamespaceContext context, Topic topic) { return(context.CreateTopic(topic.TopicDescription)); }
public static void Parse(this CSharpParser.Namespace_declarationContext context, NamespaceContext ns) { context.namespace_body().Parse(ns, context.qualified_identifier().GetText()); }
private Operator ResolvePatternReferences(Operator op, IList <Pattern> localPatterns, NamespaceContext context) { var mapping = new Dictionary <Operator, Operator>(); var stack = new Stack <Operator>(); PushItem(stack, op); while (stack.Count > 0) { var current = stack.Pop(); if (current is Pattern p && p.Data == null) { var currentContext = context; if (current is NamespacedPattern np) { currentContext = LoadNamespace(np.NamespacePath); } var localPatternReference = localPatterns?.FirstOrDefault(item => item.Name == p.Name); if (localPatternReference != null) { mapping[current] = localPatterns.First(item => item.Name == p.Name); } else { var actualPattern = p is NamespacedPattern npp ? npp.FinalPattern : p; var loadedPattern = currentContext.GetPattern(actualPattern, context == currentContext); if (loadedPattern is ParameterizedPattern pp) { var currentPp = (ParameterizedPattern)actualPattern; var innerMapping = new Dictionary <Operator, Operator>(); for (var i = 0; i < pp.Parameters.Count; i++) { var k = currentPp.Parameters[i]; if (mapping.TryGetValue(k, out var mappedValue)) { k = (Pattern)mappedValue; } innerMapping[pp.Parameters[i]] = k; } loadedPattern = RemapPattern(currentPp.Parameters, (ParameterizedPattern)loadedPattern, innerMapping); } mapping[current] = loadedPattern; } }
public override bool VisitStmtVarDefFull([NotNull] GamaParser.StmtVarDefFullContext context) { var name = context.Symbol().GetText(); var val = Top.FindValue(name); if (val != null) { NamespaceContext.Context.AddError(new ErrorDuplicateVariable(context)); return(false); } var ty = NamespaceContext.FindTypeRefGlobal(context.typeName()); if (ty == null) { NamespaceContext.Context.AddError(new ErrorTypeNotFound(context.typeName())); return(false); } if (ty == InstanceTypes.Void) { NamespaceContext.Context.AddError(new ErrorVariableVoid(context.typeName())); return(false); } val = VisitExpression(ty, context.expr()); if (val == null) { return(false); } // If expression compiler returns a function then it's impossible for a type mismatch to happen // Expression compiler checks for type mismatches when evaluating function pointers // Alsp no need to check if 'ty' is a GamaFunction either, expressiom compiler already did that if (val.Type is GamaFunction valtyfn) { var tyfn = new GamaPointer(ty as GamaFunction); /* LLVM */ CurrentBlock.PositionBuilderAtEnd(Builder); var alloc = Builder.BuildAlloca(tyfn.UnderlyingType, name); Builder.BuildStore(val.Value, alloc); Top.AddValue(name, new GamaValueRef(ty, alloc, true)); return(true); } // If not function, there might be a mismatch. Check it and error if it mismatches if (val.Type != ty) { NamespaceContext.Context.AddError(new ErrorTypeMismatch(context.expr())); return(false); } /* LLVM */ // One block above to avoid dumb C# error message saying 'alloc' is already defined (SOMEHOW) { CurrentBlock.PositionBuilderAtEnd(Builder); var alloc = Builder.BuildAlloca(ty.UnderlyingType, name); Builder.BuildStore(val.Value, alloc); Top.AddValue(name, new GamaValueRef(ty, alloc, true)); } return(true); }
public async Task Start(NamespaceContext context) { var options = new SessionHandlerOptions { AutoComplete = false, AutoRenewTimeout = _clientSettings.AutoRenewTimeout, MaxConcurrentSessions = _clientSettings.MaxConcurrentCalls, MessageWaitTimeout = _clientSettings.MessageWaitTimeout }; options.ExceptionReceived += (sender, x) => { if (!(x.Exception is OperationCanceledException)) { if (_log.IsErrorEnabled) _log.Error($"Exception received on session receiver: {_clientContext.InputAddress} during {x.Action}", x.Exception); } if (_tracker.ActiveDeliveryCount == 0) { if (_log.IsDebugEnabled) _log.DebugFormat("Session receiver shutdown completed: {0}", _clientContext.InputAddress); _participant.SetComplete(); } }; IMessageSessionAsyncHandlerFactory handlerFactory = new MessageSessionAsyncHandlerFactory(context, _supervisor, this, _tracker, _sendEndpointProvider, _publishEndpointProvider); await _clientContext.RegisterSessionHandlerFactoryAsync(handlerFactory, options).ConfigureAwait(false); _participant.SetReady(); }
public override bool VisitTopLevelExternDef([NotNull] GamaParser.TopLevelExternDefContext context) { var name = context.Symbol().GetText(); var list = NamespaceContext.FindFunctionRefGlobal(name); if (list == null) { list = new GamaFunctionList(name); NamespaceContext.This.Functions.Add(list); } var retty = InstanceTypes.Void; var rettyfqtn = context.typeName(); if (rettyfqtn != null) { retty = NamespaceContext.FindTypeRefGlobal(rettyfqtn); if (retty == null) { GlobalContext.AddError(new ErrorTypeNotFound(context.typeName())); return(false); } } var ellipsis = context.ellipsis() != null; var parmslist = new GamaParamList(); var argtypes = new GamaTypeRef[0]; var argtypesnative = new LLVMTypeRef[0]; var fqtnlist = context.typeList(); if (fqtnlist != null) { var types = fqtnlist.typeName(); argtypesnative = new LLVMTypeRef[types.Length]; argtypes = new GamaTypeRef[types.Length]; for (int i = 0; i < types.Length; i++) { var ty = NamespaceContext.FindTypeRefGlobal(types[i]); if (ty == null) { GlobalContext.AddError(new ErrorTypeNotFound(types[i])); return(false); } parmslist.Add(i.ToString(), ty); // Adding parameter with a numeric name, doesn't matter since this is a extern. argtypes[i] = ty; argtypesnative[i] = ty.UnderlyingType; } } if (list.FindFunction(parmslist) != null) { GlobalContext.AddError(new ErrorDuplicateFunction(context)); return(false); } var fnty = new GamaFunction(retty, argtypes, LLVMTypeRef.CreateFunction(retty.UnderlyingType, argtypesnative, ellipsis), ellipsis); var modfn = GlobalContext.Module.AddFunction(name, fnty.UnderlyingType); var fnref = new GamaFunctionRef(retty, parmslist, fnty, modfn, false); list.AddFunction(fnref); return(true); }