Changeset 29038ef
- Timestamp:
- Jul 7, 2017, 10:39:13 AM (7 years ago)
- 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:
- 54d714e, b5f9829
- Parents:
- 53a6c2a (diff), e182ce3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/proposals/tagged-struct.txt
r53a6c2a r29038ef 71 71 should be possible to do during linking. 72 72 73 If a generic/polymorphic type is tagged its tagged would then be shared 74 between all applications of that generic. Internal tags could be used to 75 seperate these structures again, however it seems in most cases simply using 76 the existing type parameters should provide the needed information. 77 73 78 74 79 Traits: … … 102 107 To allow for growth each option would have to be a structure itself. 103 108 104 Which brings us to "tagge tstruct union", ie. a union of tagged structures109 Which brings us to "tagged struct union", ie. a union of tagged structures 105 110 as opposed to tagging the union itself. This extention acts as a constraint. 106 111 If unions are declared tagged instead of creating a new tagged type, all 107 possible values of the union must be of that tagged type or a child type. 112 possible values of the union must be of that tagged type or a child type. If 113 the tagged type is omitted then they must all be tagged but of any tagged 114 type. 115 116 As a short cut union_instance->type might get the type object of the loaded 117 value. It should always be the same operation regardless so it saves 118 abritarly picking a branch of the union to get the type object. 108 119 109 120 110 Custom Type Objects (Extention):121 Type Objects Fields (Extention): 111 122 112 Some method to define type objects used within a tree of types. One option is 113 to allow the tree's type object to be specified by the tree root. It would 114 then have to be filled in for each type in the tree, including the root. 123 Adding fields to the type object allows data to be shared between instances 124 of the same type. Such behaviour could be mimiced by creating a lookup 125 function on the type object pointer, but this may be cleaner and more 126 efficient. 115 127 116 The only required field is the parent field, a pointer to the type object's 117 type. (This is also the only required field on the tagged structure itself.) 128 The type object fields follow similar rules to the fields on the tagged 129 objects themselves, they must be additive. So any fields present on a 130 type object will be present (and in the same place) on all of its children. 118 131 119 A further extention could allow expanding type objects, so child types could 120 append fields to their parent's feild list. They might need their own type 121 objects at that point, or maybe static checks will be enough to see the 122 minimum field list. 132 This does mean that many type object structure types will have to be auto 133 generated, and traversing up the tree might get a little wierd. That could 134 be symplified by only allowing the root type to specify fields on the type 135 object, so that the type object is consistant throughout that particular tree. 136 And hence the type_object pointers would also be consistant as the type they 137 point to would never change. 138 139 struct Example tagged { 140 tagged char const * const type_name = "Example"; 141 int data; 142 }; 143 144 Creates a tagged structure that has no parent, stores an integer and the type 145 object also has an extra field that stores a string on the type object. 146 This can be accessed by using member access on the type object, as a regular 147 structure. 148 149 Type object fields will have to allow initialization on their declaration, 150 and declarations of children as well, as they are not assotiated with the 151 later instances of the tagged structure. 152 153 ... 154 tagged void (*dtor)(tagged Example * this); 155 ... 156 157 Sub-Extention, not sure how it would work but some way to have a "dynamic" 158 field that is considered the type of the current tagged struct might be useful 159 for things like specifying a deconstructor. In this case, the following code 160 will clean up any child type of Example: 161 162 Example * ex = get_some_example(); 163 ex->type->dtor(ex); -
src/GenPoly/InstantiateGeneric.cc
r53a6c2a r29038ef 171 171 Type* postmutate( UnionInstType *inst ); 172 172 173 void premutate( FunctionType * ftype ) {173 void premutate( __attribute__((unused)) FunctionType * ftype ) { 174 174 GuardValue( inFunctionType ); 175 175 inFunctionType = true; -
src/InitTweak/GenInit.cc
r53a6c2a r29038ef 71 71 // that need to be constructed or destructed 72 72 void previsit( StructDecl *aggregateDecl ); 73 void previsit( UnionDecl *aggregateDecl ) { visit_children = false; } 74 void previsit( EnumDecl *aggregateDecl ) { visit_children = false; } 75 void previsit( TraitDecl *aggregateDecl ) { visit_children = false; } 76 void previsit( TypeDecl *typeDecl ) { visit_children = false; } 77 void previsit( TypedefDecl *typeDecl ) { visit_children = false; } 78 79 void previsit( FunctionType *funcType ) { visit_children = false; } 73 void previsit( __attribute__((unused)) UnionDecl * aggregateDecl ) { visit_children = false; } 74 void previsit( __attribute__((unused)) EnumDecl * aggregateDecl ) { visit_children = false; } 75 void previsit( __attribute__((unused)) TraitDecl * aggregateDecl ) { visit_children = false; } 76 void previsit( __attribute__((unused)) TypeDecl * typeDecl ) { visit_children = false; } 77 void previsit( __attribute__((unused)) TypedefDecl * typeDecl ) { visit_children = false; } 78 void previsit( __attribute__((unused)) FunctionType * funcType ) { visit_children = false; } 80 79 81 80 void previsit( CompoundStmt * compoundStmt ); … … 336 335 } 337 336 338 void CtorDtor::previsit( CompoundStmt * compoundStmt ) {337 void CtorDtor::previsit( __attribute__((unused)) CompoundStmt * compoundStmt ) { 339 338 GuardScope( managedTypes ); 340 339 } -
src/Parser/parser.yy
r53a6c2a r29038ef 2332 2332 | TYPEGENname 2333 2333 | CONST 2334 { $$ = Token{ new string( "__const__" ) }; }2334 { $$ = Token{ new string( "__const__" ), { nullptr, -1 } }; } 2335 2335 ; 2336 2336 -
src/ResolvExpr/CurrentObject.cc
r53a6c2a r29038ef 127 127 } 128 128 129 virtual void print( std::ostream & out, Indenter indent ) const {129 virtual void print( std::ostream & out, __attribute__((unused)) Indenter indent ) const { 130 130 out << "SimpleIterator(" << type << ")"; 131 131 } -
src/tests/.expect/32/math.txt
r53a6c2a r29038ef 22 22 cos:0.540302 0.54030230586814 0.540302305868139717 0.83373-0.988898i 0.833730025131149-0.988897705762865i 0.833730025131149049-0.988897705762865096i 23 23 tan:1.55741 1.5574077246549 1.55740772465490223 0.271753+1.08392i 0.271752585319512+1.08392332733869i 0.271752585319511717+1.08392332733869454i 24 asin:1.5708 1.5707963267949 1.57079632679489662 0.6662 4+1.06128i 0.666239432492515+1.06127506190504i 0.666239432492515255+1.06127506190503565i24 asin:1.5708 1.5707963267949 1.57079632679489662 0.666239+1.06128i 0.666239432492515+1.06127506190504i 0.666239432492515255+1.06127506190503565i 25 25 acos:0 0 0 0.904557-1.06128i 0.904556894302381-1.06127506190504i 0.904556894302381364-1.06127506190503565i 26 26 atan:0.785398 0.785398163397448 0.78539816339744831 1.01722+0.402359i 1.01722196789785+0.402359478108525i 1.01722196789785137+0.402359478108525094i
Note: See TracChangeset
for help on using the changeset viewer.