| 1 | //
 | 
|---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
 | 
|---|
| 3 | //
 | 
|---|
| 4 | // The contents of this file are covered under the licence agreement in the
 | 
|---|
| 5 | // file "LICENCE" distributed with Cforall.
 | 
|---|
| 6 | //
 | 
|---|
| 7 | // Expression.cc --
 | 
|---|
| 8 | //
 | 
|---|
| 9 | // Author           : Richard C. Bilson
 | 
|---|
| 10 | // Created On       : Mon May 18 07:44:20 2015
 | 
|---|
| 11 | // Last Modified By : Peter A. Buhr
 | 
|---|
| 12 | // Last Modified On : Tue Jul 25 14:15:47 2017
 | 
|---|
| 13 | // Update Count     : 54
 | 
|---|
| 14 | //
 | 
|---|
| 15 | 
 | 
|---|
| 16 | #include "SynTree/Expression.h"
 | 
|---|
| 17 | 
 | 
|---|
| 18 | #include <cassert>                   // for assert, assertf
 | 
|---|
| 19 | #include <iostream>                  // for ostream, operator<<, basic_ostream
 | 
|---|
| 20 | #include <list>                      // for list, _List_iterator, list<>::co...
 | 
|---|
| 21 | 
 | 
|---|
| 22 | #include "Common/utility.h"          // for maybeClone, cloneAll, deleteAll
 | 
|---|
| 23 | #include "Declaration.h"             // for ObjectDecl, DeclarationWithType
 | 
|---|
| 24 | #include "Expression.h"              // for Expression, ImplicitCopyCtorExpr
 | 
|---|
| 25 | #include "InitTweak/InitTweak.h"     // for getCallArg, getPointerBase
 | 
|---|
| 26 | #include "Initializer.h"             // for Designation, Initializer
 | 
|---|
| 27 | #include "Statement.h"               // for CompoundStmt, ExprStmt, Statement
 | 
|---|
| 28 | #include "SynTree/BaseSyntaxNode.h"  // for BaseSyntaxNode
 | 
|---|
| 29 | #include "SynTree/Constant.h"        // for Constant
 | 
|---|
| 30 | #include "Type.h"                    // for Type, BasicType, Type::Qualifiers
 | 
|---|
| 31 | #include "TypeSubstitution.h"        // for TypeSubstitution
 | 
|---|
| 32 | 
 | 
|---|
| 33 | #include "GenPoly/Lvalue.h"
 | 
|---|
| 34 | 
 | 
|---|
| 35 | void printInferParams( const InferredParams & inferParams, std::ostream &os, Indenter indent, int level ) {
 | 
|---|
| 36 |         if ( ! inferParams.empty() ) {
 | 
|---|
| 37 |                 os << indent << "with inferred parameters " << level << ":" << std::endl;
 | 
|---|
| 38 |                 for ( InferredParams::const_iterator i = inferParams.begin(); i != inferParams.end(); ++i ) {
 | 
|---|
| 39 |                         os << indent+1;
 | 
|---|
| 40 |                         Declaration::declFromId( i->second.decl )->printShort( os, indent+1 );
 | 
|---|
| 41 |                         os << std::endl;
 | 
|---|
| 42 |                         printInferParams( *i->second.inferParams, os, indent+1, level+1 );
 | 
|---|
| 43 |                 } // for
 | 
|---|
| 44 |         } // if
 | 
|---|
| 45 | }
 | 
|---|
| 46 | 
 | 
|---|
| 47 | Expression::Expression() : result( 0 ), env( 0 ) {}
 | 
|---|
| 48 | 
 | 
|---|
| 49 | Expression::Expression( const Expression &other ) : BaseSyntaxNode( other ), result( maybeClone( other.result ) ), env( maybeClone( other.env ) ), extension( other.extension ), inferParams( other.inferParams ) {
 | 
|---|
| 50 | }
 | 
|---|
| 51 | 
 | 
|---|
| 52 | Expression::~Expression() {
 | 
|---|
| 53 |         delete env;
 | 
|---|
| 54 |         delete result;
 | 
|---|
| 55 | }
 | 
|---|
| 56 | 
 | 
|---|
| 57 | void Expression::print( std::ostream &os, Indenter indent ) const {
 | 
|---|
| 58 |         printInferParams( inferParams, os, indent+1, 0 );
 | 
|---|
| 59 | 
 | 
|---|
| 60 |         if ( env ) {
 | 
|---|
| 61 |                 os << std::endl << indent << "... with environment:" << std::endl;
 | 
|---|
| 62 |                 env->print( os, indent+1 );
 | 
|---|
| 63 |         } // if
 | 
|---|
| 64 | 
 | 
|---|
| 65 |         if ( extension ) {
 | 
|---|
| 66 |                 os << std::endl << indent << "... with extension:";
 | 
|---|
| 67 |         } // if
 | 
|---|
| 68 | }
 | 
|---|
| 69 | 
 | 
|---|
| 70 | ConstantExpr::ConstantExpr( Constant _c ) : Expression(), constant( _c ) {
 | 
|---|
| 71 |         set_result( constant.get_type()->clone() );
 | 
|---|
| 72 | }
 | 
|---|
| 73 | 
 | 
|---|
| 74 | ConstantExpr::ConstantExpr( const ConstantExpr &other) : Expression( other ), constant( other.constant ) {
 | 
|---|
| 75 | }
 | 
|---|
| 76 | 
 | 
|---|
| 77 | ConstantExpr::~ConstantExpr() {}
 | 
|---|
| 78 | 
 | 
|---|
| 79 | void ConstantExpr::print( std::ostream &os, Indenter indent ) const {
 | 
|---|
| 80 |         os << "constant expression " ;
 | 
|---|
| 81 |         constant.print( os );
 | 
|---|
| 82 |         Expression::print( os, indent );
 | 
|---|
| 83 | }
 | 
|---|
| 84 | 
 | 
