Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

Compile Statement Summary

Compile is a nonterminal, command statement that occurs only in command scripts. It compiles a specified source code project or ASP file. Within the translation process, the first significant step beyond simply loading a source code is converting that source code into an intermediate representation that can be analysed, refactored, and authored. The intermediate representation itself contains two subcomponents -- a symbol table that describes the components being manipulated and intermediate gmIL code that describes the actual operations being performed.

Both VB6 projects and ASP sites can be compiled. The Project attribute compiles VB6 projects and the PageSlice attribute compiles ASP pages.

The attributes of the Compile statement are as follows:

Attribute Description
Echo This attribute has one of the values Pass1, Pass2, or All. It is used to override the echoing of source code input as specified via the Select statement for the current compilation only.
Level This attribute has one of the values Project, Load, Pass1, Pass2, and All. This attribute requests that the compile phase end after completing the indicated step. The default is All. The other values are only used for debugging purposes.
PageSlice This attribute requests that the specified page file within an ASP site be compiled, treating it in the same manner as it would be treated by the server when it gets a request for a page. It builds a source representation starting with any ASA file and its includes and then loads the page inserting any other includes as it sees them. The result of this step is a single source representation that can be compiled.
Project This attribute requests that the indicated project file, vbp, along with all references it makes and any code files that it loads be compiled.
ResX The gmStudio has the capability needed to author into a separate file the resX information for controls that do not use the standard resX conventions to store their property values. This attribute specifies the name of this separate file. The compiler searches this file first for property values before it searches the project supplied resX files. At present this feature is used only to use ImageStream Resx data generated from MSComCtl.ImageLists that are being replaced by WinForms.ImageList.

The substatements of the Compile statement are as follows:

Substatement Description
Exename This substatement changes the Exename32 associated with the project,
Fix Using the Fix command statement as a substatement of the compile restricts the range of application of the fixes to code files within the project or pageslice.
Refactor Using the Refactor refactoring statement as a substatement of the compile restricts the range of application of any refactoring to the symbols defined within the project or pageslice.
Reference Using the Reference command statement as a substatement of the compile restricts references to its components to the current project or pageslice.
Select Using the Select command statement as a substatement of the compile is no different that using it outside of the compile. It is included as a substatement for convenience only.

The script errors associated with the Compile statement are as follows:

Error Description
1109 Encountered illegal COMPILE directive %1d
1110 Encountered illegal COMPILE directive %1d
1157 Unable to open project file [%1d]
1158 Unable to add project [%1d] to data storage area.

Before any code can be processed the environment within which that compilation is to occur must be established. For a given command script, the loading of this information occurs only once. The compiler checks if this load has occurred before it executes a Compile or Reference statement. In addition, the script can force the load to occur using LoadEnvironment statement. See the description of that statement for a details.

The compilation of VB6 project files consists of 4 distinct steps: first, the project file itself is loaded; second, all class, module, and form/usercontrol files are loaded; third, the individual source files are parsed and the symbols defined are organized into a symbol table; and fourth, the statements within the individual source files are converted into an intermediate representation.

Loading the project files begins by first storing the name of the project file in the symbol table and making certain that it is unique. Second, the project file itself is loaded into an edit buffer. Third, the GlobalSettings file is checked to see if any edit fixes are to be applied to the project file. Fourth, the file is searched for the its Name and Exename32 entries whose values are then stored in the symbol table.

Loading the individual source files involves searching the project file for Form, UserDocument, UserControl, Module, and Class entries whose values are the source code filenames to be loaded. Each file is then loaded into an edit buffer and its name is stored in the symbol table. For each file the GlobalSettings file is checked to see if any edit fixes are to be applied to it. In addition, the EditAspSource event is triggered, which could make additional changes to the file. Once all files have been loaded and individually edited, the subcommands associated with the statement are executed, up to any Refactor statements.

The initial parsing of the source files to organize the symbols defined into the symbol table is referred to as Pass1 of the compiler. If source code errors are encountered during this pass, then further processing within the compiler is blocked. If there were no problems, the final step is to tabulate all of the global symbols found so that they can be quickly identified by the next pass of the compiler.

The converting of the actual statements in the source files into intermediate gmIL code is referred to as Pass2 of the compiler. The first step is to process any Refactor substatements that remain. The quality of translations can often be greatly improved if symbols are strongly typed before the compiler processes the statements that reference them. Next if any Resource files are specified via the ResX attribute, they are loaded. Finally, the actual compilation into intermediate code is performed. There may well be syntax errors and warnings generated by this compilation; however, unlike pass1 errors these do not block further processing. Error causing source code statements are simply entered into the target translations as though they had been commented out in the source.

