- Created by Mark Juras , last modified on Jul 25, 2018
You are viewing an old version of this page. View the current version.
Compare with Current View Page History
« Previous Version 2 Next »
The gmSL Intrinsics
The gmSL language contains a few intrinsic methods and enumerations.OPC Enumeration
Opcodes are defined in the metalanguage file Opcode.xml. The intrinsic enumeration OPC allows the code to reference the entries in this file. Note that in the current version of opcodes.xml there are 189 opcodes and over 4100 opcode.subcode combinations. The OPC enumeration has two forms -- opcode and subcode. The opcode form is written OPC.opc where opc is one of the 189 defined opcodes. The subcode form is written OPC.opc.subcode where opc.subcode is one of the 4100 valid combinations defined. Note that gmSL is not case sensitive, but by convention upper case is used for the opcodes here to make them easier to see in the code. Consider the following opcode definition from the opcode.xml metalanguage file.<opcode id="CNV" opc="55" type="DoubleByte" role="convert" subcodes="65" > <subcode id="ToChar" value="0" /> <subcode id="ToDateTime" value="1" /> <subcode id="ToString" value="2" /> ...
System.LogMessage("Emission of opcode CNV is " + OPC.CNV); System.LogMessage("Emission of subcode ToString of CNV is " + OPC.CNV.ToString); System.LogMessage("Value of undefined subcode myString is " + OPC.CNV.myString);
Emission of opcode CNV is 55 Emission of subcode ToString of CNV is 2 Value of undefined subcode myString is -1
mask Method
gmSL: int mask(int seqNumb) The method mask is used to convert a sequence number between 0 and 31 into a power of 2 mask value that can be used as a boolean flag. As an example consider the PropertyStatus enumeration that combines various ContextFlags enumeration entries under single identifiers.<Enumeration id="PropertyStatus" > <Entry id="SetByRef" value="(%= Mask(ContextFlags.ByRef) + Mask(ContextFlags.UseGet) %)" /> <Entry id="GetSet" value="(%= Mask(ContextFlags.UseGet) %)" /> ... <Entry id="AsNew" value="(%= Mask(ContextFlags.ByRef) + Mask(ContextFlags.New) %)" /> </Enumeration>
int SetByRef; int AsNew; SetByRef = Mask(ContextFlags.ByRef) + Mask(ContextFlags.UseGet); AsNew = Mask(ContextFlags.ByRef) + Mask(ContextFlags.New); System.LogMessage("ContextFlags.ByRef = " + ContextFlags.ByRef); System.LogMessage("mask(ContextFlags.ByRef) = " + Mask(ContextFlags.ByRef)); System.LogMessage("ContextFlags.UseGet = " + ContextFlags.UseGet); System.LogMessage("mask(ContextFlags.UseGet) = " + Mask(ContextFlags.UseGet)); System.LogMessage("ContextFlags.New = " + ContextFlags.New); System.LogMessage("mask(ContextFlags.New) = " + Mask(ContextFlags.New)); System.LogMessage("SetByRef = " + SetByRef); System.LogMessage("AsNew = " + AsNew); if(SetByRef & mask(ContextFlags.ByRef)) System.LogMessage("SetByRef has ByRef flag"); else System.LogMessage("SetByRef does not have ByRef flag"); if(SetByRef & mask(ContextFlags.New)) System.LogMessage("SetByRef has New flag"); else System.LogMessage("SetByRef does not have New flag");
ContextFlags.ByRef = 7 mask(ContextFlags.ByRef) = 64 ContextFlags.UseGet = 10 mask(ContextFlags.UseGet) = 512 ContextFlags.New = 19 mask(ContextFlags.New) = 262144 SetByRef = 576 AsNew = 262208 SetByRef has ByRef flag SetByRef does not have New flag
sizeof Method
gmSL: int sizeof(object attributeClass) The method sizeof is used to determine the size of the gmSL attribute classes. This size value is needed when storing or allocating room for instances of these classes. The parameter className can only refer to one of these language classes, not to an arbitrary binary type or component. A typical use of this method might beiRefer = Store.FindVector(basName,0); if(iRefer == 0) { iRefer = Store.Vector(basName,0,sizeof(tVbName),ObjectType.Vb_Name); }
pcnt = Opcode.ExpandCode(iRefer,pcnt,sizeof(OPC.CNV)); Opcode.SetOperation(codptr,iRefer,OPC.CNV,OPC.CNV.ToString);
System.LogMessage("sizeof(tMigInfo) = " + sizeof(tMigInfo)); System.LogMessage("sizeof(tInfoFile) = " + sizeof(tInfoFile)); System.LogMessage("sizeof(tVbName) = " + sizeof(tVbName)); System.LogMessage("sizeof(tVariable) = " + sizeof(tVariable)); System.LogMessage("sizeof(tOpcInfo) = " + sizeof(tOpcInfo)); System.LogMessage("sizeof(OPC.LDA) = " + sizeof(OPC.LDA)); System.LogMessage("sizeof(OPC.LIC) = " + sizeof(OPC.LIC)); System.LogMessage("sizeof(OPC.CBN) = " + sizeof(OPC.CBN)); System.LogMessage("sizeof(OPC.USC) = " + sizeof(OPC.USC));
sizeof(tMigInfo) = 28 sizeof(tInfoFile) = 72 sizeof(tVbName) = 36 sizeof(tVariable) = 60 sizeof(tOpcInfo) = 17 sizeof(OPC.LDA) = 5 sizeof(OPC.LIC) = 3 sizeof(OPC.CBN) = 1 sizeof(OPC.USC) = 2
Table of Contents
- No labels