Пример #1
0
        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));
        }
Пример #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);
        }
Пример #3
0
        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);
        }
Пример #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));
        }
Пример #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);
        }
Пример #6
0
 public void RegisterFunction(LlvmFunction function)
 {
     this.functions.Add(function.Name, function);
 }
Пример #7
0
 public LlvmValue CreateCall(LlvmFunction function, string resultIdentifier)
 {
     // Delegate to the main handler with zero arguments.
     return(this.CreateCall(function, resultIdentifier, new LlvmValue[] { }));
 }
Пример #8
0
 public ExitCode RunFunctionAsEntry(LlvmFunction function)
 {
     // Delegate to the main handler with zero arguments.
     return(this.RunFunctionAsEntry(function, new string[] { }));
 }
Пример #9
0
 public LLVMGenericValueRef RunFunction(LlvmFunction function)
 {
     // Delegate to the main handler with zero arguments.
     return(this.RunFunction(function, new LLVMGenericValueRef[] { }));
 }