|---|
| 85 | long long int ConstantExpr::intValue() const {
 | 
|---|
| 86 |         if ( BasicType * basicType = dynamic_cast< BasicType * >( result ) ) {
 | 
|---|
| 87 |                 if ( basicType->isInteger() ) {
 | 
|---|
| 88 |                         return get_constant()->get_ival();
 | 
|---|
| 89 |                 }
 | 
|---|
| 90 |         } else if ( dynamic_cast< OneType * >( result ) ) {
 | 
|---|
| 91 |                 return 1;
 | 
|---|
| 92 |         } else if ( dynamic_cast< ZeroType * >( result ) ) {
 | 
|---|
| 93 |                 return 0;
 | 
|---|
| 94 |         }
 | 
|---|
| 95 |         throw SemanticError( "Constant expression of non-integral type ", this );
 | 
|---|
| 96 | }
 | 
|---|
| 97 | 
 | 
|---|
| 98 | VariableExpr::VariableExpr( DeclarationWithType *_var ) : Expression(), var( _var ) {
 | 
|---|
| 99 |         assert( var );
 | 
|---|
| 100 |         assert( var->get_type() );
 | 
|---|
| 101 |         Type * type = var->get_type()->clone();
 | 
|---|
| 102 |         type->set_lvalue( true );
 | 
|---|
| 103 | 
 | 
|---|
| 104 |         // xxx - doesn't quite work yet - get different alternatives with the same cost
 | 
|---|
| 105 | 
 | 
|---|
| 106 |         // // enumerators are not lvalues
 | 
|---|
| 107 |         // if ( EnumInstType * inst = dynamic_cast< EnumInstType * >( var->get_type() ) ) {
 | 
|---|
| 108 |         //      assert( inst->baseEnum );
 | 
|---|
| 109 |         //      EnumDecl * decl = inst->baseEnum;
 | 
|---|
| 110 |         //      for ( Declaration * member : decl->members ) {
 | 
|---|
| 111 |         //              if ( member == _var ) {
 | 
|---|
| 112 |         //                      type->set_lvalue( false );
 | 
|---|
| 113 |         //              }
 | 
|---|
| 114 |         //      }
 | 
|---|
| 115 |         // }
 | 
|---|
| 116 | 
 | 
|---|
| 117 |         set_result( type );
 | 
|---|
| 118 | }
 | 
|---|
| 119 | 
 | 
|---|
| 120 | VariableExpr::VariableExpr( const VariableExpr &other ) : Expression( other ), var( other.var ) {
 | 
|---|
| 121 | }
 | 
|---|
| 122 | 
 | 
|---|
| 123 | VariableExpr::~VariableExpr() {
 | 
|---|
| 124 |         // don't delete the declaration, since it points somewhere else in the tree
 | 
|---|
| 125 | }
 | 
|---|
| 126 | 
 | 
|---|
| 127 | VariableExpr * VariableExpr::functionPointer( FunctionDecl * func ) {
 | 
|---|
| 128 |         VariableExpr * funcExpr = new VariableExpr( func );
 | 
|---|
| 129 |         funcExpr->set_result( new PointerType( Type::Qualifiers(), funcExpr->get_result() ) );
 | 
|---|
| 130 |         return funcExpr;
 | 
|---|
| 131 | }
 | 
|---|
| 132 | 
 | 
|---|
| 133 | void VariableExpr::print( std::ostream &os, Indenter indent ) const {
 | 
|---|
| 134 |         os << "Variable Expression: ";
 | 
|---|
| 135 |         var->printShort(os, indent);
 | 
|---|
| 136 |         Expression::print( os, indent );
 | 
|---|
| 137 | }
 | 
|---|
| 138 | 
 | 
|---|
| 139 | SizeofExpr::SizeofExpr( Expression *expr_ ) :
 | 
|---|
| 140 |                 Expression(), expr(expr_), type(0), isType(false) {
 | 
|---|
| 141 |         set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
 | 
|---|
| 142 | }
 | 
|---|
| 143 | 
 | 
|---|
| 144 | SizeofExpr::SizeofExpr( Type *type_ ) :
 | 
|---|
| 145 |                 Expression(), expr(0), type(type_), isType(true) {
 | 
|---|
| 146 |         set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
 | 
|---|
| 147 | }
 | 
|---|
| 148 | 
 | 
|---|
| 149 | SizeofExpr::SizeofExpr( const SizeofExpr &other ) :
 | 
|---|
| 150 |         Expression( other ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) {
 | 
|---|
| 151 | }
 | 
|---|
| 152 | 
 | 
|---|
| 153 | SizeofExpr::~SizeofExpr() {
 | 
|---|
| 154 |         delete expr;
 | 
|---|
| 155 |         delete type;
 | 
|---|
| 156 | }
 | 
|---|
| 157 | 
 | 
|---|
| 158 | void SizeofExpr::print( std::ostream &os, Indenter indent) const {
 | 
|---|
| 159 |         os << "Sizeof Expression on: ";
 | 
|---|
| 160 |         if (isType) type->print(os, indent+1);
 | 
|---|
| 161 |         else expr->print(os, indent+1);
 | 
|---|
| 162 |         Expression::print( os, indent );
 | 
|---|
| 163 | }
 | 
|---|
| 164 | 
 | 
|---|
| 165 | AlignofExpr::AlignofExpr( Expression *expr_ ) :
 | 
|---|
| 166 |                 Expression(), expr(expr_), type(0), isType(false) {
 | 
|---|
| 167 |         set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
 | 
|---|
| 168 | }
 | 
|---|
| 169 | 
 | 
|---|
| 170 | AlignofExpr::AlignofExpr( Type *type_ ) :
 | 
|---|
| 171 |                 Expression(), expr(0), type(type_), isType(true) {
 | 
|---|
| 172 |         set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
 | 
|---|
| 173 | }
 | 
|---|
| 174 | 
 | 
|---|
| 175 | AlignofExpr::AlignofExpr( const AlignofExpr &other ) :
 | 
|---|
| 176 |         Expression( other ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) {
 | 
|---|
| 177 | }
 | 
|---|
| 178 | 
 | 
|---|
| 179 | AlignofExpr::~AlignofExpr() {
 | 
|---|
| 180 |         delete expr;
 | 
|---|
| 181 |         delete type;
 | 
|---|
| 182 | }
 | 
|---|
| 183 | 
 | 
