Forráskód Böngészése

fixed a bug in the order of parameters in the output port delegation operator;
double-check the correctness of port delegation defined via the use of operators

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@6912 8c9fc860-2736-0410-a75d-ab315db34111

eth.morozova 8 éve
szülő
commit
98b10aa406
2 módosított fájl, 14 hozzáadás és 5 törlés
  1. 10 1
      source/ActiveCellsRunner.mod
  2. 4 4
      source/ActiveCellsRuntime.mod

+ 10 - 1
source/ActiveCellsRunner.mod

@@ -83,6 +83,8 @@ type
 		fifo-: Fifo;
 		delegatedTo-: Port;
 		inout-: set;
+		
+		owner: Cell;
 
 		procedure & InitPort(inout: set; width: longint);
 		begin
@@ -167,6 +169,7 @@ type
 			if res # 0 then return; end; (*! do not do anything in case of an error *)
 			new(cel); c := cel;
 			cel.isCellnet := isCellnet;
+			if scope # nil then cel.scope := scope(Cell); end;
 		end Allocate;
 
 		procedure AddPort*(c: any; var p: any; const name: array of char; inout: set; width: longint);
@@ -174,7 +177,8 @@ type
 		begin
 			if res # 0 then return; end; (*! do not do anything in case of an error *)
 			if EnableTrace then trace(c,p,name, inout, width); end;
-			new(por,inout,width); p := por;
+			new(por,inout,width); por.owner := c(Cell);
+			p := por;
 		end AddPort;
 
 		procedure AddPortArray*(c: any; var ports: any; const name: array of char; inout: set; width: longint; const lens: array of longint);
@@ -248,6 +252,11 @@ type
 		begin
 			if res # 0 then return; end; (*! do not do anything in case of an error *)
 			if EnableTrace then trace(netPort, cellPort); end;
+			(*! check correctness of delegation which is not 100% guaranteed by the operator ">>" *)
+			if ~netPort(Port).owner.isCellnet or (cellPort(Port).owner = netPort(Port).owner) then
+				res := -1;
+				return;
+			end;
 			netPort(Port).Delegate(cellPort(Port));
 		end Delegate;
 

+ 4 - 4
source/ActiveCellsRuntime.mod

@@ -523,14 +523,14 @@ type
 		Connect(system.val(any, pout), system.val(any, pin), 0);
 	end ">>";
 	
-	operator ">>"* (p0: Pout; p1: Pout); 
+	operator ">>"* (cellPort: Pout; netPort: Pout); 
 	begin
-		Delegate(system.val(any, p0), system.val(any, p1));
+		Delegate(system.val(any, netPort), system.val(any, cellPort));
 	end ">>";
 	
-	operator ">>"* (p0: Pin; p1: Pin); 
+	operator ">>"* (netPort: Pin; cellPort: Pin); 
 	begin
-		Delegate(system.val(any, p0), system.val(any, p1));
+		Delegate(system.val(any, netPort), system.val(any, cellPort));
 	end ">>";
 end ActiveCellsRuntime.