• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "booleanLiteralType.h"
17 
18 namespace panda::es2panda::checker {
19 
ToString(std::stringstream & ss) const20 void BooleanLiteralType::ToString(std::stringstream &ss) const
21 {
22     if (value_) {
23         ss << "true";
24         return;
25     }
26 
27     ss << "false";
28 }
29 
ToStringAsSrc(std::stringstream & ss) const30 void BooleanLiteralType::ToStringAsSrc(std::stringstream &ss) const
31 {
32     ss << "boolean";
33 }
34 
Identical(TypeRelation * relation,Type * other)35 void BooleanLiteralType::Identical(TypeRelation *relation, Type *other)
36 {
37     if (other->IsBooleanLiteralType()) {
38         relation->Result(other->AsBooleanLiteralType()->Value());
39     }
40 }
41 
AssignmentTarget(TypeRelation * relation,Type * source)42 void BooleanLiteralType::AssignmentTarget([[maybe_unused]] TypeRelation *relation, [[maybe_unused]] Type *source) {}
43 
GetTypeFacts() const44 TypeFacts BooleanLiteralType::GetTypeFacts() const
45 {
46     return value_ ? TypeFacts::TRUE_FACTS : TypeFacts::FALSE_FACTS;
47 }
48 
Instantiate(ArenaAllocator * allocator,TypeRelation * relation,GlobalTypesHolder * globalTypes)49 Type *BooleanLiteralType::Instantiate([[maybe_unused]] ArenaAllocator *allocator,
50                                       [[maybe_unused]] TypeRelation *relation,
51                                       [[maybe_unused]] GlobalTypesHolder *globalTypes)
52 {
53     return this;
54 }
55 
56 }  // namespace panda::es2panda::checker
57