#include "run-time.h"

/* Typedefs for referenced classes */

typedef struct {
  D wrapper;
  D instanceQ_iep_;
  D debug_name_;
  D class_implementation_class_;
  D class_subtype_bit_;
  D class_module_;
} _KLclassGVKd;

#define  define__KLmm_wrapperGVKi(nrepeated) \
  typedef struct { \
    D wrapper; \
    D mm_wrapper_implementation_class_; \
    D mm_wrapper_subtype_mask_; \
    DWORD mm_wrapper_fixed_part_; \
    DWORD mm_wrapper_variable_part_; \
    D mm_wrapper_number_patterns_; \
    DWORD mm_wrapper_pattern_element_[nrepeated+1]; \
  } _KLmm_wrapperGVKi_##nrepeated;
define__KLmm_wrapperGVKi(1);
define__KLmm_wrapperGVKi(0);

typedef struct {
  D wrapper;
} _KLobjectGVKd;

typedef struct {
  D wrapper;
} _KLunboundGVKe;

typedef struct {
  D wrapper;
} _KLbooleanGVKd;

#define  define__KLsimple_object_vectorGVKd(nrepeated) \
  typedef struct { \
    D wrapper; \
    D size_; \
    D vector_element_[nrepeated+1]; \
  } _KLsimple_object_vectorGVKd_##nrepeated;
define__KLsimple_object_vectorGVKd(0);
define__KLsimple_object_vectorGVKd(16);
define__KLsimple_object_vectorGVKd(1);

#define  define__KLbyte_stringGVKd(nrepeated) \
  typedef struct { \
    D wrapper; \
    D size_; \
    char string_element_[nrepeated+1]; \
  } _KLbyte_stringGVKd_##nrepeated;
define__KLbyte_stringGVKd(0);

typedef struct {
  D wrapper;
  D head_;
  D tail_;
} _KLempty_listGVKd;

typedef struct {
  D wrapper;
  D head_;
  D tail_;
} _KLpairGVKd;

typedef struct {
  D wrapper;
  D xep_;
  D function_signature_;
  D mep_;
} _KLsimple_methodGVKe;

typedef struct {
  D wrapper;
  D instanceQ_iep_;
  D debug_name_;
  D class_implementation_class_;
  D class_subtype_bit_;
  D class_module_;
} _KLfunction_classGVKi;

typedef struct {
  D wrapper;
  D signature_properties_;
  D signature_required_;
  D signature_values_;
} _KLsignatureAvaluesGVKi;

typedef struct {
  D wrapper;
  D xep_;
  D function_signature_;
  D Pgf_cache_;
  D debug_name_;
  D generic_function_methods_;
  D discriminator_;
  D incremental_gf_module_;
  D incremental_gf_domain_info_;
  D incremental_gf_method_libraries_;
  D incremental_gf_properties_;
} _KLincremental_generic_functionGVKe;

#define  define__KLsimple_closure_methodGVKi(nrepeated) \
  typedef struct { \
    D wrapper; \
    D xep_; \
    D function_signature_; \
    D mep_; \
    D environment_size_; \
    D environment_element_[nrepeated+1]; \
  } _KLsimple_closure_methodGVKi_##nrepeated;
define__KLsimple_closure_methodGVKi(0);

typedef struct {
  D wrapper;
  D signature_properties_;
  D signature_required_;
} _KLsignatureGVKe;


/* Typedefs for defined classes */


/* Referenced object declarations */

