Skip to content

Commit 2cf8312

Browse files
committed
FEAT: hash! datatype (works like block! for now, hashing not implemented yet)
1 parent 324f5dc commit 2cf8312

File tree

6 files changed

+26
-4
lines changed

6 files changed

+26
-4
lines changed

src/boot/types.reb

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ REBOL [
33
Title: "Datatype definitions"
44
Rights: {
55
Copyright 2012 REBOL Technologies
6-
Copyright 2012-2021 Rebol Open Source Contributors
6+
Copyright 2012-2024 Rebol Open Source Contributors
77
REBOL is a trademark of REBOL Technologies
88
}
99
License: {
@@ -66,6 +66,7 @@ REBOL [
6666
get-path path block * * * * [series block path]
6767
lit-path lit-path block * * * * [series block path]
6868

69+
hash self block + f* * * [series block]
6970
map self map + f* * * -
7071

7172
datatype self datatype + f* - * -

src/boot/typespec.reb

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ REBOL [
33
Title: "Datatype help spec"
44
Rights: {
55
Copyright 2012 REBOL Technologies
6+
Copyright 2012-2024 Rebol Open Source Contributors
67
REBOL is a trademark of REBOL Technologies
78
}
89
License: {
@@ -35,6 +36,7 @@ get-path ["the value of a path" block]
3536
get-word ["the value of a word (variable)" word]
3637
gob ["graphical object" opt-object]
3738
handle ["arbitrary internal object or value" internal]
39+
hash ["series of values (using hash table)" block]
3840
image ["RGB image with alpha channel" vector]
3941
integer ["64 bit integer" scalar]
4042
issue ["identifying marker word" word]

src/core/m-gc.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
** REBOL [R3] Language Interpreter and Run-time Environment
44
**
55
** Copyright 2012 REBOL Technologies
6-
** Copyright 2012-2021 Rebol Open Source Contributors
6+
** Copyright 2012-2024 Rebol Open Source Contributors
77
** REBOL is a trademark of REBOL Technologies
88
**
99
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -454,6 +454,7 @@ static void Mark_Series(REBSER *series, REBCNT depth);
454454
case REB_SET_PATH:
455455
case REB_GET_PATH:
456456
case REB_LIT_PATH:
457+
case REB_HASH:
457458
ser = VAL_SERIES(val);
458459
ASSERT(ser != 0, RP_NULL_SERIES);
459460
if (IS_BARE_SERIES(ser)) {

src/core/s-mold.c

+17
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
** REBOL [R3] Language Interpreter and Run-time Environment
44
**
55
** Copyright 2012 REBOL Technologies
6+
** Copyright 2012-2024 Rebol Open Source Contributors
67
** REBOL is a trademark of REBOL Technologies
78
**
89
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -806,6 +807,15 @@ STOID Mold_Block(REBVAL *value, REB_MOLD *mold, REBFLG molded)
806807
}
807808
}
808809

810+
STOID Mold_Hash(REBVAL *value, REB_MOLD *mold, REBFLG molded) {
811+
Pre_Mold(value, mold); // #(hash! part
812+
Mold_Block_Series(mold, VAL_SERIES(value), VAL_INDEX(value), 0);
813+
if (GET_MOPT(mold, MOPT_MOLD_ALL))
814+
Post_Mold(value, mold);
815+
else
816+
End_Mold(mold);
817+
}
818+
809819
STOID Mold_Simple_Block(REB_MOLD *mold, REBVAL *block, REBCNT len)
810820
{
811821
// Simple molder for error locations. Series must be valid.
@@ -1383,6 +1393,13 @@ STOID Mold_Error(REBVAL *value, REB_MOLD *mold, REBFLG molded)
13831393
Mold_Map(value, mold, molded);
13841394
break;
13851395

1396+
case REB_HASH:
1397+
if (molded)
1398+
Mold_Hash(value, mold, molded);
1399+
else
1400+
Form_Block_Series(VAL_SERIES(value), VAL_INDEX(value), mold, 0);
1401+
break;
1402+
13861403
case REB_GOB:
13871404
{
13881405
REBSER *blk;

src/include/sys-value.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1311,7 +1311,7 @@ typedef struct Reb_All {
13111311
#define ANY_SERIES(v) (VAL_TYPE(v) >= REB_BINARY && VAL_TYPE(v) <= REB_LIT_PATH)
13121312
#define ANY_STR(v) (VAL_TYPE(v) >= REB_STRING && VAL_TYPE(v) <= REB_TAG)
13131313
#define ANY_BINSTR(v) (VAL_TYPE(v) >= REB_BINARY && VAL_TYPE(v) <= REB_TAG)
1314-
#define ANY_BLOCK(v) (VAL_TYPE(v) >= REB_BLOCK && VAL_TYPE(v) <= REB_LIT_PATH)
1314+
#define ANY_BLOCK(v) (VAL_TYPE(v) >= REB_BLOCK && VAL_TYPE(v) <= REB_HASH)
13151315
#define ANY_WORD(v) (VAL_TYPE(v) >= REB_WORD && VAL_TYPE(v) <= REB_ISSUE)
13161316
#define ANY_PATH(v) (VAL_TYPE(v) >= REB_PATH && VAL_TYPE(v) <= REB_LIT_PATH)
13171317
#define ANY_FUNC(v) (VAL_TYPE(v) >= REB_NATIVE && VAL_TYPE(v) <= REB_FUNCTION)

src/mezz/mezz-types.reb

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ REBOL [
33
Title: "REBOL 3 Mezzanine: To-Type Helpers"
44
Rights: {
55
Copyright 2012 REBOL Technologies
6+
Copyright 2012-2024 Rebol Open Source Contributors
67
REBOL is a trademark of REBOL Technologies
78
}
89
License: {
@@ -19,7 +20,7 @@ to-bitset: to-image: to-vector: to-block: to-paren:
1920
to-path: to-set-path: to-get-path: to-lit-path: to-map: to-datatype: to-typeset:
2021
to-word: to-set-word: to-get-word: to-lit-word: to-ref: to-refinement: to-issue:
2122
to-command: to-closure: to-function: to-object: to-module: to-error: to-port: to-gob:
22-
to-event:
23+
to-event: to-hash:
2324
none
2425

2526
; Auto-build the functions for the above TO-* words.

0 commit comments

Comments
 (0)