|---|
| 184 | void AlignofExpr::print( std::ostream &os, Indenter indent) const {
 | 
|---|
| 185 |         os << "Alignof Expression on: ";
 | 
|---|
| 186 |         if (isType) type->print(os, indent+1);
 | 
|---|
| 187 |         else expr->print(os, indent+1);
 | 
|---|
| 188 |         Expression::print( os, indent );
 | 
|---|
| 189 | }
 | 
|---|
| 190 | 
 | 
|---|
| 191 | UntypedOffsetofExpr::UntypedOffsetofExpr( Type *type, const std::string &member ) :
 | 
|---|
| 192 |                 Expression(), type(type), member(member) {
 | 
|---|
| 193 |         assert( type );
 | 
|---|
| 194 |         set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
 | 
|---|
| 195 | }
 | 
|---|
| 196 | 
 | 
|---|
| 197 | UntypedOffsetofExpr::UntypedOffsetofExpr( const UntypedOffsetofExpr &other ) :
 | 
|---|
| 198 |         Expression( other ), type( maybeClone( other.type ) ), member( other.member ) {}
 | 
|---|
| 199 | 
 | 
|---|
| 200 | UntypedOffsetofExpr::~UntypedOffsetofExpr() {
 | 
|---|
| 201 |         delete type;
 | 
|---|
| 202 | }
 | 
|---|
| 203 | 
 | 
|---|
| 204 | void UntypedOffsetofExpr::print( std::ostream &os, Indenter indent) const {
 | 
|---|
| 205 |         os << "Untyped Offsetof Expression on member " << member << " of ";
 | 
|---|
| 206 |         type->print(os, indent+1);
 | 
|---|
| 207 |         Expression::print( os, indent );
 | 
|---|
| 208 | }
 | 
|---|
| 209 | 
 | 
|---|
| 210 | OffsetofExpr::OffsetofExpr( Type *type, DeclarationWithType *member ) :
 | 
|---|
| 211 |                 Expression(), type(type), member(member) {
 | 
|---|
| 212 |         assert( member );
 | 
|---|
| 213 |         assert( type );
 | 
|---|
| 214 |         set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
 | 
|---|
| 215 | }
 | 
|---|
| 216 | 
 | 
|---|
| 217 | OffsetofExpr::OffsetofExpr( const OffsetofExpr &other ) :
 | 
|---|
| 218 |         Expression( other ), type( maybeClone( other.type ) ), member( other.member ) {}
 | 
|---|
| 219 | 
 | 
|---|
| 220 | OffsetofExpr::~OffsetofExpr() {
 | 
|---|
| 221 |         delete type;
 | 
|---|
| 222 | }
 | 
|---|
| 223 | 
 | 
|---|
| 224 | void OffsetofExpr::print( std::ostream &os, Indenter indent) const {
 | 
|---|
| 225 |         os << "Offsetof Expression on member " << member->name << " of ";
 | 
|---|
| 226 |         type->print(os, indent+1);
 | 
|---|
| 227 |         Expression::print( os, indent );
 | 
|---|
| 228 | }
 | 
|---|
| 229 | 
 | 
|---|
| 230 | OffsetPackExpr::OffsetPackExpr( StructInstType *type ) : Expression(), type( type ) {
 | 
|---|
| 231 |         assert( type );
 | 
|---|
| 232 |         set_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) );
 | 
|---|
| 233 | }
 | 
|---|
| 234 | 
 | 
|---|
| 235 | OffsetPackExpr::OffsetPackExpr( const OffsetPackExpr &other ) : Expression( other ), type( maybeClone( other.type ) ) {}
 | 
|---|
| 236 | 
 | 
|---|
| 237 | OffsetPackExpr::~OffsetPackExpr() { delete type; }
 | 
|---|
| 238 | 
 | 
|---|
| 239 | void OffsetPackExpr::print( std::ostream &os, Indenter indent ) const {
 | 
|---|
| 240 |         os << "Offset pack expression on ";
 | 
|---|
| 241 |         type->print(os, indent+1);
 | 
|---|
| 242 |         Expression::print( os, indent );
 | 
|---|
| 243 | }
 | 
|---|
| 244 | 
 | 
|---|
| 245 | AttrExpr::AttrExpr( Expression *attr, Expression *expr_ ) :
 | 
|---|
| 246 |                 Expression(), attr( attr ), expr(expr_), type(0), isType(false) {
 | 
|---|
| 247 | }
 | 
|---|
| 248 | 
 | 
|---|
| 249 | AttrExpr::AttrExpr( Expression *attr, Type *type_ ) :
 | 
|---|
| 250 |                 Expression(), attr( attr ), expr(0), type(type_), isType(true) {
 | 
|---|
| 251 | }
 | 
|---|
| 252 | 
 | 
|---|
| 253 | AttrExpr::AttrExpr( const AttrExpr &other ) :
 | 
|---|
| 254 |                 Expression( other ), attr( maybeClone( other.attr ) ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) {
 | 
|---|
| 255 | }
 | 
|---|
| 256 | 
 | 
|---|
| 257 | AttrExpr::~AttrExpr() {
 | 
|---|
| 258 |         delete attr;
 | 
|---|
| 259 |         delete expr;
 | 
|---|
| 260 |         delete type;
 | 
|---|
| 261 | }
 | 
|---|
| 262 | 
 | 
|---|
| 263 | void AttrExpr::print( std::ostream &os, Indenter indent) const {
 | 
|---|
| 264 |         os << "Attr ";
 | 
|---|
| 265 |         attr->print( os, indent+1);
 | 
|---|
| 266 |         if ( isType || expr ) {
 | 
|---|
| 267 |                 os << "applied to: ";
 | 
|---|
| 268 |                 if (isType) type->print(os, indent+1);
 | 
|---|
| 269 |                 else expr->print(os, indent+1);
 | 
|---|
| 270 |         } // if
 | 
|---|
| 271 |         Expression::print( os, indent );
 | 
|---|
| 272 | }
 | 
|---|
| 273 | 
 | 
|---|
| 274 | CastExpr::CastExpr( Expression *arg_, Type *toType ) : Expression(), arg(arg_) {
 | 
|---|
| 275 |         set_result(toType);
 | 
|---|
| 276 | }
 | 
|---|
| 277 | 
 | 
