Changeset 76e8c55
- Timestamp:
- Aug 4, 2016, 12:30:01 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 064e3ff, cf37a8e
- Parents:
- 8688ce1 (diff), bee4283 (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. - Location:
- src
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/GenPoly/Box.cc ¶
r8688ce1 r76e8c55 619 619 return 0; 620 620 } 621 621 622 622 /// Returns T if the given declaration is a function with parameters (T*, T) for some TypeInstType T, NULL otherwise 623 623 TypeInstType *isTypeInstPtrValFn( DeclarationWithType *decl ) { … … 637 637 return 0; 638 638 } 639 639 640 640 /// Returns T if the given declaration is (*?=?)(T *, T) for some TypeInstType T (return not checked, but maybe should be), NULL otherwise 641 641 TypeInstType *isTypeInstAssignment( DeclarationWithType *decl ) { … … 677 677 return 0; 678 678 } 679 679 680 680 /// Returns T if the given declaration is a function with parameters (T*, T) for some type T, where neither parameter is cv-qualified, 681 681 /// NULL otherwise … … 772 772 copyOps.beginScope(); 773 773 dtorOps.beginScope(); 774 774 775 775 DeclarationWithType *oldRetval = retval; 776 776 bool oldUseRetval = useRetval; … … 1471 1471 VariableExpr *wrapFunctionDecl( DeclarationWithType *functionDecl ) { 1472 1472 // line below cloned from FixFunction.cc 1473 // xxx - functionObj is never added to a list of declarations... 1473 1474 ObjectDecl *functionObj = new ObjectDecl( functionDecl->get_name(), functionDecl->get_storageClass(), functionDecl->get_linkage(), 0, 1474 1475 new PointerType( Type::Qualifiers(), functionDecl->get_type()->clone() ), 0 ); 1475 1476 functionObj->set_mangleName( functionDecl->get_mangleName() ); 1477 functionObj->set_scopeLevel( functionDecl->get_scopeLevel() ); 1476 1478 return new VariableExpr( functionObj ); 1477 1479 } … … 1492 1494 = ParamEntry( assertOp->get_uniqueId(), assertOp->get_type()->clone(), actualDecl->get_type()->clone(), wrapFunctionDecl( assertOp ) ); 1493 1495 } 1494 1496 1495 1497 Statement * Pass1::mutate( ReturnStmt *returnStmt ) { 1496 1498 if ( retval && returnStmt->get_expr() ) { … … 1554 1556 DeclarationWithType *assertDtor = findOpForType( formalType, dtorOps, scopedDtorOps ); 1555 1557 if ( ! assertDtor ) throw SemanticError( "No destructor found for ", formalType ); 1556 1558 1557 1559 // add inferred parameters for otype operators to assignment expression 1558 1560 // NOTE: Code here assumes that first four assertions are assign op, ctor, copy ctor, dtor, in that order … … 1568 1570 ++actualIt; 1569 1571 addAssertionFor( assignExpr, *actualIt, assertDtor ); 1570 1571 //DeclarationWithType *actualDecl = asserts.front(); 1572 //assignExpr->get_inferParams()[ actualDecl->get_uniqueId() ] 1573 // = ParamEntry( assertAssign->get_uniqueId(), assertAssign->get_type()->clone(), actualDecl->get_type()->clone(), wrapFunctionDecl( assertAssign ) ); 1572 1574 1573 } 1575 1574 } … … 2181 2180 bool PolyGenericCalculator::findGeneric( Type *ty ) { 2182 2181 ty = replaceTypeInst( ty, env ); 2183 2182 2184 2183 if ( TypeInstType *typeInst = dynamic_cast< TypeInstType* >( ty ) ) { 2185 2184 if ( scopeTyVars.find( typeInst->get_name() ) != scopeTyVars.end() ) { -
TabularUnified src/SymTab/Validate.cc ¶
r8688ce1 r76e8c55 541 541 if ( StructInstType *aggDecl = dynamic_cast< StructInstType * >( tyDecl->get_base() ) ) { 542 542 return new StructDecl( aggDecl->get_name() ); 543 // return aggDecl->get_baseStruct();544 543 } else if ( UnionInstType *aggDecl = dynamic_cast< UnionInstType * >( tyDecl->get_base() ) ) { 545 544 return new UnionDecl( aggDecl->get_name() ); 545 } else if ( EnumInstType *enumDecl = dynamic_cast< EnumInstType * >( tyDecl->get_base() ) ) { 546 return new EnumDecl( enumDecl->get_name() ); 546 547 } else { 547 548 return ret; -
TabularUnified src/examples/gc_no_raii/bug-repro/return_template.c ¶
r8688ce1 r76e8c55 5 5 }; 6 6 7 forall(otype T) void ?{}(wrap(T)* this); 8 forall(otype T) void ?{}(wrap(T)* this, wrap(T)* rhs); 9 forall(otype T) void ^?{}(wrap(T)* this); 10 forall(otype T) void ?=?(wrap(T)* this, wrap(T)* rhs); 11 7 12 forall(otype T) 8 static inlinewrap(T) test()13 wrap(T) test() 9 14 { 10 15 wrap(T) tester; -
TabularUnified src/examples/gc_no_raii/src/gc.h ¶
r8688ce1 r76e8c55 7 7 static inline gcpointer(T) gcmalloc() 8 8 { 9 gcpointer(T) test; 10 // ctor(&test, gc_allocate(sizeof(T))); 11 // gc_conditional_collect(); 12 return test; 9 gcpointer(T) ptr; 10 void* address = gc_allocate(sizeof(T)); 11 (&ptr){ address }; 12 ctor(&ptr, address); 13 gc_conditional_collect(); 14 return ptr; 13 15 } -
TabularUnified src/examples/gc_no_raii/src/gcpointers.c ¶
r8688ce1 r76e8c55 1 1 #include "gcpointers.h" 2 2 3 #include "gc.h"3 // #include "gc.h" 4 4 #include "internal/collector.h" 5 5 #include "internal/object_header.h" -
TabularUnified src/examples/gc_no_raii/src/gcpointers.h ¶
r8688ce1 r76e8c55 10 10 }; 11 11 12 void gcpointer_ctor(gcpointer_t* this);13 void gcpointer_ctor(gcpointer_t* this, void* address);14 void gcpointer_ctor(gcpointer_t* this, gcpointer_t*other);15 void gcpointer_dtor(gcpointer_t* this);16 gcpointer_t* gcpointer_assign(gcpointer_t* this, gcpointer_t*rhs);12 void ?{}(gcpointer_t* this); 13 void ?{}(gcpointer_t* this, void* address); 14 void ?{}(gcpointer_t* this, gcpointer_t other); 15 void ^?{}(gcpointer_t* this); 16 gcpointer_t* ?=?(gcpointer_t this, gcpointer_t rhs); 17 17 18 18 //Logical operators … … 27 27 }; 28 28 29 forall(otype T) 30 static inline void ctor(gcpointer(T)* this) 31 { 32 gcpointer_ctor(&this->internal); 33 } 29 // 30 forall(otype T) void ?{}(gcpointer(T)* this); 31 forall(otype T) void ?{}(gcpointer(T)* this, void* address); 32 forall(otype T) void ctor(gcpointer(T)* this, void* address); 33 forall(otype T) void ?{}(gcpointer(T)* this, gcpointer(T)* other); 34 forall(otype T) void ^?{}(gcpointer(T)* this); 35 forall(otype T) gcpointer(T) ?=?(gcpointer(T) this, gcpointer(T) rhs); 34 36 35 // forall(otype T)36 // static inline void ctor(gcpointer(T)* this, int null)37 // {38 // gcpointer_ctor(&this->internal, NULL);39 // }40 37 41 forall(otype T) 42 static inline void ctor(gcpointer(T)* this, void* address) 43 { 44 gcpointer_ctor(&this->internal, address); 45 } 46 47 forall(otype T) 48 static inline void ctor(gcpointer(T)* this, gcpointer(T)* other) 49 { 50 gcpointer_ctor(&this->internal, other); 51 } 52 53 forall(otype T) 54 static inline void dtor(gcpointer(T)* this) 55 { 56 gcpointer_dtor(&this->internal); 57 } 58 59 forall(otype T) 60 static inline gcpointer(T)* ?=?(gcpointer(T)* this, gcpointer(T)* rhs) 61 { 62 gcpointer_assign(&this->internal, &rhs->internal); 63 return this; 64 } 65 66 forall(otype T) 67 static inline T *?(gcpointer(T) this) 68 { 69 return *(T*)this.internal.ptr; 70 } 38 forall(otype T) T *?(gcpointer(T) this); 71 39 72 40 //Logical operators 73 forall(otype T) 74 static inline int ?!=?(gcpointer(T) this, gcpointer(T) rhs) 75 { 76 return this.internal.ptr != rhs.internal.ptr; 77 } 78 79 forall(otype T) 80 static inline int ?==?(gcpointer(T) this, gcpointer(T) rhs) 81 { 82 return !(this == rhs); 83 } 84 85 forall(otype T) 86 extern struct gcpointer(T) 0; 41 forall(otype T) int ?!=?(gcpointer(T) this, gcpointer(T) rhs); 42 forall(otype T) int ?==?(gcpointer(T) this, gcpointer(T) rhs); -
TabularUnified src/examples/gc_no_raii/src/internal/memory_pool.h ¶
r8688ce1 r76e8c55 3 3 extern "C" { 4 4 #include <stdbool.h> 5 #include <stddef.h> 5 6 #include <stdint.h> 6 7 } -
TabularUnified src/examples/gc_no_raii/src/internal/state.h ¶
r8688ce1 r76e8c55 1 1 #pragma once 2 2 3 #ifdef __cforall 4 extern "C" { 5 #endif 3 6 #include <stddef.h> 4 7 #include <stdint.h> 8 #ifdef __cforall 9 } 10 #endif 11 #include <vector> 5 12 6 13 #include "tools.h" 7 #include "vector.h"8 14 9 15 typedef vector(struct gc_memory_pool*, heap_allocator(struct gc_memory_pool*)) pools_table_t; -
TabularUnified src/examples/gc_no_raii/src/tools/worklist.h ¶
r8688ce1 r76e8c55 10 10 #endif 11 11 12 #include "vector.h"12 #include <vector> 13 13 14 14 typedef vector(intptr_t*, heap_allocator(intptr_t*)) worklist_t; -
TabularUnified src/examples/gc_no_raii/test/badlll.c ¶
r8688ce1 r76e8c55 7 7 }; 8 8 9 void ?{}(List_t* this); 10 List_t* ?=?(List_t* this, List_t* rhs); 11 9 12 typedef gcpointer(List_t) LLL; 10 13 11 14 #define MAX (1024 * 1024) 12 15 13 LLL buildLLL(int sz) 16 // LLL buildLLL(int sz) 17 void bla() 14 18 { 15 19 int i; 16 LLL ll0, lll, llc;17 18 ll0 = gcmalloc();19 ll0->val = 0;20 lll = ll0;21 22 for (i = 1; i < sz; i++)23 {24 llc = gcmalloc();25 llc->val = i;26 lll->next = llc;27 lll = llc;28 }29 30 return ll0;20 // LLL ll0;//, lll, llc; 21 // 22 // ll0 = gcmalloc(); 23 // ll0->val = 0; 24 // lll = ll0; 25 // 26 // for (i = 1; i < sz; i++) 27 // { 28 // llc = gcmalloc(); 29 // llc->val = i; 30 // lll->next = llc; 31 // lll = llc; 32 // } 33 // 34 // return ll0; 31 35 } 32 33 void testLLL(LLL lll)34 {35 unsigned char *counted;36 37 counted = (unsigned char *) calloc(MAX, sizeof(unsigned char));38 while (lll)39 {40 counted[lll->val]++;41 if (counted[lll->val] > 1)42 {43 fprintf(stderr, "ERROR! Encountered %d twice!\n", lll->val);44 exit(1);45 }46 lll = lll->next;47 }48 49 return;50 }36 // 37 // void testLLL(LLL lll) 38 // { 39 // unsigned char *counted; 40 // 41 // counted = (unsigned char *) calloc(MAX, sizeof(unsigned char)); 42 // while (lll) 43 // { 44 // counted[lll->val]++; 45 // if (counted[lll->val] > 1) 46 // { 47 // fprintf(stderr, "ERROR! Encountered %d twice!\n", lll->val); 48 // exit(1); 49 // } 50 // lll = lll->next; 51 // } 52 // 53 // return; 54 // } 51 55 52 56 int main(void) … … 54 58 LLL mylll; 55 59 56 mylll = buildLLL(MAX);57 58 testLLL(mylll);60 // mylll = buildLLL(MAX); 61 // 62 // testLLL(mylll); 59 63 60 64 return 0; -
TabularUnified src/examples/gc_no_raii/test/gctest.c ¶
r8688ce1 r76e8c55 7 7 int main() { 8 8 sout | "Bonjour au monde!\n"; 9 10 gcpointer(int) anInt = gcmalloc(); 9 11 }
Note: See TracChangeset
for help on using the changeset viewer.