RexxCode.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 RexxCode.hpp */
40 /* */
41 /* Primitive REXX Code Class Definitions */
42 /* */
43 /******************************************************************************/
44 #ifndef Included_RexxCode
45 #define Included_RexxCode
46 
47 #include "SourceFile.hpp"
48 #include "MethodClass.hpp"
49 #include "RoutineClass.hpp"
50 
51  /* various types of call or function */
52  /* calls */
53 #define INTERNAL_ROUTINE 1
54 #define BUILTIN_ROUTINE 2
55 #define EXTERNAL_ROUTINE 3
56 #define DYNAMIC_ROUTINE 4
57 
58 class RexxCode : public BaseCode
59 {
60  public:
61  void *operator new(size_t);
62  inline void *operator new(size_t size, void *ptr) {return ptr;};
63  inline void operator delete(void *) { ; }
64  inline void operator delete(void *, void *) { ; }
65 
66  RexxCode(RexxSource *, RexxInstruction *, RexxDirectory *, size_t, size_t);
67  inline RexxCode(RESTORETYPE restoreType) { ; };
68  void live(size_t);
69  void liveGeneral(int reason);
70  void flatten(RexxEnvelope *);
71  RexxArray * getSource();
74  inline RexxSource *getSourceObject() { return source; }
76  inline RexxDirectory *getLabels() { return labels; }
77  inline size_t getMaxStackSize() { return maxStack; }
78  inline size_t getLocalVariableSize() { return vdictSize; }
83  inline bool isTraceable() { return source->isTraceable(); }
84  inline bool isInterpret() { return source->isInterpret(); }
85  inline RexxString *extract(SourceLocation &l) { return source->extract(l); }
87  inline void install(RexxActivation *activation) { source->install(activation); }
88  inline RexxCode *interpret(RexxString *s, size_t n, RexxActivation *activation) { return source->interpret(s, labels, n, activation); }
89  inline RexxDirectory *getMethods() { return source->getMethods(); };
90  inline RexxDirectory *getRoutines() { return source->getRoutines(); };
92  inline RexxString *resolveProgramName(RexxActivity *activity, RexxString *name) { return source->resolveProgramName(activity, name); }
93  inline void mergeRequired(RexxSource *s) { source->mergeRequired(s); }
94  virtual void run(RexxActivity *, RexxMethod *, RexxObject *, RexxString *, RexxObject **, size_t, size_t, ProtectedObject &);
95  virtual void call(RexxActivity *, RoutineClass *, RexxString *, RexxObject **, size_t, size_t, RexxString *, RexxString *, int, ProtectedObject &);
96  virtual void call(RexxActivity *, RoutineClass *, RexxString *, RexxObject **, size_t, size_t, ProtectedObject &);
97 
98 protected:
99 
100  RexxSource * source; // the source this code belongs to.
101  RexxInstruction * start; /* root of parse tree */
102  RexxDirectory * labels; /* root of label list */
103  size_t maxStack; /* maximum stack depth */
104  size_t vdictSize; /* size of variable dictionary */
105 
106 };
107 #endif
RESTORETYPE
Definition: ObjectClass.hpp:80
RexxArray * getSource()
Definition: RexxCode.cpp:176
RexxObject * setSecurityManager(RexxObject *)
Definition: RexxCode.cpp:222
RexxDirectory * labels
Definition: RexxCode.hpp:102
RexxString * getProgramName()
Definition: RexxCode.cpp:203
void install(RexxActivation *activation)
Definition: RexxCode.hpp:87
void setLocalRoutines(RexxDirectory *r)
Definition: RexxCode.hpp:81
RexxCode * interpret(RexxString *s, size_t n, RexxActivation *activation)
Definition: RexxCode.hpp:88
void flatten(RexxEnvelope *)
Definition: RexxCode.cpp:162
RexxDirectory * getLocalRoutines()
Definition: RexxCode.hpp:79
void setPublicRoutines(RexxDirectory *r)
Definition: RexxCode.hpp:82
bool isInterpret()
Definition: RexxCode.hpp:84
size_t getMaxStackSize()
Definition: RexxCode.hpp:77
void live(size_t)
Definition: RexxCode.cpp:142
RexxCode(RexxSource *, RexxInstruction *, RexxDirectory *, size_t, size_t)
Definition: RexxCode.cpp:59
RexxInstruction * start
Definition: RexxCode.hpp:101
virtual void run(RexxActivity *, RexxMethod *, RexxObject *, RexxString *, RexxObject **, size_t, size_t, ProtectedObject &)
Definition: RexxCode.cpp:120
RexxDirectory * getRoutines()
Definition: RexxCode.hpp:90
RexxDirectory * getMethods()
Definition: RexxCode.hpp:89
RexxInstruction * getFirstInstruction()
Definition: RexxCode.hpp:75
bool isTraceable()
Definition: RexxCode.hpp:83
RexxSource * getSourceObject()
Definition: RexxCode.hpp:74
size_t vdictSize
Definition: RexxCode.hpp:104
RexxString * resolveProgramName(RexxActivity *activity, RexxString *name)
Definition: RexxCode.hpp:92
RexxDirectory * getPublicRoutines()
Definition: RexxCode.hpp:80
RoutineClass * findRoutine(RexxString *n)
Definition: RexxCode.hpp:91
RexxCode(RESTORETYPE restoreType)
Definition: RexxCode.hpp:67
size_t maxStack
Definition: RexxCode.hpp:103
void mergeRequired(RexxSource *s)
Definition: RexxCode.hpp:93
void liveGeneral(int reason)
Definition: RexxCode.cpp:152
RexxString * extract(SourceLocation &l)
Definition: RexxCode.hpp:85
virtual void call(RexxActivity *, RoutineClass *, RexxString *, RexxObject **, size_t, size_t, RexxString *, RexxString *, int, ProtectedObject &)
Definition: RexxCode.cpp:95
RexxDirectory * getLabels()
Definition: RexxCode.hpp:76
RexxSource * source
Definition: RexxCode.hpp:100
SecurityManager * getSecurityManager()
Definition: RexxCode.hpp:86
size_t getLocalVariableSize()
Definition: RexxCode.hpp:78
void install()
RexxDirectory * getPublicRoutines()
Definition: SourceFile.hpp:382
RexxDirectory * getLocalRoutines()
Definition: SourceFile.hpp:381
RexxCode * interpret(RexxString *, RexxDirectory *, size_t, RexxActivation *)
RexxString * resolveProgramName(RexxActivity *activity, RexxString *name)
RexxDirectory * getMethods()
Definition: SourceFile.hpp:304
RexxDirectory * getRoutines()
Definition: SourceFile.hpp:305
SecurityManager * getSecurityManager()
Definition: SourceFile.hpp:379
RoutineClass * findRoutine(RexxString *)
void setPublicRoutines(RexxDirectory *r)
Definition: SourceFile.hpp:384
RexxString * extract(SourceLocation &, bool=false)
bool isInterpret()
Definition: SourceFile.hpp:291
void mergeRequired(RexxSource *)
void setLocalRoutines(RexxDirectory *r)
Definition: SourceFile.hpp:383
bool isTraceable()
Definition: SourceFile.cpp:801