File: theme-d-compiler-core-def.scm

package info (click to toggle)
theme-d 1.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 12,784 kB
  • sloc: lisp: 47,684; sh: 4,200; makefile: 455; ansic: 319
file content (110 lines) | stat: -rw-r--r-- 2,432 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
;; Copyright (C) 2008-2013 Tommi Höynälänmaa
;; Distributed under GNU General Public License version 3,
;; see file doc/GPL-3.


;; *** Parser core definitions ***


(import (rnrs exceptions)
	(srfi srfi-1)
	(th-scheme-utilities stdutils)
	(th-scheme-utilities hrecord))


(define gl-i-globals-by-address-size 10000)
(define gl-i-globals-by-name-size 10000)
(define gl-i-cycles-size 1000)
(define gl-i-tvars-size 1000)
(define gl-i-goops-classes-size 1000)
(define gl-i-prim-classes-size 100)
(define gl-i-procs-size 50)


(define-hrecord-type <compiler> ()
  binder
  state
  unit-type
  module-name
  env
  env-all
  imports
  imports-with-reexports
  l-used-modules
  l-prelinked-bodies
  l-interface-imports
  l-body-source
  exported-objects
  public-decls
  method-decls
  lst-visited
  ht-cycles
  lst-enclosing-cycles
  ht-type-variables
  body
  expanded-body
  toplevel-unit-name
  work-dir
  module-search-path
  pretty-print-modules?
  backtrace?
  expand-only?
  no-expansion?
  next-free-loc
  imported-modules
  reexports
  ht-globals-by-name
  ht-goops-classes
  ht-prim-classes
  ht-procs
  inside-pure-proc?
  inside-param-def?
  current-letrec-env
  current-expr
  current-toplevel-expr
  current-interface-var
  current-repr
  current-toplevel-repr
  s-cur-toplevel-def
  error-info
  display-erroneous-expr?
  module-to-import
  variable-to-import
  show-imported-symbols?
  target-output-filename
  target-output-file)


(define (compiler-alloc-loc compiler s-name toplevel?)
  (if (not (eqv? s-name 'main))
      (let ((new-loc (hfield-ref compiler 'next-free-loc)))
	(hfield-set! compiler 'next-free-loc (+ new-loc 1))
	(make-hrecord <address> '() new-loc s-name toplevel?))
      (make-hrecord <address> '() address-number-target '_main
		    toplevel?)))


(define (compiler-get-binder compiler)
  (hfield-ref compiler 'binder))


(define (compiler-get-globals-by-address compiler)
  (hfield-ref (hfield-ref compiler 'binder) 'ht-globals-by-address))


(define (compiler-get-fixed-tvars compiler)
  (hfield-ref (hfield-ref compiler 'binder) 'fixed-tvars))


(define (compiler-set-fixed-tvars! compiler obj)
  (let ((binder (hfield-ref compiler 'binder)))
    (hfield-set! binder 'fixed-tvars obj)))


(define (is-null-sexpr? obj)
  (or (null? obj) (eq? obj 'null)))


(define (get-current-module-name compiler)
  (assert (hrecord-is-instance? compiler <compiler>))
  (hfield-ref compiler 'module-name))