summaryrefslogtreecommitdiffstats
path: root/src/dict.c
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2024-05-30 07:50:08 +0200
committerChristian Brabandt <cb@256bit.org>2024-05-30 07:52:44 +0200
commit51c45e89b50a4841147b9fbd7c6095ab79a10c71 (patch)
tree7e02cf9316e7d729bf29ac35ba29a584e870b49b /src/dict.c
parent51024bbc1a9e298b1fb8f2e465fccb5db409551e (diff)
patch 9.1.0450: evalc. code too complexv9.1.0450
Problem: eval.c code too complex Solution: refactor eval6() and eval9() functions into several smaller functions (Yegappan Lakshmanan) closes: #14875 Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src/dict.c')
-rw-r--r--src/dict.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/dict.c b/src/dict.c
index c78995d80e..bf45b0b928 100644
--- a/src/dict.c
+++ b/src/dict.c
@@ -1092,6 +1092,33 @@ failret:
}
/*
+ * Evaluate a literal dictionary: #{key: val, key: val}
+ * "*arg" points to the "#".
+ * On return, "*arg" points to the character after the Dict.
+ * Return OK or FAIL. Returns NOTDONE for {expr}.
+ */
+ int
+eval_lit_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
+{
+ int vim9script = in_vim9script();
+ int ret = OK;
+
+ if (vim9script)
+ {
+ ret = vim9_bad_comment(*arg) ? FAIL : NOTDONE;
+ }
+ else if ((*arg)[1] == '{')
+ {
+ ++*arg;
+ ret = eval_dict(arg, rettv, evalarg, TRUE);
+ }
+ else
+ ret = NOTDONE;
+
+ return ret;
+}
+
+/*
* Go over all entries in "d2" and add them to "d1".
* When "action" is "error" then a duplicate key is an error.
* When "action" is "force" then a duplicate key is overwritten.