<commit_before>module Twostroke::Runtime::Types
  class Function < Object
    def self.constructor_function
      unless defined?(@@constructor_function)
        @@constructor_function = nil # lock the Function constructor out from here...
        @@created_funcs = 0
        @@constructor_function = Function.new(->(scope, this, args) {
          formal_parameters = (args.size > 1 ? args[0...-1] : []).map { |a| Twostroke::Runtime::Types.to_string(a).string }
          src = Twostroke::Runtime::Types.to_string(args[-1] || Undefined.new).string
          
          parser = Twostroke::Parser.new(Twostroke::Lexer.new(src))
          parser.parse

          @@created_funcs += 1
          fun_ast = Twostroke::AST::Function.new name: "anonymous", arguments: formal_parameters, statements: parser.statements
          compiler = Twostroke::Compiler::TSASM.new [fun_ast], "runtime_created_#{@@created_funcs}_"
          compiler.compile
          
          vm = scope.global_scope.vm
          compiler.bytecode.each do |k,v|
            vm.bytecode[k] = v
          end<commit_msg>allow comma separated arguments in Function constructor<commit_after>module Twostroke::Runtime::Types
  class Function < Object
    def self.constructor_function
      unless defined?(@@constructor_function)
        @@constructor_function = nil # lock the Function constructor out from here...
        @@created_funcs = 0
        @@constructor_function = Function.new(->(scope, this, args) {
          formal_parameters = (args.size > 1 ? args[0...-1] : [])
                              .map { |a| Twostroke::Runtime::Types.to_string(a).string }
                              .map { |a| a.split "," }
                              .flatten
          src = Twostroke::Runtime::Types.to_string(args[-1] || Undefined.new).string
          
          parser = Twostroke::Parser.new(Twostroke::Lexer.new(src))
          parser.parse

          @@created_funcs += 1
          fun_ast = Twostroke::AST::Function.new name: "anonymous", arguments: formal_parameters, statements: parser.statements
          compiler = Twostroke::Compiler::TSASM.new [fun_ast], "runtime_created_#{@@created_funcs}_"
          compiler.compile
          
          vm = scope.global_scope.vm
          compiler.bytecode.each do |k,v|
            vm.bytecode[k] = v
          end
{'fraction_non_alphanumeric': 0.12248394004282655, 'fraction_numerical': 0.005139186295503212, 'mean_word_length': 2.395348837209302, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '2219772', 'n_tokens_mistral': 668, 'n_tokens_neox': 646, 'n_words': 129}