|---|
| 278 | CastExpr::CastExpr( Expression *arg_ ) : Expression(), arg(arg_) {
 | 
|---|
| 279 |         set_result( new VoidType( Type::Qualifiers() ) );
 | 
|---|
| 280 | }
 | 
|---|
| 281 | 
 | 
|---|
| 282 | CastExpr::CastExpr( const CastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ) {
 | 
|---|
| 283 | }
 | 
|---|
| 284 | 
 | 
|---|
| 285 | CastExpr::~CastExpr() {
 | 
|---|
| 286 |         delete arg;
 | 
|---|
| 287 | }
 | 
|---|
| 288 | 
 | 
|---|
| 289 | void CastExpr::print( std::ostream &os, Indenter indent ) const {
 | 
|---|
| 290 |         os << "Cast of:" << std::endl << indent+1;
 | 
|---|
| 291 |         arg->print(os, indent+1);
 | 
|---|
| 292 |         os << std::endl << indent << "... to:";
 | 
|---|
| 293 |         if ( result->isVoid() ) {
 | 
|---|
| 294 |                 os << " nothing";
 | 
|---|
| 295 |         } else {
 | 
|---|
| 296 |                 os << std::endl << indent+1;
 | 
|---|
| 297 |                 result->print( os, indent+1 );
 | 
|---|
| 298 |         } // if
 | 
|---|
| 299 |         Expression::print( os, indent );
 | 
|---|
| 300 | }
 | 
|---|
| 301 | 
 | 
|---|
| 302 | VirtualCastExpr::VirtualCastExpr( Expression *arg_, Type *toType ) : Expression(), arg(arg_) {
 | 
|---|
| 303 |         set_result(toType);
 | 
|---|
| 304 | }
 | 
|---|
| 305 | 
 | 
|---|
| 306 | VirtualCastExpr::VirtualCastExpr( const VirtualCastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ) {
 | 
|---|
| 307 | }
 | 
|---|
| 308 | 
 | 
|---|
| 309 | VirtualCastExpr::~VirtualCastExpr() {
 | 
|---|
| 310 |         delete arg;
 | 
|---|
| 311 | }
 | 
|---|
| 312 | 
 | 
|---|
| 313 | void VirtualCastExpr::print( std::ostream &os, Indenter indent ) const {
 | 
|---|
| 314 |         os << "Virtual Cast of:" << std::endl << indent+1;
 | 
|---|
| 315 |         arg->print(os, indent+1);
 | 
|---|
| 316 |         os << std::endl << indent << "... to:";
 | 
|---|
| 317 |         if ( ! result ) {
 | 
|---|
| 318 |                 os << " unknown";
 | 
|---|
| 319 |         } else {
 | 
|---|
| 320 |                 os << std::endl << indent+1;
 | 
|---|
| 321 |                 result->print( os, indent+1 );
 | 
|---|
| 322 |         } // if
 | 
|---|
| 323 |         Expression::print( os, indent );
 | 
|---|
| 324 | }
 | 
|---|
| 325 | 
 | 
|---|
| 326 | UntypedMemberExpr::UntypedMemberExpr( Expression * member, Expression *aggregate ) :
 | 
|---|
| 327 |                 Expression(), member(member), aggregate(aggregate) {
 | 
|---|
| 328 |         assert( aggregate );
 | 
|---|
| 329 | }
 | 
|---|
| 330 | 
 | 
|---|
| 331 | UntypedMemberExpr::UntypedMemberExpr( const UntypedMemberExpr &other ) :
 | 
|---|
| 332 |                 Expression( other ), member( maybeClone( other.member ) ), aggregate( maybeClone( other.aggregate ) ) {
 | 
|---|
| 333 | }
 | 
|---|
| 334 | 
 | 
|---|
| 335 | UntypedMemberExpr::~UntypedMemberExpr() {
 | 
|---|
| 336 |         delete aggregate;
 | 
|---|
| 337 |         delete member;
 | 
|---|
| 338 | }
 | 
|---|
| 339 | 
 | 
|---|
| 340 | void UntypedMemberExpr::print( std::ostream &os, Indenter indent ) const {
 | 
|---|
| 341 |         os << "Untyped Member Expression, with field: " << std::endl << indent+1;
 | 
|---|
| 342 |         member->print(os, indent+1 );
 | 
|---|
| 343 |         os << indent << "... from aggregate: " << std::endl << indent+1;
 | 
|---|
| 344 |         aggregate->print(os, indent+1);
 | 
|---|
| 345 |         Expression::print( os, indent );
 | 
|---|
| 346 | }
 | 
|---|
| 347 | 
 | 
|---|
| 348 | namespace {
 | 
|---|
| 349 |         TypeSubstitution makeSub( Type * t ) {
 | 
|---|
| 350 |                 if ( ReferenceType * refType = dynamic_cast< ReferenceType * >( t ) ) {
 | 
|---|
| 351 |                         return makeSub( refType->get_base() );
 | 
|---|
| 352 |                 } else if ( StructInstType * aggInst = dynamic_cast< StructInstType * >( t ) ) {
 | 
|---|
| 353 |                         return TypeSubstitution( aggInst->get_baseParameters()->begin(), aggInst->get_baseParameters()->end(), aggInst->parameters.begin() );
 | 
|---|
| 354 |                 } else if ( UnionInstType * aggInst = dynamic_cast< UnionInstType * >( t ) ) {
 | 
|---|
| 355 |                         return TypeSubstitution( aggInst->get_baseParameters()->begin(), aggInst->get_baseParameters()->end(), aggInst->parameters.begin() );
 | 
|---|
| 356 |                 } else {
 | 
|---|
| 357 |                         assertf( false, "makeSub expects struct or union type for aggregate, but got: %s", toString( t ).c_str() );
 | 
|---|
| 358 |                 }
 | 
|---|
| 359 |         }
 | 
|---|
| 360 | }
 | 
|---|
| 361 | 
 | 
|---|
| 362 | 
 | 
|---|
| 363 | MemberExpr::MemberExpr( DeclarationWithType *member, Expression *aggregate ) :
 | 
