X-Git-Url: https://deadsoftware.ru/gitweb?p=cpc.git;a=blobdiff_plain;f=src%2Fgeneric%2FDsw%2FMod%2FCompilerCPfrontMain.cp;h=1043752445d50c7e03409a631a72ea42eb61c16e;hp=f8ecb5ce1d04645d9d67c668d82f16d70a9c2e96;hb=d04c6367a927c536552ae595c92cc15347d3a65f;hpb=12e708d8780328a94dab7923c7db7bdf602f127b diff --git a/src/generic/Dsw/Mod/CompilerCPfrontMain.cp b/src/generic/Dsw/Mod/CompilerCPfrontMain.cp index f8ecb5c..1043752 100644 --- a/src/generic/Dsw/Mod/CompilerCPfrontMain.cp +++ b/src/generic/Dsw/Mod/CompilerCPfrontMain.cp @@ -1,7 +1,8 @@ MODULE DswCompilerCPfrontMain; IMPORT Kernel, HostFiles, Files, Console, Strings, DswDocuments, - DevCPM, DevCPT, DevCPB, DevCPP, DevCPE, DevCPH, DevCPV := CPfrontCPV, DevCPG := CPfrontCPG; + DevCPM, DevCPT, DevCPB, DevCPP, DevCPE, DevCPH, DevCPV := CPfrontCPV, DevCPG := CPfrontCPG, + DevCPR; CONST (* compiler options: *) @@ -13,7 +14,7 @@ MODULE DswCompilerCPfrontMain; (* defopt = {checks, assert, obj, ref, allref, srcpos, signatures, ctime}; *) defopt = {checks, assert, obj, ctime}; - version = "0.2"; + version = "0.3"; emulong = 0; defopt2 = {}; @@ -28,8 +29,15 @@ MODULE DswCompilerCPfrontMain; next: Elem END; + Def = POINTER TO RECORD + name: DevCPT.Name; + val: BOOLEAN; + next: Def + END; + VAR u: Elem; + d: Def; PROCEDURE GetPath (IN path: ARRAY OF CHAR; OUT dir, name: Files.Name); VAR i, j, len: INTEGER; @@ -72,6 +80,12 @@ MODULE DswCompilerCPfrontMain; END END Check; + PROCEDURE Define (IN name: DevCPT.Name; val: BOOLEAN); + VAR def: Def; + BEGIN + NEW(def); def.name := name$; def.val := val; def.next := d; d := def + END Define; + BEGIN outsym := ""; outcode := ""; opts := defopt; opts2 := defopt2; found := FALSE; @@ -177,6 +191,10 @@ MODULE DswCompilerCPfrontMain; INCL(opts, ctime) ELSIF p = "-no-use-time" THEN EXCL(opts, ctime) + ELSIF p = "-define+" THEN + Check; Define(Kernel.argv[i]$, TRUE); INC(i) + ELSIF p = "-define-" THEN + Check; Define(Kernel.argv[i]$, FALSE); INC(i) ELSE Console.WriteStr("unknown option "); Console.WriteStr(p); Console.WriteLn; @@ -205,7 +223,7 @@ MODULE DswCompilerCPfrontMain; END InitOptions; PROCEDURE Module (source: POINTER TO ARRAY OF CHAR; m: Elem; OUT error: BOOLEAN); - VAR ext, new: BOOLEAN; p: DevCPT.Node; + VAR ext, new: BOOLEAN; p: DevCPT.Node; def: Def; BEGIN DevCPG.opt := {}; (* !!! *) DevCPM.Init(source); @@ -226,7 +244,14 @@ MODULE DswCompilerCPfrontMain; (* DevCPB.typSize := DevCPV.TypeSize; *) DevCPB.typSize := DevCPV.TypSize; DevCPT.processor := DevCPV.processor; + DevCPR.Init; + def := d; + WHILE def # NIL DO + DevCPR.Set(def.name, def.val); + def := def.next + END; DevCPP.Module(p); + DevCPR.Check; IF DevCPM.noerr THEN IF DevCPT.libName # "" THEN EXCL(m.opts, obj) END; DevCPV.Init(m.opts); DevCPV.AdrAndSize(DevCPT.topScope); DevCPT.Export(ext, new); @@ -252,6 +277,7 @@ MODULE DswCompilerCPfrontMain; IF obj IN m.opts THEN DevCPG.CloseFiles END; + DevCPR.Close; DevCPT.Close; error := ~DevCPM.noerr; IF error THEN @@ -273,44 +299,28 @@ MODULE DswCompilerCPfrontMain; PROCEDURE ReadText (s: Elem): POINTER TO ARRAY OF CHAR; VAR - i, len, res: INTEGER; - text: DswDocuments.Text; - loc: Files.Locator; f: Files.File; r: Files.Reader; - ssrc: POINTER TO ARRAY OF SHORTCHAR; + i, res: INTEGER; + m: DswDocuments.Model; + r: DswDocuments.Reader; + loc: Files.Locator; src: POINTER TO ARRAY OF CHAR; - x: POINTER TO ARRAY OF BYTE; num: ARRAY 32 OF CHAR; BEGIN - src := NIL; loc := Files.dir.This(s.dir); - DswDocuments.Import(loc, s.name, text, res); - Strings.IntToString(res, num); - IF res = 0 THEN - src := text.t - ELSIF res = 2 THEN - f := Files.dir.Old(loc, s.name, Files.shared); - IF f # NIL THEN - len := f.Length(); - r := f.NewReader(NIL); - NEW(x, len + 1); - r.ReadBytes(x, 0, len); - NEW(ssrc, len + 1); - FOR i := 0 TO len - 1 DO - ssrc[i] := SHORT(CHR(x[i])) - END; - ssrc[i] := 0X; - x := NIL; - NEW(src, len + 1); - Kernel.Utf8ToString(ssrc, src, res); - ssrc := NIL; - f.Close - END - ELSE - IF DevCPM.verbose > 0 THEN - Console.WriteStr("document error "); - Console.WriteStr(num); - Console.WriteLn + DswDocuments.Open(loc, s.name, m, res); + IF m # NIL THEN + r := m.NewReader(NIL); + NEW(src, m.Length() + 1); + IF src # NIL THEN + FOR i := 0 TO m.Length() - 1 DO + r.Read; src[i] := r.char + END END + ELSIF DevCPM.verbose > 0 THEN + Strings.IntToString(res, num); + Console.WriteStr("document error "); + Console.WriteStr(num); + Console.WriteLn END; IF src = NIL THEN Console.WriteStr("unable to open file ");