extern _KLclassGVKd KLclassGVKd;
extern _KLmm_wrapperGVKi_0 KLclassGVKdW;
extern _KLclassGVKd KLmm_wrapperGVKi;
extern _KLmm_wrapperGVKi_1 KLmm_wrapperGVKiW;
extern _KLclassGVKd KLobjectGVKd;
extern _KLmm_wrapperGVKi_0 KLobjectGVKdW;
extern _KLunboundGVKe KPunboundVKi;
extern _KLclassGVKd KLunboundGVKe;
extern _KLmm_wrapperGVKi_0 KLunboundGVKeW;
extern _KLbooleanGVKd KPtrueVKi;
extern _KLclassGVKd KLbooleanGVKd;
extern _KLmm_wrapperGVKi_0 KLbooleanGVKdW;
extern _KLbooleanGVKd KPfalseVKi;
extern _KLclassGVKd KLsimple_object_vectorGVKd;
extern _KLmm_wrapperGVKi_0 KLsimple_object_vectorGVKdW;
D Kconcatenate_asVKdMM3I (D, D, D);
extern _KLclassGVKd KLbyte_stringGVKd;
extern _KLmm_wrapperGVKi_0 KLbyte_stringGVKdW;
extern _KLempty_listGVKd KPempty_listVKi;
extern _KLclassGVKd KLempty_listGVKd;
extern _KLmm_wrapperGVKi_0 KLempty_listGVKdW;
extern _KLclassGVKd KLpairGVKd;
extern _KLmm_wrapperGVKi_0 KLpairGVKdW;
extern _KLsimple_methodGVKe Kconcatenate_asVKdMM0;
extern _KLfunction_classGVKi KLsimple_methodGVKe;
extern _KLclassGVKd KLfunction_classGVKi;
extern _KLmm_wrapperGVKi_0 KLfunction_classGVKiW;
extern _KLmm_wrapperGVKi_0 KLsimple_methodGVKeW;
extern _KLsimple_methodGVKe Kconcatenate_asVKdMM1;
extern _KLclassGVKd KLsignatureAvaluesGVKi;
extern _KLmm_wrapperGVKi_0 KLsignatureAvaluesGVKiW;
extern _KLsimple_object_vectorGVKd_16 KDsignature_Lbyte_stringG_typesVKi;
D Kelement_range_errorVKeI (D, D);
extern _KLincremental_generic_functionGVKe Kfind_keyVKd;
extern _KLfunction_classGVKi KLincremental_generic_functionGVKe;
extern _KLmm_wrapperGVKi_0 KLincremental_generic_functionGVKeW;
extern _KLsimple_object_vectorGVKd_0 KPempty_vectorVKi;
extern _KLincremental_generic_functionGVKe KAVKd;
D Kcopy_sequenceVKdMM3I (D, D, D, D);
extern _KLbyte_stringGVKd_0 KPempty_stringVKi;
D Kconcatenate_2VKeMM1I (D, D);
extern _KLsimple_methodGVKe KEEVKd;
extern _KLfunction_classGVKi KLsimple_closure_methodGVKi;
extern _KLmm_wrapperGVKi_0 KLsimple_closure_methodGVKiW;
extern _KLclassGVKd KLsignatureGVKe;
extern _KLmm_wrapperGVKi_0 KLsignatureGVKeW;

/* Defined object declarations */

extern _KLsimple_methodGVKe Kstrip_gristYjam_internalsVjam;
D Kstrip_gristYjam_internalsVjamI (D);
extern _KLsimple_methodGVKe Kextract_gristYjam_internalsVjam;
D Kextract_gristYjam_internalsVjamI (D);
extern _KLsimple_methodGVKe Kadd_gristYjam_internalsVjam;
D Kadd_gristYjam_internalsVjamI (D, D);
static _KLpairGVKd K6;
static _KLpairGVKd K7;
static _KLsignatureAvaluesGVKi K8;
static _KLsimple_closure_methodGVKi_0 Kanonymous_of_extract_gristF11;
static D Kanonymous_of_extract_gristF11I (D);
static _KLsignatureGVKe K12;
static _KLsignatureAvaluesGVKi K13;
static _KLsimple_closure_methodGVKi_0 Kanonymous_of_strip_gristF16;
static D Kanonymous_of_strip_gristF16I (D);

/* Indirection variables */


/* Variables */

D extract_gristYjam_internalsVjam = &Kextract_gristYjam_internalsVjam;
D strip_gristYjam_internalsVjam = &Kstrip_gristYjam_internalsVjam;
D add_gristYjam_internalsVjam = &Kadd_gristYjam_internalsVjam;

/* Objects */

_KLsimple_methodGVKe Kstrip_gristYjam_internalsVjam = {
  &KLsimple_methodGVKeW /* wrapper */,
  &xep_1,
  &K13,
  &Kstrip_gristYjam_internalsVjamI
};

_KLsimple_methodGVKe Kextract_gristYjam_internalsVjam = {
  &KLsimple_methodGVKeW /* wrapper */,
  &xep_1,
  &K13,
  &Kextract_gristYjam_internalsVjamI
};

_KLsimple_methodGVKe Kadd_gristYjam_internalsVjam = {
  &KLsimple_methodGVKeW /* wrapper */,
  &xep_2,
  &K8,
  &Kadd_gristYjam_internalsVjamI
};

static _KLpairGVKd K6 = {
  &KLpairGVKdW /* wrapper */,
  &Kconcatenate_asVKdMM1,
  &K7
};

static _KLpairGVKd K7 = {
  &KLpairGVKdW /* wrapper */,
  &Kconcatenate_asVKdMM0,
  &KPempty_listVKi
};

static _KLsignatureAvaluesGVKi K8 = {
  &KLsignatureAvaluesGVKiW /* wrapper */,
  (D) 33555465,
  &KDsignature_Lbyte_stringG_typesVKi,
  &KDsignature_Lbyte_stringG_typesVKi
};

