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)  

RexxBehaviour.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.oorexx.org/license.html */
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 RexxBehaviour.hpp */
40 /* */
41 /* Primitive Behaviour Class Definitions */
42 /* */
43 /*******************************************************************************/
44 #ifndef Included_RexxBehaviour
45 #define Included_RexxBehaviour
46 
47 #define INTERNALCLASS (((uintptr_t)1) << ((sizeof(uintptr_t) * 8) - 1))
48 
50  {
51  public:
52  void *operator new(size_t, size_t);
53  inline void *operator new(size_t size, void *ptr) {return ptr;};
54  inline void operator delete(void *) { ; }
55  inline void operator delete(void *, size_t) { }
56  inline void operator delete(void *, void *) { ; }
57 
58  RexxBehaviour(size_t, PCPPM *);
59  inline RexxBehaviour() {;};
60  inline RexxBehaviour(RESTORETYPE restoreType) { ; };
61  void live(size_t);
62  void liveGeneral(int reason);
63  void flatten(RexxEnvelope*);
64  RexxObject *copy();
65  void copyBehaviour(RexxBehaviour *source);
67  RexxMethod *define(const char *, PCPPM, size_t);
68  void addMethod(RexxString *, RexxMethod *);
69  void removeMethod(RexxString *);
74  void restore(RexxBehaviour *);
82  bool checkScope( RexxObject *);
83  void subclass(RexxBehaviour *);
85 
87 
88  void merge( RexxBehaviour *);
90 
91 
92  inline RexxIdentityTable *getScopes() { return this->scopes; };
93  inline RexxTable *getMethodDictionary() { return this->methodDictionary; };
94  inline void setMethodDictionary(RexxTable * m) { OrefSet(this, this->methodDictionary, m); };
97  inline RexxClass *getOwningClass() { return this->owningClass;};
98  inline void setOwningClass(RexxClass *c) { OrefSet(this, this->owningClass, c); };
99 
100  inline void setClassType(size_t n) { classType = (uint16_t)n; }
101  inline size_t getClassType() { return (size_t)classType; }
102  inline bool isPrimitive() { return (behaviourFlags & NON_PRIMITIVE_BEHAVIOUR) == 0; };
103  inline bool isNonPrimitive() { return (behaviourFlags & NON_PRIMITIVE_BEHAVIOUR) != 0; };
104  inline bool isNotResolved() { return (behaviourFlags & BEHAVIOUR_NOT_RESOLVED) != 0; };
105  inline bool isResolved() { return (behaviourFlags & BEHAVIOUR_NOT_RESOLVED) == 0; };
106  inline bool isEnhanced() { return (behaviourFlags & ENHANCED_OBJECT) != 0; };
107  inline bool isInternalClass() { return (behaviourFlags & INTERNAL_CLASS) != 0; };
108  inline bool isTransientClass() { return (behaviourFlags & TRANSIENT_CLASS) != 0; };
115 
117  {
118  uintptr_t behaviourID = (uintptr_t)this->getClassType();
119  // if this is an internal class, normalize this so we can
120  // restore this to the correct value if we add additional internal classes.
121  if (isInternalClass())
122  {
123  behaviourID -= T_Last_Exported_Class;
124  behaviourID |= INTERNALCLASS;
125  }
126  return (RexxBehaviour *)behaviourID;
127  }
128 
130  {
131  uintptr_t behaviourID = (uintptr_t)b;
132  // if this is an internal class, we need to convert back to
133  // the relative internal class id
134  if ((behaviourID & INTERNALCLASS) != 0)
135  {
136  behaviourID &= ~INTERNALCLASS; // turn off the internal marker
137  behaviourID += T_Last_Exported_Class; // turn back into an internal class
138  }
139  return &primitiveBehaviours[behaviourID]; // translate back into proper behaviour
140  }
141 
142  inline PCPPM getOperatorMethod(size_t index) { return operatorMethods[index]; }
143  static inline RexxBehaviour *getPrimitiveBehaviour(size_t index) { return &primitiveBehaviours[index]; }
144  static inline PCPPM *getOperatorMethods(size_t index) { return getPrimitiveBehaviour(index)->operatorMethods; }
145  // table of primitive behaviour objects
147 
148  protected:
149 
150  enum
151  {
153  ENHANCED_OBJECT = 0x0002,
154  INTERNAL_CLASS = 0x0004,
155  TRANSIENT_CLASS = 0x0008,
157  };
158 
159 
160  uint16_t classType; // primitive class identifier
161  uint16_t behaviourFlags; // various behaviour flag types
162  RexxIdentityTable *scopes; /* scopes table */
163  RexxTable *methodDictionary; /* method dictionary */
164  PCPPM *operatorMethods; /* operator look-a-side table */
165  RexxClass *owningClass; /* class that created this object */
166  /* methods added via SETMETHOD */
168 
169  };
170 
171 
172 /******************************************************************************/
173 /* Global Objects - Primitive Behaviour */
174 /******************************************************************************/
175 
176 #include "PrimitiveBehaviourNames.h"
177 
178 #endif
RexxBehaviour::getScopes
RexxIdentityTable * getScopes()
Definition: RexxBehaviour.hpp:92
RexxBehaviour::getSavedPrimitiveBehaviour
RexxBehaviour * getSavedPrimitiveBehaviour()
Definition: RexxBehaviour.hpp:116
RexxBehaviour::flatten
void flatten(RexxEnvelope *)
Definition: RexxBehaviour.cpp:126
RexxBehaviour::resolveNonPrimitiveBehaviour
void resolveNonPrimitiveBehaviour()
Definition: RexxBehaviour.cpp:153
RexxBehaviour::liveGeneral
void liveGeneral(int reason)
Definition: RexxBehaviour.cpp:99
RexxBehaviour::setTransientClass
void setTransientClass()
Definition: RexxBehaviour.hpp:114
RexxBehaviour::getMethods
RexxSupplier * getMethods(RexxObject *scope)
Definition: RexxBehaviour.cpp:560
RexxInternalObject
Definition: ObjectClass.hpp:206
RexxBehaviour::NON_PRIMITIVE_BEHAVIOUR
Definition: RexxBehaviour.hpp:152
OrefSet
#define OrefSet(o, r, v)
Definition: RexxCore.h:94
RexxBehaviour::setResolved
void setResolved()
Definition: RexxBehaviour.hpp:109
RexxBehaviour::primitiveBehaviours
static RexxBehaviour primitiveBehaviours[]
Definition: RexxBehaviour.hpp:146
RexxBehaviour::ENHANCED_OBJECT
Definition: RexxBehaviour.hpp:153
RexxBehaviour::getClassType
size_t getClassType()
Definition: RexxBehaviour.hpp:101
RexxBehaviour::restoreClass
RexxClass * restoreClass()
Definition: RexxBehaviour.cpp:446
RexxBehaviour::methodLookup
RexxMethod * methodLookup(RexxString *)
Definition: RexxBehaviour.cpp:364
RexxBehaviour::behaviourFlags
uint16_t behaviourFlags
Definition: RexxBehaviour.hpp:161
RexxBehaviour::isPrimitive
bool isPrimitive()
Definition: RexxBehaviour.hpp:102
RexxSupplier
Definition: SupplierClass.hpp:47
RexxBehaviour::methodObject
RexxMethod * methodObject(RexxString *)
Definition: RexxBehaviour.cpp:351
RexxBehaviour::isEnhanced
bool isEnhanced()
Definition: RexxBehaviour.hpp:106
RexxEnvelope
Definition: RexxEnvelope.hpp:53
RexxBehaviour::owningClass
RexxClass * owningClass
Definition: RexxBehaviour.hpp:165
RexxBehaviour::getInstanceMethodDictionary
RexxTable * getInstanceMethodDictionary()
Definition: RexxBehaviour.hpp:96
RexxBehaviour::scopes
RexxIdentityTable * scopes
Definition: RexxBehaviour.hpp:162
PrimitiveBehaviourNames.h
RexxBehaviour::instanceMethodDictionary
RexxTable * instanceMethodDictionary
Definition: RexxBehaviour.hpp:167
RexxBehaviour
Definition: RexxBehaviour.hpp:49
RexxBehaviour::getPrimitiveBehaviour
static RexxBehaviour * getPrimitiveBehaviour(size_t index)
Definition: RexxBehaviour.hpp:143
RexxBehaviour::isResolved
bool isResolved()
Definition: RexxBehaviour.hpp:105
RexxBehaviour::superMethod
RexxMethod * superMethod(RexxString *, RexxObject *)
Definition: RexxBehaviour.cpp:485
RexxBehaviour::RexxBehaviour
RexxBehaviour(RESTORETYPE restoreType)
Definition: RexxBehaviour.hpp:60
RexxBehaviour::isTransientClass
bool isTransientClass()
Definition: RexxBehaviour.hpp:108
RexxBehaviour::RexxBehaviour
RexxBehaviour()
Definition: RexxBehaviour.hpp:59
INTERNALCLASS
#define INTERNALCLASS
Definition: RexxBehaviour.hpp:47
RexxBehaviour::methodDictionaryMerge
void methodDictionaryMerge(RexxTable *)
Definition: RexxBehaviour.cpp:690
RexxBehaviour::INTERNAL_CLASS
Definition: RexxBehaviour.hpp:154
RexxBehaviour::getOwningClass
RexxClass * getOwningClass()
Definition: RexxBehaviour.hpp:97
RexxClass
Definition: ClassClass.hpp:49
RexxBehaviour::operatorMethods
PCPPM * operatorMethods
Definition: RexxBehaviour.hpp:164
RexxBehaviour::isNotResolved
bool isNotResolved()
Definition: RexxBehaviour.hpp:104
RexxBehaviour::setInternalClass
void setInternalClass()
Definition: RexxBehaviour.hpp:113
RexxBehaviour::classType
uint16_t classType
Definition: RexxBehaviour.hpp:160
PCPPM
RexxObject *(RexxObject::* PCPPM)()
Definition: ObjectClass.hpp:198
RexxBehaviour::merge
void merge(RexxBehaviour *)
Definition: RexxBehaviour.cpp:657
RexxBehaviour::removeMethod
void removeMethod(RexxString *)
Definition: RexxBehaviour.cpp:301
RexxBehaviour::copy
RexxObject * copy()
Definition: RexxBehaviour.cpp:163
RexxBehaviour::getMethod
RexxMethod * getMethod(RexxString *)
Definition: RexxBehaviour.cpp:385
RexxBehaviour::BEHAVIOUR_NOT_RESOLVED
Definition: RexxBehaviour.hpp:156
RexxBehaviour::copyBehaviour
void copyBehaviour(RexxBehaviour *source)
Definition: RexxBehaviour.cpp:201
RexxBehaviour::checkScope
bool checkScope(RexxObject *)
Definition: RexxBehaviour.cpp:643
RexxBehaviour::isInternalClass
bool isInternalClass()
Definition: RexxBehaviour.hpp:107
RexxBehaviour::setNotResolved
void setNotResolved()
Definition: RexxBehaviour.hpp:110
RexxTable
Definition: TableClass.hpp:49
RexxBehaviour::methodDictionary
RexxTable * methodDictionary
Definition: RexxBehaviour.hpp:163
RexxBehaviour::isNonPrimitive
bool isNonPrimitive()
Definition: RexxBehaviour.hpp:103
RexxBehaviour::addScope
RexxObject * addScope(RexxObject *)
Definition: RexxBehaviour.cpp:610
RexxBehaviour::addMethod
void addMethod(RexxString *, RexxMethod *)
Definition: RexxBehaviour.cpp:319
RexxBehaviour::setMethodDictionary
void setMethodDictionary(RexxTable *m)
Definition: RexxBehaviour.hpp:94
RexxBehaviour::live
void live(size_t)
Definition: RexxBehaviour.cpp:88
RexxBehaviour::restore
void restore(RexxBehaviour *)
Definition: RexxBehaviour.cpp:426
RexxBehaviour::setClassType
void setClassType(size_t n)
Definition: RexxBehaviour.hpp:100
RexxBehaviour::define
RexxObject * define(RexxString *, RexxMethod *)
Definition: RexxBehaviour.cpp:249
RexxBehaviour::deleteMethod
RexxObject * deleteMethod(RexxString *)
Definition: RexxBehaviour.cpp:400
RexxIdentityTable
Definition: IdentityTableClass.hpp:49
T_Last_Exported_Class
Definition: ClassTypeCodes.h:106
RexxBehaviour::setOwningClass
void setOwningClass(RexxClass *c)
Definition: RexxBehaviour.hpp:98
RexxBehaviour::setEnhanced
void setEnhanced()
Definition: RexxBehaviour.hpp:111
RexxBehaviour::setMethodDictionaryScope
void setMethodDictionaryScope(RexxObject *)
Definition: RexxBehaviour.cpp:527
RexxBehaviour::setScopes
RexxObject * setScopes(RexxIdentityTable *)
Definition: RexxBehaviour.cpp:599
RexxBehaviour::restoreSavedPrimitiveBehaviour
static RexxBehaviour * restoreSavedPrimitiveBehaviour(RexxBehaviour *b)
Definition: RexxBehaviour.hpp:129
RexxBehaviour::getOperatorMethod
PCPPM getOperatorMethod(size_t index)
Definition: RexxBehaviour.hpp:142
RESTORETYPE
RESTORETYPE
Definition: ObjectClass.hpp:80
RexxMethod
Definition: MethodClass.hpp:101
RexxBehaviour::TRANSIENT_CLASS
Definition: RexxBehaviour.hpp:155
RexxBehaviour::subclass
void subclass(RexxBehaviour *)
Definition: RexxBehaviour.cpp:415
RexxBehaviour::setNonPrimitive
void setNonPrimitive()
Definition: RexxBehaviour.hpp:112
RexxBehaviour::superScope
RexxObject * superScope(RexxObject *)
Definition: RexxBehaviour.cpp:471
RexxObject
Definition: ObjectClass.hpp:311
RexxBehaviour::getOperatorMethods
static PCPPM * getOperatorMethods(size_t index)
Definition: RexxBehaviour.hpp:144
RexxBehaviour::getMethodDictionary
RexxTable * getMethodDictionary()
Definition: RexxBehaviour.hpp:93
RexxBehaviour::mergeScope
RexxObject * mergeScope(RexxObject *)
Definition: RexxBehaviour.cpp:628
RexxString
Definition: StringClass.hpp:119
RexxBehaviour::setInstanceMethodDictionary
void setInstanceMethodDictionary(RexxTable *m)
Definition: RexxBehaviour.hpp:95