BlockClass.hpp
Go to the documentation of this file.
1 /*----------------------------------------------------------------------------*/
2 /* */
3 /* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */
4 /* Copyright (c) 2005-2009 Rexx Language Association. All rights reserved. */
5 /* */
6 /* This program and the accompanying materials are made available under */
7 /* the terms of the Common Public License v1.0 which accompanies this */
8 /* distribution. A copy is also available at the following address: */
9 /* http://www.ibm.com/developerworks/oss/CPLv1.0.htm */
10 /* */
11 /* Redistribution and use in source and binary forms, with or */
12 /* without modification, are permitted provided that the following */
13 /* conditions are met: */
14 /* */
15 /* Redistributions of source code must retain the above copyright */
16 /* notice, this list of conditions and the following disclaimer. */
17 /* Redistributions in binary form must reproduce the above copyright */
18 /* notice, this list of conditions and the following disclaimer in */
19 /* the documentation and/or other materials provided with the distribution. */
20 /* */
21 /* Neither the name of Rexx Language Association nor the names */
22 /* of its contributors may be used to endorse or promote products */
23 /* derived from this software without specific prior written permission. */
24 /* */
25 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
26 /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
27 /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
28 /* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
29 /* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
30 /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
31 /* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
32 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */
33 /* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
34 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
35 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
36 /* */
37 /*----------------------------------------------------------------------------*/
38 /******************************************************************************/
39 /* REXX Kernel BlockClass.hpp */
40 /* */
41 /* Primitive Rexx contextual source */
42 /* */
43 /******************************************************************************/
44 #ifndef Included_RexxSourceLiteral
45 #define Included_RexxSourceLiteral
46 
47 #include "ObjectClass.hpp"
48 
49 class PackageClass;
50 class RexxContext;
51 
53 {
54 public:
55  inline void *operator new(size_t, void *ptr) { return ptr; }
56  inline void operator delete(void *, void *) { ; }
57  void *operator new(size_t);
58  inline void operator delete(void *) { ; }
59 
60  void live(size_t);
61  void liveGeneral(int reason);
62  void flatten(RexxEnvelope*);
63 
65  inline RexxSourceLiteral(RESTORETYPE restoreType) { ; };
66 
67  RexxArray *getSource() { return source; }
69  RexxString *getKind() { return kind; }
71  bool isClosure() { return closure; }
72 
74 
75 private:
76  RexxArray *source; // The source between curly brackets, including the tag :xxx if any
78  RexxString *kind; // The kind of source : "r", "m", "cl", etc... derived from the source's tag.
79  RexxObject *rawExecutable; // A routine or method. Its source is the same as this->source, without the tag.
80  bool closure; // true if the source's tag is ::cl...
81 };
82 
83 
84 class RexxBlock : public RexxObject
85 {
86 public:
87  inline void *operator new(size_t, void *ptr) { return ptr; }
88  inline void operator delete(void *, void *) { ; }
89  void *operator new(size_t);
90  inline void operator delete(void *) { ; }
91 
92  void live(size_t);
93  void liveGeneral(int reason);
94  void flatten(RexxEnvelope*);
95 
97  inline RexxBlock(RESTORETYPE restoreType) { ; };
98 
99  RexxObject *newRexx(RexxObject **args, size_t argc, size_t named_argc);
100  RexxObject *copyRexx();
101 
107 
108  static void createInstance();
109  static RexxClass *classInstance; // singleton class instance
110 
111 protected:
114 };
115 
116 
117 class RexxClosure : public RexxObject
118 {
119 public:
120  inline void *operator new(size_t, void *ptr) { return ptr; }
121  inline void operator delete(void *, void *) { ; }
122  void *operator new(size_t);
123  inline void operator delete(void *) { ; }
124 
125  void live(size_t);
126  void liveGeneral(int reason);
128 
130  inline RexxClosure(RESTORETYPE restoreType) { ; };
131 
132  RexxObject *newRexx(RexxObject **args, size_t argc, size_t named_argc);
134 
135  static void createInstance();
136  static RexxClass *classInstance; // singleton class instance
137 };
138 
139 #endif
RESTORETYPE
Definition: ObjectClass.hpp:82
RexxObject * copy()
Definition: ArrayClass.cpp:122
void flatten(RexxEnvelope *)
Definition: BlockClass.cpp:296
RexxString * getKind()
Definition: BlockClass.hpp:105
static void createInstance()
Definition: BlockClass.cpp:189
RexxBlock(RexxSourceLiteral *, RexxContext *)
Definition: BlockClass.cpp:215
void liveGeneral(int reason)
Definition: BlockClass.cpp:286
RexxObject * newRexx(RexxObject **args, size_t argc, size_t named_argc)
Definition: BlockClass.cpp:254
static RexxClass * classInstance
Definition: BlockClass.hpp:109
RexxObject * getVariables()
Definition: BlockClass.hpp:104
RexxDirectory * variables
Definition: BlockClass.hpp:113
RexxObject * getRawExecutable()
Definition: BlockClass.hpp:106
RexxSourceLiteral * sourceLiteral
Definition: BlockClass.hpp:112
RexxBlock(RESTORETYPE restoreType)
Definition: BlockClass.hpp:97
PackageClass * getPackage()
Definition: BlockClass.hpp:103
RexxObject * copyRexx()
Definition: BlockClass.cpp:268
RexxArray * getSource()
Definition: BlockClass.hpp:102
void live(size_t)
Definition: BlockClass.cpp:276
static RexxClass * classInstance
Definition: BlockClass.hpp:136
RexxClosure(RexxSourceLiteral *, RexxContext *)
RexxObject * copyRexx()
void live(size_t)
RexxClosure(RESTORETYPE restoreType)
Definition: BlockClass.hpp:130
static void createInstance()
RexxObject * newRexx(RexxObject **args, size_t argc, size_t named_argc)
void liveGeneral(int reason)
void flatten(RexxEnvelope *)
RexxArray * getSource()
Definition: BlockClass.hpp:67
RexxObject * evaluate(RexxActivation *, RexxExpressionStack *)
Definition: BlockClass.cpp:149
void flatten(RexxEnvelope *)
Definition: BlockClass.cpp:96
void live(size_t)
Definition: BlockClass.cpp:74
RexxString * getKind()
Definition: BlockClass.hpp:69
RexxArray * source
Definition: BlockClass.hpp:76
RexxSourceLiteral(RexxString *, PackageClass *, size_t)
Definition: BlockClass.cpp:112
PackageClass * getPackage()
Definition: BlockClass.hpp:68
void liveGeneral(int reason)
Definition: BlockClass.cpp:85
RexxObject * getRawExecutable()
Definition: BlockClass.hpp:70
PackageClass * package
Definition: BlockClass.hpp:77
RexxSourceLiteral(RESTORETYPE restoreType)
Definition: BlockClass.hpp:65
RexxObject * rawExecutable
Definition: BlockClass.hpp:79
RexxString * kind
Definition: BlockClass.hpp:78