Flutter Engine
The Flutter Engine
token.cc
Go to the documentation of this file.
1// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5#include "vm/token.h"
6
7#include "vm/object.h"
8
9namespace dart {
10
11#define TOKEN_NAME(t, s, p, a) #t,
12const char* const Token::name_[] = {DART_TOKEN_LIST(TOKEN_NAME)
14#undef TOKEN_NAME
15
16#define TOKEN_STRING(t, s, p, a) s,
17const char* const Token::tok_str_[] = {DART_TOKEN_LIST(TOKEN_STRING)
19#undef TOKEN_STRING
20
21#define TOKEN_PRECEDENCE(t, s, p, a) p,
22const uint8_t Token::precedence_[] = {DART_TOKEN_LIST(TOKEN_PRECEDENCE)
24#undef TOKEN_PRECEDENCE
25
26#define TOKEN_ATTRIBUTE(t, s, p, a) a,
27const Token::Attribute Token::attributes_[] = {
29#undef TOKEN_ATTRIBUTE
30
32 switch (token) {
33 case Token::kOR:
34 case Token::kAND:
35 return true;
36 default:
37 return IsBinaryArithmeticOperator(token);
38 }
39}
40
42 return (token == kNOT) || IsUnaryArithmeticOperator(token);
43}
44
46 switch (token) {
47 case Token::kADD:
48 case Token::kSUB:
49 case Token::kMUL:
50 case Token::kDIV:
51 case Token::kTRUNCDIV:
52 case Token::kMOD:
53 case Token::kBIT_OR:
54 case Token::kBIT_XOR:
55 case Token::kBIT_AND:
56 case Token::kSHL:
57 case Token::kSHR:
58 case Token::kUSHR:
59 case Token::kMAX:
60 case Token::kMIN:
61 return true;
62 default:
63 return false;
64 }
65}
66
68 switch (token) {
69 case Token::kBIT_NOT:
70 case Token::kNEGATE:
71 case Token::kABS:
72 case Token::kSQRT:
73 case Token::kSQUARE:
74 case Token::kRECIPROCAL:
75 case Token::kRECIPROCAL_SQRT:
76 case Token::kTRUNCATE:
77 case Token::kFLOOR:
78 case Token::kCEILING:
79 return true;
80 default:
81 return false;
82 }
83}
84
86 switch (token) {
87 case Token::kBIT_OR:
88 case Token::kBIT_XOR:
89 case Token::kBIT_AND:
90 case Token::kSHL:
91 case Token::kSHR:
92 case Token::kUSHR:
93 return true;
94 default:
95 return false;
96 }
97}
98
99} // namespace dart
static bool IsBinaryArithmeticOperator(Token::Kind token)
Definition: token.cc:45
static bool IsBinaryOperator(Token::Kind token)
Definition: token.cc:31
static bool IsUnaryOperator(Token::Kind token)
Definition: token.cc:41
static bool IsBinaryBitwiseOperator(Token::Kind token)
Definition: token.cc:85
static bool IsUnaryArithmeticOperator(Token::Kind token)
Definition: token.cc:67
Definition: dart_vm.cc:33
#define TOKEN_PRECEDENCE(t, s, p, a)
Definition: token.cc:21
#define TOKEN_ATTRIBUTE(t, s, p, a)
Definition: token.cc:26
#define TOKEN_STRING(t, s, p, a)
Definition: token.cc:16
#define TOKEN_NAME(t, s, p, a)
Definition: token.cc:11
#define DART_KEYWORD_LIST(KW)
Definition: token.h:159
#define DART_TOKEN_LIST(TOK)
Definition: token.h:34