Skip to content

Commit 44b76cb

Browse files
committed
Merge branch 'indentationRefactor' into 'master'
Fix empty c..r See merge request btj12/Interpreter!87
2 parents 11544e5 + 956dd67 commit 44b76cb

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

state-manipulation.scm

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,15 @@
191191
((atom? dotexpr) '.temp)
192192
((list? (dotted-class-instance (arglist-dot dotexpr)))
193193
(cond
194-
((eq? (car (dotted-class-instance (arglist-dot dotexpr))) 'new) '.temp)
194+
((eq? (get-dotted-head (dotted-class-instance (arglist-dot dotexpr))) 'new) '.temp)
195195
(else (find-highest-var (dotted-class-instance (arglist-dot dotexpr))))))
196196
((eq? 'this (dotted-class-instance (arglist-dot dotexpr))) '.temp)
197197
((eq? 'super (dotted-class-instance (arglist-dot dotexpr))) '.temp)
198198
((eq? 'funcall (arglist-head dotexpr)) '.temp)
199199
(else (dotted-class-instance (arglist-dot dotexpr))))))
200200

201+
(define get-dotted-head car)
202+
201203
; Gets the case class a state is in
202204
(define get-base-class
203205
(lambda (state cfuncsinstance)
@@ -218,12 +220,14 @@
218220
((null? currentclass) default-currentclass)
219221
((declared-in-scope? (get-variable-section-state (get-top-scope state)) '.class)
220222
(cond
221-
((and (eq? (car (get-value-section-state (get-top-scope state))) currentclass)
223+
((and (eq? (get-value-section-top-head (get-value-section-state (get-top-scope state))) currentclass)
222224
(G-initialized? '.class (get-tail-scope state)))
223225
(get-value-from-pair (G-value-lookup->value_state '.class (get-tail-scope state) empty-cfuncs)))
224226
(else (get-super-class currentclass (get-tail-scope state)))))
225227
(else (get-super-class currentclass (get-tail-scope state))))))
226228

229+
(define get-value-section-top-head car)
230+
227231

228232
(define default-currentclass '())
229233

@@ -523,11 +527,13 @@
523527
; value is a list: e.g. (new A). Prereq: the name of the instance has not been declared in the current stack frame
524528
(define get-instance-initialization-value
525529
(lambda (value state)
526-
(let* ([cn (cadr value)])
530+
(let* ([cn (get-instance-init-value-head value)])
527531
(cond
528532
(else (list (list 'classname cn)
529533
(G-eval-class-closure->state cn state)))))))
530534

535+
(define get-instance-init-value-head cadr)
536+
531537

532538
; Pushes the declaration statement to the state
533539
(define declare-var->state
@@ -1137,12 +1143,14 @@
11371143
((null? desiredclass) (pop-scope-to-function-default fn state))
11381144
((declared-in-scope? (get-variable-section-state (get-top-scope state)) '.class)
11391145
(cond
1140-
((eq? (car (get-value-section-state (get-top-scope state))) desiredclass)
1146+
((eq? (get-value-popped-head (get-value-section-state (get-top-scope state))) desiredclass)
11411147
(pop-scope-to-function-default fn state))
11421148
(else (G-pop-scope-to-function->state fn desiredclass (get-tail-scope state)))))
11431149
((declared-in-scope? (get-variable-section-state (get-top-scope state)) fn) state)
11441150
(else (G-pop-scope-to-function->state fn desiredclass (get-tail-scope state))))))
11451151

1152+
(define get-value-popped-head car)
1153+
11461154
; Pops a scope to a givenfunction
11471155
(define pop-scope-to-function-default
11481156
(lambda (fn state)

0 commit comments

Comments
 (0)