gmSLIntroduction
- Mark Juras
Owned by Mark Juras
Introduction to gmSL
The name gmSL stands for Great Migrations Scripting language. It is a high-level programming language that is compiled and executed by gmBasic rather than compiled by the computer's processor as other programming languages (such as C and C#) are. Code written in gmSL can be embedded within gmPL scripts or can be in stand alone source files with the extension gmSL. The gmSL language fully supports gmPL equivalents of the main line gmPL statements and can be used as a substitute for gmPL in most cases. gmSL is a procedural language and does not reproduce the gmPL declaration statements. Finally, gmSL scripts can be converted into gmNI dynamic link libraries that are executed by the tool when certain events occur. The goal of gmSL is to enhance gmPL not to replace it.<gmBasic> <Storage Action="Create" Identifier="HashTable1" /> <Select Dialect="csh" /> <Select AuthorLibrary="on" /> <Select BuildFile="on" /> <Select DeployLocation="\temp" /> <Compile Project="..\vb6\HashTable.vbp" /> <Analyse /> <Output Status="New" Filename="..\csh\HashTable1.bnd" /> <Author /> <Storage Action="Close" /> </gmBasic>
Embedding gmSL Expressions in gmPL Statements
The notation (%= ... %) is used to embed gmSL expressions in gmPL statements. Consider that except for the name of the code this script is a generic translation script that could be used in other simple contexts like this one. There is a Select attribute SrcPath that can be used to contain user supplied strings. Within gmSL expressions the values of the Select attributes can be referenced via the fully specified identifier "Select.attributeName" or simply "attributeName". The following script "HashTable2.xml"<gmBasic> <Storage Action="Create" Identifier="(%= Select.SrcPath %)2" /> <Select Dialect="csh" /> <Select AuthorLibrary="on" /> <Select BuildFile="on" /> <Select DeployLocation="\temp" /> <Compile Project="..\vb6\(%= SrcPath %).vbp" /> <Analyse /> <Output Status="New" Filename="..\csh\(%= SrcPath %)2.bnd" /> <Author /> <Storage Action="Close" /> </gmBasic>
pBasic HashTable2 SrcPath=HashTable
Embedding gmSL Statements in gmPL Scripts
It is often convenient to be able to perform simple operations during the execution of a gmPL script that are not directly supported by gmPL. An easy way to do this is to embed gmSL statements in the script. The desired statements are enclosed within <gmSL> and </gmSL> tags or bounded by them. The statements themselves can be either be a simgle statement or multiple if the bounded form is used. They are executed immediately after the closing </gmSL> tag is encountered. The following script "HashTable3.xml"<gmBasic> <gmSL>System.LogMessage("Starting Translation of HashTable.vbp")</gmSL> <Storage Action="Create" Identifier="HashTable3" /> <Select Dialect="csh" /> <Select AuthorLibrary="on" /> <Select BuildFile="on" /> <Select DeployLocation="\temp" /> <gmSL> System.LogMessage("Starting Compilation of HashTable.vbp") if(Select.Progress > 1) System.LogMessage "Compilation consists of two passes through the source code" </gmSL> <Compile Project="..\vb6\HashTable.vbp" /> <gmSL>System.LogMessage("Starting Analysis of HashTable.vbp")</gmSL> <Analyse /> <Output Status="New" Filename="..\csh\HashTable3.bnd" /> <Author /> <Storage Action="Close" /> <gmSL>System.LogMessage("Completed Translation of HashTable.vbp")</gmSL> </gmBasic>
pBasic HashTable3.xml Progress=1
Starting Translation of HashTable.vbp Starting Compilation of HashTable.vbp Loading reference:[Language.std] \gmIDF\Language.std.xml Reprocessing file: Transform.cls Reprocessing file: Transform.cls Processing file: ..\vb6\HashTable.vbp Loading reference:[StdOle2.tlb] \gmIDF\StdOle2.tlb.xml Reprocessing file: ..\vb6\HashTable.cls Reprocessing file: ..\vb6\HashTable.cls Starting Analysis of HashTable.vbp Loading reference:[MigrationSupport.dll] \gmIDF\MigrationSupport.dll.xml Completed Translation of HashTable.vbp
pBasic HashTable3.xml progress=2
Starting Translation of HashTable.vbp Starting Compilation of HashTable.vbp Compilation consists of two passes through the source code Loading reference:[Language.std] \gmIDF\Language.std.xml Reprocessing file: Transform.cls Reprocessing file: Transform.cls Processing file: ..\vb6\HashTable.vbp Loading reference:[StdOle2.tlb] \gmIDF\StdOle2.tlb.xml Reprocessing file: ..\vb6\HashTable.cls Reprocessing file: ..\vb6\HashTable.cls Starting Analysis of HashTable.vbp Loading reference:[MigrationSupport.dll] \gmIDF\MigrationSupport.dll.xml Completed Translation of HashTable.vbp
Embedding gmSL Methods in gmPL Scripts
In addition to being able to introduce simple gmSL statements into a gmPL script, it is also possible introduce methods that perform operations during the execution of the script that are not directly supported by gmPL. The method can then be executed later by the gmPL RunComand statement. In the HashTable example being used in this discussion, everything goes well and the target code builds with no problems, but in examining that codeint m_PrimaryIndex = 0; private int m_SecondaryIndex = 0; // This variable is used to make the GetNextItem faster object m_GetNextValue = null; HashTableTyp m_HT = new HashTableTyp(); public bool FindKey(string i_Key)
Dim m_PrimaryIndex As Integer Private m_SecondaryIndex As Integer ' This variable is used to make the GetNextItem faster Dim m_GetNextValue As Object Dim m_HT As HashTableTyp
<gmBasic> <Storage Action="Create" Identifier="HashTable4" /> <Select Dialect="csh" /> <Select AuthorLibrary="on" /> <Select BuildFile="on" /> <Select DeployLocation="\temp" /> <gmSL Class="Demo" > void MakePrivate(string identifier) { int iRoot; tVariable varInfo; iRoot = Symbol.FindIdentifier(identifier); if(iRoot) { varInfo = Store.DeltaVector(iRoot); varInfo.Private = True; System.LogMessage("Changed status of " + Symbol.FullName(iRoot,1) + " to Private") ; } else System.LogMessage("Could not locate " + identifier); } </gmSL> <Compile Project="..\vb6\HashTable.vbp" /> <RunCommand id="MakePrivate" Prams="HashTableProject.HashTable.m_PrimaryIndex" /> <RunCommand id="MakePrivate" Prams="HashTableProject.HashTable.m_GetNextValue" /> <RunCommand id="MakePrivate" Prams="HashTableProject.HashTable.HelpFile" /> <RunCommand id="MakePrivate" Prams="HashTableProject.HashTable.m_HT" /> <Analyse /> <Output Status="New" Filename="..\csh\HashTable4.bnd" /> <Author /> <Storage Action="Close" /> </gmBasic>
Setting components to Private Changed status of HashTableProject.HashTable.m_PrimaryIndex to Private Changed status of HashTableProject.HashTable.m_GetNextValue to Private Could not locate HashTableProject.HashTable.HelpFile Changed status of HashTableProject.HashTable.m_HT to Private
***** HashTable4.bnd <class id="HashTable" parent="IDispatch" default="Value"> <method id="FindKey" type="Boolean"> ***** HASHTABLE1.BND <class id="HashTable" parent="IDispatch" default="Value"> <field id="m_PrimaryIndex" type="Integer" status="InOut"/> <field id="m_GetNextValue" type="Object" status="InOut"/> <field id="m_HT" type="HashTableProject.HashTable.HashTableTyp" status="InOut"/> <method id="FindKey" type="Boolean"> ***** HashTable4.bnd } private int m_PrimaryIndex = 0; private int m_SecondaryIndex = 0; ***** HASHTABLE1.BND } int m_PrimaryIndex = 0; private int m_SecondaryIndex = 0; ***** HashTable4.bnd // This variable is used to make the GetNextItem faster private object m_GetNextValue = null; private HashTableTyp m_HT = new HashTableTyp(); public bool FindKey(string i_Key) ***** HASHTABLE1.BND // This variable is used to make the GetNextItem faster object m_GetNextValue = null; HashTableTyp m_HT = new HashTableTyp(); public bool FindKey(string i_Key)
Writing Stand Alone gmSL Methods
Methods written in gmSL do not have to be embedded directly in the gmPL scripts. They can be entered in stand alone files with the extension gmSL which can be loaded into the script. Consider this file "MakePrivate.gmsl"void MakePrivate(string identifier) { int iRoot; tVariable varInfo; iRoot = Symbol.FindIdentifier(identifier); if(iRoot) { varInfo = Store.DeltaVector(iRoot); varInfo.Private = True; System.LogMessage("Changed status of " + Symbol.FullName(iRoot,1) + " to Private") ; } else System.LogMessage("Could not locate " + identifier); }
<gmBasic> <Storage Action="Create" Identifier="HashTable5" /> <Select Dialect="csh" /> <Select AuthorLibrary="on" /> <Select BuildFile="on" /> <Select DeployLocation="\temp" /> <gmSL Class="Demo" source="..\gmsl\MakePrivate.gmsl" /> <Compile Project="..\vb6\HashTable.vbp" /> <RunCommand id="MakePrivate" Prams="HashTableProject.HashTable.m_PrimaryIndex" /> <RunCommand id="MakePrivate" Prams="HashTableProject.HashTable.m_GetNextValue" /> <RunCommand id="MakePrivate" Prams="HashTableProject.HashTable.HelpFile" /> <RunCommand id="MakePrivate" Prams="HashTableProject.HashTable.m_HT" /> <Analyse /> <Output Status="New" Filename="..\csh\HashTable5.bnd" /> <Author /> <Storage Action="Close" /> </gmBasic>
Writing Stand Alone gmSL scripts
Not just methods, but entire stand alone scripts can be written using gmSL. The following file "HashTable.gmsl"Execute.Storage Action := "Create", Identifier := "HashTable" Select.Dialect = Dialects.csh Select.AuthorLibrary = AuthorLibType.On Select.BuildFile = BuildFileStatus.On Select.DeployLocation = "\temp" Execute.Compile Project := "..\vb6\HashTable.vbp" Execute.Analyse Execute.Output Status := "New", Filename := "..\csh\HashTable.bnd" Execute.Author Execute.Storage Action := "Close"
<Method id="Storage" type="void" opcode="SCM.Execute_Storage" > <Argument id="action" type="String" status="ByVal" optional="NULL" /> <Argument id="identifier" type="String" status="ByVal" optional="NULL" /> <Argument id="startup" type="String" status="ByVal" optional="NULL" /> </Method>
pBasic HashTable.gmsl
Saving gmSL Methods in a Virtual Binary Information File
Previous examples have shown various ways in which gmSL source code can be introduced into translation scripts or executed directly. Methods written in gmSL can also be precompiled and stored in a virtual binary information file. In fact many of the operations performed by the tool set are actually implemented via gmSL methods stored in the vb7Lang.vbi language information file.<gmBasic> <Storage Action="Create" Identifier="HashTable6" /> <gmSL namespace="RuntimeDll" class="Methods" > void HashTable6() { Execute.Storage Action := "Create", Identifier := "HashTable" Select.Dialect = Dialects.csh Select.AuthorLibrary = AuthorLibType.On Select.BuildFile = BuildFileStatus.On Select.DeployLocation = "\temp" Execute.Compile Project := "..\vb6\HashTable.vbp" Execute.Analyse Execute.Output Status := "New", Filename := Select.BndPath Execute.Author Execute.Storage Action := "Close" } </gmSL> <Storage Action="Close" /> </gmBasic>
Audit of Symbol tree in HashTable6.vbi storage area: Lev | Address | Parent | Symbol Type | Full Symbol Identifier --- | ------- | ------ | ----------- | ---------------------- 1 | 2119 | 0 | ProjectFile | RuntimeDll.Methods.slp 2 | 3240 | 2119 | ClassFile | Methods.cls 3 | 3423 | 3240 | Subprogram | RuntimeDll.Methods.HashTable6 2 | 3342 | 2119 | Vb_Name | RuntimeDll.Methods 1 | 3382 | 0 | Vb_Name | RuntimeDll
Actual csh Codeblock Associated with HashTable6: Offset | Sl.Start | Ql.Start | Quantity type | Opcode | Operation support information ------ | -------- | -------- | ------------- | ------ | ----------------------------- 0 | | | | LEV | Nest0 2 | 1.2 | 1.2 | String | LSC | 6:Create 7 | 1.2 | | | ARG | String 9 | 1.2 | | | LEV | Nest0 11 | 2.11 | 1.11 | String | LSC | 24:\gmManual\csh\HashTable6 16 | 2.11 | | | ARG | String 18 | 2.11 | | | LEV | Nest0 20 | 3.20 | 1.20 | Variant | SPV | Null 22 | 3.20 | | | ARG | String 24 | | 1.24 | Void | SCM | Execute_Storage
<gmBasic> <gmSL>Store.Open("HashTable6.vbi",StorageUnit.METHODS,0)</gmSL> <Select BndPath="..\csh\HashTable7.bnd" /> <RunCommand id="HashTable6" /> </gmBasic>
pBasic HashTable7.xml
Converting gmSL Methods in gmNI Runtime Libraries
The same binary information file whose "HashTable6" method was executed above can also be used to create a gmNI runtime library. The "Hashtable8.xml" script below uses a method Gemini.AuthorExecuteCommandDll stored in the vb7Lang.vbi language information file to produce a file "gmNI\Hashtable.bnd. It should be noted that all methods stored in the language file are written in gmSL<gmBasic> <Storage Action="Create" /> <Select DeployLocation="..\gmNI" /> <Select Library="\gmTools\gmnidll" /> <Select BuildFile="on" /> <RunCommand Id="Gemini.AuthorExecuteCommandDll" Prams="HashTable6;..\gmNI\HashTable.bnd" /> <Storage Action="Close" /> </gmBasic>
HashTable6Migration.c HashTable6Migration.lnk HashTable6.c EXECUTE instructions to do the build
Deploy HashTable.bnd DEPLOY
<gmBasic> <LoadRuntime FileName="..\gmNI\HashTable6Migration.dll" /> <Select BndPath="..\csh\HashTable9.bnd" /> <HashTable6 /> /gmBasic>
pBasic HashTable9.xml
Table of Contents