Changeset 4a60488 for src/Common/Eval.cc
- Timestamp:
- Sep 27, 2019, 3:35:46 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 90ce35aa
- Parents:
- 8e1467d (diff), 849720f (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Common/Eval.cc
r8e1467d r4a60488 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun May 6 22:24:16 201813 // Update Count : 4012 // Last Modified On : Wed Jul 24 15:09:06 2019 13 // Update Count : 64 14 14 // 15 15 … … 27 27 bool valid = true; 28 28 29 void previsit( BaseSyntaxNode * ) { visit_children = false; }30 void postvisit( BaseSyntaxNode * ) { valid = false; }29 void previsit( const BaseSyntaxNode * ) { visit_children = false; } 30 void postvisit( const BaseSyntaxNode * ) { valid = false; } 31 31 32 void postvisit( ConstantExpr * expr ) { 32 void postvisit( const SizeofExpr * ) { 33 } 34 35 void postvisit( const ConstantExpr * expr ) { 33 36 value = expr->intValue(); 34 37 } 35 38 36 void postvisit( CastExpr * expr ) {39 void postvisit( const CastExpr * expr ) { 37 40 auto arg = eval(expr->arg); 38 41 valid = arg.second; … … 41 44 } 42 45 43 void postvisit( VariableExpr *expr ) {46 void postvisit( const VariableExpr * const expr ) { 44 47 if ( EnumInstType * inst = dynamic_cast<EnumInstType *>(expr->result) ) { 45 48 if ( EnumDecl * decl = inst->baseEnum ) { … … 52 55 } 53 56 54 void postvisit( ApplicationExpr * expr ) {55 DeclarationWithType * function = InitTweak::getFunction( expr);57 void postvisit( const ApplicationExpr * expr ) { 58 DeclarationWithType * function = InitTweak::getFunction(const_cast<ApplicationExpr *>(expr)); 56 59 if ( ! function || function->linkage != LinkageSpec::Intrinsic ) { valid = false; return; } 57 60 const std::string & fname = function->name; … … 94 97 void postvisit( const ast::ConstantExpr * expr ) { 95 98 value = expr->intValue(); 99 } 100 101 void postvisit( const ast::SizeofExpr * expr ) { 102 if ( expr->expr ) value = eval(expr->expr).first; 103 else if ( expr->type ) value = eval(expr->expr).first; 104 else SemanticError( expr->location, ::toString( "Internal error: SizeofExpr has no expression or type value" ) ); 96 105 } 97 106 … … 145 154 }; 146 155 147 std::pair<long long int, bool> eval( Expression * expr) {156 std::pair<long long int, bool> eval( const Expression * expr) { 148 157 PassVisitor<EvalOld> ev; 149 158 if (expr) {
Note: See TracChangeset
for help on using the changeset viewer.