|---|
| 364 |                 Expression(), member(member), aggregate(aggregate) {
 | 
|---|
| 365 |         assert( member );
 | 
|---|
| 366 |         assert( aggregate );
 | 
|---|
| 367 | 
 | 
|---|
| 368 |         TypeSubstitution sub( makeSub( aggregate->get_result() ) );
 | 
|---|
| 369 |         Type * res = member->get_type()->clone();
 | 
|---|
| 370 |         sub.apply( res );
 | 
|---|
| 371 |         result = res;
 | 
|---|
| 372 |         result->set_lvalue( true );
 | 
|---|
| 373 |         result->get_qualifiers() |= aggregate->result->get_qualifiers();
 | 
|---|
| 374 | }
 | 
|---|
| 375 | 
 | 
|---|
| 376 | MemberExpr::MemberExpr( const MemberExpr &other ) :
 | 
|---|
| 377 |                 Expression( other ), member( other.member ), aggregate( maybeClone( other.aggregate ) ) {
 | 
|---|
| 378 | }
 | 
|---|
| 379 | 
 | 
|---|
| 380 | MemberExpr::~MemberExpr() {
 | 
|---|
| 381 |         // don't delete the member declaration, since it points somewhere else in the tree
 | 
|---|
| 382 |         delete aggregate;
 | 
|---|
| 383 | }
 | 
|---|
| 384 | 
 | 
|---|
| 385 | void MemberExpr::print( std::ostream &os, Indenter indent ) const {
 | 
|---|
| 386 |         os << "Member Expression, with field: " << std::endl;
 | 
|---|
| 387 |         os << indent+1;
 | 
|---|
| 388 |         member->print( os, indent+1 );
 | 
|---|
| 389 |         os << std::endl << indent << "... from aggregate: " << std::endl << indent+1;
 | 
|---|
| 390 |         aggregate->print(os, indent + 1);
 | 
|---|
| 391 |         Expression::print( os, indent );
 | 
|---|
| 392 | }
 | 
|---|
| 393 | 
 | 
|---|
| 394 | UntypedExpr::UntypedExpr( Expression *function, const std::list<Expression *> &args ) :
 | 
|---|
| 395 |                 Expression(), function(function), args(args) {}
 | 
|---|
| 396 | 
 | 
|---|
| 397 | UntypedExpr::UntypedExpr( const UntypedExpr &other ) :
 | 
|---|
| 398 |                 Expression( other ), function( maybeClone( other.function ) ) {
 | 
|---|
| 399 |         cloneAll( other.args, args );
 | 
|---|
| 400 | }
 | 
|---|
| 401 | 
 | 
|---|
| 402 | UntypedExpr::~UntypedExpr() {
 | 
|---|
| 403 |         delete function;
 | 
|---|
| 404 |         deleteAll( args );
 | 
|---|
| 405 | }
 | 
|---|
| 406 | 
 | 
|---|
| 407 | UntypedExpr * UntypedExpr::createDeref( Expression * expr ) {
 | 
|---|
| 408 |         UntypedExpr * ret = new UntypedExpr( new NameExpr("*?"), std::list< Expression * >{ expr } );
 | 
|---|
| 409 |         if ( Type * type = expr->get_result() ) {
 | 
|---|
| 410 |                 Type * base = InitTweak::getPointerBase( type );
 | 
|---|
| 411 |                 assertf( base, "expected pointer type in dereference (type was %s)", toString( type ).c_str() );
 | 
|---|
| 412 |                 ret->set_result( base->clone() );
 | 
|---|
| 413 |                 if ( GenPoly::referencesPermissable() ) {
 | 
|---|
| 414 |                         // if references are still allowed in the AST, dereference returns a reference
 | 
|---|
| 415 |                         ret->set_result( new ReferenceType( Type::Qualifiers(), ret->get_result() ) );
 | 
|---|
| 416 |                 } else {
 | 
|---|
| 417 |                         // references have been removed, in which case dereference returns an lvalue of the base type.
 | 
|---|
| 418 |                         ret->get_result()->set_lvalue( true );
 | 
|---|
| 419 |                 }
 | 
|---|
| 420 |         }
 | 
|---|
| 421 |         return ret;
 | 
|---|
| 422 | }
 | 
|---|
| 423 | 
 | 
|---|
| 424 | UntypedExpr * UntypedExpr::createAssign( Expression * arg1, Expression * arg2 ) {
 | 
|---|
| 425 |         assert( arg1 && arg2 );
 | 
|---|
| 426 |         UntypedExpr * ret = new UntypedExpr( new NameExpr( "?=?" ), std::list< Expression * >{ arg1, arg2 } );
 | 
|---|
| 427 |         if ( arg1->get_result() && arg2->get_result() ) {
 | 
|---|
| 428 |                 // if both expressions are typed, assumes that this assignment is a C bitwise assignment,
 | 
|---|
| 429 |                 // so the result is the type of the RHS
 | 
|---|
| 430 |                 ret->set_result( arg2->get_result()->clone() );
 | 
|---|
| 431 |         }
 | 
|---|
| 432 |         return ret;
 | 
|---|
| 433 | }
 | 
|---|
| 434 | 
 | 
|---|
| 435 | 
 | 
|---|
| 436 | void UntypedExpr::print( std::ostream &os, Indenter indent ) const {
 | 
|---|
| 437 |         os << "Applying untyped: " << std::endl;
 | 
|---|
| 438 |         os << indent+1;
 | 
|---|
| 439 |         function->print(os, indent+1);
 | 
|---|
| 440 |         os << std::endl << indent << "...to: " << std::endl;
 | 
|---|
| 441 |         printAll(args, os, indent+1);
 | 
|---|
| 442 |         Expression::print( os, indent );
 | 
|---|
| 443 | }
 | 
|---|
| 444 | 
 | 
|---|
| 445 | NameExpr::NameExpr( std::string name ) : Expression(), name(name) {
 | 
|---|
| 446 |         assertf(name != "0", "Zero is not a valid name");
 | 
|---|
| 447 |         assertf(name != "1", "One is not a valid name");
 | 
|---|
| 448 | }
 | 
|---|
| 449 | 
 | 
|---|
| 450 | NameExpr::NameExpr( const NameExpr &other ) : Expression( other ), name( other.name ) {
 | 
|---|
| 451 | }
 | 
|---|
| 452 | 
 | 
