RexxInstruction.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 RexxInstruction.hpp */
40 /* */
41 /* Primitive Abstract Instruction Class Definitions */
42 /* */
43 /******************************************************************************/
44 #ifndef Included_RexxInstruction
45 #define Included_RexxInstruction
46 
47 class RexxInstructionEnd;
49 class RexxSource;
50 class RexxClause;
51 
52 #include "SourceLocation.hpp"
53 
55  public:
56  void *operator new(size_t);
57  inline void *operator new(size_t size, void *objectPtr) { return objectPtr; }
58  inline void operator delete(void *) { }
59  inline void operator delete(void *, void *) { }
60 
61  RexxInstruction(RexxClause *clause, int type);
62  inline RexxInstruction(RESTORETYPE restoreType) { ; };
63  inline RexxInstruction() { ; }
64 
65  void live(size_t);
66  void liveGeneral(int reason);
67  void flatten(RexxEnvelope *);
68  inline const SourceLocation &getLocation() { return instructionLocation; }
70 
71  virtual void execute(RexxActivation *, RexxExpressionStack *) { ; };
72 
73  inline void setNext(RexxInstruction *next) { OrefSet(this, this->nextInstruction, next); };
74  void setStart(size_t line, size_t off) { instructionLocation.setStart(line, off); }
75  void setEnd(size_t line, size_t off) { instructionLocation.setEnd(line, off); }
76  inline void setType(size_t type) { instructionType = (uint16_t)type; };
77  inline size_t getType() { return instructionType; };
78  inline bool isType(size_t type) { return instructionType == type; }
79  inline size_t getLineNumber() { return instructionLocation.getLineNumber(); }
80 
81  uint16_t instructionType; // name of the instruction */
82  uint16_t instructionFlags; // general flag area
83 
84  SourceLocation instructionLocation; // location of the instruction in its source
85  RexxInstruction *nextInstruction; // the next instruction object in the assembled chain.
86 };
87 
88 
89 class RexxDoBlock;
90 
92 public:
94  RexxBlockInstruction(RESTORETYPE restoreType) { ; };
95 
96  virtual bool isLabel(RexxString *) { return false; }
97  virtual RexxString *getLabel() { return OREF_NULL; };
98  virtual bool isLoop() { return false; };
99  virtual void matchEnd(RexxInstructionEnd *, RexxSource *) { ; };
100  virtual void terminate(RexxActivation *, RexxDoBlock *) { ; };
101 };
102 
103 
105  public:
107  RexxInstructionSet(RESTORETYPE restoreType) { ; };
108 
110 };
111 
113  public:
116 
117  void live(size_t);
118  void liveGeneral(int reason);
119  void flatten(RexxEnvelope *);
120 
121  RexxObject *expression; /* expression to evaluate */
122 };
123 
124 // a convenience macro for initializing instruction/expression objects.
125 // for many of the instructions, they have a variable size array
126 // that are initialized in reverse order using items pulled from a
127 // provided queue. This simplifies this initialization process and
128 // ensures it is done correctly. NOTE: This decrements the count
129 // variable so make sure you use the one from the argument list!!!!!!
130 
131 #define initializeObjectArray(count, array, type, queue) \
132 { \
133  while (count > 0) \
134  { \
135  array[--count] = (type *)queue->pop(); \
136  } \
137 }
138 
139 #endif
RESTORETYPE
Definition: ObjectClass.hpp:82
#define OREF_NULL
Definition: RexxCore.h:61
#define OrefSet(o, r, v)
Definition: RexxCore.h:101
virtual bool isLabel(RexxString *)
virtual void terminate(RexxActivation *, RexxDoBlock *)
virtual RexxString * getLabel()
virtual void matchEnd(RexxInstructionEnd *, RexxSource *)
RexxBlockInstruction(RESTORETYPE restoreType)
RexxInstructionExpression(RESTORETYPE restoreType)
void flatten(RexxEnvelope *)
void live(size_t)
void setEnd(size_t line, size_t off)
SourceLocation instructionLocation
const SourceLocation & getLocation()
virtual void execute(RexxActivation *, RexxExpressionStack *)
void setLocation(SourceLocation &l)
uint16_t instructionType
void setNext(RexxInstruction *next)
void flatten(RexxEnvelope *)
RexxInstruction(RESTORETYPE restoreType)
uint16_t instructionFlags
void setType(size_t type)
RexxInstruction * nextInstruction
void setStart(size_t line, size_t off)
bool isType(size_t type)
void liveGeneral(int reason)
RexxInstructionSet(RESTORETYPE restoreType)
virtual void setEndInstruction(RexxInstructionEndIf *)
size_t getLineNumber() const
void setEnd(SourceLocation &l)
void setStart(SourceLocation &l)
int type
Definition: cmdparse.cpp:1888
char line[LINEBUFSIZE]
unsigned short uint16_t