adimetrius / Herschel

Ground work for Component Pascal 64-bit compiler
BSD 2-Clause "Simplified" License
21 stars 1 forks source link

Can't compile module with exported procedures #7

Closed X547 closed 3 years ago

X547 commented 3 years ago

This is https://github.com/adimetrius/Herschel/commit/dd03698cc9d709cd23479bc737f15c4c77bd2e11.

When attempting to compile following code:

MODULE A;

    PROCEDURE Do*;
    BEGIN HALT(0);
    END Do;

END A.

Assert 126 (not yet implemented) fails in module HrV:

    PROCEDURE VParameters (pars: POINTER TO ARRAY OF T.Par; proc: T.Proc);
    (* firstPar.mnolev = 0 *)
        VAR par: T.Par; t: T.Type; i, len, padr, vadr: INTEGER;
    BEGIN
        padr := ParOff; 
        IF pars = NIL THEN len := 0 ELSE len := LEN(pars) END;
        i := 0; WHILE i < len DO par := pars[i];
            t := par.type; VTypeAlloc(t);
            par.adr := padr;
            IF (par.flags * T.kindMask # T.valK) & ~((T.open IN t.flags) & (t IS T.Array)) THEN
                IF (t IS T.Record) & ~(T.untagged IN t.flags) THEN INC(padr, 16)
                ELSE INC(padr, M.pointerSize)
                END
            ELSE
                IF (par.flags * T.kindMask = T.valK) & (T.open IN t.flags) & (t IS T.Array) & (T.untagged IN t.flags) THEN
                    M.err(-145) 
                END;
                INC(padr, t.size); Align(padr, M.paramAlign)
            END;
            INC(i)
        END;
        IF proc # NIL THEN
            IF T.exported IN proc.flags THEN HALT(126); (* this assert fails *) proc.flags := proc.flags + T.callbackF
            ELSE 
iadenisov commented 3 years ago

Fixed. The development of dynamic loader is on the way!