Skip to content

Commit

Permalink
Remove a compiler restriction for code procedure size.
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg-N-Cher committed May 11, 2012
1 parent 5ae36c5 commit da6f2e0
Show file tree
Hide file tree
Showing 16 changed files with 54 additions and 32 deletions.
Binary file modified Dev/Code/Analyzer.ocf
Binary file not shown.
Binary file modified Dev/Code/Browser.ocf
Binary file not shown.
Binary file modified Dev/Code/CPC486.ocf
Binary file not shown.
Binary file modified Dev/Code/CPP.ocf
Binary file not shown.
Binary file modified Dev/Code/CPT.ocf
Binary file not shown.
Binary file modified Dev/Mod/Analyzer.odc
Binary file not shown.
22 changes: 14 additions & 8 deletions Dev/Mod/Analyzer.txt
Expand Up @@ -1329,23 +1329,29 @@ MODULE DevAnalyzer;
pos: INTEGER; (*<< *)

PROCEDURE GetCode;
VAR ext: CPT.ConstExt; i, n, c: INTEGER; s: ARRAY 256 OF SHORTCHAR;
VAR ext: CPT.ConstExt; i, n, c: INTEGER; s, s2: POINTER TO ARRAY OF SHORTCHAR;
BEGIN
n := 0;
n := 0; NEW(s, 256);
LOOP
IF sym = number THEN c := CPS.intval; INC(n);
IF (c < 0) OR (c > 255) OR (n = 255) THEN
IF sym = number THEN c := CPS.intval; INC(n); i := LEN(s^);
IF n > i THEN (* if overflow then increase size of array s *)
NEW(s2, i * 2); WHILE i > 0 DO DEC(i); s2^[i] := s^[i] END; s := s2; s2 := NIL;
END;
IF (c < 0) OR (c > 255) OR (n = MAX(INTEGER)) THEN
err(64); c := 1; n := 1
END ;
CPS.Get(sym); s[n] := SHORT(CHR(c))
CPS.Get(sym); s[n - 1] := SHORT(CHR(c))
END ;
IF sym = comma THEN CPS.Get(sym)
ELSIF sym = number THEN err(comma)
ELSE s[0] := SHORT(CHR(n)); EXIT
ELSE EXIT
END
END;
NEW(ext, n + 1); proc.conval.ext := ext; i := 0;
WHILE i <= n DO ext[i] := s[i]; INC(i) END;
IF n # 0 THEN NEW(ext, n); i := 0;
WHILE i < n DO ext[i] := s[i]; INC(i) END
ELSE ext := NIL
END;
proc.conval.ext := ext;
INCL(proc.conval.setval, hasBody)
END GetCode;

Expand Down
Binary file modified Dev/Mod/Browser.odc
Binary file not shown.
14 changes: 8 additions & 6 deletions Dev/Mod/Browser.txt
Expand Up @@ -861,7 +861,7 @@ MODULE DevBrowser;
END Var;

