Changeset f674479 for src/SymTab
- Timestamp:
- Apr 11, 2017, 4:20:51 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- da1c772
- Parents:
- a0fc78a (diff), 32bcef7 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- src/SymTab
- Files:
-
- 2 edited
-
Autogen.cc (modified) (1 diff)
-
Validate.cc (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Autogen.cc
ra0fc78a rf674479 498 498 makeUnionFieldsAssignment( srcParam, dstParam, back_inserter( funcDecl->get_statements()->get_kids() ) ); 499 499 if ( returnVal ) { 500 if ( isDynamicLayout ) makeUnionFieldsAssignment( srcParam, returnVal, back_inserter( funcDecl->get_statements()->get_kids() ) ); 501 else funcDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new VariableExpr( srcParam ) ) ); 500 funcDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new VariableExpr( srcParam ) ) ); 502 501 } 503 502 } -
src/SymTab/Validate.cc
ra0fc78a rf674479 208 208 }; 209 209 210 class ArrayLength : public Visitor { 211 public: 212 /// for array types without an explicit length, compute the length and store it so that it 213 /// is known to the rest of the phases. For example, 214 /// int x[] = { 1, 2, 3 }; 215 /// int y[][2] = { { 1, 2, 3 }, { 1, 2, 3 } }; 216 /// here x and y are known at compile-time to have length 3, so change this into 217 /// int x[3] = { 1, 2, 3 }; 218 /// int y[3][2] = { { 1, 2, 3 }, { 1, 2, 3 } }; 219 static void computeLength( std::list< Declaration * > & translationUnit ); 220 221 virtual void visit( ObjectDecl * objDecl ); 222 }; 223 210 224 class CompoundLiteral final : public GenPoly::DeclMutator { 211 225 Type::StorageClasses storageClasses; … … 235 249 acceptAll( translationUnit, pass3 ); 236 250 VerifyCtorDtorAssign::verify( translationUnit ); 251 ArrayLength::computeLength( translationUnit ); 237 252 } 238 253 … … 869 884 } 870 885 } 886 887 void ArrayLength::computeLength( std::list< Declaration * > & translationUnit ) { 888 ArrayLength len; 889 acceptAll( translationUnit, len ); 890 } 891 892 void ArrayLength::visit( ObjectDecl * objDecl ) { 893 if ( ArrayType * at = dynamic_cast< ArrayType * >( objDecl->get_type() ) ) { 894 if ( at->get_dimension() != nullptr ) return; 895 if ( ListInit * init = dynamic_cast< ListInit * >( objDecl->get_init() ) ) { 896 at->set_dimension( new ConstantExpr( Constant::from_ulong( init->get_initializers().size() ) ) ); 897 } 898 } 899 } 871 900 } // namespace SymTab 872 901
Note:
See TracChangeset
for help on using the changeset viewer.