Ignore:
Timestamp:
Jun 28, 2019, 3:50:21 PM (5 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
03bf5c8
Parents:
55b6476
Message:

Assorted cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Autogen.h

    r55b6476 r417117e  
    2121
    2222#include "AST/Decl.hpp"
     23#include "AST/Eval.hpp"
    2324#include "AST/Expr.hpp"
    2425#include "AST/Init.hpp"
     
    264265                }
    265266
    266                 ast::ptr< ast::Expr > begin, end, cmp, update;
     267                ast::ptr< ast::Expr > begin, end;
     268                std::string cmp, update;
    267269
    268270                if ( forward ) {
     
    270272                        begin = ast::ConstantExpr::from_int( loc, 0 );
    271273                        end = array->dimension;
    272                         cmp = new ast::NameExpr{ loc, "?<?" };
    273                         update = new ast::NameExpr{ loc, "++?" };
     274                        cmp = "?<?";
     275                        update = "++?";
    274276                } else {
    275277                        // generate: for ( int i = N-1; i >= 0; --i )
    276                         begin = new ast::UntypedExpr{
    277                                 loc, new ast::NameExpr{ loc, "?-?" },
    278                                 { array->dimension, ast::ConstantExpr::from_int( loc, 1 ) } };
     278                        begin = ast::call(
     279                                loc, "?-?", array->dimension, ast::ConstantExpr::from_int( loc, 1 ) );
    279280                        end = ast::ConstantExpr::from_int( loc, 0 );
    280                         cmp = new ast::NameExpr{ loc, "?>=?" };
    281                         update = new ast::NameExpr{ loc, "--?" };
     281                        cmp = "?>=?";
     282                        update = "--?";
    282283                }
    283284
     
    285286                        loc, indexName.newName(), new ast::BasicType{ ast::BasicType::SignedInt },
    286287                        new ast::SingleInit{ loc, begin } };
    287                
    288                 ast::ptr< ast::Expr > cond = new ast::UntypedExpr{
    289                         loc, cmp, { new ast::VariableExpr{ loc, index }, end } };
    290                
    291                 ast::ptr< ast::Expr > inc = new ast::UntypedExpr{
    292                         loc, update, { new ast::VariableExpr{ loc, index } } };
    293                
    294                 ast::ptr< ast::Expr > dstIndex = new ast::UntypedExpr{
    295                         loc, new ast::NameExpr{ loc, "?[?]" },
    296                         { dstParam, new ast::VariableExpr{ loc, index } } };
     288                ast::ptr< ast::Expr > indexVar = new ast::VariableExpr{ loc, index };
     289               
     290                ast::ptr< ast::Expr > cond = ast::call( loc, cmp, indexVar, end );
     291               
     292                ast::ptr< ast::Expr > inc = ast::call( loc, update, indexVar );
     293               
     294                ast::ptr< ast::Expr > dstIndex = ast::call( loc, "?[?]", dstParam, indexVar );
    297295               
    298296                // srcParam must keep track of the array indices to build the source parameter and/or
    299297                // array list initializer
    300                 srcParam.addArrayIndex( new ast::VariableExpr{ loc, index }, array->dimension );
     298                srcParam.addArrayIndex( indexVar, array->dimension );
    301299
    302300                // for stmt's body, eventually containing call
     
    384382                if ( isUnnamedBitfield( obj ) ) return {};
    385383
    386                 ast::ptr< ast::Type > addCast = nullptr;
     384                ast::ptr< ast::Type > addCast;
    387385                if ( (fname == "?{}" || fname == "^?{}") && ( ! obj || ( obj && ! obj->bitfieldWidth ) ) ) {
    388386                        assert( dstParam->result );
Note: See TracChangeset for help on using the changeset viewer.