Skip to content

Commit

Permalink
add __rvalue(expression) builtin
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Nov 3, 2024
1 parent f713bd3 commit 0f383fd
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 27 deletions.
56 changes: 29 additions & 27 deletions compiler/src/dmd/frontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -2068,6 +2068,7 @@ enum class EXP : uint8_t
_Generic_ = 125u,
interval = 126u,
loweredAssignExp = 127u,
rvalue = 128u,
};

typedef uint64_t dinteger_t;
Expand Down Expand Up @@ -2888,33 +2889,34 @@ enum class TOK : uint8_t
wchar_tLiteral = 196u,
endOfLine = 197u,
whitespace = 198u,
inline_ = 199u,
register_ = 200u,
restrict_ = 201u,
signed_ = 202u,
sizeof_ = 203u,
typedef_ = 204u,
unsigned_ = 205u,
volatile_ = 206u,
_Alignas_ = 207u,
_Alignof_ = 208u,
_Atomic_ = 209u,
_Bool_ = 210u,
_Complex_ = 211u,
_Generic_ = 212u,
_Imaginary_ = 213u,
_Noreturn_ = 214u,
_Static_assert_ = 215u,
_Thread_local_ = 216u,
_assert_ = 217u,
_import_ = 218u,
__cdecl_ = 219u,
__declspec_ = 220u,
__stdcall_ = 221u,
__thread_ = 222u,
__pragma_ = 223u,
__int128_ = 224u,
__attribute___ = 225u,
rvalue = 199u,
inline_ = 200u,
register_ = 201u,
restrict_ = 202u,
signed_ = 203u,
sizeof_ = 204u,
typedef_ = 205u,
unsigned_ = 206u,
volatile_ = 207u,
_Alignas_ = 208u,
_Alignof_ = 209u,
_Atomic_ = 210u,
_Bool_ = 211u,
_Complex_ = 212u,
_Generic_ = 213u,
_Imaginary_ = 214u,
_Noreturn_ = 215u,
_Static_assert_ = 216u,
_Thread_local_ = 217u,
_assert_ = 218u,
_import_ = 219u,
__cdecl_ = 220u,
__declspec_ = 221u,
__stdcall_ = 222u,
__thread_ = 223u,
__pragma_ = 224u,
__int128_ = 225u,
__attribute___ = 226u,
};

class FuncExp final : public Expression
Expand Down
6 changes: 6 additions & 0 deletions compiler/src/dmd/tokens.d
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ enum TOK : ubyte
{
reserved,

// if this list changes, update ../tests/cxxfrontend.cc and ../../test/unit/lexer/location_offset.d to match

// Other
leftParenthesis,
rightParenthesis,
Expand Down Expand Up @@ -249,6 +251,7 @@ enum TOK : ubyte
wchar_tLiteral,
endOfLine, // \n, \r, \u2028, \u2029
whitespace,
rvalue,

// C only keywords
inline,
Expand Down Expand Up @@ -425,6 +428,7 @@ enum EXP : ubyte
interval,

loweredAssignExp,
rvalue,
}

enum FirstCKeyword = TOK.inline;
Expand Down Expand Up @@ -556,6 +560,7 @@ private immutable TOK[] keywords =
TOK.prettyFunction,
TOK.shared_,
TOK.immutable_,
TOK.rvalue,

// C only keywords
TOK.inline,
Expand Down Expand Up @@ -680,6 +685,7 @@ extern (C++) struct Token
TOK.pragma_: "pragma",
TOK.typeof_: "typeof",
TOK.typeid_: "typeid",
TOK.rvalue: "__rvalue",
TOK.template_: "template",
TOK.void_: "void",
TOK.int8: "byte",
Expand Down
1 change: 1 addition & 0 deletions compiler/src/dmd/tokens.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ enum class TOK : unsigned char
auto_,
package_,
immutable_,
rvalue,

// Statements
if_,
Expand Down
1 change: 1 addition & 0 deletions compiler/test/unit/lexer/location_offset.d
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ enum Test[string] tests = [
"auto_" : Test("auto"),
"package_" : Test("package"),
"immutable_" : Test("immutable"),
"rvalue" : Test("__rvalue"),

"if_" : Test("if"),
"else_" : Test("else"),
Expand Down

0 comments on commit 0f383fd

Please sign in to comment.