stack. Methods call stack trace   [3.4.5]


^reflection:stack[options]

Returns current stack of parser methods calls . For each stack frame the hash is returned, which contains object self, called method name, file name and line number where the method is defined.

Options hash can be specified:
·$.args(false/true) - to create args hash, containing parameters passed to the mehod. The default is not to create.  
·$.locals(false/true) - дополнительно создавать хеш locals, содержащий локальные переменные метода. По умолчанию не создавать.  
·$.limit(n) - to limit the numbed or returned stack frames. By default all stack frames are returned.  
·$.offset(o) - to return stack frames starting with the specified number. By default stack frames are returned starting with the first one.  


Example

@example[value]
^json:string[^reflection:stack[ $.args(true) ]; $.indent(true) ]

@main[]
^example[
some value]

Outputs:

{
   "1":{
      "self":{},
      "name":"example",
      "file":"filename.html",
      "line":1,
      "args":{
         "value":"some value"
      }
   },
   "2":{
      "self":{},
      "name":"main",
      "file":"filename.html",
      "line":4,
      "args":{}
   }
}



Copyright © 1997–2021 Art. Lebedev Studio | http://www.artlebedev.com Last updated: 27.04.2017