public ExitCode RunFunctionAsEntry(LlvmFunction function, string[] arguments)
        {
            // Avoid passing environment values as it may cause undefined behaviour.
            int exitCode = LLVM.RunFunctionAsMain(this.reference, function.Unwrap(), (uint)arguments.Length, arguments, new string[] { });

            // Return the exit code wrapped in an exit code helper instance.
            return(new ExitCode(exitCode));
        }
Exemple #2
0
        public LlvmBlock(LlvmFunction parent, LLVMBasicBlockRef reference) : base(reference)
        {
            this.Parent  = parent;
            this.Builder = this.CreateBuilder();

            // TODO: Awaiting LLVMSharp fix (#91).
            // this.Name = LLVM.GetBasicBlockName(reference);
        }
        public LLVMGenericValueRef RunFunction(LlvmFunction function, LLVMGenericValueRef[] arguments)
        {
            // Run the function and capture its result.
            LLVMGenericValueRef result = LLVM.RunFunction(this.reference, function.Unwrap(), arguments);

            // Return the result.
            return(result);
        }
Exemple #4
0
        public LlvmValue CreateCall(LlvmFunction callee, string resultIdentifier, LlvmValue[] arguments)
        {
            // Invoke the native function and capture the resulting reference.
            LLVMValueRef reference = LLVM.BuildCall(this.reference, callee.Unwrap(), arguments.Unwrap(), resultIdentifier);

            // Register the instruction.
            this.instructions.Add(reference.Wrap());

            // Wrap and return the reference.
            return(new LlvmValue(reference));
        }
Exemple #5
0
        public LlvmFunction CreateFunction(string identifier, LlvmType type)
        {
            // Create the function.
            LLVMValueRef function = LLVM.AddFunction(this.reference, identifier, type.Unwrap());

            // Add and wrap the function.
            LlvmFunction reference = new LlvmFunction(this, function);

            // Cache the function locally.
            this.functions.Add(identifier, reference);

            // Return the function.
            return(reference);
        }
Exemple #6
0
 public void RegisterFunction(LlvmFunction function)
 {
     this.functions.Add(function.Name, function);
 }
Exemple #7
0
 public LlvmValue CreateCall(LlvmFunction function, string resultIdentifier)
 {
     // Delegate to the main handler with zero arguments.
     return(this.CreateCall(function, resultIdentifier, new LlvmValue[] { }));
 }
 public ExitCode RunFunctionAsEntry(LlvmFunction function)
 {
     // Delegate to the main handler with zero arguments.
     return(this.RunFunctionAsEntry(function, new string[] { }));
 }
 public LLVMGenericValueRef RunFunction(LlvmFunction function)
 {
     // Delegate to the main handler with zero arguments.
     return(this.RunFunction(function, new LLVMGenericValueRef[] { }));
 }