浏览代码

Added connection and delegation as operators

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@6903 8c9fc860-2736-0410-a75d-ab315db34111
felixf 8 年之前
父节点
当前提交
f5a15dbf8a
共有 2 个文件被更改,包括 21 次插入3 次删除
  1. 17 1
      source/ActiveCellsRuntime.mod
  2. 4 2
      source/FoxSemanticChecker.Mod

+ 17 - 1
source/ActiveCellsRuntime.mod

@@ -495,8 +495,24 @@ type
 		if EnableTrace then trace('normal rec');end;
 		BulkReceive(system.val(any,p),a);
 	end "<<";
+
+	type Pin = port in; Pout = port out;
 	
+	operator ">>"* (pout: Pout; pin: Pin); 
+	begin
+		connect(pout, pin);
+	end ">>";
 	
-
+	operator ">>"* (p0: Pout; p1: Pout); 
+	begin
+		delegate(p0,p1);
+	end ">>";
+	
+	operator ">>"* (p0: Pin; p1: Pin); 
+	begin
+		delegate(p0,p1);
+	end ">>";
 end ActiveCellsRuntime.
 
+
+SystemTools.FreeDownTo FoxSemanticChecker ~

+ 4 - 2
source/FoxSemanticChecker.Mod

@@ -6064,9 +6064,9 @@ TYPE
 					END;
 				(* ------- CONNECT -------*)
 				ELSIF (id = Global.Connect) & (CheckArity(2,3)) THEN
-					IF 	~(currentIsCellNet) THEN
+					(*IF 	~(currentIsCellNet) THEN
 						Error(position,Diagnostics.Invalid,"connection outside activeCells body block");
-					END;
+					END;*)
 
 					IF CheckPortType(parameter0, outPort) & CheckPortType(parameter1, inPort) THEN
 						IF (outPort.direction # SyntaxTree.OutPort) THEN Error(parameter0.position,Diagnostics.Invalid,"not an out-port") END;
@@ -6085,9 +6085,11 @@ TYPE
 					activeCellsStatement := TRUE;
 				(* ---------- DELEGATE --------*)
 				ELSIF (id = Global.Delegate) & (CheckArity(2,2)) THEN
+					(*
 					IF 	~(currentIsCellNet) THEN
 						Error(position,Diagnostics.Invalid,"connection delegation outside activeCells body block");
 					END;
+					*)
 					IF ~CheckPortType(parameter1, inPort) THEN
 						Error(parameter0.position,Diagnostics.Invalid,"not a port")
 					ELSIF ~CheckPortType(parameter0, outPort) THEN