public void LeftHandSideExpression_matches_identifier_body_with_no_arguments() { var expected = new CallExpression( new IdentifierExpression("foo", new SourceRange(1,3,1,1)), new IExpression[0], new SourceRange(1,5,1,1) ); var match = EmdGrammar.LeftHandSideExpression.ShouldMatchAllOf("@foo()"); match.Product.ShouldBeEquivalentTo(expected); }
public void LeftHandSideExpression_matches_identifier_body_with_arguments() { var expected = new CallExpression( new IdentifierExpression("foo", new SourceRange(1,3,1,1)), new IExpression[] { new NumericLiteralExpression(1d, new SourceRange(5,1,1,5)), new StringLiteralExpression("2", new SourceRange(7,3,1,7)) }, new SourceRange(1,10,1,1) ); var match = EmdGrammar.LeftHandSideExpression.ShouldMatchAllOf("@foo(1,'2')"); match.Product.ShouldBeEquivalentTo(expected); }
private Object evalCallExpression(Object context, CallExpression call) { Object result; string name = call.Function.Literal; if (context[name] is Callable target) { List <Object> callParams = new List <Object>(); foreach (Expression param in call.Parameters) { callParams.Add(Eval(ExecutionContext.Peek(), param)); } result = target.Invoke(callParams); } else { throw new System.Exception("The object named \'" + name + "\' is not a function."); } return(result); }
private static CallExpression ParseCallExpressionWithoutType(BinaryReader reader, CodeSectionInfo codeSectionInfo, int blockId, out string unvalidCode, out string comment, out bool mask) { int methodId = reader.ReadInt32(); short libraryId = reader.ReadInt16(); short num = reader.ReadInt16(); unvalidCode = reader.ReadStringWithLengthPrefix(); comment = reader.ReadStringWithLengthPrefix(); mask = (num == 1 || num == 32); if ("".Equals(unvalidCode)) { unvalidCode = null; } if ("".Equals(comment)) { comment = null; } CallExpression callExpression = new CallExpression(libraryId, methodId, codeSectionInfo); if (reader.BaseStream.Position != reader.BaseStream.Length) { switch (reader.ReadByte()) { case 54: callExpression.ParamList = ParseParamList(reader, codeSectionInfo, blockId); break; case 56: reader.BaseStream.Position -= 1L; callExpression.Target = ParseExpression(reader, codeSectionInfo, blockId, true); callExpression.ParamList = ParseParamList(reader, codeSectionInfo, blockId); break; default: reader.BaseStream.Position -= 1L; throw new Exception(); } } return(callExpression); }
private static bool IsJasmineInvocation(CallExpression expr) { var callee = expr.Callee; switch (callee.Type) { case SyntaxNodes.Identifier: var identifier = callee.As <Identifier>(); return(Constants.FunctionIdentifiers.SuiteFunctions.Contains(identifier.Name)); case SyntaxNodes.MemberExpression: var member = callee.As <MemberExpression>(); if (member.Property.Type == SyntaxNodes.Identifier) { var property = member.Property.As <Identifier>(); return(Constants.FunctionIdentifiers.SuiteFunctions.Contains(property.Name)); } break; } return(false); }
protected override Expression Transform(CallExpression lx) { if (lx.Operands.Length != 2) { return(base.Transform(lx)); } if (Operators.SameOperator(lx.OperatorName, Operators.IntermediateOpLike)) { return(TryCompileLikeExpression(lx.IgnoreCase, lx.Operands[0], lx.Operands[1])); } if (Operators.SameOperator(lx.OperatorName, Operators.IntermediateOpNotLike)) { return(new CallExpression( false, Operators.RuntimeOpStrictNot, TryCompileLikeExpression(lx.IgnoreCase, lx.Operands[0], lx.Operands[1]))); } return(base.Transform(lx)); }
public void Equals() { CallExpression expr1 = new CallExpression("puts", new IExpression[] { new ConstantExpression(1) }); CallExpression expr2 = new CallExpression("put", new IExpression[] { new ConstantExpression(1) }); CallExpression expr3 = new CallExpression("puts", new IExpression[] { new ConstantExpression(2) }); CallExpression expr4 = new CallExpression("puts", new IExpression[] { new ConstantExpression(2), new ConstantExpression(3) }); CallExpression expr5 = new CallExpression("puts", new IExpression[] { new ConstantExpression(1) }); Assert.IsTrue(expr1.Equals(expr5)); Assert.IsTrue(expr5.Equals(expr1)); Assert.AreEqual(expr1.GetHashCode(), expr5.GetHashCode()); Assert.IsFalse(expr1.Equals(null)); Assert.IsFalse(expr1.Equals(123)); Assert.IsFalse(expr1.Equals(expr2)); Assert.IsFalse(expr2.Equals(expr1)); Assert.IsFalse(expr1.Equals(expr3)); Assert.IsFalse(expr3.Equals(expr1)); Assert.IsFalse(expr1.Equals(expr4)); Assert.IsFalse(expr4.Equals(expr1)); }
public async Task <IMember> GetValueFromClassCtorAsync(IPythonClassType cls, CallExpression expr, CancellationToken cancellationToken = default) { await SymbolTable.EvaluateAsync(cls.ClassDefinition, cancellationToken); // Determine argument types var args = ArgumentSet.Empty; var init = cls.GetMember <IPythonFunctionType>(@"__init__"); if (init != null) { var a = new ArgumentSet(init, new PythonInstance(cls), expr, Module, this); if (a.Errors.Count > 0) { AddDiagnostics(a.Errors); } else { args = await a.EvaluateAsync(cancellationToken); } } return(cls.CreateInstance(cls.Name, GetLoc(expr), args)); }
private static bool IsRequireCall(CallExpression expr) { var callee = expr.Callee; switch (callee.Type) { case SyntaxNodes.Identifier: var identifier = callee.As <Identifier>(); return(string.Equals(identifier.Name, @"require", StringComparison.CurrentCulture)); case SyntaxNodes.MemberExpression: var member = callee.As <MemberExpression>(); if (member.Property.Type == SyntaxNodes.Identifier) { var property = member.Property.As <Identifier>(); return(string.Equals(property.Name, @"require", StringComparison.CurrentCulture)); } break; } return(false); }
public Node VisitExpression(CallExpression exp) { var newCode = exp; foreach (var edit in _edits) { if (edit.CanApply(exp)) { if (edit is Update) { newCode = (CallExpression)edit.ModifiedNode.InnerNode; } else if (edit is Insert) { switch (((Insert)edit).Index) { case 1: var args = new List <Arg>(); args.Add((Arg)edit.ModifiedNode.InnerNode); args.AddRange(exp.Args); newCode = new CallExpression(exp.Target, args.ToArray()); break; default: throw new NotImplementedException(); } } else { throw new NotImplementedException(); } } } var newArgs = newCode.Args.Select(VisitArg); return(new CallExpression(VisitExpression(exp.Target), newArgs.ToArray())); }
protected override string VisitFunctionCall(CallExpression exp, out object resultObj) { var function = exp.Name; var paramBuilder = new StringBuilder(); var iParam = 0; foreach (var parameter in exp.Parameters) { var paramStr = Visit(parameter as IExpression); paramBuilder.Append(paramStr); if (iParam < exp.Parameters.Count - 1) { paramBuilder.Append(", "); } iParam++; } var jsFunction = JsFunctions.Resolve(function, exp.Parameters); resultObj = null; var result = $"{jsFunction}({paramBuilder})"; return(result); }
public object VisitCallExpression(CallExpression expression) { var callee = Evaluate(expression.Callee); var arguments = new List <object>(); foreach (var argument in expression.Arguments) { arguments.Add(Evaluate(argument)); } if (!(callee is ILoxCallable function)) { throw new LoxRunTimeException(expression.Paren, "Can only call functions and classes."); } if (arguments.Count != function.Arity) { throw new LoxRunTimeException(expression.Paren, $"Expected {function.Arity} arguments but got {arguments.Count}."); } return(function.Call(this, arguments)); }
/// <summary> /// /// </summary> /// <returns></returns> public CallExpression ReadFunctionCall() { var f = new CallExpression(); var tknFunctionName = Reader.DiscardToken(TokenType.Symbol); Reader.DiscardToken(TokenType.OpenParenthesis); f.Name = tknFunctionName.Value; var cursor = Reader.Marker.Clone(); //Create a predicate untill the closing of the function var fnEndPredicate = DonutSyntaxReader.Filters.FunctionCallEnd(cursor); while (!Reader.IsComplete && !fnEndPredicate(Reader.Marker)) { ParameterExpression fnParameter = ReadFunctionParameter(); f.AddParameter(fnParameter); if (Reader.Current.TokenType == TokenType.Comma) { Reader.DiscardToken(); } } Reader.DiscardToken(TokenType.CloseParenthesis); return(f); }
public void EvaluateMakeVectorCallExpression() { Context context = new Context(); context.SetValue("one", 1); context.SetValue("two", 2); context.SetValue("three", 3); context.SetValue("c", new MakeVector()); var expr = new CallExpression(new NameExpression("c"), new IExpression[] { new NameExpression("one"), new NameExpression("two"), new NameExpression("three") }, null); var result = expr.Evaluate(context); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(Vector)); var vector = (Vector)result; Assert.AreEqual(3, vector.Length); Assert.AreEqual(1, vector[0]); Assert.AreEqual(2, vector[1]); Assert.AreEqual(3, vector[2]); }
private bool IsBaseConstructor(Node node) { if (node.Kind != NodeKind.ExpressionStatement) { return(false); } ExpressionStatement expStatement = node as ExpressionStatement; if (expStatement.Expression.Kind != NodeKind.CallExpression) { return(false); } CallExpression callExp = expStatement.Expression as CallExpression; if (callExp.Expression.Kind != NodeKind.SuperKeyword) { return(false); } return(true); }
protected override Expression Transform(CallExpression lx) { if (lx.Operands.Length != 2) { return(base.Transform(lx)); } if (Operators.SameOperator(lx.OperatorName, Operators.OpIndexOfMatch)) { return(TryCompileIndexOfMatch(lx.IgnoreCase, lx.Operands[0], lx.Operands[1])); } if (Operators.SameOperator(lx.OperatorName, Operators.OpIsMatch)) { return(new CallExpression( false, Operators.RuntimeOpNotEqual, TryCompileIndexOfMatch(lx.IgnoreCase, lx.Operands[0], lx.Operands[1]), new ConstantExpression(new ScalarValue(-1)))); } return(base.Transform(lx)); }
public IMember GetValueFromInstanceCall(IPythonInstance pi, CallExpression expr) { // Call on an instance such as 'a = 1; a()' // If instance is a function (such as an unbound method), then invoke it. var type = pi.GetPythonType(); if (type is IPythonFunctionType pft) { return(GetValueFromFunctionType(pft, pi, expr)); } // Try using __call__ var call = type.GetMember("__call__").GetPythonType <IPythonFunctionType>(); if (call != null) { return(GetValueFromFunctionType(call, pi, expr)); } // Optimistically return the instance itself. This happens when the call is // over 'function' that was actually replaced by a instance of a type. return(pi); }
public IEnumerable <AsmLine> Translate(CallExpression ce) { if (Blocks.Program.LibFunc.Contains(ce.Function) || ce.Function == "printd") { yield return(new AsmLine("sub", "rsp", "40")); ce.Context.Push(40); } var opRegs = new List <int>(); foreach (var op in ce.Operands) { foreach (var ex in Translate(op)) { yield return(ex); } opRegs.Add(_regUsed); } for (var i = 0; i < opRegs.Count; i++) { yield return(new AsmLine("mov", $"{RegParams[i]}", $"#{opRegs[i]}#")); } var fun = ce.Function == "printd" ? "printf" : ce.Function; yield return(new AsmLine("call", fun, null)); if (Blocks.Program.LibFunc.Contains(ce.Function) || ce.Function == "printd") { yield return(new AsmLine("add", "rsp", "40")); ce.Context.Pop(40); } yield return(new AsmLine("mov", NewReg(), "rax")); }
private void ProcessRequireCall(ref RequireCall parentCall, CallExpression callExpression, NodeWithChildren parentNode) { var argCount = callExpression.Arguments.Count(); if (argCount < 1 || argCount > 3) { throw new Exception("Invalid number of arguments for require() call " + relativeFileName); } var requireCall = new RequireCall { Type = RequireCallType.Require, ParentNode = parentNode }; if (parentCall != null) { parentCall.Children.Add(requireCall); } else { result.RequireCalls.Add(requireCall); } parentCall = requireCall; var depsNode = callExpression.Arguments[0]; ProcessRequireCallDeps(requireCall, depsNode); if (argCount > 1) { var moduleNode = callExpression.Arguments[1]; requireCall.IsModule = true; this.ProcessModuleDefinition(moduleNode, parentCall, parentNode); } }
/// <summary> /// Walks the right hand side of an assignment where the assignment expression is a call expression. /// Typically the call expression will be a constructor call. /// /// Constructor call: System.Windows.Forms.Form() /// </summary> void WalkAssignmentRhs(CallExpression node) { MemberExpression memberExpression = node.Target as MemberExpression; if (memberExpression != null) { string name = fieldExpression.GetInstanceName(componentCreator); object instance = CreateInstance(name, node); if (instance != null) { if (!fieldExpression.SetPropertyValue(componentCreator, instance)) { AddComponent(fieldExpression.MemberName, instance); } } else { object obj = deserializer.Deserialize(node); if (obj != null) { fieldExpression.SetPropertyValue(componentCreator, obj); } else if (IsResource(memberExpression)) { fieldExpression.SetPropertyValue(componentCreator, GetResource(node)); } else { ThrowCouldNotFindTypeException(memberExpression); } } } else if (node.Target is IndexExpression) { WalkArrayAssignmentRhs(node); } }
public static EocCallExpression Translate(CodeConverter C, CallExpression expr) { var P = C.P; if (expr == null) { return(null); } var paramList = expr.ParamList?.Select(x => EocExpression.Translate(C, x)).ToList(); var countOfDefaultAtEnd = 0; for (int i = paramList.Count - 1; i >= 0; i--) { if (paramList[i] != null) { break; } countOfDefaultAtEnd++; } if (countOfDefaultAtEnd != 0) { paramList.RemoveRange(paramList.Count - countOfDefaultAtEnd, countOfDefaultAtEnd); } var result = new EocCallExpression( C, P.GetEocCmdInfo(expr), EocExpression.Translate(C, expr.Target), paramList, expr.LibraryId >= 0 ? P.EocLibs[expr.LibraryId]?.SuperTemplateAssembly : null); if (expr.InvokeSpecial) { result.SpecialScope = "raw_" + P.GetUserDefinedName_SimpleCppName(P.MethodIdToClassMap[expr.MethodId].Id); } return(result); }
internal void AddToDebugCallStack(CallExpression callExpression) { if (callExpression.Callee is Identifier identifier) { var stack = identifier.Name + "("; var paramStrings = new List <string>(); foreach (var argument in callExpression.Arguments) { if (argument != null) { paramStrings.Add(argument is Identifier argIdentifier ? argIdentifier.Name : "null"); } else { paramStrings.Add("null"); } } stack += string.Join(", ", paramStrings.ToArray()); stack += ")"; _debugCallStack.Push(stack); } }
public IExpression ParseExpression() { IExpression expr = this.ParseTerm(); while (true) { if (this.TryParseToken(".", TokenType.Punctuation)) { expr = new DotExpression(expr, this.ParseName()); continue; } if (this.TryParseToken("(", TokenType.Punctuation)) { IList <IExpression> exprs = new List <IExpression>(); while (!this.TryParseToken(")", TokenType.Punctuation)) { if (exprs.Count > 0) { this.ParseToken(",", TokenType.Punctuation); } exprs.Add(this.ParseExpression()); } expr = new CallExpression(expr, exprs); continue; } break; } return(expr); }
public void Visit(CallExpression node) { // only interested if the index is greater than zero, since the zero-index // needs to be a lookup. Also needs to be a brackets-call, and there needs to // be a single argument. if (node != null && m_index > 0 && node.InBrackets && node.Arguments != null && node.Arguments.Count == 1) { // better be a constant wrapper, too var constantWrapper = node.Arguments[0] as ConstantWrapper; if (constantWrapper != null && constantWrapper.PrimitiveType == PrimitiveType.String) { // check the value of the constant wrapper against the current part if (string.CompareOrdinal(constantWrapper.Value.ToString(), m_parts[m_index--]) == 0) { // match! recurse the function after decrementing the index node.Function.Accept(this); } } } }
/// <summary> /// Gets the names which should be in a new scope for isinstance(...) checks. We don't /// use a walker here because we only support a very limited set of assertions (e.g. isinstance(x, type) and ... /// or a bare isinstance(...). /// </summary> internal static void GetIsInstanceNamesAndExpressions(ref List <KeyValuePair <NameExpression, Expression> > names, Expression node) { CallExpression callExpr = node as CallExpression; if (callExpr != null && callExpr.Args.Count == 2) { NameExpression nameExpr = callExpr.Target as NameExpression; if (nameExpr != null && nameExpr.Name == "isinstance") { nameExpr = callExpr.Args[0].Expression as NameExpression; if (nameExpr != null) { if (names == null) { names = new List <KeyValuePair <NameExpression, Expression> >(); } var type = callExpr.Args[1].Expression; names.Add(new KeyValuePair <NameExpression, Expression>(nameExpr, type)); } } } AndExpression andExpr = node as AndExpression; OrExpression orExpr = node as OrExpression; if (andExpr != null) { GetIsInstanceNamesAndExpressions(ref names, andExpr.Left); GetIsInstanceNamesAndExpressions(ref names, andExpr.Right); } else if (orExpr != null) { GetIsInstanceNamesAndExpressions(ref names, orExpr.Left); GetIsInstanceNamesAndExpressions(ref names, orExpr.Right); } }
private IMember GetValueFromCallable(CallExpression expr, LookupOptions options) { if (expr == null || expr.Target == null) { return(null); } var m = GetValueFromExpression(expr.Target); if (m is IPythonType type) { if (type.TypeId == BuiltinTypeId.Type && type == Interpreter.GetBuiltinType(BuiltinTypeId.Type) && expr.Args.Count >= 1) { var aType = GetTypeFromValue(GetValueFromExpression(expr.Args[0].Expression)); if (aType != null) { return(aType); } } return(new AstPythonConstant(type, GetLoc(expr))); } if (m is IPythonFunction fn) { // TODO: Select correct overload and handle multiple return types if (fn.Overloads.Count > 0 && fn.Overloads[0].ReturnType.Count > 0) { return(new AstPythonConstant(fn.Overloads[0].ReturnType[0])); } _log?.Log(TraceLevel.Verbose, "NoReturn", expr.Target.ToCodeString(Ast).Trim()); return(new AstPythonConstant(Interpreter.GetBuiltinType(BuiltinTypeId.NoneType), GetLoc(expr))); } _log?.Log(TraceLevel.Verbose, "UnknownCallable", expr.Target.ToCodeString(Ast).Trim()); return(new AstPythonConstant(_unknownType, GetLoc(expr))); }
/** * Resolve a call to a Function with positional and key-value arguments. * * @param {Object} env * Resolver environment object. * @param {Object} expr * An expression to be resolved. * @param {Object} expr.fun * FTL Function object. * @param {Array} expr.args * FTL Function argument list. * @returns {FluentType} * @private */ static IFluentType CallExpression(ResolverEnvironment env, CallExpression expr) { // Some functions are built-in. Others may be provided by the runtime via // the `MessageContext` constructor. ExternalFunction fn; if (!env.Context.Functions.TryGetValue(expr.Function, out fn) && !BuiltInFunctions.TryGetValue(expr.Function, out fn)) { env.Errors?.Add(new ReferenceError( $"Unknown function: {expr.Function}()")); return(new FluentNone($"{expr.Function}()")); } var posArgs = new List <object>(); var keyArgs = new Dictionary <string, object>(); foreach (var arg in expr.Args) { if (arg is NamedArgument narg) { keyArgs[narg.Name] = ResolveNode(env, narg.Value); } else { posArgs.Add(ResolveNode(env, arg)); } } return(fn(posArgs, keyArgs)); // try { // return callee(posargs, keyargs); // } catch (e) { // // XXX Report errors. // return new FluentNone(); // } }
/// <summary> /// 处理插件调用 /// </summary> /// <returns></returns> private CallExpression ParsePluginCall() { Tokens.MoveToNext(); var command = new CallExpression(Tokens.Current.Position) { Target = ParseBinaryOperator(GeneralParser(TokenType.String, TokenType.Number, TokenType.PluginCallStart, TokenType.Variable, TokenType.Constant, TokenType.LeftParenthesis)) }; while (Tokens.Current.Type != TokenType.PluginCallEnd) { if (Tokens.Current.Type == TokenType.LineBreak) { Tokens.MoveToNext(); continue; } var parameter = new ParameterExpression(Tokens.Current.Position) { Name = ParseBinaryOperator( GeneralParser(TokenType.String, TokenType.Number, TokenType.PluginCallStart, TokenType.Variable, TokenType.Constant, TokenType.LeftParenthesis), 0, TokenType.Equal) }; if (Tokens.Current.Type != TokenType.Equal) { parameter.Value = new EmptyExpression(parameter.Name.Position); command.Parameters.Add(parameter); continue; } Tokens.MoveToNext(); parameter.Value = ParseBinaryOperator(GeneralParser( TokenType.String, TokenType.Number, TokenType.PluginCallStart, TokenType.Variable, TokenType.Constant, TokenType.LeftParenthesis, TokenType.LogicNot)); command.Parameters.Add(parameter); } Tokens.MoveToNext(); return(command); }
public ExprNode ParseLeftHandSideExpression() { var callExp = new CallExpression { Token = Next() }; callExp.Member = ParseMemberExpression(); if (Next().IsNot(TokenType.LeftParen)) return callExp.Member; callExp.Arguments = ParseArguments(); while (true) { switch (Next().Type) { case TokenType.LeftParen: callExp.Suffixes.Add(ParseArguments()); break; case TokenType.LeftBracket: callExp.Suffixes.Add(ParseIndexSuffix()); break; case TokenType.Dot: callExp.Suffixes.Add(ParsePropertyReferenceSuffix()); break; case TokenType.LessThan: Node node; if (Speculate(ParseTypeDescriptorSuffix, out node)) { callExp.Suffixes.Add(node); } else { return callExp; } break; default: return callExp; } } }
public override bool Enter(CallExpression node) { Print("CallExpression"); level++; return true; }
public override void Exit(CallExpression node) { level--; }
public virtual bool Enter(CallExpression node) { return true; }
public virtual void Exit(CallExpression node) { }
public virtual void PostWalk(CallExpression node) { }
public void FullMemberExpression() { CallExpression call = PythonParserHelper.GetCallExpression("self._a.b.Add()"); Assert.AreEqual("self._a.b.Add", PythonControlFieldExpression.GetMemberName(call.Target as MemberExpression)); }
public virtual object Walk(CallExpression node) { if (Enter(node)) { node.Member.Accept(this); if (node.Arguments != null) node.Arguments.Accept(this); foreach (var suffix in node.Suffixes) suffix.Accept(this); } Exit(node); return null; }
public override object Walk(CallExpression node) { return Call(node, node.Suffixes); }
// CallExpression public override bool Walk(CallExpression node) { return Location >= node.StartIndex && Location <= node.EndIndex; }
public void VisitCallExpression(CallExpression callExpr) { throw new NotImplementedException(); }
public override void Accept(CallExpression call) { call.VisitChildren(this); }
private object Call(CallExpression node, IEnumerable<Node> suffixes) { object firstObject; var memberSuffixes = new List<Node>(); if (node.Member is MemberExpression) { var member = (MemberExpression)node.Member; memberSuffixes.AddRange(member.Suffixes); firstObject = GetFirstObjectFromMember(member.Expression, memberSuffixes); } else if (node.Member is FunctionExpression || node.Member is Identifier || node.Member is SelfExpression) { firstObject = node.Member.Accept(this); } else { throw ErrorFactory.CreateError(string.Format("Invalid member type {0}", node.Member)); } var allSuffixes = new List<Node>(); allSuffixes.AddRange(memberSuffixes); allSuffixes.Add(node.Arguments); allSuffixes.AddRange(suffixes); return AccessOneByOne(firstObject, null, allSuffixes); }
public override void Visit(CallExpression node) { // same logic for most nodes TypicalHandler(node); }
public override bool Walk(CallExpression node) { ShouldExecute = false; return base.Walk(node); }
public override bool Walk(CallExpression node) => Save(node, base.Walk(node), _options.Calls);
public override void PostWalk(CallExpression node) { }
// CallExpression public override bool Walk(CallExpression node) { return false; }
void PrintExpression(CallExpression e, int d) { Say("CallExpression("); Say(e.Func.ToString()); SayLn(","); PrintExpressionList(e.Args, d + 1); Say(")"); }
// CallExpression public virtual bool Walk(CallExpression node) { return true; }
private Expression LeftHandSideFollow(Seq<InputElement> newStack, Expression lhs) { switch (Current.Tag) { case InputElementTag.LParen: { var applicand = lhs; var arguments = new Seq<Expression>(); var loc = DelimitedList("call expression arguments", "')' or ','", InputElementTag.Comma, InputElementTag.RParen, () => arguments.Add(AssignmentExpression(false))); LastWasInExpressionContext(); var ce = new CallExpression(lhs.Loc.Union(loc), applicand, arguments); if (newStack.Count > 0) return PopNew(newStack, ce); else return ce; } case InputElementTag.LSquare: { var left = lhs; Consume(); var right = Expression(false); var loc = Only("index expression", "']'", InputElementTag.RSquare); return new IndexExpression(lhs.Loc.Union(loc), left, right); } case InputElementTag.Period: { var left = lhs; Consume(); if (Current.Tag != InputElementTag.Identifier) throw IEError("property access expression", "identifier"); var right = new StringLiteral(Current.Loc, Current.Value); Consume(); return new IndexExpression(lhs.Loc.Union(right.Loc), left, right); } default: return null; } }
public void VisitCallExpression(CallExpression callExpr) { callExpr.Target.AcceptWalker(this); callExpr.Arguments.AcceptWalker(this); }
public virtual object Visit(CallExpression that, object value) { throw new System.NotImplementedException(); }