[torque] Add local const bindings

This CL adds local const bindings. This means that instead of
generating TVARIABLEs for variables, we can generate simple TNodes.

Example:

macro FooBar(): {
  const kSomeSmi: Smi = 10;
  ...
}

This CL also enforces that variables with a constexpr type are bound
using 'const' and not 'let'.

R=tebbi@chromium.org

Bug: v8:7793
Change-Id: Id20a18149df9fc374ce718bdb1478e3eabb6e6df
Reviewed-on: https://chromium-review.googlesource.com/1138316
Commit-Queue: Simon Zünd <szuend@google.com>
Reviewed-by: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54479}
This commit is contained in:
Simon Zünd 2018-07-17 08:39:07 +02:00 committed by Commit Bot
parent aab1d29d82
commit b95def3488
14 changed files with 892 additions and 867 deletions

View File

@ -31,6 +31,7 @@ TAIL: 'tail';
ISNT: 'isnt';
IS: 'is';
LET: 'let';
CONST: 'const';
EXTERN: 'extern';
ASSERT_TOKEN: 'assert';
CHECK_TOKEN: 'check';
@ -227,7 +228,7 @@ argumentList: '(' argument? (',' argument)* ')';
helperCall: (MIN | MAX | IDENTIFIER) genericSpecializationTypeList? argumentList optionalOtherwise;
labelReference: IDENTIFIER;
variableDeclaration: LET IDENTIFIER ':' type;
variableDeclaration: (LET | CONST) IDENTIFIER ':' type;
variableDeclarationWithInitialization: variableDeclaration (ASSIGNMENT expression)?;
helperCallStatement: (TAIL)? helperCall;
expressionStatement: assignment;
@ -277,8 +278,8 @@ externalRuntime : EXTERN RUNTIME IDENTIFIER typeListMaybeVarArgs optionalType ';
builtinDeclaration : JAVASCRIPT? BUILTIN IDENTIFIER optionalGenericTypeList parameterList optionalType (helperBody | ';');
genericSpecialization: IDENTIFIER genericSpecializationTypeList parameterList optionalType optionalLabelList helperBody;
macroDeclaration : ('operator' STRING_LITERAL)? MACRO IDENTIFIER optionalGenericTypeList parameterList optionalType optionalLabelList (helperBody | ';');
externConstDeclaration : 'const' IDENTIFIER ':' type generatesDeclaration ';';
constDeclaration: 'const' IDENTIFIER ':' type ASSIGNMENT expression ';';
externConstDeclaration : CONST IDENTIFIER ':' type generatesDeclaration ';';
constDeclaration: CONST IDENTIFIER ':' type ASSIGNMENT expression ';';
declaration
: typeDeclaration

View File