|---|
| 453 | NameExpr::~NameExpr() {}
 | 
|---|
| 454 | 
 | 
|---|
| 455 | void NameExpr::print( std::ostream &os, Indenter indent ) const {
 | 
|---|
| 456 |         os << "Name: " << get_name();
 | 
|---|
| 457 |         Expression::print( os, indent );
 | 
|---|
| 458 | }
 | 
|---|
| 459 | 
 | 
|---|
| 460 | LogicalExpr::LogicalExpr( Expression *arg1_, Expression *arg2_, bool andp ) :
 | 
|---|
| 461 |                 Expression(), arg1(arg1_), arg2(arg2_), isAnd(andp) {
 | 
|---|
| 462 |         set_result( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) );
 | 
|---|
| 463 | }
 | 
|---|
| 464 | 
 | 
|---|
| 465 | LogicalExpr::LogicalExpr( const LogicalExpr &other ) :
 | 
|---|
| 466 |                 Expression( other ), arg1( maybeClone( other.arg1 ) ), arg2( maybeClone( other.arg2 ) ), isAnd( other.isAnd ) {
 | 
|---|
| 467 | }
 | 
|---|
| 468 | 
 | 
|---|
| 469 | LogicalExpr::~LogicalExpr() {
 | 
|---|
| 470 |         delete arg1;
 | 
|---|
| 471 |         delete arg2;
 | 
|---|
| 472 | }
 | 
|---|
| 473 | 
 | 
|---|
| 474 | void LogicalExpr::print( std::ostream &os, Indenter indent )const {
 | 
|---|
| 475 |         os << "Short-circuited operation (" << (isAnd ? "and" : "or") << ") on: ";
 | 
|---|
| 476 |         arg1->print(os);
 | 
|---|
| 477 |         os << " and ";
 | 
|---|
| 478 |         arg2->print(os);
 | 
|---|
| 479 |         Expression::print( os, indent );
 | 
|---|
| 480 | }
 | 
|---|
| 481 | 
 | 
|---|
| 482 | ConditionalExpr::ConditionalExpr( Expression * arg1, Expression * arg2, Expression * arg3 ) :
 | 
|---|
| 483 |                 Expression(), arg1(arg1), arg2(arg2), arg3(arg3) {}
 | 
|---|
| 484 | 
 | 
|---|
| 485 | ConditionalExpr::ConditionalExpr( const ConditionalExpr &other ) :
 | 
|---|
| 486 |                 Expression( other ), arg1( maybeClone( other.arg1 ) ), arg2( maybeClone( other.arg2 ) ), arg3( maybeClone( other.arg3 ) ) {
 | 
|---|
| 487 | }
 | 
|---|
| 488 | 
 | 
|---|
| 489 | ConditionalExpr::~ConditionalExpr() {
 | 
|---|
| 490 |         delete arg1;
 | 
|---|
| 491 |         delete arg2;
 | 
|---|
| 492 |         delete arg3;
 | 
|---|
| 493 | }
 | 
|---|
| 494 | 
 | 
|---|
| 495 | void ConditionalExpr::print( std::ostream &os, Indenter indent ) const {
 | 
|---|
| 496 |         os << "Conditional expression on: " << std::endl << indent+1;
 | 
|---|
| 497 |         arg1->print( os, indent+1 );
 | 
|---|
| 498 |         os << indent << "First alternative:" << std::endl << indent+1;
 | 
|---|
| 499 |         arg2->print( os, indent+1 );
 | 
|---|
| 500 |         os << indent << "Second alternative:" << std::endl << indent+1;
 | 
|---|
| 501 |         arg3->print( os, indent+1 );
 | 
|---|
| 502 |         Expression::print( os, indent );
 | 
|---|
| 503 | }
 | 
|---|
| 504 | 
 | 
|---|
| 505 | AsmExpr::AsmExpr( const AsmExpr & other ) : Expression( other ), inout( maybeClone( other.inout ) ), constraint( maybeClone( other.constraint ) ), operand( maybeClone( other.operand ) ) {}
 | 
|---|
| 506 | 
 | 
|---|
| 507 | 
 | 
|---|
| 508 | void AsmExpr::print( std::ostream &os, Indenter indent ) const {
 | 
|---|
| 509 |         os << "Asm Expression: " << std::endl;
 | 
|---|
| 510 |         if ( inout ) inout->print( os, indent+1 );
 | 
|---|
| 511 |         if ( constraint ) constraint->print( os, indent+1 );
 | 
|---|
| 512 |         if ( operand ) operand->print( os, indent+1 );
 | 
|---|
| 513 | }
 | 
|---|
| 514 | 
 | 
|---|
| 515 | 
 | 
|---|
| 516 | ImplicitCopyCtorExpr::ImplicitCopyCtorExpr( ApplicationExpr * callExpr ) : callExpr( callExpr ) {
 | 
|---|
| 517 |         assert( callExpr );
 | 
|---|
| 518 |         assert( callExpr->result );
 | 
|---|
| 519 |         set_result( callExpr->get_result()->clone() );
 | 
|---|
| 520 | }
 | 
|---|
| 521 | 
 | 
|---|
| 522 | ImplicitCopyCtorExpr::ImplicitCopyCtorExpr( const ImplicitCopyCtorExpr & other ) : Expression( other ), callExpr( maybeClone( other.callExpr ) ) {
 | 
|---|
| 523 |         cloneAll( other.tempDecls, tempDecls );
 | 
|---|
| 524 |         cloneAll( other.returnDecls, returnDecls );
 | 
|---|
| 525 |         cloneAll( other.dtors, dtors );
 | 
|---|
| 526 | }
 | 
|---|
| 527 | 
 | 
|---|
| 528 | ImplicitCopyCtorExpr::~ImplicitCopyCtorExpr() {
 | 
|---|
| 529 |         set_env( nullptr ); // ImplicitCopyCtorExpr does not take ownership of an environment
 | 
|---|
| 530 |         delete callExpr;
 | 
|---|
| 531 |         deleteAll( tempDecls );
 | 
|---|
| 532 |         deleteAll( returnDecls );
 | 
|---|
| 533 |         deleteAll( dtors );
 | 
|---|
| 534 | }
 | 