static _KLsimple_closure_methodGVKi_0 Kanonymous_of_extract_gristF11 = {
  &KLsimple_closure_methodGVKiW /* wrapper */,
  &rest_xep_0,
  &K12,
  &Kanonymous_of_extract_gristF11I,
  (D) 1
};

static _KLsignatureGVKe K12 = {
  &KLsignatureGVKeW /* wrapper */,
  (D) 45088769,
  &KPempty_vectorVKi
};

static _KLsignatureAvaluesGVKi K13 = {
  &KLsignatureAvaluesGVKiW /* wrapper */,
  (D) 33555461,
  &KDsignature_Lbyte_stringG_typesVKi,
  &KDsignature_Lbyte_stringG_typesVKi
};

static _KLsimple_closure_methodGVKi_0 Kanonymous_of_strip_gristF16 = {
  &KLsimple_closure_methodGVKiW /* wrapper */,
  &rest_xep_0,
  &K12,
  &Kanonymous_of_strip_gristF16I,
  (D) 1
};

/* Code */

D Kstrip_gristYjam_internalsVjamI (D name_) {
  D T1;
  D grist_end_;
  D T3;
  D T4_0;
  D T5_0;
  D T6_0;
  D T7_0;
  D T8;
  DWORD T9;
  D T10;
  D T11;
  DBCHR T12;
  D T13;
  D T14_0;
  D T15;
  D T16;
  D T17;
  _KLsimple_object_vectorGVKd_1 T18 = {&KLsimple_object_vectorGVKdW, (D) 5};
  D T19;
  D T20;
  D T21_0;

  // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:23
  // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:26
  T8 = SLOT_VALUE_INITD(name_, 0);
  // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:26
  T9 = primitive_cast_integer_as_raw(T8);
  // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:26
  T10 = primitive_machine_word_less_thanQ(5,T9);
  // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:26
  if (T10 != &KPfalseVKi) {
    // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:26
    T11 = primitive_machine_word_unsigned_less_thanQ(1,T9);
    // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:26
    if (T11 != &KPfalseVKi) {
      // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:26
      T12 = REPEATED_DBCHR_SLOT_VALUE_TAGGED(name_, 1, 1);
      // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:26
      T13 = primitive_raw_as_byte_character(T12);
      T16 = T13;
    } else {
      // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:26
      T14_0 = Kelement_range_errorVKeI(name_, (D) 1);
      // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:26
      T15 = T14_0;
      T16 = T15;
    }
    // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:26
    // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:26
    T17 = primitive_idQ(T16,C('<'));
    T1 = T17;
  } else {
    T1 = &KPfalseVKi;
  }
  // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:26
  // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:26
  if (T1 != &KPfalseVKi) {
    // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:27
    T18.vector_element_[0] = C('>');
    // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:27
    T19 = primitive_copy_vector(&T18);
    // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:27
    T20 = MAKE_CLOSURE_INITD(&Kanonymous_of_strip_gristF16, 1, T19);
    // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:27
    CONGRUENT_CALL_PROLOG(&Kfind_keyVKd, 3);
    grist_end_ = CONGRUENT_CALL3(name_, T20, &KPempty_vectorVKi);
    // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:28
    if (grist_end_ != &KPfalseVKi) {
      // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:29
      CONGRUENT_CALL_PROLOG(&KAVKd, 2);
      T3 = CONGRUENT_CALL2(grist_end_, (D) 5);
      // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:29
      T21_0 = Kcopy_sequenceVKdMM3I(name_, &KPempty_vectorVKi, T3, &KPunboundVKi);
      T5_0 = T21_0;
    } else {
      // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:31
      T4_0 = name_;
      T5_0 = T4_0;
    }
    // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:28
    T7_0 = T5_0;
  } else {
    // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:34
    T6_0 = name_;
    T7_0 = T6_0;
  }
  // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:26
  // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:23
  MV_SET_COUNT(1);
  return(T7_0);
}

