@@ -25,9 +25,11 @@ import classes from 'src/styles/Draggable.module.scss';
2525import { ArrayUnit } from './components/ArrayUnit' ;
2626import { Binding } from './components/Binding' ;
2727import { ControlItemComponent } from './components/ControlItemComponent' ;
28+ import { isNode } from './components/ControlStack' ;
2829import { Frame } from './components/Frame' ;
2930import { StashItemComponent } from './components/StashItemComponent' ;
3031import { ArrayValue } from './components/values/ArrayValue' ;
32+ import { ContValue } from './components/values/ContValue' ;
3133import { FnValue } from './components/values/FnValue' ;
3234import { GlobalFnValue } from './components/values/GlobalFnValue' ;
3335import { Value } from './components/values/Value' ;
@@ -57,6 +59,7 @@ import {
5759 isCustomPrimitive ,
5860 needsNewRepresentation
5961} from './utils/altLangs' ;
62+ import { isContinuation , schemeToString } from './utils/scheme' ;
6063class AssertionError extends Error {
6164 constructor ( msg ?: string ) {
6265 super ( msg ) ;
@@ -233,6 +236,12 @@ export function setDifference<T>(set1: Set<T>, set2: Set<T>) {
233236 * always prioritised over array units.
234237 */
235238export function isMainReference ( value : Value , reference : ReferenceType ) {
239+ if ( isContinuation ( value . data ) ) {
240+ return (
241+ reference instanceof Binding &&
242+ isEnvEqual ( reference . frame . environment , value . data . getEnv ( ) [ 0 ] )
243+ ) ;
244+ }
236245 if ( isGlobalFn ( value . data ) ) {
237246 return (
238247 reference instanceof Binding &&
@@ -583,6 +592,19 @@ export function getControlItemComponent(
583592 ? index === Math . min ( Layout . control . size ( ) - 1 , 9 )
584593 : index === Layout . control . size ( ) - 1 ;
585594 if ( ! isInstr ( controlItem ) ) {
595+ if ( ! isNode ( controlItem ) ) {
596+ // at the moment, the only non-node and non-instruction control items are
597+ // literals from scheme.
598+ const representation = schemeToString ( controlItem as any ) ;
599+ return new ControlItemComponent (
600+ representation ,
601+ representation ,
602+ stackHeight ,
603+ highlightOnHover ,
604+ unhighlightOnHover ,
605+ topItem
606+ ) ;
607+ }
586608 // there's no reason to provide an alternate representation
587609 // for a instruction.
588610 if ( needsNewRepresentation ( chapter ) ) {
@@ -609,11 +631,13 @@ export function getControlItemComponent(
609631 topItem
610632 ) ;
611633 }
612- switch ( controlItem . type ) {
634+
635+ // at this point, the control item is a node.
636+ switch ( ( controlItem as any ) . type ) {
613637 case 'Program' :
614638 // If the control item is the whole program
615639 // add {} to represent the implicit block
616- const originalText = astToString ( controlItem )
640+ const originalText = astToString ( controlItem as any )
617641 . trim ( )
618642 . split ( '\n' )
619643 . map ( line => `\t\t${ line } ` )
@@ -629,7 +653,9 @@ export function getControlItemComponent(
629653 ) ;
630654 case 'Literal' :
631655 const textL =
632- typeof controlItem . value === 'string' ? `"${ controlItem . value } "` : controlItem . value ;
656+ typeof ( controlItem as any ) . value === 'string'
657+ ? `"${ ( controlItem as any ) . value } "`
658+ : ( controlItem as any ) . value ;
633659 return new ControlItemComponent (
634660 textL ,
635661 String ( textL ) ,
@@ -639,7 +665,7 @@ export function getControlItemComponent(
639665 topItem
640666 ) ;
641667 default :
642- const text = astToString ( controlItem ) . trim ( ) ;
668+ const text = astToString ( controlItem as any ) . trim ( ) ;
643669 return new ControlItemComponent (
644670 text ,
645671 text ,
@@ -846,10 +872,10 @@ export function getStashItemComponent(
846872 index : number ,
847873 _chapter : Chapter
848874) : StashItemComponent {
849- let arrowTo : ArrayValue | FnValue | GlobalFnValue | undefined ;
850- if ( isFunction ( stashItem ) || isDataArray ( stashItem ) ) {
851- if ( isClosure ( stashItem ) || isDataArray ( stashItem ) ) {
852- arrowTo = Layout . values . get ( stashItem . id ) as ArrayValue | FnValue ;
875+ let arrowTo : ArrayValue | FnValue | GlobalFnValue | ContValue | undefined ;
876+ if ( isFunction ( stashItem ) || isDataArray ( stashItem || isContinuation ( stashItem ) ) ) {
877+ if ( isClosure ( stashItem ) || isDataArray ( stashItem ) || isContinuation ( stashItem ) ) {
878+ arrowTo = Layout . values . get ( stashItem . id ) as ArrayValue | FnValue | ContValue ;
853879 } else {
854880 arrowTo = Layout . values . get ( stashItem ) as FnValue | GlobalFnValue ;
855881 }
0 commit comments