index Zimbu documentation

MODULE ZC @directory

summary

     

Items built into the compiler

CLASS Pos @public  Class that stores the line/column position in a file.
 
string lang @public  The language currently being generated: "C" or "JS"
string permu @public  The permutation currently being generated.
 
pos(): ZC.Pos @public  Return the current position in the code.
callerPos(): ZC.Pos @public  Return the code position of the calling method.
backtrace(): list<ZC.Pos> @public  Return the stack backtrace, the list of code positions that brought us to the current position.
backtrace(skip): list<ZC.Pos> @public  Return the stack backtrace, just like backtrace(), but skip the first skip entries.
have(feature): bool @public  Return TRUE when feature is supported.
 

members

     

string lang @public

     

The language currently being generated: "C" or "JS"

For example, to generate code for JavaScript only:

 GENERATE_IF ZC.lang == "JS"
 >>>
   javascript code
 <<<
 }

string permu @public

     

The permutation currently being generated.

Only when ZC.lang is "JS".

Currently possible values are: "ie6", "ie8", "gecko", "gecko18", "safari" and "opera".

Example:

 GENERATE_IF ZC.permu == "safari"
   safari code
 GENERATE_ELSE
   non-safari code
 }

FUNC pos() ZC.Pos @public

     

Return the current position in the code.

This is generated at compile time.

Example:

 THROW NEW("something wrong here", ZC.pos())

FUNC callerPos() ZC.Pos @public

     

Return the code position of the calling method.

When ZC.have("backtrace") is FALSE then NIL is returned.

Example:

 PROC getAtIndex(int idx)
   if idx < 0
     THROW NEW("idx invalid", ZC.callerPos())
   }
 }

FUNC backtrace() list<ZC.Pos> @public

     

Return the stack backtrace, the list of code positions that brought us to the current position.

The position where ZC.backtrace() is invoked is the first position, index zero in the list. The last position is a call from MAIN().

When ZC.have("backtrace") is FALSE then NIL is returned. When used in a method with backtrace=no a compilation error is produced.

Example:

 FOR p IN ZC.backtrace()
   IO.writeLine(p.toString() .. ": " .. p.text)
 }

FUNC backtrace(int skip) list<ZC.Pos> @public

     

Return the stack backtrace, just like backtrace(), but skip the first skip entries.

To omit the position this function is called use ZC.backtrace(1).

FUNC have(string feature) bool @public

     

Return TRUE when feature is supported.

Known features are:

"backtrace" - Wether stack backtrace is available "resolve" - Wether IO.resolve() is available "fork" - Wether fork() is available

Example:

 GENERATE_IF ZC.have("resolve")
   fname = IO.resolve(fname)
 }

license

      Copyright 2010-2011 Bram Moolenaar

      Licensed under the Apache License, Version 2.0. See the LICENSE file or obtain a copy at: http://www.apache.org/licenses/LICENSE-2.0