private bool HighlightArgumentMapping(FunctionCallContext callContext) { int line = textCore.CursorPosition.Y; int column = textCore.CursorPosition.X; int argument = -1; string function = callContext.GetFunctionAtPoint(column, line, out argument); return(HighlightArgumentMapping(function, argument)); }
public static QsiExpressionNode VisitFunctionCall(FunctionCallContext context) { if (context.builtInFunctionCall() != null) { return(VisitBuiltInFunctionCall(context.builtInFunctionCall())); } if (context.nativeFunctionCall() != null) { return(VisitNativeFunctionCall(context.nativeFunctionCall())); } throw TreeHelper.NotSupportedTree(context); }
private bool DisplayOrRetainToolTip(bool forceEvaluation) { // If the function tool-tip is visible, then always re-evaluate to // see if the tool-tip needs to be retained. The forced evaluation // can happen when user keys in '(' character, or press some shortcut // keys to trigger function tool-tip at a function call site. // bool popupVisible = IsFunctionSignaturePopupVisible(); if (popupVisible == false && (!forceEvaluation)) { return(false); } int line = textCore.CursorPosition.Y; int column = textCore.CursorPosition.X; ITextBuffer textBuffer = textCore.CurrentTextBuffer; FunctionCallContext callContext = textBuffer.GetFunctionCallContext(line, column); // We won't need to do anything if the popup is already in the right state. bool validCallContext = (null != callContext && (callContext.IsValidCallContext)); if (popupVisible == validCallContext) { // Highlight (or bold) the current argument based on // the cursor position in the function call context. if (false != popupVisible) { HighlightArgumentMapping(callContext); } return(popupVisible); } if (false == validCallContext) { HideFunctionSignaturePopup(); return(false); // Tool-tip hidden. } if (GenerateCompletionDataForCallContext() == false) { return(false); // Possible compilation failures. } return(HighlightArgumentMapping(callContext)); }
public override Symbol VisitFunctionCall([NotNull] FunctionCallContext context) { var identifier = context.IDENTIFIER().GetText(); var functionArguments = context.functionArguments(); var functionDefinition = callStack.ResolveFunction(identifier); var functionBody = functionDefinition.Body.statementBlock(); seleniumLogger.Log($"Calling function {identifier}", SeleniumScriptLogLevel.InterpreterDetails); Variable[] argumentVariables = null; if (functionDefinition.Parameters.Count > 0 && (context.functionArguments() == null || context.functionArguments().data().Length != functionDefinition.Parameters.Count)) { throw new SeleniumScriptVisitorException( $"Error calling function {identifier}, argument list does not match parameter definition\n" + $"Expecting: {string.Join(", ", functionDefinition.Parameters.Select(x => x.Value + " " + x.Key))}" ); } else if (functionDefinition.Parameters.Count > 0) { argumentVariables = functionArguments.Accept(this).AsArray.Select((x, i) => new Variable(functionDefinition.Parameters.ElementAt(i).Key, functionDefinition.Parameters.ElementAt(i).Value, x)).ToArray(); } callStack.Push(StackFrameScope.Method); if (argumentVariables != null) { foreach (var variable in argumentVariables) { callStack.Current.AddVariable(variable.Name, variable.ReturnType, variable.AsString); } } foreach (var statement in functionBody.statement()) { if (statement.functionReturn() != null) { var data = statement.functionReturn().data().Accept(this).Value; callStack.Pop(); return(new Symbol(string.Empty, functionDefinition.ReturnType, data)); } statement.Accept(this); } callStack.Pop(); return(null); }
private void ShowFunctionSignatureExecuted(object sender, ExecutedRoutedEventArgs e) { int x = textCore.CursorPosition.X; int y = textCore.CursorPosition.Y; ITextBuffer textBuffer = textCore.CurrentTextBuffer; FunctionCallContext callContext = textBuffer.GetFunctionCallContext(y, x); string message = "No function call context"; if ((null != callContext) && callContext.IsValidCallContext) { int argumentIndex = -1; string functionName = callContext.GetFunctionAtPoint(x, y, out argumentIndex); if (!string.IsNullOrEmpty(functionName)) { message = string.Format("Function: {0}, Argument Index: {1}", functionName, argumentIndex); } } this.DisplayStatusMessage(StatusTypes.Info, message, 2); }
public void VisitFunctionExpression(FunctionCallContext context) { var name = context.IDENTIFIER().GetText(); if (!Enum.TryParse(name, out RemoteFunction id)) { throw new Exception($"Could not find remote function with the name of {name}"); } var paramcount = 0; if (context.functionparam() != null) { foreach (var e in context.functionparam().expression()) { VisitExpression(e); builder.OutputOperation(Operation.OpPush); paramcount++; } } builder.OutputOperation(Operation.OpVal, paramcount); builder.OutputOperation(Operation.OpFunc, (int)id); }
public override void ExitFunctionCall([NotNull] FunctionCallContext context) { PopElementStack(); }
public override void EnterFunctionCall([NotNull] FunctionCallContext context) { var e = CreateElementOnStack <FunctionCall>(); GiveChildToParent(e); }
public override void EnterFunctionCall([NotNull] FunctionCallContext context) { inFunction = true; ethGlobal.DebugPrint("Entering function call " + context.Start.Text); }
public override void ExitFunctionCall([NotNull] FunctionCallContext context) { inFunction = false; ethGlobal.DebugPrint("->Exit function call " + context.Start.Text); }
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; }