Commit Graph

72 Commits

Author SHA1 Message Date
ridiculousfish
eff4873eca Stop creating subclasses of block_t
Move all block_t creation methods to static methods, and stop creating
subclasses (all of which are now empty).
2019-05-19 14:40:35 -07:00
ridiculousfish
cf92b7626c Migrate event_block's event into block_t 2019-05-19 13:07:06 -07:00
ridiculousfish
8697fa063b Migrate source_block's source_file into block_t
Continue to work towards flattening this hierarchy.
2019-05-19 13:01:59 -07:00
ridiculousfish
fec0e40b5e Migrate function_block name and args into block_t
The goal is to eliminate this block hierarchy.
2019-05-19 12:56:07 -07:00
ridiculousfish
cd7e8f4103 Migrate loop status from blocks into libdata
Blocks will soon need to be shared across parsers. Migrate the loop status
(like break or continue) from the block into the libdata. It turns out we
only ever need one, we don't need to track this per-block.

Make it an enum class.
2019-05-19 12:50:05 -07:00
ridiculousfish
c42eb0eb4f Remove the process from function_block_t
Prior to this fix, a function_block stored a process_t, which was only used
when printing backtraces. Switch this to an array of arguments, and make
various other cleanups around null terminated argument arrays.
2019-05-18 21:09:04 -07:00
ridiculousfish
508c3a8005 Make is_event and other globals part of parser_t libdata 2019-05-18 19:03:45 -07:00
ridiculousfish
5158ee812b Eliminate the job from block_t
This exists only to support the '--on-job-exit caller' feature.
Just store the calling job ID directly in the parser's libdata.
2019-05-18 18:50:28 -07:00
ridiculousfish
1719d6f136 Make $status and $pipestatus per-parser
Another step towards allowing multiple parsers to execute in parallel.
2019-05-12 14:00:44 -07:00
ridiculousfish
8a8b2513b5 Eliminate the global jobs() function
All job lists are attached to a parser now.
2019-05-05 11:33:08 -07:00
Fabian Homborg
c2970f9618 Reformat all files
This runs build_tools/style.fish, which runs clang-format on C++, fish_indent on fish and (new) black on python.

If anything is wrong with the formatting, we should fix the tools, but automated formatting is worth it.
2019-05-05 12:09:25 +02:00
ridiculousfish
9fb98baba6 Thread the parser into process_clean_after_marking 2019-05-04 20:58:35 -07:00
ridiculousfish
36998eee55 Make more miscellaneous globals thread safe 2019-05-04 20:58:35 -07:00
ridiculousfish
0de1611bf1 Migrate builtin_complete recursion_level into parser_t::libdata 2019-05-04 20:58:35 -07:00
ridiculousfish
b0a695e9fa Migrate the global exec_count into the parser 2019-05-04 20:58:35 -07:00
ridiculousfish
bffacd2fbf Thread a parser into expansion
Expansion may perform command substitution, which needs to know the parser
to use.
2019-05-04 19:30:00 -07:00
ridiculousfish
923a7ca0f0 Thread the parser into complete()
Eliminates uses of principal_parser
2019-05-04 18:17:18 -07:00
Mahmoud Al-Qudsi
b2a1da602f Fix error propagation in parser_t::eval
It was unconditionally returning `parse_execution_success`. This was
causing certain parser errors to incorrectly return after evaluation
with `$status` equal to `0`, as reported after `eval`, `source`, or
sub-`fish` execution.
2019-04-13 17:28:16 -05:00
ridiculousfish
dd007c29f4 Revert "parser: try to avoid some strings being copied"
This reverts commit 7a74198aa3.

Believe it or not this commit actually increased copying. When accepting
a value you know you're going to take ownership of, just accept it by
value; then temporaries can invoke the move ctor and blah blah blah.

