- Timestamp:
- Mar 21, 2017, 12:36:01 PM (8 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:
- 168c007, cb0e6de
- Parents:
- 31ce3d6
- Location:
- src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Concurrency/Keywords.cc
r31ce3d6 re04b636 150 150 coroutine_decl = decl; 151 151 } 152 else if ( false) {152 else if ( decl->is_coroutine() ) { 153 153 handle( decl ); 154 154 } … … 178 178 ); 179 179 180 decl->get_members().push_ front( cor );180 decl->get_members().push_back( cor ); 181 181 182 182 return cor; … … 201 201 ) 202 202 ); 203 type->get_returnVals().push_back( 204 new ObjectDecl( 205 "ret", 206 noStorage, 207 LinkageSpec::Cforall, 208 nullptr, 209 new PointerType( 210 noQualifiers, 211 new StructInstType( 212 noQualifiers, 213 coroutine_decl 214 ) 215 ), 216 nullptr 217 ) 218 ); 203 219 204 220 CompoundStmt * statement = new CompoundStmt( noLabels ); … … 206 222 new ReturnStmt( 207 223 noLabels, 208 new UntypedMemberExpr( 209 new NameExpr( "__cor" ), 210 new NameExpr( "this" ) 224 new AddressExpr( 225 new UntypedMemberExpr( 226 new NameExpr( "__cor" ), 227 new UntypedExpr( 228 new NameExpr( "*?" ), 229 { new NameExpr( "this" ) } 230 ) 231 ) 211 232 ) 212 233 ) 213 234 ); 214 235 215 declsToAddAfter.push_back( 216 new FunctionDecl( 217 "get_coroutine", 218 Type::Static, 219 LinkageSpec::Cforall, 220 type, 221 statement, 222 noAttributes, 223 Type::Inline 224 ) 225 ); 236 FunctionDecl * get_decl = new FunctionDecl( 237 "get_coroutine", 238 Type::Static, 239 LinkageSpec::Cforall, 240 type, 241 statement, 242 noAttributes, 243 Type::Inline 244 ); 245 246 declsToAddAfter.push_back( get_decl ); 247 248 get_decl->fixUniqueId(); 226 249 } 227 250 … … 285 308 286 309 //Make sure that typed isn't mutex 287 if( !base->get_mutex() ) throw SemanticError( "mutex keyword may only appear once per argument ", arg );310 if( base->get_mutex() ) throw SemanticError( "mutex keyword may only appear once per argument ", arg ); 288 311 } 289 312 -
src/Parser/lex.ll
r31ce3d6 re04b636 202 202 __const__ { KEYWORD_RETURN(CONST); } // GCC 203 203 continue { KEYWORD_RETURN(CONTINUE); } 204 _Coroutine { KEYWORD_RETURN(COROUTINE); } // CFA204 coroutine { KEYWORD_RETURN(COROUTINE); } // CFA 205 205 default { KEYWORD_RETURN(DEFAULT); } 206 206 disable { KEYWORD_RETURN(DISABLE); } // CFA -
src/SynTree/Type.h
r31ce3d6 re04b636 117 117 bool operator!=( Qualifiers other ) const { return (val & Mask) != (other.val & Mask); } 118 118 bool operator<=( Qualifiers other ) const { 119 return is_const <= other.is_const && is_volatile <= other.is_volatile && 120 is_mutex >= other.is_mutex && is_atomic == other.is_atomic; 119 return is_const <= other.is_const //Any non-const converts to const without cost 120 && is_volatile <= other.is_volatile //Any non-volatile converts to volatile without cost 121 && is_mutex >= other.is_mutex //Any mutex converts to non-mutex without cost 122 && is_atomic == other.is_atomic; //No conversion from atomic to non atomic is free 121 123 } 122 124 bool operator<( Qualifiers other ) const { return *this != other && *this <= other; } -
src/tests/coroutine.c
r31ce3d6 re04b636 2 2 #include <coroutine> 3 3 4 structFibonacci {4 coroutine Fibonacci { 5 5 int fn; // used for communication 6 coroutine_desc __cor;7 6 }; 8 7 … … 11 10 } 12 11 13 coroutine_desc* get_coroutine(Fibonacci* this) {14 return &this->__cor;15 }16 17 12 void main(Fibonacci* this) { 18 #ifdef MORE_DEBUG19 sout | "Starting main of coroutine " | this | endl;20 sout | "Started from " | this->__cor.last | endl;21 #endif22 13 int fn1, fn2; // retained between resumes 23 14 this->fn = 0; … … 45 36 int main() { 46 37 Fibonacci f1, f2; 47 #ifdef MORE_DEBUG48 Fibonacci *pf1 = &f1, *pf2 = &f2;49 coroutine_desc *cf1 = &f1.c, *cf2 = &f2.c;50 covptr_t *vf1 = vtable(pf1), *vf2 = vtable(pf2);51 coroutine_desc *cv1 = get_coroutine(vf1), *cv2 = get_coroutine(vf2);52 Fibonacci *ov1 = (Fibonacci *)get_object(vf1), *ov2 = (Fibonacci *)get_object(vf2);53 54 sout | "User coroutines : " | pf1 | ' ' | pf2 | endl;55 sout | "Coroutine data : " | cf1 | ' ' | cf2 | endl;56 sout | "Vptr address : " | vf1 | ' ' | vf2 | endl;57 sout | "Vptr obj data : " | ov1 | ' ' | ov2 | endl;58 sout | "Vptr cor data : " | cv1 | ' ' | cv2 | endl;59 #endif60 38 for ( int i = 1; i <= 10; i += 1 ) { 61 39 sout | next(&f1) | ' ' | next(&f2) | endl;
Note: See TracChangeset
for help on using the changeset viewer.