Skip to content

Commit f7f815c

Browse files
committed
spreadinstr
1 parent d161689 commit f7f815c

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

src/cse-machine/interpreter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { evaluateBinaryExpression, evaluateUnaryExpression } from '../utils/oper
2121
import * as rttc from '../utils/rttc'
2222
import * as seq from '../utils/statementSeqTransform'
2323
import { checkProgramForUndefinedVariables } from '../validator/validator'
24+
import { isSchemeLanguage } from '../alt-langs/mapper'
2425
import Closure from './closure'
2526
import {
2627
Continuation,
@@ -83,7 +84,6 @@ import {
8384
} from './utils'
8485
import { isApply, isEval, schemeEval } from './scheme-macros'
8586
import { Transformer } from './patterns'
86-
import { isSchemeLanguage } from '../alt-langs/mapper'
8787
import { flattenList, isList } from './macro-utils'
8888

8989
type CmdEvaluator = (
@@ -1339,7 +1339,7 @@ const cmdEvaluators: { [type: string]: CmdEvaluator } = {
13391339
const cont = control.getStack()
13401340
const size = control.size()
13411341
for (let i = size - 1; i >= 0; i--) {
1342-
// guaranteed at least one call instr above
1342+
// guaranteed at least one call instr above, because spread is not allowed inside arrays
13431343
if ((cont[i] as AppInstr).instrType === InstrType.APPLICATION) {
13441344
(cont[i] as AppInstr).numOfArgs += array.length - 1;
13451345
break; // only the nearest call instruction above

src/cse-machine/patterns.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// and a final template (for the list to be transformed into).
66
import { List, Pair } from '../stdlib/list'
77
import { _Symbol } from '../alt-langs/scheme/scm-slang/src/stdlib/base'
8+
import { atomic_equals, is_number } from '../alt-langs/scheme/scm-slang/src/stdlib/core-math'
89
import {
910
arrayToImproperList,
1011
arrayToList,
@@ -14,7 +15,6 @@ import {
1415
isPair,
1516
isList
1617
} from './macro-utils'
17-
import { atomic_equals, is_number } from '../alt-langs/scheme/scm-slang/src/stdlib/core-math'
1818

1919
// a single pattern stored within the patterns component
2020
// may have several transformers attributed to it.

src/cse-machine/scheme-macros.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { List } from '../stdlib/list'
44
import { _Symbol } from '../alt-langs/scheme/scm-slang/src/stdlib/base'
55
import { is_number, SchemeNumber } from '../alt-langs/scheme/scm-slang/src/stdlib/core-math'
66
import { Context } from '..'
7+
import { encode } from '../alt-langs/scheme/scm-slang/src'
78
import { Control, Stash } from './interpreter'
89
import { currentTransformers, getVariable, handleRuntimeError } from './utils'
910
import { Transformer, macro_transform, match } from './patterns'
@@ -12,11 +13,9 @@ import {
1213
arrayToList,
1314
flattenImproperList,
1415
isImproperList
15-
} from './macro-utils'
16+
, flattenList, isList } from './macro-utils'
1617
import { ControlItem } from './types'
17-
import { encode } from '../alt-langs/scheme/scm-slang/src'
1818
import { popInstr } from './instrCreator'
19-
import { flattenList, isList } from './macro-utils'
2019

2120
// this needs to be better but for now it's fine
2221
export type SchemeControlItems = List | _Symbol | SchemeNumber | boolean | string

src/cse-machine/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import * as errors from '../errors/errors'
66
import { RuntimeSourceError } from '../errors/runtimeSourceError'
77
import { Chapter, type Environment, type Node, type StatementSequence, type Value } from '../types'
88
import * as ast from '../utils/ast/astCreator'
9+
import { _Symbol } from '../alt-langs/scheme/scm-slang/src/stdlib/base'
10+
import { is_number } from '../alt-langs/scheme/scm-slang/src/stdlib/core-math'
911
import Heap from './heap'
1012
import * as instr from './instrCreator'
1113
import { Control, Transformers } from './interpreter'
@@ -22,8 +24,6 @@ import {
2224
import Closure from './closure'
2325
import { Continuation, isCallWithCurrentContinuation } from './continuations'
2426
import { isApply, isEval } from './scheme-macros'
25-
import { _Symbol } from '../alt-langs/scheme/scm-slang/src/stdlib/base'
26-
import { is_number } from '../alt-langs/scheme/scm-slang/src/stdlib/core-math'
2727

2828
/**
2929
* Typeguard for commands to check if they are scheme values.

0 commit comments

Comments
 (0)