kjs Library API Documentation

function.h

00001 // -*- c-basic-offset: 2 -*-
00002 /*
00003  *  This file is part of the KDE libraries
00004  *  Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
00005  *
00006  *  This library is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU Lesser General Public
00008  *  License as published by the Free Software Foundation; either
00009  *  version 2 of the License, or (at your option) any later version.
00010  *
00011  *  This library is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  *  Lesser General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU Lesser General Public License
00017  *  along with this library; see the file COPYING.LIB.  If not, write to
00018  *  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019  *  Boston, MA 02111-1307, USA.
00020  *
00021  *  $Id: function.h,v 1.28.2.1 2003/05/17 11:19:24 mueller Exp $
00022  */
00023 
00024 #ifndef _KJS_FUNCTION_H_
00025 #define _KJS_FUNCTION_H_
00026 
00027 #include "internal.h"
00028 
00029 namespace KJS {
00030 
00031   class Parameter;
00032 
00036   class FunctionImp : public InternalFunctionImp {
00037     friend class Function;
00038     friend class ActivationImp;
00039   public:
00040     FunctionImp(ExecState *exec, const UString &n = UString::null);
00041     virtual ~FunctionImp();
00042 
00043     virtual void mark();
00044 
00045     virtual bool implementsCall() const;
00046     virtual Value call(ExecState *exec, Object &thisObj, const List &args);
00047 
00048     void addParameter(const UString &n);
00049     // parameters in string representation, e.g. (a, b, c)
00050     UString parameterString() const;
00051     virtual CodeType codeType() const = 0;
00052 
00053     virtual Completion execute(ExecState *exec) = 0;
00054     UString name() const { return ident; }
00055 
00056     virtual const ClassInfo *classInfo() const { return &info; }
00057     static const ClassInfo info;
00058   protected:
00059     Parameter *param;
00060     UString ident;
00061 
00062   private:
00063     void processParameters(ExecState *exec, const List &);
00064     virtual void processVarDecls(ExecState *exec);
00065 
00066     void pushArgs(ExecState *exec, const Object &args);
00067     void popArgs(ExecState *exec);
00068     ListImp *argStack;
00069   };
00070 
00071   class DeclaredFunctionImp : public FunctionImp {
00072   public:
00073     DeclaredFunctionImp(ExecState *exec, const UString &n,
00074             FunctionBodyNode *b, const List &sc);
00075     ~DeclaredFunctionImp();
00076 
00077     bool implementsConstruct() const;
00078     Object construct(ExecState *exec, const List &args);
00079 
00080     virtual Completion execute(ExecState *exec);
00081     CodeType codeType() const { return FunctionCode; }
00082     FunctionBodyNode *body;
00083 
00084     virtual const ClassInfo *classInfo() const { return &info; }
00085     static const ClassInfo info;
00086   private:
00087     virtual void processVarDecls(ExecState *exec);
00088   };
00089 
00090 
00091 
00092 
00093   class ArgumentsImp : public ObjectImp {
00094   public:
00095     ArgumentsImp(ExecState *exec, FunctionImp *func, const List &args);
00096 
00097     virtual const ClassInfo *classInfo() const { return &info; }
00098     static const ClassInfo info;
00099   };
00100 
00101   class ActivationImp : public ObjectImp {
00102   public:
00103     ActivationImp(ExecState *exec, FunctionImp *f, const List &args);
00104     ~ActivationImp();
00105 
00106     Object argumentsObject() { return Object(arguments); }
00107 
00108     virtual const ClassInfo *classInfo() const { return &info; }
00109     static const ClassInfo info;
00110   private:
00111     ObjectImp* arguments;
00112   };
00113 
00114   class GlobalFuncImp : public InternalFunctionImp {
00115   public:
00116     GlobalFuncImp(ExecState *exec, FunctionPrototypeImp *funcProto, int i, int len);
00117     virtual bool implementsCall() const;
00118     virtual Value call(ExecState *exec, Object &thisObj, const List &args);
00119     virtual CodeType codeType() const;
00120     enum { Eval, ParseInt, ParseFloat, IsNaN, IsFinite, Escape, UnEscape };
00121   private:
00122     int id;
00123   };
00124 
00125 
00126 
00127 } // namespace
00128 
00129 #endif
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sun Feb 27 22:15:17 2005 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001