PROCEDURE Proc (obj: DevCPT.Object);
VAR ext: DevCPT.ConstExt; i, m: SHORTINT;
VAR ext: DevCPT.ConstExt; i, m: INTEGER;
BEGIN
IF global.hideHooks & (obj.link # NIL) & (obj.link.link = NIL) & IsHook(obj.link.typ) THEN RETURN END;
IF global.extensioninterface THEN RETURN END;
Expand All @@ -877,11 +877,13 @@ MODULE DevBrowser;
IF (obj.mode = cProc) & global.hints THEN
Ln;
INC(global.level); Indent;
ext := obj.conval.ext; m := ORD(ext^[0]); i := 1;
WHILE i <= m DO
global.out.WriteIntForm(ORD(ext^[i]), TextMappers.hexadecimal, 3, "0", TextMappers.showBase);
IF i < m THEN String(", ") END;
INC(i)
ext := obj.conval.ext;
IF ext # NIL THEN m := LEN(ext^); i := 0;
WHILE i < m DO
global.out.WriteIntForm(ORD(ext^[i]), TextMappers.hexadecimal, 3, "0", TextMappers.showBase);
INC(i);
IF i < m THEN String(", ") END
END
END;
DEC(global.level)
END;
Expand Down
Binary file modified Dev/Mod/CPC486.odc
Binary file not shown.
6 changes: 4 additions & 2 deletions Dev/Mod/CPC486.txt
Expand Up @@ -1854,8 +1854,10 @@ lx := LONG(SHORT(ly)) y b+ y w* x w *
Result(x.obj.link, tag) (* use result load for first parameter *)
END
END;
i := 1; n := ORD(x.obj.conval.ext^[0]);
WHILE i <= n DO DevCPL486.GenCode(ORD(x.obj.conval.ext^[i])); INC(i) END
IF x.obj.conval.ext # NIL THEN
i := 0; n := LEN(x.obj.conval.ext^);
WHILE i < n DO DevCPL486.GenCode(ORD(x.obj.conval.ext^[i])); INC(i) END
END
ELSE (* proc var *)
DevCPL486.GenCall(x); Free(x);
IF x.typ.sysflag = ccall THEN (* remove parameters *)
Expand Down
Binary file modified Dev/Mod/CPP.odc
Binary file not shown.
20 changes: 13 additions & 7 deletions Dev/Mod/CPP.txt
Expand Up @@ -1071,28 +1071,34 @@ MODULE DevCPP;
sys: SHORTINT;

PROCEDURE GetCode;
VAR ext: DevCPT.ConstExt; i, n, c: INTEGER; s: ARRAY 256 OF SHORTCHAR;
VAR ext: DevCPT.ConstExt; i, n, c: INTEGER; s, s2: POINTER TO ARRAY OF SHORTCHAR;
BEGIN
n := 0;
IF sym = string THEN
NEW(ext, DevCPS.intval);
WHILE DevCPS.str[n] # 0X DO ext[n+1] := DevCPS.str[n]; INC(n) END ;
ext^[0] := SHORT(CHR(n)); DevCPS.Get(sym);
ELSE
NEW(s, 256);
LOOP
IF sym = number THEN c := DevCPS.intval; INC(n);
IF (c < 0) OR (c > 255) OR (n = 255) THEN
IF sym = number THEN c := DevCPS.intval; INC(n); i := LEN(s^);
IF n > i THEN (* if overflow then increase size of array s *)
NEW(s2, i * 2); WHILE i > 0 DO DEC(i); s2^[i] := s^[i] END; s := s2; s2 := NIL;
END;
IF (c < 0) OR (c > 255) OR (n = MAX(INTEGER)) THEN
err(64); c := 1; n := 1
END ;
DevCPS.Get(sym); s[n] := SHORT(CHR(c))
DevCPS.Get(sym); s[n - 1] := SHORT(CHR(c))
END ;
IF sym = comma THEN DevCPS.Get(sym)
ELSIF sym = number THEN err(comma)
ELSE s[0] := SHORT(CHR(n)); EXIT
ELSE EXIT
END
END;
NEW(ext, n + 1); i := 0;
WHILE i <= n DO ext[i] := s[i]; INC(i) END;
IF n # 0 THEN NEW(ext, n); i := 0;
WHILE i < n DO ext[i] := s[i]; INC(i) END
ELSE ext := NIL
END
END;
proc.conval.ext := ext;
INCL(proc.conval.setval, hasBody)
Expand Down
Binary file modified Dev/Mod/CPT.odc
Binary file not shown.
24 changes: 15 additions & 9 deletions Dev/Mod/CPT.txt
Expand Up @@ -645,7 +645,7 @@ MODULE DevCPT;
END FPrintStr;

PROCEDURE FPrintObj*(obj: Object);
VAR fprint: INTEGER; f, m: SHORTINT; rval: SHORTREAL; ext: ConstExt; mod: Object; r: REAL; x: INTEGER;
VAR fprint, m: INTEGER; f: SHORTINT; rval: SHORTREAL; ext: ConstExt; mod: Object; r: REAL; x: INTEGER;
BEGIN
IF ~obj.fpdone THEN
fprint := 0; obj.fpdone := TRUE;
Expand Down Expand Up @@ -678,8 +678,10 @@ MODULE DevCPT;
FPrintSign(fprint, obj.typ, obj.link)
ELSIF obj.mode = CProc THEN
FPrintSign(fprint, obj.typ, obj.link); ext := obj.conval.ext;
m := ORD(ext^[0]); f := 1; DevCPM.FPrint(fprint, m);
WHILE f <= m DO DevCPM.FPrint(fprint, ORD(ext^[f])); INC(f) END
IF ext # NIL THEN m := LEN(ext^); x := 0; DevCPM.FPrint(fprint, m);
WHILE x < m DO DevCPM.FPrint(fprint, ORD(ext^[x])); INC(x) END
ELSE DevCPM.FPrint(fprint, 0);
END
ELSIF obj.mode = Typ THEN
FPrintStr(obj.typ); DevCPM.FPrint(fprint, obj.typ.pbfp)
END ;
Expand Down Expand Up @@ -1084,9 +1086,11 @@ MODULE DevCPT;
| Sipro: obj.mode := IProc
| Scpro: obj.mode := CProc;
s := DevCPM.SymRInt();
NEW(ext, s + 1); obj.conval.ext := ext;
ext^[0] := SHORT(CHR(s)); i := 1;
WHILE i <= s DO DevCPM.SymRCh(ext^[i]); INC(i) END
IF s # 0 THEN NEW(ext, s); i := 0;
WHILE i < s DO DevCPM.SymRCh(ext^[i]); INC(i) END
ELSE ext := NIL
END;
obj.conval.ext := ext;
END
ELSIF tag = Salias THEN
obj.mode := Typ; InStruct(obj.typ)
Expand Down Expand Up @@ -1438,7 +1442,7 @@ MODULE DevCPT;
END OutConstant;

PROCEDURE OutObj(obj: Object);
VAR i, j: SHORTINT; ext: ConstExt;
VAR i, j: INTEGER; ext: ConstExt;
BEGIN
IF obj # NIL THEN
OutObj(obj.left);
Expand Down Expand Up @@ -1483,8 +1487,10 @@ MODULE DevCPT;
DevCPM.SymWInt(Sipro); OutSign(obj.typ, obj.link); OutName(obj.name^)
| CProc:
DevCPM.SymWInt(Scpro); OutSign(obj.typ, obj.link); ext := obj.conval.ext;
j := ORD(ext^[0]); i := 1; DevCPM.SymWInt(j);
WHILE i <= j DO DevCPM.SymWCh(ext^[i]); INC(i) END ;
IF ext # NIL THEN j := LEN(ext^); i := 0; DevCPM.SymWInt(j);
WHILE i < j DO DevCPM.SymWCh(ext^[i]); INC(i) END
ELSE DevCPM.SymWInt(0)
END ;
OutName(obj.name^); portable := FALSE
END
END
Expand Down
Binary file added Dev/Test/CodeSizeProc.odc
Binary file not shown.

0 comments on commit da6f2e0

Please sign in to comment.