startup classage expr111 { main(String[] args) { create TX(); } } classage TX = T + X with E >> F as K { TX() { :X(); } } classage T { mixer E { export void c() { return; } } connector A { import void t0() export void e(int x) {return; } } } classage X { X() { ::t(create Y(), create Z()); } mixer F { export void b() { return; } } connector A { import void t0() export void t1() { print("OK from export t1"); print("now inside t1 of A for a passive call"); t0(); print("end of the passive call"); print("now the value of per-connection state connf is " + connf); connf = 3; print("now the value of per-connection state connf is " + connf); } state int connf = 0; } void t(Y y, Z z) { A x1, x2; print("[1]"); // the following line should have no effect, since currently // A is not connected forall(h::A) {print("now inside forall before connect:"); h->t0();} print("[2]"); //connect happens here x1 = connect y with A >> B; print("[3]"); // now the t0 defined by Y's B should be invoked, pure import case x1->t0(); print("[5]"); // now the t1 defined by X's A should be invoked, pure export case x1->t1(); print("[6]"); // the following line should now invoke t0 defined by Y's B, since // currently A is connected to y forall(h::A) {print("now inside forall after connect:"); h->t0(); } print("[7]"); // another connect happens here x2 = connect z with A >> B; print("[8]"); // now the t0 defined by Z's B should be invoked, pure import case x2->t0(); print("[10]"); // now the t1 defined by X's A should be invoked, pure export case x2->t1(); print("[11]"); // the following line should now invoke t0 defined by Y's B, and // invoke t0 defined by Z's B, since currently A is connected to // two objectages. forall(h::A) {print("now inside forall after connect:"); h->t0(); } print("[12]"); //disconnect disconnect x1; print("[13]"); // the following line should now invoke t0 defined by Z's B, // since currently A is only connected to z. forall(h::A) {print("now inside forall after disconnect:"); h->t0();} print("[14]"); // if the following line are not commented out, runtime exception // will be thrown because x1 is currently stale. // x1->t0(); // x1->t1(); print("[15]"); //cascaded connect/disconnect disconnect (connect y with A >> B); return; } } classage Y { connector B { export void t0() { print("OK from export t0 of Y"); return; } export void t1() { print("OK from export t1 of Y"); return; } } } classage Z { connector B { export void t0() { print("OK from export t0 of Z"); return; } export void t1() { print("OK from export t1 of Z"); return; } } }