D Kextract_gristYjam_internalsVjamI (D name_) {
  D T1;
  D grist_end_;
  D T3;
  D T4_0;
  D T5_0;
  D T6_0;
  D T7_0;
  D T8;
  DWORD T9;
  D T10;
  D T11;
  DBCHR T12;
  D T13;
  D T14_0;
  D T15;
  D T16;
  D T17;
  _KLsimple_object_vectorGVKd_1 T18 = {&KLsimple_object_vectorGVKdW, (D) 5};
  D T19;
  D T20;
  D T21_0;

  // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:8
  // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:11
  T8 = SLOT_VALUE_INITD(name_, 0);
  // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:11
  T9 = primitive_cast_integer_as_raw(T8);
  // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:11
  T10 = primitive_machine_word_less_thanQ(5,T9);
  // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:11
  if (T10 != &KPfalseVKi) {
    // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:11
    T11 = primitive_machine_word_unsigned_less_thanQ(1,T9);
    // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:11
    if (T11 != &KPfalseVKi) {
      // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:11
      T12 = REPEATED_DBCHR_SLOT_VALUE_TAGGED(name_, 1, 1);
      // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:11
      T13 = primitive_raw_as_byte_character(T12);
      T16 = T13;
    } else {
      // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:11
      T14_0 = Kelement_range_errorVKeI(name_, (D) 1);
      // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:11
      T15 = T14_0;
      T16 = T15;
    }
    // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:11
    // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:11
    T17 = primitive_idQ(T16,C('<'));
    T1 = T17;
  } else {
    T1 = &KPfalseVKi;
  }
  // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:11
  // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:11
  if (T1 != &KPfalseVKi) {
    // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:12
    T18.vector_element_[0] = C('>');
    // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:12
    T19 = primitive_copy_vector(&T18);
    // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:12
    T20 = MAKE_CLOSURE_INITD(&Kanonymous_of_extract_gristF11, 1, T19);
    // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:12
    CONGRUENT_CALL_PROLOG(&Kfind_keyVKd, 3);
    grist_end_ = CONGRUENT_CALL3(name_, T20, &KPempty_vectorVKi);
    // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:13
    if (grist_end_ != &KPfalseVKi) {
      // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:14
      CONGRUENT_CALL_PROLOG(&KAVKd, 2);
      T3 = CONGRUENT_CALL2(grist_end_, (D) 5);
      // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:14
      T21_0 = Kcopy_sequenceVKdMM3I(name_, &KPempty_vectorVKi, (D) 1, T3);
      T5_0 = T21_0;
    } else {
      // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:16
      T4_0 = &KPempty_stringVKi;
      T5_0 = T4_0;
    }
    // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:13
    T7_0 = T5_0;
  } else {
    // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:19
    T6_0 = &KPempty_stringVKi;
    T7_0 = T6_0;
  }
  // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:11
  // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:8
  MV_SET_COUNT(1);
  return(T7_0);
}

D Kadd_gristYjam_internalsVjamI (D old_, D new_) {
  D old_grist_;
  D T4_0;
  D T5_0;
  D T6;
  DWORD T7;
  D T8;
  _KLsimple_object_vectorGVKd_1 T9 = {&KLsimple_object_vectorGVKdW, (D) 5};
  D T10_0;

  // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:38
  // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:41
  old_grist_ = Kextract_gristYjam_internalsVjamI(old_);
  // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:42
  T6 = SLOT_VALUE_INITD(old_grist_, 0);
  // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:42
  T7 = primitive_cast_integer_as_raw(T6);
  // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:42
  T8 = primitive_machine_word_equalQ(T7,1);
  // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:42
  if (T8 != &KPfalseVKi) {
    // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:43
    T4_0 = new_;
    T5_0 = T4_0;
  } else {
    // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:45
    T9.vector_element_[0] = new_;
    // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:45
    MIEP_CALL_PROLOG(&K6);
    T10_0 = Kconcatenate_asVKdMM3I(&KLbyte_stringGVKd, old_grist_, &T9);
    T5_0 = T10_0;
  }
  // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:42
  // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:38
  MV_SET_COUNT(1);
  return(T5_0);
}

static D Kanonymous_of_extract_gristF11I (D args_) {
  D T1;
  D T2;
  CAPTURE_ENVIRONMENT

  // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:12
  // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:12
  T1 = Kconcatenate_2VKeMM1I(CREF(0), args_);
  // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:12
  T2 = APPLY1(&KEEVKd, T1);
  // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:12
  return(T2);
}

static D Kanonymous_of_strip_gristF16I (D args_) {
  D T1;
  D T2;
  CAPTURE_ENVIRONMENT

  // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:27
  // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:27
  T1 = Kconcatenate_2VKeMM1I(CREF(0), args_);
  // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:27
  T2 = APPLY1(&KEEVKd, T1);
  // /Users/bruce/Development/dylan/opendylan/sources/lib/jam/jam-grist.dylan:27
  return(T2);
}


/* SYSTEM INIT CODE */

void _Init_jam__X_jam_grist_for_system () {
  extern D KPresolve_symbolVKiI(D);
  return;
}

/* USER INIT CODE */

void _Init_jam__X_jam_grist_for_user () {
  return;
}


/* eof */
