ooRexx  4.2.0-source
About: ooRexx (Open Object Rexx) is a free implementation of Object Rexx. Object Rexx is an enhancement of the classic Rexx interpreter; a full-featured programming language with a human-oriented syntax.
  Fossies Dox: ooRexx-4.2.0-source.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

ContextClass.cpp
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 */
40 /* */
41 /* Primitive Rexx execution context */
42 /* */
43 /******************************************************************************/
44 #include "RexxCore.h"
45 #include "ContextClass.hpp"
46 #include "RexxActivation.hpp"
47 #include "SupplierClass.hpp"
48 #include "DirectoryClass.hpp"
49 
50 RexxClass *RexxContext::classInstance = OREF_NULL; // singleton class instance
51 
56 {
57  CLASS_CREATE(RexxContext, "RexxContext", RexxClass);
58 }
59 
60 
68 void *RexxContext::operator new(size_t size)
69 {
70  /* Get new object */
71  return new_object(size, T_RexxContext);
72 }
73 
74 
81 {
82  activation = a;
83 }
84 
85 
97 {
98  // we do not allow these to be allocated from Rexx code...
100  return TheNilObject;
101 }
102 
103 
104 void RexxContext::live(size_t liveMark)
105 /******************************************************************************/
106 /* Function: Normal garbage collection live marking */
107 /******************************************************************************/
108 {
109  memory_mark(this->activation);
110 }
111 
112 void RexxContext::liveGeneral(int reason)
113 /******************************************************************************/
114 /* Function: Generalized object marking */
115 /******************************************************************************/
116 {
118 }
119 
121 /******************************************************************************/
122 /* Function: Flatten an object */
123 /******************************************************************************/
124 {
126 
127  newThis->activation = OREF_NULL; // this never should be getting flattened, so sever the connection
128 
130 }
131 
132 
140 {
141  // we do not allow these to be allocated from Rexx code...
143  return TheNilObject;
144 }
145 
146 
151 {
152  if (activation == OREF_NULL)
153  {
155  }
156 }
157 
158 
166 {
167  checkValid();
168  return activation->getPackage();
169 }
170 
171 
178 {
179  checkValid();
180  return new_integer(activation->digits());
181 }
182 
183 
190 {
191  checkValid();
192  return new_integer(activation->fuzz());
193 }
194 
195 
202 {
203  checkValid();
204  return activation->form() == Numerics::FORM_SCIENTIFIC ? OREF_SCIENTIFIC : OREF_ENGINEERING;
205 }
206 
207 
215 {
216  checkValid();
218 }
219 
220 
227 {
228  checkValid();
229  return activation->getExecutable();
230 }
231 
232 
239 {
240  checkValid();
242  size_t size = activation->getMethodArgumentCount();
243  return new (size, arglist) RexxArray;
244 }
245 
246 
253 {
254  checkValid();
255  /* get current trapped condition */
256  RexxObject *conditionobj = activation->getConditionObj();
257  return conditionobj == OREF_NULL ? TheNilObject : conditionobj->copy();
258 }
259 
260 
267 {
268  checkValid();
269  return activation->getContextLine();
270 }
271 
272 
279 {
280  checkValid();
282 }
283 
284 
295 {
296  checkValid();
297  return activation->getCallname();
298 }
299 
306 {
307  checkValid();
308  // we don't want to include the stackframes frame in the list, so ask
309  // that it be skipped.
310  return activation->getStackFrames(true);
311 }
RexxObject::copy
RexxObject * copy()
Definition: ObjectClass.cpp:518
RexxContext::getName
RexxObject * getName()
Definition: ContextClass.cpp:294
RexxArray
Definition: ArrayClass.hpp:100
RexxActivation::getConditionObj
RexxDirectory * getConditionObj()
Definition: RexxActivation.hpp:358
RexxContext::createInstance
static void createInstance()
Definition: ContextClass.cpp:55
RexxActivation::getAllLocalVariables
RexxDirectory * getAllLocalVariables()
Definition: RexxActivation.hpp:459
RexxContext::getVariables
RexxObject * getVariables()
Definition: ContextClass.cpp:214
RexxActivation::getMethodArgumentList
RexxObject ** getMethodArgumentList()
Definition: RexxActivation.hpp:423
new_integer
RexxInteger * new_integer(wholenumber_t v)
Definition: IntegerClass.hpp:198
memory_mark_general
#define memory_mark_general(oref)
Definition: RexxMemory.hpp:437
RexxContext::getArgs
RexxObject * getArgs()
Definition: ContextClass.cpp:238
RexxActivation.hpp
RexxContext::checkValid
void checkValid()
Definition: ContextClass.cpp:150
RexxContext
Definition: ContextClass.hpp:53
RexxContext::getPackage
PackageClass * getPackage()
Definition: ContextClass.cpp:165
SupplierClass.hpp
RexxContext::live
void live(size_t)
Definition: ContextClass.cpp:104
reportException
void reportException(wholenumber_t error)
Definition: ActivityManager.hpp:136
T_RexxContext
Definition: ClassTypeCodes.h:99
Error_Execution_context_not_active
#define Error_Execution_context_not_active
Definition: RexxErrorCodes.h:558
Numerics::FORM_SCIENTIFIC
static const bool FORM_SCIENTIFIC
Definition: Numerics.hpp:76
RexxEnvelope
Definition: RexxEnvelope.hpp:53
RexxContext::newRexx
RexxObject * newRexx(RexxObject **args, size_t argc)
Definition: ContextClass.cpp:96
RexxActivation::getCallname
RexxString * getCallname()
Definition: RexxActivation.hpp:353
RexxActivation::form
bool form()
Definition: RexxActivation.cpp:1929
RexxActivationBase::getExecutable
BaseExecutable * getExecutable()
Definition: ObjectClass.hpp:598
RexxContext::activation
RexxActivation * activation
Definition: ContextClass.hpp:92
RexxContext::getDigits
RexxObject * getDigits()
Definition: ContextClass.cpp:177
RexxActivation::fuzz
size_t fuzz()
Definition: RexxActivation.cpp:1921
OREF_NULL
#define OREF_NULL
Definition: RexxCore.h:60
RexxActivation::getContextLine
RexxObject * getContextLine()
Definition: RexxActivation.cpp:2486
RexxContext::flatten
void flatten(RexxEnvelope *)
Definition: ContextClass.cpp:120
RexxContext::classInstance
static RexxClass * classInstance
Definition: ContextClass.hpp:87
RexxClass
Definition: ClassClass.hpp:49
cleanUpFlatten
#define cleanUpFlatten
Definition: RexxMemory.hpp:432
RexxContext::getStackFrames
RexxObject * getStackFrames()
Definition: ContextClass.cpp:305
RexxContext::getExecutable
RexxObject * getExecutable()
Definition: ContextClass.cpp:226
RexxContext::getFuzz
RexxObject * getFuzz()
Definition: ContextClass.cpp:189
PackageClass
Definition: PackageClass.hpp:48
RexxContext::getRS
RexxObject * getRS()
Definition: ContextClass.cpp:278
ContextClass.hpp
RexxActivation::getMethodArgumentCount
size_t getMethodArgumentCount()
Definition: RexxActivation.hpp:424
CLASS_CREATE
#define CLASS_CREATE(name, id, className)
Definition: RexxMemory.hpp:445
RexxContext::getCondition
RexxObject * getCondition()
Definition: ContextClass.cpp:252
memory_mark
#define memory_mark(oref)
Definition: RexxMemory.hpp:436
RexxActivation
Definition: RexxActivation.hpp:156
Error_Unsupported_copy_method
#define Error_Unsupported_copy_method
Definition: RexxErrorCodes.h:516
RexxActivation::digits
size_t digits()
Definition: RexxActivation.cpp:1913
RexxActivation::getContextReturnStatus
RexxObject * getContextReturnStatus()
Definition: RexxActivation.cpp:2528
setUpFlatten
#define setUpFlatten(type)
Definition: RexxMemory.hpp:427
TheNilObject
#define TheNilObject
Definition: RexxCore.h:180
RexxContext::RexxContext
RexxContext(RexxActivation *)
Definition: ContextClass.cpp:80
RexxActivation::getStackFrames
RexxArray * getStackFrames(bool skipFirst)
Definition: RexxActivation.cpp:4382
RexxCore.h
DirectoryClass.hpp
RexxContext::copyRexx
RexxObject * copyRexx()
Definition: ContextClass.cpp:139
Error_Unsupported_new_method
#define Error_Unsupported_new_method
Definition: RexxErrorCodes.h:513
RexxContext::liveGeneral
void liveGeneral(int reason)
Definition: ContextClass.cpp:112
new_object
RexxObject * new_object(size_t s)
Definition: RexxMemory.hpp:422
RexxContext::getLine
RexxObject * getLine()
Definition: ContextClass.cpp:266
RexxContext::getForm
RexxObject * getForm()
Definition: ContextClass.cpp:201
RexxObject
Definition: ObjectClass.hpp:311
RexxActivation::getPackage
PackageClass * getPackage()
Definition: RexxActivation.cpp:4139