Changes in / [de91427b:083cf31]
- Location:
- src
- Files:
-
- 2 deleted
- 7 edited
-
CodeGen/CodeGenerator.cc (modified) (3 diffs)
-
CodeGen/OperatorTable.cc (modified) (2 diffs)
-
CodeGen/OperatorTable.h (modified) (2 diffs)
-
MakeLibCfa.cc (modified) (2 diffs)
-
Parser/ParseNode.h (modified) (2 diffs)
-
SymTab/Validate.cc (modified) (4 diffs)
-
examples/tests/vector_test.in.txt (deleted)
-
examples/tests/vector_test.out.txt (deleted)
-
initialization.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
rde91427b r083cf31 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Thu Sep 17 15:2 4:08 201513 // Update Count : 23 112 // Last Modified On : Thu Sep 17 15:25:58 2015 13 // Update Count : 233 14 14 // 15 15 … … 258 258 259 259 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 261 263 assert( false ); 262 264 break; … … 322 324 323 325 case OT_CALL: 326 case OT_CTOR: 327 case OT_DTOR: 324 328 assert( false ); 325 329 break; -
src/CodeGen/OperatorTable.cc
rde91427b r083cf31 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Tue Jun 23 17:41:14 201513 // Update Count : 511 // Last Modified By : Rob Schluntz 12 // Last Modified On : Tue Oct 06 15:26:34 2015 13 // Update Count : 9 14 14 // 15 15 … … 21 21 const OperatorInfo tableValues[] = { 22 22 { "?[?]", "", "_operator_index", OT_INDEX }, 23 { "?{}", "", "_constructor", OT_CTOR }, 24 { "^?{}", "", "_destructor", OT_DTOR }, // ~?{}, -?{}, !?{}, $?{}, ??{}, ^?{}, ?destroy, ?delete 23 25 { "?()", "", "_operator_call", OT_CALL }, 24 26 { "?++", "++", "_operator_postincr", OT_POSTFIXASSIGN }, -
src/CodeGen/OperatorTable.h
rde91427b r083cf31 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Tue Jun 23 16:09:27 201513 // Update Count : 311 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Jun 24 16:17:57 2015 13 // Update Count : 5 14 14 // 15 15 … … 22 22 enum OperatorType { 23 23 OT_INDEX, 24 OT_CTOR, 25 OT_DTOR, 24 26 OT_CALL, 25 27 OT_PREFIX, -
src/MakeLibCfa.cc
rde91427b r083cf31 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sat May 16 10:33:33 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Ju n 26 16:52:59201513 // Update Count : 1 411 // Last Modified By : Rob Schluntz 12 // Last Modified On : Fri Jul 03 18:11:37 2015 13 // Update Count : 18 14 14 // 15 15 … … 77 77 break; 78 78 } 79 case CodeGen::OT_CTOR: 80 case CodeGen::OT_DTOR: 79 81 case CodeGen::OT_CONSTANT: 80 82 case CodeGen::OT_LABELADDRESS: -
src/Parser/ParseNode.h
rde91427b r083cf31 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Aug 1 2 13:27:11201513 // Update Count : 17 212 // Last Modified On : Wed Aug 19 15:59:27 2015 13 // Update Count : 174 14 14 // 15 15 … … 180 180 Assign, MulAssn, DivAssn, ModAssn, PlusAssn, MinusAssn, LSAssn, RSAssn, AndAssn, 181 181 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, 183 184 }; 184 185 -
src/SymTab/Validate.cc
rde91427b r083cf31 10 10 // Created On : Sun May 17 21:50:04 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Fri Dec 18 15:34:05 201513 // Update Count : 2 1812 // Last Modified On : Thu Jan 07 11:27:49 2016 13 // Update Count : 269 14 14 // 15 15 … … 202 202 }; 203 203 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 204 217 void validate( std::list< Declaration * > &translationUnit, bool doDebug ) { 205 218 Pass1 pass1; … … 213 226 AutogenerateRoutines::autogenerateRoutines( translationUnit ); 214 227 acceptAll( translationUnit, pass3 ); 228 VerifyCtorDtor::verify( translationUnit ); 215 229 } 216 230 … … 1029 1043 } 1030 1044 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 * > ¶ms = 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 } 1031 1077 } // namespace SymTab 1032 1078 -
src/initialization.txt
rde91427b r083cf31 34 34 sure that resolved initializers for all declarations are being 35 35 generated. 36 37 38 ------ 39 40 More 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 47 No, unfortunately. Initialization isn't being rewritten as assignment, 48 so you shouldn't allow the particular selection of assignment 49 operators that happen to be in scope (and which may include 50 user-defined operators) to guide the type resolution. 51 52 I don't think there is any way to rewrite an initializer as a single 53 expression and have the resolver just do the right thing. I see the 54 algorithm as: 55 56 For 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 62 Go through the list of possibilities and pick the lowest cost 63 64 As with many things in the resolver, it's conceptually simple but the 65 implementation may be a bit of a pain. It fits in with functions like 66 findSingleExpression, findIntegralExpression in Resolver.cc, although 67 it will be significantly more complicated than any of the existing 68 ones. 69 70 71
Note:
See TracChangeset
for help on using the changeset viewer.