We really need a lightweight refcounted pass-by-value string to make this
less error prone.
2019-04-01 20:22:02 -07:00
Mahmoud Al-Qudsi
f8e0e0ef82 Remove abstractions around job list
Directly access the job list without the intermediate job_iterator_t,
and remove functions that are ripe for abuse by modifying a local
enumeration of the same list instead of operating on the iterators
directly (e.g. proc.cpp iterates jobs, and mid-iteration calls
parser::job_remove(j) with the job (and not the iterator to the job),
causing an invisible invalidation of the pre-existing local iterators.
2019-03-28 18:55:36 -05:00
Aaron Gyes
7a74198aa3 parser: try to avoid some strings being copied 2019-03-23 12:34:48 -07:00
ridiculousfish
815e20066b parser_t to become enable_shared_from_this 2019-02-24 12:12:24 -08:00
ridiculousfish
780b53ba73 Convert event_type_t to an enum class 2019-02-23 13:17:28 -08:00
ridiculousfish
003998c921 Event blocks just block all events
In a galaxy far, far away, event_blockage_t was intended to block only cetain
events. But it always just blocked everything. Eliminate the event block
mask.
2019-02-23 13:02:07 -08:00
ridiculousfish
6f52e6bb1c Instantize contents of exec.cpp and others 2019-01-10 20:07:47 -08:00
ridiculousfish
421fbdd52a Instantize env_get_pwd_slash
This requires threading environment_t through many places, such as completions
and history. We introduce null_environment_t for when the environment isn't
important.
2019-01-10 20:01:28 -08:00
ridiculousfish
a47f6859bd Equip parser_t with a variable stack
Prepares to eliminate env_get and env_set by accessing variables through
a parser.
2019-01-10 20:29:10 -08:00
ridiculousfish
895c2c4af0 Minor cleanup of parser interface 2019-01-10 20:29:10 -08:00
ridiculousfish
3770d9fb7a Teach each job about its parent
The parent of a job is the parent pipeline that executed the function or
block corresponding to this job. This will help simplify
process_mark_finished_children().
2018-11-04 01:40:07 -08:00
Jon Eyolfson
c3ca108dbe Added const to methods which 'ought to be const' based on Const Checker 2018-08-09 19:05:47 -07:00
ridiculousfish
137c2559d9 Remove parser_error
It was unused.
2018-02-18 20:29:28 -08:00
ridiculousfish
da84b38430 Constructors to accept more parameters by value
In cases where the constructor needs to take ownership of parameters,
pass them by value and use std::move.
2018-02-18 19:12:45 -08:00
ridiculousfish
d536b152f7 Simplify the parser_t::eval() return type to void
The return value was unused.
2018-02-12 10:55:55 -08:00
ridiculousfish
4eb73862fc Switch parser_t::execution_contexts to only storing one
We only ever need the topmost (currently executing) context. We can
store the stack via the C stack rather than an explicit std::vector.
2018-02-12 10:55:42 -08:00
ridiculousfish
92d5c28730 Move eval_level into parser_t
This avoids the ping-ponging of eval_level through
parse_execution_context. Simply store the global eval level in the
parser_t.
2018-02-12 10:55:31 -08:00
ridiculousfish
8bddce2633 Remove fake_block_t
It was unused.
2018-02-12 10:55:28 -08:00
ridiculousfish
3e063e7c13 Remove node_offset from block_t
It was not used. Also clean up the constructor some.
2018-02-12 10:55:26 -08:00
ridiculousfish
c3f1961e36 Stop copying out function definition when executing a function
This switches function execution from the function's source code to
its stored node and pstree. This means we no longer have to re-parse
the function every time we execute it.
2018-02-12 10:55:00 -08:00
ridiculousfish
41ba0dfadb Evaluate tnode_t instead of parse_node_t
This concerns block nodes with redirections, like
begin ... end | grep ...
Prior to this fix, we passed in a pointer to the node. Switch to passing
in the tnode and parsed source ref. This improves type safety and better
aligns with the function-node plans.
2018-02-12 10:51:39 -08:00
ridiculousfish
a99eecfad8 Wrap up source code and a parse tree into a new type parsed_source_ref_t
This will make it unnecessary to carry around the parse tree and source
separately, and enable some simplifications.
2017-12-22 14:40:15 -08:00
Kurtis Rader
4ef14ea6e2 another make style-all cleanup 2017-06-23 23:19:09 -07:00
Kurtis Rader
30368d5526 implement status function when in a breakpoint
Another step to fixing #1310. This changes means that `status -L0
function` reports the correct function when inside a breakpoint.
2017-06-23 22:14:21 -07:00
Kurtis Rader
385e40540c fix issues with builtin_function()
This does several things. It fixes `builtin_function()` so that errors it
emits are displayed. As part of doing that I've removed the unnecessary
`out_err` parameter to make the interface like every other builtin.

This also fixes a regression introduced by #4000 which was attempting to
fix a bug introduced by #3649.

Fixes #4139
2017-06-18 12:55:14 -07:00
Kurtis Rader
65c762f1e1 fix parser error message
Fixes #4000
2017-04-29 21:33:50 -07:00
David Adam
d32e7f5ad7 job_get_from_pid: use canonical pid_t type 2017-04-29 19:20:03 +08:00
Marc Garcia Sastre
980af4aa5b status returns the function name when called with -u parameter
Fixes #1743
2017-04-26 20:15:45 -07:00
Kurtis Rader
4ffb0adb78 lint cleanups 2017-02-11 21:30:38 -08:00
Kurtis Rader
5b6cc5af6d time for another make style-all
Gotta keep the entropy (i.e., disorder) from increasing.
2017-01-26 20:05:46 -08:00
ridiculousfish
fec83fa975 Eliminate moved_ref
Use real rvalue references instead
2017-01-26 15:43:46 -08:00
ridiculousfish
14fb38f952 Switch job handling to use shared pointers instead of raw pointers
Clarifies memory management around allocation of job_ts
2017-01-26 14:47:32 -08:00