Skip to main content

Ens.DTL.Compiler

class Ens.DTL.Compiler extends %Library.RegisteredObject

This is the DTL Compiler. It it called primarily during the compilation process of subclasses of Ens.DataTransformDTL that define a DTL XDATA block. However, it can be called to directly compile a file or a stream containing DTL These debug flags affect the diagnostic output of the compiler:- ^Ens.Debug("ShowGeneratedXML") - Displays xml reconstructed from the parse tree to the current device

Property Inventory

Method Inventory

Properties

property ClassName as %String;
This holds the name of the data transform class
Property methods: ClassNameDisplayToLogical(), ClassNameGet(), ClassNameIsValid(), ClassNameLogicalToDisplay(), ClassNameLogicalToOdbc(), ClassNameNormalize(), ClassNameSet()
property ContextCustomVariables as %String [ MultiDimensional ];
This property tracks newly created variables to be stored in the context of the Compiler. These variables are created when an Assign Action uses a "set" statement to create a new variable that is not a VDoc
Property methods: ContextCustomVariablesDisplayToLogical(), ContextCustomVariablesGet(), ContextCustomVariablesIsValid(), ContextCustomVariablesLogicalToDisplay(), ContextCustomVariablesLogicalToOdbc(), ContextCustomVariablesNormalize(), ContextCustomVariablesSet()
property ForEachKeys as %String [ MultiDimensional ];
This property stores the key for each ForEach action the compiler encounters at the time of code generation
Property methods: ForEachKeysDisplayToLogical(), ForEachKeysGet(), ForEachKeysIsValid(), ForEachKeysLogicalToDisplay(), ForEachKeysLogicalToOdbc(), ForEachKeysNormalize(), ForEachKeysSet()
property Implementation as %RawString [ Transient ];
This holds the method implementation stream
Property methods: ImplementationGet(), ImplementationIsValid(), ImplementationSet()
property Indent as %String [ InitialExpression = $char(9) ];
Property methods: IndentDisplayToLogical(), IndentGet(), IndentIsValid(), IndentLogicalToDisplay(), IndentLogicalToOdbc(), IndentNormalize(), IndentSet()
property Language as %String;
This holds the language of the current compilation
Property methods: LanguageDisplayToLogical(), LanguageIsValid(), LanguageLogicalToDisplay(), LanguageLogicalToOdbc(), LanguageNormalize(), LanguageSet()
property PyMethodCounter as Ens.BPL.Counter;
Counter for Python Method name suffix to ensure unique method name regardless of thread or context location
Property methods: PyMethodCounterGet(), PyMethodCounterGetSwizzled(), PyMethodCounterIsValid(), PyMethodCounterNewObject(), PyMethodCounterSet()
property Transform as Ens.DTL.Transform;
This holds the root of the Parse Tree
Property methods: TransformGet(), TransformGetSwizzled(), TransformIsValid(), TransformNewObject(), TransformSet()

Methods

method AddIndent()
classmethod CompileStream(pStream As %BinaryStream, pClass As %Dictionary.ClassDefinition, pMethod As %Stream.MethodGenerator) as %Status
Parse the DTL contained in the supplied stream and generate a stream containing the implementation of the Transform method
classmethod GenerateCode(pTransform As Ens.DTL.Transform, pClass As %Dictionary.ClassDefinition, pMethod As %Stream.MethodGenerator) as %Status
classmethod GenerateXML(pTransform As Ens.DTL.Transform) as %Status
method LanguageGet() as %String
Accesor for Language
classmethod ParseStream(Output pTransform As Ens.DTL.Transform, pStream As %BinaryStream) as %Status
method RemoveIndent()
classmethod findEmptyStringComparisons(expression As %String) as %ArrayOfDataTypes [ Language = python ]
Takes in a python expression and returns list of arguments that are being compared to an empty string. for expression: ("" == arg1) and (arg2 == "") and (arg3=arg4) and (not arg5), this method returns an array with arg1, arg2 and arg5 as keys
classmethod findLocalVariables(text) as %ArrayOfDataTypes
Takes in an objectscript code block and returns all the new variables that have been "set" in it
method invokePyMethodinIntFile(compiler, returnName, statusName, invokeMethod, args, returnsValue, newArgs, pyDefinedVariables)
classmethod parsePyExpression(expression As %String) as %ListOfDataTypes [ Language = python ]
Takes in a python expression and returns the arguments as ArrayOfDataTypes. expression = "variable1 + math.sqrt(variable2)" will return {"variable1":1,"math":1, "variable2":1} Note: in the above expression, "math" is also treated as a variable
classmethod pyDefinedVariables(text) [ Language = python ]
This method returns all the variables that have been defined in a block of python code
classmethod vDocsToPythonArgs(text, args, fullcode, replaced) as %Status
this method allows to parse vDoc syntax from the input, get its values using objectscript and pass these values as arguments to the generated python method. example: text = "source.{PIDgrp.PID:PatientID.IDNumber} + "" abc "" + source.{PIDgrp.PID:PatientID.IDNumber}" returns-> args = 2 args(1) = "source.{PIDgrp.PID:PatientID.IDNumber}" args(2) = "source.{PIDgrp.PID:PatientID.IDNumber}" fullcode = "set arg2 = source.{PIDgrp.PID:PatientID.IDNumber}"_$c(13,10)_" set arg1 = source.{PIDgrp.PID:PatientID.IDNumber}"_$c(13,10)_" " replaced = "arg1 + "" abc "" + arg2"
method writeGeneralPyImports(pyMethod As %Dictionary.MethodDefinition, errorPrefix)
Checks if there are any libraries imported under the Transform tab and adds them to the method
method writePythonCode(pyMethod As %Dictionary.MethodDefinition, content, errorPrefix, returnsValue, pyDefinedVariables)

Inherited Members

Inherited Methods

FeedbackOpens in a new tab