Interface Expressions

interface Expressions {
    evaluate(expression: string):
        | string
        | number
        | bigint
        | void;
}

Methods

Methods

  • Evaluates a GEL expression and returns the resulting value, if numerical or a string. All standard rules for GEL expressions apply. If the result of evaluating the expression is an integral value, a BigInt will be returned. If the value is a floating point value, a standard Javascript number will be returned. For any other value, like a reference to a c++ object, we return without a value.

    Parameters

    • expression: string

      The GEL expression to evaluate

    Returns
        | string
        | number
        | bigint
        | void

    The value resulting from the evaluation of the expression, if numerical or a string.

    Will throw if the evaluation of the expression fails.

    // Adds 8 to the address of the main symbol, returns a BigInt
    let result = session.expressions.evaluate("main + 8");

    // Returns a (floating point) number
    let result = session.expressions.evaluate("1.0 / 2");

    // Call a GEL function (assuming that this function is defined in a loaded GEL script)
    session.expressions.evaluate('userDefinedGelFunction()');