Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Autogen.h

    r417117e rb4f8808  
    2121
    2222#include "AST/Decl.hpp"
    23 #include "AST/Eval.hpp"
    2423#include "AST/Expr.hpp"
    2524#include "AST/Init.hpp"
     
    9897                        //   type->get_qualifiers() = Type::Qualifiers();
    9998                        Type * castType = addCast->clone();
    100                         castType->get_qualifiers() -= Type::Qualifiers( Type::Lvalue | Type::Const | Type::Volatile | Type::Restrict | Type::Atomic );
     99                        castType->get_qualifiers() -= Type::Qualifiers( Type::Const | Type::Volatile | Type::Restrict | Type::Atomic );
    101100                        // castType->set_lvalue( true ); // xxx - might not need this
    102101                        dstParam = new CastExpr( dstParam, new ReferenceType( Type::Qualifiers(), castType ) );
     
    265264                }
    266265
    267                 ast::ptr< ast::Expr > begin, end;
    268                 std::string cmp, update;
     266                ast::ptr< ast::Expr > begin, end, cmp, update;
    269267
    270268                if ( forward ) {
     
    272270                        begin = ast::ConstantExpr::from_int( loc, 0 );
    273271                        end = array->dimension;
    274                         cmp = "?<?";
    275                         update = "++?";
     272                        cmp = new ast::NameExpr{ loc, "?<?" };
     273                        update = new ast::NameExpr{ loc, "++?" };
    276274                } else {
    277275                        // generate: for ( int i = N-1; i >= 0; --i )
    278                         begin = ast::call(
    279                                 loc, "?-?", array->dimension, ast::ConstantExpr::from_int( loc, 1 ) );
     276                        begin = new ast::UntypedExpr{
     277                                loc, new ast::NameExpr{ loc, "?-?" },
     278                                { array->dimension, ast::ConstantExpr::from_int( loc, 1 ) } };
    280279                        end = ast::ConstantExpr::from_int( loc, 0 );
    281                         cmp = "?>=?";
    282                         update = "--?";
     280                        cmp = new ast::NameExpr{ loc, "?>=?" };
     281                        update = new ast::NameExpr{ loc, "--?" };
    283282                }
    284283
     
    286285                        loc, indexName.newName(), new ast::BasicType{ ast::BasicType::SignedInt },
    287286                        new ast::SingleInit{ loc, begin } };
    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 );
     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 } } };
    295297               
    296298                // srcParam must keep track of the array indices to build the source parameter and/or
    297299                // array list initializer
    298                 srcParam.addArrayIndex( indexVar, array->dimension );
     300                srcParam.addArrayIndex( new ast::VariableExpr{ loc, index }, array->dimension );
    299301
    300302                // for stmt's body, eventually containing call
     
    382384                if ( isUnnamedBitfield( obj ) ) return {};
    383385
    384                 ast::ptr< ast::Type > addCast;
     386                ast::ptr< ast::Type > addCast = nullptr;
    385387                if ( (fname == "?{}" || fname == "^?{}") && ( ! obj || ( obj && ! obj->bitfieldWidth ) ) ) {
    386388                        assert( dstParam->result );
Note: See TracChangeset for help on using the changeset viewer.