KJS

completion.h
1 /*
2  * This file is part of the KDE libraries
3  * Copyright (C) 1999-2001 Harri Porten ([email protected])
4  * Copyright (C) 2001 Peter Kelly ([email protected])
5  * Copyright (C) 2003 Apple Computer, Inc
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public License
18  * along with this library; see the file COPYING.LIB. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  *
22  */
23 
24 #ifndef _KJS_COMPLETION_H_
25 #define _KJS_COMPLETION_H_
26 
27 #include "CommonIdentifiers.h"
28 
29 namespace KJS
30 {
31 
32 typedef unsigned Addr; // ### should there be some separate types h?
33 
34 class Node;
35 class JSValue;
36 
37 /**
38  * Completion types.
39  */
40 enum ComplType { Normal, Break, Continue, ReturnValue, Throw, Interrupted };
41 
42 /**
43  * Completion objects are used to convey the return status and value
44  * from functions.
45  *
46  * See FunctionImp::execute()
47  *
48  * @see FunctionImp
49  *
50  * @short Handle for a Completion type.
51  */
52 class KJS_EXPORT Completion
53 {
54 public:
55  explicit Completion(ComplType c = Normal, JSValue *v = nullptr, Addr t = 0)
56  : comp(c), val(v), tar(t) { }
57 
58  /**
59  * Returns the type of this completion.
60  */
61  ComplType complType() const
62  {
63  return comp;
64  }
65 
66  /**
67  * Returns the value of this completion if it is of type
68  * value-completion, 0 otherwise.
69  */
70  JSValue *value() const
71  {
72  return val;
73  }
74 
75  /**
76  * Returns the address a break or a continue statement targets
77  */
78  Addr target() const
79  {
80  return tar;
81  }
82 
83  /**
84  * Returns true if this is a value completion, false otherwise.
85  */
86  bool isValueCompletion() const
87  {
88  return !!val;
89  }
90 private:
91  ComplType comp;
92  JSValue *val;
93  Addr tar;
94 };
95 
96 }
97 
98 #endif
JSValue is the base type for all primitives (Undefined, Null, Boolean, String, Number) and objects in...
Definition: value.h:58
Addr target() const
Returns the address a break or a continue statement targets.
Definition: completion.h:78
ComplType complType() const
Returns the type of this completion.
Definition: completion.h:61
Completion objects are used to convey the return status and value from functions.
Definition: completion.h:52
bool isValueCompletion() const
Returns true if this is a value completion, false otherwise.
Definition: completion.h:86
JSValue * value() const
Returns the value of this completion if it is of type value-completion, 0 otherwise.
Definition: completion.h:70
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Feb 5 2023 03:57:18 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.