From 9e8dbf2dab67310e0acae19058609a6c696beeb6 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Thu, 23 Feb 2023 08:54:02 -0500 Subject: s/immediate/constant/ --- chickadee/graphics/seagull.scm | 43 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/chickadee/graphics/seagull.scm b/chickadee/graphics/seagull.scm index 5bdd6f3..a9a5944 100644 --- a/chickadee/graphics/seagull.scm +++ b/chickadee/graphics/seagull.scm @@ -100,9 +100,8 @@ (define (float? x) (and (number? x) (inexact? x))) -;; Immediate types are fundamental data types that need no -;; compilation. -(define (immediate? x) +;; Constant types are fundamental data types that need no compilation. +(define (constant? x) (or (exact-integer? x) (float? x) (boolean? x))) @@ -531,8 +530,8 @@ (define (primitive-call-for-stage? x) (primitive-call? x stage)) (match exp - ;; Immediates and variables: - ((? immediate?) + ;; Constants and variables: + ((? constant?) exp) ((? symbol?) (expand:variable exp stage env)) @@ -596,7 +595,7 @@ ;;; Constant propagation and folding ;;; -;; Replace references to constants (variables that store an immediate +;; Replace references to constants (variables that store an constant ;; value: integer, float, boolean) with the constants themselves. ;; Then look for opportunities to evaluate primitive expressions that ;; have constant arguments. This will make the type inferencer's job @@ -621,14 +620,14 @@ ;; Extend environment with known constants. (define env* (fold (lambda (name exp env*) - (if (immediate? exp) + (if (constant? exp) (extend-env name exp env*) env*)) env names exps*)) ;; Drop all bindings for constant expressions. (define bindings (filter-map (lambda (name exp) - (if (immediate? exp) + (if (constant? exp) #f (list name exp))) names exps*)) @@ -644,13 +643,13 @@ (define env* (fold (lambda (names exp env) (match exp - ((? immediate?) + ((? constant?) (match names ((name) (extend-env name exp env)))) (('values vals ...) (fold (lambda (name val env) - (if (immediate? val) + (if (constant? val) (extend-env name val env) env)) env names vals)) @@ -660,12 +659,12 @@ (define bindings (filter-map (lambda (names exp) (match exp - ((? immediate?) #f) + ((? constant?) #f) (('values vals ...) (define-values (names* exps*) (unzip2 (filter-map (lambda (name val) - (if (immediate? val) + (if (constant? val) #f (list name val))) names vals))) @@ -711,7 +710,7 @@ (define (simplify:primcall op args env) (let ((proc (assq-ref %simplify-primitives op)) (args* (simplify:list args env))) - (if (and (procedure? proc) (every immediate? args*)) + (if (and (procedure? proc) (every constant? args*)) (apply proc args*) `(primcall ,op ,@args*)))) @@ -737,7 +736,7 @@ (define (simplify-exp exp env) (match exp - ((? immediate?) exp) + ((? constant?) exp) ((? symbol?) (or (lookup* exp env) exp)) (('if predicate consequent alternate) @@ -791,7 +790,7 @@ (define (unused-in-list? exps) (every (lambda (exp) (unused-variable? var exp)) exps)) (match exp - ((? immediate?) #t) + ((? constant?) #t) ((? symbol?) (not (eq? exp var))) (('if predicate consequent alternate) @@ -898,7 +897,7 @@ (define (prune exp) (match exp - ((or (? immediate?) (? symbol?)) + ((or (? constant?) (? symbol?)) exp) (('if predicate consequent alternate) (prune:if predicate consequent alternate)) @@ -950,7 +949,7 @@ (define (check-free-variables exp bound-vars top-level-vars) (match exp - ((? immediate?) + ((? constant?) #t) ((? symbol?) (or (memq exp bound-vars) ; bound vars: OK @@ -1125,7 +1124,7 @@ (define (hoist-functions exp) (match exp - ((or (? immediate?) (? symbol?)) + ((or (? constant?) (? symbol?)) (values exp (empty-env))) (('if predicate consequent alternate) (hoist:if predicate consequent alternate)) @@ -1941,7 +1940,7 @@ (_ (type-mismatch a b unify)))) -(define (infer:immediate x) +(define (infer:constant x) (values (texp (list (cond ((exact-integer? x) type:int) @@ -2308,8 +2307,8 @@ ;; - a type predicate (define (infer-exp exp env) (match exp - ((? immediate?) - (infer:immediate exp)) + ((? constant?) + (infer:constant exp)) ((? symbol? name) (infer:variable name env)) (('if predicate consequent alternate) @@ -2667,7 +2666,7 @@ (define (find-signatures name texp) (match (texp-exp texp) - ((or (? immediate?) (? symbol?)) + ((or (? constant?) (? symbol?)) '()) (('if predicate consequent alternate) (find-signatures:if name predicate consequent alternate)) -- cgit v1.2.3