Esempio n. 1
0
        protected override Expression ParseRight(Scopes.Scope scope, Token[] tokens, Scopes.Scope typeSource)
        {
            var argListClose = ParserHelper.FindClosingScope(
                tokens.Prepend(new Token {
                Value = "("
            }).ToArray(),
                0
                ) - 1;
            var argList = tokens.Take(argListClose).ToArray();

            var arguments = ArgumentsNode.Parse(_functionNode, scope, argList);
            var overload  = Function.GetMatchingOverload(arguments.Arguments, FunctionType.ArgumentParameterSpecificity.ParameterMoreSpecific);

            if (overload == null)
            {
                if (argList.Length > 0)
                {
                    throw new InvalidArgumentsException(argList.FirstOrDefault(), Function, arguments.Arguments);
                }
                else
                {
                    throw new InvalidArgumentsException(tokens[0], Function, arguments.Arguments);
                }
            }

            Function = overload;

            return(new Expression(
                       argList.FirstOrDefault() ?? _functionNode.DefiningToken,
                       scope,
                       arguments
                       ));
        }
        private ArgumentsNode BuildArgumentsNode(SyntaxNodeOrToken node)
        {
            var args = new ArgumentsNode();

            args.AddNode(node);

            return(args);
        }
        public override Expression Compile()
        {
            var blockNode = ArgumentsNode.FirstOrDefault(_ => _.Token.Type == kDO || _.Token.Type == kLBRACE2);

            if (blockNode != null && ArgumentsNode.Any(_ => _.Token.Type == kAMPER))
            {
                var line = blockNode.Token.Location.StartLine;
                throw new SyntaxError(Compiler.Filename, line, "both block arg and actual block given");
            }

            var instance   = GetLeftExpression();
            var arguments  = CompileArguments();
            var methodName = new Symbol(MethodName);
            var visibility = GetVisibility();

            return(CompilerUtils.Call(instance, methodName, visibility, arguments));
        }
Esempio n. 4
0
 public TypeCtorNode(TypeIdentifierNode typeIdentifier, ArgumentsNode arguments) : base(typeIdentifier.Pos, typeIdentifier.Content, LexTokenType.None)
 {
     this.Type      = typeIdentifier;
     this.Arguments = arguments;
 }