Commit Graph

84 Commits

Author SHA1 Message Date
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
Kurtis Rader
4df5e8e015 Use exported methods to access ports
Commit 734eb95 changed most uses of `fm.ports[x].` to a public method
that makes the intent clearer. This changes a couple of uses that were
overlooked by that prior change.
2020-12-25 01:11:33 +00:00
Shengjing Zhu
6c08de0ff3 Fix typos found by codespell 2020-10-10 22:47:50 +01:00
Qi Xiao
2af7361bd5 pkg/eval: De-export Closure. 2020-09-04 22:18:50 +01:00
Qi Xiao
9b9a6de2cd pkg/eval: Cause -> Reason. 2020-09-04 21:04:58 +01:00
Qi Xiao
fca1621294 pkg/eval: Export the StackTrace type. 2020-09-03 05:54:32 +01:00
Qi Xiao
0c00a92839 Fix crash when accessing the body attribute of fn-defined functions.
This fixes #1126.
2020-08-25 20:17:21 +01:00
Qi Xiao
b04ea12d48 pkg/eval: Refactor effectOp and valuesOp, remove lvaluesOp.
* Make effectOp and valuesOp interfaces - implementations now handle the
  range information themselves.

* Remove lvaluesOp; it is no longer used.
2020-08-22 19:57:11 +01:00
Qi Xiao
1e2ead56e2 pkg/eval: Rewrite the lvalue parsing code.
Also lift the restriction on rest variables and rest arguments - they may now
appear anywhere, as long as there is only one.
2020-08-20 13:15:00 +01:00
Qi Xiao
ea31426a9a pkg/eval: Refactor to reuse code between "use" and "eval". 2020-08-16 23:32:51 +01:00
Qi Xiao
e5e0446c5a Warn about deprecated syntax features in imported modules.
This fixes #1072.
2020-07-15 00:04:03 +01:00
Qi Xiao
7b9f784cd5 pkg/eval: Rename fields of Exception, and expose fields as a pseudomap. 2020-06-29 21:26:10 +01:00
Qi Xiao
c767f92d01 Support compile-time deprecation.
This fixes #898.
2020-04-26 13:14:51 +01:00
Qi Xiao
88122a019e pkg: Simplify some APIs by using parse.Tree. 2020-04-25 19:36:35 +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
13f7b29707 pkg/parse: Add a new Parse function and a Tree type.
This replaces the AsChunk function. All current users of parse.AsChunk has been
changed to use parse.Parse instead.
2020-04-25 19:16:22 +01:00
Qi Xiao
21f5a6f7c3 pkg/parse: Turn most public methods of Node into functions.
This make the godoc of the parse package much cleaner and removes some
boilerplate.
2020-04-25 18:55:44 +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
c112223611 pkg/eval: Simplify API of "src".
Remove the Type and Root fields, and add a new IsFile field.
2020-04-25 12:50:07 +01:00
Qi Xiao
64e282c828 pkg/eval: Replace ValuesUnwrapper with simple functions.
Also add structured BadValue error type to pkg/eval/errs.
2020-04-13 13:27:55 +01:00
Qi Xiao
af6b523e02 pkg/eval: Remove Frame.{eval,Call}. 2020-04-09 21:01:14 +01:00
Qi Xiao
ffa9727f14 pkg/eval: Remove Frame.srcRange.
Maintaining a state of current range is error-prone. Instead, always keep track
of range information explicitly.
2020-04-09 20:44:09 +01:00
Qi Xiao
bcd1c1df6f pkg/eval: Move intCh from Evaler to Frame.
This avoids a race condition when using EvalInTTY concurrently.

This addresses #73.
2020-03-28 23:56:47 +00:00
Qi Xiao
72234e70fa [cleanup] pkg/eval: Replace frame.{begin,end} with a Ranging. 2020-03-28 22:03:42 +00:00
Qi Xiao
e6b7d06e80 [cleanup] pkg/eval: Remove compiler.errorf and compiler.compiling.
All errors are now written using compiler.errorpf.
2020-03-28 21:33:55 +00:00
Qi Xiao
d306f33af6 [cleanup] pkg/eval: Let compiler.errorpf accept a single diag.Ranger. 2020-03-28 21:33:55 +00:00
Qi Xiao
11919e83ec [cleanup] pkg/eval: use diag.Ranging in op types. 2020-03-28 21:33:55 +00:00
Qi Xiao
6b6029452f Revert "Validate namespace and function names"
This breaks the use of meta characters in names of user-defined functions. See
b.elv.sh/946 on how to resolve the inconsistency on the restrictions in variable
names.

This reverts commit 02f5433789.
2020-03-22 22:06:14 +00:00
Kurtis Rader
02f5433789 Validate namespace and function names
Resolves #561
2020-03-20 23:15:02 +00:00
Qi Xiao
b3a48ed510 pkg/eval: Revamp Source. 2020-01-11 03:01:30 +00:00
Qi Xiao
433b5f2d96 pkg/eval: Lift the restriction of relative "use" from scripts. 2020-01-11 02:27:43 +00:00
Qi Xiao
44f266f92c pkg/eval: De-export SrcType. 2020-01-05 13:54:08 +00:00
Qi Xiao
e45fdf7228 Move all libraries to new pkg/. 2019-12-23 20:00:59 +00:00