Link Search Menu Expand Document

Inspect

Table of contents

  1. Inspect
    1. Inspect.getFrameCount()
    2. Inspect.getLine(number: count -> optional)
    3. Inspect.getFile(number: count -> optional)

Inspect

To make use of the Inspect module an import is required.

import Inspect;

Inspect.getFrameCount()

This gives you the current frame count of the VM at the point of calling.

Note: This is 0-based.

Inspect.getFrameCount(); // 0

def test() {
    print(Inspect.getFrameCount());
}

test(); // 1

Inspect.getLine(number: count -> optional)

This gives you the line number within the file that the function was called from.

The optional argument passed is the amount of frames to traverse back up. If this number exceeds the frame count an error is raised.

Inspect.getLine(); // 1
Inspect.getLine(1000); // Optional argument passed to getLine() exceeds the frame count.

Inspect.getFile(number: count -> optional)

This gives you the name of the file that the function was called from.

The optional argument passed is the amount of frames to traverse back up. If this number exceeds the frame count an error is raised.

Inspect.getFile(); // repl
Inspect.getFile(); // myFile.du

This site uses Just The Docs, with modifications.