<commit_before>;;; abstract syntax for annotated programs
;;; definitions
;;; formals are #f if no formals are available
(define (annMakeDef name formals body)
  (vector 'DEF name formals body 'btvar 'ocs))
(define (annDefFetchProcName d)
  (vector-ref d 1)) 
(define (annDefFetchProcFormals d)
  (vector-ref d 2)) 
(define (annDefFetchProcBody d)
  (vector-ref d 3))
(define (annDefSetProcBody d body)
  (vector-set! d 3 body))
(define (annDefSetProcBTVar! d tv)
  (vector-set! d 4 tv))
(define (annDefFetchProcBTVar d)
  (vector-ref d 4))
(define (annDefFetchProcOcs d)
  (vector-ref d 5))
(define (annDefSetProcOcs! d ocs)
  (vector-set! d 5 ocs))
(define (annDefLookup name d*)
  (let loop ((d* d*))
    (and (not (null? d*))
	 (let ((d (car d*)))
	   (if (equal? (annDefFetchProcName d) name)
	       d
	       (loop (cdr d*)))))))
;;; expressions
(define (annExprFetchType e)
  (vector-ref e 1))
(define (annExprSetType! e bt)
  (vector-set! e 1 bt))
(define (annExprFetchMemo e)
  (vector-ref e 2))
(define (annExprSetMemo! e bt)
  (vector-set! e 2 bt))
(define (annExprFetchLevel e)
  (vector-ref e 3))
(define (annExprSetLevel! e lv)
  (vector-set! e 3 lv))
;;; variable
(define (annMakeVar v)
  (vector 'VAR #f #f 0 v 'dummy))
(define (annIsVar? e)
  (equal? 'VAR (vector-ref e 0)))
(define (annFetchVar e)
  (vector-ref e 4))
;;; constant
(define (annMakeConst c)
  (vector 'CONST #f #f 0 c 'dummy))
(define (annIsConst? e)
  (equal? 'CONST (vector-ref e 0)))
(define (annFetchConst e)
  (vector-ref e 4))
;;; conditional
(define (annMakeCond e-cond e-then e-else)
  (vector 'CONDITION #f #f 0 e-cond e-then e-else))
(define (annIsCond? e)
  (equal? 'CONDITION (vector-ref e 0)))
(define (annFetchCondTest e)
  (vector-ref e 4))
(define (annFetchCondThen e)
  (vector-ref e 5))
(define (annFetchCondElse e)
  (vector-ref e 6))
;;; primitive operations
(define INTERNAL-IDENTITY (list '***internal-identity***))
(define (annMakeOp op args)
  (vector 'OP #f #f 0 op args #t #f #f))
(define (annMakeOpaqueOp op args)
  (vector 'OP #f #f 0 op args #f #f #f))
(define (annMakeFullOp op opaque property type args)
  (vector 'OP #f #f 0 op args opaque property type))
(define (annMakeOp1 opaque property type)
  (lambda (op args) (annMakeFullOp op opaque property type args)))
(define (annIsOp? e)
  (equal? 'OP (vector-ref e 0)))
(define (annFetchOpName e)
  (vector-ref e 4))
(define (annFetchOpArgs e)
  (vector-ref e 5))
(define (annFetchOpDiscardability e)
  (vector-ref e 6))
(define (annFetchOpProperty e)
  (vector-ref e 7))
(define (annFetchOpType e)
  (vector-ref e 8))
;;; procedure call
(define (annMakeCall fname args)
  (vector 'CALL #f #f 0 fname args))
(define (annIsCall? e)
  (equal? 'CALL (vector-ref e 0)))
(define (annFetchCallName e)
  (vector-ref e 4))
(define (annFetchCallArgs e)
  (vector-ref e 5))
;;; let, one variable
(define (annMakeLet v e1 e2)
  (vector 'LET #f #f 0 v e1 e2 #f))
(define (annIsLet? e)<commit_msg>Additions for flexible memoization.<commit_after>;;; abstract syntax for annotated programs
;;; definitions
;;; formals are #f if no formals are available
(define (annMakeDef name formals body)
  (vector 'DEF name formals body 'btvar 'ocs #t))
(define (annMakeDefWithoutMemoization name formals body)
  (vector 'DEF name formals body 'btvar 'ocs #f))
(define (annDefFetchProcName d)
  (vector-ref d 1)) 
(define (annDefFetchProcFormals d)
  (vector-ref d 2)) 
(define (annDefFetchProcBody d)
  (vector-ref d 3))
(define (annDefSetProcBody d body)
  (vector-set! d 3 body))
(define (annDefSetProcBTVar! d tv)
  (vector-set! d 4 tv))
(define (annDefFetchProcBTVar d)
  (vector-ref d 4))
(define (annDefFetchProcOcs d)
  (vector-ref d 5))
(define (annDefSetProcOcs! d ocs)
  (vector-set! d 5 ocs))
(define (annDefFetchProcAutoMemo d)
  (vector-ref d 6))
(define (annDefSetProcAutoMemo! d f)
  (vector-set! d 6 f))
(define (annDefLookup name d*)
  (let loop ((d* d*))
    (and (not (null? d*))
	 (let ((d (car d*)))
	   (if (equal? (annDefFetchProcName d) name)
	       d
	       (loop (cdr d*)))))))
;;; expressions
(define (annExprFetchType e)
  (vector-ref e 1))
(define (annExprSetType! e bt)
  (vector-set! e 1 bt))
(define (annExprFetchMemo e)
  (vector-ref e 2))
(define (annExprSetMemo! e bt)
  (vector-set! e 2 bt))
(define (annExprFetchLevel e)
  (vector-ref e 3))
(define (annExprSetLevel! e lv)
  (vector-set! e 3 lv))
;;; variable
(define (annMakeVar v)
  (vector 'VAR #f #f 0 v 'dummy))
(define (annIsVar? e)
  (equal? 'VAR (vector-ref e 0)))
(define (annFetchVar e)
  (vector-ref e 4))
;;; constant
(define (annMakeConst c)
  (vector 'CONST #f #f 0 c 'dummy))
(define (annIsConst? e)
  (equal? 'CONST (vector-ref e 0)))
(define (annFetchConst e)
  (vector-ref e 4))
;;; conditional
(define (annMakeCond e-cond e-then e-else)
  (vector 'CONDITION #f #f 0 e-cond e-then e-else))
(define (annIsCond? e)
  (equal? 'CONDITION (vector-ref e 0)))
(define (annFetchCondTest e)
  (vector-ref e 4))
(define (annFetchCondThen e)
  (vector-ref e 5))
(define (annFetchCondElse e)
  (vector-ref e 6))
;;; primitive operations
(define INTERNAL-IDENTITY (list '***internal-identity***))
(define (annMakeOp op args)
  (vector 'OP #f #f 0 op args #t #f #f #f))
(define (annMakeOpaqueOp op args)
  (vector 'OP #f #f 0 op args #f #f #f #f))
(define (annMakeFullOp op opaque property pp type args)
  (vector 'OP #f #f 0 op args opaque property pp type))
(define (annMakeOp1 opaque property pp type)
  (lambda (op args) (annMakeFullOp op opaque property pp type args)))
(define (annIsOp? e)
  (equal? 'OP (vector-ref e 0)))
(define (annFetchOpName e)
  (vector-ref e 4))
(define (annFetchOpArgs e)
  (vector-ref e 5))
(define (annFetchOpDiscardability e)
  (vector-ref e 6))
(define (annFetchOpProperty e)
  (vector-ref e 7))
(define (annFetchOpPostprocessor e)
  (vector-ref e 8))
(define (annFetchOpType e)
  (vector-ref e 9))
;;; procedure call
(define (annMakeCall fname args)
  (vector 'CALL #f #f 0 fname args))
(define (annIsCall? e)
  (equal? 'CALL (vector-ref e 0)))
(define (annFetchCallName e)
  (vector-ref e 4))
(define (annFetchCallArgs e)
  (vector-ref e 5))
;;; let, one variable
(define (annMakeLet v e1 e2)
  (vector 'LET #f #f 0 v e1 e2 #f))
(define (annIsLet? e)
{'fraction_non_alphanumeric': 0.15160771704180065, 'fraction_numerical': 0.014630225080385853, 'mean_word_length': 4.344501718213058, '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': '5852862', 'n_tokens_mistral': 2474, 'n_tokens_neox': 2364, 'n_words': 832}