Files
harbour-core/harbour/source/compiler/hbfunchk.c
Ryszard Glab 912b301c85 2006-07-14 16:00 UTC+0100 Ryszard Glab <rglab//imid.med.pl>
* include/hbcomp.h
   * include/hberrors.h
   * include/hbexpra.c
   * include/hbexprb.c
   * include/hbexprc.c
   * include/hbmacro.h
   * include/hbpcode.h
   * include/hbpp.h
   * include/hbxvm.h
   * source/common/expropt1.c
   * source/compiler/cmdcheck.c
   * source/compiler/expropta.c
   * source/compiler/exproptb.c
   * source/compiler/exproptc.c
   * source/compiler/genc.c
   * source/compiler/gencc.c
   * source/compiler/gencli.c
   * source/compiler/genhrb.c
   * source/compiler/genjava.c
   * source/compiler/genobj32.c
   * source/compiler/harbour.c
   * source/compiler/harbour.l
   * source/compiler/harbour.y
   * source/compiler/hbdead.c
   * source/compiler/hbfix.c
   * source/compiler/hbfunchk.c
   * source/compiler/hbgenerr.c
   * source/compiler/hblbl.c
   * source/compiler/hbpcode.c
   * source/compiler/hbstripl.c
   * source/macro/macroa.c
   * source/macro/macrob.c
   * source/macro/macroc.c
   * source/vm/hvm.c
   * source/vm/macro.c
      * fixed compilation of code that uses '@' pass by
       reference. The following syntax is no longer supported:
       var := IIF( .T., @var, var )
       however you can still use the following:
       funcall( IIF( bPassbyRef, @someVar, someVar ) )
      +added support for the following statement:
         WITH OBJECT <objexpression>
            ...
         END
       inside this statement you can use simplified form of sending
       messages to the object specified by <objexpression>
         :message( )    instead objexpression:message()
         :property      instead objexpression:property
       The runtime error will be generated at the time of message
       sending (or property access/assign) if <objexpression>
       is not a value of type object.
       You can use the reserved property:
         :__withobject
       to access/assign the controlling object.
      *fixed support for command line response file (@file.clp)
       to be compatible with Clipper (Clipper genertes a single
       obj file)
      *fixed memory leaks when there is a fatal error in autoopened
       module (using DO ... statement)
      *implicit startup functions are removed from the list of
       functions before generation of output code

   * source/pp/ppcomp.c
   * source/pp/pplib.c
   * source/pp/ppcore.c
      * redefinition of #define no longer causes a memory leak
      * fixed repeatable optional clauses
         #xcommand SET <var1> [, <varN>] WITH <val> =>
          <var1>:=<val>[; <varN>:=<val>]
      * fixed compilation of optional clauses (when used in different
        order then declared) -this fixes the following long
        waiting bug:
         #command MYCOMMAND [<mylist,...>] [MYCLAUSE <myval>] => ;
            MyFunction( {<mylist>} [, <myval>] )
         MYCOMMAND MYCLAUSE 321 "HELLO"
      * fixed restricted macro match marker <x:&>

   * tests/Makefile
   - tests/pretest.prg
   + utils/hbpptest
   + utils/hbpptest/Makefile
   + utils/hbpptest/pretest.prg
      * moved file 'pretest.prg' from tests to separate directory
        to make easier validation of the preprocessor

   * TODO
      * added note to fix hb_objGetMethod() so it will not generate
        error if there is no method

   * doc/en/clipper.txt
      * added documentation for WITH OBJECT usage
2006-07-14 13:47:17 +00:00

167 lines
4.8 KiB
C

