Show / Hide Table of Contents

Class JSCompiler

Implements a DecisionModel compiler for expressions in the JavaScript language for processing by a JSProcessor instance.

Inheritance
object
JSCompiler
Implements
ICompiler
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Quantellia.WMServer.Execution.JS
Assembly: WMServer.dll
Syntax
public class JSCompiler : ICompiler
Remarks

The following keywords may not be used as element names:

abstractbreakchardebuggerdoubleexportfinally
inletnullpublicsuperthrowtry
volatileargumentsbyteclassdefaultelseextends
floatifinstanceoflongpackagereturnswitch
throwstypeofwhileawaitcaseconstdelete
enumFALSEforimplementsintnativeprivate
shortsynchronizedtransientvarwithbooleancatch
continuedoevalfinalfunctionimportinterface
newprotectedstaticthisTRUEvoidyield

JavaScript Math Library Support

All static functions and values defined in the JavaScript Math library may be used. Note that the World Modeler parser does not resolve dot-separated namespaces in qualified names. Calls to Math library functions must be made without any spaces.
Math.exp(x) will work but Math . exp(x), although it is legal JavaScript, will not be recognized by the World Modeler Parser and "Symbol not found" errors will be genrerated.

Supported Math library functions are:

Math.E Math.LN10 Math.LN2 Math.LOG10E Math.LOG2E Math.PI Math.SQRT1_2 Math.SQRT2
Math.abs Math.acos Math.acosh Math.asin Math.asinh Math.atan Math.atan2 Math.atanh
Math.cbrt Math.ceil Math.clz32 Math.cos Math.cosh Math.exp Math.expm1 Math.floor
Math.froundMath.hypot Math.imul Math.log Math.log10 Math.log1p Math.log2 Math.max
Math.min Math.pow Math.random Math.round Math.sign Math.sin Math.sinh Math.sqrt
Math.tan Math.tanh Math.trunc

Fields

ConstraintsFunction

Name of the function used to evaluate constraint conditions in a simulation. This is a reserved name and should not be used by user-defined functions.

Declaration
public const string ConstraintsFunction = "__WM_constraints"
Field Value
Type Description
string

SelectArgsFunction

Name of the function used to evaluate simulation arguments. This is a reserved name and should not be used by user-defined functions.

Declaration
public const string SelectArgsFunction = "__WM_selectArgs"
Field Value
Type Description
string

StopFunction

Name of the function used to evaluate the simulation stop condition. This is a reserved name and should not be used by user-defined functions.

Declaration
public const string StopFunction = "__WM_stop"
Field Value
Type Description
string

Methods

Compile(string)

Declaration
public object Compile(string sourceCode)
Parameters
Type Name Description
string sourceCode
Returns
Type Description
object

GenerateSourceCode(DecisionModel, SimulationParams?)

Declaration
public string GenerateSourceCode(DecisionModel model, SimulationParams? simulationParams = null)
Parameters
Type Name Description
DecisionModel model
SimulationParams simulationParams
Returns
Type Description
string

IdentifierToName(string)

Declaration
public static string IdentifierToName(string identifier)
Parameters
Type Name Description
string identifier
Returns
Type Description
string

NameToIdentifier(string)

Converts provided fully qualified name to a string that is an acceptable identifier name in coding languages.

Declaration
public static string NameToIdentifier(string name)
Parameters
Type Name Description
string name
Returns
Type Description
string
Remarks

The following characters (shown as enclosed in single quote) are replaced with character \255 (0xFF):

' '    '_'    '-'    ':'    ';'    '.'    '!'    '@'    '#'    '$'    '%'    '&'    '*'    '%'   '('    ')'    ','    '+'    '='    '/'    '\\'    '<'    '>'    '?'

Implements

ICompiler
In this article
Back to top Copyright © 2025 Quantellia LLC.    Version 2.0.0 Revision 399     Last Updated 1/15/2025    DRAFT DOCUMENTATION. SUBJECT TO CHANGE