about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorDaniel Shahaf <d.s@daniel.shahaf.name>2020-03-19 21:15:54 +0000
committerDaniel Shahaf <d.s@daniel.shahaf.name>2020-03-22 02:23:52 +0000
commit338a4a299ad9b5c2e925a5c7ec38d1a6c811c4ed (patch)
tree090b9aa593ef4fcabca677474a43491a9251b8f2 /Src
parent4960699de2fd010598d14d59f4bcd3d9b48ec46b (diff)
downloadzsh-338a4a299ad9b5c2e925a5c7ec38d1a6c811c4ed.tar.gz
zsh-338a4a299ad9b5c2e925a5c7ec38d1a6c811c4ed.tar.xz
zsh-338a4a299ad9b5c2e925a5c7ec38d1a6c811c4ed.zip
45583/0004: internal: Add some comments around wordcodes. No functional change.
Diffstat (limited to 'Src')
-rw-r--r--Src/parse.c7
-rw-r--r--Src/zsh.h8
2 files changed, 13 insertions, 2 deletions
diff --git a/Src/parse.c b/Src/parse.c
index 170e07298..a4f83b573 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -102,6 +102,13 @@ struct heredocs *hdocs;
  * The parser now produces word code, reducing memory consumption compared
  * to the nested structs we had before.
  *
+ * Word codes are represented by the "wordcode" type.
+ *
+ * Each wordcode variable consists of a "code", in the least-significant bits
+ * of the value, and "data" in the other bits.  The macros wc_code() and wc_data()
+ * access the "code" and "data" parts of a wordcode.  The macros wc_bdata() and
+ * wc_bld() build wordcodes from code and data.
+ *
  * Word code layout:
  *
  *   WC_END
diff --git a/Src/zsh.h b/Src/zsh.h
index 82d152bb8..d72c338da 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -866,8 +866,8 @@ struct eccstr {
 #define EC_DUP    1
 #define EC_DUPTOK 2
 
+/* See comment at the top of Src/parse.c for details. */
 #define WC_CODEBITS 5
-
 #define wc_code(C)   ((C) & ((wordcode) ((1 << WC_CODEBITS) - 1)))
 #define wc_data(C)   ((C) >> WC_CODEBITS)
 #define wc_bdata(D)  ((D) << WC_CODEBITS)
@@ -896,7 +896,11 @@ struct eccstr {
 #define WC_AUTOFN  20
 #define WC_TRY     21
 
-/* increment as necessary */
+/* 
+ * Increment as necessary.
+ * 
+ * If this exceeds 31, increment WC_CODEBITS.
+ */
 #define WC_COUNT   22
 
 #define WCB_END()           wc_bld(WC_END, 0)