|---|
| 535 | 
 | 
|---|
| 536 | void ImplicitCopyCtorExpr::print( std::ostream &os, Indenter indent ) const {
 | 
|---|
| 537 |         os <<  "Implicit Copy Constructor Expression: " << std::endl << indent+1;
 | 
|---|
| 538 |         callExpr->print( os, indent+1 );
 | 
|---|
| 539 |         os << std::endl << indent << "... with temporaries:" << std::endl;
 | 
|---|
| 540 |         printAll( tempDecls, os, indent+1 );
 | 
|---|
| 541 |         os << std::endl << indent << "... with return temporaries:" << std::endl;
 | 
|---|
| 542 |         printAll( returnDecls, os, indent+1 );
 | 
|---|
| 543 |         Expression::print( os, indent );
 | 
|---|
| 544 | }
 | 
|---|
| 545 | 
 | 
|---|
| 546 | 
 | 
|---|
| 547 | ConstructorExpr::ConstructorExpr( Expression * callExpr ) : callExpr( callExpr ) {
 | 
|---|
| 548 |         // allow resolver to type a constructor used as an expression as if it has the same type as its first argument
 | 
|---|
| 549 |         assert( callExpr );
 | 
|---|
| 550 |         Expression * arg = InitTweak::getCallArg( callExpr, 0 );
 | 
|---|
| 551 |         assert( arg );
 | 
|---|
| 552 |         set_result( maybeClone( arg->result ) );
 | 
|---|
| 553 | }
 | 
|---|
| 554 | 
 | 
|---|
| 555 | ConstructorExpr::ConstructorExpr( const ConstructorExpr & other ) : Expression( other ), callExpr( maybeClone( other.callExpr ) ) {
 | 
|---|
| 556 | }
 | 
|---|
| 557 | 
 | 
|---|
| 558 | ConstructorExpr::~ConstructorExpr() {
 | 
|---|
| 559 |         delete callExpr;
 | 
|---|
| 560 | }
 | 
|---|
| 561 | 
 | 
|---|
| 562 | void ConstructorExpr::print( std::ostream &os, Indenter indent ) const {
 | 
|---|
| 563 |         os <<  "Constructor Expression: " << std::endl << indent+1;
 | 
|---|
| 564 |         callExpr->print( os, indent + 2 );
 | 
|---|
| 565 |         Expression::print( os, indent );
 | 
|---|
| 566 | }
 | 
|---|
| 567 | 
 | 
|---|
| 568 | 
 | 
|---|
| 569 | CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : initializer( initializer ) {
 | 
|---|
| 570 |         assert( type && initializer );
 | 
|---|
| 571 |         type->set_lvalue( true );
 | 
|---|
| 572 |         set_result( type );
 | 
|---|
| 573 | }
 | 
|---|
| 574 | 
 | 
|---|
| 575 | CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), initializer( other.initializer->clone() ) {}
 | 
|---|
| 576 | 
 | 
|---|
| 577 | CompoundLiteralExpr::~CompoundLiteralExpr() {
 | 
|---|
| 578 |         delete initializer;
 | 
|---|
| 579 | }
 | 
|---|
| 580 | 
 | 
|---|
| 581 | void CompoundLiteralExpr::print( std::ostream &os, Indenter indent ) const {
 | 
|---|
| 582 |         os << "Compound Literal Expression: " << std::endl << indent+1;
 | 
|---|
| 583 |         result->print( os, indent+1 );
 | 
|---|
| 584 |         os << indent+1;
 | 
|---|
| 585 |         initializer->print( os, indent+1 );
 | 
|---|
| 586 |         Expression::print( os, indent );
 | 
|---|
| 587 | }
 | 
|---|
| 588 | 
 | 
|---|
| 589 | RangeExpr::RangeExpr( Expression *low, Expression *high ) : low( low ), high( high ) {}
 | 
|---|
| 590 | RangeExpr::RangeExpr( const RangeExpr &other ) : Expression( other ), low( other.low->clone() ), high( other.high->clone() ) {}
 | 
|---|
| 591 | void RangeExpr::print( std::ostream &os, Indenter indent ) const {
 | 
|---|
| 592 |         os << "Range Expression: ";
 | 
|---|
| 593 |         low->print( os, indent );
 | 
|---|
| 594 |         os << " ... ";
 | 
|---|
| 595 |         high->print( os, indent );
 | 
|---|
| 596 |         Expression::print( os, indent );
 | 
|---|
| 597 | }
 | 
|---|
| 598 | 
 | 
|---|
| 599 | StmtExpr::StmtExpr( CompoundStmt *statements ) : statements( statements ) {
 | 
|---|
| 600 |         assert( statements );
 | 
|---|
| 601 |         std::list< Statement * > & body = statements->get_kids();
 | 
|---|
| 602 |         if ( ! body.empty() ) {
 | 
|---|
| 603 |                 if ( ExprStmt * exprStmt = dynamic_cast< ExprStmt * >( body.back() ) ) {
 | 
|---|
| 604 |                         result = maybeClone( exprStmt->expr->result );
 | 
|---|
| 605 |                 }
 | 
|---|
| 606 |         }
 | 
|---|
| 607 |         // ensure that StmtExpr has a result type
 | 
|---|
| 608 |         if ( ! result ) {
 | 
|---|
| 609 |                 result = new VoidType( Type::Qualifiers() );
 | 
|---|
| 610 |         }
 | 
|---|
| 611 | }
 | 
|---|
| 612 | StmtExpr::StmtExpr( const StmtExpr &other ) : Expression( other ), statements( other.statements->clone() ) {
 | 
|---|
| 613 |         cloneAll( other.returnDecls, returnDecls );
 | 
|---|
| 614 |         cloneAll( other.dtors, dtors );
 | 
|---|
| 615 | }
 | 
|---|
| 616 | StmtExpr::~StmtExpr() {
 | 
|---|
| 617 |         delete statements;
 | 
|---|
| 618 |         deleteAll( dtors );
 | 
|---|
| 619 |         deleteAll( returnDecls );
 | 
|---|
| 620 | }
 | 
