<commit_before>module LLVM
  module Builder
    class Action
      def initialize(&action)
        @action = action
      end
      
      def call(fun, builder)
        @value ||= @action.(fun, builder)
      end
    end
    
    module_function
    
    def action
      Action.new { |f,b| yield f,b }
    end
    
    def const(val)
      action { |_,_| val }
    end
    
    def seq(*actions)
      actions.reduce { |fst, snd|
        action { |f,b|
          fst.(f,b); snd.(f,b)
        }
      }
    end
    
    def recur(*args)
      action { |f,b| call(f, *args).(f,b) }
    end
    
    def current_block
      action { |f,b| C.LLVMGetInsertBlock(b) }
    end
    
    def int64(n)
      const(LLVM::Int64.from_i(n).to_ptr)
    end
    
    def basic_block(name = "block")
      action { |f,b|
        block = C.LLVMAppendBasicBlock(f.to_ptr, name)
        prev = C.LLVMGetInsertBlock(b)
        begin
          C.LLVMPositionBuilderAtEnd(b, block) # push
          yield(const(block)).(f, b)
        ensure
          C.LLVMPositionBuilderAtEnd(b, prev) # pop
        end
        block
      }<commit_msg>Added float and int32 constructors to LLVM::Builder.<commit_after>module LLVM
  module Builder
    class Action
      def initialize(&action)
        @action = action
      end
      
      def call(fun, builder)
        @value ||= @action.(fun, builder)
      end
    end
    
    module_function
    
    def action
      Action.new { |f,b| yield f,b }
    end
    
    def const(val)
      action { |_,_| val }
    end
    
    def seq(*actions)
      actions.reduce { |fst, snd|
        action { |f,b|
          fst.(f,b); snd.(f,b)
        }
      }
    end
    
    def recur(*args)
      action { |f,b| call(f, *args).(f,b) }
    end
    
    def current_block
      action { |f,b| C.LLVMGetInsertBlock(b) }
    end
    
    def float(x)
      const(LLVM::Float.from_f(x).to_ptr)
    end
    
    def int32(n)
      const(LLVM::Int32.from_i(n).to_ptr)
    end
    
    def int64(n)
      const(LLVM::Int64.from_i(n).to_ptr)
    end
    
    def basic_block(name = "block")
      action { |f,b|
        block = C.LLVMAppendBasicBlock(f.to_ptr, name)
        prev = C.LLVMGetInsertBlock(b)
        begin
          C.LLVMPositionBuilderAtEnd(b, block) # push
          yield(const(block)).(f, b)
        ensure
          C.LLVMPositionBuilderAtEnd(b, prev) # pop
        end
        block
      }
{'fraction_non_alphanumeric': 0.11625982623086471, 'fraction_numerical': 0.005792304509722797, 'mean_word_length': 1.6455142231947484, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3666715', 'n_tokens_mistral': 875, 'n_tokens_neox': 858, 'n_words': 176}