Changes in / [083cf31:de91427b]
- Location:
- src
- Files:
-
- 2 added
- 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 (added)
-
examples/tests/vector_test.out.txt (added)
-
initialization.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r083cf31 rde91427b 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 5:58 201513 // Update Count : 23 312 // Last Modified On : Thu Sep 17 15:24:08 2015 13 // Update Count : 231 14 14 // 15 15 … … 258 258 259 259 case OT_CALL: 260 case OT_CTOR: 261 case OT_DTOR: 262 // there are no intrinsic definitions of the function call operator or constructors or destructors 260 // there are no intrinsic definitions of the function call operator 263 261 assert( false ); 264 262 break; … … 324 322 325 323 case OT_CALL: 326 case OT_CTOR:327 case OT_DTOR:328 324 assert( false ); 329 325 break; -
src/CodeGen/OperatorTable.cc
r083cf31 rde91427b 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Tue Oct 06 15:26:34 201513 // Update Count : 911 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jun 23 17:41:14 2015 13 // Update Count : 5 14 14 // 15 15 … … 21 21 const OperatorInfo tableValues[] = { 22 22 { "?[?]", "", "_operator_index", OT_INDEX }, 23 { "?{}", "", "_constructor", OT_CTOR },24 { "^?{}", "", "_destructor", OT_DTOR }, // ~?{}, -?{}, !?{}, $?{}, ??{}, ^?{}, ?destroy, ?delete25 23 { "?()", "", "_operator_call", OT_CALL }, 26 24 { "?++", "++", "_operator_postincr", OT_POSTFIXASSIGN }, -
src/CodeGen/OperatorTable.h
r083cf31 rde91427b 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Jun 24 16:17:57 201513 // Update Count : 511 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jun 23 16:09:27 2015 13 // Update Count : 3 14 14 // 15 15 … … 22 22 enum OperatorType { 23 23 OT_INDEX, 24 OT_CTOR,25 OT_DTOR,26 24 OT_CALL, 27 25 OT_PREFIX, -
src/MakeLibCfa.cc
r083cf31 rde91427b 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sat May 16 10:33:33 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Fri Ju l 03 18:11:37201513 // Update Count : 1 811 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jun 26 16:52:59 2015 13 // Update Count : 14 14 14 // 15 15 … … 77 77 break; 78 78 } 79 case CodeGen::OT_CTOR:80 case CodeGen::OT_DTOR:81 79 case CodeGen::OT_CONSTANT: 82 80 case CodeGen::OT_LABELADDRESS: -
src/Parser/ParseNode.h
r083cf31 rde91427b 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 9 15:59:27201513 // Update Count : 17 412 // Last Modified On : Wed Aug 12 13:27:11 2015 13 // Update Count : 172 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, 183 Ctor, Dtor, 182 UnPlus, UnMinus, AddressOf, PointTo, Neg, BitNeg, Incr, IncrPost, Decr, DecrPost, LabelAddress 184 183 }; 185 184 -
src/SymTab/Validate.cc
r083cf31 rde91427b 10 10 // Created On : Sun May 17 21:50:04 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Thu Jan 07 11:27:49 201613 // Update Count : 2 6912 // Last Modified On : Fri Dec 18 15:34:05 2015 13 // Update Count : 218 14 14 // 15 15 … … 202 202 }; 203 203 204 class VerifyCtorDtor : public Visitor {205 public:206 /// ensure that constructors and destructors have at least one207 /// parameter, the first of which must be a pointer, and no208 /// return values.209 static void verify( std::list< Declaration * > &translationUnit );210 211 // VerifyCtorDtor() {}212 213 virtual void visit( FunctionDecl *funcDecl );214 private:215 };216 217 204 void validate( std::list< Declaration * > &translationUnit, bool doDebug ) { 218 205 Pass1 pass1; … … 226 213 AutogenerateRoutines::autogenerateRoutines( translationUnit ); 227 214 acceptAll( translationUnit, pass3 ); 228 VerifyCtorDtor::verify( translationUnit );229 215 } 230 216 … … 1043 1029 } 1044 1030 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 statements1069 // to cause desired behaviour1070 // 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 a1072 // complicated expression with side effects (see: malloc). idea: add temporary variable1073 // that is assigned address of constructed object in ctor argument position and1074 // return the temporary. It should also be done after all implicit ctors are1075 // added, so not in this pass!1076 }1077 1031 } // namespace SymTab 1078 1032 -
src/initialization.txt
r083cf31 rde91427b 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 correct42 > results from the unification engine is by feeding it an expression that43 > looks like "?=?( ((struct Y)x.y).a, 10 )", then picking out the pieces that44 > I need (namely the correct choice for a). Does this seem like a reasonable45 > 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 assignment49 operators that happen to be in scope (and which may include50 user-defined operators) to guide the type resolution.51 52 I don't think there is any way to rewrite an initializer as a single53 expression and have the resolver just do the right thing. I see the54 algorithm as:55 56 For each alternative interpretation of the designator:57 Construct an expression that casts the initializer to the type of58 the designator59 Construct an AlternativeFinder and use it to find the lowest cost60 interpretation of the expression61 Add this interpretation to a list of possibilities62 Go through the list of possibilities and pick the lowest cost63 64 As with many things in the resolver, it's conceptually simple but the65 implementation may be a bit of a pain. It fits in with functions like66 findSingleExpression, findIntegralExpression in Resolver.cc, although67 it will be significantly more complicated than any of the existing68 ones.69 70 71
Note:
See TracChangeset
for help on using the changeset viewer.