File indexing completed on 2024-05-12 15:43:16
0001 /* 0002 * This file is part of the KDE libraries 0003 * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) 0004 * Copyright (C) 2001 Peter Kelly (pmk@post.com) 0005 * Copyright (C) 2003 Apple Computer, Inc 0006 * 0007 * This library is free software; you can redistribute it and/or 0008 * modify it under the terms of the GNU Library General Public 0009 * License as published by the Free Software Foundation; either 0010 * version 2 of the License, or (at your option) any later version. 0011 * 0012 * This library is distributed in the hope that it will be useful, 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0015 * Library General Public License for more details. 0016 * 0017 * You should have received a copy of the GNU Library General Public License 0018 * along with this library; see the file COPYING.LIB. If not, write to 0019 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0020 * Boston, MA 02110-1301, USA. 0021 * 0022 */ 0023 0024 #ifndef _KJS_COMPLETION_H_ 0025 #define _KJS_COMPLETION_H_ 0026 0027 #include "CommonIdentifiers.h" 0028 0029 namespace KJS 0030 { 0031 0032 typedef unsigned Addr; // ### should there be some separate types h? 0033 0034 class Node; 0035 class JSValue; 0036 0037 /** 0038 * Completion types. 0039 */ 0040 enum ComplType { Normal, Break, Continue, ReturnValue, Throw, Interrupted }; 0041 0042 /** 0043 * Completion objects are used to convey the return status and value 0044 * from functions. 0045 * 0046 * See FunctionImp::execute() 0047 * 0048 * @see FunctionImp 0049 * 0050 * @short Handle for a Completion type. 0051 */ 0052 class KJS_EXPORT Completion 0053 { 0054 public: 0055 explicit Completion(ComplType c = Normal, JSValue *v = nullptr, Addr t = 0) 0056 : comp(c), val(v), tar(t) { } 0057 0058 /** 0059 * Returns the type of this completion. 0060 */ 0061 ComplType complType() const 0062 { 0063 return comp; 0064 } 0065 0066 /** 0067 * Returns the value of this completion if it is of type 0068 * value-completion, 0 otherwise. 0069 */ 0070 JSValue *value() const 0071 { 0072 return val; 0073 } 0074 0075 /** 0076 * Returns the address a break or a continue statement targets 0077 */ 0078 Addr target() const 0079 { 0080 return tar; 0081 } 0082 0083 /** 0084 * Returns true if this is a value completion, false otherwise. 0085 */ 0086 bool isValueCompletion() const 0087 { 0088 return !!val; 0089 } 0090 private: 0091 ComplType comp; 0092 JSValue *val; 0093 Addr tar; 0094 }; 0095 0096 } 0097 0098 #endif