/*
* $Id$
*/
/*
* Harbour Project source code:
* Compile time RTL argument checking
*
* Copyright 1999 Jose Lalin <dezac@corevia.com>
* www - http://www.harbour-project.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
*
*/
#include "hbcomp.h"
/* NOTE: iMinParam = -1, means no checking
* iMaxParam = -1, means no upper limit
*/
typedef struct
{
char * cFuncName; /* function name */
int iMinParam; /* min no of parms it needs */
int iMaxParam; /* max no of parms need */
} HB_FUNCINFO, * HB_PFUNCINFO;
static HB_FUNCINFO hb_StdFunc[] =
{
{ "AADD" , 2, 2 },
{ "ABS" , 1, 1 },
{ "ASC" , 1, 1 },
#if defined( HB_C52_STRICT )
{ "AT" , 2, 2 },
#else
{ "AT" , 2, 4 },
#endif
{ "BOF" , 0, 0 },
{ "BREAK" , 0, 1 },
{ "CDOW" , 1, 1 },
{ "CHR" , 1, 1 },
{ "CMONTH" , 1, 1 },
{ "COL" , 0, 0 },
{ "CTOD" , 1, 1 },
{ "DATE" , 0, 0 },
{ "DAY" , 1, 1 },
{ "DELETED" , 0, 0 },
{ "DEVPOS" , 2, 2 },
{ "DOW" , 1, 1 },
{ "DTOC" , 1, 1 },
{ "DTOS" , 1, 1 },
{ "EMPTY" , 1, 1 },
{ "EOF" , 0, 0 },
{ "EVAL" , 1, -1 },
{ "EXP" , 1, 1 },
{ "FCOUNT" , 0, 0 },
{ "FIELDNAME" , 1, 1 },
{ "FILE" , 1, 1 },
{ "FLOCK" , 0, 0 },
{ "FOUND" , 0, 0 },
{ "INKEY" , 0, 2 },
{ "INT" , 1, 1 },
{ "LASTREC" , 0, 0 },
{ "LEFT" , 2, 2 },
{ "LEN" , 1, 1 },
{ "LOCK" , 0, 0 },
{ "LOG" , 1, 1 },
{ "LOWER" , 1, 1 },
{ "LTRIM" , 1, 1 },
{ "MAX" , 2, 2 },
{ "MIN" , 2, 2 },
{ "MONTH" , 1, 1 },
{ "PCOL" , 0, 0 },
{ "PCOUNT" , 0, 0 },
{ "PROW" , 0, 0 },
{ "QSELF" , 0, 0 },
{ "RECCOUNT" , 0, 0 },
{ "RECNO" , 0, 0 },
{ "REPLICATE" , 2, 2 },
{ "RLOCK" , 0, 0 },
{ "ROUND" , 2, 2 },
{ "ROW" , 0, 0 },
{ "RTRIM" , 1, 2 }, /* Second parameter is a Harbour extension */
{ "SECONDS" , 0, 0 },
{ "SELECT" , 0, 1 },
{ "SETPOS" , 2, 2 },
{ "SETPOSBS" , 0, 0 },
{ "SPACE" , 1, 1 },
{ "SQRT" , 1, 1 },
{ "STR" , 1, 3 },
{ "SUBSTR" , 2, 3 },
{ "TIME" , 0, 0 },
{ "TRANSFORM" , 2, 2 },
{ "TRIM" , 1, 2 }, /* Second parameter is a Harbour extension */
{ "TYPE" , 1, 1 },
{ "UPPER" , 1, 1 },
{ "VAL" , 1, 1 },
{ "VALTYPE" , 1, 1 },
{ "WORD" , 1, 1 },
{ "YEAR" , 1, 1 },
{ 0 , 0, 0 }
};
BOOL hb_compFunCallCheck( char * szFuncCall, int iArgs )
{
HB_FUNCINFO * f = hb_StdFunc;
int i = 0;
int iPos = -1;
int iCmp;
while( f[ i ].cFuncName )
{
iCmp = strncmp( szFuncCall, f[ i ].cFuncName, 4 );
if( iCmp == 0 )
iCmp = strncmp( szFuncCall, f[ i ].cFuncName, strlen( szFuncCall ) );
if( iCmp == 0 )
{
iPos = i;
break;
}
else
++i;
}
if( iPos >= 0 && ( f[ iPos ].iMinParam != -1 ) )
{
if( iArgs < f[ iPos ].iMinParam || ( f[ iPos ].iMaxParam != -1 && iArgs > f[ iPos ].iMaxParam ) )
{
if( HB_COMP_ISSUPPORTED( HB_COMPFLAG_HARBOUR ) )
{
char szMsg[ 40 ];
if( f[ iPos ].iMaxParam == -1 )
sprintf( szMsg, "\nPassed: %i, expected: at least %i", iArgs, f[ iPos ].iMinParam );
else if( f[ iPos ].iMinParam == f[ iPos ].iMaxParam )
sprintf( szMsg, "\nPassed: %i, expected: %i", iArgs, f[ iPos ].iMinParam );
else
sprintf( szMsg, "\nPassed: %i, expected: %i - %i", iArgs, f[ iPos ].iMinParam, f[ iPos ].iMaxParam );
hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_CHECKING_ARGS, szFuncCall, szMsg );
return FALSE;
}
else
{
/* Clipper way */
hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_CHECKING_ARGS, szFuncCall, NULL );
return FALSE;
}
}
}
return TRUE;
}