@@ -68,6 +68,18 @@ const packageDir: SKStore.EHandle<
6868 packageDirName,
6969);
7070
71+ const packageEnvAccessDirName: SKStore.DirName = SKStore.DirName::create(
72+ "/packageEnvAccess/",
73+ );
74+ const packageEnvAccessDir: SKStore.EHandle<
75+ SKStore.SID,
76+ SKStore.StringFile,
77+ > = SKStore.EHandle(
78+ SKStore.SID::keyType,
79+ SKStore.StringFile::type,
80+ packageEnvAccessDirName,
81+ );
82+
7183fun pkgDelta(
7284 old_pkg: InputPackageFiles,
7385 new_pkg: InputPackageFiles,
@@ -205,17 +217,33 @@ fun writeFiles(
205217 }
206218}
207219
220+ // FIXME: Ensure package names cannot start with an underscore to avoid clash with `_anonymous`.
221+ const kAnonymousPackageName: String = "_anonymous";
222+
223+ fun packageEnvDirName(pkg_opt: ?String): SKStore.DirName {
224+ SKStore.DirName::create(
225+ `/packageEnv/${pkg_opt.default(kAnonymousPackageName)}/`,
226+ )
227+ }
228+
229+ fun packageEnvDir(
230+ pkg_opt: ?String,
231+ ): SKStore.EHandle<SKStore.SID, SKStore.StringFile> {
232+ SKStore.EHandle(
233+ SKStore.SID::keyType,
234+ SKStore.StringFile::type,
235+ packageEnvDirName(pkg_opt),
236+ )
237+ }
238+
208239fun updatePackageEnv(
209240 context: mutable SKStore.Context,
210241 pkg_opt: ?String,
211242 env: Array<(String, String)>,
212243): void {
213- envDirName = SKStore.DirName::create(
214- `/packageEnv/${pkg_opt.default("_default")}/`,
215- );
244+ envDirName = packageEnvDirName(pkg_opt);
216245 envDir = context.unsafeMaybeGetEagerDir(envDirName) match {
217- | Some _ ->
218- SKStore.EHandle(SKStore.SID::keyType, SKStore.StringFile::type, envDirName)
246+ | Some _ -> packageEnvDir(pkg_opt)
219247 | None _ ->
220248 context.mkdir(SKStore.SID::keyType, SKStore.StringFile::type, envDirName)
221249 };
@@ -236,12 +264,6 @@ fun updatePackageEnv(
236264 };
237265}
238266
239- const kEnvAccessGlobal: String = "ACCESSED_ENV_MAP";
240-
241- class EnvMapFile(
242- value: SortedMap<?String, SortedSet<String>>,
243- ) extends SKStore.File
244-
245267module end;
246268
247269module SkipParse;
@@ -254,11 +276,18 @@ const astDir: SKStore.EHandle<SKStore.SID, DefsFile> = SKStore.EHandle(
254276);
255277
256278class DefsFile(value: List<SkipAst.Definition>) extends SKStore.File
279+ class DefsWithAccessedEnvVarsFile(
280+ defs: List<SkipAst.Definition>,
281+ accessed_env_vars: SortedSet<String>,
282+ ) extends SKStore.File
257283
258- fun parseFile(file: FileCache.InputSource, source: String): DefsFile {
259- fileResult = SkipParser.parseSource(source, true);
260- ast = parseToAst(file, fileResult);
261- DefsFile(ast)
284+ fun parseFile(
285+ file: FileCache.InputSource,
286+ source: String,
287+ ): DefsWithAccessedEnvVarsFile {
288+ (fileResult, accessed_env_vars) = SkipParser.parseSource(source, true);
289+ defs = parseToAst(file, fileResult);
290+ DefsWithAccessedEnvVarsFile(defs, accessed_env_vars)
262291}
263292
264293fun parseToAst(
0 commit comments