refactor(ptc): reuse the existing scoped REPL prefix export

This commit is contained in:
_Kerman committed 2026-11-12 17:52:48 +08:00
1 parent 968ea6ebc0
commit 70be41c8ad
3 files changed
+3 -7

No files matched your search

@@ -2,7 +2,7 @@
import { PtcImage, RESERVED_BINDING_WORDS, PtcRuntimeError, RESERVED_BINDING_GLOBALS, RESERVED_ERROR_MEMBERS } from '@deepseek-ai/dsh-ptc-runtime'
import type { PtcBindingFunction, PtcBindingNamespace, PtcJsonValue, PtcProgramFormat, PtcRunRequest } from '@deepseek-ai/dsh-ptc-runtime'
import { snapshotPtcJsonValue, encodePtcJsonWire, type PtcJsonWire, type PtcImageWire } from './json-wire.ts'
import { RESERVED_PREFIX } from './evaluators/scoped-repl-names.ts'
import { RESERVED_PREFIX } from './evaluators/scoped-repl.ts'
const IDENTIFIER = /^[A-Za-z_$][A-Za-z0-9_$]*$/
/**
* Reject unusable namespaces before starting a process.
@@ -1,4 +0,0 @@
/** Internal identifiers shared by scoped REPL source generation and host binding validation. */
/** Prefix of generated names, excluded from program source and injected identifiers. */
export const RESERVED_PREFIX = '__$binding_'
@@ -2,8 +2,6 @@
import { getLineInfo, parse } from 'acorn'
import type { Identifier, ModuleDeclaration, Pattern, Program, Statement } from 'acorn'
import { Script, type Context, type ScriptOptions } from 'node:vm'
import { RESERVED_PREFIX } from './scoped-repl-names.ts'
export { RESERVED_PREFIX } from './scoped-repl-names.ts'
/** Declaration keyword recorded for a top-level binding; later programs copy `var` bindings as `var` and every other binding as `let`. */
export type ScopedReplBindingKind = 'var' | 'let' | 'const' | 'function' | 'class'
@@ -36,6 +34,8 @@ export interface ScopedReplScan {
finalExpression?: ScopedReplFinalExpression
}
/** Prefix of every generated name; programs that contain it anywhere are rejected. */
export const RESERVED_PREFIX = '__$binding_'
/** Generated parameter receiving the values copied from earlier programs. */
export const BINDING_VALUES = `${RESERVED_PREFIX}vals`
/** Generated parameter receiving one read function per binding, in binding order. */