Exename Compile Substatement Summary

Exename is a terminal substatement of the Compile statement. It changes the value of the Exename32 attribute in the project file before the first compiler pass has begun. If used, this substatement must precede any Refactor subcommands within the same specification. Note that an existing Exename32 is replaced by the new name; therefore, if there is no existing name, this substatement does nothing.

The attributes of the Exename substatement are as follows:

Attribute Description
id This attribute specifies the new Exename32 to be assigned to the project.


How do I get the name of an FrxData resource?

The FrxData resources are associated with control properties. For example the actual picture associated with a PictureBox is in a property called Picture. Information about controls is stored in their property control vectors. Here is what the Picture property entry looks like.

Code Block
languagenone
themeEclipse
linenumberstrue


60 |      1.60 |      1.60 | PictureBox           | LDA    | PictureBox:BPlate:965712
65 |      1.60 |      2.65 | String               | LPI    | resource: 2921134
70 |      2.70 |      3.70 | FrxPicture           | PBX    | Picture
The LPI operator points to a "Linked String". This string contains the original name of the resource as it was entered in the VB6 source file. For example

Code Block
languagenone
themeEclipse
linenumberstrue


"Glb_lbox.frx":0000
"Vendgrp.frx":0000
"Vendgrp.frx":0000
It is the name of the resource file and the starting offset of the resource. In addition to the original name there is also a link to the ResXInfo vector. Returning to the code dump above the entry resource: 2921134 points to the ResXinfo information vector for the resource

Code Block
languagenone
themeEclipse
linenumberstrue


3 |  2921134 |    76831 | ResXinfo                       | SampleCode.AnglesAndPlates.FrxData1575B
The actual information associated with that link is as follows

Code Block
languagenone
themeEclipse
linenumberstrue


Detailed Description of ResXinfo SampleCode.AnglesAndPlates.FrxData1575B with root address 2921134:
Property                       | Content
--------                       | -------
Header Type                    | ItemInfo
Header Size                    | 12
Info Size                      | 20790
Info Type                      | Bitmap Image
Info Address                   | 2915929
Property Name                  | Picture
Property Type                  | FrxPicture
Base64 representation of 20790 Bytes of Information:
Qk02UQAAAAAAADYAAAAoAAAAYAAAAEgAAAABABgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////
   ...
The name of this resource is derived from the original source name by gmBasic. This is probably the name referred to in the question. Finally we have the name as it appears by default in the translation, such as below

Code Block
languagecpp
themeEclipse
linenumberstrue


this.BPlate.ForeColor = System.Drawing.SystemColors.ControlText;
this.BPlate.Image = (System.Drawing.Image)resources.GetObject("FrxData1575B.Picture");
this.BPlate.Cursor = System.Windows.Forms.Cursors.Default;
This name is constructed by gmBasic and triggered by surface patterns containing the pattern code \R.

Code Block
languagexml
themeEclipse
linenumberstrue


<pattern id="LPI">
    <vbn narg="1" code="CType(resources.GetObject(\s\R\s),System.Drawing.Image)"/>
    <csh narg="1" code="(System.Drawing.Image)resources.GetObject(\s\R\s)"/>
</pattern>
<pattern id="LTX">
    <vbn narg="1" code="resources.GetString(\s\R\s)"/>
    <csh narg="1" code="resources.GetString(\s\R\s)"/>
</pattern>
<pattern id="ICN">
    <vbn narg="1" code="CType(resources.GetObject(\s\R\s),System.Drawing.Icon)"/>
    <csh narg="1" code="(System.Drawing.Icon)resources.GetObject(\s\R\s)"/>
</pattern>
which are authored when the control properties are authored. There is no direct gmSL way of getting at these default names; however, the FrxDataName can be obtained using the ControlData service class. For example when used with the control data for the PictureBox in the translation from above

Code Block
languagecpp
themeEclipse
linenumberstrue


iProp = ControlData.FindProperty(ctlType,"Picture",iCode);
if(iProp > 0)
{
   sValue = ControlData.GetProperty(iProp);
   System.LogMessage("sValue = " + sValue);
}
The desired name is displayed as "sValue = FrxData1575B".

Panel
bgColorCCFFFF
titleTable of Contents

Table of Contents