• Welcome to Theos PowerBasic Museum 2017.

zXref (version 1.10)

Started by Patrice Terrier, August 14, 2009, 08:25:54 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Patrice Terrier

The purpose of zXref is not to produce a small include file, but the smallest resulting exe.

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Paul Breen

Maybe this does not happen often but If I use a file like main.bas that has the "compile" statement in an include file, zXref refuses to scan the file.
Example, my main.bas has:
#include "directives.inc"

directives.inc
has this:
#COMPILE EXE '"C:\TSE\ff.exe"
#DIM ALL
'etc
Sometimes I use a main.bas that has only comments and includes.
thanks,
Paul Breen

Patrice Terrier

#92
See James comment.
QuoteI believe the xRef comes with the source code so people can tweak it to meet their needs.

Read also the first post of this thread, to learn the purpose of zXref and how to use it.

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Rick Glover

Has anyone considered extending this tool to look for common programming logic issues?  Aivosto.com has produced this for some languages and was big with VB9.  Other IDEs have these features built in and some just won't let you compile with bad logic problems.  One such issue that I find when debugging someone else's code is that they re-use a loop iterator within the loop for another loop (sample below).  Since this tool is already tokenizing the variables it would be the next logical step to fit something like this in.


#COMPILE EXE
#DIM ALL

FUNCTION PBMAIN () AS LONG

    DIM i AS LONG
    FOR i = 1 TO 50
       DIM j AS LONG
       FOR j = 1 TO 10
          FOR i = 1 TO 5
             INCR j
          NEXT i
       NEXT j
    NEXT i

END FUNCTION


Rick

Nathan Maddox

This produces a false positive and an unnecessary report in zXref.

1)It lists MyFunction1() As Un-Used (there are no unused) and
2)all four functions as Existing but not declared... (only 1 exists and
   the declared report goes away with PB Win 9.0)


#COMPILE EXE
#DIM ALL

%DoNotIncludeF1=1
%DoNotIncludeF2=1
%DoNotIncludeF3=1

#INCLUDE "MyInclude.Inc"

FUNCTION PBMAIN () AS LONG

LOCAL A$

? "Hello World"

A$=MyFunction4("Whatever")

END FUNCTION



'MyInclude.Inc

#IF NOT %DEF(%DoNotIncludeF1)
    FUNCTION MyFunction1(BYVAL A$) AS STRING
        ? A$
        FUNCTION = A$
    END FUNCTION
#ENDIF

#IF NOT %DEF(%DoNotIncludeF2)
    FUNCTION MyFunction3(BYVAL A$) AS STRING
        ? A$
        FUNCTION=A$
    END FUNCTION
#ENDIF

#IF NOT %DEF(%DoNotIncludeF3)
    FUNCTION MyFunction3(BYVAL A$) AS STRING
        ? A$
        FUNCTION = A$
    END FUNCTION
#ENDIF

#IF NOT %DEF(%DoNotIncludeF4)
    FUNCTION MyFunction4(BYVAL A$) AS STRING
        ? A$
        FUNCTION=A$
    END FUNCTION
#ENDIF         

Theo Gottwald

Interesting developement. We should continue to work on it.
Besides that, the sollution HOW PB and the COmponents look for "Include Files" is not yet perfect.
In the best case, ´the compiler and all Utilities would use the same pathes and the same Order to find include files.
No Need for config files.

If the compiler doesn't need them, why should another tool?

Patrice Terrier

The first post of this thread has been updated, to fix the ZIP file corruption caused by the "Server Collapse".

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Larry Charlton

It appears that this will read header files multiple times even if they have the Once directive.  Not a huge deal, but some of my projects are taking over a minute due to scanning the winapi headers multiple times.

Paul Elliott

Do PB's compilers search anywhere other than the specified directory on the #Include ( whether a
direcotry is relative to the current source directory is coded ) or the current source directory or
the directories specified in the PB IDE options?

Can anyone explain to me why an INC file should be included multiple times? Unless it is to include
parts of the code based on having other INC files defining equates at different times ( which doesn't
seem right if it is one of the PB or Jose supplied INC files ).

Seeing as zXref keeps track of which INC files it has read, it should be easy to force them to all be
Include Once.

Will we see a version to handle the newer code ( such as Macros with parameters or Class
coding ) ? I'm seeing an odd occurence on DIM x(100, 2) as string  with it showing 100 as the
variable and ignoring the x().




Paul Elliott

I see at least part of the problem of files included multiple times.

gsIncludes() only has the main file name ( sometime multiple entries ).
gsFiles() has the whole path & file name.

The DoGetIncFiles is only searching for the INC file name ( no path ) in gsIncludes().

There may be other places that it gets searched but this routine seems the right place to weed
out duplicates.


Paul Elliott

#100
something along the lines of


'                // Patrice resolve missing include path
                 IF zExist(sWork) = 0 THEN sWork = zFindFile(sWork)
                 IF zExist(sWork) THEN                       'safety check - if we can find what we got..
         ' I added the following
                    ARRAY SCAN tmpFiles(), COLLATE UCASE, = sWork, TO xx
                    IF xx = 0 THEN
                       ARRAY SCAN gsFiles(), COLLATE UCASE, = sWork, TO xx
                       IF xx = 0 THEN
         '  checks to see if file already in tables               
                          tmpFiles(fc) = sWork                               'store path + name in temporary array
                          fc += 1: REDIM PRESERVE tmpFiles(fc)     'incr counter and redim temporary array
         ' and the 2 End Ifs
                       END IF
                    END IF
                 END IF   


should work. Had to add another variable  ( Local xx as Long ) to keep from changing something
I shouldn't.

This checks to see if the file is already in the tmpFiles() or in gsFiles() in DoGetIncFiles().

Patrice will probably have a better method.


Larry Charlton

That worked really well.  Scan time dropped from 95 seconds to 29 seconds.

Turns out there's another option also, in zXRef.cfg all the exclude files are commented out.  I updated it to point to the PBWin10 includes and built an updated list of all the include files and dropped them in uncommented.  Skips right over them and reduces scan time to 1.7 seconds.  8)


Paul Elliott

#102
Larry,

It also works if you point it to .\ so that it only looks at the current directory. Then you can work on
programs dealing with either PB's or Jose's INC files and different versions of them without any
change to the cfg file.
Another choice would be to point it to the directory where you have your INC files ( in case they are
not specified on the #Include lines ).



Paul Elliott

Patrice,

Have not heard your opinion yet.

I was confused about which array had what file name at first. Then I ran a few files and dumped
out what was in them. I think I got it right.

Is what I wrote in reply #101 correct? Or did I miss something? 


Theo Gottwald

QuoteCan anyone explain to me why an INC file should be included multiple times?

Paul, the WinAPI not, I guess.

BUT, an Included file is technically same like MACRO.
You see that, if you intermix MACROS and Include files, they even share the same "NESTING DEPT".

The reason for including a file twice is the same, why you should use a MACRO twice.
Include files are not solely for using WinAPI, or reading definitions,
but you can also use them to include your personal code-stuff "as often as you want" without always typing it again.