@ -69,7 +69,6 @@ std::vector<std::string> TorqueLexer::_ruleNames = {u8"T__0",
u8"T__17",
u8"T__18",
u8"T__19",
u8"T__20",
u8"MACRO",
u8"BUILTIN",
u8"RUNTIME",
@ -92,6 +91,7 @@ std::vector<std::string> TorqueLexer::_ruleNames = {u8"T__0",
u8"ISNT",
u8"IS",
u8"LET",
u8"CONST",
u8"EXTERN",
u8"ASSERT_TOKEN",
u8"CHECK_TOKEN",
@ -160,7 +160,6 @@ std::vector<std::string> TorqueLexer::_literalNames = {"",
u8"'extends'",
u8"'generates'",
u8"'operator'",
u8"'const'",
u8"'macro'",
u8"'builtin'",
u8"'runtime'",
@ -183,6 +182,7 @@ std::vector<std::string> TorqueLexer::_literalNames = {"",
u8"'isnt'",
u8"'is'",
u8"'let'",
u8"'const'",
u8"'extern'",
u8"'assert'",
u8"'check'",
@ -237,7 +237,6 @@ std::vector<std::string> TorqueLexer::_symbolicNames = {
"",
"",
"",
"",
u8"MACRO",
u8"BUILTIN",
u8"RUNTIME",
@ -260,6 +259,7 @@ std::vector<std::string> TorqueLexer::_symbolicNames = {
u8"ISNT",
u8"IS",
u8"LET",
u8"CONST",
u8"EXTERN",
u8"ASSERT_TOKEN",
u8"CHECK_TOKEN",
@ -376,36 +376,36 @@ TorqueLexer::Initializer::Initializer() {
0x3, 0x15, 0x3, 0x15, 0x3, 0x15, 0x3, 0x16, 0x3,
0x16, 0x3, 0x16, 0x3, 0x16, 0x3, 0x16, 0x3, 0x16,
0x3, 0x17, 0x3, 0x17, 0x3, 0x17, 0x3, 0x17, 0x3,
0x17, 0x3, 0x17, 0x3, 0x18, 0x3, 0x18, 0x3, 0x18,
0x17, 0x3, 0x17, 0x3, 0x17, 0x3, 0x17, 0x3, 0x18,
0x3, 0x18, 0x3, 0x18, 0x3, 0x18, 0x3,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 0x112, 0x7,
0x77, 0x2, 0x2, 0x112, 0x113, 0x7, 0x6e, 0x2, 0x2,
0x113, 0x114, 0x7, 0x67, 0x2, 0x2, 0x114, 0x34, 0x3,
0x2, 0x2, 0x2, 0x115, 0x116, 0x7, 0x6c, 0x2, 0x2,
0x116, 0x117, 0x7, 0x63, 0x2, 0x2, 0x117, 0x118, 0x7,
0x78, 0x2, 0x2, 0x118, 0x119, 0x7, 0x63, 0x2, 0x2,
0x119, 0x11a, 0x7, 0x75, 0x2, 0x2, 0x11a, 0x11b, 0x7,
0x65, 0x2, 0x2, 0x11b, 0x11c, 0x7, 0x74, 0x2, 0x2,
0x11c, 0x11d, 0x7, 0x6b, 0x2, 0x2, 0x11d, 0x11e, 0x7,
0x72, 0x2, 0x2, 0x11e, 0x11f, 0x7, 0x76, 0x2, 0x2,
0x11f, 0x36, 0x3, 0x2, 0x2, 0x2, 0x120, 0x121, 0x7,
0x66, 0x2, 0x2, 0x121, 0x122, 0x7, 0x67, 0x2, 0x2,
0x122, 0x123, 0x7, 0x68, 0x2, 0x2, 0x123, 0x124, 0x7,
0x67, 0x2, 0x2, 0x124, 0x125, 0x7, 0x74, 0x2, 0x2,
0x125, 0x126, 0x7, 0x74, 0x2, 0x2, 0x126, 0x127, 0x7,
0x67, 0x2, 0x2, 0x127, 0x128, 0x7, 0x66, 0x2, 0x2,
0x128, 0x38, 0x3, 0x2, 0x2, 0x2, 0x129, 0x12a, 0x7,
0x6b, 0x2, 0x2, 0x12a, 0x12b, 0x7, 0x68, 0x2, 0x2,
0x12b, 0x3a, 0x3, 0x2, 0x2, 0x2, 0x12c, 0x12d, 0x7,
0x68, 0x2, 0x2, 0x12d, 0x12e, 0x7, 0x71, 0x2, 0x2,
0x12e, 0x12f, 0x7, 0x74, 0x2, 0x2, 0x12f, 0x3c, 0x3,
0x2, 0x2, 0x2, 0x130, 0x131, 0x7, 0x79, 0x2, 0x2,
0x131, 0x132, 0x7, 0x6a, 0x2, 0x2, 0x132, 0x133, 0x7,
0x6b, 0x2, 0x2, 0x133, 0x134, 0x7, 0x6e, 0x2, 0x2,
0x134, 0x135, 0x7, 0x67, 0x2, 0x2, 0x135, 0x3e, 0x3,
0x2, 0x2, 0x2, 0x136, 0x137, 0x7, 0x74, 0x2, 0x2,
0x137, 0x138, 0x7, 0x67, 0x2, 0x2, 0x138, 0x139, 0x7,
0x76, 0x2, 0x2, 0x139, 0x13a, 0x7, 0x77, 0x2, 0x2,
0x13a, 0x13b, 0x7, 0x74, 0x2, 0x2, 0x13b, 0x13c, 0x7,
0x70, 0x2, 0x2, 0x13c, 0x40, 0x3, 0x2, 0x2, 0x2,
0x13d, 0x13e, 0x7, 0x65, 0x2, 0x2, 0x13e, 0x13f, 0x7,
0x71, 0x2, 0x2, 0x13f, 0x140, 0x7, 0x70, 0x2, 0x2,
0x140, 0x141, 0x7, 0x75, 0x2, 0x2, 0x141, 0x142, 0x7,
0x76, 0x2, 0x2, 0x142, 0x143, 0x7, 0x67, 0x2, 0x2,
0x143, 0x144, 0x7, 0x7a, 0x2, 0x2, 0x144, 0x145, 0x7,
0x72, 0x2, 0x2, 0x145, 0x146, 0x7, 0x74, 0x2, 0x2,
0x146, 0x42, 0x3, 0x2, 0x2, 0x2, 0x147, 0x148, 0x7,
0x65, 0x2, 0x2, 0x148, 0x149, 0x7, 0x71, 0x2, 0x2,
0x149, 0x14a, 0x7, 0x70, 0x2, 0x2, 0x14a, 0x14b, 0x7,
0x76, 0x2, 0x2, 0x14b, 0x14c, 0x7, 0x6b, 0x2, 0x2,
0x14c, 0x14d, 0x7, 0x70, 0x2, 0x2, 0x14d, 0x14e, 0x7,
0x77, 0x2, 0x2, 0x14e, 0x14f, 0x7, 0x67, 0x2, 0x2,
0xf2, 0xf3, 0x7, 0x6f, 0x2, 0x2, 0xf3, 0xf4, 0x7,
0x63, 0x2, 0x2, 0xf4, 0xf5, 0x7, 0x65, 0x2, 0x2,
0xf5, 0xf6, 0x7, 0x74, 0x2, 0x2, 0xf6, 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117, 0x118, 0x7,
0x72, 0x2, 0x2, 0x118, 0x119, 0x7, 0x76, 0x2, 0x2,
0x119, 0x34, 0x3, 0x2, 0x2, 0x2, 0x11a, 0x11b, 0x7,
0x66, 0x2, 0x2, 0x11b, 0x11c, 0x7, 0x67, 0x2, 0x2,
0x11c, 0x11d, 0x7, 0x68, 0x2, 0x2, 0x11d, 0x11e, 0x7,
0x67, 0x2, 0x2, 0x11e, 0x11f, 0x7, 0x74, 0x2, 0x2,
0x11f, 0x120, 0x7, 0x74, 0x2, 0x2, 0x120, 0x121, 0x7,
0x67, 0x2, 0x2, 0x121, 0x122, 0x7, 0x66, 0x2, 0x2,
0x122, 0x36, 0x3, 0x2, 0x2, 0x2, 0x123, 0x124, 0x7,
0x6b, 0x2, 0x2, 0x124, 0x125, 0x7, 0x68, 0x2, 0x2,
0x125, 0x38, 0x3, 0x2, 0x2, 0x2, 0x126, 0x127, 0x7,
0x68, 0x2, 0x2, 0x127, 0x128, 0x7, 0x71, 0x2, 0x2,
0x128, 0x129, 0x7, 0x74, 0x2, 0x2, 0x129, 0x3a, 0x3,
0x2, 0x2, 0x2, 0x12a, 0x12b, 0x7, 0x79, 0x2, 0x2,
0x12b, 0x12c, 0x7, 0x6a, 0x2, 0x2, 0x12c, 0x12d, 0x7,
0x6b, 0x2, 0x2, 0x12d, 0x12e, 0x7, 0x6e, 0x2, 0x2,
0x12e, 0x12f, 0x7, 0x67, 0x2, 0x2, 0x12f, 0x3c, 0x3,
0x2, 0x2, 0x2, 0x130, 0x131, 0x7, 0x74, 0x2, 0x2,
0x131, 0x132, 0x7, 0x67, 0x2, 0x2, 0x132, 0x133, 0x7,
0x76, 0x2, 0x2, 0x133, 0x134, 0x7, 0x77, 0x2, 0x2,
0x134, 0x135, 0x7, 0x74, 0x2, 0x2, 0x135, 0x136, 0x7,
0x70, 0x2, 0x2, 0x136, 0x3e, 0x3, 0x2, 0x2, 0x2,
0x137, 0x138, 0x7, 0x65, 0x2, 0x2, 0x138, 0x139, 0x7,
0x71, 0x2, 0x2, 0x139, 0x13a, 0x7, 0x70, 0x2, 0x2,
0x13a, 0x13b, 0x7, 0x75, 0x2, 0x2, 0x13b, 0x13c, 0x7,
0x76, 0x2, 0x2, 0x13c, 0x13d, 0x7, 0x67, 0x2, 0x2,
0x13d, 0x13e, 0x7, 0x7a, 0x2, 0x2, 0x13e, 0x13f, 0x7,
0x72, 0x2, 0x2, 0x13f, 0x140, 0x7, 0x74, 0x2, 0x2,
0x140, 0x40, 0x3, 0x2, 0x2, 0x2, 0x141, 0x142, 0x7,
0x65, 0x2, 0x2, 0x142, 0x143, 0x7, 0x71, 0x2, 0x2,
0x143, 0x144, 0x7, 0x70, 0x2, 0x2, 0x144, 0x145, 0x7,
0x76, 0x2, 0x2, 0x145, 0x146, 0x7, 0x6b, 0x2, 0x2,
0x146, 0x147, 0x7, 0x70, 0x2, 0x2, 0x147, 0x148, 0x7,
0x77, 0x2, 0x2, 0x148, 0x149, 0x7, 0x67, 0x2, 0x2,
0x149, 0x42, 0x3, 0x2, 0x2, 0x2, 0x14a, 0x14b, 0x7,
0x64, 0x2, 0x2, 0x14b, 0x14c, 0x7, 0x74, 0x2, 0x2,
0x14c, 0x14d, 0x7, 0x67, 0x2, 0x2, 0x14d, 0x14e, 0x7,
0x63, 0x2, 0x2, 0x14e, 0x14f, 0x7, 0x6d, 0x2, 0x2,
0x14f, 0x44, 0x3, 0x2, 0x2, 0x2, 0x150, 0x151, 0x7,
0x64, 0x2, 0x2, 0x151, 0x152, 0x7, 0x74, 0x2, 0x2,
0x152, 0x153, 0x7, 0x67, 0x2, 0x2, 0x153, 0x154, 0x7,
0x63, 0x2, 0x2, 0x154, 0x155, 0x7, 0x6d, 0x2, 0x2,
0x155, 0x46, 0x3, 0x2, 0x2, 0x2, 0x156, 0x157, 0x7,
0x69, 0x2, 0x2, 0x157, 0x158, 0x7, 0x71, 0x2, 0x2,
0x158, 0x159, 0x7, 0x76, 0x2, 0x2, 0x159, 0x15a, 0x7,
0x71, 0x2, 0x2, 0x15a, 0x48, 0x3, 0x2, 0x2, 0x2,
0x15b, 0x15c, 0x7, 0x71, 0x2, 0x2, 0x15c, 0x15d, 0x7,
0x76, 0x2, 0x2, 0x15d, 0x15e, 0x7, 0x6a, 0x2, 0x2,
0x15e, 0x15f, 0x7, 0x67, 0x2, 0x2, 0x15f, 0x160, 0x7,
0x74, 0x2, 0x2, 0x160, 0x161, 0x7, 0x79, 0x2, 0x2,
0x161, 0x162, 0x7, 0x6b, 0x2, 0x2, 0x162, 0x163, 0x7,
0x75, 0x2, 0x2, 0x163, 0x164, 0x7, 0x67, 0x2, 0x2,
0x164, 0x4a, 0x3, 0x2, 0x2, 0x2, 0x165, 0x166, 0x7,
0x76, 0x2, 0x2, 0x166, 0x167, 0x7, 0x74, 0x2, 0x2,
0x167, 0x168, 0x7, 0x7b, 0x2, 0x2, 0x168, 0x4c, 0x3,
0x69, 0x2, 0x2, 0x151, 0x152, 0x7, 0x71, 0x2, 0x2,
0x152, 0x153, 0x7, 0x76, 0x2, 0x2, 0x153, 0x154, 0x7,
0x71, 0x2, 0x2, 0x154, 0x46, 0x3, 0x2, 0x2, 0x2,
0x155, 0x156, 0x7, 0x71, 0x2, 0x2, 0x156, 0x157, 0x7,
0x76, 0x2, 0x2, 0x157, 0x158, 0x7, 0x6a, 0x2, 0x2,
0x158, 0x159, 0x7, 0x67, 0x2, 0x2, 0x159, 0x15a, 0x7,
0x74, 0x2, 0x2, 0x15a, 0x15b, 0x7, 0x79, 0x2, 0x2,
0x15b, 0x15c, 0x7, 0x6b, 0x2, 0x2, 0x15c, 0x15d, 0x7,
0x75, 0x2, 0x2, 0x15d, 0x15e, 0x7, 0x67, 0x2, 0x2,
0x15e, 0x48, 0x3, 0x2, 0x2, 0x2, 0x15f, 0x160, 0x7,
0x76, 0x2, 0x2, 0x160, 0x161, 0x7, 0x74, 0x2, 0x2,
0x161, 0x162, 0x7, 0x7b, 0x2, 0x2, 0x162, 0x4a, 0x3,
0x2, 0x2, 0x2, 0x163, 0x164, 0x7, 0x6e, 0x2, 0x2,
0x164, 0x165, 0x7, 0x63, 0x2, 0x2, 0x165, 0x166, 0x7,
0x64, 0x2, 0x2, 0x166, 0x167, 0x7, 0x67, 0x2, 0x2,
0x167, 0x168, 0x7, 0x6e, 0x2, 0x2, 0x168, 0x4c, 0x3,
0x2, 0x2, 0x2, 0x169, 0x16a, 0x7, 0x6e, 0x2, 0x2,
0x16a, 0x16b, 0x7, 0x63, 0x2, 0x2, 0x16b, 0x16c, 0x7,
0x64, 0x2, 0x2, 0x16c, 0x16d, 0x7, 0x67, 0x2, 0x2,
0x16d, 0x16e, 0x7, 0x6e, 0x2, 0x2, 0x16e, 0x4e, 0x3,
0x2, 0x2, 0x2, 0x16f, 0x170, 0x7, 0x6e, 0x2, 0x2,
0x170, 0x171, 0x7, 0x63, 0x2, 0x2, 0x171, 0x172, 0x7,
0x64, 0x2, 0x2, 0x172, 0x173, 0x7, 0x67, 0x2, 0x2,
0x173, 0x174, 0x7, 0x6e, 0x2, 0x2, 0x174, 0x175, 0x7,
0x75, 0x2, 0x2, 0x175, 0x50, 0x3, 0x2, 0x2, 0x2,
0x176, 0x177, 0x7, 0x76, 0x2, 0x2, 0x177, 0x178, 0x7,
0x63, 0x2, 0x2, 0x178, 0x179, 0x7, 0x6b, 0x2, 0x2,
0x179, 0x17a, 0x7, 0x6e, 0x2, 0x2, 0x17a, 0x52, 0x3,
0x2, 0x2, 0x2, 0x17b, 0x17c, 0x7, 0x6b, 0x2, 0x2,
0x17c, 0x17d, 0x7, 0x75, 0x2, 0x2, 0x17d, 0x17e, 0x7,
0x70, 0x2, 0x2, 0x17e, 0x17f, 0x7, 0x76, 0x2, 0x2,
0x17f, 0x54, 0x3, 0x2, 0x2, 0x2, 0x180, 0x181, 0x7,
0x6b, 0x2, 0x2, 0x181, 0x182, 0x7, 0x75, 0x2, 0x2,
0x182, 0x56, 0x3, 0x2, 0x2, 0x2, 0x183, 0x184, 0x7,
0x6e, 0x2, 0x2, 0x184, 0x185, 0x7, 0x67, 0x2, 0x2,
0x16d, 0x16e, 0x7, 0x6e, 0x2, 0x2, 0x16e, 0x16f, 0x7,
0x75, 0x2, 0x2, 0x16f, 0x4e, 0x3, 0x2, 0x2, 0x2,
0x170, 0x171, 0x7, 0x76, 0x2, 0x2, 0x171, 0x172, 0x7,
0x63, 0x2, 0x2, 0x172, 0x173, 0x7, 0x6b, 0x2, 0x2,
0x173, 0x174, 0x7, 0x6e, 0x2, 0x2, 0x174, 0x50, 0x3,
0x2, 0x2, 0x2, 0x175, 0x176, 0x7, 0x6b, 0x2, 0x2,
0x176, 0x177, 0x7, 0x75, 0x2, 0x2, 0x177, 0x178, 0x7,
0x70, 0x2, 0x2, 0x178, 0x179, 0x7, 0x76, 0x2, 0x2,
0x179, 0x52, 0x3, 0x2, 0x2, 0x2, 0x17a, 0x17b, 0x7,
0x6b, 0x2, 0x2, 0x17b, 0x17c, 0x7, 0x75, 0x2, 0x2,
0x17c, 0x54, 0x3, 0x2, 0x2, 0x2, 0x17d, 0x17e, 0x7,
0x6e, 0x2, 0x2, 0x17e, 0x17f, 0x7, 0x67, 0x2, 0x2,
0x17f, 0x180, 0x7, 0x76, 0x2, 0x2, 0x180, 0x56, 0x3,
0x2, 0x2, 0x2, 0x181, 0x182, 0x7, 0x65, 0x2, 0x2,
0x182, 0x183, 0x7, 0x71, 0x2, 0x2, 0x183, 0x184, 0x7,
0x70, 0x2, 0x2, 0x184, 0x185, 0x7, 0x75, 0x2, 0x2,
0x185, 0x186, 0x7, 0x76, 0x2, 0x2, 0x186, 0x58, 0x3,
0x2, 0x2, 0x2, 0x187, 0x188, 0x7, 0x67, 0x2, 0x2,
0x188, 0x189, 0x7, 0x7a, 0x2, 0x2, 0x189, 0x18a, 0x7,

View File

@ -33,29 +33,29 @@ class TorqueLexer : public antlr4::Lexer {
T__17 = 18,
T__18 = 19,
T__19 = 20,
T__20 = 21,
MACRO = 22,
BUILTIN = 23,
RUNTIME = 24,
MODULE = 25,
JAVASCRIPT = 26,
DEFERRED = 27,
IF = 28,
FOR = 29,
WHILE = 30,
RETURN = 31,
CONSTEXPR = 32,
CONTINUE = 33,
BREAK = 34,
GOTO = 35,
OTHERWISE = 36,
TRY = 37,
LABEL = 38,
LABELS = 39,
TAIL = 40,
ISNT = 41,
IS = 42,
LET = 43,
MACRO = 21,
BUILTIN = 22,
RUNTIME = 23,
MODULE = 24,
JAVASCRIPT = 25,
DEFERRED = 26,
IF = 27,
FOR = 28,
WHILE = 29,
RETURN = 30,
CONSTEXPR = 31,
CONTINUE = 32,
BREAK = 33,
GOTO = 34,
OTHERWISE = 35,
TRY = 36,
LABEL = 37,
LABELS = 38,
TAIL = 39,
ISNT = 40,
IS = 41,
LET = 42,
CONST = 43,
EXTERN = 44,
ASSERT_TOKEN = 45,
CHECK_TOKEN = 46,

File diff suppressed because it is too large Load Diff

View File

@ -33,29 +33,29 @@ class TorqueParser : public antlr4::Parser {
T__17 = 18,
T__18 = 19,
T__19 = 20,
T__20 = 21,
MACRO = 22,
BUILTIN = 23,
RUNTIME = 24,
MODULE = 25,
JAVASCRIPT = 26,
DEFERRED = 27,
IF = 28,
FOR = 29,
WHILE = 30,
RETURN = 31,
CONSTEXPR = 32,
CONTINUE = 33,
BREAK = 34,
GOTO = 35,
OTHERWISE = 36,
TRY = 37,
LABEL = 38,
LABELS = 39,
TAIL = 40,
ISNT = 41,
IS = 42,
LET = 43,
MACRO = 21,
BUILTIN = 22,
RUNTIME = 23,
MODULE = 24,
JAVASCRIPT = 25,
DEFERRED = 26,
IF = 27,
FOR = 28,
WHILE = 29,
RETURN = 30,
CONSTEXPR = 31,
CONTINUE = 32,
BREAK = 33,
GOTO = 34,
OTHERWISE = 35,
TRY = 36,
LABEL = 37,
LABELS = 38,
TAIL = 39,
ISNT = 40,
IS = 41,
LET = 42,
CONST = 43,
EXTERN = 44,
ASSERT_TOKEN = 45,
CHECK_TOKEN = 46,
@ -893,9 +893,10 @@ class TorqueParser : public antlr4::Parser {
VariableDeclarationContext(antlr4::ParserRuleContext* parent,
size_t invokingState);
size_t getRuleIndex() const override;
antlr4::tree::TerminalNode* LET();
antlr4::tree::TerminalNode* IDENTIFIER();
TypeContext* type();
antlr4::tree::TerminalNode* LET();
antlr4::tree::TerminalNode* CONST();
void enterRule(antlr4::tree::ParseTreeListener* listener) override;
void exitRule(antlr4::tree::ParseTreeListener* listener) override;
@ -1404,6 +1405,7 @@ class TorqueParser : public antlr4::Parser {
ExternConstDeclarationContext(antlr4::ParserRuleContext* parent,
size_t invokingState);
size_t getRuleIndex() const override;
antlr4::tree::TerminalNode* CONST();
antlr4::tree::TerminalNode* IDENTIFIER();
TypeContext* type();
GeneratesDeclarationContext* generatesDeclaration();
@ -1421,6 +1423,7 @@ class TorqueParser : public antlr4::Parser {
ConstDeclarationContext(antlr4::ParserRuleContext* parent,
size_t invokingState);
size_t getRuleIndex() const override;
antlr4::tree::TerminalNode* CONST();
antlr4::tree::TerminalNode* IDENTIFIER();
TypeContext* type();
antlr4::tree::TerminalNode* ASSIGNMENT();

View File

@ -345,8 +345,10 @@ antlrcpp::Any AstGenerator::visitTypeAliasDeclaration(
antlrcpp::Any AstGenerator::visitVariableDeclaration(
TorqueParser::VariableDeclarationContext* context) {
bool is_const_qualified = context->CONST() != nullptr;
return RegisterNode(
new VarDeclarationStatement{Pos(context),
is_const_qualified,
context->IDENTIFIER()->getSymbol()->getText(),
GetType(context->type()),
{}});

View File

@ -436,9 +436,14 @@ struct TailCallStatement : Statement {
struct VarDeclarationStatement : Statement {
DEFINE_AST_NODE_LEAF_BOILERPLATE(VarDeclarationStatement)
VarDeclarationStatement(SourcePosition p, std::string n, TypeExpression* t,
base::Optional<Expression*> i)
: Statement(kKind, p), name(std::move(n)), type(t), initializer(i) {}
VarDeclarationStatement(SourcePosition p, bool c, std::string n,
TypeExpression* t, base::Optional<Expression*> i)
: Statement(kKind, p),
const_qualified(c),
name(std::move(n)),
type(t),
initializer(i) {}
bool const_qualified;
std::string name;
TypeExpression* type;
base::Optional<Expression*> initializer;

View File

@ -132,19 +132,19 @@ class ModuleConstant : public Value {
class Variable : public Value {
public:
DECLARE_DECLARABLE_BOILERPLATE(Variable, variable);
bool IsConst() const override { return false; }
bool IsConst() const override { return const_; }
std::string value() const override { return value_; }
std::string RValue() const override {
if (!IsDefined()) {
ReportError("Reading uninitialized variable.");
}
std::string result = "(*" + value() + ")";
if (!type()->IsConstexpr()) result += ".value()";
if (!IsConst()) result += ".value()";
return result;
}
void Define() {
if (defined_ && type()->IsConstexpr()) {
ReportError("Cannot re-define a constexpr variable.");
if (defined_ && IsConst()) {
ReportError("Cannot re-define a const-bound variable.");
}
defined_ = true;
}
@ -152,13 +152,18 @@ class Variable : public Value {
private:
friend class Declarations;
Variable(const std::string& name, const std::string& value, const Type* type)
Variable(const std::string& name, const std::string& value, const Type* type,
bool is_const)
: Value(Declarable::kVariable, type, name),
value_(value),
defined_(false) {}
defined_(false),
const_(is_const) {
DCHECK_IMPLIES(type->IsConstexpr(), IsConst());
}
std::string value_;
bool defined_;
bool const_;
};
class Label : public Declarable {

View File

@ -158,8 +158,9 @@ void DeclarationVisitor::Visit(TorqueMacroDeclaration* decl,
DeclareSignature(signature);
Variable* return_variable = nullptr;
if (!signature.return_type->IsVoidOrNever()) {
return_variable = declarations()->DeclareVariable(kReturnValueVariable,
signature.return_type);
return_variable = declarations()->DeclareVariable(
kReturnValueVariable, signature.return_type,
signature.return_type->IsConstexpr());
}
PushControlSplit();
@ -254,14 +255,23 @@ void DeclarationVisitor::Visit(ReturnStatement* stmt) {
void DeclarationVisitor::Visit(VarDeclarationStatement* stmt) {
std::string variable_name = stmt->name;
const Type* type = declarations()->GetType(stmt->type);
if (type->IsConstexpr()) {
ReportError("cannot declare variable with constexpr type");
if (type->IsConstexpr() && !stmt->const_qualified) {
ReportError(
"cannot declare variable with constexpr type. Use 'const' instead.");
}
declarations()->DeclareVariable(variable_name, type);
declarations()->DeclareVariable(variable_name, type, stmt->const_qualified);
if (global_context_.verbose()) {
std::cout << "declared variable " << variable_name << " with type " << *type
<< "\n";
}
// const qualified variables are required to be initialized properly.
if (stmt->const_qualified && !stmt->initializer) {
std::stringstream stream;
stream << "local constant \"" << variable_name << "\" is not initialized.";
ReportError(stream.str());
}
if (stmt->initializer) {
Visit(*stmt->initializer);
if (global_context_.verbose()) {
@ -399,8 +409,14 @@ void DeclarationVisitor::Visit(TryLabelStatement* stmt) {
size_t i = 0;
for (auto p : block->parameters.names) {
shared_label->AddVariable(declarations()->DeclareVariable(
p, declarations()->GetType(block->parameters.types[i])));
const Type* type =
declarations()->GetType(block->parameters.types[i]);
if (type->IsConstexpr()) {
ReportError("no constexpr type allowed for label arguments");
}
shared_label->AddVariable(
declarations()->DeclareVariable(p, type, false));
++i;
}
}
@ -549,9 +565,13 @@ void DeclarationVisitor::DeclareSignature(const Signature& signature) {
Label* new_label = declarations()->DeclareLabel(label.name);
size_t i = 0;
for (auto var_type : label_params) {
if (var_type->IsConstexpr()) {
ReportError("no constexpr type allowed for label arguments");
}
std::string var_name = label.name + std::to_string(i++);
new_label->AddVariable(
declarations()->DeclareVariable(var_name, var_type));
declarations()->DeclareVariable(var_name, var_type, false));
}
}
}

View File

@ -288,10 +288,10 @@ RuntimeFunction* Declarations::DeclareRuntimeFunction(
}
Variable* Declarations::DeclareVariable(const std::string& var,
const Type* type) {
const Type* type, bool is_const) {
std::string name(var + std::to_string(GetNextUniqueDeclarationNumber()));
CheckAlreadyDeclared(var, "variable");
Variable* result = new Variable(var, name, type);
Variable* result = new Variable(var, name, type, is_const);
Declare(var, std::unique_ptr<Declarable>(result));
return result;
}

View File

@ -87,7 +87,8 @@ class Declarations {
RuntimeFunction* DeclareRuntimeFunction(const std::string& name,
const Signature& signature);
Variable* DeclareVariable(const std::string& var, const Type* type);
Variable* DeclareVariable(const std::string& var, const Type* type,
bool is_const);
Parameter* DeclareParameter(const std::string& name,
const std::string& mangled_name,

View File

@ -814,10 +814,6 @@ const Type* ImplementationVisitor::Visit(ReturnStatement* stmt) {
source_out() << "Return(" << return_result.RValue() << ");"
<< std::endl;
}
} else if (current_callable->IsModuleConstant()) {
Variable* var =
Variable::cast(declarations()->LookupValue(kReturnValueVariable));
GenerateAssignToVariable(var, return_result);
} else {
UNREACHABLE();
}
@ -1231,7 +1227,7 @@ void ImplementationVisitor::GenerateChangedVarsFromControlSplit(AstNode* node) {
source_out() << "{";
bool first = true;
for (auto v : changed_vars) {
if (v->type()->IsConstexpr()) continue;
if (v->IsConst()) continue;
if (first) {
first = false;
} else {
@ -1339,7 +1335,7 @@ Variable* ImplementationVisitor::GenerateVariableDeclaration(
if (declarations()->TryLookup(name)) {
variable = Variable::cast(declarations()->LookupValue(name));
} else {
variable = declarations()->DeclareVariable(name, *type);
variable = declarations()->DeclareVariable(name, *type, false);
// Because the variable is being defined during code generation, it must be
// assumed that it changes along all control split paths because it's no
// longer possible to run the control-flow anlaysis in the declaration pass
@ -1352,17 +1348,20 @@ Variable* ImplementationVisitor::GenerateVariableDeclaration(
GenerateIndent();
if (variable->type()->IsConstexpr()) {
source_out() << variable->type()->GetGeneratedTypeName();
source_out() << " " << variable->value() << "_impl;" << std::endl;
source_out() << " " << variable->value() << "_impl;\n";
} else if (variable->IsConst()) {
source_out() << "TNode<" << variable->type()->GetGeneratedTNodeTypeName();
source_out() << "> " << variable->value() << "_impl;\n";
} else {
source_out() << "TVARIABLE(";
source_out() << variable->type()->GetGeneratedTNodeTypeName();
source_out() << ", " << variable->value() << "_impl);" << std::endl;
source_out() << ", " << variable->value() << "_impl);\n";
}
GenerateIndent();
source_out() << "auto " << variable->value() << " = &" << variable->value()
<< "_impl;" << std::endl;
<< "_impl;\n";
GenerateIndent();
source_out() << "USE(" << variable->value() << ");" << std::endl;
source_out() << "USE(" << variable->value() << ");\n";
if (initialization) {
GenerateAssignToVariable(variable, *initialization);
}

View File

@ -212,6 +212,18 @@ TEST(TestModuleConstBindings) {
ft.Call();
}
TEST(TestLocalConstBindings) {
Isolate* isolate(CcTest::InitIsolateOnce());
CodeAssemblerTester asm_tester(isolate, 0);
TestBuiltinsFromDSLAssembler m(asm_tester.state());
{
m.TestLocalConstBindings();
m.Return(m.UndefinedConstant());
}
FunctionTester ft(asm_tester.GenerateCode(), 0);
ft.Call();
}
} // namespace compiler
} // namespace internal
} // namespace v8

View File

@ -238,4 +238,9 @@ module test {
check(kIntptrConst == 4);
check(kSmiConst == 3);
}
macro TestLocalConstBindings() {
const kSmi: Smi = 3;
check(kSmi == 3);
}
}