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)  

TranslateDispatcher.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.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 #include "RexxCore.h"
40 #include "TranslateDispatcher.hpp"
41 #include "RoutineClass.hpp"
42 #include "ProtectedObject.hpp"
43 #include "RexxNativeActivation.hpp"
44 
45 
51 {
52  ProtectedSet savedObjects;
53 
54  RoutineClass *program;
55 
56  RexxString *name = OREF_NULLSTRING; // name of the invoked program
57  if (programName != NULL) /* have an actual name? */
58  {
59  /* get string version of the name */
60  name = new_string(programName);
61  }
62 
63  savedObjects.add(name); /* protect from garbage collect */
64 
65  if (instore == NULL) /* no instore request? */
66  {
67  /* go resolve the name */
69  if (fullname == OREF_NULL) /* not found? */
70  {
71  /* got an error here */
73  }
74  savedObjects.add(fullname);
75  /* go translate the image */
76  program = new RoutineClass(fullname);
77  savedObjects.add(program);
78  }
79  else /* have an instore program */
80  {
81  /* go handle instore parms */
82  program = RoutineClass::processInstore(instore, name);
83  if (program == OREF_NULL) /* couldn't get it? */
84  {
85  /* got an error here */
87  }
88  savedObjects.add(program);
89  }
90  if (outputName != NULL) /* want to save this to a file? */
91  {
92  /* go save this method */
93  program->save(outputName);
94  }
95 }
96 
97 
105 {
106  // use the base error handling and set our return code to the negated error code.
108  rc = -r;
109  // process the error to display the error message.
111 }
112 
113 
119 {
120  ProtectedSet savedObjects;
121  RexxString *name = OREF_NULLSTRING; // name of the invoked program
122  if (programName != NULL) /* have an actual name? */
123  {
124  /* get string version of the name */
125  name = new_string(programName);
126  }
127 
128  savedObjects.add(name); /* protect from garbage collect */
129 
130  RXSTRING instore[2];
131 
132  MAKERXSTRING(instore[0], const_cast<char *>(source->strptr), source->strlength);
133  MAKERXSTRING(instore[1], NULL, 0);
134 
135  /* go handle instore parms */
136  RoutineClass *program = RoutineClass::processInstore(instore, name);
137  if (program == OREF_NULL) /* couldn't get it? */
138  {
139  /* got an error here */
141  }
142  // copy the image information back
143  image->strptr = instore[1].strptr;
144  image->strlength = instore[1].strlength;
145 }
146 
147 
155 {
156  // use the base error handling and set our return code to the negated error code.
158  rc = -r;
159 }
160 
TranslateDispatcher::instore
PRXSTRING instore
Definition: TranslateDispatcher.hpp:55
TranslateInstoreDispatcher::source
CONSTRXSTRING * source
Definition: TranslateDispatcher.hpp:70
ActivityDispatcher::handleError
virtual void handleError(wholenumber_t, RexxDirectory *)
Definition: ActivityDispatcher.cpp:62
_RXSTRING::strlength
size_t strlength
Definition: rexx.h:157
ActivityDispatcher::activation
RexxNativeActivation * activation
Definition: ActivityDispatcher.hpp:68
RoutineClass.hpp
RoutineClass
Definition: RoutineClass.hpp:49
_CONSTRXSTRING::strptr
const char * strptr
Definition: rexx.h:163
RexxNativeActivation.hpp
_RXSTRING::strptr
char * strptr
Definition: rexx.h:158
Error_Program_unreadable_name
#define Error_Program_unreadable_name
Definition: RexxErrorCodes.h:58
RoutineClass::save
RexxBuffer * save()
Definition: RoutineClass.cpp:333
reportException
void reportException(wholenumber_t error)
Definition: ActivityManager.hpp:136
RexxActivity::error
wholenumber_t error()
Definition: RexxActivity.cpp:323
TranslateDispatcher::run
virtual void run()
Definition: TranslateDispatcher.cpp:50
ProtectedSet
Definition: ProtectedObject.hpp:170
ProtectedSet::add
void add(RexxObject *)
Definition: ProtectedObject.cpp:44
new_string
RexxString * new_string(const char *s, stringsize_t l)
Definition: StringClass.hpp:524
MAKERXSTRING
#define MAKERXSTRING(r, p, l)
Definition: rexx.h:182
TranslateInstoreDispatcher::image
RXSTRING * image
Definition: TranslateDispatcher.hpp:71
ActivityDispatcher::conditionData
RexxDirectory * conditionData
Definition: ActivityDispatcher.hpp:63
OREF_NULL
#define OREF_NULL
Definition: RexxCore.h:60
_RXSTRING
Definition: rexx.h:156
RexxDirectory
Definition: DirectoryClass.hpp:49
ProtectedObject.hpp
_CONSTRXSTRING::strlength
size_t strlength
Definition: rexx.h:162
TranslateDispatcher::handleError
virtual void handleError(wholenumber_t, RexxDirectory *)
Definition: TranslateDispatcher.cpp:104
Error_Program_unreadable_notfound
#define Error_Program_unreadable_notfound
Definition: RexxErrorCodes.h:60
TranslateInstoreDispatcher::run
virtual void run()
Definition: TranslateDispatcher.cpp:118
TranslateInstoreDispatcher::handleError
virtual void handleError(wholenumber_t, RexxDirectory *)
Definition: TranslateDispatcher.cpp:154
RoutineClass::processInstore
static RoutineClass * processInstore(PRXSTRING instore, RexxString *name)
Definition: RoutineClass.cpp:653
TranslateDispatcher::outputName
const char * outputName
Definition: TranslateDispatcher.hpp:56
wholenumber_t
ssize_t wholenumber_t
Definition: rexx.h:229
ActivityDispatcher::rc
wholenumber_t rc
Definition: ActivityDispatcher.hpp:62
ActivityDispatcher::activity
RexxActivity * activity
Definition: ActivityDispatcher.hpp:67
TranslateDispatcher.hpp
TranslateInstoreDispatcher::programName
const char * programName
Definition: TranslateDispatcher.hpp:69
RexxCore.h
TranslateDispatcher::programName
const char * programName
Definition: TranslateDispatcher.hpp:54
RexxActivity::resolveProgramName
RexxString * resolveProgramName(RexxString *, RexxString *, RexxString *)
Definition: RexxActivity.cpp:3187
RexxString
Definition: StringClass.hpp:119