issue-#167 endless loop in DevBrowser for cyclic pointer typ

luowy
Posts: 234
Joined: Mon Oct 20, 2014 12:52 pm

Re: issue-#167 endless loop in DevBrowser for cyclic pointer

Post by luowy »

ok, the last one,challenge all your examples, igore its complexity.

Code: Select all

	
	PROCEDURE IsHook(typ: DevCPT.Struct): BOOLEAN;
		VAR t0: ARRAY 128 OF DevCPT.Struct; 
		VAR n: INTEGER;

		PROCEDURE In(t: DevCPT.Struct): BOOLEAN;
			VAR i: INTEGER;
		BEGIN
			IF n >= LEN(t0) THEN RETURN TRUE END;
			FOR i := 0 TO n - 1 DO 
				IF t0[i] = t THEN RETURN TRUE END;
			END;
			RETURN FALSE; 
		END In;
		
	BEGIN
		n := 0;
		WHILE ((typ.form = pointer) OR (typ.form = comp)) & (typ.BaseTyp # NIL) & ~In(typ.BaseTyp) DO
			IF (typ.form = pointer)&(n < LEN(t0)) THEN t0[n] := typ; INC(n); END;
			typ := typ.BaseTyp
		END;
		RETURN (DevCPT.glbMods[typ.mno].name^ = "Kernel") & (typ.strobj.name^ = "Hook^")
	END IsHook;
luowy
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#167 endless loop in DevBrowser for cyclic pointer

Post by Josef Templ »

I agree. For a perfect solution there would be the need for a BaseTyp 'history' of arbitrary size.
In your solution it is an array of a fixed size (128). So there is still a limit on the depth.
Introducing a dynamic list would make it free of a hard-coded limit but it would increase the complexity even more.
As it turns out the counter solution is much simpler and the introduced limit is irrelevant in practice.

I think we can stay with the current solution and proceed with the voting.

- Josef
Zinn
Posts: 476
Joined: Tue Mar 25, 2014 5:56 pm
Location: Frankfurt am Main
Contact:

Re: issue-#167 endless loop in DevBrowser for cyclic pointer

Post by Zinn »

There exist another change for DevBrowser from 20170308, TemirgaleevEE, B25 Documents.Document:
Adding two times the line
IF v IS Documents.Document THEN v := v(Documents.Document).ThisView() END;

Code: Select all

	PROCEDURE ImportSymFile* (f: Files.File; OUT s: Stores.Store);
		VAR v: Views.View; title: Views.Title; noerr: BOOLEAN;
	BEGIN
		ASSERT(f # NIL, 20);
		DevCPM.file := f;
		OpenCompiler("@file", noerr);
		IF noerr THEN
			Browse("", "", v, title);
			IF v IS Documents.Document THEN v := v(Documents.Document).ThisView() END;
			s := v
		END;
		CloseCompiler;
		DevCPM.file := NIL;
		Kernel.Cleanup
	END ImportSymFile;

Code: Select all

	PROCEDURE ImportCodeFile* (f: Files.File; OUT s: Stores.Store);
		VAR v: Views.View; title: Views.Title;
	BEGIN
		ASSERT(f # NIL, 20);
		Decode(f, v, title);
		IF v IS Documents.Document THEN v := v(Documents.Document).ThisView() END;
		s := v
	END ImportCodeFile;
I don't know under which condition this change are necessary.
Sorry, I'm late. Since yesterday the download work again.
- Helmut
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#167 endless loop in DevBrowser for cyclic pointer

Post by Josef Templ »

Helmut, is it possible to contact TemirgaleevEE directly?

In any case, it does not seem to be related to this issue.

- Josef
Post Reply