Beispiel #1
0
        public override Value?Visit(FunctionCallExpression functionCall)
        {
            functionCall.ValidateNotNull(nameof(functionCall));
            string targetName = functionCall.FunctionPrototype.Name;

            IrFunction?function;

            if (RuntimeState.FunctionDeclarations.TryGetValue(targetName, out Prototype target))
            {
                function = GetOrDeclareFunction(target);
            }
            else if (!Module.TryGetFunction(targetName, out function))
            {
                throw new CodeGeneratorException($"Definition for function {targetName} not found");
            }

            var args = (from expr in functionCall.Arguments
                        select expr.Accept(this) ?? throw new CodeGeneratorException(ExpectValidExpr)
                        ).ToArray();

            return(InstructionBuilder.Call(function, args).RegisterName("calltmp"));
        }