<commit_before>=head1 [proc]

Create a PIR sub on the fly for this user defined proc.

=cut

.namespace [ "Tcl" ]

.sub "&proc"
  .param pmc argv :slurpy

  .local int argc
  argc = argv

  if argc != 3 goto error

  .local string name
  name   = argv[0]
  .local pmc args_p
  args_p = argv[1]
  .local pmc body_p
  body_p = argv[2]

  .local pmc retval

  .local pmc compiler,pir_compiler
  compiler = find_global "_Tcl", "compile"
  pir_compiler = find_global "_Tcl", "pir_compiler"

  .local pmc __list
  __list = find_global "_Tcl", "__list"

  args_p = __list(args_p)
  .local string args
  args = args_p

got_args:

  # Save the parsed body.
  .local pmc parsed_body
  $S0 = body_p
  ($I0,$P0) = compiler(0,$S0)
  parsed_body = pir_compiler($I0,$P0)
  register parsed_body

  # XXX these need to go away - for now, we'll just escape
  # the code portion and put it, escaped, into the proc
  # definition. The arg list will be used to generate the proc's
  # indvidual argument handling code.

  # Now, shove the parsed routine into the global hash...
  $P0 = find_global "_Tcl", "proc_parsed"
  $P0[name] = parsed_body

  # Save the code for the proc for [info body]
  $P1 = find_global "_Tcl", "proc_body"
  $P1[name] = body_p

  # Save the args for the proc for [info body]
  # XXX When dealing with defaults, this will have to be updated.
  $P1 = find_global "_Tcl", "proc_args"
  $P1[name] = args_p

  .local pmc escaper
  escaper = find_global "Data::Escape", "String"
  .local string esc_name
  esc_name = escaper(name)

  .local string proc_body, temp_code

  temp_code = <<"END_PIR"
.namespace ['Tcl']
.sub '&%s'<commit_msg>tcl: Store Sub PMCs instead of Eval PMCs and fix lexical issues<commit_after>=head1 [proc]

Create a PIR sub on the fly for this user defined proc.

=cut

.namespace [ "Tcl" ]

.sub "&proc"
  .param pmc argv :slurpy

  .local int argc
  argc = argv

  if argc != 3 goto error

  .local string name
  name   = argv[0]
  .local pmc args_p
  args_p = argv[1]
  .local pmc body_p
  body_p = argv[2]

  .local pmc retval

  .local pmc compiler,pir_compiler
  compiler = find_global "_Tcl", "compile"
  pir_compiler = find_global "_Tcl", "pir_compiler"

  .local pmc __list
  __list = find_global "_Tcl", "__list"

  args_p = __list(args_p)
  .local string args
  args = args_p

got_args:

  # Save the parsed body.
  .local pmc parsed_body
  $S0 = body_p
  ($I0,$P0) = compiler(0,$S0)
  $P0 = pir_compiler($I0,$P0)
  parsed_body = $P0[0]

  # XXX these need to go away - for now, we'll just escape
  # the code portion and put it, escaped, into the proc
  # definition. The arg list will be used to generate the proc's
  # indvidual argument handling code.

  # Now, shove the parsed routine into the global hash...
  $P0 = find_global "_Tcl", "proc_parsed"
  $P0[name] = parsed_body

  # Save the code for the proc for [info body]
  $P1 = find_global "_Tcl", "proc_body"
  $P1[name] = body_p

  # Save the args for the proc for [info body]
  # XXX When dealing with defaults, this will have to be updated.
  $P1 = find_global "_Tcl", "proc_args"
  $P1[name] = args_p

  .local pmc escaper
  escaper = find_global "Data::Escape", "String"
  .local string esc_name
  esc_name = escaper(name)

  .local string proc_body, temp_code

  temp_code = <<"END_PIR"
.namespace ['Tcl']
.sub '&%s'
{'fraction_non_alphanumeric': 0.10608800482218204, 'fraction_numerical': 0.011754068716094032, 'mean_word_length': 3.3272490221642763, 'pattern_counts': {'":': 0, '<': 7, '<?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': '1990909', 'n_tokens_mistral': 1256, 'n_tokens_neox': 1224, 'n_words': 422}