Changeset ca35c51
- Timestamp:
- Jun 30, 2016, 1:47:52 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 1bc1bb2
- Parents:
- 84d4d6f
- Location:
- src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ControlStruct/CaseRangeMutator.cc
r84d4d6f rca35c51 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jan 25 21:22:40201613 // Update Count : 412 // Last Modified On : Thu Jun 30 13:28:55 2016 13 // Update Count : 8 14 14 // 15 15 -
src/GenPoly/Box.cc
r84d4d6f rca35c51 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Fri May 13 14:51:21201613 // Update Count : 29 511 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jun 29 21:43:03 2016 13 // Update Count : 296 14 14 // 15 15 … … 2294 2294 // all union members are at offset zero 2295 2295 delete offsetofExpr; 2296 return new ConstantExpr( Constant( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), std::string("0")) );2296 return new ConstantExpr( Constant( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), "0" ) ); 2297 2297 } else return offsetofExpr; 2298 2298 } -
src/GenPoly/GenPoly.cc
r84d4d6f rca35c51 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed May 25 13:39:21201613 // Update Count : 1 311 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jun 29 21:45:53 2016 13 // Update Count : 14 14 14 // 15 15 … … 78 78 type = replaceTypeInst( type, env ); 79 79 80 if ( TypeInstType *typeInst =dynamic_cast< TypeInstType * >( type ) ) {80 if ( dynamic_cast< TypeInstType * >( type ) ) { 81 81 return type; 82 82 } else if ( StructInstType *structType = dynamic_cast< StructInstType* >( type ) ) { -
src/InitTweak/FixGlobalInit.cc
r84d4d6f rca35c51 9 9 // Author : Rob Schluntz 10 10 // Created On : Mon May 04 15:14:56 2016 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Fri May 13 11:37:30201613 // Update Count : 211 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jun 29 22:33:15 2016 13 // Update Count : 4 14 14 // 15 15 … … 85 85 init->accept( checker ); 86 86 return checker.isConstExpr; 87 } 87 } // if 88 88 // for all intents and purposes, no initializer means const expr 89 89 return true; … … 98 98 } else { 99 99 translationUnit.push_back( fixer.initFunction ); 100 } 100 } // if 101 101 102 if ( fixer.destroyFunction->get_statements()->get_kids().empty() ) { 102 103 delete fixer.destroyFunction; 103 104 } else { 104 105 translationUnit.push_back( fixer.destroyFunction ); 105 } 106 } // if 106 107 } 107 108 … … 146 147 // if ( isConstExpr( objDecl->get_init() ) ) return; 147 148 148 if ( ArrayType * at =dynamic_cast< ArrayType * > ( objDecl->get_type() ) ) {149 if ( dynamic_cast< ArrayType * > ( objDecl->get_type() ) ) { 149 150 // xxx - initialize each element of the array 150 151 } else { … … 164 165 destroy->get_args().push_back( new AddressExpr( new VariableExpr( objDecl ) ) ); 165 166 destroyStatements.push_front( new ImplicitCtorDtorStmt( new ExprStmt( noLabels, destroy ) ) ); 166 } 167 } // if 167 168 } 168 169 -
src/Parser/ExpressionNode.cc
r84d4d6f rca35c51 10 10 // Created On : Sat May 16 13:17:07 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jun 13 14:46:17201613 // Update Count : 3 0712 // Last Modified On : Thu Jun 30 13:33:16 2016 13 // Update Count : 319 14 14 // 15 15 … … 19 19 #include <sstream> 20 20 #include <cstdio> 21 #include <climits>22 21 23 22 #include "ParseNode.h" … … 90 89 //############################################################################## 91 90 92 static inline bool checkU( char c ) { return c == 'u' || c == 'U'; } 93 static inline bool checkL( char c ) { return c == 'l' || c == 'L'; } 94 static inline bool checkF( char c ) { return c == 'f' || c == 'F'; } 95 static inline bool checkD( char c ) { return c == 'd' || c == 'D'; } 96 static inline bool checkI( char c ) { return c == 'i' || c == 'I'; } 97 static inline bool checkX( char c ) { return c == 'x' || c == 'X'; } 98 99 // Difficult to separate extra parts of constants during lexing because actions are not allow in the middle of patterns: 100 // 101 // prefix action constant action suffix 102 // 103 // Alternatively, breaking a pattern using BEGIN does not work if the following pattern can be empty: 104 // 105 // constant BEGIN CONT ... 106 // <CONT>(...)? BEGIN 0 ... // possible empty suffix 107 // 108 // because the CONT rule is NOT triggered if the pattern is empty. Hence, constants are reparsed here to determine their 109 // type. 110 111 ConstantNode::ConstantNode( Type t, string *inVal ) : type( t ), value( *inVal ) { 112 // lexing divides constants into 4 kinds 113 switch ( type ) { 114 case Integer: 115 { 116 static const BasicType::Kind kind[2][3] = { 117 { BasicType::SignedInt, BasicType::LongSignedInt, BasicType::LongLongSignedInt }, 118 { BasicType::UnsignedInt, BasicType::LongUnsignedInt, BasicType::LongLongUnsignedInt }, 119 }; 120 bool dec = true, Unsigned = false; // decimal, unsigned constant 121 int size; // 0 => int, 1 => long, 2 => long long 122 unsigned long long v; // converted integral value 123 size_t last = value.length() - 1; // last character of constant 124 125 if ( value[0] == '0' ) { // octal constant ? 126 dec = false; 127 if ( last != 0 && checkX( value[1] ) ) { // hex constant ? 128 sscanf( (char *)value.c_str(), "%llx", &v ); 129 //printf( "%llx %llu\n", v, v ); 130 } else { 131 sscanf( (char *)value.c_str(), "%llo", &v ); 132 //printf( "%llo %llu\n", v, v ); 133 } // if 134 } else { // decimal constant ? 135 sscanf( (char *)value.c_str(), "%llu", &v ); 136 //printf( "%llu %llu\n", v, v ); 137 } // if 138 139 if ( v <= INT_MAX ) { // signed int 140 size = 0; 141 } else if ( v <= UINT_MAX && ! dec ) { // unsigned int 142 size = 0; 143 Unsigned = true; // unsigned 144 } else if ( v <= LONG_MAX ) { // signed long int 145 size = 1; 146 } else if ( v <= ULONG_MAX && ( ! dec || LONG_MAX == LLONG_MAX ) ) { // signed long int 147 size = 1; 148 Unsigned = true; // unsigned long int 149 } else if ( v <= LLONG_MAX ) { // signed long long int 150 size = 2; 151 } else { // unsigned long long int 152 size = 2; 153 Unsigned = true; // unsigned long long int 154 } // if 155 156 if ( checkU( value[last] ) ) { // suffix 'u' ? 157 Unsigned = true; 158 if ( last > 0 && checkL( value[ last - 1 ] ) ) { // suffix 'l' ? 159 size = 1; 160 if ( last > 1 && checkL( value[ last - 2 ] ) ) { // suffix 'll' ? 161 size = 2; 162 } // if 163 } // if 164 } else if ( checkL( value[ last ] ) ) { // suffix 'l' ? 165 size = 1; 166 if ( last > 0 && checkL( value[ last - 1 ] ) ) { // suffix 'll' ? 167 size = 2; 168 if ( last > 1 && checkU( value[ last - 2 ] ) ) { // suffix 'u' ? 169 Unsigned = true; 170 } // if 171 } else { 172 if ( last > 0 && checkU( value[ last - 1 ] ) ) { // suffix 'u' ? 173 Unsigned = true; 174 } // if 175 } // if 176 } // if 177 btype = kind[Unsigned][size]; // lookup constant type 178 break; 179 } 180 case Float: 181 { 182 static const BasicType::Kind kind[2][3] = { 183 { BasicType::Float, BasicType::Double, BasicType::LongDouble }, 184 { BasicType::FloatComplex, BasicType::DoubleComplex, BasicType::LongDoubleComplex }, 185 }; 186 bool complx = false; // real, complex 187 int size = 1; // 0 => float, 1 => double (default), 2 => long double 188 // floating-point constant has minimum of 2 characters: 1. or .1 189 size_t last = value.length() - 1; 190 191 if ( checkI( value[last] ) ) { // imaginary ? 192 complx = true; 193 last -= 1; // backup one character 194 } // if 195 if ( checkF( value[last] ) ) { // float ? 196 size = 0; 197 } else if ( checkD( value[last] ) ) { // double ? 198 size = 1; 199 } else if ( checkL( value[last] ) ) { // long double ? 200 size = 2; 201 } // if 202 if ( ! complx && checkI( value[last - 1] ) ) { // imaginary ? 203 complx = true; 204 } // if 205 btype = kind[complx][size]; // lookup constant type 206 break; 207 } 208 case Character: 209 btype = BasicType::Char; // default 210 if ( string( "LUu" ).find( value[0] ) != string::npos ) { 211 // ??? 212 } // if 213 break; 214 case String: 215 // array of char 216 if ( string( "LUu" ).find( value[0] ) != string::npos ) { 217 if ( value[0] == 'u' && value[1] == '8' ) { 218 // ??? 219 } else { 220 // ??? 221 } // if 222 } // if 223 break; 224 } // switch 91 ConstantNode::ConstantNode( ConstantExpr *expr ) : expr( expr ) { 225 92 } // ConstantNode::ConstantNode 226 93 227 94 ConstantNode *ConstantNode::appendstr( const std::string *newValue ) { 228 95 assert( newValue != 0 ); 229 assert( type == String);96 string value = expr->get_constant()->get_value(); 230 97 231 98 // "abc" "def" "ghi" => "abcdefghi", remove new text from quotes and insert before last quote in old string. … … 237 104 238 105 void ConstantNode::printOneLine( std::ostream &os, int indent ) const { 239 os << string( indent, ' ' );240 printDesignation( os );241 242 switch ( type ) {243 case Integer:244 case Float:245 os << value ;246 break;247 case Character:248 os << "'" << value << "'";249 break;250 case String:251 os << '"' << value << '"';252 break;253 } // switch254 255 os << ' ';106 // os << string( indent, ' ' ); 107 // printDesignation( os ); 108 109 // switch ( type ) { 110 // case Integer: 111 // case Float: 112 // os << value ; 113 // break; 114 // case Character: 115 // os << "'" << value << "'"; 116 // break; 117 // case String: 118 // os << '"' << value << '"'; 119 // break; 120 // } // switch 121 122 // os << ' '; 256 123 } 257 124 … … 262 129 263 130 Expression *ConstantNode::build() const { 264 ::Type::Qualifiers q; // no qualifiers on constants 265 266 switch ( get_type() ) { 267 case String: 268 { 269 // string should probably be a primitive type 270 ArrayType *at = new ArrayType( q, new BasicType( q, BasicType::Char ), 271 new ConstantExpr( 272 Constant( new BasicType( q, BasicType::UnsignedInt ), 273 toString( value.size()+1-2 ) ) ), // +1 for '\0' and -2 for '"' 274 false, false ); 275 return new ConstantExpr( Constant( at, value ), maybeBuild< Expression >( get_argName() ) ); 276 } 277 default: 278 return new ConstantExpr( Constant( new BasicType( q, btype ), get_value() ), maybeBuild< Expression >( get_argName() ) ); 279 } 131 return expr->clone(); 280 132 } 281 133 -
src/Parser/ParseNode.cc
r84d4d6f rca35c51 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 13:26:29 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Aug 12 13:26:00 201513 // Update Count : 3611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jun 30 13:30:43 2016 13 // Update Count : 50 14 14 // 15 15 16 #include <climits> 16 17 #include "ParseNode.h" 17 18 using namespace std; 19 20 // Difficult to separate extra parts of constants during lexing because actions are not allow in the middle of patterns: 21 // 22 // prefix action constant action suffix 23 // 24 // Alternatively, breaking a pattern using BEGIN does not work if the following pattern can be empty: 25 // 26 // constant BEGIN CONT ... 27 // <CONT>(...)? BEGIN 0 ... // possible empty suffix 28 // 29 // because the CONT rule is NOT triggered if the pattern is empty. Hence, constants are reparsed here to determine their 30 // type. 31 32 static inline bool checkU( char c ) { return c == 'u' || c == 'U'; } 33 static inline bool checkL( char c ) { return c == 'l' || c == 'L'; } 34 static inline bool checkF( char c ) { return c == 'f' || c == 'F'; } 35 static inline bool checkD( char c ) { return c == 'd' || c == 'D'; } 36 static inline bool checkI( char c ) { return c == 'i' || c == 'I'; } 37 static inline bool checkX( char c ) { return c == 'x' || c == 'X'; } 38 39 BasicType::Kind literalType( ConstantNode::Type type, string &value ) { 40 BasicType::Kind btype; 41 42 // lexing divides constants into 4 kinds 43 switch ( type ) { 44 case ConstantNode::Integer: 45 { 46 static const BasicType::Kind kind[2][3] = { 47 { BasicType::SignedInt, BasicType::LongSignedInt, BasicType::LongLongSignedInt }, 48 { BasicType::UnsignedInt, BasicType::LongUnsignedInt, BasicType::LongLongUnsignedInt }, 49 }; 50 bool dec = true, Unsigned = false; // decimal, unsigned constant 51 int size; // 0 => int, 1 => long, 2 => long long 52 unsigned long long v; // converted integral value 53 size_t last = value.length() - 1; // last character of constant 54 55 if ( value[0] == '0' ) { // octal constant ? 56 dec = false; 57 if ( last != 0 && checkX( value[1] ) ) { // hex constant ? 58 sscanf( (char *)value.c_str(), "%llx", &v ); 59 //printf( "%llx %llu\n", v, v ); 60 } else { 61 sscanf( (char *)value.c_str(), "%llo", &v ); 62 //printf( "%llo %llu\n", v, v ); 63 } // if 64 } else { // decimal constant ? 65 sscanf( (char *)value.c_str(), "%llu", &v ); 66 //printf( "%llu %llu\n", v, v ); 67 } // if 68 69 if ( v <= INT_MAX ) { // signed int 70 size = 0; 71 } else if ( v <= UINT_MAX && ! dec ) { // unsigned int 72 size = 0; 73 Unsigned = true; // unsigned 74 } else if ( v <= LONG_MAX ) { // signed long int 75 size = 1; 76 } else if ( v <= ULONG_MAX && ( ! dec || LONG_MAX == LLONG_MAX ) ) { // signed long int 77 size = 1; 78 Unsigned = true; // unsigned long int 79 } else if ( v <= LLONG_MAX ) { // signed long long int 80 size = 2; 81 } else { // unsigned long long int 82 size = 2; 83 Unsigned = true; // unsigned long long int 84 } // if 85 86 if ( checkU( value[last] ) ) { // suffix 'u' ? 87 Unsigned = true; 88 if ( last > 0 && checkL( value[ last - 1 ] ) ) { // suffix 'l' ? 89 size = 1; 90 if ( last > 1 && checkL( value[ last - 2 ] ) ) { // suffix 'll' ? 91 size = 2; 92 } // if 93 } // if 94 } else if ( checkL( value[ last ] ) ) { // suffix 'l' ? 95 size = 1; 96 if ( last > 0 && checkL( value[ last - 1 ] ) ) { // suffix 'll' ? 97 size = 2; 98 if ( last > 1 && checkU( value[ last - 2 ] ) ) { // suffix 'u' ? 99 Unsigned = true; 100 } // if 101 } else { 102 if ( last > 0 && checkU( value[ last - 1 ] ) ) { // suffix 'u' ? 103 Unsigned = true; 104 } // if 105 } // if 106 } // if 107 btype = kind[Unsigned][size]; // lookup constant type 108 break; 109 } 110 case ConstantNode::Float: 111 { 112 static const BasicType::Kind kind[2][3] = { 113 { BasicType::Float, BasicType::Double, BasicType::LongDouble }, 114 { BasicType::FloatComplex, BasicType::DoubleComplex, BasicType::LongDoubleComplex }, 115 }; 116 bool complx = false; // real, complex 117 int size = 1; // 0 => float, 1 => double (default), 2 => long double 118 // floating-point constant has minimum of 2 characters: 1. or .1 119 size_t last = value.length() - 1; 120 121 if ( checkI( value[last] ) ) { // imaginary ? 122 complx = true; 123 last -= 1; // backup one character 124 } // if 125 if ( checkF( value[last] ) ) { // float ? 126 size = 0; 127 } else if ( checkD( value[last] ) ) { // double ? 128 size = 1; 129 } else if ( checkL( value[last] ) ) { // long double ? 130 size = 2; 131 } // if 132 if ( ! complx && checkI( value[last - 1] ) ) { // imaginary ? 133 complx = true; 134 } // if 135 btype = kind[complx][size]; // lookup constant type 136 break; 137 } 138 case ConstantNode::Character: 139 btype = BasicType::Char; // default 140 if ( string( "LUu" ).find( value[0] ) != string::npos ) { 141 // ??? 142 } // if 143 break; 144 case ConstantNode::String: 145 assert( false ); 146 // array of char 147 if ( string( "LUu" ).find( value[0] ) != string::npos ) { 148 if ( value[0] == 'u' && value[1] == '8' ) { 149 // ??? 150 } else { 151 // ??? 152 } // if 153 } // if 154 break; 155 } // switch 156 return btype; 157 } // literalType 158 159 ConstantNode *makeConstant( ConstantNode::Type type, std::string *str ) { 160 ::Type::Qualifiers emptyQualifiers; // no qualifiers on constants 161 return new ConstantNode( new ConstantExpr( Constant( new BasicType( emptyQualifiers, literalType( type, *str ) ), *str ), nullptr ) ); 162 } 163 164 ConstantNode *makeConstantStr( ConstantNode::Type type, std::string *str ) { 165 ::Type::Qualifiers emptyQualifiers; // no qualifiers on constants 166 // string should probably be a primitive type 167 ArrayType *at = new ArrayType( emptyQualifiers, new BasicType( emptyQualifiers, BasicType::Char ), 168 new ConstantExpr( 169 Constant( new BasicType( emptyQualifiers, BasicType::UnsignedInt ), 170 toString( str->size()+1-2 ) ) ), // +1 for '\0' and -2 for '"' 171 false, false ); 172 return new ConstantNode( new ConstantExpr( Constant( at, *str ), nullptr ) ); 173 } 174 18 175 19 176 // Builder -
src/Parser/ParseNode.h
r84d4d6f rca35c51 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jun 27 23:28:10201613 // Update Count : 2 4212 // Last Modified On : Thu Jun 30 11:48:28 2016 13 // Update Count : 252 14 14 // 15 15 … … 126 126 enum Type { Integer, Float, Character, String }; 127 127 128 ConstantNode( Type, std::string* );129 ConstantNode( const ConstantNode &other ) : type( other.type ), btype( other.btype), value( *new std::string( other.value) ) {};130 ~ConstantNode() { delete &value; }128 ConstantNode( ConstantExpr * ); 129 ConstantNode( const ConstantNode &other ) : expr( other.expr->clone() ) {}; 130 ~ConstantNode() { delete expr; } 131 131 132 132 virtual ConstantNode *clone() const { return new ConstantNode( *this ); } 133 Type get_type( void ) const { return type; }134 133 virtual void print( std::ostream &, int indent = 0) const; 135 134 virtual void printOneLine( std::ostream &, int indent = 0) const; 136 135 137 const std::string &get_value() const { return value; }138 136 ConstantNode *appendstr( const std::string *newValue ); 139 137 140 138 Expression *build() const; 141 139 private: 142 Type type; 143 BasicType::Kind btype; 144 std::string &value; 145 }; 140 ConstantExpr *expr; 141 }; 142 143 ConstantNode *makeConstant( ConstantNode::Type, std::string * ); 144 ConstantNode *makeConstantStr( ConstantNode::Type type, std::string *str ); 146 145 147 146 class VarRefNode : public ExpressionNode { -
src/Parser/parser.cc
r84d4d6f rca35c51 5237 5237 /* Line 1806 of yacc.c */ 5238 5238 #line 305 "parser.yy" 5239 { (yyval.constant) = new ConstantNode( ConstantNode::Integer, (yyvsp[(1) - (1)].tok) ); }5239 { (yyval.constant) = makeConstant( ConstantNode::Integer, (yyvsp[(1) - (1)].tok) ); } 5240 5240 break; 5241 5241 … … 5244 5244 /* Line 1806 of yacc.c */ 5245 5245 #line 306 "parser.yy" 5246 { (yyval.constant) = new ConstantNode( ConstantNode::Float, (yyvsp[(1) - (1)].tok) ); }5246 { (yyval.constant) = makeConstant( ConstantNode::Float, (yyvsp[(1) - (1)].tok) ); } 5247 5247 break; 5248 5248 … … 5251 5251 /* Line 1806 of yacc.c */ 5252 5252 #line 307 "parser.yy" 5253 { (yyval.constant) = new ConstantNode( ConstantNode::Character, (yyvsp[(1) - (1)].tok) ); }5253 { (yyval.constant) = makeConstant( ConstantNode::Character, (yyvsp[(1) - (1)].tok) ); } 5254 5254 break; 5255 5255 … … 5258 5258 /* Line 1806 of yacc.c */ 5259 5259 #line 332 "parser.yy" 5260 { (yyval.constant) = new ConstantNode( ConstantNode::String, (yyvsp[(1) - (1)].tok) ); }5260 { (yyval.constant) = makeConstantStr( ConstantNode::String, (yyvsp[(1) - (1)].tok) ); } 5261 5261 break; 5262 5262 … … 5953 5953 /* Line 1806 of yacc.c */ 5954 5954 #line 684 "parser.yy" 5955 { (yyval.sn) = new StatementNode( (yyvsp[(2) - (2)].decl) )/*->set_extension( true )*/; }5955 { (yyval.sn) = (new StatementNode( (yyvsp[(2) - (2)].decl) ))->set_extension( true ); } 5956 5956 break; 5957 5957 … … 7266 7266 /* Line 1806 of yacc.c */ 7267 7267 #line 1474 "parser.yy" 7268 { (yyval.decl) = (yyvsp[(2) - (3)].decl) /*->set_extension( true )*/; }7268 { (yyval.decl) = (yyvsp[(2) - (3)].decl)->set_extension( true ); } 7269 7269 break; 7270 7270 … … 7273 7273 /* Line 1806 of yacc.c */ 7274 7274 #line 1477 "parser.yy" 7275 { (yyval.decl) = (yyvsp[(2) - (3)].decl) /*->set_extension( true )*/; }7275 { (yyval.decl) = (yyvsp[(2) - (3)].decl)->set_extension( true ); } 7276 7276 break; 7277 7277 … … 8057 8057 /* Line 1806 of yacc.c */ 8058 8058 #line 1993 "parser.yy" 8059 { (yyval.decl) = (yyvsp[(2) - (2)].decl) /*->set_extension( true )*/; }8059 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->set_extension( true ); } 8060 8060 break; 8061 8061 -
src/Parser/parser.yy
r84d4d6f rca35c51 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jun 27 17:47:56201613 // Update Count : 16 2712 // Last Modified On : Thu Jun 30 13:26:01 2016 13 // Update Count : 1639 14 14 // 15 15 … … 303 303 constant: 304 304 // ENUMERATIONconstant is not included here; it is treated as a variable with type "enumeration constant". 305 INTEGERconstant { $$ = new ConstantNode( ConstantNode::Integer, $1 ); }306 | FLOATINGconstant { $$ = new ConstantNode( ConstantNode::Float, $1 ); }307 | CHARACTERconstant { $$ = new ConstantNode( ConstantNode::Character, $1 ); }305 INTEGERconstant { $$ = makeConstant( ConstantNode::Integer, $1 ); } 306 | FLOATINGconstant { $$ = makeConstant( ConstantNode::Float, $1 ); } 307 | CHARACTERconstant { $$ = makeConstant( ConstantNode::Character, $1 ); } 308 308 ; 309 309 … … 330 330 331 331 string_literal_list: // juxtaposed strings are concatenated 332 STRINGliteral { $$ = new ConstantNode( ConstantNode::String, $1 ); }332 STRINGliteral { $$ = makeConstantStr( ConstantNode::String, $1 ); } 333 333 | string_literal_list STRINGliteral { $$ = $1->appendstr( $2 ); } 334 334 ; … … 682 682 { $$ = new StatementNode( $1 ); } 683 683 | EXTENSION declaration // GCC 684 { $$ = new StatementNode( $2 )/*->set_extension( true )*/; }684 { $$ = (new StatementNode( $2 ))->set_extension( true ); } 685 685 | function_definition 686 686 { $$ = new StatementNode( $1 ); } … … 1472 1472 new_field_declaring_list ';' // CFA, new style field declaration 1473 1473 | EXTENSION new_field_declaring_list ';' // GCC 1474 { $$ = $2 /*->set_extension( true )*/; }1474 { $$ = $2->set_extension( true ); } 1475 1475 | field_declaring_list ';' 1476 1476 | EXTENSION field_declaring_list ';' // GCC 1477 { $$ = $2 /*->set_extension( true )*/; }1477 { $$ = $2->set_extension( true ); } 1478 1478 ; 1479 1479 … … 1991 1991 } 1992 1992 | EXTENSION external_definition 1993 { $$ = $2 /*->set_extension( true )*/; }1993 { $$ = $2->set_extension( true ); } 1994 1994 ; 1995 1995 -
src/SynTree/Constant.h
r84d4d6f rca35c51 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Ju l 30 15:19:16 201513 // Update Count : 512 // Last Modified On : Thu Jun 30 13:33:17 2016 13 // Update Count : 6 14 14 // 15 15 … … 29 29 Type *get_type() { return type; } 30 30 void set_type( Type *newValue ) { type = newValue; } 31 std::string get_value() { return value; }31 std::string &get_value() { return value; } 32 32 void set_value( std::string newValue ) { value = newValue; } 33 33
Note: See TracChangeset
for help on using the changeset viewer.