@@ -38,6 +38,8 @@ import { makeWrapper } from './utils/makeWrapper'
3838import * as operators from './utils/operators'
3939import { stringify } from './utils/stringify'
4040import { schemeVisualise } from './alt-langs/scheme/scheme-mapper'
41+ import { cset_apply , cset_eval } from './cse-machine/scheme-macros'
42+ import { Transformers } from './cse-machine/interpreter'
4143
4244export class LazyBuiltIn {
4345 func : ( ...arg0 : any ) => any
@@ -117,7 +119,7 @@ const createEmptyRuntime = () => ({
117119 nodes : [ ] ,
118120 control : null ,
119121 stash : null ,
120- transformers : null ,
122+ transformers : new Transformers ( ) ,
121123 objectCount : 0 ,
122124 envSteps : - 1 ,
123125 envStepsTotal : 0 ,
@@ -452,16 +454,14 @@ export const importBuiltins = (context: Context, externalBuiltIns: CustomBuiltIn
452454 if ( context . chapter <= + Chapter . SCHEME_1 && context . chapter >= + Chapter . FULL_SCHEME ) {
453455 switch ( context . chapter ) {
454456 case Chapter . FULL_SCHEME :
457+ // Introduction to eval
458+ // eval metaprocedure
459+ defineBuiltin ( context , '$scheme_ZXZhbA$61$$61$(xs)' , cset_eval )
460+
455461 case Chapter . SCHEME_4 :
456462 // Introduction to call/cc
457463 defineBuiltin ( context , 'call$47$cc(f)' , call_with_current_continuation )
458464
459- // Introduction to eval
460-
461- // Scheme apply
462- // ^ is needed in Schemes 2 and 3 to apply to call functions with rest parameters,
463- // so we move it there.
464-
465465 case Chapter . SCHEME_3 :
466466 // Introduction to mutable values, streams
467467
@@ -499,10 +499,6 @@ export const importBuiltins = (context: Context, externalBuiltIns: CustomBuiltIn
499499 defineBuiltin ( context , 'list$45$$62$vector(xs)' , scheme_libs . list$45$$62$vector )
500500
501501 case Chapter . SCHEME_2 :
502- // Splicing builtin resolvers
503- // defineBuiltin(context, '$36$make$45$splice(expr)', scheme_libs.make_splice)
504- // defineBuiltin(context, '$36$resolve$45$splice(xs)', scheme_libs.resolve_splice)
505-
506502 // Scheme pairs
507503 defineBuiltin ( context , 'cons(left, right)' , scheme_libs . cons )
508504 defineBuiltin ( context , 'xcons(right, left)' , scheme_libs . xcons )
@@ -624,11 +620,16 @@ export const importBuiltins = (context: Context, externalBuiltIns: CustomBuiltIn
624620 defineBuiltin ( context , 'list$45$$62$string(xs)' , scheme_libs . list$45$$62$string )
625621
626622 // Scheme apply is needed here to help in the definition of the Scheme Prelude.
627- defineBuiltin ( context , 'apply(f, ...args)' , scheme_libs . apply , 2 )
623+ defineBuiltin ( context , 'apply(f, ...args)' , cset_apply , 2 )
628624
629625 case Chapter . SCHEME_1 :
630626 // Display
631- defineBuiltin ( context , 'display(val)' , ( val : any ) => display ( schemeVisualise ( val ) ) )
627+ defineBuiltin (
628+ context ,
629+ 'display(val, prepend = undefined)' ,
630+ ( val : any , ...str : string [ ] ) => display ( schemeVisualise ( val ) , ...str ) ,
631+ 1
632+ )
632633 defineBuiltin ( context , 'newline()' , ( ) => display ( '' ) )
633634
634635 // I/O
0 commit comments