Changes in / [de91427b:083cf31]


Ignore:
Location:
src
Files:
2 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    rde91427b r083cf31  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Thu Sep 17 15:24:08 2015
    13 // Update Count     : 231
     12// Last Modified On : Thu Sep 17 15:25:58 2015
     13// Update Count     : 233
    1414//
    1515
     
    258258             
    259259                                  case OT_CALL:
    260                                         // there are no intrinsic definitions of the function call operator
     260                                  case OT_CTOR:
     261                                  case OT_DTOR:
     262                                        // there are no intrinsic definitions of the function call operator or constructors or destructors
    261263                                        assert( false );
    262264                                        break;
     
    322324             
    323325                                  case OT_CALL:
     326                                        case OT_CTOR:
     327                                        case OT_DTOR:
    324328                                        assert( false );
    325329                                        break;
  • src/CodeGen/OperatorTable.cc

    rde91427b r083cf31  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jun 23 17:41:14 2015
    13 // Update Count     : 5
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Tue Oct 06 15:26:34 2015
     13// Update Count     : 9
    1414//
    1515
     
    2121                const OperatorInfo tableValues[] = {
    2222                        {       "?[?]",         "",             "_operator_index",                              OT_INDEX                        },
     23                        {       "?{}",          "",             "_constructor",                                 OT_CTOR                         },
     24                        {       "^?{}",         "",             "_destructor",                                  OT_DTOR                         }, // ~?{}, -?{}, !?{}, $?{}, ??{}, ^?{}, ?destroy, ?delete
    2325                        {       "?()",          "",             "_operator_call",                               OT_CALL                         },
    2426                        {       "?++",          "++",   "_operator_postincr",                   OT_POSTFIXASSIGN        },
  • src/CodeGen/OperatorTable.h

    rde91427b r083cf31  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jun 23 16:09:27 2015
    13 // Update Count     : 3
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed Jun 24 16:17:57 2015
     13// Update Count     : 5
    1414//
    1515
     
    2222        enum OperatorType {
    2323                OT_INDEX,
     24                OT_CTOR,
     25                OT_DTOR,
    2426                OT_CALL,
    2527                OT_PREFIX,
  • src/MakeLibCfa.cc

    rde91427b r083cf31  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sat May 16 10:33:33 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jun 26 16:52:59 2015
    13 // Update Count     : 14
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Fri Jul 03 18:11:37 2015
     13// Update Count     : 18
    1414//
    1515
     
    7777                                break;
    7878                        }
     79                  case CodeGen::OT_CTOR:
     80                  case CodeGen::OT_DTOR:
    7981                  case CodeGen::OT_CONSTANT:
    8082                  case CodeGen::OT_LABELADDRESS:
  • src/Parser/ParseNode.h

    rde91427b r083cf31  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Aug 12 13:27:11 2015
    13 // Update Count     : 172
     12// Last Modified On : Wed Aug 19 15:59:27 2015
     13// Update Count     : 174
    1414//
    1515
     
    180180                                Assign, MulAssn, DivAssn, ModAssn, PlusAssn, MinusAssn, LSAssn, RSAssn, AndAssn,
    181181                                ERAssn, OrAssn, Index, FieldSel, PFieldSel, Range,
    182                                 UnPlus, UnMinus, AddressOf, PointTo, Neg, BitNeg, Incr, IncrPost, Decr, DecrPost, LabelAddress
     182                                UnPlus, UnMinus, AddressOf, PointTo, Neg, BitNeg, Incr, IncrPost, Decr, DecrPost, LabelAddress,
     183                                Ctor, Dtor,
    183184        };
    184185
  • src/SymTab/Validate.cc

    rde91427b r083cf31  
    1010// Created On       : Sun May 17 21:50:04 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri Dec 18 15:34:05 2015
    13 // Update Count     : 218
     12// Last Modified On : Thu Jan 07 11:27:49 2016
     13// Update Count     : 269
    1414//
    1515
     
    202202        };
    203203
     204        class VerifyCtorDtor : public Visitor {
     205        public:
     206                /// ensure that constructors and destructors have at least one
     207                /// parameter, the first of which must be a pointer, and no
     208                /// return values.
     209                static void verify( std::list< Declaration * > &translationUnit );
     210
     211                // VerifyCtorDtor() {}
     212
     213                virtual void visit( FunctionDecl *funcDecl );
     214        private:
     215        };
     216
    204217        void validate( std::list< Declaration * > &translationUnit, bool doDebug ) {
    205218                Pass1 pass1;
     
    213226                AutogenerateRoutines::autogenerateRoutines( translationUnit );
    214227                acceptAll( translationUnit, pass3 );
     228                VerifyCtorDtor::verify( translationUnit );
    215229        }
    216230
     
    10291043        }
    10301044
     1045        void VerifyCtorDtor::verify( std::list< Declaration * > & translationUnit ) {
     1046                VerifyCtorDtor verifier;
     1047                acceptAll( translationUnit, verifier );
     1048        }
     1049
     1050        void VerifyCtorDtor::visit( FunctionDecl * funcDecl ) {
     1051                FunctionType * funcType = funcDecl->get_functionType();
     1052                std::list< DeclarationWithType * > &returnVals = funcType->get_returnVals();
     1053                std::list< DeclarationWithType * > &params = funcType->get_parameters();
     1054
     1055                if ( funcDecl->get_name() == "?{}" || funcDecl->get_name() == "^?{}" ) {
     1056                        if ( params.size() == 0 ) {
     1057                                throw SemanticError( "Constructors and destructors require at least one parameter ", funcDecl );
     1058                        }
     1059                        if ( ! dynamic_cast< PointerType * >( params.front()->get_type() ) ) {
     1060                                throw SemanticError( "First parameter of a constructor or destructor must be a pointer ", funcDecl );
     1061                        }
     1062                        if ( returnVals.size() != 0 ) {
     1063                                throw SemanticError( "Constructors and destructors cannot have explicit return values ", funcDecl );
     1064                        }
     1065                }
     1066
     1067                Visitor::visit( funcDecl );
     1068                // original idea: modify signature of ctor/dtors and insert appropriate return statements
     1069                // to cause desired behaviour
     1070                // new idea: add comma exprs to every ctor call to produce first parameter.
     1071                // this requires some memoization of the first parameter, because it can be a
     1072                // complicated expression with side effects (see: malloc). idea: add temporary variable
     1073                // that is assigned address of constructed object in ctor argument position and
     1074                // return the temporary. It should also be done after all implicit ctors are
     1075                // added, so not in this pass!
     1076        }
    10311077} // namespace SymTab
    10321078
  • src/initialization.txt

    rde91427b r083cf31  
    3434sure that resolved initializers for all declarations are being
    3535generated.
     36
     37
     38------
     39
     40More recent email: (I am quoted; Richard is the responder)
     41> As far as I'm aware, the only way that I could currently get the correct
     42> results from the unification engine is by feeding it an expression that
     43> looks like "?=?( ((struct Y)x.y).a, 10 )", then picking out the pieces that
     44> I need (namely the correct choice for a). Does this seem like a reasonable
     45> approach to solve this problem?
     46
     47No, unfortunately. Initialization isn't being rewritten as assignment,
     48so you shouldn't allow the particular selection of assignment
     49operators that happen to be in scope (and which may include
     50user-defined operators) to guide the type resolution.
     51
     52I don't think there is any way to rewrite an initializer as a single
     53expression and have the resolver just do the right thing. I see the
     54algorithm as:
     55
     56For each alternative interpretation of the designator:
     57  Construct an expression that casts the initializer to the type of
     58    the designator
     59  Construct an AlternativeFinder and use it to find the lowest cost
     60    interpretation of the expression
     61  Add this interpretation to a list of possibilities
     62Go through the list of possibilities and pick the lowest cost
     63
     64As with many things in the resolver, it's conceptually simple but the
     65implementation may be a bit of a pain. It fits in with functions like
     66findSingleExpression, findIntegralExpression in Resolver.cc, although
     67it will be significantly more complicated than any of the existing
     68ones.
     69
     70
     71
Note: See TracChangeset for help on using the changeset viewer.