home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / harbb30g.zip / INCLUDE / ctoharb.h < prev    next >
C/C++ Source or Header  |  1999-09-17  |  12KB  |  183 lines

  1. /*
  2.  * $Id: ctoharb.h,v 1.30 1999/09/17 11:43:24 vszel Exp $
  3.  */
  4.  
  5. /*
  6.  * Harbour Project source code:
  7.  * Header file for the Virtual Machine API
  8.  *
  9.  * Copyright 1999 Antonio Linares <alinares@fivetech.com>
  10.  * www - http://www.harbour-project.org
  11.  *
  12.  * This program is free software; you can redistribute it and/or modify
  13.  * it under the terms of the GNU General Public License as published by
  14.  * the Free Software Foundation; either version 2 of the License, or
  15.  * (at your option) any later version, with one exception:
  16.  *
  17.  * The exception is that if you link the Harbour Runtime Library (HRL)
  18.  * and/or the Harbour Virtual Machine (HVM) with other files to produce
  19.  * an executable, this does not by itself cause the resulting executable
  20.  * to be covered by the GNU General Public License. Your use of that
  21.  * executable is in no way restricted on account of linking the HRL
  22.  * and/or HVM code into it.
  23.  *
  24.  * This program is distributed in the hope that it will be useful,
  25.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  26.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  27.  * GNU General Public License for more details.
  28.  *
  29.  * You should have received a copy of the GNU General Public License
  30.  * along with this program; if not, write to the Free Software
  31.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit
  32.  * their web site at http://www.gnu.org/).
  33.  *
  34.  */
  35.  
  36. /*
  37.    Harbour Project source code
  38.  
  39.    Harbour from C caller functions
  40.  
  41.    Copyright 1999  Antonio Linares <alinares@fivetech.com>
  42.    www - http://www.harbour-project.org
  43.  
  44.    This program is free software; you can redistribute it and/or modify
  45.    it under the terms of the GNU General Public License as published by
  46.    the Free Software Foundation; either version 2 of the License, or
  47.    (at your option) any later version, with one exception:
  48.  
  49.    The exception is that if you link the Harbour Runtime Library (HRL)
  50.    and/or the Harbour Virtual Machine (HVM) with other files to produce
  51.    an executable, this does not by itself cause the resulting executable
  52.    to be covered by the GNU General Public License. Your use of that
  53.    executable is in no way restricted on account of linking the HRL
  54.    and/or HVM code into it.
  55.  
  56.    This program is distributed in the hope that it will be useful,
  57.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  58.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  59.    GNU General Public License for more details.
  60.  
  61.    You should have received a copy of the GNU General Public License
  62.    along with this program; if not, write to the Free Software
  63.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit
  64.    their web site at http://www.gnu.org/).
  65. */
  66.  
  67. #ifndef HB_CTOHARB_H_
  68. #define HB_CTOHARB_H_
  69.  
  70. #include "extend.h"
  71.  
  72. /* Harbour virtual machine functions */
  73. extern void    hb_vmExecute( BYTE * pCode, PHB_SYMB pSymbols );  /* invokes the virtual machine */
  74. extern void    hb_vmProcessSymbols( PHB_SYMB pSymbols, USHORT uiSymbols ); /* statics symbols initialization */
  75. extern void    hb_vmSymbolInit_RT( void );   /* initialization of runtime support symbols */
  76.  
  77. /* Harbour virtual machine escaping API */
  78. extern void    hb_vmRequestQuit( void );
  79. extern void    hb_vmRequestCancel( void );
  80. extern void    hb_vmRequestBreak( PHB_ITEM pItem );
  81. extern USHORT  hb_vmRequestQuery( void );
  82. extern void    hb_vmQuit( void );            /* Immediately quits the virtual machine */
  83.  
  84. /* Return values of hb_vmRequestQuery() */
  85. #define HB_QUIT_REQUESTED       1            /* immediately quit the application */
  86. #define HB_BREAK_REQUESTED      2            /* break to nearest RECOVER/END sequence */
  87.  
  88. /* PCode functions */
  89.  
  90. /* Operators ( mathematical / character / misc ) */
  91. extern void    hb_vmMult( void );            /* multiplies the latest two values on the stack, removes them and leaves the result */
  92. extern void    hb_vmDivide( void );          /* divides the latest two values on the stack, removes them and leaves the result */
  93. extern void    hb_vmPlus( void );            /* sums the latest two values on the stack, removes them and leaves the result */
  94. extern void    hb_vmMinus( void );           /* substracts the latest two values on the stack, removes them and leaves the result */
  95. extern void    hb_vmPower( void );           /* power the latest two values on the stack, removes them and leaves the result */
  96. extern void    hb_vmModulus( void );         /* calculates the modulus of latest two values on the stack, removes them and leaves the result */
  97. extern void    hb_vmInc( void );             /* increment the latest numeric value on the stack */
  98. extern void    hb_vmDec( void );             /* decrements the latest numeric value on the stack */
  99. extern void    hb_vmNegate( void );          /* negates (-) the latest value on the stack */
  100. extern void    hb_vmFuncPtr( void );         /* pushes a function address pointer. Removes the symbol from the satck */
  101.  
  102. /* Operators (relational) */
  103. extern void    hb_vmEqual( BOOL bExact );    /* checks if the two latest values on the stack are equal, removes both and leaves result */
  104. extern void    hb_vmNotEqual( void );        /* checks if the two latest values on the stack are not equal, removes both and leaves result */
  105. extern void    hb_vmGreater( void );         /* checks if the latest - 1 value is greater than the latest, removes both and leaves result */
  106. extern void    hb_vmGreaterEqual( void );    /* checks if the latest - 1 value is greater than or equal the latest, removes both and leaves result */
  107. extern void    hb_vmLess( void );            /* checks if the latest - 1 value is less than the latest, removes both and leaves result */
  108. extern void    hb_vmLessEqual( void );       /* checks if the latest - 1 value is less than or equal the latest, removes both and leaves result */
  109. extern void    hb_vmInstring( void );        /* check whether string 1 is contained in string 2 */
  110.  
  111. /* Operators (logical) */
  112. extern void    hb_vmAnd( void );             /* performs the logical AND on the latest two values, removes them and leaves result on the stack */
  113. extern void    hb_vmOr( void );              /* performs the logical OR on the latest two values, removes them and leaves result on the stack */
  114. extern void    hb_vmNot( void );             /* changes the latest logical value on the stack */
  115.  
  116. /* Array */
  117. extern void    hb_vmArrayAt( void );         /* pushes an array element to the stack, removing the array and the index from the stack */
  118. extern void    hb_vmArrayPut( void );        /* sets an array value and pushes the value on to the stack */
  119. extern void    hb_vmDimArray( USHORT uiDimensions ); /* generates an uiDimensions Array and initialize those dimensions from the stack values */
  120. extern void    hb_vmGenArray( ULONG ulElements ); /* generates an ulElements Array and fills it from the stack values */
  121.  
  122. /* Object */
  123. extern void    hb_vmMessage( PHB_SYMB pSymMsg ); /* sends a message to an object */
  124. extern void    hb_vmOperatorCall( PHB_ITEM, PHB_ITEM, char * ); /* call an overloaded operator */
  125. extern void    hb_vmOperatorCallUnary( PHB_ITEM, char * ); /* call an overloaded unary operator */
  126.  
  127. /* Execution */
  128. extern void    hb_vmFrame( BYTE bLocals, BYTE bParams );  /* increases the stack pointer for the amount of locals and params suplied */
  129. extern void    hb_vmLocalName( USHORT uiLocal, char * szLocalName ); /* locals and parameters index and name information for the debugger */
  130. extern void    hb_vmModuleName( char * szModuleName ); /* PRG and function name information for the debugger */
  131. extern void    hb_vmSFrame( PHB_SYMB pSym );     /* sets the statics frame for a function */
  132. extern void    hb_vmStatics( PHB_SYMB pSym );    /* increases the the global statics array to hold a PRG statics */
  133. extern void    hb_vmRetValue( void );           /* pops the latest stack value into stack.Return */
  134. extern void    hb_vmEndBlock( void );        /* copies the last codeblock pushed value into the return value */
  135.  
  136. /* Misc */
  137. extern void    hb_vmDo( USHORT uiParams );      /* invoke the virtual machine */
  138. extern HARBOUR hb_vmDoBlock( void );         /* executes a codeblock */
  139. extern void    hb_vmFunction( USHORT uiParams ); /* executes a function saving its result */
  140. extern void    hb_vmDuplicate( void );       /* duplicates the latest value on the stack */
  141. extern void    hb_vmDuplTwo( void );         /* duplicates the latest two value on the stack */
  142. extern void    hb_vmForTest( void );         /* test for end condition of for */
  143.  
  144. /* Push */
  145. extern void    hb_vmPush( PHB_ITEM pItem );     /* pushes a generic item onto the stack */
  146. extern void    hb_vmPushNil( void );            /* in this case it places nil at self */
  147. extern void    hb_vmPushNumber( double dNumber, int iDec ); /* pushes a number on to the stack and decides if it is integer, long or double */
  148. extern void    hb_vmPushInteger( int iNumber ); /* pushes a integer number onto the stack */
  149. extern void    hb_vmPushLong( long lNumber ); /* pushes a long number onto the stack */
  150. extern void    hb_vmPushDouble( double lNumber, int iDec ); /* pushes a double number onto the stack */
  151. extern void    hb_vmPushLogical( BOOL bValue );    /* pushes a logical value onto the stack */
  152. extern void    hb_vmPushString( char * szText, ULONG length );  /* pushes a string on to the stack */
  153. extern void    hb_vmPushDate( LONG lDate );   /* pushes a long date onto the stack */
  154. extern void    hb_vmPushBlock( BYTE * pCode, PHB_SYMB pSymbols ); /* creates a codeblock */
  155. extern void    hb_vmPushSymbol( PHB_SYMB pSym ); /* pushes a function pointer onto the stack */
  156. extern void    hb_vmPushLocal( SHORT iLocal );     /* pushes the containts of a local onto the stack */
  157. extern void    hb_vmPushLocalByRef( SHORT iLocal ); /* pushes a local by refrence onto the stack */
  158. extern void    hb_vmPushStatic( USHORT uiStatic );   /* pushes the containts of a static onto the stack */
  159. extern void    hb_vmPushStaticByRef( USHORT uiLocal ); /* pushes a static by refrence onto the stack */
  160.  
  161. /* Pop */
  162. extern long    hb_vmPopDate( void );         /* pops the stack latest value and returns its date value as a LONG */
  163. extern double  hb_vmPopNumber( void );          /* pops the stack latest value and returns its numeric value */
  164. extern double  hb_vmPopDouble( int * );    /* pops the stack latest value and returns its double numeric format value */
  165. extern BOOL    hb_vmPopLogical( void );           /* pops the stack latest value and returns its logical value */
  166. extern void    hb_vmPopLocal( SHORT iLocal );      /* pops the stack latest value onto a local */
  167. extern void    hb_vmPopStatic( USHORT uiStatic );    /* pops the stack latest value onto a static */
  168. extern void    hb_vmPopDefStat( USHORT uiStatic ); /* pops the stack latest value onto a static as default init */
  169.  
  170. /* stack management functions */
  171. extern void    hb_stackDec( void );        /* pops an item from the stack without clearing it's contents */
  172. extern void    hb_stackPop( void );        /* pops an item from the stack */
  173. extern void    hb_stackFree( void );       /* releases all memory used by the stack */
  174. extern void    hb_stackPush( void );       /* pushes an item on to the stack */
  175. extern void    hb_stackInit( void );       /* initializes the stack */
  176. extern void    hb_stackDispLocal( void );  /* show the types of the items on the stack for debugging purposes */
  177. extern void    hb_stackDispCall( void );   /* show the procedure names of the call stack for internal errors use */
  178.  
  179. #define STACK_INITHB_ITEMS      100
  180. #define STACK_EXPANDHB_ITEMS    20
  181.  
  182. #endif /* HB_CTOHARB_H_ */
  183.