Commit Graph

18 Commits

Author SHA1 Message Date
Qi Xiao
94e43cd2fd pkg/eval: Add tests for errors in tilde expansion. 2022-06-19 23:34:36 +01:00
Qi Xiao
51e4d97568 interface{} -> any now that Elvish requires Go 1.18. 2022-03-20 16:17:19 +00:00
Qi Xiao
4d62732ebc Fix "indicies" -> indices. 2021-08-22 23:31:26 +01:00
Qi Xiao
196eea21d4 Change module import path to src.elv.sh 2021-01-27 01:30:25 +00:00
Qi Xiao
02d9252b5d pkg/eval: Return bool instead error from (*Evaler)'s PurelyEval* methods. 2021-01-09 16:05:04 +00:00
Qi Xiao
9991b08fe0 Fix panic in completion of non-existing namespace variable.
This fixes #1209.
2021-01-09 15:54:12 +00:00
Qi Xiao
a2790af67a pkg/eval: Clean up the structure and methods of Evaler and Frame.
- Make Evaler mostly thread-safe. The only remaining thread-unsafe part is the
  modules field, which is more tricky than other fields.

- Remove the state and evalerScopes type, and move their fields into Evaler.

- Expose valuePrefix via a get method, and change PortsFromFiles to take the
  prefix instead of a *Evaler. Also expose a PortsFromStdFiles.

- Make Evaler a normal field of Frame, instead of an embedded field. This makes
  access to global states more explicit.
2021-01-05 00:22:09 +00:00
Qi Xiao
7932f58201 pkg/eval: Add a (*Evaler).Call method for calling a function.
Most of the places that need to directly call a function is in the edit package,
which need to call user-defined callbacks.

This change eliminates most call sites of NewTopFrame (including all call sites
outside the eval package). Remove the function and inline it in the remaining
few call sites.

Remove NewTopFrame means that the eval package no longer offers other packages
a way to construct Frame instances. This is intended: Frame is a relatively
low-level concept, and all code outside the eval package now uses the more
high-level Eval, Call, Check/CheckTree methods of *Evaler. The most notable
exception is packages that implement modules; they may still use Frame to access
the information kept in it, but they never construct Frame instances.

In future, the Frame type can be changed to an interface.
2021-01-03 18:57:11 +00:00
Qi Xiao
719314c029 pkg/eval: Various cleanups for qname handling code. 2020-12-25 22:31:52 +00:00
Qi Xiao
6419f4524a Implement namespaces using slices instead of maps.
More related improvements and cleanups will be done in followup commits.

This fixes #1139.
2020-12-25 17:46:46 +00:00
Qi Xiao
9df62a6dc9 pkg/eval: Remove unused PurelyEvalCompound. 2020-09-04 22:15:15 +01:00
Qi Xiao
11898f763a pkg/util: Break into fsutil/ and logutil/. 2020-09-03 05:27:18 +01:00
Qi Xiao
20979b44a2 pkg/parse: Use Source values, not pointers.
The Source type is small enough that using values is likely more efficient.
2020-04-25 19:22:38 +01:00
Qi Xiao
b8505c7065 pkg/eval/source.go -> pkg/parse/source.go. 2020-04-25 18:26:17 +01:00
Qi Xiao
53a1eca9af pkg/eval: Remove New*Source functions.
All call sites of such functions are replaced with simple &Source{...}
expressions.
2020-04-25 13:22:07 +01:00
Qi Xiao
bca4c8062c [cleanup] pkg/eval: Simplify PurelyEvalPartialCompound.
This makes the function easier to test.
2020-03-31 05:13:00 +01:00
Qi Xiao
10b4baf89c pkg/eval: NewInternalSource -> NewInternalGoSource. 2020-01-05 14:07:03 +00:00
Qi Xiao
e45fdf7228 Move all libraries to new pkg/. 2019-12-23 20:00:59 +00:00