Commit a3353da8 authored by Daniel Clifford's avatar Daniel Clifford

Torque: Implement a DSL for CSA

An overview of motivation behind Torque and some of its principles
can be found here: https://bit.ly/2qAI5Ep

Note that there is quite a bit of work left to do in order to get
Torque production-ready for any non-trivial amount of code, but
landing the prototype as-is will allow for much faster iteration.

Bugs will be filed for all of the big-ticket items that are not
landing blockers but called out in this patch as important to fix.

Cq-Include-Trybots: luci.v8.try:v8_linux_nosnap_rel;luci.v8.try:v8_linux_noi18n_rel_ng
Change-Id: Ib07af70966d5133dc57344928885478b9c6b8b73
Reviewed-on: https://chromium-review.googlesource.com/845682
Commit-Queue: Daniel Clifford <danno@chromium.org>
Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52618}
parent c1401045
This diff is collapsed.
......@@ -1653,7 +1653,12 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
SimpleInstallFunction(proto, "unshift", Builtins::kArrayUnshift, 1, false);
SimpleInstallFunction(proto, "slice", Builtins::kArrayPrototypeSlice, 2,
false);
SimpleInstallFunction(proto, "splice", Builtins::kArraySplice, 2, false);
if (FLAG_enable_experimental_builtins) {
SimpleInstallFunction(proto, "splice", Builtins::kArraySpliceTorque, 2,
false);
} else {
SimpleInstallFunction(proto, "splice", Builtins::kArraySplice, 2, false);
}
SimpleInstallFunction(proto, "includes", Builtins::kArrayIncludes, 1,
false);
SimpleInstallFunction(proto, "indexOf", Builtins::kArrayIndexOf, 1, false);
......
This diff is collapsed.
This diff is collapsed.
......@@ -20,7 +20,7 @@ using Node = compiler::Node;
ArrayBuiltinsAssembler::ArrayBuiltinsAssembler(
compiler::CodeAssemblerState* state)
: CodeStubAssembler(state),
: BaseBuiltinsFromDSLAssembler(state),
k_(this, MachineRepresentation::kTagged),
a_(this, MachineRepresentation::kTagged),
to_(this, MachineRepresentation::kTagged, SmiConstant(0)),
......
......@@ -5,12 +5,12 @@
#ifndef V8_BUILTINS_BUILTINS_ARRAY_GEN_H_
#define V8_BUILTINS_BUILTINS_ARRAY_GEN_H_
#include "src/code-stub-assembler.h"
#include "./builtins-base-from-dsl-gen.h"
namespace v8 {
namespace internal {
class ArrayBuiltinsAssembler : public CodeStubAssembler {
class ArrayBuiltinsAssembler : public BaseBuiltinsFromDSLAssembler {
public:
explicit ArrayBuiltinsAssembler(compiler::CodeAssemblerState* state);
......
......@@ -5,6 +5,9 @@
#ifndef V8_BUILTINS_BUILTINS_DEFINITIONS_H_
#define V8_BUILTINS_BUILTINS_DEFINITIONS_H_
// include generated header
#include "builtin-definitions-from-dsl.h" //NOLINT
namespace v8 {
namespace internal {
......@@ -1257,6 +1260,7 @@ namespace internal {
#ifdef V8_INTL_SUPPORT
#define BUILTIN_LIST(CPP, API, TFJ, TFC, TFS, TFH, ASM) \
BUILTIN_LIST_BASE(CPP, API, TFJ, TFC, TFS, TFH, ASM) \
BUILTIN_LIST_FROM_DSL(CPP, API, TFJ, TFC, TFS, TFH, ASM) \
\
TFS(StringToLowerCaseIntl, kString) \
/* ES #sec-string.prototype.tolowercase */ \
......@@ -1268,18 +1272,19 @@ namespace internal {
/* ecma402 #sec-intl.numberformat.prototype.formattoparts */ \
CPP(NumberFormatPrototypeFormatToParts)
#else
#define BUILTIN_LIST(CPP, API, TFJ, TFC, TFS, TFH, ASM) \
BUILTIN_LIST_BASE(CPP, API, TFJ, TFC, TFS, TFH, ASM) \
\
/* no-op fallback version */ \
CPP(StringPrototypeNormalize) \
/* same as toLowercase; fallback version */ \
CPP(StringPrototypeToLocaleLowerCase) \
/* same as toUppercase; fallback version */ \
CPP(StringPrototypeToLocaleUpperCase) \
/* (obsolete) Unibrow version */ \
CPP(StringPrototypeToLowerCase) \
/* (obsolete) Unibrow version */ \
#define BUILTIN_LIST(CPP, API, TFJ, TFC, TFS, TFH, ASM) \
BUILTIN_LIST_BASE(CPP, API, TFJ, TFC, TFS, TFH, ASM) \
BUILTIN_LIST_FROM_DSL(CPP, API, TFJ, TFC, TFS, TFH, ASM) \
\
/* no-op fallback version */ \
CPP(StringPrototypeNormalize) \
/* same as toLowercase; fallback version */ \
CPP(StringPrototypeToLocaleLowerCase) \
/* same as toUppercase; fallback version */ \
CPP(StringPrototypeToLocaleUpperCase) \
/* (obsolete) Unibrow version */ \
CPP(StringPrototypeToLowerCase) \
/* (obsolete) Unibrow version */ \
CPP(StringPrototypeToUpperCase)
#endif // V8_INTL_SUPPORT
......
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
grammar Torque;
options {
language=Cpp;
}
// parser rules start with lowercase letters, lexer rules with uppercase
MACRO: 'macro';
BUILTIN: 'builtin';
RUNTIME: 'runtime';
MODULE: 'module';
JAVASCRIPT: 'javascript';
IMPLICIT: 'implicit';
DEFERRED: 'deferred';
IF: 'if';
CAST_KEYWORD: 'cast';
CONVERT_KEYWORD: 'convert';
FOR: 'for';
WHILE: 'while';
RETURN: 'return';
CONTINUE: 'continue';
BREAK: 'break';
GOTO: 'goto';
OTHERWISE: 'otherwise';
TRY: 'try';
CATCH: 'catch';
LABEL: 'label';
LABELS: 'labels';
TAIL: 'tail';
ISNT: 'isnt';
IS: 'is';
LET: 'let';
ASSIGNMENT: '=';
ASSIGNMENT_OPERATOR
: '*='
| '/='
| '%='
| '+='
| '-='
| '<<='
| '>>='
| '>>>='
| '&='
| '^='
| '|='
;
EQUAL: '==';
PLUS: '+';
MINUS: '-';
MULTIPLY: '*';
DIVIDE: '/';
MODULO: '%';
BIT_OR: '|';
BIT_AND: '&';
BIT_NOT: '~';
MAX: 'max';
MIN: 'min';
NOT_EQUAL: '!=';
LESS_THAN: '<';
LESS_THAN_EQUAL: '<=';
GREATER_THAN: '>';
GREATER_THAN_EQUAL: '>=';
SHIFT_LEFT: '<<';
SHIFT_RIGHT: '>>';
SHIFT_RIGHT_ARITHMETIC: '>>>';
VARARGS: '...';
EQUALITY_OPERATOR: EQUAL | NOT_EQUAL;
INCREMENT: '++';
DECREMENT: '--';
NOT: '!';
STRING_LITERAL : ('"' ( ESCAPE | ~('"' | '\\' | '\n' | '\r') ) + '"')
| ('\'' ( ESCAPE | ~('"' | '\\' | '\n' | '\r') ) + '\'');
fragment ESCAPE : '\\' ( '\'' | '\\' );
IDENTIFIER : [A-Za-z][0-9A-Za-z_]* ;
WS : [ \t\r\n\f]+ -> channel(HIDDEN);
BLOCK_COMMENT
: '/*' .*? ('*/' | EOF) -> channel(HIDDEN)
;
LINE_COMMENT
: '//' ~[\r\n]* -> channel(HIDDEN)
;
fragment DECIMAL_DIGIT
: [0-9]
;
fragment DECIMAL_INTEGER_LITERAL
: '0'
| [1-9] DECIMAL_DIGIT*
;
fragment EXPONENT_PART
: [eE] [+-]? DECIMAL_DIGIT+
;
DECIMAL_LITERAL
: DECIMAL_INTEGER_LITERAL '.' DECIMAL_DIGIT* EXPONENT_PART?
| '.' DECIMAL_DIGIT+ EXPONENT_PART?
| DECIMAL_INTEGER_LITERAL EXPONENT_PART?
;
type : IDENTIFIER;
typeList : '(' type? (',' type)* ')';
typeListMaybeVarArgs: '(' type? (',' type)* (',' VARARGS)? ')'
| '(' VARARGS ')';
labelParameter: IDENTIFIER typeList?;
optionalType: (':' type)?;
optionalLabelList: (LABELS labelParameter (',' labelParameter)*)?;
poptionalOtherwise: (OTHERWISE IDENTIFIER (',' IDENTIFIER)*)?;
parameter: IDENTIFIER ':' type?;
parameterList
: '(' parameter? (',' parameter)* ')'
| '(' parameter ',' parameter ',' VARARGS IDENTIFIER ')';
labelDeclaration: IDENTIFIER parameterList?;
expression
: conditionalExpression;
conditionalExpression
: logicalORExpression
| conditionalExpression '?' logicalORExpression ':' logicalORExpression;
logicalORExpression
: logicalANDExpression
| logicalORExpression '||' logicalANDExpression;
logicalANDExpression
: bitwiseExpression
| logicalANDExpression '&&' bitwiseExpression;
bitwiseExpression
: equalityExpression
| bitwiseExpression op=(BIT_AND | BIT_OR) equalityExpression;
equalityExpression
: relationalExpression
| equalityExpression
op=(EQUAL | NOT_EQUAL)
relationalExpression;
relationalExpression
: shiftExpression
| relationalExpression
op=(LESS_THAN | LESS_THAN_EQUAL | GREATER_THAN | GREATER_THAN_EQUAL)
shiftExpression;
shiftExpression
: additiveExpression
| shiftExpression op=(SHIFT_RIGHT | SHIFT_LEFT | SHIFT_RIGHT_ARITHMETIC) additiveExpression;
additiveExpression
: multiplicativeExpression
| additiveExpression op=(PLUS | MINUS) multiplicativeExpression;
multiplicativeExpression
: unaryExpression
| multiplicativeExpression op=(MULTIPLY | DIVIDE | MODULO) unaryExpression;
unaryExpression
: assignmentExpression
| op=(PLUS | MINUS | BIT_NOT | NOT) unaryExpression;
locationExpression
: IDENTIFIER
| locationExpression '.' IDENTIFIER
| locationExpression '[' expression ']';
incrementDecrement
: INCREMENT locationExpression
| DECREMENT locationExpression
| locationExpression op=INCREMENT
| locationExpression op=DECREMENT
;
assignment
: incrementDecrement
| locationExpression ((ASSIGNMENT | ASSIGNMENT_OPERATOR) expression)?;
assignmentExpression
: primaryExpression
| assignment;
primaryExpression
: helperCall
| DECIMAL_LITERAL
| STRING_LITERAL
| CAST_KEYWORD '<' type '>' '(' expression ')' OTHERWISE IDENTIFIER
| CONVERT_KEYWORD '<' type '>' '(' expression ')'
| ('(' expression ')');
forInitialization : variableDeclarationWithInitialization?;
forLoop: FOR '(' forInitialization ';' expression ';' assignment ')' statementBlock;
rangeSpecifier: '[' begin=expression? ':' end=expression? ']';
forOfRange: rangeSpecifier?;
forOfLoop: FOR '(' variableDeclaration 'of' expression forOfRange ')' statementBlock;
argument: expression;
argumentList: '(' argument? (',' argument)* ')';
helperCall: (MIN | MAX | IDENTIFIER) argumentList optionalOtherwise;
labelReference: IDENTIFIER;
variableDeclaration: LET IDENTIFIER ':' type;
variableDeclarationWithInitialization: variableDeclaration ('=' expression)?;
helperCallStatement: (TAIL)? helperCall;
expressionStatement: assignment;
ifStatement: IF '(' expression ')' statementBlock ('else' statementBlock)?;
whileLoop: WHILE '(' expression ')' statementBlock;
returnStatement: RETURN expression?;
breakStatement: BREAK;
continueStatement: CONTINUE;
gotoStatement: GOTO labelReference argumentList?;
handlerWithStatement: (CATCH IDENTIFIER | LABEL labelDeclaration) statementBlock;
tryCatch: TRY statementBlock handlerWithStatement+;
statement : variableDeclarationWithInitialization ';'
| helperCallStatement ';'
| expressionStatement ';'
| returnStatement ';'
| breakStatement ';'
| continueStatement ';'
| gotoStatement ';'
| ifStatement
| whileLoop
| forOfLoop
| forLoop
| tryCatch
;
statementList : statement*;
statementScope : DEFERRED? '{' statementList '}';
statementBlock
: statement
| statementScope;
helperBody : statementScope;
generatesDeclaration: 'generates' STRING_LITERAL;
extendsDeclaration: 'extends' IDENTIFIER;
typeDeclaration : 'type' IDENTIFIER extendsDeclaration? generatesDeclaration? ';';
externalBuiltin : 'extern' JAVASCRIPT? BUILTIN IDENTIFIER typeList optionalType ';';
externalMacro : 'extern' (IMPLICIT? 'operator' STRING_LITERAL)? MACRO IDENTIFIER typeListMaybeVarArgs optionalType optionalLabelList ';';
externalRuntime : 'extern' RUNTIME IDENTIFIER typeListMaybeVarArgs optionalType ';';
builtinDeclaration : JAVASCRIPT? BUILTIN IDENTIFIER parameterList optionalType helperBody;
macroDeclaration : MACRO IDENTIFIER parameterList optionalType optionalLabelList helperBody;
constDeclaration : 'const' IDENTIFIER ':' type '=' STRING_LITERAL ';';
declaration
: typeDeclaration
| builtinDeclaration
| macroDeclaration
| externalMacro
| externalBuiltin
| externalRuntime
| constDeclaration;
moduleDeclaration : MODULE IDENTIFIER '{' declaration* '}';
file: (moduleDeclaration | declaration)*;
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Generated from Torque.g4 by ANTLR 4.7.1
#include "TorqueBaseListener.h"
This diff is collapsed.
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Generated from Torque.g4 by ANTLR 4.7.1
#include "TorqueBaseVisitor.h"
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_TORQUE_TORQUEBASEVISITOR_H_
#define V8_TORQUE_TORQUEBASEVISITOR_H_
// Generated from Torque.g4 by ANTLR 4.7.1
#pragma once
#include "./antlr4-runtime.h"
#include "TorqueVisitor.h"
/**
* This class provides an empty implementation of TorqueVisitor, which can be
* extended to create a visitor which only needs to handle a subset of the
* available methods.
*/
class TorqueBaseVisitor : public TorqueVisitor {
public:
antlrcpp::Any visitType(TorqueParser::TypeContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitTypeList(TorqueParser::TypeListContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitTypeListMaybeVarArgs(
TorqueParser::TypeListMaybeVarArgsContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitLabelParameter(
TorqueParser::LabelParameterContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitOptionalType(
TorqueParser::OptionalTypeContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitOptionalLabelList(
TorqueParser::OptionalLabelListContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitOptionalOtherwise(
TorqueParser::OptionalOtherwiseContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitParameter(TorqueParser::ParameterContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitParameterList(
TorqueParser::ParameterListContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitLabelDeclaration(
TorqueParser::LabelDeclarationContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitExpression(TorqueParser::ExpressionContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitConditionalExpression(
TorqueParser::ConditionalExpressionContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitLogicalORExpression(
TorqueParser::LogicalORExpressionContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitLogicalANDExpression(
TorqueParser::LogicalANDExpressionContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitBitwiseExpression(
TorqueParser::BitwiseExpressionContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitEqualityExpression(
TorqueParser::EqualityExpressionContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitRelationalExpression(
TorqueParser::RelationalExpressionContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitShiftExpression(
TorqueParser::ShiftExpressionContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitAdditiveExpression(
TorqueParser::AdditiveExpressionContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitMultiplicativeExpression(
TorqueParser::MultiplicativeExpressionContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitUnaryExpression(
TorqueParser::UnaryExpressionContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitLocationExpression(
TorqueParser::LocationExpressionContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitIncrementDecrement(
TorqueParser::IncrementDecrementContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitAssignment(TorqueParser::AssignmentContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitAssignmentExpression(
TorqueParser::AssignmentExpressionContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitPrimaryExpression(
TorqueParser::PrimaryExpressionContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitForInitialization(
TorqueParser::ForInitializationContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitForLoop(TorqueParser::ForLoopContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitRangeSpecifier(
TorqueParser::RangeSpecifierContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitForOfRange(TorqueParser::ForOfRangeContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitForOfLoop(TorqueParser::ForOfLoopContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitArgument(TorqueParser::ArgumentContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitArgumentList(
TorqueParser::ArgumentListContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitHelperCall(TorqueParser::HelperCallContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitLabelReference(
TorqueParser::LabelReferenceContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitVariableDeclaration(
TorqueParser::VariableDeclarationContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitVariableDeclarationWithInitialization(
TorqueParser::VariableDeclarationWithInitializationContext* ctx)
override {
return visitChildren(ctx);
}
antlrcpp::Any visitHelperCallStatement(
TorqueParser::HelperCallStatementContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitExpressionStatement(
TorqueParser::ExpressionStatementContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitIfStatement(
TorqueParser::IfStatementContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitWhileLoop(TorqueParser::WhileLoopContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitReturnStatement(
TorqueParser::ReturnStatementContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitBreakStatement(
TorqueParser::BreakStatementContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitContinueStatement(
TorqueParser::ContinueStatementContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitGotoStatement(
TorqueParser::GotoStatementContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitHandlerWithStatement(
TorqueParser::HandlerWithStatementContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitTryCatch(TorqueParser::TryCatchContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitStatement(TorqueParser::StatementContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitStatementList(
TorqueParser::StatementListContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitStatementScope(
TorqueParser::StatementScopeContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitStatementBlock(
TorqueParser::StatementBlockContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitHelperBody(TorqueParser::HelperBodyContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitGeneratesDeclaration(
TorqueParser::GeneratesDeclarationContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitExtendsDeclaration(
TorqueParser::ExtendsDeclarationContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitTypeDeclaration(
TorqueParser::TypeDeclarationContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitExternalBuiltin(
TorqueParser::ExternalBuiltinContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitExternalMacro(
TorqueParser::ExternalMacroContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitExternalRuntime(
TorqueParser::ExternalRuntimeContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitBuiltinDeclaration(
TorqueParser::BuiltinDeclarationContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitMacroDeclaration(
TorqueParser::MacroDeclarationContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitConstDeclaration(
TorqueParser::ConstDeclarationContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitDeclaration(
TorqueParser::DeclarationContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitModuleDeclaration(
TorqueParser::ModuleDeclarationContext* ctx) override {
return visitChildren(ctx);
}
antlrcpp::Any visitFile(TorqueParser::FileContext* ctx) override {
return visitChildren(ctx);
}
};
#endif // V8_TORQUE_TORQUEBASEVISITOR_H_
This diff is collapsed.
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_TORQUE_TORQUELEXER_H_
#define V8_TORQUE_TORQUELEXER_H_
// Generated from Torque.g4 by ANTLR 4.7.1
#pragma once
#include "./antlr4-runtime.h"
class TorqueLexer : public antlr4::Lexer {
public:
enum {
T__0 = 1,
T__1 = 2,
T__2 = 3,
T__3 = 4,
T__4 = 5,
T__5 = 6,
T__6 = 7,
T__7 = 8,
T__8 = 9,
T__9 = 10,
T__10 = 11,
T__11 = 12,
T__12 = 13,
T__13 = 14,
T__14 = 15,
T__15 = 16,
T__16 = 17,
T__17 = 18,
T__18 = 19,
T__19 = 20,
T__20 = 21,
MACRO = 22,
BUILTIN = 23,
RUNTIME = 24,
MODULE = 25,
JAVASCRIPT = 26,
IMPLICIT = 27,
DEFERRED = 28,
IF = 29,
CAST_KEYWORD = 30,
CONVERT_KEYWORD = 31,
FOR = 32,
WHILE = 33,
RETURN = 34,
CONTINUE = 35,
BREAK = 36,
GOTO = 37,
OTHERWISE = 38,
TRY = 39,
CATCH = 40,
LABEL = 41,
LABELS = 42,
TAIL = 43,
ISNT = 44,
IS = 45,
LET = 46,
ASSIGNMENT = 47,
ASSIGNMENT_OPERATOR = 48,
EQUAL = 49,
PLUS = 50,
MINUS = 51,
MULTIPLY = 52,
DIVIDE = 53,
MODULO = 54,
BIT_OR = 55,
BIT_AND = 56,
BIT_NOT = 57,
MAX = 58,
MIN = 59,
NOT_EQUAL = 60,
LESS_THAN = 61,
LESS_THAN_EQUAL = 62,
GREATER_THAN = 63,
GREATER_THAN_EQUAL = 64,
SHIFT_LEFT = 65,
SHIFT_RIGHT = 66,
SHIFT_RIGHT_ARITHMETIC = 67,
VARARGS = 68,
EQUALITY_OPERATOR = 69,
INCREMENT = 70,
DECREMENT = 71,
NOT = 72,
STRING_LITERAL = 73,
IDENTIFIER = 74,
WS = 75,
BLOCK_COMMENT = 76,
LINE_COMMENT = 77,
DECIMAL_LITERAL = 78
};
explicit TorqueLexer(antlr4::CharStream* input);
~TorqueLexer();
std::string getGrammarFileName() const override;
const std::vector<std::string>& getRuleNames() const override;
const std::vector<std::string>& getChannelNames() const override;
const std::vector<std::string>& getModeNames() const override;
const std::vector<std::string>& getTokenNames()
const override; // deprecated, use vocabulary instead
antlr4::dfa::Vocabulary& getVocabulary() const override;
const std::vector<uint16_t> getSerializedATN() const override;
const antlr4::atn::ATN& getATN() const override;
private:
static std::vector<antlr4::dfa::DFA> _decisionToDFA;
static antlr4::atn::PredictionContextCache _sharedContextCache;
static std::vector<std::string> _ruleNames;
static std::vector<std::string> _tokenNames;
static std::vector<std::string> _channelNames;
static std::vector<std::string> _modeNames;
static std::vector<std::string> _literalNames;
static std::vector<std::string> _symbolicNames;
static antlr4::dfa::Vocabulary _vocabulary;
static antlr4::atn::ATN _atn;
static std::vector<uint16_t> _serializedATN;
// Individual action functions triggered by action() above.
// Individual semantic predicate functions triggered by sempred() above.
struct Initializer {
Initializer();
};
static Initializer _init;
};
#endif // V8_TORQUE_TORQUELEXER_H_
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Generated from Torque.g4 by ANTLR 4.7.1
#include "TorqueListener.h"
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Generated from Torque.g4 by ANTLR 4.7.1
#include "TorqueVisitor.h"
This diff is collapsed.
This diff is collapsed.
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_TORQUE_AST_GENERATOR_H_
#define V8_TORQUE_AST_GENERATOR_H_
#include "src/torque/TorqueBaseVisitor.h"
#include "src/torque/ast.h"
#include "src/torque/global-context.h"
namespace v8 {
namespace internal {
namespace torque {
class AstGenerator : public TorqueBaseVisitor {
public:
antlrcpp::Any visitParameterList(
TorqueParser::ParameterListContext* context) override;
antlrcpp::Any visitTypeList(TorqueParser::TypeListContext* context) override;
antlrcpp::Any visitTypeListMaybeVarArgs(
TorqueParser::TypeListMaybeVarArgsContext* context) override;
antlrcpp::Any visitModuleDeclaration(
TorqueParser::ModuleDeclarationContext* context) override;
antlrcpp::Any visitMacroDeclaration(
TorqueParser::MacroDeclarationContext* context) override;
antlrcpp::Any visitBuiltinDeclaration(
TorqueParser::BuiltinDeclarationContext* context) override;
antlrcpp::Any visitExternalMacro(
TorqueParser::ExternalMacroContext* context) override;
antlrcpp::Any visitExternalBuiltin(
TorqueParser::ExternalBuiltinContext* context) override;
antlrcpp::Any visitExternalRuntime(
TorqueParser::ExternalRuntimeContext* context) override;
antlrcpp::Any visitConstDeclaration(
TorqueParser::ConstDeclarationContext* context) override;
antlrcpp::Any visitTypeDeclaration(
TorqueParser::TypeDeclarationContext* context) override;
antlrcpp::Any visitVariableDeclaration(
TorqueParser::VariableDeclarationContext* context) override;
antlrcpp::Any visitVariableDeclarationWithInitialization(
TorqueParser::VariableDeclarationWithInitializationContext* context)
override;
antlrcpp::Any visitHelperCall(
TorqueParser::HelperCallContext* context) override;
antlrcpp::Any visitHelperCallStatement(
TorqueParser::HelperCallStatementContext* context) override;
antlrcpp::Any visitConditionalExpression(
TorqueParser::ConditionalExpressionContext* context) override;
antlrcpp::Any visitLogicalORExpression(
TorqueParser::LogicalORExpressionContext* context) override;
antlrcpp::Any visitLogicalANDExpression(
TorqueParser::LogicalANDExpressionContext* context) override;
antlrcpp::Any visitBitwiseExpression(
TorqueParser::BitwiseExpressionContext* context) override;
antlrcpp::Any visitEqualityExpression(
TorqueParser::EqualityExpressionContext* context) override;
antlrcpp::Any visitRelationalExpression(
TorqueParser::RelationalExpressionContext* context) override;
antlrcpp::Any visitShiftExpression(
TorqueParser::ShiftExpressionContext* context) override;
antlrcpp::Any visitAdditiveExpression(
TorqueParser::AdditiveExpressionContext* context) override;
antlrcpp::Any visitMultiplicativeExpression(
TorqueParser::MultiplicativeExpressionContext* context) override;
antlrcpp::Any visitUnaryExpression(
TorqueParser::UnaryExpressionContext* context) override;
antlrcpp::Any visitLocationExpression(
TorqueParser::LocationExpressionContext* locationExpression) override;
antlrcpp::Any visitIncrementDecrement(
TorqueParser::IncrementDecrementContext* context) override;
antlrcpp::Any visitAssignment(
TorqueParser::AssignmentContext* context) override;
antlrcpp::Any visitPrimaryExpression(
TorqueParser::PrimaryExpressionContext* context) override;
antlrcpp::Any visitTryCatch(TorqueParser::TryCatchContext* context) override;
antlrcpp::Any visitStatementScope(
TorqueParser::StatementScopeContext* context) override;
antlrcpp::Any visitExpressionStatement(
TorqueParser::ExpressionStatementContext* context) override;
antlrcpp::Any visitReturnStatement(
TorqueParser::ReturnStatementContext* context) override;
antlrcpp::Any visitGotoStatement(
TorqueParser::GotoStatementContext* context) override;
antlrcpp::Any visitIfStatement(
TorqueParser::IfStatementContext* context) override;
antlrcpp::Any visitWhileLoop(
TorqueParser::WhileLoopContext* context) override;
antlrcpp::Any visitBreakStatement(
TorqueParser::BreakStatementContext* context) override;
antlrcpp::Any visitContinueStatement(
TorqueParser::ContinueStatementContext* context) override;
antlrcpp::Any visitForLoop(TorqueParser::ForLoopContext* context) override;
antlrcpp::Any visitForOfLoop(
TorqueParser::ForOfLoopContext* context) override;
antlrcpp::Any aggregateResult(antlrcpp::Any aggregate,
const antlrcpp::Any& nextResult) override {
if (aggregate.isNull())
return std::move(const_cast<antlrcpp::Any&>(nextResult));
if (nextResult.isNull()) return aggregate;
UNREACHABLE();
return {};
}
void visitSourceFile(SourceFileContext* context);
SourcePosition Pos(antlr4::ParserRuleContext* context);
Ast GetAst() && { return std::move(ast_); }
private:
Ast ast_;
SourceId current_source_file_;
SourceFileContext* source_file_context_;
};
} // namespace torque
} // namespace internal
} // namespace v8
#endif // V8_TORQUE_AST_GENERATOR_H_
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_TORQUE_UTILS_H_
#define V8_TORQUE_UTILS_H_
#include <string>
#include "src/objects.h"
namespace v8 {
namespace internal {
namespace torque {
typedef std::vector<std::string> NameVector;
void ReportError(const std::string& error);
std::string CamelifyString(const std::string& underscore_string);
void ReplaceFileContentsIfDifferent(const std::string& file_path,
const std::string& contents);
} // namespace torque
} // namespace internal
} // namespace v8
#endif // V8_TORQUE_UTILS_H_
This diff is collapsed.
This diff is collapsed.
......@@ -112,6 +112,7 @@ local function MakeClangCommandLine(
.. " -DV8_INTL_SUPPORT"
.. " -I./"
.. " -Iinclude/"
.. " -Iout/Release/gen"
.. " -Ithird_party/icu/source/common"
.. " -Ithird_party/icu/source/i18n"
.. " " .. arch_options
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment