Changeset 406a6e6


Ignore:
Timestamp:
Aug 14, 2017, 2:44:40 PM (7 years ago)
Author:
Andrew Beach <ajbeach@…>
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:
6a36975
Parents:
bd46af4
Message:

Working on exception related readablility.

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Statement.cc

    rbd46af4 r406a6e6  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Mon Jun 12 10:37:00 2017
    13 // Update Count     : 64
     12// Last Modified On : Mon Aug 14 12:26:00 2017
     13// Update Count     : 65
    1414//
    1515
     
    329329void TryStmt::print( std::ostream &os, int indent ) const {
    330330        os << "Try Statement" << endl;
    331         os << string( indent + 2, ' ' ) << "with block: " << endl;
     331        os << string( indent + 2, ' ' ) << "with block:" << endl;
     332        os << string( indent + 4, ' ' );
    332333        block->print( os, indent + 4 );
    333334
    334335        // handlers
    335         os << string( indent + 2, ' ' ) << "and handlers: " << endl;
    336         for ( std::list<CatchStmt *>::const_iterator i = handlers.begin(); i != handlers.end(); i++)
     336        os << string( indent + 2, ' ' ) << "and handlers:" << endl;
     337        for ( std::list<CatchStmt *>::const_iterator i = handlers.begin(); i != handlers.end(); i++) {
     338                os << string( indent + 4, ' ' );
    337339                (*i )->print( os, indent + 4 );
     340        }
    338341
    339342        // finally block
    340343        if ( finallyBlock != 0 ) {
    341                 os << string( indent + 2, ' ' ) << "Finally block: " << endl;
     344                os << string( indent + 2, ' ' ) << "and finally:" << endl;
    342345                finallyBlock->print( os, indent + 4 );
    343346        } // if
     
    360363        os << "Catch " << ((Terminate == kind) ? "Terminate" : "Resume") << " Statement" << endl;
    361364
    362         os << string( indent, ' ' ) << "... catching" << endl;
     365        os << string( indent + 2, ' ' ) << "... catching: ";
    363366        if ( decl ) {
    364367                decl->printShort( os, indent + 4 );
     
    367370        else
    368371                os << string( indent + 4 , ' ' ) << ">>> Error:  this catch clause must have a declaration <<<" << endl;
     372
     373        if ( cond ) {
     374                os << string( indent + 2, ' ' ) << "with conditional:" << endl;
     375                os << string( indent + 4, ' ' );
     376                cond->print( os, indent + 4 );
     377        }
     378        else
     379                os << string( indent + 2, ' ' ) << "with no conditional" << endl;
     380
     381        os << string( indent + 2, ' ' ) << "with block:" << endl;
     382        os << string( indent + 4, ' ' );
     383        body->print( os, indent + 4 );
    369384}
    370385
     
    383398void FinallyStmt::print( std::ostream &os, int indent ) const {
    384399        os << "Finally Statement" << endl;
    385         os << string( indent + 2, ' ' ) << "with block: " << endl;
     400        os << string( indent + 2, ' ' ) << "with block:" << endl;
     401        os << string( indent + 4, ' ' );
    386402        block->print( os, indent + 4 );
    387403}
  • src/tests/except-2.c

    rbd46af4 r406a6e6  
    55
    66// Local Exception Types and manual vtable types.
     7#define GLUE2(left, right) left##right
     8#define GLUE3(left, middle, right) left##middle##right
    79#define BASE_EXCEPT __cfaehm__base_exception_t
    8 #define TABLE(name) name##_vtable
    9 #define INSTANCE(name) _##name##_vtable_instance
     10#define TABLE(name) GLUE2(name,_vtable)
     11#define INSTANCE(name) GLUE3(_,name,_vtable_instance)
    1012#define TRIVIAL_EXCEPTION(name) \
    1113struct name; \
    1214struct TABLE(name) { \
    13         struct __cfaehm__base_exception_t_vtable const * parent; \
     15        struct TABLE(BASE_EXCEPT) const * parent; \
    1416        size_t size; \
    1517        void (*copy)(name *this, name * other); \
     
    2830} \
    2931TABLE(name) INSTANCE(name) @= { \
    30         .parent : &INSTANCE(__cfaehm__base_exception_t), \
     32        .parent : &INSTANCE(BASE_EXCEPT), \
    3133        .size : sizeof(name), .copy : name##_copy, \
    3234        .free : ^?{}, .msg : name##_msg \
     
    4042struct num_error;
    4143struct num_error_vtable {
    42         struct exception_t_vtable const * parent;
     44        struct TABLE(BASE_EXCEPT) const * parent;
    4345        size_t size;
    4446        void (*copy)(num_error *this, num_error * other);
     
    6264}
    6365void ?{}(num_error * this, int num) {
    64         this->virtual_table = &_num_error_vtable_instance;
     66        this->virtual_table = &INSTANCE(num_error);
    6567        this->msg = 0;
    6668        this->num = num;
Note: See TracChangeset for help on using the changeset viewer.