Changeset 3bbd012 for src/ResolvExpr


Ignore:
Timestamp:
Jul 31, 2018, 2:43:04 PM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
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, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
Children:
642bc83
Parents:
d1e0979 (diff), 04e367c (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.
Message:

Merge branch 'master' into demangler

Location:
src/ResolvExpr
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AlternativeFinder.cc

    rd1e0979 r3bbd012  
    2525#include <vector>                  // for vector
    2626
     27#include "CompilationState.h"      // for resolvep
    2728#include "Alternative.h"           // for AltList, Alternative
    2829#include "AlternativeFinder.h"
     
    4950#include "typeops.h"               // for adjustExprType, polyCost, castCost
    5051
    51 bool resolvep;
    5252#define PRINT( text ) if ( resolvep ) { text }
    5353//#define DEBUG_COST
  • src/ResolvExpr/CurrentObject.cc

    rd1e0979 r3bbd012  
    139139                ArrayIterator( ArrayType * at ) : array( at ) {
    140140                        PRINT( std::cerr << "Creating array iterator: " << at << std::endl; )
    141                         base = at->get_base();
     141                        base = at->base;
    142142                        memberIter = createMemberIterator( base );
    143                         if ( at->isVarLen ) SemanticError( at, "VLA initialization does not support @=" );
    144                         setSize( at->get_dimension() );
     143                        if ( at->isVarLen ) SemanticError( at, "VLA initialization does not support @=: " );
     144                        setSize( at->dimension );
    145145                }
    146146
     
    150150
    151151        private:
    152                 void setSize( Expression * expr ) {
    153                         if ( ConstantExpr * constExpr = dynamic_cast< ConstantExpr * >( expr ) ) {
    154                                 try {
    155                                         size = constExpr->intValue();
    156                                         PRINT( std::cerr << "array type with size: " << size << std::endl; )
    157                                 } catch ( SemanticErrorException & ) {
    158                                         SemanticError( expr, "Constant expression of non-integral type in array dimension: " );
    159                                 }
    160                         }       else if ( CastExpr * castExpr = dynamic_cast< CastExpr * >( expr ) ) {
    161                                 setSize( castExpr->get_arg() ); // xxx - need to perform the conversion specified by the cast
    162                         } else if ( VariableExpr * varExpr = dynamic_cast< VariableExpr * >( expr ) ) {
    163                                 if ( EnumInstType * inst = dynamic_cast< EnumInstType * > ( varExpr->result ) ) {
    164                                         long long int value;
    165                                         if ( inst->baseEnum->valueOf( varExpr->var, value ) ) {
    166                                                 size = value;
    167                                         }
    168                                 }
     152                void setSize( Expression * expr ) { // replace this logic with an eval call
     153                        auto res = eval(expr);
     154                        if (res.second) {
     155                                size = res.first;
    169156                        } else {
    170                                 assertf( false, "unhandled expression in setSize: %s", toString( expr ).c_str() ); // xxx - if not a constant expression, it's not simple to determine how long the array actually is, which is necessary for initialization to be done correctly -- fix this
     157                                SemanticError( expr->location, toString("Array designator must be a constant expression: ", expr) );
    171158                        }
    172159                }
Note: See TracChangeset for help on using the changeset viewer.