|---|
| 621 | void StmtExpr::print( std::ostream &os, Indenter indent ) const {
 | 
|---|
| 622 |         os << "Statement Expression: " << std::endl << indent+1;
 | 
|---|
| 623 |         statements->print( os, indent+1 );
 | 
|---|
| 624 |         if ( ! returnDecls.empty() ) {
 | 
|---|
| 625 |                 os << indent+1 << "... with returnDecls: ";
 | 
|---|
| 626 |                 printAll( returnDecls, os, indent+1 );
 | 
|---|
| 627 |         }
 | 
|---|
| 628 |         if ( ! dtors.empty() ) {
 | 
|---|
| 629 |                 os << indent+1 << "... with dtors: ";
 | 
|---|
| 630 |                 printAll( dtors, os, indent+1 );
 | 
|---|
| 631 |         }
 | 
|---|
| 632 |         Expression::print( os, indent );
 | 
|---|
| 633 | }
 | 
|---|
| 634 | 
 | 
|---|
| 635 | 
 | 
|---|
| 636 | long long UniqueExpr::count = 0;
 | 
|---|
| 637 | UniqueExpr::UniqueExpr( Expression *expr, long long idVal ) : expr( expr ), object( nullptr ), var( nullptr ), id( idVal ) {
 | 
|---|
| 638 |         assert( expr );
 | 
|---|
| 639 |         assert( count != -1 );
 | 
|---|
| 640 |         if ( id == -1 ) id = count++;
 | 
|---|
| 641 |         if ( expr->get_result() ) {
 | 
|---|
| 642 |                 set_result( expr->get_result()->clone() );
 | 
|---|
| 643 |         }
 | 
|---|
| 644 | }
 | 
|---|
| 645 | UniqueExpr::UniqueExpr( const UniqueExpr &other ) : Expression( other ), expr( maybeClone( other.expr ) ), object( maybeClone( other.object ) ), var( maybeClone( other.var ) ), id( other.id ) {
 | 
|---|
| 646 | }
 | 
|---|
| 647 | UniqueExpr::~UniqueExpr() {
 | 
|---|
| 648 |         delete expr;
 | 
|---|
| 649 |         delete object;
 | 
|---|
| 650 |         delete var;
 | 
|---|
| 651 | }
 | 
|---|
| 652 | void UniqueExpr::print( std::ostream &os, Indenter indent ) const {
 | 
|---|
| 653 |         os << "Unique Expression with id:" << id << std::endl << indent+1;
 | 
|---|
| 654 |         expr->print( os, indent+1 );
 | 
|---|
| 655 |         if ( object ) {
 | 
|---|
| 656 |                 os << indent << "... with decl: ";
 | 
|---|
| 657 |                 get_object()->printShort( os, indent+1 );
 | 
|---|
| 658 |         }
 | 
|---|
| 659 |         Expression::print( os, indent );
 | 
|---|
| 660 | }
 | 
|---|
| 661 | 
 | 
|---|
| 662 | InitAlternative::InitAlternative( Type * type, Designation * designation ) : type( type ), designation( designation ) {}
 | 
|---|
| 663 | InitAlternative::InitAlternative( const InitAlternative & other ) : type( maybeClone( other.type ) ), designation( maybeClone( other.designation ) ) {}
 | 
|---|
| 664 | InitAlternative::~InitAlternative() {
 | 
|---|
| 665 |         delete type;
 | 
|---|
| 666 |         delete designation;
 | 
|---|
| 667 | }
 | 
|---|
| 668 | 
 | 
|---|
| 669 | UntypedInitExpr::UntypedInitExpr( Expression * expr, const std::list<InitAlternative> & initAlts ) : expr( expr ), initAlts( initAlts ) {}
 | 
|---|
| 670 | UntypedInitExpr::UntypedInitExpr( const UntypedInitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), initAlts( other.initAlts ) {}
 | 
|---|
| 671 | UntypedInitExpr::~UntypedInitExpr() {
 | 
|---|
| 672 |         delete expr;
 | 
|---|
| 673 | }
 | 
|---|
| 674 | 
 | 
|---|
| 675 | void UntypedInitExpr::print( std::ostream & os, Indenter indent ) const {
 | 
|---|
| 676 |         os << "Untyped Init Expression" << std::endl << indent+1;
 | 
|---|
| 677 |         expr->print( os, indent+1 );
 | 
|---|
| 678 |         if ( ! initAlts.empty() ) {
 | 
|---|
| 679 |                 for ( const InitAlternative & alt : initAlts ) {
 | 
|---|
| 680 |                         os << indent+1 <<  "InitAlternative: ";
 | 
|---|
| 681 |                         alt.type->print( os, indent+1 );
 | 
|---|
| 682 |                         alt.designation->print( os, indent+1 );
 | 
|---|
| 683 |                 }
 | 
|---|
| 684 |         }
 | 
|---|
| 685 | }
 | 
|---|
| 686 | 
 | 
|---|
| 687 | InitExpr::InitExpr( Expression * expr, Designation * designation ) : expr( expr ), designation( designation ) {
 | 
|---|
| 688 |         set_result( expr->get_result()->clone() );
 | 
|---|
| 689 | }
 | 
|---|
| 690 | InitExpr::InitExpr( const InitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), designation( maybeClone( other.designation) ) {}
 | 
|---|
| 691 | InitExpr::~InitExpr() {
 | 
|---|
| 692 |         delete expr;
 | 
|---|
| 693 |         delete designation;
 | 
|---|
| 694 | }
 | 
|---|
| 695 | 
 | 
|---|
| 696 | void InitExpr::print( std::ostream & os, Indenter indent ) const {
 | 
|---|
| 697 |         os << "Init Expression" << std::endl << indent+1;
 | 
|---|
| 698 |         expr->print( os, indent+1 );
 | 
|---|
| 699 |         os << indent+1 << "... with designation: ";
 | 
|---|
| 700 |         designation->print( os, indent+1 );
 | 
|---|
| 701 | }
 | 
|---|
| 702 | 
 | 
|---|
| 703 | // Local Variables: //
 | 
|---|
| 704 | // tab-width: 4 //
 | 
|---|
| 705 | // mode: c++ //
 | 
|---|
| 706 | // compile-command: "make install" //
 | 
|---|
| 707 | // End: //
 | 
|---|