Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Right-click on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: <bigrixx@us...> - 2008-02-03 14:15:32
|
Revision: 2333 http://oorexx.svn.sourceforge.net/oorexx/?rev=2333&view=rev Author: bigrixx Date: 2008-02-03 06:15:37 -0800 (Sun, 03 Feb 2008) Log Message: ----------- svn error fixup Added Paths: ----------- sandbox/rick/opt/kernel/api/ sandbox/rick/opt/kernel/api/CallContextStubs.cpp sandbox/rick/opt/kernel/api/ContextApi.hpp sandbox/rick/opt/kernel/api/InterpreterAPI.cpp sandbox/rick/opt/kernel/api/InterpreterInstanceStubs.cpp sandbox/rick/opt/kernel/api/MethodContextStubs.cpp sandbox/rick/opt/kernel/api/ThreadContextStubs.cpp sandbox/rick/opt/kernel/instructions/RequiresDirective.cpp sandbox/rick/opt/kernel/instructions/RequiresDirective.hpp sandbox/rick/opt/kernel/messages/ApiErrorCodes.xsl sandbox/rick/opt/kernel/platform/unix/SysInterpreterInstance.cpp sandbox/rick/opt/kernel/platform/unix/SysInterpreterInstance.hpp sandbox/rick/opt/kernel/platform/unix/SysLibrary.cpp sandbox/rick/opt/kernel/platform/unix/SysLibrary.hpp sandbox/rick/opt/kernel/platform/windows/SysInterpreterInstance.cpp sandbox/rick/opt/kernel/platform/windows/SysInterpreterInstance.hpp sandbox/rick/opt/kernel/platform/windows/SysLibrary.cpp sandbox/rick/opt/kernel/platform/windows/SysLibrary.hpp sandbox/rick/opt/kernel/runtime/ActivationApiContexts.hpp Removed Paths: ------------- sandbox/rick/opt/kernel/runtime/LibraryManager.cpp sandbox/rick/opt/kernel/runtime/LibraryManager.hpp Added: sandbox/rick/opt/kernel/api/CallContextStubs.cpp =================================================================== --- sandbox/rick/opt/kernel/api/CallContextStubs.cpp (rev 0) +++ sandbox/rick/opt/kernel/api/CallContextStubs.cpp 2008-02-03 14:15:37 UTC (rev 2333) @@ -0,0 +1,272 @@ +/*----------------------------------------------------------------------------*/ +/* */ +/* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */ +/* Copyright (c) 2005-2006 Rexx Language Association. All rights reserved. */ +/* */ +/* This program and the accompanying materials are made available under */ +/* the terms of the Common Public License v1.0 which accompanies this */ +/* distribution. A copy is also available at the following address: */ +/* http://www.ibm.com/developerworks/oss/CPLv1.0.htm */ +/* */ +/* Redistribution and use in source and binary forms, with or */ +/* without modification, are permitted provided that the following */ +/* conditions are met: */ +/* */ +/* Redistributions of source code must retain the above copyright */ +/* notice, this list of conditions and the following disclaimer. */ +/* Redistributions in binary form must reproduce the above copyright */ +/* notice, this list of conditions and the following disclaimer in */ +/* the documentation and/or other materials provided with the distribution. */ +/* */ +/* Neither the name of Rexx Language Association nor the names */ +/* of its contributors may be used to endorse or promote products */ +/* derived from this software without specific prior written permission. */ +/* */ +/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ +/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ +/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */ +/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ +/* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ +/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */ +/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */ +/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */ +/* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */ +/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */ +/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/* */ +/*----------------------------------------------------------------------------*/ +/******************************************************************************/ +/* REXX API support */ +/* */ +/* Stub functions for all APIs accessed via the NativeMethodContext */ +/* */ +/******************************************************************************/ + +#include "RexxCore.h" +#include "ContextApi.hpp" +#include "RexxNativeActivation.hpp" +#include "SupplierClass.hpp" +#include "Interpreter.hpp" + +BEGIN_EXTERN_C() + +RexxArrayObject RexxEntry GetCallArguments(RexxCallContext *c) +{ + ApiContext context(c); + try + { + return context.context->getArguments(); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +RexxObjectPtr RexxEntry GetCallArgument(RexxCallContext *c, RexxUnsignedNumber i) +{ + ApiContext context(c); + try + { + return context.context->getArgument(i); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +void RexxEntry SetContextVariable(RexxCallContext *c, RexxStringPointer n, RexxObjectPtr v) +{ + ApiContext context(c); + try + { + context.context->setContextVariable((stringchar_t *)n, (RexxObject *)v); + } + catch (ActivityException) + { + } +} + +RexxObjectPtr RexxEntry GetContextVariable(RexxCallContext *c, RexxStringPointer n) +{ + ApiContext context(c); + try + { + return context.context->getContextVariable((stringchar_t *)n); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +void RexxEntry DropContextVariable(RexxCallContext *c, RexxStringPointer n) +{ + ApiContext context(c); + try + { + context.context->dropContextVariable((stringchar_t *)n); + } + catch (ActivityException) + { + } +} + +RexxSupplierObject RexxEntry GetAllContextVariables(RexxCallContext *c) +{ + ApiContext context(c); + try + { + return (RexxSupplierObject)context.ret(context.context->getAllContextVariables()); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +RexxStemObject RexxEntry ResolveStemVariable(RexxCallContext *c, RexxObjectPtr s) +{ + ApiContext context(c); + try + { + return (RexxStemObject)context.context->resolveStemVariable((RexxObject *)s); + } + catch (ActivityException) + { + // this may throw an exception, so clear it out. The null return is the + // failure indication. + context.context->setConditionInfo(OREF_NULL); + } + return NULLOBJECT; +} + +void RexxEntry InvalidRoutine(RexxCallContext *c) +{ + ApiContext context(c); + try + { + // raise an exception which will be reraised when the caller returns. + reportException(Error_Incorrect_call); + } + catch (ActivityException) + { + } +} + +void RexxEntry SetExitContextVariable(RexxExitContext *c, RexxStringPointer n, RexxObjectPtr v) +{ + ApiContext context(c); + try + { + context.context->setContextVariable((stringchar_t *)n, (RexxObject *)v); + } + catch (ActivityException) + { + } +} + +RexxObjectPtr RexxEntry GetExitContextVariable(RexxExitContext *c, RexxStringPointer n) +{ + ApiContext context(c); + try + { + return context.context->getContextVariable((stringchar_t *)n); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +void RexxEntry DropExitContextVariable(RexxExitContext *c, RexxStringPointer n) +{ + ApiContext context(c); + try + { + context.context->dropContextVariable((stringchar_t *)n); + } + catch (ActivityException) + { + } +} + +RexxSupplierObject RexxEntry GetAllExitContextVariables(RexxExitContext *c) +{ + ApiContext context(c); + try + { + return (RexxSupplierObject)context.ret(context.context->getAllContextVariables()); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +wholenumber_t RexxEntry GetContextDigits(RexxCallContext *c) +{ + ApiContext context(c); + try + { + return numberDigits(); + } + catch (ActivityException) + { + } + return 0; +} +wholenumber_t RexxEntry GetContextFuzz(RexxCallContext *c) +{ + ApiContext context(c); + try + { + return numberFuzz(); + } + catch (ActivityException) + { + } + return 0; + +} +RexxBoolean RexxEntry GetContextForm(RexxCallContext *c) +{ + ApiContext context(c); + try + { + return numberForm() ? TRUE : FALSE; + } + catch (ActivityException) + { + } + return FALSE; +} + +END_EXTERN_C() + +CallContextInterface RexxActivity::callContextFunctions = +{ + CALL_INTERFACE_VERSION, + GetCallArguments, + GetCallArgument, + SetContextVariable, + GetContextVariable, + DropContextVariable, + GetAllContextVariables, + ResolveStemVariable, + InvalidRoutine, + GetContextDigits, + GetContextFuzz, + GetContextForm +}; + +ExitContextInterface RexxActivity::exitContextFunctions = +{ + EXIT_INTERFACE_VERSION, + SetExitContextVariable, + GetExitContextVariable, + DropExitContextVariable, + GetAllExitContextVariables, +}; + Property changes on: sandbox/rick/opt/kernel/api/CallContextStubs.cpp ___________________________________________________________________ Name: svn:eol-style + native Added: sandbox/rick/opt/kernel/api/ContextApi.hpp =================================================================== --- sandbox/rick/opt/kernel/api/ContextApi.hpp (rev 0) +++ sandbox/rick/opt/kernel/api/ContextApi.hpp 2008-02-03 14:15:37 UTC (rev 2333) @@ -0,0 +1,163 @@ +/*----------------------------------------------------------------------------*/ +/* */ +/* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */ +/* Copyright (c) 2005-2006 Rexx Language Association. All rights reserved. */ +/* */ +/* This program and the accompanying materials are made available under */ +/* the terms of the Common Public License v1.0 which accompanies this */ +/* distribution. A copy is also available at the following address: */ +/* http://www.ibm.com/developerworks/oss/CPLv1.0.htm */ +/* */ +/* Redistribution and use in source and binary forms, with or */ +/* without modification, are permitted provided that the following */ +/* conditions are met: */ +/* */ +/* Redistributions of source code must retain the above copyright */ +/* notice, this list of conditions and the following disclaimer. */ +/* Redistributions in binary form must reproduce the above copyright */ +/* notice, this list of conditions and the following disclaimer in */ +/* the documentation and/or other materials provided with the distribution. */ +/* */ +/* Neither the name of Rexx Language Association nor the names */ +/* of its contributors may be used to endorse or promote products */ +/* derived from this software without specific prior written permission. */ +/* */ +/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ +/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ +/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */ +/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ +/* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ +/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */ +/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */ +/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */ +/* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */ +/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */ +/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/* */ +/*----------------------------------------------------------------------------*/ +/******************************************************************************/ +/* REXX API support */ +/* */ +/* Stub functions for all APIs accessed via the NativeFunctionContext */ +/* */ +/******************************************************************************/ + +#ifndef ContextApi_Included +#define ContextApi_Included + +#include "RexxCore.h" +#include "RexxNativeActivation.hpp" +#include "ActivationApiContexts.hpp" +#include "RexxActivity.hpp" + +/** + * A stack-based API context object used for API stubs. + */ +class ApiContext +{ +public: + /** + * Initialize an API context from a thread context. + * + * @param c The source context. + */ + inline ApiContext(RexxThreadContext *c) + { + activity = contextToActivity(c); + context = activity->getApiContext(); + activity->activate(); + } + + /** + * Initialize an API context from a call context. + * + * @param c The source context. + */ + inline ApiContext(RexxCallContext *c) + { + activity = contextToActivity(c); + context = contextToActivation(c); + activity->activate(); + } + + /** + * Initialize an API context from an exit context. + * + * @param c The source context. + */ + inline ApiContext(RexxExitContext *c) + { + activity = contextToActivity(c); + context = contextToActivation(c); + activity->activate(); + } + + /** + * Initialize an API context from a method context. + * + * @param c The source context. + */ + inline ApiContext(RexxMethodContext *c) + { + activity = contextToActivity(c); + context = contextToActivation(c); + activity->activate(); + } + + /** + * Destructor for an API context. Releases the interpreter + * access lock on exit. + */ + inline ~ApiContext() + { + activity->deactivate(); + } + + inline RexxObjectPtr ret(RexxObject *o) + { + activity->createLocalReference(o); + return (RexxObjectPtr)o; + } + + /** + * The activity used for the API callback. + */ + RexxActivity *activity; + /** + * The top-level API context. + */ + RexxNativeActivation *context; +}; + + +/** + * A stack-based API context object used for instance stubs. + */ +class InstanceApiContext +{ +public: + /** + * Initialize an API context from an instance context. + * + * @param c The source context. + */ + inline InstanceApiContext(RexxInstance *c) + { + instance = (InterpreterInstance *)c; + } + + /** + * Destructor for an API context. Releases the interpreter + * access lock on exit. + */ + inline ~InstanceApiContext() + { + } + + /** + * The top-level API context. + */ + InterpreterInstance *instance; +}; + +#endif Property changes on: sandbox/rick/opt/kernel/api/ContextApi.hpp ___________________________________________________________________ Name: svn:eol-style + native Added: sandbox/rick/opt/kernel/api/InterpreterAPI.cpp =================================================================== --- sandbox/rick/opt/kernel/api/InterpreterAPI.cpp (rev 0) +++ sandbox/rick/opt/kernel/api/InterpreterAPI.cpp 2008-02-03 14:15:37 UTC (rev 2333) @@ -0,0 +1,530 @@ +/*----------------------------------------------------------------------------*/ +/* */ +/* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */ +/* Copyright (c) 2005-2006 Rexx Language Association. All rights reserved. */ +/* */ +/* This program and the accompanying materials are made available under */ +/* the terms of the Common Public License v1.0 which accompanies this */ +/* distribution. A copy is also available at the following address: */ +/* http://www.oorexx.org/license.html */ +/* */ +/* Redistribution and use in source and binary forms, with or */ +/* without modification, are permitted provided that the following */ +/* conditions are met: */ +/* */ +/* Redistributions of source code must retain the above copyright */ +/* notice, this list of conditions and the following disclaimer. */ +/* Redistributions in binary form must reproduce the above copyright */ +/* notice, this list of conditions and the following disclaimer in */ +/* the documentation and/or other materials provided with the distribution. */ +/* */ +/* Neither the name of Rexx Language Association nor the names */ +/* of its contributors may be used to endorse or promote products */ +/* derived from this software without specific prior written permission. */ +/* */ +/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ +/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ +/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */ +/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ +/* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ +/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */ +/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */ +/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */ +/* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */ +/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */ +/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/* */ +/*----------------------------------------------------------------------------*/ +/******************************************************************************/ +/* REXX Kernel */ +/* */ +/* Startup */ +/* */ +/******************************************************************************/ +#include <string.h> +#include <signal.h> +#include <stdlib.h> + +#include "RexxCore.h" +#include "RexxMemory.hpp" +#include "StringClass.hpp" +#include "DirectoryClass.hpp" +#include "RexxActivity.hpp" +#include "ActivityManager.hpp" +#include "MethodClass.hpp" +#include "RexxNativeAPI.h" +#include "StackClass.hpp" +#include "Interpreter.hpp" +#include "TranslateDispatcher.hpp" +#include "RexxStartDispatcher.hpp" +#include "CreateMethodDispatcher.hpp" +#include "InterpreterInstance.hpp" +#include "RexxNativeActivation.hpp" +#include "RexxInternalApis.h" + + +int REXXENTRY RexxTerminate() +/******************************************************************************/ +/* Function: Terminate the REXX interpreter...will only terminate if the */ +/* call nesting level has reached zero. */ +/******************************************************************************/ +{ + // terminate and clean up the interpreter runtime. This only works + // if there are no active instances + return Interpreter::terminateInterpreter() ? 0 : 1; +} + +int REXXENTRY RexxInitialize () +/******************************************************************************/ +/* Function: Perform main kernel initializations */ +/******************************************************************************/ +{ + // start this up for normal execution + Interpreter::startInterpreter(Interpreter::RUN_MODE); + // this always returns true + return true; +} + +int REXXENTRY RexxQuery () +/******************************************************************************/ +/* Function: Determine if the REXX interpreter is initialized and active */ +/******************************************************************************/ +{ + // see if we have an active environment + return Interpreter::isActive(); +} + + +/** + * Create the Rexx saved image during build processing. + * + * @return Nothing + */ +void REXXENTRY RexxCreateInterpreterImage() +{ + // start this up and save the image. This never returns to here + Interpreter::startInterpreter(Interpreter::SAVE_IMAGE_MODE); +} + + + +/******************************************************************************/ +/* Name: RexxMain */ +/* */ +/* Arguments: argcount - Number of args in arglist */ +/* arglist - Array of args (array of RXSTRINGs) */ +/* programname - REXX program to run */ +/* instore - Instore array (array of 2 RXSTRINGs) */ +/* envname - Initial cmd environment */ +/* calltype - How the program is called */ +/* exits - Array of system exit names (array of RXSTRINGs) */ +/* */ +/* Returned: result - Result returned from program */ +/* rc - Return code from program */ +/* */ +/* Notes: Primary path into Object REXX. Makes sure Object REXX is up */ +/* and runs the requested program. */ +/* */ +/******************************************************************************/ +int REXXENTRY RexxStart( + size_t argcount, /* Number of args in arglist */ + PCONSTRXSTRING arglist, /* Array of args */ + const char *programname, /* REXX program to run */ + PRXSTRING instore, /* Instore array */ + const char *envname, /* Initial cmd environment */ + int calltype, /* How the program is called */ + PRXSYSEXIT exits, /* Array of system exit names */ + short * retcode, /* Integer form of result */ + PRXSTRING result) /* Result returned from program */ +{ + if (calltype == RXCOMMAND && argcount == 1 && arglist[0].strptr != NULL && StringUtil::caselessCompare(arglist[0].strptr, "//T", arglist[0].strlength) == 0) + { + TranslateDispatcher arguments(exits); + arguments.programName = programname; + arguments.instore = instore; + // this just translates and gives the error, potentially returning + // the instore image + arguments.outputName = NULL; + // go run this program + arguments.invoke(); + + return (int)arguments.rc; /* return the error code (negated) */ + } + + + // this is the dispatcher that handles the actual + // interpreter call. This gets all of the RexxStart arguments, then + // gets dispatched on the other side of the interpreter boundary + RexxStartDispatcher arguments(exits, envname); + /* copy all of the arguments into */ + /* the info control block, which is */ + /* passed across the kernel boundary */ + /* into the real RexxStart method */ + /* this is a real execution */ + arguments.argcount = argcount; + arguments.arglist = arglist; + arguments.programName = programname; + arguments.instore = instore; + arguments.calltype = calltype; + arguments.retcode = 0; + arguments.result = result; + + // go run this program + arguments.invoke(); + *retcode = arguments.retcode; + + return (int)arguments.rc; /* return the error code (negated) */ +} + + + +/** + * Translate a program and store the translated results in an + * external file. + * + * @param inFile The input source file. + * @param outFile The output source. + * @param exits The exits to use during the translation process. + * + * @return The error return code (if any). + */ +RexxReturnCode REXXENTRY RexxTranslateProgram(const char *inFile, const char *outFile, PRXSYSEXIT exits) +{ + TranslateDispatcher arguments(exits); + // this gets processed from disk, always. + arguments.programName = inFile; + arguments.instore = NULL; + // this just translates and gives the error, potentially returning + // the instore image + arguments.outputName = outFile; + // go run this program + arguments.invoke(); + + return (RexxReturnCode)arguments.rc; /* return the error code (negated) */ +} + + +/** + * Create a new stripting context used for RexxRunMethod, et. al. + * + * @param contextName + * The name of the scripting engine context. + */ +void REXXENTRY RexxCreateScriptContext(const char *contextName) +{ + // Get an instance. This also gives the root activity of the instance + // the kernel lock. + InstanceBlock instance; + // now create a directory and hang it off of the local environment. This + // will persist in the environment until the entire interpreter environment is + // terminated. + RexxString *context = new_string(contextName); + ActivityManager::localEnvironment->put(new_directory(), context); +} + + +/** + * Destroy a script context created using RexxCreateScriptContext. + * + * @param contextName + * The name of the target context. + * + * @return nothing. + */ +void REXXENTRY RexxDestroyScriptContext(const char *contextName) +{ + // Get an instance. This also gives the root activity of the instance + // the kernel lock. + InstanceBlock instance; + + // delete the named context from the local environment. + RexxString *context = new_string(contextName); + ActivityManager::localEnvironment->remove(context); +} + + +/** + * Release an object reference stored within the named scripting + * context. + * + * @param contextName + * The name of the context. + * @param obj The object reference to release. + * + * @return true if this object was held in the target context, false if + * it was not found. + */ +int REXXENTRY RexxReleaseScriptReference(const char *contextName, REXXOBJECT obj) +{ + // Get an instance. This also gives the root activity of the instance + // the kernel lock. + InstanceBlock instance; + + // delete the named context from the local environment. + RexxString *context = new_string(contextName); + RexxDirectory *locked_objects = (RexxDirectory *)ActivityManager::localEnvironment->at(context); + // the value used in our directory is the string value of the + // method pointer + char buffer[32]; + sprintf(buffer, "0x%p", obj); + REXXOBJECT oldObject = locked_objects->remove(new_string(buffer)); + + // the return code indicates the removed object matches the input object + return oldObject == obj; +} + + +/** + * Create a new invokable method within an given scripting + * context. + * + * @param context The scripting context name. + * @param sourceData The source for the program to transform into a method. + * @param pmethod The returned method object reference. + * @param pRexxCondData + * Any error condition data returned for a translation failure. + * + * @return The translation return code. + */ +RexxReturnCode REXXENTRY RexxCreateMethod(const char *context, PCONSTRXSTRING sourceData, + REXXOBJECT *pmethod, RexxConditionData *pRexxCondData) +{ + // create the dispatcher + CreateMethodDispatcher arguments(pRexxCondData); + + arguments.contextName = context; + arguments.programBuffer = *sourceData; + arguments.translatedMethod = NULL; + + // go perform the operation + arguments.invoke(); + // fill in the return value + *pmethod = arguments.translatedMethod; + + return (RexxReturnCode)arguments.rc; /* return the error code */ +} + + +/** + * Run a method in a scripting context. + * + * @param context The name of the script context (used to anchor returned results). + * @param method The method to run. + * @param callbackArgs + * Opaque argument function used by the argument callback for + * marshaling arguments into ooRexx objects. + * @param callbackFunction + * The callback function used for argument marshalling. + * @param exit_list The set of exits used to run this method. + * @param presult The return result value. + * @param securityManager + * The security manager to use for running this method. + * @param pRexxCondData + * Any error condition information returned to the caller. + * + * @return The return code from running this program (0 indicates success). + */ +RexxReturnCode REXXENTRY RexxRunMethod(const char * context, REXXOBJECT method, void * callbackArgs, + REXXOBJECT (REXXENTRY *callbackFunction)(void *), PRXSYSEXIT exit_list, REXXOBJECT *presult, + REXXOBJECT securityManager, RexxConditionData *pRexxCondData) /* returned condition data */ +{ + RunMethodDispatcher arguments(exit_list, pRexxCondData); + + arguments.contextName = context; + arguments.method = method; + arguments.callbackArguments = callbackArgs; + arguments.argumentCallback = callbackFunction; + arguments.securityManager = securityManager; + + // make the call + arguments.invoke(); + // fill in the return value + *presult = arguments.result; + + return (RexxReturnCode)arguments.rc; /* return the error code */ +} + + +/** + * Retrieve the interpreter version information. + * + * @return + */ +char *REXXENTRY RexxGetVersionInformation() +{ + char ver[100]; + sprintf( ver, " %d.%d.%d", ORX_VER, ORX_REL, ORX_MOD ); + char vbuf0[] = "Open Object Rexx %s Version"; + #ifdef _DEBUG + char vbuf1[] = " - Internal Test Version\nBuild date: "; + #else + char vbuf1[] = "\nBuild date: "; + #endif + char vbuf2[] = "\nCopyright (c) IBM Corporation 1995, 2004.\nCopyright (c) RexxLA 2005-2008.\nAll Rights Reserved."; + char vbuf3[] = "\nThis program and the accompanying materials"; + char vbuf4[] = "\nare made available under the terms of the Common Public License v1.0"; + char vbuf5[] = "\nwhich accompanies this distribution."; + char vbuf6[] = "\nhttp://www.oorexx.org/license.html";; + size_t s0 = strlen(vbuf0); + size_t s1 = strlen(vbuf1); + size_t s2 = strlen(vbuf2); + size_t s3 = strlen(vbuf3); + size_t s4 = strlen(vbuf4); + size_t s5 = strlen(vbuf5); + size_t s6 = strlen(vbuf6); + size_t sd = strlen(__DATE__); + size_t sv = strlen(ver); + char *ptr = (char *)SysAllocateResultMemory(sv+s0+s1+s2+s3+s4+s5+s6+sd+1); + if (ptr) + { + sprintf(ptr, "%s%s%s%s%s%s%s%s%s", vbuf0, ver, vbuf1, __DATE__, vbuf2, vbuf3, vbuf4, vbuf5, vbuf6); + } + return ptr; +} + + +/** + * Raise a halt condition for a target thread. + * + * @param threadid The target threadid. + * + * @return RXARI_OK if this worked, RXARI_NOT_FOUND if the thread isn't + * active. + */ +RexxReturnCode REXXENTRY RexxHaltThread(thread_id_t threadid) +{ + if (RexxQuery()) + { /* Are we up? */ + if (!ActivityManager::haltActivity(threadid, OREF_NULL)) + { + return (RXARI_NOT_FOUND); /* Couldn't find threadid */ + } + return (RXARI_OK); + } + return RXARI_NOT_FOUND; /* REXX not running, error... */ +} + + +/** + * Compatibility function for doing a RexxHaltThread(). + * + * @param procid The process id (ignored). + * @param threadid The target threadid + * + * @return the success/failure return code. + */ +RexxReturnCode REXXENTRY RexxSetHalt(process_id_t procid, thread_id_t threadid) +{ + return RexxHaltThread(threadid); +} + + +/** + * Turn on tracing for a given interpreter thread. + * + * @param threadid The target thread identifier. + * + * @return the success/failure return code. + */ +RexxReturnCode REXXENTRY RexxSetThreadTrace(thread_id_t threadid) +{ + if (RexxQuery()) + { + if (!ActivityManager::setActivityTrace(threadid, true)) + { + return (RXARI_NOT_FOUND); /* Couldn't find threadid */ + } + return (RXARI_OK); + } + return RXARI_NOT_FOUND; /* REXX not running, error... */ +} + + +/** + * Reset the external trace for a target thread. + * + * @param threadid The target thread id. + * + * @return The success/failure indicator. + */ +RexxReturnCode REXXENTRY RexxResetThreadTrace(thread_id_t threadid) +{ + if (RexxQuery()) + { + if (!ActivityManager::setActivityTrace(threadid, false)) + { + return (RXARI_NOT_FOUND); /* Couldn't find threadid */ + } + return (RXARI_OK); + } + return RXARI_NOT_FOUND; /* REXX not running, error... */ +} + + +/** + * Compatibility stub for the old signature of RexxSetTrace. + * + * @param procid The process id (ignored). + * @param threadid The target thread identifier. + * + * @return the success/failure return code. + */ +RexxReturnCode REXXENTRY RexxSetTrace(process_id_t procid, thread_id_t threadid) +{ + return RexxSetThreadTrace(threadid); +} + + +/** + * The compatibility stub for the reset trace API. + * + * @param procid The target process id (ignored). + * @param threadid The thread id of the target thread. + * + * @return The success/failure indicator. + */ +RexxReturnCode REXXENTRY RexxResetTrace(process_id_t procid, thread_id_t threadid) +{ + return RexxResetThreadTrace(threadid); +} + + +/** + * Retrieve the current digits setting for an external context. + * + * @param precision The current precision. + */ +size_t REXXENTRY RexxGetCurrentPrecision() +{ + NativeContextBlock context; + // get the digits setting from the current context. + return context.self->digits(); +} + + +/** + * Create an interpreter instance at the API level. + * + * @param instance The returned instance pointer. + * @param context The initial thread context for this instance. + * @param exits A list of user exits to be used for this context. + * @param userData A pointer to a user defined data area. + * + * @return RXAPI_OK if the instance was created, RXAPI_MEMFAIL for any + * creation errors. + */ +RexxReturnCode RexxEntry RexxCreateInterpreter(RexxInstance **instance, RexxThreadContext **context, RexxExitCallback *exits, RexxOption *options) +{ + ExitHandler handlers[RXNOOFEXITS + 1]; // our set of exit handlers + // do we have exits? resolve these before creating the instance + if (exits != NULL) + { + for (int i = 0; exits[i].exit_code != RXENDLST; i++) + { + // resolve the entry point and call style information + handlers[exits[i].exit_code].setEntryPoint(exits[i].entry_point); + } + } + return RexxInterpreter::createInstance(instance, context, handlers, options) ? RXAPI_OK : RXAPI_MEMFAIL; +} + Property changes on: sandbox/rick/opt/kernel/api/InterpreterAPI.cpp ___________________________________________________________________ Name: svn:eol-style + native Added: sandbox/rick/opt/kernel/api/InterpreterInstanceStubs.cpp =================================================================== --- sandbox/rick/opt/kernel/api/InterpreterInstanceStubs.cpp (rev 0) +++ sandbox/rick/opt/kernel/api/InterpreterInstanceStubs.cpp 2008-02-03 14:15:37 UTC (rev 2333) @@ -0,0 +1,92 @@ +/*----------------------------------------------------------------------------*/ +/* */ +/* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */ +/* Copyright (c) 2005-2006 Rexx Language Association. All rights reserved. */ +/* */ +/* This program and the accompanying materials are made available under */ +/* the terms of the Common Public License v1.0 which accompanies this */ +/* distribution. A copy is also available at the following address: */ +/* http://www.ibm.com/developerworks/oss/CPLv1.0.htm */ +/* */ +/* Redistribution and use in source and binary forms, with or */ +/* without modification, are permitted provided that the following */ +/* conditions are met: */ +/* */ +/* Redistributions of source code must retain the above copyright */ +/* notice, this list of conditions and the following disclaimer. */ +/* Redistributions in binary form must reproduce the above copyright */ +/* notice, this list of conditions and the following disclaimer in */ +/* the documentation and/or other materials provided with the distribution. */ +/* */ +/* Neither the name of Rexx Language Association nor the names */ +/* of its contributors may be used to endorse or promote products */ +/* derived from this software without specific prior written permission. */ +/* */ +/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ +/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ +/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */ +/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ +/* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ +/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */ +/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */ +/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */ +/* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */ +/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */ +/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/* */ +/*----------------------------------------------------------------------------*/ +/******************************************************************************/ +/* REXX API support */ +/* */ +/* Stub functions for all APIs accessed via the RexxInstance structure */ +/* */ +/******************************************************************************/ + +#include "RexxCore.h" +#include "ContextApi.hpp" +#include "InterpreterInstance.hpp" + +BEGIN_EXTERN_C() + +void RexxEntry Terminate(RexxInstance *c) +{ + InstanceApiContext context(c); + context.instance->terminate(); +} + +RexxBoolean RexxEntry AttachThread(RexxInstance *c, RexxThreadContext **tc) +{ + InstanceApiContext context(c); + return context.instance->attachThread(tc); +} + +void RexxEntry Halt(RexxInstance *c) +{ + InstanceApiContext context(c); + context.instance->halt(); +} + +void RexxEntry SetTrace(RexxInstance *c, RexxBoolean setting) +{ + InstanceApiContext context(c); + context.instance->setTrace(setting != 0); +} + + +RexxBoolean RexxEntry CreateScriptContext(RexxInstance *c, RexxScriptContext **sc, RexxOption *o) +{ + return (RexxBoolean)false; +} + +END_EXTERN_C() + + +RexxInstanceInterface InterpreterInstance::interfaceVector = +{ + INSTANCE_INTERFACE_VERSION, + Terminate, + AttachThread, + CreateScriptContext, + Halt, + SetTrace, +}; Property changes on: sandbox/rick/opt/kernel/api/InterpreterInstanceStubs.cpp ___________________________________________________________________ Name: svn:eol-style + native Added: sandbox/rick/opt/kernel/api/MethodContextStubs.cpp =================================================================== --- sandbox/rick/opt/kernel/api/MethodContextStubs.cpp (rev 0) +++ sandbox/rick/opt/kernel/api/MethodContextStubs.cpp 2008-02-03 14:15:37 UTC (rev 2333) @@ -0,0 +1,264 @@ +/*----------------------------------------------------------------------------*/ +/* */ +/* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */ +/* Copyright (c) 2005-2006 Rexx Language Association. All rights reserved. */ +/* */ +/* This program and the accompanying materials are made available under */ +/* the terms of the Common Public License v1.0 which accompanies this */ +/* distribution. A copy is also available at the following address: */ +/* http://www.ibm.com/developerworks/oss/CPLv1.0.htm */ +/* */ +/* Redistribution and use in source and binary forms, with or */ +/* without modification, are permitted provided that the following */ +/* conditions are met: */ +/* */ +/* Redistributions of source code must retain the above copyright */ +/* notice, this list of conditions and the following disclaimer. */ +/* Redistributions in binary form must reproduce the above copyright */ +/* notice, this list of conditions and the following disclaimer in */ +/* the documentation and/or other materials provided with the distribution. */ +/* */ +/* Neither the name of Rexx Language Association nor the names */ +/* of its contributors may be used to endorse or promote products */ +/* derived from this software without specific prior written permission. */ +/* */ +/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ +/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ +/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */ +/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ +/* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ +/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */ +/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */ +/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */ +/* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */ +/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */ +/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/* */ +/*----------------------------------------------------------------------------*/ +/******************************************************************************/ +/* REXX API support */ +/* */ +/* Stub functions for all APIs accessed via the NativeMethodContext */ +/* */ +/******************************************************************************/ +#include "RexxCore.h" +#include "ContextApi.hpp" +#include "RexxNativeActivation.hpp" + +BEGIN_EXTERN_C() + +RexxArrayObject RexxEntry GetMethodArguments(RexxMethodContext *c) +{ + ApiContext context(c); + try + { + return context.context->getArguments(); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +RexxObjectPtr RexxEntry GetMethodArgument(RexxMethodContext *c, RexxUnsignedNumber i) +{ + ApiContext context(c); + try + { + return context.context->getArgument(i); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +RexxMethodObject RexxEntry GetCurrentMethod(RexxMethodContext *c) +{ + ApiContext context(c); + try + { + return (RexxMethodObject)context.context->getMethod(); + } + catch (ActivityException) + { + } + return NULL; +} + +RexxStringPointer RexxEntry GetMessageName(RexxMethodContext *c) +{ + ApiContext context(c); + try + { + return (RexxStringPointer)context.context->getMessageName(); + } + catch (ActivityException) + { + } + return NULL; +} + +RexxObjectPtr RexxEntry GetSelf(RexxMethodContext *c) +{ + ApiContext context(c); + try + { + return context.context->getSelf(); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +RexxClassObject RexxEntry GetSuper(RexxMethodContext *c) +{ + ApiContext context(c); + try + { + return (RexxClassObject)context.context->getSuper(); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +void RexxEntry SetObjectVariable(RexxMethodContext *c, RexxStringPointer n, RexxObjectPtr v) +{ + ApiContext context(c); + try + { + context.context->setObjectVariable((stringchar_t *)n, (RexxObject *)v); + } + catch (ActivityException) + { + } +} + +RexxObjectPtr RexxEntry GetObjectVariable(RexxMethodContext *c, RexxStringPointer n) +{ + ApiContext context(c); + try + { + return context.context->getObjectVariable((stringchar_t *)n); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +void RexxEntry DropObjectVariable(RexxMethodContext *c, RexxStringPointer n) +{ + ApiContext context(c); + try + { + context.context->dropObjectVariable((stringchar_t *)n); + } + catch (ActivityException) + { + } +} + +RexxObjectPtr RexxEntry SendSuperMessage(RexxMethodContext *c, RexxStringPointer n, RexxArrayObject a) +{ + ApiContext context(c); + try + { + RexxObject *self = context.context->getSelf(); + RexxObject *super = context.context->getSuper(); + RexxString *message = new_string(n); + RexxArray *args = (RexxArray *)a; + ProtectedObject result; + self->messageSend(context.activity, message, args->size(), args->data(), super, result); + return context.ret((RexxObject *)result); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +RexxObjectPtr RexxEntry SendOverrideMessage(RexxMethodContext *c, RexxStringPointer n, RexxClassObject clazz, RexxArrayObject a) +{ + ApiContext context(c); + try + { + RexxObject *self = context.context->getSelf(); + RexxObject *super = (RexxObject *)clazz; + RexxString *message = new_string(n); + RexxArray *args = (RexxArray *)a; + ProtectedObject result; + self->messageSend(context.activity, message, args->size(), args->data(), super, result); + return context.ret((RexxObject *)result); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +void RexxEntry SetGuardOn(RexxMethodContext *c) +{ + ApiContext context(c); + try + { + context.context->guardOn(); + } + catch (ActivityException) + { + } +} + +void RexxEntry SetGuardOff(RexxMethodContext *c) +{ + ApiContext context(c); + try + { + context.context->guardOff(); + } + catch (ActivityException) + { + } +} + +RexxClassObject RexxEntry FindContextClass(RexxMethodContext *c, RexxStringPointer n) +{ + ApiContext context(c); + try + { + // convert the name to a string instance, and check the environments. + RexxString *name = new_upper_string(n); + return (RexxClassObject)context.ret(context.context->getMethod()->resolveClass(context.activity, name)); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +END_EXTERN_C() + + +MethodContextInterface RexxActivity::methodContextFunctions = +{ + METHOD_INTERFACE_VERSION, + GetMethodArguments, + GetMethodArgument, + GetMessageName, + GetCurrentMethod, + GetSelf, + GetSuper, + SetObjectVariable, + GetObjectVariable, + DropObjectVariable, + SendSuperMessage, + SendOverrideMessage, + SetGuardOn, + SetGuardOff, + FindContextClass +}; + + Property changes on: sandbox/rick/opt/kernel/api/MethodContextStubs.cpp ___________________________________________________________________ Name: svn:eol-style + native Added: sandbox/rick/opt/kernel/api/ThreadContextStubs.cpp =================================================================== --- sandbox/rick/opt/kernel/api/ThreadContextStubs.cpp (rev 0) +++ sandbox/rick/opt/kernel/api/ThreadContextStubs.cpp 2008-02-03 14:15:37 UTC (rev 2333) @@ -0,0 +1,1625 @@ +/*----------------------------------------------------------------------------*/ +/* */ +/* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */ +/* Copyright (c) 2005-2006 Rexx Language Association. All rights reserved. */ +/* */ +/* This program and the accompanying materials are made available under */ +/* the terms of the Common Public License v1.0 which accompanies this */ +/* distribution. A copy is also available at the following address: */ +/* http://www.ibm.com/developerworks/oss/CPLv1.0.htm */ +/* */ +/* Redistribution and use in source and binary forms, with or */ +/* without modification, are permitted provided that the following */ +/* conditions are met: */ +/* */ +/* Redistributions of source code must retain the above copyright */ +/* notice, this list of conditions and the following disclaimer. */ +/* Redistributions in binary form must reproduce the above copyright */ +/* notice, this list of conditions and the following disclaimer in */ +/* the documentation and/or other materials provided with the distribution. */ +/* */ +/* Neither the name of Rexx Language Association nor the names */ +/* of its contributors may be used to endorse or promote products */ +/* derived from this software without specific prior written permission. */ +/* */ +/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ +/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ +/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */ +/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ +/* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ +/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */ +/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */ +/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */ +/* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */ +/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */ +/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/* */ +/*----------------------------------------------------------------------------*/ +/******************************************************************************/ +/* REXX API support */ +/* */ +/* Stub functions for all APIs accessed via the NativeMethodContext */ +/* */ +/******************************************************************************/ + +#include "oorexx.h" +#include "ContextApi.hpp" +#include "RexxActivity.hpp" +#include "StringClass.hpp" +#include "IntegerClass.hpp" +#include "RexxBuffer.hpp" +#include "SupplierClass.hpp" +#include "ArrayClass.hpp" +#include "DirectoryClass.hpp" +#include "TableClass.hpp" +#include "MethodClass.hpp" +#include "Interpreter.hpp" +#include "SysInterpreter.hpp" +#include "PointerClass.hpp" + +BEGIN_EXTERN_C() + +void RexxEntry DetachThread(RexxThreadContext *c) +{ + ApiContext context(c); + try + { + context.activity->detachInstance(); + } + catch (ActivityException) + { + } +} + + +/** + * API stub for raising a halt condition on a thread. + */ +void RexxEntry HaltThread(RexxThreadContext *c) +{ + ApiContext context(c); + try + { + context.activity->halt(OREF_NULL); + } + catch (ActivityException) + { + } +} + + +void RexxEntry SetThreadTrace(RexxThreadContext *c, RexxBoolean setting) +{ + ApiContext context(c); + try + { + context.activity->setTrace(setting == TRUE); + } + catch (ActivityException) + { + } +} + + +RexxObjectPtr RexxEntry RequestGlobalReference(RexxThreadContext *c, RexxObjectPtr o) +{ + ApiContext context(c); + try + { + context.activity->addGlobalReference((RexxObject *)o); + return o; + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + + +void RexxEntry ReleaseGlobalReference(RexxThreadContext *c, RexxObjectPtr o) +{ + ApiContext context(c); + try + { + context.activity->removeGlobalReference((RexxObject *)o); + } + catch (ActivityException) + { + } +} + + +void RexxEntry ReleaseLocalReference(RexxThreadContext *c, RexxObjectPtr o) +{ + ApiContext context(c); + try + { + context.activity->removeLocalReference((RexxObject *)o); + } + catch (ActivityException) + { + } +} + +//NB: The name "SendMessage" has a conflict with a Windows API, so this name differs from +// the call vector version. +RexxObjectPtr RexxEntry SendMessageArray(RexxThreadContext *c, RexxObjectPtr o, RexxStringPointer m, RexxArrayObject a) +{ + ApiContext context(c); + try + { + return context.ret(((RexxObject *)o)->sendMessage(new_upper_string(m), (RexxArray *)a)); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + + +RexxObjectPtr RexxEntry SendMessage0(RexxThreadContext *c, RexxObjectPtr o, RexxStringPointer m) +{ + ApiContext context(c); + try + { + return context.ret(((RexxObject *)o)->sendMessage(new_upper_string(m))); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + + +RexxObjectPtr RexxEntry SendMessage1(RexxThreadContext *c, RexxObjectPtr o, RexxStringPointer m, RexxObjectPtr a1) +{ + ApiContext context(c); + try + { + return context.ret(((RexxObject *)o)->sendMessage(new_upper_string(m), (RexxObject *)a1)); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +RexxObjectPtr RexxEntry SendMessage2(RexxThreadContext *c, RexxObjectPtr o, RexxStringPointer m, RexxObjectPtr a1, RexxObjectPtr a2) +{ + ApiContext context(c); + try + { + return context.ret(((RexxObject *)o)->sendMessage(new_upper_string(m), (RexxObject *)a1, (RexxObject *)a2)); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +RexxDirectoryObject RexxEntry GetLocalEnvironment(RexxThreadContext *c) +{ + ApiContext context(c); + try + { + context.activity->getLocalEnvironment(); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +RexxDirectoryObject RexxEntry GetGlobalEnvironment(RexxThreadContext *c) +{ + ApiContext context(c); + try + { + RexxInterpreter::theEnvironment; + } + catch (ActivityException) + { + + } + return NULLOBJECT; +} + + +RexxBoolean RexxEntry IsSameType(RexxThreadContext *c, RexxObjectPtr o1, RexxObjectPtr o2) +{ + ApiContext context(c); + try + { + return isSameType((RexxObject *)o1, (RexxObject *)o2); + } + catch (ActivityException) + { + } + return 0; +} + + +RexxBoolean RexxEntry IsInstanceOf(RexxThreadContext *c, RexxObjectPtr o, RexxClassObject cl) +{ + ApiContext context(c); + try + { + return ((RexxClass *)cl)->instanceOf((RexxObject *)o); + } + catch (ActivityException) + { + } + return 0; +} + + +RexxClassObject RexxEntry FindClass(RexxThreadContext *c, RexxStringPointer n) +{ + ApiContext context(c); + try + { + // convert the name to a string instance, and check the environments. + RexxString *name = new_upper_string(n); + return (RexxClassObject)context.ret(context.activity->resolveClass(name)); + + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + + +RexxClassObject RexxEntry FindClassFromMethod(RexxThreadContext *c, RexxMethodObject m, RexxStringPointer n) +{ + ApiContext context(c); + try + { + // convert the name to a string instance, and check the environments. + RexxString *name = new_upper_string(n); + return (RexxClassObject)context.ret(((RexxMethod *)m)->resolveClass(context.activity, name)); + + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + + +RexxBoolean RexxEntry HasMethod(RexxThreadContext *c, RexxObjectPtr o, RexxStringPointer n) +{ + ApiContext context(c); + try + { + // convert the name to a string instance, and check the environments. + return ((RexxObject *)o)->hasMethod((stringchar_t *)n); + + } + catch (ActivityException) + { + } + return 0; +} + + +RexxMethodObject RexxEntry NewMethod(RexxThreadContext *c, RexxStringPointer source, RexxUnsignedNumber length) +{ + ApiContext context(c); + try + { + // convert the name to a string instance, and check the environments. + return (RexxMethodObject)context.ret(RexxMethod::newMethod((stringchar_t *)source, (stringsize_t)length)); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +RexxDirectoryObject RexxEntry GetMethodRoutines(RexxThreadContext *c, RexxMethodObject m) +{ + ApiContext context(c); + try + { + return (RexxDirectoryObject)context.ret(((RexxMethod *)m)->getRoutines()); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +RexxDirectoryObject RexxEntry GetMethodClasses(RexxThreadContext *c, RexxMethodObject m) +{ + ApiContext context(c); + try + { + return (RexxDirectoryObject)context.ret(((RexxMethod *)m)->getMethods()); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +RexxDirectoryObject RexxEntry GetMethodMethods(RexxThreadContext *c, RexxMethodObject m) +{ + ApiContext context(c); + try + { + return (RexxDirectoryObject)context.ret(((RexxMethod *)m)->getClasses()); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +RexxObjectPtr RexxEntry CallMethod(RexxThreadContext *c, RexxMethodObject m, RexxArrayObject a) +{ + ApiContext context(c); + try + { + ProtectedObject result; + RexxArray *args = (RexxArray *)a; + context.activity->runProgram((RexxMethod *)m, OREF_NULLSTRING, OREF_SCRIPT, OREF_NULL, args->data(), args->size(), result); + return context.ret((RexxObject *)result); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + + +RexxBufferObject RexxEntry SaveMethod(RexxThreadContext *c, RexxMethodObject m) +{ + ApiContext context(c); + try + { + return (RexxBufferObject)context.ret((RexxObject *)((RexxMethod *)m)->save()); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +RexxMethodObject RexxEntry LoadMethod(RexxThreadContext *c, RexxStringPointer d, size_t l) +{ + ApiContext context(c); + try + { + RexxBuffer *buf = new_buffer((stringchar_t *)d, (size_t)l); + return (RexxMethodObject)context.ret(RexxMethod::restore(buf, buf->address())); + } + catch (ActivityException) + { + } + return NULLOBJECT; + +} + + +RexxObjectPtr RexxEntry NewObject(RexxThreadContext *c) +{ + ApiContext context(c); + try + { + return context.ret(new (TheObjectClass) RexxObject()); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +RexxObjectPtr RexxEntry NumberToObject(RexxThreadContext *c, wholenumber_t n) +{ + ApiContext context(c); + try + { + return context.ret(Numerics::toObject((wholenumber_t)n)); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +RexxObjectPtr RexxEntry UintptrToObject(RexxThreadContext *c, uintptr_t n) +{ + ApiContext context(c); + try + { + return context.ret(Numerics::ptrToObject(n)); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +RexxObjectPtr RexxEntry ValueToObject(RexxThreadContext *c, ValueDescriptor *d) +{ + ApiContext context(c); + try + { + return context.ret(context.context->valueToObject(d)); + } + catch (ActivityException) + { + context.context->setConditionInfo(OREF_NULL); + } + return NULLOBJECT; +} + +RexxBoolean RexxEntry ObjectToValue(RexxThreadContext *c, RexxObjectPtr o, ValueDescriptor *d) +{ + ApiContext context(c); + try + { + return context.context->objectToValue((RexxObject *)o, d); + } + catch (ActivityException) + { + // some conversion failures result in an exception...cancel that, and + // just return FALSE; + context.context->setConditionInfo(OREF_NULL); + } + return FALSE; +} + +RexxObjectPtr RexxEntry UnsignedNumberToObject(RexxThreadContext *c, RexxUnsignedNumber n) +{ + ApiContext context(c); + try + { + return context.ret(Numerics::toObject((stringsize_t)n)); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + + +RexxBoolean RexxEntry ObjectToNumber(RexxThreadContext *c, RexxObjectPtr o, wholenumber_t *n) +{ + ApiContext context(c); + try + { + wholenumber_t temp; + // this uses the entire value range + if (Numerics::objectToWholeNumber((RexxObject *)o, temp, SSIZE_MAX, SSIZE_MIN)) + { + *n = (wholenumber_t)temp; + return true; + } + return false; + } + catch (ActivityException) + { + } + return 0; +} + + +RexxBoolean RexxEntry ObjectToUnsignedNumber(RexxThreadContext * c, RexxObjectPtr o, RexxUnsignedNumber * n) +{ + ApiContext context(c); + try + { + stringsize_t temp; + // this uses the entire value range + if (Numerics::objectToStringSize((RexxObject *)o, temp, SIZE_MAX)) + { + *n = (RexxUnsignedNumber)temp; + return true; + } + return false; + } + catch (ActivityException) + { + } + return 0; +} + +RexxObjectPtr RexxEntry Int64ToObject(RexxThreadContext *c, int64_t n) +{ + ApiContext context(c); + try + { + return context.ret(Numerics::toObject(n)); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +RexxObjectPtr RexxEntry UnsignedInt64ToObject(RexxThreadContext * c, uint64_t n) +{ + ApiContext context(c); + try + { + return context.ret(Numerics::toObject(n)); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +RexxBoolean RexxEntry ObjectToInt64(RexxThreadContext *c, RexxObjectPtr o, int64_t * n) +{ + ApiContext context(c); + try + { + // this uses the entire value range + return Numerics::objectToInt64((RexxObject *)o, *n); + } + catch (ActivityException) + { + } + return 0; +} + +RexxBoolean RexxEntry ObjectToUnsignedInt64(RexxThreadContext *c, RexxObjectPtr o, uint64_t *n) +{ + ApiContext context(c); + try + { + // this uses the entire value range + return Numerics::objectToUnsignedInt64((RexxObject *)o, *n); + } + catch (ActivityException) + { + } + return 0; +} + +RexxBoolean RexxEntry ObjectToUintptr(RexxThreadContext * c, RexxObjectPtr o, uintptr_t * n) +{ + ApiContext context(c); + try + { + // this uses the entire value range + return Numerics::objectToUintptr((RexxObject *)o, *n); + } + catch (ActivityException) + { + } + return 0; +} + +RexxObjectPtr RexxEntry DoubleToObject(RexxThreadContext *c, double n) +{ + ApiContext context(c); + try + { + return context.ret(new_numberstring(n)); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +RexxObjectPtr RexxEntry DoubleToObjectWithPrecision(RexxThreadContext *c, double n, wholenumber_t precision) +{ + ApiContext context(c); + try + { + return context.ret(new_string(n, (stringsize_t)precision)); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +RexxBoolean RexxEntry ObjectToDouble(RexxThreadContext *c, RexxObjectPtr o, double *n) +{ + ApiContext context(c); + try + { + return ((RexxObject *)o)->doubleValue(n); + } + catch (ActivityException) + { + } + return 0; +} + +RexxStringObject RexxEntry ObjectToString(RexxThreadContext *c, RexxObjectPtr o) +{ + ApiContext context(c); + try + { + return context.ret(REQUEST_STRING(o)); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +RexxStringPointer RexxEntry ObjectToStringValue(RexxThreadContext *c, RexxObjectPtr o) +{ + ApiContext context(c); + try + { + RexxString *temp = REQUEST_STRING(o); + context.ret(temp); + return (RexxStringPointer)temp->getStringData(); + } + catch (ActivityException) + { + } + return NULL; +} + +size_t RexxEntry StringGet(RexxThreadContext *c, RexxStringObject s, size_t o, RexxStringPointer r, size_t l) +{ + ApiContext context(c); + try + { + RexxString *temp = (RexxString *)s; + return temp->get(o, (stringchar_t *)r, l); + } + catch (ActivityException) + { + } + return 0; +} + +size_t RexxEntry StringLength(RexxThreadContext *c, RexxStringObject s) +{ + ApiContext context(c); + try + { + RexxString *temp = (RexxString *)s; + return temp->getLength(); + } + catch (ActivityException) + { + } + return 0; +} + +RexxStringPointer RexxEntry StringData(RexxThreadContext *c, RexxStringObject s) +{ + ApiContext context(c); + try + { + RexxString *temp = (RexxString *)s; + return (RexxStringPointer)temp->getStringData(); + } + catch (ActivityException) + { + } + return NULL; +} + +RexxStringObject RexxEntry NewString(RexxThreadContext *c, RexxStringPointer s, size_t l) +{ + ApiContext context(c); + try + { + return (RexxStringObject)context.ret(new_string((stringchar_t *)s, (stringsize_t)l)); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +RexxStringObject RexxEntry NewStringFromAsciiz(RexxThreadContext *c, RexxStringPointer s) +{ + ApiContext context(c); + try + { + return (RexxStringObject)context.ret(new_string((char *)s)); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +RexxStringObject RexxEntry StringUpper(RexxThreadContext *c, RexxStringObject s) +{ + ApiContext context(c); + try + { + RexxString *temp = (RexxString *)s; + return context.ret(temp->upper()); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +RexxStringObject RexxEntry StringLower(RexxThreadContext *c, RexxStringObject s) +{ + ApiContext context(c); + try + { + RexxString *temp = (RexxString *)s; + return context.ret(temp->lower()); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +RexxBoolean RexxEntry IsString(RexxThreadContext *c, RexxObjectPtr o) +{ + ApiContext context(c); + try + { + return isString((RexxObject *)o); + } + catch (ActivityException) + { + } + return 0; +} + +RexxBufferStringObject RexxEntry NewBufferString(RexxThreadContext * c, size_t l) +{ + ApiContext context(c); + try + { + return (RexxStringObject)context.ret(raw_string((stringsize_t)l)); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +size_t RexxEntry BufferStringLength(RexxThreadContext *c, RexxBufferStringObject s) +{ + ApiContext context(c); + try + { + RexxString *temp = (RexxString *)s; + return temp->getLength(); + } + catch (ActivityException) + { + } + return 0; +} + +RexxStringPointer RexxEntry BufferStringData(RexxThreadContext *c, RexxBufferStringObject s) +{ + ApiContext context(c); + try + { + RexxString *temp = (RexxString *)s; + return (RexxStringPointer)temp->getStringData(); + } + catch (ActivityException) + { + } + return NULL; +} + +RexxStringObject RexxEntry FinishBufferString(RexxThreadContext *c, RexxBufferStringObject s, size_t l) +{ + ApiContext context(c); + try + { + RexxString *temp = (RexxString *)s; + temp->finish(l); + return s; + } + catch (ActivityException) + { + } + return NULL; +} + +void RexxEntry TablePut(RexxThreadContext *c, RexxTableObject t, RexxObjectPtr o, RexxObjectPtr i) +{ + ApiContext context(c); + try + { + ((RexxTable *)t)->put((RexxObject *)o, (RexxObject *)i); + } + catch (ActivityException) + { + } +} + +RexxObjectPtr RexxEntry TableGet(RexxThreadContext *c, RexxTableObject t, RexxObjectPtr i) +{ + ApiContext context(c); + try + { + return context.ret(((RexxTable *)t)->get((RexxObject *)i)); + } + catch (ActivityException) + { + } + return OREF_NULL; +} + +RexxObjectPtr RexxEntry TableRemove(RexxThreadContext *c, RexxTableObject t, RexxObjectPtr i) +{ + ApiContext context(c); + try + { + return context.ret(((RexxTable *)t)->remove((RexxObject *)i)); + } + catch (ActivityException) + { + } + return OREF_NULL; +} + +RexxTableObject RexxEntry NewTable(RexxThreadContext *c) +{ + ApiContext context(c); + try + { + return context.ret(new_table()); + } + catch (ActivityException) + { + } + return OREF_NULL; +} + +RexxBoolean RexxEntry IsTable(RexxThreadContext *c, RexxObjectPtr o) +{ + ApiContext context(c); + try + { + return isOfClass(Table, (RexxObject *)o); + } + catch (ActivityException) + { + } + return FALSE; +} + +void RexxEntry DirectoryPut(RexxThreadContext *c, RexxDirectoryObject t, RexxObjectPtr o, RexxStringPointer i) +{ + ApiContext context(c); + try + { + ((RexxDirectory *)t)->put((RexxObject *)o, new_string(i)); + } + catch (ActivityException) + { + } +} + +RexxObjectPtr RexxEntry DirectoryAt(RexxThreadContext *c, RexxDirectoryObject t, RexxStringPointer i) +{ + ApiContext context(c); + try + { + return context.ret(((RexxDirectory *)t)->at(new_string(i))); + } + catch (ActivityException) + { + } + return OREF_NULL; +} + +RexxObjectPtr RexxEntry DirectoryRemove(RexxThreadContext *c, RexxDirectoryObject t, RexxStringPointer i) +{ + ApiContext context(c); + try + { + return context.ret(((RexxDirectory *)t)->remove(new_string(i))); + } + catch (ActivityException) + { + } + return OREF_NULL; +} + +RexxDirectoryObject RexxEntry NewDirectory(RexxThreadContext *c) +{ + ApiContext context(c); + try + { + return context.ret(new_table()); + } + catch (ActivityException) + { + } + return OREF_NULL; +} + +RexxBoolean RexxEntry IsDirectory(RexxThreadContext *c, RexxObjectPtr o) +{ + ApiContext context(c); + try + { + return isOfClass(Directory, (RexxObject *)o); + } + catch (ActivityException) + { + } + return FALSE; +} + +RexxObjectPtr RexxEntry ArrayAt(RexxThreadContext *c, RexxArrayObject a, RexxUnsignedNumber i) +{ + ApiContext context(c); + try + { + return context.ret(((RexxArray *)a)->getApi((arraysize_t)i)); + } + catch (ActivityException) + { + } + return OREF_NULL; +} + +RexxBoolean RexxEntry ArrayHasIndex(RexxThreadContext *c, RexxArrayObject a, RexxUnsignedNumber i) +{ + ApiContext context(c); + try + { + return ((RexxArray *)a)->hasIndexApi((arraysize_t)i); + } + catch (ActivityException) + { + } + return FALSE; +} + +void RexxEntry ArrayPut(RexxThreadContext *c, RexxArrayObject a, RexxObjectPtr o, RexxUnsignedNumber i) +{ + ApiContext context(c); + try + { + ((RexxArray *)a)->putApi((RexxObject *)o, (arraysize_t)i); + } + catch (ActivityException) + { + } +} + +RexxUnsignedNumber RexxEntry ArraySize(RexxThreadContext *c, RexxArrayObject a) +{ + ApiContext context(c); + try + { + return ((RexxArray *)a)->size(); + } + catch (ActivityException) + { + } + return 0; +} + +wholenumber_t RexxEntry ArrayDimension(RexxThreadContext *c, RexxArrayObject a) +{ + ApiContext context(c); + try + { + return ((RexxArray *)a)->getDimension(); + } + catch (ActivityException) + { + } + return 0; +} + +RexxArrayObject RexxEntry NewArray(RexxThreadContext *c, RexxUnsignedNumber s) +{ + ApiContext context(c); + try + { + return (RexxArrayObject)context.ret(new_array(s)); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +RexxArrayObject RexxEntry ArrayOfOne(RexxThreadContext *c, RexxObjectPtr o) +{ + ApiContext context(c); + try + { + return (RexxArrayObject)context.ret(new_array((RexxObject *)o)); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +RexxArrayObject RexxEntry ArrayOfTwo(RexxThreadContext *c, RexxObjectPtr o1, RexxObjectPtr o2) +{ + ApiContext context(c); + try + { + return (RexxArrayObject)context.ret(new_array((RexxObject *)o1, (RexxObject *)o2)); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + + +RexxBoolean RexxEntry IsArray(RexxThreadContext *c, RexxObjectPtr o) +{ + ApiContext context(c); + try + { + return isArray((RexxObject *)o); + } + catch (ActivityException) + { + } + return FALSE; +} + +RexxStringPointer RexxEntry BufferData(RexxThreadContext *c, RexxBufferObject b) +{ + ApiContext context(c); + try + { + return (RexxStringPointer)((RexxBuffer *)b)->address(); + } + catch (ActivityException) + { + } + return NULL; +} + +wholenumber_t RexxEntry BufferLength(RexxThreadContext *c, RexxBufferObject b) +{ + ApiContext context(c); + try + { + return ((RexxBuffer *)b)->length(); + } + catch (ActivityException) + { + } + return 0; +} + +RexxBufferObject RexxEntry NewBuffer(RexxThreadContext *c, RexxUnsignedNumber l) +{ + ApiContext context(c); + try + { + return (RexxBufferObject)context.ret((RexxObject *)new_buffer(l)); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +RexxBoolean RexxEntry IsBuffer(RexxThreadContext *c, RexxObjectPtr o) +{ + ApiContext context(c); + try + { + return isOfClass(Buffer, (RexxObject *)o); + } + catch (ActivityException) + { + } + return FALSE; +} + +wholenumber_t RexxEntry IntegerValue(RexxThreadContext *c, RexxIntegerObject o) +{ + ApiContext context(c); + try + { + return ((RexxInteger *)o)->wholeNumber(); + } + catch (ActivityException) + { + } + return 0; +} + +RexxIntegerObject RexxEntry NewInteger(RexxThreadContext *c, wholenumber_t n) +{ + ApiContext context(c); + try + { + return (RexxIntegerObject)context.ret(new_integer(n)); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +RexxBoolean RexxEntry IsInteger(RexxThreadContext *c, RexxObjectPtr o) +{ + ApiContext context(c); + try + { + return isInteger((RexxObject *)o); + } + catch (ActivityException) + { + } + return FALSE; +} + +POINTER RexxEntry PointerValue(RexxThreadContext *c, RexxPointerObject o) +{ + ApiContext context(c); + try + { + return (POINTER)((RexxPointer *)o)->pointer(); + } + catch (ActivityException) + { + } + return NULL; +} + +RexxPointerObject RexxEntry NewPointer(RexxThreadContext *c, POINTER p) +{ + ApiContext context(c); + try + { + return (RexxPointerObject)context.ret(new_pointer(p)); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +RexxBoolean RexxEntry IsPointer(RexxThreadContext *c, RexxObjectPtr o) +{ + ApiContext context(c); + try + { + return isOfClass(Pointer, (RexxObject *)o); + } + catch (ActivityException) + { + } + return FALSE; +} + +RexxObjectPtr RexxEntry SupplierValue(RexxThreadContext *c, RexxSupplierObject o) +{ + ApiContext context(c); + try + { + return context.ret(((RexxSupplier *)o)->value()); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +RexxObjectPtr RexxEntry SupplierIndex(RexxThreadContext *c, RexxSupplierObject o) +{ + ApiContext context(c); + try + { + return context.ret(((RexxSupplier *)o)->index()); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +RexxBoolean RexxEntry SupplierAvailable(RexxThreadContext *c, RexxSupplierObject o) +{ + ApiContext context(c); + try + { + return ((RexxSupplier *)o)->available() == TheTrueObject; + } + catch (ActivityException) + { + } + return FALSE; +} + +void RexxEntry SupplierNext(RexxThreadContext *c, RexxSupplierObject o) +{ + ApiContext context(c); + try + { + ((RexxSupplier *)o)->next(); + } + catch (ActivityException) + { + } +} + +RexxSupplierObject RexxEntry NewSupplier(RexxThreadContext *c, RexxArrayObject values, RexxArrayObject names) +{ + ApiContext context(c); + try + { + return context.ret(new_supplier((RexxArray *)values, (RexxArray *)names)); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +void RexxEntry SetStemElement(RexxThreadContext *c, RexxStemObject s, RexxStringPointer n, RexxObjectPtr v) +{ + ApiContext context(c); + try + { + ((RexxStem *)s)->setElement((stringchar_t *)n, (RexxObject *)v); + } + catch (ActivityException) + { + } +} + +RexxObjectPtr RexxEntry GetStemElement(RexxThreadContext *c, RexxStemObject s, RexxStringPointer n) +{ + ApiContext context(c); + try + { + return context.ret(((RexxStem *)s)->getElement((stringchar_t *)n)); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +void RexxEntry DropStemElement(RexxThreadContext *c, RexxStemObject s, RexxStringPointer n) +{ + ApiContext context(c); + try + { + ((RexxStem *)s)->dropElement((stringchar_t *)n); + } + catch (ActivityException) + { + } +} + +void RexxEntry SetStemArrayElement(RexxThreadContext *c, RexxStemObject s, RexxUnsignedNumber i, RexxObjectPtr v) +{ + ApiContext context(c); + try + { + ((RexxStem *)s)->setElement((stringsize_t )i, (RexxObject *)v); + } + catch (ActivityException) + { + } +} + +RexxObjectPtr RexxEntry GetStemArrayElement(RexxThreadContext *c, RexxStemObject s, RexxUnsignedNumber i) +{ + ApiContext context(c); + try + { + return context.ret(((RexxStem *)s)->getElement((stringsize_t)i)); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +void RexxEntry DropStemArrayElement(RexxThreadContext *c, RexxStemObject s, RexxUnsignedNumber i) +{ + ApiContext context(c); + try + { + ((RexxStem *)s)->dropElement((stringsize_t)i); + } + catch (ActivityException) + { + } +} + +RexxSupplierObject RexxEntry GetAllStemElements(RexxThreadContext *c, RexxStemObject s) +{ + ApiContext context(c); + try + { + return (RexxSupplierObject)context.ret(((RexxStem *)s)->supplier()); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +RexxObjectPtr RexxEntry GetStemValue(RexxThreadContext *c, RexxStemObject s) +{ + ApiContext context(c); + try + { + return context.ret(((RexxStem *)s)->getStemValue()); + } + catch (ActivityException) + { + } + return NULLOBJECT; +} + +RexxBoolean RexxEntry IsStem(RexxThreadContext *c, RexxObjectPtr o) +{ + ApiContext context(c); + try + { + return isOfClass(Stem, (RexxObject *)o); + } + catch (ActivityException) + { + } + return FALSE; +} + +void RexxEntry RaiseException0(RexxThreadContext *c, RexxUnsignedNumber n) +{ + ApiContext context(c); + try + { + reportException((wholenumber_t)n); + } + catch (ActivityException) + { + } +} + +void RexxEntry RaiseException1(RexxThreadContext *c, RexxUnsignedNumber n, RexxObjectPtr o1) +{ + ApiContext context(c); + try + { + reportException((wholenumber_t)n, (RexxObject *)o1); + } + catch (ActivityException) + { + } +} + +void RexxEntry RaiseException2(RexxThreadContext *c, RexxUnsignedNumber n, RexxObjectPtr o1, RexxObjectPtr o2) +{ + ApiContext context(c); + try + { + reportException((wholenumber_t)n, (RexxObject *)o1, (RexxObject *)o2); + } + catch (ActivityException) + { + } +} + +void RexxEntry RaiseExceptionArray(RexxThreadContext *c, RexxUnsignedNumber n, RexxArrayObject a) +{ + ApiContext context(c); + try + { + reportException((wholenumber_t)n, (RexxArray *)a); + } + catch (ActivityException) + { + } +} + +void RexxEntry RaiseCondition(RexxThreadContext *c, RexxStringPointer name, RexxStringPointer desc, RexxArrayObject add, RexxObjectPtr result) +{ + ApiContext context(c); + try + { + context.activity->raiseCondition(new_upper_string(name), OREF_NULL, new_string(desc), + (RexxArray *)add, (RexxObject *)result, OREF_NULL); + } + catch (ActivityException) + { + } +} + +RexxBoolean RexxEntry CheckCondition(RexxThreadContext *c) +{ + ApiContext context(c); + try + { + return context.context->getConditionInfo() != OREF_NULL; + } + catch (ActivityException) + { + } + return FALSE; +} + +RexxDirectoryObject RexxEntry GetConditionInfo(RexxThreadContext *c) +{ + ApiContext context(c); + try + { + return context.context->getConditionInfo(); + } + catch (ActivityException) + { + } + return OREF_NULL; +} + + +void RexxEntry DecodeConditionInfo(RexxThreadContext *c, RexxDirectoryObject d, ConditionData *cd) +{ + ApiContext context(c); + try + { + RexxInterpreter::decodeConditionData((RexxDirectory *)d, cd); + } + catch (ActivityException) + { + } +} + +void RexxEntry ClearCondition(RexxThreadContext *c) +{ + ApiContext context(c); + try + { + context.context->setConditionInfo(OREF_NULL); + } + catch (ActivityException) + { + } +} + +END_EXTERN_C() + +RexxThreadInterface RexxActivity::threadContextFunctions = +{ + THREAD_INTERFACE_VERSION, + DetachThread, + HaltThread, + SetThreadTrace, + RequestGlobalReference, + ReleaseGlobalReference, + ReleaseLocalReference, + + SendMessageArray, + SendMessage0, + SendMessage1, + SendMessage2, + + GetLocalEnvironment, + GetGlobalEnvironment, + + IsSameType, + IsInstanceOf, + FindClass, + FindClassFromMethod, + HasMethod, + + NewMethod, + GetMethodRoutines, + GetMethodClasses, + GetMethodMethods, + CallMethod, + SaveMethod, + LoadMethod, + + NewObject, + NumberToObject, + UintptrToObject, + ValueToObject, + ObjectToValue, + UnsignedNumberToObject, + ObjectToNumber, + ObjectToUnsignedNumber, + Int64ToObject, + UnsignedInt64ToObject, + ObjectToInt64, + ObjectToUnsignedInt64, + ObjectToUintptr, + DoubleToObject, + DoubleToObjectWithPrecision, + ObjectToDouble, + + ObjectToString, + ObjectToStringValue, + StringGet, + StringLength, + StringData, + NewString, + NewStringFromAsciiz, + StringUpper, + StringLower, + IsString, + + NewBufferString, + BufferStringLength, + BufferStringData, + FinishBufferString, + + TablePut, + TableGet, + TableRemove, + NewTable, + IsTable, + + DirectoryPut, + DirectoryAt, + DirectoryRemove, + NewDirectory, + IsDirectory, + + ArrayAt, + ArrayHasIndex, + ArrayPut, + ArraySize, + ArrayDimension, + NewArray, + ArrayOfOne, + ArrayOfTwo, + IsArray, + + BufferData, + BufferLength, + NewBuffer, + IsBuffer, + + IntegerValue, + NewInteger, + IsInteger, + + PointerValue, + NewPointer, + IsPointer, + + SupplierValue, + SupplierIndex, + SupplierAvailable, + SupplierNext, + NewSupplier, + + SetStemElement, + GetStemElement, + DropStemElement, + SetStemArrayElement, + GetStemArrayElement, + DropStemArrayElement, + GetAllStemElements, + GetStemValue, + IsStem, + + RaiseException0, + RaiseException1, + RaiseException2, + RaiseExceptionArray, + RaiseCondition, + CheckCondition, + GetConditionInfo, + DecodeConditionInfo, + ClearCondition, + + OREF_NULL, + OREF_NULL, + OREF_NULL, + OREF_NULL +}; Property changes on: sandbox/rick/opt/kernel/api/ThreadContextStubs.cpp ___________________________________________________________________ Name: svn:eol-style + native Added: sandbox/rick/opt/kernel/instructions/RequiresDirective.cpp =================================================================== --- sandbox/rick/opt/kernel/instructions/RequiresDirective.cpp (rev 0) +++ sandbox/rick/opt/kernel/instructions/RequiresDirective.cpp 2008-02-03 14:15:37 UTC (rev 2333) @@ -0,0 +1,130 @@ +/*----------------------------------------------------------------------------*/ +/* */ +/* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */ +/* Copyright (c) 2005-2006 Rexx Language Association. All rights reserved. */ +/* */ +/* This program and the accompanying materials are made available under */ +/* the terms of the Common Public License v1.0 which accompanies this */ +/* distribution. A copy is also available at the following address: */ +/* http://www.oorexx.org/license.html */ +/* */ +/* Redistribution and use in source and binary forms, with or */ +/* without modification, are permitted provided that the following */ +/* conditions are met: */ +/* */ +/* Redistributions of source code must retain the above copyright */ +/* notice, this list of conditions and the following disclaimer. */ +/* Redistributions in binary form must reproduce the above copyright */ +/* notice, this list of conditions and the following disclaimer in */ +/* the documentation and/or other materials provided with the distribution. */ +/* */ +/* Neither the name of Rexx Language Association nor the names */ +/* of its contributors may be used to endorse or promote products */ +/* derived from this software without specific prior written permission. */ +/* */ +/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ +/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ +/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */ +/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ +/* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ +/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */ +/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */ +/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */ +/* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */ +/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */ +/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/* */ +/*----------------------------------------------------------------------------*/ +/******************************************************************************/ +/* REXX Kernel RequiresDirective.cpp */ +/* */ +/* Primitive Translator Abstract Directive Code */ +/* */ +/******************************************************************************/ +#include <stdlib.h> +#include "RexxCore.h" +#include "RequiresDirective.hpp" +#include "Clause.hpp" + + + +/** + * Construct a RequiresDirective. + * + * @param n The name of the requires target. + * @param clause The source file clause containing the directive. + */ +RequiresDirective::RequiresDirective(RexxString *n, RexxClause *clause) : RexxDirective(clause, KEYWORD_REQUIRES) +{ + name = n; + resolvedTarget = OREF_NULL; // this is resolved at install time +} + +/** + * Normal garbage collecting live mark. + * + * @param liveMark The current live object mark. + */ +void RequiresDirective::live(size_t liveMark) +{ + memory_mark(this->nextInstruction); // must be first one marked (though normally null) + memory_mark(this->name); + memory_mark(this->resolvedTarget); +} + + +/** + * The generalized object marking routine. + * + * @param reason The processing faze we're running the mark on. + */ +void RequiresDirective::liveGeneral(int reason) +{ + memory_mark_general(this->nextInstruction); // must be first one marked (though normally null) + memory_mark_general(this->name); + memory_mark_general(this->resolvedTarget); +} + + +/** + * Flatten the directive instance. + * + * @param envelope The envelope we're flattening into. + */ +void RequiresDirective::flatten(RexxEnvelope *envelope) +{ + setUpFlatten(RequiresDirective) + + flatten_reference(newThis->nextInstruction, envelope); + flatten_reference(newThis->name, envelope); + // We sever this connection when the method is flattened. + newThis->resolvedTarget = OREF_NULL; + + cleanUpFlatten +} + + +/** + * Allocate a new requires directive. + * + * @param size The size of the object. + * + * @return The memory for the new object. + */ +void *RequiresDirective::operator new(size_t size) +{ + return new_object(size, T_RequiresDirective); /* Get new object */ +} + + +/** + * Do install-time processing of the ::requires directive. This + * will resolve the directive and merge all of the public information + * from the resolved file into this program context. + * + * @param activation The activation we're running under for the install. + */ +void RequiresDirective::install(RexxActivation *context) +{ + OrefSet(this, this->resolvedTarget, context->processRequires(name, this)); +} Property changes on: sandbox/rick/opt/kernel/instructions/RequiresDirective.cpp ___________________________________________________________________ Name: svn:eol-style + native Added: sandbox/rick/opt/kernel/instructions/RequiresDirective.hpp =================================================================== --- sandbox/rick/opt/kernel/instructions/RequiresDirective.hpp (rev 0) +++ sandbox/rick/opt/kernel/instructions/RequiresDirective.hpp 2008-02-03 14:15:37 UTC (rev 2333) @@ -0,0 +1,73 @@ +/*----------------------------------------------------------------------------*/ +/* */ +/* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */ +/* Copyright (c) 2005-2006 Rexx Language Association. All rights reserved. */ +/* */ +/* This program and the accompanying materials are made available under */ +/* the terms of the Common Public License v1.0 which accompanies this */ +/* distribution. A copy is also available at the following address: */ +/* http://www.oorexx.org/license.html */ +/* */ +/* Redistribution and use in source and binary forms, with or */ +/* without modification, are permitted provided that the following */ +/* conditions are met: */ +/* */ +/* Redistributions of source code must retain the above copyright */ +/* notice, this list of conditions and the following disclaimer. */ +/* Redistributions in binary form must reproduce the above copyright */ +/* notice, this list of conditions and the following disclaimer in */ +/* the documentation and/or other materials provided with the distribution. */ +/* */ +/* Neither the name of Rexx Language Association nor the names */ +/* of its contributors may be used to endorse or promote products */ +/* derived from this software without specific prior written permission. */ +/* */ +/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ +/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ +/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */ +/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ +/* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ +/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */ +/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */ +/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */ +/* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */ +/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */ +/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/* */ +/*----------------------------------------------------------------------------*/ +/******************************************************************************/ +/* REXX Kernel RequiresDirective.hpp */ +/* */ +/* Primitive Abstract Directive Class Definitions */ +/* */ +/******************************************************************************/ +#ifndef Included_RequiresDirective +#define Included_RequiresDirective + +#include "RexxDirective.hpp" + +class RequiresDirective : public RexxDirective +{ + public: + void *operator new(size_t); + inline void *operator new(size_t size, void *objectPtr) { return objectPtr; } + inline void operator delete(void *) { } + inline void operator delete(void *, void *) { } + + RequiresDirective(RexxString *, RexxClause *); + inline RequiresDirective(RESTORETYPE restoreType) { ; }; + + void live(size_t); + void liveGeneral(int reason); + void flatten(RexxEnvelope *); + + inline RexxString *getName() { return name; } + +protected: + RexxString *name; // the name of the directive + RexxCode *resolvedTarget; // the anchor for the resolved package + +}; + +#endif + Property changes on: sandbox/rick/opt/kernel/instructions/RequiresDirective.hpp ___________________________________________________________________ Name: svn:eol-style + native Added: sandbox/rick/opt/kernel/messages/ApiErrorCodes.xsl =================================================================== --- sandbox/rick/opt/kernel/messages/ApiErrorCodes.xsl (rev 0) +++ sandbox/rick/opt/kernel/messages/ApiErrorCodes.xsl 2008-02-03 14:15:37 UTC (rev 2333) @@ -0,0 +1,83 @@ +<?xml version="1.0"?> +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> +<xsl:output method="text"/> +<xsl:template match="Messages"> +<xsl:text>/*----------------------------------------------------------------------------*/ +/* */ +/* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */ +/* Copyright (c) 2005-2006 Rexx Language Association. All rights reserved. */ +/* */ +/* This program and the accompanying materials are made available under */ +/* the terms of the Common Public License v1.0 which accompanies this */ +/* distribution. A copy is also available at the following address: */ +/* http://www.ibm.com/developerworks/oss/CPLv1.0.htm */ +/* */ +/* Redistribution and use in source and binary forms, with or */ +/* without modification, are permitted provided that the following */ +/* conditions are met: */ +/* */ +/* Redistributions of source code must retain the above copyright */ +/* notice, this list of conditions and the following disclaimer. */ +/* Redistributions in binary form must reproduce the above copyright */ +/* notice, this list of conditions and the following disclaimer in */ +/* the documentation and/or other materials provided with the distribution. */ +/* */ +/* Neither the name of Rexx Language Association nor the names */ +/* of its contributors may be used to endorse or promote products */ +/* derived from this software without specific prior written permission. */ +/* */ +/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ +/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ +/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */ +/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ +/* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ +/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */ +/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */ +/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */ @@ Diff output truncated at 100000 characters. @@ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bigrixx@us...> - 2008-02-09 00:16:08
|
Revision: 2350 http://oorexx.svn.sourceforge.net/oorexx/?rev=2350&view=rev Author: bigrixx Date: 2008-02-08 16:16:13 -0800 (Fri, 08 Feb 2008) Log Message: ----------- incremental checkin Modified Paths: -------------- sandbox/rick/opt/kernel/RexxClasses/CoreClasses.orx sandbox/rick/opt/kernel/classes/ClassClass.cpp sandbox/rick/opt/kernel/classes/DirectoryClass.cpp sandbox/rick/opt/kernel/classes/MessageClass.cpp sandbox/rick/opt/kernel/classes/MethodClass.cpp sandbox/rick/opt/kernel/classes/MethodClass.hpp sandbox/rick/opt/kernel/classes/ObjectClass.cpp sandbox/rick/opt/kernel/classes/RoutineClass.hpp sandbox/rick/opt/kernel/kernel.mak sandbox/rick/opt/kernel/parser/SourceFile.cpp sandbox/rick/opt/kernel/parser/SourceFile.hpp sandbox/rick/opt/kernel/platform/unix/UnixMethods.orx sandbox/rick/opt/kernel/platform/windows/FileSystem.cpp sandbox/rick/opt/kernel/platform/windows/SysInterpreterInstance.hpp sandbox/rick/opt/kernel/platform/windows/WindowsMethods.orx sandbox/rick/opt/kernel/runtime/ActivityManager.cpp sandbox/rick/opt/kernel/runtime/ActivityManager.hpp sandbox/rick/opt/kernel/runtime/ClassTypeCodes.h sandbox/rick/opt/kernel/runtime/CreateMethodDispatcher.cpp sandbox/rick/opt/kernel/runtime/InterpreterInstance.hpp sandbox/rick/opt/kernel/runtime/NativeMethods.h sandbox/rick/opt/kernel/runtime/NativeRoot.cpp sandbox/rick/opt/kernel/runtime/Package.cpp sandbox/rick/opt/kernel/runtime/Package.hpp sandbox/rick/opt/kernel/runtime/PackageManager.cpp sandbox/rick/opt/kernel/runtime/PackageManager.hpp sandbox/rick/opt/kernel/runtime/PrimitiveBehaviourNames.h sandbox/rick/opt/kernel/runtime/PrimitiveBehaviours.cpp sandbox/rick/opt/kernel/runtime/PrimitiveClasses.xml sandbox/rick/opt/kernel/runtime/RexxActivation.cpp sandbox/rick/opt/kernel/runtime/RexxActivation.hpp sandbox/rick/opt/kernel/runtime/RexxActivity.cpp sandbox/rick/opt/kernel/runtime/RexxActivity.hpp sandbox/rick/opt/kernel/runtime/RexxCode.hpp sandbox/rick/opt/kernel/runtime/RexxConstants.hpp sandbox/rick/opt/kernel/runtime/RexxCore.h sandbox/rick/opt/kernel/runtime/RexxMemory.cpp sandbox/rick/opt/kernel/runtime/RexxMemory.hpp sandbox/rick/opt/kernel/runtime/RexxNativeActivation.cpp sandbox/rick/opt/kernel/runtime/RexxNativeActivation.hpp sandbox/rick/opt/kernel/runtime/RexxNativeCode.cpp sandbox/rick/opt/kernel/runtime/RexxNativeCode.hpp sandbox/rick/opt/kernel/runtime/SecurityManager.cpp sandbox/rick/opt/kernel/runtime/SecurityManager.hpp sandbox/rick/opt/kernel/runtime/Setup.cpp sandbox/rick/opt/kernel/runtime/VirtualFunctionTable.cpp Added Paths: ----------- sandbox/rick/opt/kernel/runtime/MessageDispatcher.cpp sandbox/rick/opt/kernel/runtime/MessageDispatcher.hpp Modified: sandbox/rick/opt/kernel/RexxClasses/CoreClasses.orx =================================================================== --- sandbox/rick/opt/kernel/RexxClasses/CoreClasses.orx 2008-02-08 21:17:58 UTC (rev 2349) +++ sandbox/rick/opt/kernel/RexxClasses/CoreClasses.orx 2008-02-09 00:16:13 UTC (rev 2350) @@ -146,6 +146,9 @@ /* ********************************************************************************************* */ /* ********************************************************************************************* */ +-- method for dispatching message objects on a new thread +::METHOD !dispatch PRIVATE unguarded EXTERNAL 'REXX message_nstart' + /*============================================================================*/ /* Additional S U P P L I E R methods */ /*============================================================================*/ Modified: sandbox/rick/opt/kernel/classes/ClassClass.cpp =================================================================== --- sandbox/rick/opt/kernel/classes/ClassClass.cpp 2008-02-08 21:17:58 UTC (rev 2349) +++ sandbox/rick/opt/kernel/classes/ClassClass.cpp 2008-02-09 00:16:13 UTC (rev 2350) @@ -578,7 +578,7 @@ else if (TheNilObject != method_object && !isOfClass(Method, method_object)) { /* make one from a string */ - method_object = TheMethodClass->newRexxCode(method_name, method_object, IntegerTwo); + method_object = RexxMethod::newMethodObject(method_name, method_object, IntegerTwo, OREF_NULL); } if (TheNilObject != method_object) /* if the method is not TheNilObject */ { @@ -960,7 +960,7 @@ if (!isOfClass(Method, newMethod)) /* object */ { /* make it into a method object */ - newMethod = TheMethodClass->newRexxCode(method_name, newMethod, IntegerOne); + newMethod = RexxMethod::newMethodObject(method_name, newMethod, IntegerOne, OREF_NULL); newMethod->setScope(scope); /* and set the scope to the given */ } else Modified: sandbox/rick/opt/kernel/classes/DirectoryClass.cpp =================================================================== --- sandbox/rick/opt/kernel/classes/DirectoryClass.cpp 2008-02-08 21:17:58 UTC (rev 2349) +++ sandbox/rick/opt/kernel/classes/DirectoryClass.cpp 2008-02-09 00:16:13 UTC (rev 2350) @@ -68,9 +68,9 @@ /* Function: Generalized object marking */ /******************************************************************************/ { - this->RexxHashTableCollection::liveGeneral(reason); - memory_mark_general(this->method_table); - memory_mark_general(this->unknown_method); + this->RexxHashTableCollection::liveGeneral(reason); + memory_mark_general(this->method_table); + memory_mark_general(this->unknown_method); } void RexxDirectory::flatten(RexxEnvelope *envelope) @@ -93,8 +93,8 @@ /* Function: unflatten an object */ /******************************************************************************/ { - envelope->addTable(this); /* add to the envelope table */ - return this; /* and just return out selves */ + envelope->addTable(this); /* add to the envelope table */ + return this; /* and just return out selves */ } RexxObject *RexxDirectory::copy() @@ -102,16 +102,15 @@ /* Function: Copy a directory */ /******************************************************************************/ { - RexxDirectory *newObj; /* new directory copy */ - /* copy object via Collection copy */ - newObj = (RexxDirectory *)this->RexxHashTableCollection::copy(); + RexxDirectory *newObj = (RexxDirectory *)this->RexxHashTableCollection::copy(); /* No specifics for Directory. */ - if (this->method_table != OREF_NULL) { + if (this->method_table != OREF_NULL) + { /* copy it too */ - OrefSet(newObj, newObj->method_table, (RexxTable *)this->method_table->copy()); - } - return newObj; /* return the copy */ + OrefSet(newObj, newObj->method_table, (RexxTable *)this->method_table->copy()); + } + return newObj; /* return the copy */ } RexxObject *RexxDirectory::entry( @@ -132,16 +131,15 @@ /* number of methods added via set method calls */ /******************************************************************************/ { - size_t count; /* count of items */ - - /* get the direct table size */ - count = this->contents->totalEntries(); - /* have a method table? */ - if (this->method_table != OREF_NULL) { - /* add in the count of methods */ - count += this->method_table->items(); - } - return count; /* return this amount */ + /* get the direct table size */ + size_t count = this->contents->totalEntries(); + /* have a method table? */ + if (this->method_table != OREF_NULL) + { + /* add in the count of methods */ + count += this->method_table->items(); + } + return count; /* return this amount */ } RexxObject *RexxDirectory::itemsRexx(void) @@ -150,7 +148,7 @@ /* number of methods added via set method calls */ /******************************************************************************/ { - return (RexxObject *)new_integer(this->items()); + return (RexxObject *)new_integer(this->items()); } RexxSupplier *RexxDirectory::supplier(void) @@ -159,37 +157,35 @@ /* of the SETMETHOD methods as values */ /******************************************************************************/ { - RexxTable *result; /* Constructed results table */ - RexxTable *methodTable; /* constructed method table */ - RexxHashTable *hashTab; /* contents hash table */ - HashLink i; /* table index */ - - result = new_table(); /* get a table for the supplier */ - ProtectedObject p(result); - hashTab = this->contents; /* point to the contents */ - /* now traverse the entire table */ - for (i = hashTab->first(); hashTab->index(i) != OREF_NULL; i = hashTab->next(i)) { - /* get the directory index */ - RexxString *name = (RexxString *)hashTab->index(i); - /* add to the table */ - result->put(hashTab->value(i), name); - } - /* have a method table? */ - if (this->method_table != OREF_NULL) { - methodTable = this->method_table; - /* need to extract method values */ - for (i = methodTable->first(); methodTable->available(i); i = methodTable->next(i)) { - /* get the directory index */ - RexxString *name = (RexxString *)methodTable->index(i); - /* get the method */ - RexxMethod *method = (RexxMethod *)methodTable->value(i); - ProtectedObject v; - /* run the method */ - method->run(ActivityManager::currentActivity, this, name, 0, NULL, v); - result->put((RexxObject *)v, name); /* add to the table */ + RexxTable *result = new_table(); /* get a table for the supplier */ + ProtectedObject p(result); + RexxHashTable *hashTab = this->contents; /* point to the contents */ + /* now traverse the entire table */ + for (HashLink i = hashTab->first(); hashTab->index(i) != OREF_NULL; i = hashTab->next(i)) + { + /* get the directory index */ + RexxString *name = (RexxString *)hashTab->index(i); + /* add to the table */ + result->put(hashTab->value(i), name); } - } - return result->supplier(); /* convert this to a supplier */ + /* have a method table? */ + if (this->method_table != OREF_NULL) + { + RexxTable *methodTable = this->method_table; + /* need to extract method values */ + for (HashLink i = methodTable->first(); methodTable->available(i); i = methodTable->next(i)) + { + /* get the directory index */ + RexxString *name = (RexxString *)methodTable->index(i); + /* get the method */ + RexxMethod *method = (RexxMethod *)methodTable->value(i); + ProtectedObject v; + /* run the method */ + method->run(ActivityManager::currentActivity, this, name, 0, NULL, v); + result->put((RexxObject *)v, name); /* add to the table */ + } + } + return result->supplier(); /* convert this to a supplier */ } RexxArray *RexxDirectory::requestArray() @@ -197,12 +193,14 @@ /* Function: Primitive level request('ARRAY') fast path */ /******************************************************************************/ { - if (isOfClass(Directory, this)) /* primitive level object? */ - return this->makeArray(); /* just do the makearray */ - else /* need to so full request mechanism */ - { - return (RexxArray *)this->sendMessage(OREF_REQUEST, OREF_ARRAYSYM); - } + if (isOfClass(Directory, this)) /* primitive level object? */ + { + return this->makeArray(); /* just do the makearray */ + } + else /* need to so full request mechanism */ + { + return (RexxArray *)this->sendMessage(OREF_REQUEST, OREF_ARRAYSYM); + } } RexxArray *RexxDirectory::makeArray(void) @@ -256,43 +254,38 @@ /* values of all the SETMETHOD methods */ /******************************************************************************/ { - size_t count; /* count of items in the directory */ - size_t i; /* loop counter */ - RexxArray *result; /* returned result */ - RexxHashTable *hashTab; /* contents hash table */ - RexxTable *methodTable; /* contents method table */ - RexxString *name; /* table index */ - - /* return the count as an object */ - count = this->items(); /* get the array size */ - /* get result array of correct size */ - result = (RexxArray *)new_array(count); - ProtectedObject p(result); - i = 1; /* position in array */ - hashTab = this->contents; - /* now traverse the entire table */ - for (HashLink j = hashTab->first(); hashTab->index(j) != OREF_NULL; j = hashTab->next(j)) { - /* get the directory index */ - name = (RexxString *)hashTab->index(j); - /* add to the array */ - result->put(hashTab->value(j), i++); - } - /* have a method table? */ - if (this->method_table != OREF_NULL) { - methodTable = this->method_table; /* grab the table */ - /* need to extract method values */ - for (HashLink j = methodTable->first(); methodTable->available(j); j = methodTable->next(j)) { - /* get the directory index */ - name = (RexxString *)methodTable->index(j); - /* need to extract method values */ - RexxMethod *method = (RexxMethod *)methodTable->value(j); - ProtectedObject v; - /* run the method */ - method->run(ActivityManager::currentActivity, this, name, 0, NULL, v); - result->put((RexxObject *)v, i++); /* add to the array */ + size_t count = this->items(); /* get the array size */ + /* get result array of correct size */ + RexxArray *result = (RexxArray *)new_array(count); + ProtectedObject p(result); + size_t i = 1; /* position in array */ + RexxHashTable *hashTab = this->contents; + /* now traverse the entire table */ + for (HashLink j = hashTab->first(); hashTab->index(j) != OREF_NULL; j = hashTab->next(j)) + { + /* get the directory index */ + RexxString *name = (RexxString *)hashTab->index(j); + /* add to the array */ + result->put(hashTab->value(j), i++); } - } - return result; /* send back the array */ + /* have a method table? */ + if (this->method_table != OREF_NULL) + { + RexxTable *methodTable = this->method_table; /* grab the table */ + /* need to extract method values */ + for (HashLink j = methodTable->first(); methodTable->available(j); j = methodTable->next(j)) + { + /* get the directory index */ + RexxString *name = (RexxString *)methodTable->index(j); + /* need to extract method values */ + RexxMethod *method = (RexxMethod *)methodTable->value(j); + ProtectedObject v; + /* run the method */ + method->run(ActivityManager::currentActivity, this, name, 0, NULL, v); + result->put((RexxObject *)v, i++); /* add to the array */ + } + } + return result; /* send back the array */ } RexxObject *RexxDirectory::entryRexx( @@ -303,16 +296,16 @@ /* string or a name object. Thus, this may raise NOSTRING. */ /******************************************************************************/ { - RexxObject *temp; /* Temporary holder for return value */ + /* get a string parameter (uppercase)*/ + entryName = REQUIRED_STRING(entryName, ARG_ONE)->upper(); + RexxObject *temp = this->at(entryName); /* retrieve the name */ - /* get a string parameter (uppercase)*/ - entryName = REQUIRED_STRING(entryName, ARG_ONE)->upper(); - temp = this->at(entryName); /* retrieve the name */ - - /* if we found nothing or the method */ - if (temp == OREF_NULL) /* we ran returned nothing, */ - temp = TheNilObject; /* return TheNilObject as a default */ - return temp; /* return the value */ + /* if we found nothing or the method */ + if (temp == OREF_NULL) /* we ran returned nothing, */ + { + temp = TheNilObject; /* return TheNilObject as a default */ + } + return temp; /* return the value */ } RexxObject *RexxDirectory::hasIndex( @@ -322,25 +315,29 @@ /* without uppercasing) */ /******************************************************************************/ { - RexxMethod *method; /* retrieved method */ - - /* get as a string parameter */ - indexName = REQUIRED_STRING(indexName, ARG_ONE); - /* got a value? */ - if (this->contents->stringGet(indexName) != OREF_NULL) - return (RexxObject *)TheTrueObject;/* return true */ - else { - /* have a table? */ - if (this->method_table != OREF_NULL) { - /* look for a method */ - method = (RexxMethod *)this->method_table->stringGet(indexName); - if (method != OREF_NULL) /* have a method? */ - /* then we have the index */ - return (RexxObject *)TheTrueObject; + /* get as a string parameter */ + indexName = REQUIRED_STRING(indexName, ARG_ONE); + /* got a value? */ + if (this->contents->stringGet(indexName) != OREF_NULL) + { + return(RexxObject *)TheTrueObject;/* return true */ } - /* not in the directory */ - return (RexxObject *)TheFalseObject; - } + else + { + /* have a table? */ + if (this->method_table != OREF_NULL) + { + /* look for a method */ + RexxMethod *method = (RexxMethod *)this->method_table->stringGet(indexName); + if (method != OREF_NULL) /* have a method? */ + { + /* then we have the index */ + return(RexxObject *)TheTrueObject; + } + } + /* not in the directory */ + return(RexxObject *)TheFalseObject; + } } RexxObject *RexxDirectory::hasEntry( @@ -350,25 +347,29 @@ /* upper cased) */ /******************************************************************************/ { - RexxMethod *method; /* retrieved method name */ - - /* get as a string parameter */ - entryName = REQUIRED_STRING(entryName, ARG_ONE)->upper(); - /* in the table? */ - if (this->contents->stringGet(entryName) != OREF_NULL) - return (RexxObject *)TheTrueObject;/* this is true */ - else { - /* have a table? */ - if (this->method_table != OREF_NULL) { - /* look for a method */ - method = (RexxMethod *)this->method_table->stringGet(entryName); - if (method != OREF_NULL) /* have a method? */ - /* then we have the index */ - return (RexxObject *)TheTrueObject; + /* get as a string parameter */ + entryName = REQUIRED_STRING(entryName, ARG_ONE)->upper(); + /* in the table? */ + if (this->contents->stringGet(entryName) != OREF_NULL) + { + return(RexxObject *)TheTrueObject;/* this is true */ } - /* not in the directory */ - return (RexxObject *)TheFalseObject; - } + else + { + /* have a table? */ + if (this->method_table != OREF_NULL) + { + /* look for a method */ + RexxMethod *method = (RexxMethod *)this->method_table->stringGet(entryName); + if (method != OREF_NULL) /* have a method? */ + { + /* then we have the index */ + return(RexxObject *)TheTrueObject; + } + } + /* not in the directory */ + return(RexxObject *)TheFalseObject; + } } RexxObject *RexxDirectory::setEntry( @@ -431,32 +432,33 @@ /* return value handling is performed. */ /******************************************************************************/ { - RexxString * message_value; /* value of the message name */ - stringsize_t message_length; /* length of the message name */ - - /* validate the name */ - message_value = REQUIRED_STRING(msgname, ARG_ONE); - required_arg(arguments, TWO); /* need an argument array */ - /* get the length */ - message_length = message_value->getLength(); - /* assignment form of access? */ - if (message_length > 0 && message_value->getChar(message_length - 1) == '=') { - /* get this as an array */ - arguments = (RexxArray *)REQUEST_ARRAY(arguments); - /* not an array item or a multiple */ - /* dimension one, or more than one */ - /* argument (CHM) */ - if (arguments == TheNilObject || arguments->getDimension() != 1 || - arguments->size() != 1 ) - /* raise an error */ - reportException(Error_Incorrect_method_noarray, IntegerTwo); - /* extract the name part of the msg */ - message_value = (RexxString *)message_value->extract(0, message_length - 1); - /* do this as an assignment */ - return this->setEntry(message_value, arguments->get(1)); - } - else /* just a lookup form */ - return this->entryRexx(message_value); + /* validate the name */ + RexxString *message_value = REQUIRED_STRING(msgname, ARG_ONE); + required_arg(arguments, TWO); /* need an argument array */ + /* get the length */ + stringsize_t message_length = message_value->getLength(); + /* assignment form of access? */ + if (message_length > 0 && message_value->getChar(message_length - 1) == '=') + { + /* get this as an array */ + arguments = (RexxArray *)REQUEST_ARRAY(arguments); + /* not an array item or a multiple */ + /* dimension one, or more than one */ + /* argument (CHM) */ + if (arguments == TheNilObject || arguments->getDimension() != 1 || arguments->size() != 1 ) + { + /* raise an error */ + reportException(Error_Incorrect_method_noarray, IntegerTwo); + } + /* extract the name part of the msg */ + message_value = (RexxString *)message_value->extract(0, message_length - 1); + /* do this as an assignment */ + return this->setEntry(message_value, arguments->get(1)); + } + else /* just a lookup form */ + { + return this->entryRexx(message_value); + } } RexxObject *RexxDirectory::setMethod( @@ -466,49 +468,60 @@ /* Function: Add a method to the directory method table. */ /******************************************************************************/ { - /* get as a string parameter */ - entryname = REQUIRED_STRING(entryname, ARG_ONE)->upper(); - if (methodobj != OREF_NULL) { /* have a method object? */ - if (!isOfClass(Method, methodobj)) { /* given as a string? */ - /* convert to a method */ - methodobj = TheMethodClass->newRexxCode(entryname, methodobj, IntegerTwo, OREF_NULL); - /* set a new scope on this */ - methodobj->setScope((RexxClass *)this); + /* get as a string parameter */ + entryname = REQUIRED_STRING(entryname, ARG_ONE)->upper(); + if (methodobj != OREF_NULL) /* have a method object? */ + { + if (!isOfClass(Method, methodobj)) /* given as a string? */ + { + /* convert to a method */ + methodobj = RexxMethod::newMethodObject(entryname, methodobj, IntegerTwo, OREF_NULL); + /* set a new scope on this */ + methodobj->setScope((RexxClass *)this); + } + else + { + /* set a new scope on this */ + methodobj = methodobj->newScope((RexxClass *)this); + } + /* the unknown method? */ + if (entryname->strCompare(CHAR_UNKNOWN)) + { + /* stash this is a special place */ + OrefSet(this, this->unknown_method, methodobj); + } + else + { + /* no table yet? */ + if (this->method_table == OREF_NULL) + { + /* create one */ + OrefSet(this, this->method_table, new_table()); + } + /* now add the method */ + this->method_table->stringPut(methodobj, entryname); + } } else - /* set a new scope on this */ - methodobj = methodobj->newScope((RexxClass *)this); - /* the unknown method? */ - if (entryname->strCompare(CHAR_UNKNOWN)) { - /* stash this is a special place */ - OrefSet(this, this->unknown_method, methodobj); + { + /* the unknown method? */ + if (entryname->strCompare(CHAR_UNKNOWN)) + { + /* cast off the unknown method */ + OrefSet(this, this->unknown_method, OREF_NULL); + } + else + { + /* if we have a table */ + if (this->method_table != OREF_NULL) + { + /* remove this entry */ + this->method_table->remove(entryname); + } + } } - else { - /* no table yet? */ - if (this->method_table == OREF_NULL) { - /* create one */ - OrefSet(this, this->method_table, new_table()); - } - /* now add the method */ - this->method_table->stringPut(methodobj, entryname); -// this->contents->remove(entryname); // remove entry in contents! - } - } - else { - /* the unknown method? */ - if (entryname->strCompare(CHAR_UNKNOWN)) { - /* cast off the unknown method */ - OrefSet(this, this->unknown_method, OREF_NULL); - } - else { - /* if we have a table */ - if (this->method_table != OREF_NULL) - /* remove this entry */ - this->method_table->remove(entryname); - } - } - this->contents->remove(entryname); /* remove any table entry */ - return OREF_NULL; /* this always returns nothing */ + this->contents->remove(entryname); /* remove any table entry */ + return OREF_NULL; /* this always returns nothing */ } RexxObject *RexxDirectory::mergeItem( Modified: sandbox/rick/opt/kernel/classes/MessageClass.cpp =================================================================== --- sandbox/rick/opt/kernel/classes/MessageClass.cpp 2008-02-08 21:17:58 UTC (rev 2349) +++ sandbox/rick/opt/kernel/classes/MessageClass.cpp 2008-02-09 00:16:13 UTC (rev 2350) @@ -70,27 +70,29 @@ /* Function: Initialize a message object */ /******************************************************************************/ { - this->clearObject(); /* Start out with everythign 0. */ - /* defult target is target specified */ - OrefSet(this, this->receiver, _target); - OrefSet(this, this->target, _target); /* Target specified on new */ - /* Args to be sent wuth tmessage */ - OrefSet(this, this->args, _args); - /* initialize a list of message to be*/ - /* once we have a result. */ - OrefSet(this, this->interestedParties, new RexxList); + this->clearObject(); /* Start out with everythign 0. */ + /* defult target is target specified */ + OrefSet(this, this->receiver, _target); + OrefSet(this, this->target, _target); /* Target specified on new */ + /* Args to be sent wuth tmessage */ + OrefSet(this, this->args, _args); + /* initialize a list of message to be*/ + /* once we have a result. */ + OrefSet(this, this->interestedParties, new RexxList); - if (isOfClass(Array, _message)) { /* is message specified as an array? */ - OrefSet(this, this->message, ((RexxString *)((RexxArray *)_message)->get(1))->upper()); - /* starting lookup scope is ourself. */ - OrefSet(this, this->startscope, (RexxClass *)((RexxArray *)_message)->get(2)); - } - else { /* not an array as message. */ - /* Message to be sent. */ - OrefSet(this, this->message, ((RexxString *)_message)->upper()); - /* starting lookup scope is ourself. */ - OrefSet(this, this->startscope, (RexxClass *)TheNilObject); - } + if (isOfClass(Array, _message)) /* is message specified as an array? */ + { + OrefSet(this, this->message, ((RexxString *)((RexxArray *)_message)->get(1))->upper()); + /* starting lookup scope is ourself. */ + OrefSet(this, this->startscope, (RexxClass *)((RexxArray *)_message)->get(2)); + } + else /* not an array as message. */ + { + /* Message to be sent. */ + OrefSet(this, this->message, ((RexxString *)_message)->upper()); + /* starting lookup scope is ourself. */ + OrefSet(this, this->startscope, (RexxClass *)TheNilObject); + } } void RexxMessage::live(size_t liveMark) @@ -156,28 +158,36 @@ /* Function: Add a message object to the notification list */ /******************************************************************************/ { - /* is argument a real message object?*/ - if (message != OREF_NULL && isOfClass(Message, _message)) { - /* Yes, then add it to the */ - /* toBeNotified list. */ + /* is argument a real message object?*/ + if (message != OREF_NULL && isOfClass(Message, _message)) + { + /* Yes, then add it to the */ + /* toBeNotified list. */ - if (this->allNotified()) { /* Have all notifications been sent? */ - /* Yes, then send notification right */ - _message->send(OREF_NULL); /* away */ - } - else { - /* nope, add it to list and wait for */ - /* for result. */ - this->interestedParties->addLast(_message); - } - } - else { /* nope, its and error, report it. */ - if ( message == OREF_NULL) - reportException(Error_Incorrect_method_noarg, IntegerOne); - else - reportException(Error_Incorrect_method_nomessage, _message); - } - return OREF_NULL; /* all done, we return nothing */ + if (this->allNotified()) /* Have all notifications been sent? */ + { + /* Yes, then send notification right */ + _message->send(OREF_NULL); /* away */ + } + else + { + /* nope, add it to list and wait for */ + /* for result. */ + this->interestedParties->addLast(_message); + } + } + else + { /* nope, its and error, report it. */ + if ( message == OREF_NULL) + { + reportException(Error_Incorrect_method_noarg, IntegerOne); + } + else + { + reportException(Error_Incorrect_method_nomessage, _message); + } + } + return OREF_NULL; /* all done, we return nothing */ } RexxObject *RexxMessage::result(void) @@ -186,40 +196,48 @@ /******************************************************************************/ { - /* Did send/satrt cause an error */ - /*condition Yes, we need to raise it */ - /*here. */ - if (this->raiseError()) { - ActivityManager::currentActivity->reraiseException(this->condition); - } - else { - /* Quick test to see if result */ - /*already present */ - if (!this->resultReturned()) { - /* got an activity available? */ - if (this->startActivity != OREF_NULL) - /* go perform dead lock checks */ - this->startActivity->checkDeadLock(ActivityManager::currentActivity); + /* Did send/satrt cause an error */ + /*condition Yes, we need to raise it */ + /*here. */ + if (this->raiseError()) + { + ActivityManager::currentActivity->reraiseException(this->condition); + } + else + { + /* Quick test to see if result */ + /*already present */ + if (!this->resultReturned()) + { + /* got an activity available? */ + if (this->startActivity != OREF_NULL) + { + /* go perform dead lock checks */ + this->startActivity->checkDeadLock(ActivityManager::currentActivity); + } - /* No result yet, now we need to wait*/ - /* until we get a result. */ - /* Is anyone else waiting ???? */ - if (this->waitingActivities == OREF_NULL) - /* No, Create a waiting list */ - OrefSet(this, this->waitingActivities, new_list()); - /* add this activity to the list */ - this->waitingActivities->addLast((RexxObject *)ActivityManager::currentActivity); - /* now go wait to be woken up */ - ActivityManager::currentActivity->waitReserve((RexxObject *)this); - if (this->raiseError()) { /* do we need to raise an error. */ - /* yes, */ - this->setErrorReported(); /* indicate error was reported, and */ - /* report and error. */ - ActivityManager::currentActivity->reraiseException(this->condition); - } - } - } - return this->resultObject; /* ok, return the result. */ + /* No result yet, now we need to wait*/ + /* until we get a result. */ + /* Is anyone else waiting ???? */ + if (this->waitingActivities == OREF_NULL) + { + /* No, Create a waiting list */ + OrefSet(this, this->waitingActivities, new_list()); + } + /* add this activity to the list */ + this->waitingActivities->addLast((RexxObject *)ActivityManager::currentActivity); + /* now go wait to be woken up */ + ActivityManager::currentActivity->waitReserve((RexxObject *)this); + if (this->raiseError()) /* do we need to raise an error. */ + { + /* yes, */ + this->setErrorReported(); /* indicate error was reported, and */ + /* report and error. */ + ActivityManager::currentActivity->reraiseException(this->condition); + } + } + } + return this->resultObject; /* ok, return the result. */ } RexxObject *RexxMessage::send(RexxObject *_receiver) @@ -227,51 +245,58 @@ /* Function: Send the message contained by this message object */ /******************************************************************************/ { - RexxActivity *myActivity; /* Activity I am running under */ - /* has message already been sent to */ - /* the receiver? */ - if (this->msgSent()) - /* Yes, this is an error */ - reportException(Error_Execution_message_reuse); + if (this->msgSent()) + { + /* Yes, this is an error */ + reportException(Error_Execution_message_reuse); + } - /* get the activity I'm running under*/ - myActivity = (RexxActivity *)ActivityManager::currentActivity; - /* If we have a pending start message*/ - /* sure this send is a result of */ - /*that message dispatch. */ - if (this->startPending() && myActivity != this->startActivity ) - /* Yes, this is an error */ - reportException(Error_Execution_message_reuse); - this->setMsgSent(); /* indicate we were sent a message */ + /* get the activity I'm running under*/ + RexxActivity *myActivity = (RexxActivity *)ActivityManager::currentActivity; + /* If we have a pending start message*/ + /* sure this send is a result of */ + /*that message dispatch. */ + if (this->startPending() && myActivity != this->startActivity ) + { + /* Yes, this is an error */ + reportException(Error_Execution_message_reuse); + } + this->setMsgSent(); /* indicate we were sent a message */ - if (_receiver != OREF_NULL) { /* new receiver specified? */ - /* Yes, indicate this is the receiver*/ - OrefSet(this, this->receiver, _receiver); - } - /* validate startscope */ - if (!this->receiver->behaviour->checkScope(this->startscope)) { - reportException(Error_Incorrect_method_array_noclass, IntegerTwo); - } - /* this is a primitive object? */ - /* tell the activation/nativeact, we */ - /*are running under to let us know */ - /*if an error occured. */ - myActivity->getTopStackFrame()->setObjNotify(this); - /* set this for resource deadlock */ - /* checking purposes */ - OrefSet(this, this->startActivity, myActivity); - ProtectedObject p; - /* call message_send to do the send */ - /* and assign our result. */ - if (this->startscope != TheNilObject)/* have a starting scope? */ - /* send it with an override */ - this->receiver->messageSend(this->message, this->args->size(), (RexxObject **)this->args->data(), this->startscope, p); - else /* no over ride */ - this->receiver->messageSend(this->message, this->args->size(), (RexxObject **)this->args->data(), p); - this->resultObject = (RexxObject *)p; - this->setResultReturned(); /* Indicate we have a result. */ - this->sendNotification(); - return this->resultObject; /* return the result of the send. */ + if (_receiver != OREF_NULL) /* new receiver specified? */ + { + /* Yes, indicate this is the receiver*/ + OrefSet(this, this->receiver, _receiver); + } + /* validate startscope */ + if (!this->receiver->behaviour->checkScope(this->startscope)) + { + reportException(Error_Incorrect_method_array_noclass, IntegerTwo); + } + /* this is a primitive object? */ + /* tell the activation/nativeact, we */ + /*are running under to let us know */ + /*if an error occured. */ + myActivity->getTopStackFrame()->setObjNotify(this); + /* set this for resource deadlock */ + /* checking purposes */ + OrefSet(this, this->startActivity, myActivity); + ProtectedObject p; + /* call message_send to do the send */ + /* and assign our result. */ + if (this->startscope != TheNilObject)/* have a starting scope? */ + { + /* send it with an override */ + this->receiver->messageSend(this->message, this->args->size(), (RexxObject **)this->args->data(), this->startscope, p); + } + else /* no over ride */ + { + this->receiver->messageSend(this->message, this->args->size(), (RexxObject **)this->args->data(), p); + } + this->resultObject = (RexxObject *)p; + this->setResultReturned(); /* Indicate we have a result. */ + this->sendNotification(); + return this->resultObject; /* return the result of the send. */ } RexxObject *RexxMessage::start(RexxObject *_receiver) @@ -282,47 +307,36 @@ /* object on the new activity. */ /******************************************************************************/ { - RexxMethod *newNMethod; /* NMethod of messaeg_nstart method */ - RexxActivity *newActivity; /* Activity the start will be run on */ - RexxActivity *oldActivity; /* Currently executing activity */ - RexxNativeActivation *newNativeAct; /* Native Activation to run on */ + /* has message already been sent or */ + /* is another start message pending? */ + if (this->msgSent() || this->startPending()) + { + /* Yes, this is an error */ + reportException(Error_Execution_message_reuse); + } + /* indicate object has received a */ + /*start we need this additional bit */ + /*so that the send message will */ + /*accept this msg */ + this->setStartPending(); - /* has message already been sent or */ - /* is another start message pending? */ - if (this->msgSent() || this->startPending()) - /* Yes, this is an error */ - reportException(Error_Execution_message_reuse); - /* indicate object has received a */ - /*start we need this additional bit */ - /*so that the send message will */ - /*accept this msg */ - this->setStartPending(); + if (_receiver != OREF_NULL) /* new receiver specified? */ + { + /* Yes, indicate this is the receiver*/ + OrefSet(this, this->receiver, _receiver); + } - if (_receiver != OREF_NULL) { /* new receiver specified? */ - /* Yes, indicate this is the receiver*/ - OrefSet(this, this->receiver, _receiver); - } - /* create a native method object */ - /* this method is found in OKNMSG.C */ - newNMethod = new_method(new RexxNativeCode((PNATIVEMETHOD)message_nstart)); - /* get the current activity */ - oldActivity = ActivityManager::currentActivity; - /* Create the new activity */ - newActivity = oldActivity->spawnReply(); - /* indicate the activity the send */ - /*message should come in on. */ - OrefSet(this, this->startActivity, newActivity); - /* create the native method to be run*/ - /* on the activity */ - newNativeAct = new RexxNativeActivation(newActivity, newNMethod, (RexxNativeCode *)newNMethod->getCode()); - newNativeAct->setObjNotify(this); - newNativeAct->prepare(this, message, 0, NULL); - /* Push new nativeAct onto activity */ - newActivity->pushStackFrame(newNativeAct); /*stack */ - /* indicate we want the NativeAct to */ - newActivity->run(); /*run */ - return OREF_NULL; /* all done here, return to caller. */ + /* get the current activity */ + RexxActivity *oldActivity = ActivityManager::currentActivity; + /* Create the new activity */ + RexxActivity *newActivity = oldActivity->spawnReply(); + /* indicate the activity the send */ + /*message should come in on. */ + OrefSet(this, this->startActivity, newActivity); + // tell the activity to run this + newActivity->run(this); + return OREF_NULL; /* all done here, return to caller. */ } void RexxMessage::sendNotification(void) @@ -331,41 +345,39 @@ /* all interested parties, and post the waitResult semopohore if it exists */ /******************************************************************************/ { - RexxObject *listIndex; /* index of the list as we traverse */ - RexxMessage *thisMessage; /* Message object to noitfy */ - RexxActivity *waitingActivity; /* activity to notify */ - size_t i; /* loop index */ - - /* no longer care about any error */ - /*condition */ - ActivityManager::currentActivity->getTopStackFrame()->setObjNotify(OREF_NULL); - /* others waiting for a result? */ - if (this->waitingActivities != OREF_NULL) { - i = this->waitingActivities->getSize();/* get the waiting count */ - while (i--) { /* while we have items */ - /* get the first item */ - waitingActivity = (RexxActivity *)this->waitingActivities->removeFirst(); - waitingActivity->postRelease(); /* go wake it up */ + /* no longer care about any error */ + /*condition */ + ActivityManager::currentActivity->getTopStackFrame()->setObjNotify(OREF_NULL); + /* others waiting for a result? */ + if (this->waitingActivities != OREF_NULL) + { + size_t i = this->waitingActivities->getSize();/* get the waiting count */ + while (i--) /* while we have items */ + { + /* get the first item */ + RexxActivity *waitingActivity = (RexxActivity *)this->waitingActivities->removeFirst(); + waitingActivity->postRelease(); /* go wake it up */ + } } - } - /* now traverse the list of Iterested*/ - /* parties, and let them know we */ - /*have a result */ - for (listIndex = this->interestedParties->firstRexx() ; - listIndex != TheNilObject ; - listIndex = this->interestedParties->next(listIndex) ) { - /* Get the next message object to */ - /*process */ - thisMessage = (RexxMessage *)this->interestedParties->value(listIndex); - /* now just have this message send */ - /*its message */ - thisMessage->send(OREF_NULL); - } + /* now traverse the list of Iterested*/ + /* parties, and let them know we */ + /*have a result */ + for (size_t listIndex = this->interestedParties->firstIndex() ; + listIndex != LIST_END; + listIndex = this->interestedParties->nextIndex(listIndex) ) + { + /* Get the next message object to */ + /*process */ + RexxMessage *thisMessage = (RexxMessage *)this->interestedParties->getValue(listIndex); + /* now just have this message send */ + /*its message */ + thisMessage->send(OREF_NULL); + } - /* indicate we notified all */ - /*Interested parties. Not used */ - /*yet.... */ - this->setAllNotified(); + /* indicate we notified all */ + /*Interested parties. Not used */ + /*yet.... */ + this->setAllNotified(); } @@ -388,12 +400,16 @@ /* Function: Give a completed polling status */ /******************************************************************************/ { - /* Test to see if result already */ - /*present or error occured in send? */ - if (this->resultReturned() || this->raiseError()) - return (RexxObject *)TheTrueObject; /* Yes, return true */ - else - return (RexxObject *)TheFalseObject;/* nope return false. */ + /* Test to see if result already */ + /*present or error occured in send? */ + if (this->resultReturned() || this->raiseError()) + { + return(RexxObject *)TheTrueObject; /* Yes, return true */ + } + else + { + return(RexxObject *)TheFalseObject;/* nope return false. */ + } } @@ -495,136 +511,157 @@ /* Function: Rexx level new routine */ /******************************************************************************/ { - RexxMessage *newMessage; /* actual message to be sent. */ - RexxObject *_target; /* object to receive message. */ - RexxObject *_message; /* message to be sent to receiver. */ - RexxArray *argPtr = OREF_NULL; /* arguments to be sent with message */ - /* the option parameter as a string */ - RexxString *optionString; - RexxObject *sender; /* sending object */ - RexxObject *msgName; /* msgname to be sent */ - RexxArray *msgNameArray; /* msgname to be sent */ - RexxString *msgNameStr; /* msgname as a string object */ - char option; /* how are the args passed. */ - size_t num_args; /* number of args passed. */ + RexxObject *sender; /* sending object */ + RexxArray *argPtr; // the arguments used with the message. - num_args = argCount; /* get number of args passed */ + size_t num_args = argCount; /* get number of args passed */ - if (num_args < 2 ) { /* passed less than 2 args? */ - /* Yes, this is an error. */ - reportException(Error_Incorrect_method_minarg, IntegerTwo); - } - _target = msgArgs[0]; /* Get the receiver object */ - if (_target == OREF_NULL) /* no receiver? */ - /* this is an error */ - reportException(Error_Incorrect_method_noarg, IntegerOne); - _message = msgArgs[1]; /* get the message . */ + if (num_args < 2 ) /* passed less than 2 args? */ + { + /* Yes, this is an error. */ + reportException(Error_Incorrect_method_minarg, IntegerTwo); + } + RexxObject *_target = msgArgs[0]; /* Get the receiver object */ + if (_target == OREF_NULL) /* no receiver? */ + { + /* this is an error */ + reportException(Error_Incorrect_method_noarg, IntegerOne); + } + RexxObject *_message = msgArgs[1]; /* get the message . */ - /* see if this is an array item */ - msgNameArray = REQUEST_ARRAY(_message); - if (msgNameArray != TheNilObject) { /* is message specified as an array? */ - if (msgNameArray->getDimension() != 1 || msgNameArray->size() != 2) - /* raise an error */ - reportException(Error_Incorrect_method_message); - /* Was message name omitted? */ - msgName = msgNameArray->get(1); - if (msgName == OREF_NULL) - /* Yes, this is an error, report it. */ - reportException(Error_Incorrect_method_noarg, IntegerOne); + /* see if this is an array item */ + RexxArray *msgNameArray = REQUEST_ARRAY(_message); + if (msgNameArray != TheNilObject) /* is message specified as an array? */ + { + if (msgNameArray->getDimension() != 1 || msgNameArray->size() != 2) + { + /* raise an error */ + reportException(Error_Incorrect_method_message); + } + /* Was message name omitted? */ + RexxObject *msgName = msgNameArray->get(1); + if (msgName == OREF_NULL) + { + /* Yes, this is an error, report it. */ + reportException(Error_Incorrect_method_noarg, IntegerOne); + } - msgNameStr = (RexxString *)msgName->makeString(); - if (msgNameStr == TheNilObject) /* got back .nil? */ - /* raise an error */ - reportException(Error_Incorrect_method_array_nostring, IntegerOne); - /* Was starting scope omitted ? */ - if (OREF_NULL == msgNameArray->get(2)) - /* Yes, this is an error, report it. */ - reportException(Error_Incorrect_method_noarg, IntegerTwo); - /* get the top activation */ - RexxActivationBase *activation = ActivityManager::currentActivity->getTopStackFrame(); - /* have an activation? */ - if (activation != OREF_NULL) + RexxString *msgNameStr = (RexxString *)msgName->makeString(); + if (msgNameStr == TheNilObject) /* got back .nil? */ + { + /* raise an error */ + reportException(Error_Incorrect_method_array_nostring, IntegerOne); + } + /* Was starting scope omitted ? */ + if (OREF_NULL == msgNameArray->get(2)) + { + /* Yes, this is an error, report it. */ + reportException(Error_Incorrect_method_noarg, IntegerTwo); + } + /* get the top activation */ + RexxActivationBase *activation = ActivityManager::currentActivity->getTopStackFrame(); + /* have an activation? */ + if (activation != OREF_NULL) + { + /* get the receiving object */ + sender = activation->getReceiver(); + if (sender != target) /* not the same receiver? */ + { + /* this is an error */ + reportException(Error_Execution_super); + } + } + else + { + /* this is an error */ + reportException(Error_Execution_super); + } + _message = msgNameArray; /* Message to be sent. */ + } + else /* not an array as message. */ { - /* get the receiving object */ - sender = activation->getReceiver(); - if (sender != target) /* not the same receiver? */ - { - /* this is an error */ - reportException(Error_Execution_super); - } + /* force to a string value */ + _message = REQUIRED_STRING(_message, ARG_TWO); + /* Message to be sent. */ } - else - /* this is an error */ - reportException(Error_Execution_super); - _message = msgNameArray; /* Message to be sent. */ - } - else { /* not an array as message. */ - /* force to a string value */ - _message = REQUIRED_STRING(_message, ARG_TWO); - /* Message to be sent. */ - } - /* are there arguments to be sent */ - /*with the message? */ - if (num_args > 2 ) { - /* get 3rd arg only concerned w/ 1st */ - optionString = (RexxString *)msgArgs[2]; - /* Did we really get an option */ - /*passed? */ - if (optionString == OREF_NULL) { - /* nope, use null array as argument */ - argPtr = (RexxArray *)TheNullArray->copy(); - } - else { - /* Convert it into a string. */ - optionString = REQUIRED_STRING(optionString, ARG_THREE); - /* char and make it lower case */ - option = tolower(optionString->getChar(0)); - if (option == 'a') { /* args passed as an array? */ - /* are there less than 4 required */ - /*args? */ - if (num_args < 4) /* this is an error */ - reportException(Error_Incorrect_method_minarg, IntegerFour); + /* are there arguments to be sent */ + /*with the message? */ + if (num_args > 2 ) + { + /* get 3rd arg only concerned w/ 1st */ + RexxString *optionString = (RexxString *)msgArgs[2]; + /* Did we really get an option */ + /*passed? */ + if (optionString == OREF_NULL) + { + /* nope, use null array as argument */ + argPtr = (RexxArray *)TheNullArray->copy(); + } + else + { + /* Convert it into a string. */ + optionString = REQUIRED_STRING(optionString, ARG_THREE); + /* char and make it lower case */ + char option = tolower(optionString->getChar(0)); + if (option == 'a') /* args passed as an array? */ + { + /* are there less than 4 required */ + /*args? */ + if (num_args < 4) /* this is an error */ + { + reportException(Error_Incorrect_method_minarg, IntegerFour); + } - /* are there more than 4 required */ - /*args? */ - if (num_args > 4) /* this is an error */ - reportException(Error_Incorrect_method_maxarg, IntegerFour); + /* are there more than 4 required */ + /*args? */ + if (num_args > 4) /* this is an error */ + { + reportException(Error_Incorrect_method_maxarg, IntegerFour); + } - /* get the array of arguments */ - argPtr = (RexxArray *)msgArgs[3]; - if (argPtr == OREF_NULL) /* no array given? */ - /* this is an error */ - reportException(Error_Incorrect_method_noarg, IntegerFour); - /* force to array form */ - argPtr = (RexxArray *)REQUEST_ARRAY(argPtr); - /* not an array? */ - if (argPtr == TheNilObject || argPtr->getDimension() != 1) - /* raise an error */ - reportException(Error_Incorrect_method_noarray, msgArgs[3]); - } - else if (option == 'i' ){ /* specified as individual? */ - /* yes, build array of all arguments */ - argPtr = new (argCount - 3, msgArgs + 3) RexxArray; - } - else { - reportException(Error_Incorrect_method_option, "AI", msgArgs[2]); - } + /* get the array of arguments */ + argPtr = (RexxArray *)msgArgs[3]; + if (argPtr == OREF_NULL) /* no array given? */ + { + /* this is an error */ + reportException(Error_Incorrect_method_noarg, IntegerFour); + } + /* force to array form */ + argPtr = (RexxArray *)REQUEST_ARRAY(argPtr); + /* not an array? */ + if (argPtr == TheNilObject || argPtr->getDimension() != 1) + { + /* raise an error */ + reportException(Error_Incorrect_method_noarray, msgArgs[3]); + } + } + else if (option == 'i' ) /* specified as individual? */ + { + /* yes, build array of all arguments */ + argPtr = new (argCount - 3, msgArgs + 3) RexxArray; + } + else + { + reportException(Error_Incorrect_method_option, "AI", msgArgs[2]); + } + } } - } - else { - /* no args, use a null array. */ - argPtr = (RexxArray *)TheNullArray->copy(); - } - /* all args are parcelled out, go */ - /*create the new message object... */ - newMessage = new RexxMessage(_target, _message, argPtr); - /* actually a subclassed item? */ - if (((RexxClass *)this)->isPrimitive()){ - /* Give new object its behaviour */ - newMessage->setBehaviour(((RexxClass *)this)->getInstanceBehaviour()); - newMessage->sendMessage(OREF_INIT);/* call any rexx inits */ - } - return newMessage; /* return the new message */ + else + { + /* no args, use a null array. */ + argPtr = (RexxArray *)TheNullArray->copy(); + } + /* all args are parcelled out, go */ + /*create the new message object... */ + RexxMessage *newMessage = new RexxMessage(_target, _message, argPtr); + /* actually a subclassed item? */ + if (((RexxClass *)this)->isPrimitive()) + { + /* Give new object its behaviour */ + newMessage->setBehaviour(((RexxClass *)this)->getInstanceBehaviour()); + newMessage->sendMessage(OREF_INIT);/* call any rexx inits */ + } + return newMessage; /* return the new message */ } Modified: sandbox/rick/opt/kernel/classes/MethodClass.cpp =================================================================== --- sandbox/rick/opt/kernel/classes/MethodClass.cpp 2008-02-08 21:17:58 UTC (rev 2349) +++ sandbox/rick/opt/kernel/classes/MethodClass.cpp 2008-02-09 00:16:13 UTC (rev 2350) @@ -58,11 +58,12 @@ #include "ProtectedObject.hpp" #include "BufferClass.hpp" #include "RexxInternalApis.h" +#include "RoutineClass.hpp" #include <ctype.h> // singleton class instance -RexxMethodClass *RexxMethod::classInstance = OREF_NULL; +RexxClass *RexxMethod::classInstance = OREF_NULL; RexxMethod::RexxMethod(BaseCode *codeObj) /******************************************************************************/ @@ -138,42 +139,6 @@ } -void RexxMethod::call( - RexxActivity *activity, /* activity running under */ - RexxString *msgname, /* message to be run */ - RexxObject**argPtr, /* arguments to the method */ - size_t argcount, /* the count of arguments */ - RexxString *calltype, /* COMMAND/ROUTINE/FUNCTION */ - RexxString *environment, /* initial command environment */ - int context, /* type of context */ - ProtectedObject &result) // the method result -/******************************************************************************/ -/* Function: Call a method as a top level program or external function call */ -/******************************************************************************/ -{ - ProtectedObject p(this); // belt-and-braces to make sure this is protected - // just forward this to the code object - code->call(activity, this, msgname, argPtr, argcount, calltype, environment, context, result); -} - - -void RexxMethod::runProgram( - RexxActivity *activity, - RexxString * calltype, /* type of invocation */ - RexxString * environment, /* initial address */ - RexxObject **arguments, /* array of arguments */ - size_t argCount, /* the number of arguments */ - ProtectedObject &result) // the method result -/****************************************************************************/ -/* Function: Run a method as a program */ -/****************************************************************************/ -{ - /* ensure correct scope */ - RexxMethod *method = this->newScope((RexxClass *)TheNilObject); - method->call(activity, OREF_NULL, OREF_NONE, arguments, argCount, calltype, environment, PROGRAMCALL, result); -} - - RexxMethod *RexxMethod::newScope( RexxClass *_scope) /* new method scope */ /******************************************************************************/ @@ -195,13 +160,6 @@ } } -RexxArray *RexxMethod::source() -/******************************************************************************/ -/* Function: Return an array of source strings that represent this method */ -/******************************************************************************/ -{ - return code->getSource(); -} RexxObject *RexxMethod::setSecurityManager( RexxObject *manager) /* supplied security manager */ @@ -347,85 +305,78 @@ * * @return The constructed method object. */ -RexxMethod *RexxMethod::newMethodObject(RexxString *pgmname, RexxObject *source, RexxObject *position, RexxMethod *parentScope) +RexxMethod *RexxMethod::newMethodObject(RexxString *pgmname, RexxObject *source, RexxObject *position, RexxSource *parentSource) { - RexxSource *newSource; /* created source object */ - - // request this as an array. If not convertable, then we'll use it as a string - RexxArray *newSourceArray = source->requestArray(); - /* couldn't convert? */ - if (newSourceArray == (RexxArray *)TheNilObject) - { - /* get the string representation */ - RexxString *sourceString = source->makeString(); - /* got back .nil? */ - if (sourceString == (RexxString *)TheNilObject) + // request this as an array. If not convertable, then we'll use it as a string + RexxArray *newSourceArray = source->requestArray(); + /* couldn't convert? */ + if (newSourceArray == (RexxArray *)TheNilObject) { - /* raise an error */ - reportException(Error_Incorrect_method_no_method, position); + /* get the string representation */ + RexxString *sourceString = source->makeString(); + /* got back .nil? */ + if (sourceString == (RexxString *)TheNilObject) + { + /* raise an error */ + reportException(Error_Incorrect_method_no_method, position); + } + /* wrap an array around the value */ + newSourceArray = new_array(sourceString); } - /* wrap an array around the value */ - newSourceArray = new_array(sourceString); - } - else /* have an array, make sure all */ - { - /* is it single dimensional? */ - if (newSourceArray->getDimension() != 1) + else /* have an array, make sure all */ { - /* raise an error */ - reportException(Error_Incorrect_method_noarray, position); + /* is it single dimensional? */ + if (newSourceArray->getDimension() != 1) + { + /* raise an error */ + reportException(Error_Incorrect_method_noarray, position); + } + /* element are strings. */ + /* Make a source array safe. */ + ProtectedObject p(newSourceArray); + /* Make sure all elements in array */ + for (size_t counter = 1; counter <= newSourceArray->size(); counter++) + { + /* Get element as string object */ + RexxString *sourceString = newSourceArray ->get(counter)->makeString(); + /* Did it convert? */ + if (sourceString == (RexxString *)TheNilObject) + { + /* and report the error. */ + reportException(Error_Incorrect_method_nostring_inarray, IntegerTwo); + } + else + { + /* itsa string add to source array */ + newSourceArray ->put(sourceString, counter); + } + } } - /* element are strings. */ - /* Make a source array safe. */ - ProtectedObject p(newSourceArray); - /* Make sure all elements in array */ - for (size_t counter = 1; counter <= newSourceArray->size(); counter++) - { - /* Get element as string object */ - sourceString = newSourceArray ->get(counter)->makeString(); - /* Did it convert? */ - if (sourceString == (RexxString *)TheNilObject) - { - /* and report the error. */ - reportException(Error_Incorrect_method_nostring_inarray, IntegerTwo); - } - else - { - /* itsa string add to source array */ - newSourceArray ->put(sourceString, counter); - } - } - } - /* create a source object */ - RexxSource *newSource = new RexxSource (pgmname, newSourceArray); + /* create a source object */ + RexxSource *newSource = new RexxSource (pgmname, newSourceArray); - ProtectedObject p(newSource); - Rexxmethod *result = RexxMethod::newRexxMethod(newSource, OREF_NULL); - RexxCode *resultCode = (RexxCode *)result->getCode(); + ProtectedObject p(newSource); + RexxMethod *result = RexxMethod::newRexxMethod(newSource, OREF_NULL); - // if we've been provided with a scope, use it - if (parentScope != OREF_NULL) - { - parentSource = parentScope->getSourceObject(); - } - else - { - // see if we have an active context and use the current source as the basis for the lookup - RexxActivation *currentContext = ActivityManager::currentActivity->getCurrentRexxFrame(); - if (currentContext != OREF_NULL) - { - parentSource = currentContext->getSource(); - } - } + // if we've been provided with a scope, use it + if (parentSource == OREF_NULL) + { + // see if we have an active context and use the current source as the basis for the lookup + RexxActivation *currentContext = ActivityManager::currentActivity->getCurrentRexxFrame(); + if (currentContext != OREF_NULL) + { + parentSource = currentContext->getSource(); + } + } - // if there is a parent source, then merge in the scope information - if (parentSource != OREF_NULL) - { - code->getSourceObject()->inheritSourceContext(parentSource); - } + // if there is a parent source, then merge in the scope information + if (parentSource != OREF_NULL) + { + newSource->inheritSourceContext(parentSource); + } - return result; + return result; } @@ -437,54 +388,59 @@ /* array */ /******************************************************************************/ { - RexxObject *pgmname; /* method name */ - RexxObject *source; /* Array or string object */ - RexxMethod *newMethod; /* newly created method object */ - RexxObject *option = OREF_NULL; - size_t initCount = 0; /* count of arguments we pass along */ + RexxObject *pgmname; /* method name */ + RexxObject *source; /* Array or string object */ + RexxMethod *newMethod; /* newly created method object */ + RexxObject *option = OREF_NULL; + size_t initCount = 0; /* count of arguments we pass along */ - /* break up the arguments */ + /* break up the arguments */ - process_new_args(init_args, argCount, &init_args, &initCount, 2, (RexxObject **)&pgmname, (RexxObject **)&source); - /* get the method name as a string */ - RexxString *nameString = REQUIRED_STRING(pgmname, ARG_ONE); - required_arg(source, TWO); /* make sure we have the second too */ + process_new_args(init_args, argCount, &init_args, &initCount, 2, (RexxObject **)&pgmname, (RexxObject **)&source); + /* get the method name as a string */ + RexxString *nameString = REQUIRED_STRING(pgmname, ARG_ONE); + required_arg(source, TWO); /* make sure we have the second too */ - RexxMethod *sourceContext = OREF_NULL; - // retrieve extra parameter if exists - if (initCount != 0) - { - process_new_args(init_args, initCount, &init_args, &initCount, 1, (RexxObject **)&option, NULL); - if (isOfClass(Method, option)) - { - sourceContext = (RexxMethod *)option; - } - else - { - // this must be a string (or convertable) and have a specific value - option = option->requestString(); - if (option == TheNilObject) - { - reportException(Error_Incorrect_method_argType, IntegerThree, "Method/String object"); - } - // default given? set option to NULL (see code below) - if (!((RexxString *)option)->strICompare("PROGRAMSCOPE")) - { - reportException(Error_Incorrect_call_list, "NEW", IntegerThree, "\"PROGRAMSCOPE\", Method object", option); - } - } - } - /* go create a method */ - newMethod = RexxMethod::newMethodObject(nameString, source, IntegerTwo, sourceContext); - ProtectedObject p(newMethod); - /* Give new object its behaviour */ - newMethod->setBehaviour(((RexxClass)this)->getInstanceBehaviour()); - if (this->hasUninitDefined()) { /* does object have an UNINT method */ - newMethod->hasUninit(); /* Make sure everyone is notified. */ - } - /* now send an INIT message */ - newMethod->sendMessage(OREF_INIT, init_args, initCount); - return newMethod; /* return the new method */ + RexxSource *sourceContext = OREF_NULL; + // retrieve extra parameter if exists + if (initCount != 0) + { + process_new_args(init_args, initCount, &init_args, &initCount, 1, (RexxObject **)&option, NULL); + if (isOfClass(Method, option)) + { + sourceContext = ((RexxMethod *)option)->getSourceObject(); + } + else if (isOfClass(Routine, option)) + { + sourceContext = ((RoutineClass *)option)->getSourceObject(); + } + else + { + // this must be a string (or convertable) and have a specific value + option = option->requestString(); + if (option == TheNilObject) + { + reportException(Error_Incorrect_method_argType, IntegerThree, "Method/String object"); + } + // default given? set option to NULL (see code below) + if (!((RexxString *)option)->strICompare("PROGRAMSCOPE")) + { + reportException(Error_Incorrect_call_list, "NEW", IntegerThree, "\"PROGRAMSCOPE\", Method object", option); + } + } + } + /* go create a method */ + newMethod = RexxMethod::newMethodObject(nameString, source, IntegerTwo, sourceContext); + ProtectedObject p(newMethod); + /* Give new object its behaviour */ + newMethod->setBehaviour(((RexxClass *)this)->getInstanceBehaviour()); + if (((RexxClass *)this)->hasUninitDefined()) /* does object have an UNINT method */ + { + newMethod->hasUninit(); /* Make sure everyone is notified. */ + } + /* now send an INIT message */ + newMethod->sendMessage(OREF_INIT, init_args, initCount); + return newMethod; /* return the new method */ } @@ -503,7 +459,8 @@ ProtectedObject p2(newMethod); /* Give new object its behaviour */ newMethod->setBehaviour(((RexxClass *)this)->getInstanceBehaviour()); - if (this->hasUninitDefined()) { /* does object have an UNINT method */ + if (((RexxClass *)this)->hasUninitDefined()) /* does object have an UNINT method */ + { newMethod->hasUninit(); /* Make sure everyone is notified. */ } /* now send an INIT message */ @@ -534,71 +491,6 @@ } -RexxMethod * RexxMethod::processInstore(PRXSTRING instore, RexxString * name ) -/******************************************************************************/ -/* Function: Process instorage execution arguments */ -/******************************************************************************/ -{ - // just a generic empty one indicating that we should check the macrospace? - if (instore[0].strptr == NULL && instore[1].strptr == NULL) - { - unsigned short temp; - - /* see if this exists */ - if (!RexxQueryMacro(name->getStringData(), &temp)) - { - RXSTRING buffer; /* instorage buffer */ - - MAKERXSTRING(buffer, NULL, 0); - /* get the image of function */ - RexxExecuteMacroFunction(name->getStringData(), &buffer); - /* unflatten the method now */ - RexxMethod *routine = SysRestoreProgramBuffer(&buffer, name); - // release the buffer memory - SysReleaseResultMemory(buffer.strptr); - return routine; - } - return OREF_NULL; // not found - } - if (instore[1].strptr != NULL) /* have an image */ - { - /* go convert into a method */ - RexxMethod *method = SysRestoreProgramBuffer(&instore[1], name); - if (method != OREF_NULL) - { /* did it unflatten successfully? */ - if (instore[0].strptr != NULL) /* have source also? */ - { - /* get a buffer object */ - RexxBuffer *source_buffer = new_buffer(instore[0].strlength); - /* copy source into the buffer */ - memcpy(source_buffer->address(), instore[0].strptr, instore[0].strlength); - /* reconnect this with the source */ - ((RexxCode *)method)->getSourceObject()->setBufferedSource(source_buffer); - } - return method; /* go return it */ - } - } - if (instore[0].strptr != NULL) /* have instorage source */ - { - /* get a buffer object */ - RexxBuffer *source_buffer = new_buffer(instore[0].strlength); - /* copy source into the buffer */ - memcpy(source_buffer->address(), instore[0].strptr, instore[0].strlength); - - if (source_buffer->address()[0] == '#' && source_buffer->address()[1] == '!') - { - memcpy(source_buffer->address(), "--", 2); - } - /* translate this source */ - RexxMethod *method = newRexxBuffer(name, source_buffer, (RexxClass *)TheNilObject); - /* return this back in instore[1] */ - SysSaveProgramBuffer(&instore[1], method); - return method; /* return translated source */ - } - return OREF_NULL; /* processing failed */ -} - - RexxMethod *RexxMethod::restore( RexxBuffer *buffer, /* buffer containing the method */ char *startPointer) /* first character of the method */ @@ -706,6 +598,18 @@ /** + * Non-virtual method for retrieving the source array. This is needed + * for purposes of exporting as a Rexx method. + * + * @return An array of source line elements. + */ +RexxArray *BaseCode::source() +{ + return this->getSource(); +} + + +/** * Set the security manager in the code source context. * * @param manager The new security manager. @@ -724,10 +628,11 @@ /** - * Perform any needed resolution before calling a BaseCode - * object. The default resolution step is a no-op. + * Retrieve the source object associated with a code object. + * + * @return */ -void BaseCode::resolve() +RexxSource *BaseCode::getSourceObject() { - // nothing to do by default + return OREF_NULL; } Modified: sandbox/rick/opt/kernel/classes/MethodClass.hpp =================================================================== --- sandbox/rick/opt/kernel/classes/MethodClass.hpp 2008-02-08 21:17:58 UTC (rev 2349) +++ sandbox/rick/opt/kernel/classes/MethodClass.hpp 2008-02-09 00:16:13 UTC (rev 2350) @@ -44,30 +44,62 @@ #ifndef Included_RexxMethod #define Included_RexxMethod -class BaseCode; +class RexxSource; +class RexxActivity; +class RexxMethod; +class ProtectedObject; +class RexxArray; + + +/** + * Base class for a code object. Code objects can be invoked as + * methods, or called. + */ +class BaseCode : public RexxInternalObject +{ +public: + virtual void run(RexxActivity *, RexxMethod *, RexxObject *, RexxString *, size_t, RexxObject **, ProtectedObject &); + virtual void call(RexxActivity *, RexxString *, RexxObject **, size_t, RexxString *, RexxString *, int, ProtectedObject &); + virtual void call(RexxActivity *, RexxString *, RexxObject **, size_t, ProtectedObject &); + virtual RexxArray *getSource(); + virtual RexxObject *setSecurityManager(RexxObject *manager); + virtual RexxSource *getSourceObject(); + + RexxArray *source(); +}; /* pointer to native method function */ typedef uint16_t *(RexxEntry *PNATIVEMETHOD)(RexxMethodContext *, ValueDescriptor *); /* pointer to native function function*/ typedef uint16_t *(RexxEntry *PNATIVEFUNCTION)(RexxCallContext *, ValueDescriptor *); -class RexxMethodClass; +class BaseExecutable : public RexxObject +{ +public: + inline RexxSource *getSourceObject() { return code->getSourceObject(); }; + inline BaseCode *getCode() { return code; } + RexxArray *getSource() { return code->getSource(); } - class RexxMethod : public RexxObject { +protected: + BaseCode *code; // the backing code object +}; + + + class RexxMethod : public BaseExecutable + { public: void *operator new(size_t); inline void *operator new(size_t size, void *ptr) { return ptr; }; RexxMethod(BaseCode *_code); + RexxMethod(RexxSource *source); inline RexxMethod(RESTORETYPE restoreType) { ; }; + void execute(RexxObject *, RexxObject *); void live(size_t); void liveGeneral(int reason); void flatten(RexxEnvelope*); + void run(RexxActivity *, RexxObject *, RexxString *, size_t, RexxObject **, ProtectedObject &); - void call(RexxActivity *, RexxString *, RexxObject **, size_t, RexxString *, RexxString *, int, ProtectedObject &); - void call(RexxActivity *, RexxString *, RexxObject **, size_t, ProtectedObject &); - void runProgram(RexxActivity *activity, RexxString * calltype, RexxString * environment, RexxObject **arguments, size_t argCount, ProtectedObject &result); RexxMethod *newScope(RexxClass *); - RexxArray *source(); void setScope(RexxClass *); RexxSmartBuffer *saveMethod(); RexxObject *setUnGuardedRexx(); @@ -95,15 +127,14 @@ RexxMethod *newRexx(RexxObject **, size_t); RexxMethod *newFileRexx(RexxString *); - static RexxMethod *processInstore(PRXSTRING instore, RexxString * name ); static RexxMethod *newRexxMethod(RexxSource *, RexxClass *); - static RexxMethod *newRexxCode(RexxString *, RexxObject *, RexxObject *, RexxSource *a); + static RexxMethod *newMethodObject(RexxString *, RexxObject *, RexxObject *, RexxSource *a); static RexxMethod *newRexxBuffer(RexxString *, RexxBuffer *, RexxClass *); static RexxMethod *newEntry(PNATIVEMETHOD); static RexxMethod *restore(RexxBuffer *, char *); static RexxMethod *newFile(RexxString *); - static RexxMethodClass *classInstance; + static RexxClass *classInstance; protected: enum @@ -115,26 +146,11 @@ size_t methodFlags; // method status flags RexxClass *scope; /* pointer to the method scope */ - BaseCode *code; // the backing code object - }; +}; inline RexxMethod *new_method(BaseCode *c) { return new RexxMethod(c); } -/** - * Base class for a code object. Code objects can be invoked as - * methods, or called. - */ -class BaseCode : public RexxInternalObject -{ -public: - virtual void run(RexxActivity *, RexxMethod *, RexxObject *, RexxString *, size_t, RexxObject **, ProtectedObject &); - virtual void call(RexxActivity *, RexxString *, RexxObject **, size_t, RexxString *, RexxString *, int, ProtectedObject &); - virtual void call(RexxActivity *, RexxString *, RexxObject **, size_t, ProtectedObject &); - virtual RexxArray *getSource(); - virtual RexxObject *setSecurityManager(RexxObject *manager); - virtual void resolve(); -}; #endif Modified: sandbox/rick/opt/kernel/classes/ObjectClass.cpp =================================================================== --- sandbox/rick/opt/kernel/classes/ObjectClass.cpp 2008-02-08 21:17:58 UTC (rev 2349) +++ sandbox/rick/opt/kernel/classes/ObjectClass.cpp 2008-02-09 00:16:13 UTC (rev 2350) @@ -794,7 +794,7 @@ { SecurityManager *manager = activation->getSecurityManager(); // the security manager can replace provide a new result - if (manager->checkProtectedMethod(this, messageName, count, arguments, result) + if (manager->checkProtectedMethod(this, messageName, count, arguments, result)) { return; } @@ -1447,27 +1447,38 @@ /* Function: Add a new method to an object instance */ /******************************************************************************/ { - /* get the message name as a string */ - msgname = REQUIRED_STRING(msgname, ARG_ONE)->upper(); - if (option) { - option = REQUIRED_STRING(option, ARG_THREE); - if (!stricmp("OBJECT",option->getStringData())) { - // do nothing if OBJECT - } else if (!stricmp("FLOAT",option->getStringData())) - // "FLOAT" makes option a NULL pointer, causing the old default behaviour on setMethod... - option = OREF_NULL; - else - reportException(Error_Incorrect_call_list, CHAR_SETMETHOD, IntegerThree, "\"FLOAT\", \"OBJECT\"", option); - } + /* get the message name as a string */ + msgname = REQUIRED_STRING(msgname, ARG_ONE)->upper(); + if (option) + { + option = REQUIRED_STRING(option, ARG_THREE); + if (!stricmp("OBJECT",option->getStringData())) + { + // do nothing if OBJECT + } + else if (!stricmp("FLOAT",option->getStringData())) + { + // "FLOAT" makes option a NULL pointer, causing the old default behaviour on setMethod... + option = OREF_NULL; + } + else + { + reportException(Error_Incorrect_call_list, CHAR_SETMETHOD, IntegerThree, "\"FLOAT\", \"OBJECT\"", option); + } + } - if (methobj == OREF_NULL) /* we weren't passed a method, */ - /* add a dummy method */ - methobj = (RexxMethod *)TheNilObject; - else if (!isOfClass(Method, methobj)) /* not a method type already? */ - /* make one from a string or array */ - methobj = TheMethodClass->newRexxCode(msgname, (RexxObject *)methobj, IntegerTwo, OREF_NULL); - this->defMethod(msgname, methobj, option); /* defMethod handles all the details */ - return OREF_NULL; /* no return value */ + if (methobj == OREF_NULL) /* we weren't passed a method, */ + { + /* add a dummy method */ + methobj = (RexxMethod *)TheNilObject; + } + else if (!isOfClass(Method, methobj)) /* not a method type already? */ + { + /* make one from a string or array */ + methobj = RexxMethod::newMethodObject(msgname, (RexxObject *)methobj, IntegerTwo, OREF_NULL); + } + this->defMethod(msgname, methobj, option); /* defMethod handles all the details */ + return OREF_NULL; /* no return value */ } RexxObject *RexxObject::unsetMethod( @@ -1645,76 +1656,85 @@ /* behaviour. */ /****************************************************************************/ { - RexxMethod *methobj; /* the object method */ - RexxString *option; /* run option string */ - RexxArray *arglist = OREF_NULL; /* forwarded option string */ - RexxObject **argumentPtr = NULL; /* default to no arguments passed along */ - size_t argcount = 0; + RexxArray *arglist = OREF_NULL; /* forwarded option string */ + RexxObject **argumentPtr = NULL; /* default to no arguments passed along */ + size_t argcount = 0; - /* get the method object */ - methobj = (RexxMethod *)arguments[0]; - required_arg(methobj, ONE); /* make sure we have a method */ - if (!isOfClass(Method, methobj)) { /* this a method object? */ - /* create a method object */ - methobj = TheMethodClass->newRexxCode(OREF_RUN, (RexxObject *)methobj, IntegerOne, OREF_NULL); - /* set the correct scope */ - methobj->setScope((RexxClass *)TheNilObject); - } - else - /* ensure correct scope on method */ - methobj = methobj->newScope((RexxClass *)TheNilObject); - // we need to save this, since we might be working off of a newly created - // one or a copy - ProtectedObject p(methobj); + /* get the method object */ + RexxMethod *methobj = (RexxMethod *)arguments[0]; + required_arg(methobj, ONE); /* make sure we have a method */ + if (!isOfClass(Method, methobj)) /* this a method object? */ + { + /* create a method object */ + methobj = RexxMethod::newMethodObject(OREF_RUN, (RexxObject *)methobj, IntegerOne, OREF_NULL); + /* set the correct scope */ + methobj->setScope((RexxClass *)TheNilObject); + } + else + { + /* ensure correct scope on method */ + methobj = methobj->newScope((RexxClass *)TheNilObject); + } + // we need to save this, since we might be working off of a newly created + // one or a copy + ProtectedObject p(methobj); - if (argCount > 1) { /* if any arguments passed */ - /* get the 1st one, its the option */ - option = (RexxString *)arguments[1]; - /* this is now required */ - option = REQUIRED_STRING(option, ARG_TWO); - /* process the different options */ - switch (toupper(option->getChar(0))) { - case 'A': /* args are an array */ + if (argCount > 1) /* if any arguments passed */ + { + /* get the 1st one, its the option */ + RexxString *option = (RexxString *)arguments[1]; + /* this is now required */ + option = REQUIRED_STRING(option, ARG_TWO); + /* process the different options */ + switch (toupper(option->getChar(0))) { - /* so they say, make sure we have an */ - /* array and we were only passed 3 */ - /*args */ - if (argCount < 3) /* not enough arguments? */ - missing_argument(ARG_THREE); /* this is an error */ - if (argCount > 3) /* too many arguments? */ - reportException(Error_Incorrect_method_maxarg, IntegerThree); - /* now get the array */ - arglist = (RexxArray *)arguments[2]; - /* force to array form */ - arglist = REQUEST_ARRAY(arglist); - /* not an array? */ - if (arglist == TheNilObject || arglist->getDimension() != 1) - /* raise an error */ - reportException(Error_Incorrect_method_noarray, arguments[2]); - // request array may create a new one...keep it safe - ProtectedObject p1(arglist); - /* grab the argument information */ - argumentPtr = arglist->data(); - argcount = arglist->size(); - break; - } + case 'A': /* args are an array */ + { + /* so they say, make sure we have an */ + /* array and we were only passed 3 */ + /*args */ + if (argCount < 3) /* not enough arguments? */ + { + missing_argument(ARG_THREE); /* this is an error */ + } + if (argCount > 3) /* too many arguments? */ + { + reportException(Error_Incorrect_method_maxarg, IntegerThree); + } + /* now get the array */ + arglist = (RexxArray *)arguments[2]; + /* force to array form */ + arglist = REQUEST_ARRAY(arglist); + /* not an array? */ + if (arglist == TheNilObject || arglist->getDimension() != 1) + { + /* raise an error */ + reportException(Error_Incorrect_method_noarray, arguments[2]); + } + // request array may create a new one...keep it safe + ProtectedObject p1(arglist); + /* grab the argument information */ + argumentPtr = arglist->data(); + argcount = arglist->size(); + break; + } - case 'I': /* args are "strung out" */ - /* point to the array data for the second value */ - argumentPtr = arguments + 2; - argcount = argCount - 2; - break; + case 'I': /* args are "strung out" */ + /* point to the array data for the second value */ @@ Diff output truncated at 100000 characters. @@ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bigrixx@us...> - 2008-02-12 00:59:58
|
Revision: 2355 http://oorexx.svn.sourceforge.net/oorexx/?rev=2355&view=rev Author: bigrixx Date: 2008-02-11 16:59:58 -0800 (Mon, 11 Feb 2008) Log Message: ----------- incremental checkin Modified Paths: -------------- sandbox/rick/opt/kernel/api/CallContextStubs.cpp sandbox/rick/opt/kernel/api/ContextApi.hpp sandbox/rick/opt/kernel/api/InterpreterInstanceStubs.cpp sandbox/rick/opt/kernel/api/MethodContextStubs.cpp sandbox/rick/opt/kernel/api/ThreadContextStubs.cpp sandbox/rick/opt/kernel/classes/IntegerClass.cpp sandbox/rick/opt/kernel/classes/IntegerClass.hpp sandbox/rick/opt/kernel/classes/MethodClass.cpp sandbox/rick/opt/kernel/classes/MethodClass.hpp sandbox/rick/opt/kernel/classes/NumberStringClass.cpp sandbox/rick/opt/kernel/classes/NumberStringClass.hpp sandbox/rick/opt/kernel/classes/ObjectClass.hpp sandbox/rick/opt/kernel/classes/RoutineClass.cpp sandbox/rick/opt/kernel/classes/StringClass.cpp sandbox/rick/opt/kernel/classes/StringClass.hpp sandbox/rick/opt/kernel/expression/CommonExternalFunctions.cpp sandbox/rick/opt/kernel/expression/ExpressionCompoundVariable.cpp sandbox/rick/opt/kernel/expression/ExpressionCompoundVariable.hpp sandbox/rick/opt/kernel/expression/ExpressionStem.cpp sandbox/rick/opt/kernel/expression/ExpressionStem.hpp sandbox/rick/opt/kernel/expression/ExpressionVariable.cpp sandbox/rick/opt/kernel/expression/ExpressionVariable.hpp sandbox/rick/opt/kernel/runtime/ActivityManager.cpp sandbox/rick/opt/kernel/runtime/ActivityManager.hpp sandbox/rick/opt/kernel/runtime/CPPCode.cpp sandbox/rick/opt/kernel/runtime/CreateRoutineDispatcher.cpp sandbox/rick/opt/kernel/runtime/Numerics.cpp sandbox/rick/opt/kernel/runtime/PackageManager.hpp sandbox/rick/opt/kernel/runtime/RexxActivation.cpp sandbox/rick/opt/kernel/runtime/RexxActivation.hpp sandbox/rick/opt/kernel/runtime/RexxActivity.hpp sandbox/rick/opt/kernel/runtime/RexxCode.cpp sandbox/rick/opt/kernel/runtime/RexxCode.hpp sandbox/rick/opt/kernel/runtime/RexxNativeActivation.cpp sandbox/rick/opt/kernel/runtime/RexxNativeActivation.hpp sandbox/rick/opt/kernel/runtime/RexxNativeCode.cpp sandbox/rick/opt/kernel/runtime/RexxNativeCode.hpp Modified: sandbox/rick/opt/kernel/api/CallContextStubs.cpp =================================================================== --- sandbox/rick/opt/kernel/api/CallContextStubs.cpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/api/CallContextStubs.cpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -63,7 +63,7 @@ return NULLOBJECT; } -RexxObjectPtr RexxEntry GetCallArgument(RexxCallContext *c, RexxUnsignedNumber i) +RexxObjectPtr RexxEntry GetCallArgument(RexxCallContext *c, stringsize_t i) { ApiContext context(c); try @@ -76,24 +76,24 @@ return NULLOBJECT; } -void RexxEntry SetContextVariable(RexxCallContext *c, RexxStringPointer n, RexxObjectPtr v) +void RexxEntry SetContextVariable(RexxCallContext *c, CSTRING n, RexxObjectPtr v) { ApiContext context(c); try { - context.context->setContextVariable((stringchar_t *)n, (RexxObject *)v); + context.context->setContextVariable((const char *)n, (RexxObject *)v); } catch (ActivityException) { } } -RexxObjectPtr RexxEntry GetContextVariable(RexxCallContext *c, RexxStringPointer n) +RexxObjectPtr RexxEntry GetContextVariable(RexxCallContext *c, CSTRING n) { ApiContext context(c); try { - return context.context->getContextVariable((stringchar_t *)n); + return context.context->getContextVariable((const char *)n); } catch (ActivityException) { @@ -101,12 +101,12 @@ return NULLOBJECT; } -void RexxEntry DropContextVariable(RexxCallContext *c, RexxStringPointer n) +void RexxEntry DropContextVariable(RexxCallContext *c, CSTRING n) { ApiContext context(c); try { - context.context->dropContextVariable((stringchar_t *)n); + context.context->dropContextVariable((const char *)n); } catch (ActivityException) { @@ -155,24 +155,24 @@ } } -void RexxEntry SetExitContextVariable(RexxExitContext *c, RexxStringPointer n, RexxObjectPtr v) +void RexxEntry SetExitContextVariable(RexxExitContext *c, CSTRING n, RexxObjectPtr v) { ApiContext context(c); try { - context.context->setContextVariable((stringchar_t *)n, (RexxObject *)v); + context.context->setContextVariable((const char *)n, (RexxObject *)v); } catch (ActivityException) { } } -RexxObjectPtr RexxEntry GetExitContextVariable(RexxExitContext *c, RexxStringPointer n) +RexxObjectPtr RexxEntry GetExitContextVariable(RexxExitContext *c, CSTRING n) { ApiContext context(c); try { - return context.context->getContextVariable((stringchar_t *)n); + return context.context->getContextVariable((const char *)n); } catch (ActivityException) { @@ -180,12 +180,12 @@ return NULLOBJECT; } -void RexxEntry DropExitContextVariable(RexxExitContext *c, RexxStringPointer n) +void RexxEntry DropExitContextVariable(RexxExitContext *c, CSTRING n) { ApiContext context(c); try { - context.context->dropContextVariable((stringchar_t *)n); + context.context->dropContextVariable((const char *)n); } catch (ActivityException) { @@ -230,7 +230,7 @@ return 0; } -RexxBoolean RexxEntry GetContextForm(RexxCallContext *c) +logical_t RexxEntry GetContextForm(RexxCallContext *c) { ApiContext context(c); try Modified: sandbox/rick/opt/kernel/api/ContextApi.hpp =================================================================== --- sandbox/rick/opt/kernel/api/ContextApi.hpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/api/ContextApi.hpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -115,7 +115,7 @@ inline RexxObjectPtr ret(RexxObject *o) { - activity->createLocalReference(o); + context->createLocalReference(o); return (RexxObjectPtr)o; } Modified: sandbox/rick/opt/kernel/api/InterpreterInstanceStubs.cpp =================================================================== --- sandbox/rick/opt/kernel/api/InterpreterInstanceStubs.cpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/api/InterpreterInstanceStubs.cpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -54,7 +54,7 @@ context.instance->terminate(); } -RexxBoolean RexxEntry AttachThread(RexxInstance *c, RexxThreadContext **tc) +logical_t RexxEntry AttachThread(RexxInstance *c, RexxThreadContext **tc) { InstanceApiContext context(c); return context.instance->attachThread(tc); @@ -66,16 +66,16 @@ context.instance->halt(); } -void RexxEntry SetTrace(RexxInstance *c, RexxBoolean setting) +void RexxEntry SetTrace(RexxInstance *c, logical_t setting) { InstanceApiContext context(c); context.instance->setTrace(setting != 0); } -RexxBoolean RexxEntry CreateScriptContext(RexxInstance *c, RexxScriptContext **sc, RexxOption *o) +logical_t RexxEntry CreateScriptContext(RexxInstance *c, RexxScriptContext **sc, RexxOption *o) { - return (RexxBoolean)false; + return (logical_t)false; } END_EXTERN_C() Modified: sandbox/rick/opt/kernel/api/MethodContextStubs.cpp =================================================================== --- sandbox/rick/opt/kernel/api/MethodContextStubs.cpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/api/MethodContextStubs.cpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -60,7 +60,7 @@ return NULLOBJECT; } -RexxObjectPtr RexxEntry GetMethodArgument(RexxMethodContext *c, RexxUnsignedNumber i) +RexxObjectPtr RexxEntry GetMethodArgument(RexxMethodContext *c, stringsize_t i) { ApiContext context(c); try @@ -86,12 +86,12 @@ return NULL; } -RexxStringPointer RexxEntry GetMessageName(RexxMethodContext *c) +CSTRING RexxEntry GetMessageName(RexxMethodContext *c) { ApiContext context(c); try { - return (RexxStringPointer)context.context->getMessageName(); + return (CSTRING)context.context->getMessageName(); } catch (ActivityException) { @@ -125,7 +125,7 @@ return NULLOBJECT; } -void RexxEntry SetObjectVariable(RexxMethodContext *c, RexxStringPointer n, RexxObjectPtr v) +void RexxEntry SetObjectVariable(RexxMethodContext *c, CSTRING n, RexxObjectPtr v) { ApiContext context(c); try @@ -137,7 +137,7 @@ } } -RexxObjectPtr RexxEntry GetObjectVariable(RexxMethodContext *c, RexxStringPointer n) +RexxObjectPtr RexxEntry GetObjectVariable(RexxMethodContext *c, CSTRING n) { ApiContext context(c); try @@ -150,7 +150,7 @@ return NULLOBJECT; } -void RexxEntry DropObjectVariable(RexxMethodContext *c, RexxStringPointer n) +void RexxEntry DropObjectVariable(RexxMethodContext *c, CSTRING n) { ApiContext context(c); try @@ -162,7 +162,7 @@ } } -RexxObjectPtr RexxEntry SendSuperMessage(RexxMethodContext *c, RexxStringPointer n, RexxArrayObject a) +RexxObjectPtr RexxEntry SendSuperMessage(RexxMethodContext *c, CSTRING n, RexxArrayObject a) { ApiContext context(c); try @@ -181,7 +181,7 @@ return NULLOBJECT; } -RexxObjectPtr RexxEntry SendOverrideMessage(RexxMethodContext *c, RexxStringPointer n, RexxClassObject clazz, RexxArrayObject a) +RexxObjectPtr RexxEntry SendOverrideMessage(RexxMethodContext *c, CSTRING n, RexxClassObject clazz, RexxArrayObject a) { ApiContext context(c); try @@ -224,7 +224,7 @@ } } -RexxClassObject RexxEntry FindContextClass(RexxMethodContext *c, RexxStringPointer n) +RexxClassObject RexxEntry FindContextClass(RexxMethodContext *c, CSTRING n) { ApiContext context(c); try Modified: sandbox/rick/opt/kernel/api/ThreadContextStubs.cpp =================================================================== --- sandbox/rick/opt/kernel/api/ThreadContextStubs.cpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/api/ThreadContextStubs.cpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -88,7 +88,7 @@ } -void RexxEntry SetThreadTrace(RexxThreadContext *c, RexxBoolean setting) +void RexxEntry SetThreadTrace(RexxThreadContext *c, logical_t setting) { ApiContext context(c); try @@ -143,7 +143,7 @@ //NB: The name "SendMessage" has a conflict with a Windows API, so this name differs from // the call vector version. -RexxObjectPtr RexxEntry SendMessageArray(RexxThreadContext *c, RexxObjectPtr o, RexxStringPointer m, RexxArrayObject a) +RexxObjectPtr RexxEntry SendMessageArray(RexxThreadContext *c, RexxObjectPtr o, CSTRING m, RexxArrayObject a) { ApiContext context(c); try @@ -157,7 +157,7 @@ } -RexxObjectPtr RexxEntry SendMessage0(RexxThreadContext *c, RexxObjectPtr o, RexxStringPointer m) +RexxObjectPtr RexxEntry SendMessage0(RexxThreadContext *c, RexxObjectPtr o, CSTRING m) { ApiContext context(c); try @@ -171,7 +171,7 @@ } -RexxObjectPtr RexxEntry SendMessage1(RexxThreadContext *c, RexxObjectPtr o, RexxStringPointer m, RexxObjectPtr a1) +RexxObjectPtr RexxEntry SendMessage1(RexxThreadContext *c, RexxObjectPtr o, CSTRING m, RexxObjectPtr a1) { ApiContext context(c); try @@ -184,7 +184,7 @@ return NULLOBJECT; } -RexxObjectPtr RexxEntry SendMessage2(RexxThreadContext *c, RexxObjectPtr o, RexxStringPointer m, RexxObjectPtr a1, RexxObjectPtr a2) +RexxObjectPtr RexxEntry SendMessage2(RexxThreadContext *c, RexxObjectPtr o, CSTRING m, RexxObjectPtr a1, RexxObjectPtr a2) { ApiContext context(c); try @@ -225,7 +225,7 @@ } -RexxBoolean RexxEntry IsSameType(RexxThreadContext *c, RexxObjectPtr o1, RexxObjectPtr o2) +logical_t RexxEntry IsSameType(RexxThreadContext *c, RexxObjectPtr o1, RexxObjectPtr o2) { ApiContext context(c); try @@ -239,7 +239,7 @@ } -RexxBoolean RexxEntry IsInstanceOf(RexxThreadContext *c, RexxObjectPtr o, RexxClassObject cl) +logical_t RexxEntry IsInstanceOf(RexxThreadContext *c, RexxObjectPtr o, RexxClassObject cl) { ApiContext context(c); try @@ -253,7 +253,7 @@ } -RexxClassObject RexxEntry FindClass(RexxThreadContext *c, RexxStringPointer n) +RexxClassObject RexxEntry FindClass(RexxThreadContext *c, CSTRING n) { ApiContext context(c); try @@ -270,7 +270,7 @@ } -RexxClassObject RexxEntry FindClassFromMethod(RexxThreadContext *c, RexxMethodObject m, RexxStringPointer n) +RexxClassObject RexxEntry FindClassFromMethod(RexxThreadContext *c, RexxMethodObject m, CSTRING n) { ApiContext context(c); try @@ -287,7 +287,7 @@ } -RexxBoolean RexxEntry HasMethod(RexxThreadContext *c, RexxObjectPtr o, RexxStringPointer n) +logical_t RexxEntry HasMethod(RexxThreadContext *c, RexxObjectPtr o, CSTRING n) { ApiContext context(c); try @@ -303,7 +303,7 @@ } -RexxMethodObject RexxEntry NewMethod(RexxThreadContext *c, RexxStringPointer source, RexxUnsignedNumber length) +RexxMethodObject RexxEntry NewMethod(RexxThreadContext *c, CSTRING source, stringsize_t length) { ApiContext context(c); try @@ -386,7 +386,7 @@ return NULLOBJECT; } -RexxMethodObject RexxEntry LoadMethod(RexxThreadContext *c, RexxStringPointer d, size_t l) +RexxMethodObject RexxEntry LoadMethod(RexxThreadContext *c, CSTRING d, size_t l) { ApiContext context(c); try @@ -455,7 +455,7 @@ return NULLOBJECT; } -RexxBoolean RexxEntry ObjectToValue(RexxThreadContext *c, RexxObjectPtr o, ValueDescriptor *d) +logical_t RexxEntry ObjectToValue(RexxThreadContext *c, RexxObjectPtr o, ValueDescriptor *d) { ApiContext context(c); try @@ -471,7 +471,7 @@ return FALSE; } -RexxObjectPtr RexxEntry UnsignedNumberToObject(RexxThreadContext *c, RexxUnsignedNumber n) +RexxObjectPtr RexxEntry UnsignedNumberToObject(RexxThreadContext *c, stringsize_t n) { ApiContext context(c); try @@ -485,7 +485,7 @@ } -RexxBoolean RexxEntry ObjectToNumber(RexxThreadContext *c, RexxObjectPtr o, wholenumber_t *n) +logical_t RexxEntry ObjectToNumber(RexxThreadContext *c, RexxObjectPtr o, wholenumber_t *n) { ApiContext context(c); try @@ -506,7 +506,7 @@ } -RexxBoolean RexxEntry ObjectToUnsignedNumber(RexxThreadContext * c, RexxObjectPtr o, RexxUnsignedNumber * n) +logical_t RexxEntry ObjectToUnsignedNumber(RexxThreadContext * c, RexxObjectPtr o, stringsize_t * n) { ApiContext context(c); try @@ -515,7 +515,7 @@ // this uses the entire value range if (Numerics::objectToStringSize((RexxObject *)o, temp, SIZE_MAX)) { - *n = (RexxUnsignedNumber)temp; + *n = (stringsize_t)temp; return true; } return false; @@ -552,7 +552,7 @@ return NULLOBJECT; } -RexxBoolean RexxEntry ObjectToInt64(RexxThreadContext *c, RexxObjectPtr o, int64_t * n) +logical_t RexxEntry ObjectToInt64(RexxThreadContext *c, RexxObjectPtr o, int64_t * n) { ApiContext context(c); try @@ -566,7 +566,7 @@ return 0; } -RexxBoolean RexxEntry ObjectToUnsignedInt64(RexxThreadContext *c, RexxObjectPtr o, uint64_t *n) +logical_t RexxEntry ObjectToUnsignedInt64(RexxThreadContext *c, RexxObjectPtr o, uint64_t *n) { ApiContext context(c); try @@ -580,7 +580,7 @@ return 0; } -RexxBoolean RexxEntry ObjectToUintptr(RexxThreadContext * c, RexxObjectPtr o, uintptr_t * n) +logical_t RexxEntry ObjectToUintptr(RexxThreadContext * c, RexxObjectPtr o, uintptr_t * n) { ApiContext context(c); try @@ -620,7 +620,7 @@ return NULLOBJECT; } -RexxBoolean RexxEntry ObjectToDouble(RexxThreadContext *c, RexxObjectPtr o, double *n) +logical_t RexxEntry ObjectToDouble(RexxThreadContext *c, RexxObjectPtr o, double *n) { ApiContext context(c); try @@ -646,14 +646,14 @@ return NULLOBJECT; } -RexxStringPointer RexxEntry ObjectToStringValue(RexxThreadContext *c, RexxObjectPtr o) +CSTRING RexxEntry ObjectToStringValue(RexxThreadContext *c, RexxObjectPtr o) { ApiContext context(c); try { RexxString *temp = REQUEST_STRING(o); context.ret(temp); - return (RexxStringPointer)temp->getStringData(); + return (CSTRING)temp->getStringData(); } catch (ActivityException) { @@ -661,7 +661,7 @@ return NULL; } -size_t RexxEntry StringGet(RexxThreadContext *c, RexxStringObject s, size_t o, RexxStringPointer r, size_t l) +size_t RexxEntry StringGet(RexxThreadContext *c, RexxStringObject s, size_t o, CSTRING r, size_t l) { ApiContext context(c); try @@ -689,13 +689,13 @@ return 0; } -RexxStringPointer RexxEntry StringData(RexxThreadContext *c, RexxStringObject s) +CSTRING RexxEntry StringData(RexxThreadContext *c, RexxStringObject s) { ApiContext context(c); try { RexxString *temp = (RexxString *)s; - return (RexxStringPointer)temp->getStringData(); + return (CSTRING)temp->getStringData(); } catch (ActivityException) { @@ -703,7 +703,7 @@ return NULL; } -RexxStringObject RexxEntry NewString(RexxThreadContext *c, RexxStringPointer s, size_t l) +RexxStringObject RexxEntry NewString(RexxThreadContext *c, CSTRING s, size_t l) { ApiContext context(c); try @@ -716,7 +716,7 @@ return NULLOBJECT; } -RexxStringObject RexxEntry NewStringFromAsciiz(RexxThreadContext *c, RexxStringPointer s) +RexxStringObject RexxEntry NewStringFromAsciiz(RexxThreadContext *c, CSTRING s) { ApiContext context(c); try @@ -757,7 +757,7 @@ return NULLOBJECT; } -RexxBoolean RexxEntry IsString(RexxThreadContext *c, RexxObjectPtr o) +logical_t RexxEntry IsString(RexxThreadContext *c, RexxObjectPtr o) { ApiContext context(c); try @@ -797,13 +797,13 @@ return 0; } -RexxStringPointer RexxEntry BufferStringData(RexxThreadContext *c, RexxBufferStringObject s) +CSTRING RexxEntry BufferStringData(RexxThreadContext *c, RexxBufferStringObject s) { ApiContext context(c); try { RexxString *temp = (RexxString *)s; - return (RexxStringPointer)temp->getStringData(); + return (CSTRING)temp->getStringData(); } catch (ActivityException) { @@ -877,7 +877,7 @@ return OREF_NULL; } -RexxBoolean RexxEntry IsTable(RexxThreadContext *c, RexxObjectPtr o) +logical_t RexxEntry IsTable(RexxThreadContext *c, RexxObjectPtr o) { ApiContext context(c); try @@ -890,7 +890,7 @@ return FALSE; } -void RexxEntry DirectoryPut(RexxThreadContext *c, RexxDirectoryObject t, RexxObjectPtr o, RexxStringPointer i) +void RexxEntry DirectoryPut(RexxThreadContext *c, RexxDirectoryObject t, RexxObjectPtr o, CSTRING i) { ApiContext context(c); try @@ -902,7 +902,7 @@ } } -RexxObjectPtr RexxEntry DirectoryAt(RexxThreadContext *c, RexxDirectoryObject t, RexxStringPointer i) +RexxObjectPtr RexxEntry DirectoryAt(RexxThreadContext *c, RexxDirectoryObject t, CSTRING i) { ApiContext context(c); try @@ -915,7 +915,7 @@ return OREF_NULL; } -RexxObjectPtr RexxEntry DirectoryRemove(RexxThreadContext *c, RexxDirectoryObject t, RexxStringPointer i) +RexxObjectPtr RexxEntry DirectoryRemove(RexxThreadContext *c, RexxDirectoryObject t, CSTRING i) { ApiContext context(c); try @@ -941,7 +941,7 @@ return OREF_NULL; } -RexxBoolean RexxEntry IsDirectory(RexxThreadContext *c, RexxObjectPtr o) +logical_t RexxEntry IsDirectory(RexxThreadContext *c, RexxObjectPtr o) { ApiContext context(c); try @@ -954,7 +954,7 @@ return FALSE; } -RexxObjectPtr RexxEntry ArrayAt(RexxThreadContext *c, RexxArrayObject a, RexxUnsignedNumber i) +RexxObjectPtr RexxEntry ArrayAt(RexxThreadContext *c, RexxArrayObject a, stringsize_t i) { ApiContext context(c); try @@ -967,7 +967,7 @@ return OREF_NULL; } -RexxBoolean RexxEntry ArrayHasIndex(RexxThreadContext *c, RexxArrayObject a, RexxUnsignedNumber i) +logical_t RexxEntry ArrayHasIndex(RexxThreadContext *c, RexxArrayObject a, stringsize_t i) { ApiContext context(c); try @@ -980,7 +980,7 @@ return FALSE; } -void RexxEntry ArrayPut(RexxThreadContext *c, RexxArrayObject a, RexxObjectPtr o, RexxUnsignedNumber i) +void RexxEntry ArrayPut(RexxThreadContext *c, RexxArrayObject a, RexxObjectPtr o, stringsize_t i) { ApiContext context(c); try @@ -992,7 +992,7 @@ } } -RexxUnsignedNumber RexxEntry ArraySize(RexxThreadContext *c, RexxArrayObject a) +stringsize_t RexxEntry ArraySize(RexxThreadContext *c, RexxArrayObject a) { ApiContext context(c); try @@ -1018,7 +1018,7 @@ return 0; } -RexxArrayObject RexxEntry NewArray(RexxThreadContext *c, RexxUnsignedNumber s) +RexxArrayObject RexxEntry NewArray(RexxThreadContext *c, stringsize_t s) { ApiContext context(c); try @@ -1058,7 +1058,7 @@ } -RexxBoolean RexxEntry IsArray(RexxThreadContext *c, RexxObjectPtr o) +logical_t RexxEntry IsArray(RexxThreadContext *c, RexxObjectPtr o) { ApiContext context(c); try @@ -1071,12 +1071,12 @@ return FALSE; } -RexxStringPointer RexxEntry BufferData(RexxThreadContext *c, RexxBufferObject b) +CSTRING RexxEntry BufferData(RexxThreadContext *c, RexxBufferObject b) { ApiContext context(c); try { - return (RexxStringPointer)((RexxBuffer *)b)->address(); + return (CSTRING)((RexxBuffer *)b)->address(); } catch (ActivityException) { @@ -1097,7 +1097,7 @@ return 0; } -RexxBufferObject RexxEntry NewBuffer(RexxThreadContext *c, RexxUnsignedNumber l) +RexxBufferObject RexxEntry NewBuffer(RexxThreadContext *c, stringsize_t l) { ApiContext context(c); try @@ -1110,7 +1110,7 @@ return NULLOBJECT; } -RexxBoolean RexxEntry IsBuffer(RexxThreadContext *c, RexxObjectPtr o) +logical_t RexxEntry IsBuffer(RexxThreadContext *c, RexxObjectPtr o) { ApiContext context(c); try @@ -1149,7 +1149,7 @@ return NULLOBJECT; } -RexxBoolean RexxEntry IsInteger(RexxThreadContext *c, RexxObjectPtr o) +logical_t RexxEntry IsInteger(RexxThreadContext *c, RexxObjectPtr o) { ApiContext context(c); try @@ -1188,7 +1188,7 @@ return NULLOBJECT; } -RexxBoolean RexxEntry IsPointer(RexxThreadContext *c, RexxObjectPtr o) +logical_t RexxEntry IsPointer(RexxThreadContext *c, RexxObjectPtr o) { ApiContext context(c); try @@ -1227,7 +1227,7 @@ return NULLOBJECT; } -RexxBoolean RexxEntry SupplierAvailable(RexxThreadContext *c, RexxSupplierObject o) +logical_t RexxEntry SupplierAvailable(RexxThreadContext *c, RexxSupplierObject o) { ApiContext context(c); try @@ -1265,7 +1265,7 @@ return NULLOBJECT; } -void RexxEntry SetStemElement(RexxThreadContext *c, RexxStemObject s, RexxStringPointer n, RexxObjectPtr v) +void RexxEntry SetStemElement(RexxThreadContext *c, RexxStemObject s, CSTRING n, RexxObjectPtr v) { ApiContext context(c); try @@ -1277,7 +1277,7 @@ } } -RexxObjectPtr RexxEntry GetStemElement(RexxThreadContext *c, RexxStemObject s, RexxStringPointer n) +RexxObjectPtr RexxEntry GetStemElement(RexxThreadContext *c, RexxStemObject s, CSTRING n) { ApiContext context(c); try @@ -1290,7 +1290,7 @@ return NULLOBJECT; } -void RexxEntry DropStemElement(RexxThreadContext *c, RexxStemObject s, RexxStringPointer n) +void RexxEntry DropStemElement(RexxThreadContext *c, RexxStemObject s, CSTRING n) { ApiContext context(c); try @@ -1302,7 +1302,7 @@ } } -void RexxEntry SetStemArrayElement(RexxThreadContext *c, RexxStemObject s, RexxUnsignedNumber i, RexxObjectPtr v) +void RexxEntry SetStemArrayElement(RexxThreadContext *c, RexxStemObject s, stringsize_t i, RexxObjectPtr v) { ApiContext context(c); try @@ -1314,7 +1314,7 @@ } } -RexxObjectPtr RexxEntry GetStemArrayElement(RexxThreadContext *c, RexxStemObject s, RexxUnsignedNumber i) +RexxObjectPtr RexxEntry GetStemArrayElement(RexxThreadContext *c, RexxStemObject s, stringsize_t i) { ApiContext context(c); try @@ -1327,7 +1327,7 @@ return NULLOBJECT; } -void RexxEntry DropStemArrayElement(RexxThreadContext *c, RexxStemObject s, RexxUnsignedNumber i) +void RexxEntry DropStemArrayElement(RexxThreadContext *c, RexxStemObject s, stringsize_t i) { ApiContext context(c); try @@ -1365,7 +1365,7 @@ return NULLOBJECT; } -RexxBoolean RexxEntry IsStem(RexxThreadContext *c, RexxObjectPtr o) +logical_t RexxEntry IsStem(RexxThreadContext *c, RexxObjectPtr o) { ApiContext context(c); try @@ -1378,7 +1378,7 @@ return FALSE; } -void RexxEntry RaiseException0(RexxThreadContext *c, RexxUnsignedNumber n) +void RexxEntry RaiseException0(RexxThreadContext *c, stringsize_t n) { ApiContext context(c); try @@ -1390,7 +1390,7 @@ } } -void RexxEntry RaiseException1(RexxThreadContext *c, RexxUnsignedNumber n, RexxObjectPtr o1) +void RexxEntry RaiseException1(RexxThreadContext *c, stringsize_t n, RexxObjectPtr o1) { ApiContext context(c); try @@ -1402,7 +1402,7 @@ } } -void RexxEntry RaiseException2(RexxThreadContext *c, RexxUnsignedNumber n, RexxObjectPtr o1, RexxObjectPtr o2) +void RexxEntry RaiseException2(RexxThreadContext *c, stringsize_t n, RexxObjectPtr o1, RexxObjectPtr o2) { ApiContext context(c); try @@ -1414,7 +1414,7 @@ } } -void RexxEntry RaiseExceptionArray(RexxThreadContext *c, RexxUnsignedNumber n, RexxArrayObject a) +void RexxEntry RaiseExceptionArray(RexxThreadContext *c, stringsize_t n, RexxArrayObject a) { ApiContext context(c); try @@ -1426,7 +1426,7 @@ } } -void RexxEntry RaiseCondition(RexxThreadContext *c, RexxStringPointer name, RexxStringPointer desc, RexxArrayObject add, RexxObjectPtr result) +void RexxEntry RaiseCondition(RexxThreadContext *c, CSTRING name, CSTRING desc, RexxArrayObject add, RexxObjectPtr result) { ApiContext context(c); try @@ -1439,7 +1439,7 @@ } } -RexxBoolean RexxEntry CheckCondition(RexxThreadContext *c) +logical_t RexxEntry CheckCondition(RexxThreadContext *c) { ApiContext context(c); try Modified: sandbox/rick/opt/kernel/classes/IntegerClass.cpp =================================================================== --- sandbox/rick/opt/kernel/classes/IntegerClass.cpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/classes/IntegerClass.cpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -1024,6 +1024,26 @@ return (RexxObject *)this; /* just return this value */ } + +RexxObject *RexxInteger::getRealValue( + RexxActivation *context) /* current activation context */ +/******************************************************************************/ +/* Function: Polymorphic get_value function used with expression terms */ +/******************************************************************************/ +{ + return (RexxObject *)this; /* just return this value */ +} + + +RexxObject *RexxInteger::getRealValue( + RexxVariableDictionary *context) /* current activation context */ +/******************************************************************************/ +/* Function: Polymorphic get_value function used with expression terms */ +/******************************************************************************/ +{ + return (RexxObject *)this; /* just return this value */ +} + /* **************************************** */ /* Integer class methods begin here ..... */ /* **************************************** */ Modified: sandbox/rick/opt/kernel/classes/IntegerClass.hpp =================================================================== --- sandbox/rick/opt/kernel/classes/IntegerClass.hpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/classes/IntegerClass.hpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -133,6 +133,8 @@ RexxObject *evaluate(RexxActivation *, RexxExpressionStack *); RexxObject *getValue(RexxActivation *); RexxObject *getValue(RexxVariableDictionary *); + RexxObject *getRealValue(RexxActivation *); + RexxObject *getRealValue(RexxVariableDictionary *); RexxString *concat(RexxString *); RexxString *concatBlank(RexxString *); void setString(RexxString *string); Modified: sandbox/rick/opt/kernel/classes/MethodClass.cpp =================================================================== --- sandbox/rick/opt/kernel/classes/MethodClass.cpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/classes/MethodClass.cpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -559,11 +559,11 @@ * etc.) * @param result The returned result. */ -void BaseCode::call(RexxActivity *activity, RexxString *msgname, RexxObject **arguments, size_t argcount, RexxString *ct, RexxString *env, int context, ProtectedObject &result) +void BaseCode::call(RexxActivity *activity, RoutineClass *routine, RexxString *msgname, RexxObject **arguments, size_t argcount, RexxString *ct, RexxString *env, int context, ProtectedObject &result) { // the default for this is the simplified call. This is used by Rexx code to make calls to // both Rexx programs and native routines, so the polymorphism simplifies the processing. - call(activity, msgname, arguments, argcount, result); + call(activity, routine, msgname, arguments, argcount, result); } @@ -576,7 +576,7 @@ * @param argcount The count of arguments. * @param result The returned result. */ -void BaseCode::call(RexxActivity *activity, RexxString *msgname, RexxObject **arguments, size_t argcount, ProtectedObject &result) +void BaseCode::call(RexxActivity *activity, RoutineClass *routine, RexxString *msgname, RexxObject **arguments, size_t argcount, ProtectedObject &result) { // The subcasses decide which of run and call are allowed reportException(Error_Interpretation); Modified: sandbox/rick/opt/kernel/classes/MethodClass.hpp =================================================================== --- sandbox/rick/opt/kernel/classes/MethodClass.hpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/classes/MethodClass.hpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -61,8 +61,8 @@ { public: virtual void run(RexxActivity *, RexxMethod *, RexxObject *, RexxString *, size_t, RexxObject **, ProtectedObject &); - virtual void call(RexxActivity *, RexxString *, RexxObject **, size_t, RexxString *, RexxString *, int, ProtectedObject &); - virtual void call(RexxActivity *, RexxString *, RexxObject **, size_t, ProtectedObject &); + virtual void call(RexxActivity *, RoutineClass *, RexxString *, RexxObject **, size_t, RexxString *, RexxString *, int, ProtectedObject &); + virtual void call(RexxActivity *, RoutineClass *, RexxString *, RexxObject **, size_t, ProtectedObject &); virtual RexxArray *getSource(); virtual RexxObject *setSecurityManager(RexxObject *manager); virtual RexxSource *getSourceObject(); Modified: sandbox/rick/opt/kernel/classes/NumberStringClass.cpp =================================================================== --- sandbox/rick/opt/kernel/classes/NumberStringClass.cpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/classes/NumberStringClass.cpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -2720,6 +2720,46 @@ return Retval; /* return proper result */ } + +RexxObject *RexxNumberString::getValue( + RexxActivation *context) /* current activation context */ +/******************************************************************************/ +/* Function: Polymorphic get_value function used with expression terms */ +/******************************************************************************/ +{ + return (RexxObject *)this; /* just return this value */ +} + + +RexxObject *RexxNumberString::getValue( + RexxVariableDictionary *context) /* current activation context */ +/******************************************************************************/ +/* Function: Polymorphic get_value function used with expression terms */ +/******************************************************************************/ +{ + return (RexxObject *)this; /* just return this value */ +} + + +RexxObject *RexxNumberString::getRealValue( + RexxActivation *context) /* current activation context */ +/******************************************************************************/ +/* Function: Polymorphic get_value function used with expression terms */ +/******************************************************************************/ +{ + return (RexxObject *)this; /* just return this value */ +} + + +RexxObject *RexxNumberString::getRealValue( + RexxVariableDictionary *context) /* current activation context */ +/******************************************************************************/ +/* Function: Polymorphic get_value function used with expression terms */ +/******************************************************************************/ +{ + return (RexxObject *)this; /* just return this value */ +} + void *RexxNumberString::operator new(size_t size, size_t length) /******************************************************************************/ /* Function: Create a new NumberString object */ Modified: sandbox/rick/opt/kernel/classes/NumberStringClass.hpp =================================================================== --- sandbox/rick/opt/kernel/classes/NumberStringClass.hpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/classes/NumberStringClass.hpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -148,8 +148,10 @@ RexxString *formatInternal(size_t, size_t, size_t, size_t, RexxNumberString *, size_t, bool); RexxObject *operatorNot(RexxObject *); RexxObject *evaluate(RexxActivation *, RexxExpressionStack *); - RexxObject *getValue(RexxActivation *context){return this;} - RexxObject *getValue(RexxVariableDictionary *dictionary){return this;} + RexxObject *getValue(RexxActivation *context); + RexxObject *getValue(RexxVariableDictionary *dictionary); + RexxObject *getRealValue(RexxActivation *); + RexxObject *getRealValue(RexxVariableDictionary *); RexxObject *trunc(RexxObject *); RexxObject *truncInternal(size_t); RexxObject *unknown(RexxString *, RexxArray *); Modified: sandbox/rick/opt/kernel/classes/ObjectClass.hpp =================================================================== --- sandbox/rick/opt/kernel/classes/ObjectClass.hpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/classes/ObjectClass.hpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -260,6 +260,8 @@ virtual RexxObject *evaluate(RexxActivation *, RexxExpressionStack *) { return OREF_NULL; } virtual RexxObject *getValue(RexxActivation *) { return OREF_NULL; } virtual RexxObject *getValue(RexxVariableDictionary *) { return OREF_NULL; } + virtual RexxObject *getRealValue(RexxActivation *) { return OREF_NULL; } + virtual RexxObject *getRealValue(RexxVariableDictionary *) { return OREF_NULL; } virtual void uninit() {;} virtual HashCode hash() { return getHashValue(); } virtual HashCode getHashValue() { return identityHash(); } Modified: sandbox/rick/opt/kernel/classes/RoutineClass.cpp =================================================================== --- sandbox/rick/opt/kernel/classes/RoutineClass.cpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/classes/RoutineClass.cpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -118,7 +118,7 @@ { ProtectedObject p(this); // belt-and-braces to make sure this is protected // just forward this to the code object - code->call(activity, msgname, argPtr, argcount, calltype, environment, context, result); + code->call(activity, this, msgname, argPtr, argcount, calltype, environment, context, result); } @@ -134,7 +134,7 @@ /****************************************************************************/ { ProtectedObject p(this); // belt-and-braces to make sure this is protected - code->call(activity, OREF_NONE, arguments, argCount, calltype, environment, PROGRAMCALL, result); + code->call(activity, this, OREF_NONE, arguments, argCount, calltype, environment, PROGRAMCALL, result); } Modified: sandbox/rick/opt/kernel/classes/StringClass.cpp =================================================================== --- sandbox/rick/opt/kernel/classes/StringClass.cpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/classes/StringClass.cpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -1630,6 +1630,46 @@ } +RexxObject *RexxString::getValue( + RexxActivation *context) /* current activation context */ +/******************************************************************************/ +/* Function: Polymorphic get_value function used with expression terms */ +/******************************************************************************/ +{ + return (RexxObject *)this; /* just return this value */ +} + + +RexxObject *RexxString::getValue( + RexxVariableDictionary *context) /* current activation context */ +/******************************************************************************/ +/* Function: Polymorphic get_value function used with expression terms */ +/******************************************************************************/ +{ + return (RexxObject *)this; /* just return this value */ +} + + +RexxObject *RexxString::getRealValue( + RexxActivation *context) /* current activation context */ +/******************************************************************************/ +/* Function: Polymorphic get_value function used with expression terms */ +/******************************************************************************/ +{ + return (RexxObject *)this; /* just return this value */ +} + + +RexxObject *RexxString::getRealValue( + RexxVariableDictionary *context) /* current activation context */ +/******************************************************************************/ +/* Function: Polymorphic get_value function used with expression terms */ +/******************************************************************************/ +{ + return (RexxObject *)this; /* just return this value */ +} + + RexxString *RexxString::newString(const char *string, size_t length) /******************************************************************************/ /* Function: Allocate (and initialize) a string object */ Modified: sandbox/rick/opt/kernel/classes/StringClass.hpp =================================================================== --- sandbox/rick/opt/kernel/classes/StringClass.hpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/classes/StringClass.hpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -177,8 +177,10 @@ RexxObject *logicalOperation(RexxObject *, RexxObject *, unsigned int); RexxString *extract(size_t offset, size_t sublength) { return newString(this->getStringData() + offset, sublength); } RexxObject *evaluate(RexxActivation *, RexxExpressionStack *); - RexxObject *getValue(RexxActivation *context) {return this;} - RexxObject *getValue(RexxVariableDictionary *context) {return this;} + RexxObject *getValue(RexxActivation *); + RexxObject *getValue(RexxVariableDictionary *); + RexxObject *getRealValue(RexxActivation *); + RexxObject *getRealValue(RexxVariableDictionary *); /* the following methods are in */ /* OKBSUBS */ RexxString *center(RexxInteger *, RexxString *); Modified: sandbox/rick/opt/kernel/expression/CommonExternalFunctions.cpp =================================================================== --- sandbox/rick/opt/kernel/expression/CommonExternalFunctions.cpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/expression/CommonExternalFunctions.cpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -43,7 +43,7 @@ /******************************************************************************/ /* activation_rxfuncadd - Method to support RXFUNCADD function */ /******************************************************************************/ -RexxRoutine3(RexxBoolean, sysRxfuncadd, CSTRING,name, CSTRING,module, OPTIONAL_CSTRING, proc) +RexxRoutine3(logical_t, sysRxfuncadd, CSTRING,name, CSTRING,module, OPTIONAL_CSTRING, proc) { if (proc == NO_CSTRING) /* no procedure given? */ { @@ -57,7 +57,7 @@ /******************************************************************************/ /* activation_rxfuncdrop - Method to support RXFUNCDROP function */ /******************************************************************************/ -RexxRoutine1(RexxBoolean, sysRxfuncdrop, CSTRING, name) +RexxRoutine1(logical_t, sysRxfuncdrop, CSTRING, name) { /* try to drop the function */ return RexxDeregisterFunction(name) != 0; @@ -67,7 +67,7 @@ /******************************************************************************/ /* activation_rxfuncquery - Method to support RXFUNCQUERY function */ /******************************************************************************/ -RexxRoutine1(RexxBoolean, sysRxfuncquery, CSTRING,name) +RexxRoutine1(logical_t, sysRxfuncquery, CSTRING,name) { // see if the function is there return RexxQueryFunction(name) != 0; Modified: sandbox/rick/opt/kernel/expression/ExpressionCompoundVariable.cpp =================================================================== --- sandbox/rick/opt/kernel/expression/ExpressionCompoundVariable.cpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/expression/ExpressionCompoundVariable.cpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -227,7 +227,39 @@ return context->getLocalCompoundVariableValue(stemName, index, &tails[0], tailCount); } +/** + * Retrieve an object variable value, returning OREF_NULL if + * the variable does not have a value. + * + * @param dictionary The source variable dictionary. + * + * @return The variable value, or OREF_NULL if the variable is not + * assigned. + */ +RexxObject *RexxCompoundVariable::getRealValue(RexxVariableDictionary *dictionary) +{ + /* resolve the tail element */ + return dictionary->getCompoundVariableRealValue(stem, &tails[0], tailCount); +} + +/** + * Get the value of a variable without applying a default value + * to it. Used in the apis so the caller can more easily + * detect an uninitialized variable. + * + * @param context The current context. + * + * @return The value of the variable. Returns OREF_NULL if the variable + * has not been assigned a value. + */ +RexxObject *RexxCompoundVariable::getRealValue(RexxActivation *context) +{ + /* resolve the tail element */ + return context->getLocalCompoundVariableRealValue(stem, index, &tails[0], tailCount); +} + + void RexxCompoundVariable::set( RexxActivation *context, /* current activation context */ RexxObject *value ) /* new value to assign */ Modified: sandbox/rick/opt/kernel/expression/ExpressionCompoundVariable.hpp =================================================================== --- sandbox/rick/opt/kernel/expression/ExpressionCompoundVariable.hpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/expression/ExpressionCompoundVariable.hpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -66,6 +66,8 @@ RexxObject *evaluate(RexxActivation *, RexxExpressionStack *); RexxObject *getValue(RexxActivation *context); RexxObject *getValue(RexxVariableDictionary *context); + RexxObject *getRealValue(RexxVariableDictionary *); + RexxObject *getRealValue(RexxActivation *); bool exists(RexxActivation *); void set(RexxActivation *, RexxObject *) ; void set(RexxVariableDictionary *, RexxObject *); Modified: sandbox/rick/opt/kernel/expression/ExpressionStem.cpp =================================================================== --- sandbox/rick/opt/kernel/expression/ExpressionStem.cpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/expression/ExpressionStem.cpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -137,6 +137,34 @@ return context->getLocalStem(stem, index); } +/** + * Retrieve the real value of a stem variable. Stem variables + * will always be created on first reference, so there is no + * difference between getValue() and getRealValue(). + * + * @param dictionary The source variable dictionary. + * + * @return The stem object representing this variable. + */ +RexxObject *RexxStemVariable::getRealValue(RexxVariableDictionary *dictionary) +{ + return dictionary->getStem(this->stem); +} + +/** + * Retrieve the real value of a stem variable. Stem variables + * will always be created on first reference, so there is no + * difference between getValue() and getRealValue(). + * + * @param context The current execution context. + * + * @return The stem object representing this variable. + */ +RexxObject *RexxStemVariable::getRealValue(RexxActivation *context) +{ + return context->getLocalStem(stem, index); +} + void RexxStemVariable::set( RexxActivation *context, /* current activation context */ RexxObject *value ) /* new value to be assigned */ Modified: sandbox/rick/opt/kernel/expression/ExpressionStem.hpp =================================================================== --- sandbox/rick/opt/kernel/expression/ExpressionStem.hpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/expression/ExpressionStem.hpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -61,6 +61,8 @@ RexxObject *evaluate(RexxActivation *, RexxExpressionStack *); RexxObject *getValue(RexxVariableDictionary *); RexxObject *getValue(RexxActivation *); + RexxObject *getRealValue(RexxVariableDictionary *); + RexxObject *getRealValue(RexxActivation *); bool exists(RexxActivation *); void set(RexxActivation *, RexxObject *) ; void set(RexxVariableDictionary *, RexxObject *) ; Modified: sandbox/rick/opt/kernel/expression/ExpressionVariable.cpp =================================================================== --- sandbox/rick/opt/kernel/expression/ExpressionVariable.cpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/expression/ExpressionVariable.cpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -151,6 +151,39 @@ return value; /* return the located variable */ } +/** + * Retrieve an object variable value, returning OREF_NULL if + * the variable does not have a value. + * + * @param dictionary The source variable dictionary. + * + * @return The variable value, or OREF_NULL if the variable is not + * assigned. + */ +RexxObject *RexxParseVariable::getRealValue(RexxVariableDictionary *dictionary) +{ + /* look up the name */ + RexxVariable *variable = dictionary->getVariable(variableName); + return variable->getVariableValue();/* get the value */ +} + + +/** + * Get the value of a variable without applying a default value + * to it. Used in the apis so the caller can more easily + * detect an uninitialized variable. + * + * @param context The current context. + * + * @return The value of the variable. Returns OREF_NULL if the variable + * has not been assigned a value. + */ +RexxObject *RexxParseVariable::getRealValue(RexxActivation *context) +{ + RexxVariable *variable = context->getLocalVariable(variableName, index); + return variable->getVariableValue();/* get the value */ +} + void RexxParseVariable::set( RexxVariableDictionary *dictionary, /* current activation dictionary */ RexxObject *value ) Modified: sandbox/rick/opt/kernel/expression/ExpressionVariable.hpp =================================================================== --- sandbox/rick/opt/kernel/expression/ExpressionVariable.hpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/expression/ExpressionVariable.hpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -61,6 +61,8 @@ RexxObject *evaluate(RexxActivation *, RexxExpressionStack *); RexxObject *getValue(RexxVariableDictionary *); RexxObject *getValue(RexxActivation *); + RexxObject *getRealValue(RexxVariableDictionary *); + RexxObject *getRealValue(RexxActivation *); bool exists(RexxActivation *); void set(RexxActivation *, RexxObject *) ; void set(RexxVariableDictionary *, RexxObject *) ; Modified: sandbox/rick/opt/kernel/runtime/ActivityManager.cpp =================================================================== --- sandbox/rick/opt/kernel/runtime/ActivityManager.cpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/runtime/ActivityManager.cpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -266,10 +266,11 @@ /** - * Create a new activation for CALLing a method (vs. a method + * Create a new activation for CALLing a routine (vs. a method * invocation). * * @param activity The activity we're running on. + * @param routine The routine object we're calling. * @param code The code object associated with the method. * @param parent The parent activation. OREF_NULL is used if this is a top-level * call. @@ -280,7 +281,7 @@ * * @return The newly created activation. */ -RexxActivation *ActivityManager::newActivation(RexxActivity *activity, RexxCode *code, RexxActivation *parent, RexxString *calltype, RexxString *environment, int context) +RexxActivation *ActivityManager::newActivation(RexxActivity *activity, RoutineClass *routine, RexxCode *code, RexxActivation *parent, RexxString *calltype, RexxString *environment, int context) { if (activationCacheSize != 0) /* have a cached entry? */ @@ -290,7 +291,7 @@ RexxActivation *resultActivation = (RexxActivation *)activations->stackTop(); /* reactivate this */ resultActivation->setHasReferences(); - resultActivation = new (resultActivation) RexxActivation(activity, code, parent, calltype, environment, context); + resultActivation = new (resultActivation) RexxActivation(activity, routine, code, parent, calltype, environment, context); activations->pop(); /* Remove reused activation from stac*/ return resultActivation; @@ -298,7 +299,7 @@ else /* need to create a new one */ { /* Create new Activation. */ - return new RexxActivation(activity, code, parent, calltype, environment, context); + return new RexxActivation(activity, routine, code, parent, calltype, environment, context); } } @@ -888,6 +889,6 @@ */ RexxObject *NativeContextBlock::protect(RexxObject *o) { - self->saveObject(o); + self->createLocalReference(o); return o; } Modified: sandbox/rick/opt/kernel/runtime/ActivityManager.hpp =================================================================== --- sandbox/rick/opt/kernel/runtime/ActivityManager.hpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/runtime/ActivityManager.hpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -71,7 +71,7 @@ static void createLocks(); static void closeLocks(); static void init(); - static RexxActivation *newActivation(RexxActivity *activity, RexxCode *code, RexxActivation *parent, RexxString *calltype, RexxString *environment, int context); + static RexxActivation *newActivation(RexxActivity *activity, RoutineClass *routine, RexxCode *code, RexxActivation *parent, RexxString *calltype, RexxString *environment, int context); static RexxActivation *newActivation(RexxActivity *activity, RexxMethod *method, RexxCode *code); static void cacheActivation(RexxActivation *activation); static RexxActivity *newActivity(int priority); Modified: sandbox/rick/opt/kernel/runtime/CPPCode.cpp =================================================================== --- sandbox/rick/opt/kernel/runtime/CPPCode.cpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/runtime/CPPCode.cpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -401,6 +401,7 @@ #include "QueueClass.hpp" #include "SupplierClass.hpp" #include "MethodClass.hpp" +#include "RoutineClass.hpp" #include "RexxEnvelope.hpp" #include "MessageClass.hpp" #include "StemClass.hpp" @@ -603,7 +604,7 @@ CPPM(RexxMethod::setUnGuardedRexx), /* Method methods */ CPPM(RexxMethod::setGuardedRexx), -CPPM(RexxMethod::source), +CPPM(BaseExecutable::source), CPPM(RexxMethod::setPrivateRexx), CPPM(RexxMethod::setProtectedRexx), CPPM(RexxMethod::setSecurityManager), @@ -611,9 +612,12 @@ CPPM(RexxMethod::isPrivateRexx), CPPM(RexxMethod::isProtectedRexx), -CPPM(RexxMethodClass::newFileRexx), -CPPM(RexxMethodClass::newRexx), +CPPM(RexxMethod::newFileRexx), +CPPM(RexxMethod::newRexx), +CPPM(RoutineClass::newFileRexx), +CPPM(RoutineClass::newRexx), + CPPM(RexxNumberString::formatRexx), /* NumberString methods */ CPPM(RexxNumberString::trunc), CPPM(RexxNumberString::equal), Modified: sandbox/rick/opt/kernel/runtime/CreateRoutineDispatcher.cpp =================================================================== --- sandbox/rick/opt/kernel/runtime/CreateRoutineDispatcher.cpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/runtime/CreateRoutineDispatcher.cpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -119,7 +119,7 @@ activity->run(callback); new_arglist = callback.argumentList; - activation->saveObject(new_arglist); + activation->createLocalReference(new_arglist); } // use dummy argument array else Modified: sandbox/rick/opt/kernel/runtime/Numerics.cpp =================================================================== --- sandbox/rick/opt/kernel/runtime/Numerics.cpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/runtime/Numerics.cpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -305,7 +305,7 @@ // is this an integer value (very common) if (isInteger(source)) { - result = ((RexxInteger *)source)->stringsize(); + result = ((RexxInteger *)source)->stringSize(); return true; } else @@ -319,7 +319,7 @@ } // if not a valid whole number, reject this too - return nString->uint64Value(&result, DIGITS64); + return nString->unsignedInt64Value(&result, DIGITS64); } } Modified: sandbox/rick/opt/kernel/runtime/PackageManager.hpp =================================================================== --- sandbox/rick/opt/kernel/runtime/PackageManager.hpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/runtime/PackageManager.hpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -71,9 +71,9 @@ static RoutineClass *resolveRoutine(RexxString *function); static RoutineClass *createRegisteredRoutine(RexxString *function); static RoutineClass *getLoadedRoutine(RexxString *function); - PNATIVEMETHOD resolveMethodEntry(RexxString *package, RexxString *name); - PNATIVEROUTINE resolveRoutineEntry(RexxString *package, RexxString *name); - PREGISTEREDROUTINE resolveRegisteredRoutineEntry(RexxString *package, RexxString *name); + static PNATIVEMETHOD resolveMethodEntry(RexxString *package, RexxString *name); + static PNATIVEROUTINE resolveRoutineEntry(RexxString *package, RexxString *name); + static PREGISTEREDROUTINE resolveRegisteredRoutineEntry(RexxString *package, RexxString *name); static void addPackageRoutine(RexxString *name, RoutineClass *func); static void loadInternalPackage(RexxString *name, RexxPackageEntry *p); static RexxObject *addRegisteredRoutine(RexxString *name, RexxString *module, RexxString *proc); Modified: sandbox/rick/opt/kernel/runtime/RexxActivation.cpp =================================================================== --- sandbox/rick/opt/kernel/runtime/RexxActivation.cpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/runtime/RexxActivation.cpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -125,6 +125,7 @@ setGuarded(); } this->code = _code; /* get the REXX method object */ + this->method = _method; // save the method link also this->settings.intermediate_trace = false; this->activation_context = METHODCALL; // the context is a method call /* save the sender activation */ @@ -161,12 +162,13 @@ } -RexxActivation::RexxActivation(RexxActivity *_activity, RexxCode *_code, RexxActivation *_parent, +RexxActivation::RexxActivation(RexxActivity *_activity, RoutineClass *_routine, RexxCode *_code, RexxActivation *_parent, RexxString *calltype, RexxString *env, int context) { this->clearObject(); /* start with a fresh object */ this->activity = _activity; /* save the activity pointer */ this->code = _code; /* get the REXX method object */ + this->routine = _routine; // need to save the target routine also if (context == DEBUGPAUSE) /* actually a debug pause? */ { this->debug_pause = true; /* set up for debugging intercepts */ @@ -750,6 +752,8 @@ memory_mark(this->receiver); memory_mark(this->scope); memory_mark(this->code); + memory_mark(this->method); + memory_mark(this->routine); memory_mark(this->settings.securityManager); memory_mark(this->receiver); memory_mark(this->activity); @@ -799,6 +803,8 @@ { memory_mark_general(this->receiver); memory_mark_general(this->code); + memory_mark_general(this->method); + memory_mark_general(this->routine); memory_mark_general(this->settings.securityManager); memory_mark_general(this->receiver); memory_mark_general(this->activity); @@ -1987,7 +1993,7 @@ /* translate the code */ RexxCode * newCode = this->code->interpret(codestring, this->current->getLineNumber()); /* create a new activation */ - RexxActivation *newActivation = ActivityManager::newActivation(this->activity, newCode, this, OREF_NULL, OREF_NULL, INTERPRET); + RexxActivation *newActivation = ActivityManager::newActivation(this->activity, OREF_NULL, newCode, this, OREF_NULL, OREF_NULL, INTERPRET); this->activity->pushStackFrame(newActivation); /* push on the activity stack */ ProtectedObject r; /* run the internal routine on the */ @@ -2008,7 +2014,7 @@ /* translate the code */ RexxCode *newCode = this->code->interpret(codestring, this->current->getLineNumber()); /* create a new activation */ - RexxActivation *newActivation = ActivityManager::newActivation(this->activity, newCode, this, OREF_NULL, OREF_NULL, DEBUGPAUSE); + RexxActivation *newActivation = ActivityManager::newActivation(this->activity, OREF_NULL, newCode, this, OREF_NULL, OREF_NULL, DEBUGPAUSE); this->activity->pushStackFrame(newActivation); /* push on the activity stack */ ProtectedObject r; /* run the internal routine on the */ @@ -2341,7 +2347,7 @@ /* initialize the SIGL variable */ this->setLocalVariable(OREF_SIGL, VARIABLE_SIGL, new_integer(lineNum)); /* create a new activation */ - newActivation = ActivityManager::newActivation(this->activity, + newActivation = ActivityManager::newActivation(this->activity, OREF_NULL, this->settings.parent_code, this, OREF_NULL, OREF_NULL, INTERNALCALL); this->activity->pushStackFrame(newActivation); /* push on the activity stack */ @@ -2366,7 +2372,7 @@ /* initialize the SIGL variable */ this->setLocalVariable(OREF_SIGL, VARIABLE_SIGL, new_integer(lineNum)); /* create a new activation */ - newActivation = ActivityManager::newActivation(this->activity, + newActivation = ActivityManager::newActivation(this->activity, OREF_NULL, this->settings.parent_code, this, OREF_NULL, OREF_NULL, INTERNALCALL); /* set the new condition object */ newActivation->setConditionObj(conditionObj); Modified: sandbox/rick/opt/kernel/runtime/RexxActivation.hpp =================================================================== --- sandbox/rick/opt/kernel/runtime/RexxActivation.hpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/runtime/RexxActivation.hpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -181,8 +181,8 @@ inline void operator delete(void *, void *) { ; } inline RexxActivation(RESTORETYPE restoreType) { ; }; - RexxActivation(RexxActivity* _activity, RexxMethod * _method, RexxCode *_code); - RexxActivation(RexxActivity *_activity, RexxCode *_code, RexxActivation *_parent, RexxString *calltype, RexxString *env, int context); + RexxActivation(RexxActivity* _activity, RexxMethod *_method, RexxCode *_code); + RexxActivation(RexxActivity *_activity, RoutineClass *_routine, RexxCode *_code, RexxActivation *_parent, RexxString *calltype, RexxString *env, int context); void init(RexxObject *, RexxObject *, RexxObject *, RexxObject *, RexxObject *, int); void live(size_t); void liveGeneral(int reason); @@ -661,6 +661,8 @@ ActivationSettings settings; /* inherited REXX settings */ RexxExpressionStack stack; /* current evaluation stack */ + RexxMethod *method; // for a method invocation + RoutineClass *routine; // for a routine invocation RexxCode *code; /* rexx method object */ RexxClass *scope; // scope of any active method call RexxObject *receiver; /* target of a message invocation */ Modified: sandbox/rick/opt/kernel/runtime/RexxActivity.hpp =================================================================== --- sandbox/rick/opt/kernel/runtime/RexxActivity.hpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/runtime/RexxActivity.hpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -281,6 +281,7 @@ inline int getPriority() { return priority; } inline RexxThreadContext *getThreadContext() { return &threadContext.threadContext; } + inline RexxNativeActivation *getApiContext() { return (RexxNativeActivation *)topStackFrame; } inline void allocateStackFrame(RexxExpressionStack *stack, size_t entries) { @@ -378,4 +379,64 @@ static ExitContextInterface exitContextFunctions; }; + +/** + * Convert an API context to into the top native activation + * context associated with the thread. + * + * @param c The source API context. + * + * @return A Native activation context that is the anchor point for the + * API activity. + */ +inline RexxNativeActivation *contextToActivation(RexxThreadContext *c) +{ + return contextToActivity(c)->getApiContext(); +} + + +/** + * Convert an API context to into the top native activation + * context associated with the thread. + * + * @param c The source API context. + * + * @return A Native activation context that is the anchor point for the + * API activity. + */ +inline RexxNativeActivation *contextToActivation(RexxCallContext *c) +{ + return ((CallContext *)c)->context; +} + + +/** + * Convert an API context to into the top native activation + * context associated with the thread. + * + * @param c The source API context. + * + * @return A Native activation context that is the anchor point for the + * API activity. + */ +inline RexxNativeActivation *contextToActivation(RexxExitContext *c) +{ + return ((ExitContext *)c)->context; +} + + +/** + * Convert an API context to into the top native activation + * context associated with the thread. + * + * @param c The source API context. + * + * @return A Native activation context that is the anchor point for the + * API activity. + */ +inline RexxNativeActivation *contextToActivation(RexxMethodContext *c) +{ + return ((MethodContext *)c)->context; +} + #endif Modified: sandbox/rick/opt/kernel/runtime/RexxCode.cpp =================================================================== --- sandbox/rick/opt/kernel/runtime/RexxCode.cpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/runtime/RexxCode.cpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -77,6 +77,7 @@ void RexxCode::call( RexxActivity *activity, /* activity running under */ + RoutineClass *routine, // top level routine instance RexxString *msgname, /* message to be run */ RexxObject**argPtr, /* arguments to the method */ size_t argcount, /* the count of arguments */ @@ -91,7 +92,7 @@ // check the stack space before proceeding activity->checkStackSpace(); /* have enough stack space? */ /* add to the activity stack */ - RexxActivation *newacta = ActivityManager::newActivation(activity, this, OREF_NULL, calltype, environment, context); + RexxActivation *newacta = ActivityManager::newActivation(activity, routine, this, OREF_NULL, calltype, environment, context); activity->pushStackFrame(newacta); /* run the method and return result */ newacta->run(OREF_NULL, msgname, argPtr, argcount, OREF_NULL, result); @@ -103,8 +104,8 @@ RexxMethod *method, // the method object getting invoked RexxObject *receiver, /* object receiving the message */ RexxString *msgname, /* message to be run */ + RexxObject**argPtr, /* arguments to the method */ size_t argcount, /* the count of arguments */ - RexxObject**argPtr, /* arguments to the method */ ProtectedObject &result) // the method result /******************************************************************************/ /* Function: Call a method as a top level program or external function call */ Modified: sandbox/rick/opt/kernel/runtime/RexxCode.hpp =================================================================== --- sandbox/rick/opt/kernel/runtime/RexxCode.hpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/runtime/RexxCode.hpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -91,8 +91,8 @@ inline RoutineClass *resolveRoutine(RexxString *n) { return source->resolveRoutine(n); } inline RexxString *resolveProgramName(RexxActivity *activity, RexxString *name) { return source->resolveProgramName(activity, name); } inline void mergeRequired(RexxSource *s) { source->mergeRequired(s); } - virtual void run(RexxActivity *, RexxMethod *, RexxObject *, RexxString *, size_t, RexxObject **, ProtectedObject &); - virtual void call(RexxActivity *, RexxString *, RexxObject **, size_t, RexxString *, RexxString *, int, ProtectedObject &); + virtual void run(RexxActivity *, RexxMethod *, RexxObject *, RexxString *, RexxObject **, size_t, ProtectedObject &); + virtual void call(RexxActivity *, RoutineClass *, RexxString *, RexxObject **, size_t, RexxString *, RexxString *, int, ProtectedObject &); protected: Modified: sandbox/rick/opt/kernel/runtime/RexxNativeActivation.cpp =================================================================== --- sandbox/rick/opt/kernel/runtime/RexxNativeActivation.cpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/runtime/RexxNativeActivation.cpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -99,6 +99,7 @@ memory_mark(this->argArray); memory_mark(this->receiver); memory_mark(this->method); + memory_mark(this->routine); memory_mark(this->activity); memory_mark(this->activation); memory_mark(this->msgname); @@ -128,6 +129,7 @@ memory_mark_general(this->argArray); memory_mark_general(this->receiver); memory_mark_general(this->method); + memory_mark_general(this->routine); memory_mark_general(this->activity); memory_mark_general(this->activation); memory_mark_general(this->msgname); @@ -995,7 +997,7 @@ * @param resultObj The returned result object. */ void RexxNativeActivation::run(RexxMethod *_method, RexxNativeMethod *_code, RexxObject *_receiver, - RexxString *_msgname, size_t _argcount, RexxObject **_arglist, ProtectedObject &resultObj) + RexxString *_msgname, RexxObject **_arglist, size_t _argcount, ProtectedObject &resultObj) { // anchor the relevant context information method = _method; @@ -1100,15 +1102,19 @@ /** * Process a native function call. * - * @param entryPoint The target function entry point. - * @param count The number of arguments. - * @param list The list of arguments. - * @param result A protected object to receive the function result. + * @param routine The routine we're executing (used for context resolution). + * @param code The code object. + * @param functionName + * The name of the function. + * @param list The list of arguments. + * @param count The number of arguments. + * @param resultObj The return value. */ -void RexxNativeActivation::callNativeFunction(RexxNativeRoutine *code, RexxString *functionName, size_t count, - RexxObject **list, ProtectedObject &resultObj) +void RexxNativeActivation::callNativeRoutine(RoutineClass *_routine, RexxNativeRoutine *code, RexxString *functionName, + RexxObject **list, size_t count, ProtectedObject &resultObj) { // anchor the context stuff + routine = routine; msgname = functionName; arglist = list; argcount = count; @@ -1203,15 +1209,16 @@ * Process a native function call. * * @param entryPoint The target function entry point. + * @param list The list of arguments. * @param count The number of arguments. - * @param list The list of arguments. * @param result A protected object to receive the function result. */ -void RexxNativeActivation::callRegisteredRoutine(RegisteredRoutine *code, RexxString *functionName, size_t count, - RexxObject **list, ProtectedObject &resultObj) +void RexxNativeActivation::callRegisteredRoutine(RoutineClass *_routine, RegisteredRoutine *code, RexxString *functionName, + RexxObject **list, size_t count, ProtectedObject &resultObj) { // anchor the context stuff msgname = functionName; + routine = _routine; arglist = list; argcount = count; @@ -1594,7 +1601,7 @@ // convert using the whole value range if (!Numerics::objectToUnsignedInt64(o, temp)) { - if (activationType == METHOD_INVOCATION) + if (activationType == METHOD_ACTIVATION) { /* this is an error */ reportException(Error_Incorrect_method_whole, position + 1, o); @@ -2134,12 +2141,12 @@ RexxVariableBase *retriever = activation->getVariableRetriever(name); // if this didn't parse, it's an illegal name // it must also resolve to a stem type...this could be a compound one - if (retriever == OREF_NULL || !isOfClass(StemVariable, retriever)) + if (retriever == OREF_NULL || !isOfClass(StemVariableTerm, retriever)) { return OREF_NULL; } // get the variable value - return retriever->getValue(context); + return retriever->getValue(activation); } @@ -2153,7 +2160,7 @@ */ RexxObject *RexxNativeActivation::getContextVariable(const char *name) { - RexxVariableBase *retriever = activation->getVariableRetriever(name); + RexxVariableBase *retriever = activation->getVariableRetriever(new_string(name)); // if this didn't parse, it's an illegal name if (retriever == OREF_NULL) { @@ -2170,7 +2177,7 @@ else { // get the variable value - return retriever->realValue(activation); + return retriever->getRealValue(activation); } } @@ -2183,7 +2190,7 @@ void RexxNativeActivation::setContextVariable(const char *name, RexxObject *value) { // get the REXX activation for the target context - RexxVariableBase *retriever = activation->getVariableRetriever(name); + RexxVariableBase *retriever = activation->getVariableRetriever(new_string(name)); // if this didn't parse, it's an illegal name if (retriever == OREF_NULL || isString((RexxObject *)retriever)) { @@ -2192,7 +2199,7 @@ this->resetNext(); // all next operations must be reset // do the assignment - retriever->set(context, value); + retriever->set(activation, value); } @@ -2204,7 +2211,7 @@ void RexxNativeActivation::dropContextVariable(const char *name) { // get the REXX activation for the target context - RexxVariableBase *retriever = activation->getVariableRetriever(name); + RexxVariableBase *retriever = activation->getVariableRetriever(new_string(name)); // if this didn't parse, it's an illegal name if (retriever == OREF_NULL || isString((RexxObject *)retriever)) { @@ -2213,7 +2220,7 @@ this->resetNext(); // all next operations must be reset // perform the drop - retriever->drop(context); + retriever->drop(activation); } void RexxNativeActivation::checkConditions() @@ -2226,7 +2233,7 @@ { // we're raising this in the previous stack frame. If it doesn't exist, // se just leave this in place so top-level callers can check this. - if (activaiton != OREF_NULL) + if (activation != OREF_NULL) { activity->reraiseException(conditionObj); } Modified: sandbox/rick/opt/kernel/runtime/RexxNativeActivation.hpp =================================================================== --- sandbox/rick/opt/kernel/runtime/RexxNativeActivation.hpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/runtime/RexxNativeActivation.hpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -49,6 +49,8 @@ class ActivityDispatcher; class CallbackDispatcher; class RexxNativeMethod; +class RexxNativeRoutine; +class RegisteredRoutine; class RexxStem; #define MAX_NATIVE_ARGUMENTS 16 @@ -67,7 +69,7 @@ void live(size_t); void liveGeneral(int reason); void run(RexxMethod *_method, RexxNativeMethod *_code, RexxObject *_receiver, - RexxString *_msgname, size_t _argcount, RexxObject **_arglist, ProtectedObject &resultObj); + RexxString *_msgname, RexxObject **_arglist, size_t _argcount, ProtectedObject &resultObj); void run(RexxObject *, RexxString *, size_t, RexxObject **, ProtectedObject &); void run(ActivityDispatcher &dispatcher); void run(CallbackDispatcher &dispatcher); @@ -113,7 +115,9 @@ inline RexxStem *nextStem() {return this->nextstem;} RexxObject *getContextStem(RexxString *name); RexxObject *getContextVariable(const char *name); + void dropContextVariable(const char *name); void setContextVariable(const char *name, RexxObject *value); + void checkConditions(); inline RexxVariableDictionary *nextCurrent() {return this->nextcurrent;} inline RexxCompoundElement *compoundElement() {return this->compoundelement; } inline void setNextVariable(size_t value) {this->nextvariable = value;} @@ -133,10 +137,10 @@ bool objectToValue(RexxObject *o, ValueDescriptor *value); void createLocalReference(RexxObject *objr); void removeLocalReference(RexxObject *objr); - void callNativeFunction(RexxNativeRoutine *code, RexxString *functionName, size_t count, - RexxObject **list, ProtectedObject &result); - void callRegisteredRoutine(RegisteredRoutine *code, RexxString *functionName, size_t count, - RexxObject **list, ProtectedObject &resultObj); + void callNativeRoutine(RoutineClass *routine, RexxNativeRoutine *code, RexxString *functionName, + RexxObject **list, size_t count, ProtectedObject &result); + void callRegisteredRoutine(RoutineClass *routine, RegisteredRoutine *code, RexxString *functionName, + RexxObject **list, size_t count, ProtectedObject &resultObj); protected: @@ -151,6 +155,7 @@ RexxActivity *activity; /* current activity */ RexxMethod *method; /* Method to run */ + RoutineClass *routine; /* Routine to run */ RexxNativeCode *code; // the code object controlling the target RexxObject *receiver; // the object receiving the message RexxString *msgname; /* name of the message running */ Modified: sandbox/rick/opt/kernel/runtime/RexxNativeCode.cpp =================================================================== --- sandbox/rick/opt/kernel/runtime/RexxNativeCode.cpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/runtime/RexxNativeCode.cpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -47,6 +47,9 @@ #include "StringClass.hpp" #include "DirectoryClass.hpp" #include "RexxNativeActivation.hpp" +#include "RexxNativeCode.hpp" +#include "SourceFile.hpp" +#include "PackageManager.hpp" #include <ctype.h> @@ -96,7 +99,7 @@ { entry = NULL; } - RexxNativeCode(liveGeneral(reason); + RexxNativeCode::liveGeneral(reason); } @@ -122,7 +125,7 @@ { entry = NULL; } - RexxNativeCode(liveGeneral(reason); + RexxNativeCode::liveGeneral(reason); } @@ -131,7 +134,7 @@ /* Function: Flatten an object */ /******************************************************************************/ { - setUpFlatten(RexxNativeMethod) + setUpFlatten(RexxNativeRoutine) newThis->entry = NULL; RexxNativeCode::flatten(envelope); cleanUpFlatten @@ -148,7 +151,7 @@ { entry = NULL; } - RexxNativeCode(liveGeneral(reason); + RexxNativeCode::liveGeneral(reason); } @@ -157,7 +160,7 @@ /* Function: Flatten an object */ /******************************************************************************/ { - setUpFlatten(RexxNativeMethod) + setUpFlatten(RegisteredRoutine) newThis->entry = NULL; RexxNativeCode::flatten(envelope); cleanUpFlatten @@ -177,7 +180,7 @@ * @param result The protected object used to return the result. */ void RexxNativeMethod::run(RexxActivity *activity, RexxMethod *method, RexxObject *receiver, RexxString *messageName, - size_t count, RexxObject **argPtr, ProtectedObject &result) + RexxObject **argPtr, size_t count, ProtectedObject &result) { // if this is NULL currently, we need to lazy resolve this entry if (entry == NULL) @@ -187,10 +190,10 @@ } // create a new native activation - RexxNativeActivation *newNActa = new RexxNativeActivation(activity, method); + RexxNativeActivation *newNActa = new RexxNativeActivation(activity); activity->pushStackFrame(newNActa); /* push it on the activity stack */ /* and go run it */ - newNActa->run(this, receiver, messageName, count, argPtr, result); + newNActa->run(method, this, receiver, messageName, argPtr, count, result); } @@ -205,19 +208,6 @@ /** - * Lazy resolve a native method. This will be done on the first call - * to a method definition that's been saved and restored. On - * restore, we have a potential situation where we need to get - * the package reloaded and restored before we can resolve the entry - * point. - */ -void RexxNativeRoutine::resolve() -{ -} - - - -/** * Run a method call (vs a straight program call). * * @param activity The current activity. @@ -227,20 +217,20 @@ * @param argPtr The pointer to the arguments. * @param result The protected object used to return the result. */ -void RexxNativeRoutine::call(RexxActivity *activity, RexxString *functionName, size_t count, RexxObject **argPtr, ProtectedObject &result) +void RexxNativeRoutine::call(RexxActivity *activity, RoutineClass *routine, RexxString *functionName, RexxObject **argPtr, size_t count, ProtectedObject &result) { // if this is NULL currently, we need to lazy resolve this entry if (entry == NULL) { // have the package manager resolve this for us before we make a call - entry = PackageManager::resolveFunctionEntry(package, name); + entry = PackageManager::resolveRoutineEntry(package, name); } // create a new native activation RexxNativeActivation *newNActa = new RexxNativeActivation(activity); activity->pushStackFrame(newNActa); /* push it on the activity stack */ /* and go run it */ - newNActa->run(this, functionName, count, argPtr, result); + newNActa->callNativeRoutine(routine, this, functionName, argPtr, count, result); } @@ -250,7 +240,7 @@ /* Function: Create a new Native method */ /****************************************************************************/ { - return new_object(size, T_NativeFunction); // Get new object + return new_object(size, T_NativeRoutine); // Get new object } @@ -264,20 +254,20 @@ * @param argPtr The pointer to the arguments. * @param result The protected object used to return the result. */ -void RegisteredRoutine::call(RexxActivity *activity, RexxString *functionName, size_t count, RexxObject **argPtr, ProtectedObject &result) +void RegisteredRoutine::call(RexxActivity *activity, RoutineClass *routine, RexxString *functionName, RexxObject **argPtr, size_t count, ProtectedObject &result) { // if this is NULL currently, we need to lazy resolve this entry if (entry == NULL) { // have the package manager resolve this for us before we make a call - entry = PackageManager::resolveRegusteredFunctionEntry(package, name); + entry = PackageManager::resolveRegisteredRoutineEntry(package, name); } // create a new native activation RexxNativeActivation *newNActa = new RexxNativeActivation(activity); activity->pushStackFrame(newNActa); /* push it on the activity stack */ /* and go run it */ - newNActa->run(this, functionName, count, argPtr, result); + newNActa->callRegisteredRoutine(routine, this, functionName, argPtr, count, result); } @@ -287,5 +277,5 @@ /* Function: Create a new Native method */ /****************************************************************************/ { - return new_object(size, T_RegisterdFunction); // Get new object + return new_object(size, T_RegisteredRoutine); // Get new object } Modified: sandbox/rick/opt/kernel/runtime/RexxNativeCode.hpp =================================================================== --- sandbox/rick/opt/kernel/runtime/RexxNativeCode.hpp 2008-02-11 00:48:50 UTC (rev 2354) +++ sandbox/rick/opt/kernel/runtime/RexxNativeCode.hpp 2008-02-12 00:59:58 UTC (rev 2355) @@ -83,7 +83,7 @@ inline PNATIVEMETHOD getEntry() { return entry; } virtual void run(RexxActivity *activity, RexxMethod *method, RexxObject *receiver, RexxString *messageName, - size_t count, RexxObject **argPtr, ProtectedObject &result); + RexxObject **argPtr, size_t count, ProtectedObject &result); protected: PNATIVEMETHOD entry; // method entry point. @@ -97,7 +97,7 @@ inline RexxRoutine() { } inline RexxRoutine(RexxString *p, RexxString *n, RexxSource *s) : RexxNativeCode(p, n, s) { } - virtual void call(RexxActivity *, RexxString *, RexxObject **, size_t, ProtectedObject &) = 0; + virtual void call(RexxActivity *, RoutineClass *, RexxString *, RexxObject **, size_t, ProtectedObject &) = 0; }; @@ -117,7 +117,7 @@ inline PNATIVEROUTINE getEntry() { return entry; } - virtual void call(RexxActivity *, RexxString *, RexxObject **, size_t, ProtectedObject &); + virtual void call(RexxActivity *, RoutineClass *, RexxString *, RexxObject **, size_t, ProtectedObject &); protected: PNATIVEROUTINE entry; // method entry point. @@ -140,7 +140,7 @@ RegisteredRoutine(RexxString *p, RexxString *n, RexxRoutineHandler *e) : RexxRoutine(p, n, OREF_NULL), entry(e) { } RegisteredRoutine(RexxString *p, RexxString *n, RexxSource *s, RexxRoutineHandler *e) : RexxRoutine(p, n, s), entry(e) { } - virtual void call(RexxActivity *, RexxString *, RexxObject **, size_t, ProtectedObject &); + virtual void call(RexxActivity *, RoutineClass *, RexxString *, RexxObject **, size_t, ProtectedObject &); inline RexxRoutineHandler *getEntry() { return entry; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bigrixx@us...> - 2008-02-15 00:49:02
|
Revision: 2360 http://oorexx.svn.sourceforge.net/oorexx/?rev=2360&view=rev Author: bigrixx Date: 2008-02-14 16:49:06 -0800 (Thu, 14 Feb 2008) Log Message: ----------- incremental checkin Modified Paths: -------------- sandbox/rick/opt/kernel/classes/PackageClass.cpp sandbox/rick/opt/kernel/classes/PackageClass.hpp sandbox/rick/opt/kernel/instructions/RequiresDirective.cpp sandbox/rick/opt/kernel/instructions/RequiresDirective.hpp sandbox/rick/opt/kernel/kernel.mak sandbox/rick/opt/kernel/messages/rexxmsg.xml sandbox/rick/opt/kernel/parser/SourceFile.cpp sandbox/rick/opt/kernel/runtime/PackageManager.cpp sandbox/rick/opt/kernel/runtime/PackageManager.hpp sandbox/rick/opt/kernel/runtime/PrimitiveClasses.xml sandbox/rick/opt/kernel/runtime/RexxActivation.cpp Added Paths: ----------- sandbox/rick/opt/kernel/runtime/LibraryPackage.cpp sandbox/rick/opt/kernel/runtime/LibraryPackage.hpp Removed Paths: ------------- sandbox/rick/opt/kernel/runtime/Package.cpp sandbox/rick/opt/kernel/runtime/Package.hpp Modified: sandbox/rick/opt/kernel/classes/PackageClass.cpp =================================================================== --- sandbox/rick/opt/kernel/classes/PackageClass.cpp 2008-02-14 00:39:59 UTC (rev 2359) +++ sandbox/rick/opt/kernel/classes/PackageClass.cpp 2008-02-15 00:49:06 UTC (rev 2360) @@ -141,43 +141,199 @@ } +/** + * Retrieve all classes defined by this package. + * + * @return A directory of all of the classes defined by this package. + */ RexxDirectory *PackageClass::getClasses() { - return (RexxDirectory *)source->getInstalledClasses()->copy(); + // we need to return a copy. The source might necessarily have any of these, + // so we return an empty directory if it's not there. + RexxDirectory *classes = source->getInstalledClasses(); + if (classes != OREF_NULL) + { + return (RexxDirectory *)classes->copy(); + } + else + { + return new_directory(); + } } +/** + * Retrieve all public classes defined by this package. + * + * @return A directory of the public classes. + */ RexxDirectory *PackageClass::getPublicClasses() { - return (RexxDirectory *)source->getInstalledPublicClasses()->copy(); + // we need to return a copy. The source might necessarily have any of these, + // so we return an empty directory if it's not there. + RexxDirectory *classes = source->getInstalledPublicClasses(); + if (classes != OREF_NULL) + { + return (RexxDirectory *)classes->copy(); + } + else + { + return new_directory(); + } } +/** + * Retrieve all of the classes imported into this package from + * other packages. + * + * @return A directory of the imported classes. + */ RexxDirectory *PackageClass::getImportedClasses() { - return (RexxDirectory *)source->getImportedClasses()->copy(); + // we need to return a copy. The source might necessarily have any of these, + // so we return an empty directory if it's not there. + RexxDirectory *classes = source->getImportedClasses(); + if (classes != OREF_NULL) + { + return (RexxDirectory *)classes->copy(); + } + else + { + return new_directory(); + } } +/** + * Get a list of all routines defined by this package. + * + * @return A directory of the routines. + */ RexxDirectory *PackageClass::getRoutines() { - return (RexxDirectory *)source->getInstalledRoutines()->copy(); + // we need to return a copy. The source might necessarily have any of these, + // so we return an empty directory if it's not there. + RexxDirectory *routines = source->getInstalledRoutines(); + if (routines != OREF_NULL) + { + return (RexxDirectory *)routines->copy(); + } + else + { + return new_directory(); + } } +/** + * Return a directory of the Public routines defined by this + * package. + * + * @return A directory holding the public routines. + */ RexxDirectory *PackageClass::getPublicRoutines() { - return (RexxDirectory *)source->getInstalledPublicRoutines()->copy(); + // we need to return a copy. The source might necessarily have any of these, + // so we return an empty directory if it's not there. + RexxDirectory *routines = source->getInstalledPublicRoutines(); + if (routines != OREF_NULL) + { + return (RexxDirectory *)routines->copy(); + } + else + { + return new_directory(); + } } +/** + * Get the directory of routines that have been imported into + * to this package form other packages. + * + * @return A directory of the imported routines. + */ RexxDirectory *PackageClass::getImportedRoutines() { - return (RexxDirectory *)source->getImportedRoutines()->copy(); + // we need to return a copy. The source might necessarily have any of these, + // so we return an empty directory if it's not there. + RexxDirectory *routines = source->getImportedRoutines(); + if (routines != OREF_NULL) + { + return (RexxDirectory *)routines->copy(); + } + else + { + return new_directory(); + } } +/** + * Get all of the unattached methods defined in this package. + * + * @return A directory of the unattached methods. + */ RexxDirectory *PackageClass::getMethods() { - return (RexxDirectory *)source->getMethods()->copy(); + // we need to return a copy. The source might necessarily have any of these, + // so we return an empty directory if it's not there. + RexxDirectory *methods = source->getMethods(); + if (methods != OREF_NULL) + { + return (RexxDirectory *)methods->copy(); + } + else + { + return new_directory(); + } } + + +/** + * Get all of the packages that have been added to this package + * context. + * + * @return An array of the added packages. + */ +RexxArray *PackageClass::getPackages() +{ + return source->getPackages()->makearray(); +} + + +/** + * Load a package in a source context. + * + * @param name The target package name. + * + * @return The loaded package object. + */ +PackageClass *loadPackage(RexxString *name) +{ + // make sure we have a valid name and delegate to the source object + name = REQUIRED_STRING(name, IntegerOne); + return source->loadRequired(name); +} + + +/** + * Load a package in a source context. + * + * @param name The target package name. + * + * @return The loaded package object. + */ +RexxObject *addPackage(PackageClass *package) +{ + // this is required + required_arg(package, ONE); + + if (!package->isInstanceOf(ThePackageClass)) + { + reportException(Error_Invalid_argument_noclass, "package", "Package"); + } + + source->addPackage(package); +} Modified: sandbox/rick/opt/kernel/classes/PackageClass.hpp =================================================================== --- sandbox/rick/opt/kernel/classes/PackageClass.hpp 2008-02-14 00:39:59 UTC (rev 2359) +++ sandbox/rick/opt/kernel/classes/PackageClass.hpp 2008-02-15 00:49:06 UTC (rev 2360) @@ -73,6 +73,8 @@ RexxDirectory *getImportedRoutines(); RexxArray *getImportedPackages(); + inline RexxSource *getSourceObject() { return source; } + protected; RexxSource *source; // the wrappered source object Modified: sandbox/rick/opt/kernel/instructions/RequiresDirective.cpp =================================================================== --- sandbox/rick/opt/kernel/instructions/RequiresDirective.cpp 2008-02-14 00:39:59 UTC (rev 2359) +++ sandbox/rick/opt/kernel/instructions/RequiresDirective.cpp 2008-02-15 00:49:06 UTC (rev 2360) @@ -57,7 +57,6 @@ RequiresDirective::RequiresDirective(RexxString *n, RexxClause *clause) : RexxDirective(clause, KEYWORD_REQUIRES) { name = n; - resolvedTarget = OREF_NULL; // this is resolved at install time } /** @@ -69,7 +68,6 @@ { memory_mark(this->nextInstruction); // must be first one marked (though normally null) memory_mark(this->name); - memory_mark(this->resolvedTarget); } @@ -82,7 +80,6 @@ { memory_mark_general(this->nextInstruction); // must be first one marked (though normally null) memory_mark_general(this->name); - memory_mark_general(this->resolvedTarget); } @@ -97,9 +94,6 @@ flatten_reference(newThis->nextInstruction, envelope); flatten_reference(newThis->name, envelope); - // We sever this connection when the method is flattened. - newThis->resolvedTarget = OREF_NULL; - cleanUpFlatten } @@ -124,7 +118,7 @@ * * @param activation The activation we're running under for the install. */ -void RequiresDirective::install(RexxActivation *context) +PackageClass *RequiresDirective::install(RexxActivation *context) { - OrefSet(this, this->resolvedTarget, context->processRequires(name, this)); + return context->loadRequired(name, this); } Modified: sandbox/rick/opt/kernel/instructions/RequiresDirective.hpp =================================================================== --- sandbox/rick/opt/kernel/instructions/RequiresDirective.hpp 2008-02-14 00:39:59 UTC (rev 2359) +++ sandbox/rick/opt/kernel/instructions/RequiresDirective.hpp 2008-02-15 00:49:06 UTC (rev 2360) @@ -65,8 +65,6 @@ protected: RexxString *name; // the name of the directive - RexxCode *resolvedTarget; // the anchor for the resolved package - }; #endif Modified: sandbox/rick/opt/kernel/kernel.mak =================================================================== --- sandbox/rick/opt/kernel/kernel.mak 2008-02-14 00:39:59 UTC (rev 2359) +++ sandbox/rick/opt/kernel/kernel.mak 2008-02-15 00:49:06 UTC (rev 2360) @@ -90,7 +90,7 @@ $(OR_OUTDIR)\ProcedureInstruction.$(OBJ) OTIOBJ8=$(OR_OUTDIR)\QueueInstruction.$(OBJ) $(OR_OUTDIR)\RaiseInstruction.$(OBJ) $(OR_OUTDIR)\RexxDirective.$(OBJ) \ - $(OR_OUTDIR)\RequiresDirective.$(OBJ) $(OR_OUTDIR)\PackageDirective.$(OBJ) $(OR_OUTDIR)\ClassDirective.$(OBJ) + $(OR_OUTDIR)\RequiresDirective.$(OBJ) $(OR_OUTDIR)\LibraryDirective.$(OBJ) $(OR_OUTDIR)\ClassDirective.$(OBJ) OTIOBJ9=$(OR_OUTDIR)\ReplyInstruction.$(OBJ) $(OR_OUTDIR)\ReturnInstruction.$(OBJ) $(OR_OUTDIR)\SayInstruction.$(OBJ) \ $(OR_OUTDIR)\SelectInstruction.$(OBJ) OTIOBJ10=$(OR_OUTDIR)\SignalInstruction.$(OBJ) $(OR_OUTDIR)\ThenInstruction.$(OBJ) $(OR_OUTDIR)\TraceInstruction.$(OBJ) \ @@ -118,7 +118,8 @@ OKPOBJ1=$(OR_OUTDIR)\RexxEnvelope.$(OBJ) $(OR_OUTDIR)\ArrayClass.$(OBJ) $(OR_OUTDIR)\RexxMisc.$(OBJ) \ $(OR_OUTDIR)\ClassClass.$(OBJ) $(OR_OUTDIR)\DeadObject.$(OBJ) $(OR_OUTDIR)\PointerClass.$(OBJ) \ $(OR_OUTDIR)\WeakReferenceClass.$(OBJ) -OKPOBJ2=$(OR_OUTDIR)\DirectoryClass.$(OBJ) $(OR_OUTDIR)\MethodClass.$(OBJ) $(OR_OUTDIR)\RoutineClass.$(OBJ) +OKPOBJ2=$(OR_OUTDIR)\DirectoryClass.$(OBJ) $(OR_OUTDIR)\MethodClass.$(OBJ) $(OR_OUTDIR)\RoutineClass.$(OBJ) \ + $(OR_OUTDIR)\PackageClass.$(OBJ) OKPOBJ3=$(OR_OUTDIR)\ListClass.$(OBJ) $(OR_OUTDIR)\RexxMemory.$(OBJ) $(OR_OUTDIR)\MemorySegment.$(OBJ) \ $(OR_OUTDIR)\MemoryStats.$(OBJ) $(OR_OUTDIR)\MessageClass.$(OBJ) \ $(OR_OUTDIR)\StemClass.$(OBJ) $(OR_OUTDIR)\ObjectClass.$(OBJ) $(OR_OUTDIR)\RexxCompoundTail.$(OBJ) \ @@ -135,7 +136,7 @@ $(OR_OUTDIR)\MessageDispatcher.$(OBJ) OKIOBJ2=$(OR_OUTDIR)\RexxHashTable.$(OBJ) $(OR_OUTDIR)\RexxCode.$(OBJ) $(OR_OUTDIR)\PackageManager.$(OBJ) \ $(OR_OUTDIR)\RexxListTable.$(OBJ) $(OR_OUTDIR)\RexxNativeActivation.$(OBJ) $(OR_OUTDIR)\RexxNativeCode.$(OBJ) \ - $(OR_OUTDIR)\CPPCode.$(OBJ) + $(OR_OUTDIR)\CPPCode.$(OBJ) $(OR_OUTDIR)\LibraryPackage.$(OBJ) OKIOBJ3=$(OR_OUTDIR)\RexxCollection.$(OBJ) $(OR_OUTDIR)\RexxSmartBuffer.$(OBJ) $(OR_OUTDIR)\StackClass.$(OBJ) \ $(OR_OUTDIR)\RexxVariable.$(OBJ) $(OR_OUTDIR)\RexxVariableDictionary.$(OBJ) $(OR_OUTDIR)\RexxDateTime.$(OBJ) \ $(OR_OUTDIR)\Numerics.$(OBJ) $(OR_OUTDIR)\CallContextStubs.$(OBJ) $(OR_OUTDIR)\InterpreterAPI.$(OBJ) \ Modified: sandbox/rick/opt/kernel/messages/rexxmsg.xml =================================================================== --- sandbox/rick/opt/kernel/messages/rexxmsg.xml 2008-02-14 00:39:59 UTC (rev 2359) +++ sandbox/rick/opt/kernel/messages/rexxmsg.xml 2008-02-15 00:49:06 UTC (rev 2360) @@ -4636,8 +4636,8 @@ <MessageNumber>696</MessageNumber> <Component>Rexx</Component> <Severity>Warning</Severity> - <SymbolicName>Error_Execution_package</SymbolicName> - <Text>Unable to load package <q><Sub position="1" name="name"/></q></Text> + <SymbolicName>Error_Execution_library</SymbolicName> + <Text>Unable to load library <q><Sub position="1" name="name"/></q></Text> </SubMessage> <SubMessage> <Code>98</Code> @@ -4645,8 +4645,8 @@ <MessageNumber>697</MessageNumber> <Component>Rexx</Component> <Severity>Warning</Severity> - <SymbolicName>Error_Execution_package_method</SymbolicName> - <Text>Unable to load method <q><Sub position="1" name="name"/></q> from package <q><Sub position="1" name="package"/></q></Text> + <SymbolicName>Error_Execution_library_method</SymbolicName> + <Text>Unable to load method <q><Sub position="1" name="name"/></q> from library <q><Sub position="1" name="library"/></q></Text> </SubMessage> <SubMessage> <Code>98</Code> @@ -4654,8 +4654,8 @@ <MessageNumber>698</MessageNumber> <Component>Rexx</Component> <Severity>Warning</Severity> - <SymbolicName>Error_Execution_package_routine</SymbolicName> - <Text>Unable to load routine <q><Sub position="1" name="name"/></q> from package <q><Sub position="1" name="package"/></q></Text> + <SymbolicName>Error_Execution_library_routine</SymbolicName> + <Text>Unable to load routine <q><Sub position="1" name="name"/></q> from library <q><Sub position="1" name="library"/></q></Text> </SubMessage> <SubMessage> <Code>98</Code> Modified: sandbox/rick/opt/kernel/parser/SourceFile.cpp =================================================================== --- sandbox/rick/opt/kernel/parser/SourceFile.cpp 2008-02-14 00:39:59 UTC (rev 2359) +++ sandbox/rick/opt/kernel/parser/SourceFile.cpp 2008-02-15 00:49:06 UTC (rev 2360) @@ -5465,3 +5465,71 @@ /* create a new function item */ return (RexxObject *)new (count) RexxExpressionLogical(this, count, this->subTerms); } + + +/** + * Load a ::REQUIRES directive when the source file is first + * invoked. + * + * @param target The name of the ::REQUIRES + * @param instruction + * The directive instruction being processed. + */ +PackageClass *RexxSource::loadRequired(RexxString *target) +{ + // get a fully resolved name for this....we might locate this under either name, but the + // fully resolved name is generated from this source file context. + RexxString *fullName = resolveProgramName(target); + + ProtectedObject p; + PackageClass *requiresFile = PackageManager::getRequires(ActivityManager::currentActivity, target, fullName, p); + + if (requiresFile == OREF_NULL) /* couldn't create this? */ + { + /* report an error */ + reportException(Error_Routine_not_found_requires, target); + } + // add this to the source context + addPackage(requiresFile); + + return requiresFile; +} + + +/** + * Add a package to a source file context. This allows new + * packages to be imported into a source. + * + * @param p + */ +void RexxSource::addPackage(PackageClass *p) +{ + // we only add a given package item once. + if (loadedPackages->hasItem(p) == TheTrueObject) + { + return; + } + + // add this to the list and merge the information + loadedPackages->append(p); + // not merge all of the info from the imported package + mergeRequired(requiresFile->getSourceObject()); +} + + +/** + * Retrieve the package wrapper associated with this source. + * + * @return The package instance that fronts for this source in Rexx code. + */ +PackageClass *RexxSource::getPackages() +{ + if (package == OREF_NULL) + { + OrefSet(this, this->package, new Package(this)); + } + return package; +} + + + Copied: sandbox/rick/opt/kernel/runtime/LibraryPackage.cpp (from rev 2352, sandbox/rick/opt/kernel/runtime/Package.cpp) =================================================================== --- sandbox/rick/opt/kernel/runtime/LibraryPackage.cpp (rev 0) +++ sandbox/rick/opt/kernel/runtime/LibraryPackage.cpp 2008-02-15 00:49:06 UTC (rev 2360) @@ -0,0 +1,471 @@ +/*----------------------------------------------------------------------------*/ +/* */ +/* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */ +/* Copyright (c) 2005-2006 Rexx Language Association. All rights reserved. */ +/* */ +/* This program and the accompanying materials are made available under */ +/* the terms of the Common Public License v1.0 which accompanies this */ +/* distribution. A copy is also available at the following address: */ +/* http://www.ibm.com/developerworks/oss/CPLv1.0.htm */ +/* */ +/* Redistribution and use in source and binary forms, with or */ +/* without modification, are permitted provided that the following */ +/* conditions are met: */ +/* */ +/* Redistributions of source code must retain the above copyright */ +/* notice, this list of conditions and the following disclaimer. */ +/* Redistributions in binary form must reproduce the above copyright */ +/* notice, this list of conditions and the following disclaimer in */ +/* the documentation and/or other materials provided with the distribution. */ +/* */ +/* Neither the name of Rexx Language Association nor the names */ +/* of its contributors may be used to endorse or promote products */ +/* derived from this software without specific prior written permission. */ +/* */ +/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ +/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ +/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */ +/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ +/* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ +/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */ +/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */ +/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */ +/* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */ +/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */ +/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/* */ +/*----------------------------------------------------------------------------*/ +/******************************************************************************/ +/* REXX Kernel */ +/* */ +/* Primitive LibraryPackage management */ +/* */ +/******************************************************************************/ + +#include "RexxCore.h" +#include "LibraryPackage.hpp" +#include "PackageManager.hpp" +#include "Interpreter.hpp" +#include "RexxNativeCode.hpp" + + +/** + * Create a new LibraryPackage object instance. + * + * @param size Size of the object. + * + * @return Pointer to new object storage. + */ +void *LibraryPackage::operator new(size_t size) +{ + return new_object(size, T_LibraryPackage); +} + + +/** + * Constructor for a loaded package. + * + * @param n Name of the library associated with this package. This is + * also the name used to load the library when requested. + */ +LibraryPackage::LibraryPackage(RexxString *n) +{ + ClearObject(this); + OrefSet(this, libraryName, n); +} + +/** + * Constructor for a loaded package. + * + * @param n Name of the library associated with this package. This is + * also the name used to load the library when requested. + * @param m The package manager that orchestrates the loading operations. + * @param p The packag table attached to this package name. + */ +LibraryPackage::LibraryPackage(RexxString *n, RexxPackageEntry *p) +{ + ClearObject(this); + OrefSet(this, libraryName, n); + // this is an internal package. + internal = true; + loadPackage(p); +} + +/** + * Normal live marking. + */ +void LibraryPackage::live(size_t liveMark) +{ + memory_mark(libraryName); + memory_mark(functions); + memory_mark(methods); +} + +/** + * Generalized live marking. + */ +void LibraryPackage::liveGeneral() +{ + memory_mark_general(libraryName); + memory_mark_general(functions); + memory_mark_general(methods); +} + + +/** + * Perform the initial loading of a package. The loading + * process involves resolving the external library and + * attempting to resolve a Rexx package exporter routine + * in the library. If the library loads, but does not have + * the package exporter function, this is a classic library. + * + * If we do find a package exporter, then we can load all of + * the functions immediately. Method loads are deferred + * until the first request. + * + * @param manager The package manager we're attached to. + * + * @return True if we were able to load this as proper ooRexx package + * file, false if either step failed. We do not throw + * exceptions here, since these are usually loaded in the + * context of operations that return an error result instead + * of an exception. + */ +bool LibraryPackage::load() +{ + // try to load the package table. + RexxPackageEntry *table = getPackageTable(); + // if this is NULL, return false to the manager + if (table == NULL) + { + return false; + } + // call the loader to get the package tables and set them up. + loadPackage(table); + return true; +} + + + +/** + * Unload a package library. + */ +void LibraryPackage::unload() +{ + // the internal packages don't get unloaded + if (!loaded) + { + return; + } + + // call an unloader, if we have one. + if (unloader != NULL) + { + ActivityContext *context = currentActivity()->getActivityContext(); + // unload the package + unloader(context); + currentActivity()->releaseActivityContext(context); + } + lib.unload(); +} + + +/** + * Load a library and see if it is possible to retrieve + * a package entry from the library. + * + * @return A package table entry, if possible. A load failure or + * no package loading functions returns NULL. + */ +RexxPackageEntry *LibraryPackage::getPackageTable() +{ + // first try to load the libary + PACKAGE_LOADER loader; + // reset the library handle that was saved in the image. + lib.reset(); + + if (!lib.load(libraryName->getStringData())) + { + // we don't report an exception here. This may have + // just been a probe attempt to see if we're real. We'll + // leave the exception decisions up to the package manager. + return NULL; + } + + // we're loaded now, vs. just a package fronting a name. + loaded = true; + // the try to resolve a package getting structure + // resolve the function address + PFN entry = (PFN)lib.getProcedure("ooRexxGetPackage"); + if (entry == NULL) + { + // again, this is not an exception...this could just be + // a classic style function registration. + return NULL; + } + loader = (PACKAGE_LOADER)entry; + // call the loader to get the package tables and set them up. + return (*loader)(); +} + + +/** + * Load a package with a provided package definition. + * + * @param manager The package manager instance we're attached to. + * @param p The package table entry. + */ +void LibraryPackage::loadPackage(RexxPackageEntry *p) +{ + package = p; //NB: this is NOT an object, so OrefSet is not needed. + // load the function table + loadFunctions(package->functions); + + // call a loader, if we have one. + if (p->loader != NULL) + { + ActivityContext *context = currentActivity()->getActivityContext(); + // load the package + p->loader((RexxThreadContext *)context); + currentActivity()->releaseActivityContext(context); + } +} + + +/** + * Load all of the functions in a package, registering them + * with the package manager. + * + * @param manager The package manager we're associated with. + * @param table The package table describing this package. + */ +void LibraryPackage::loadFunctions(RexxRoutineEntry *table) +{ + // no functions exported by this package? Just return without + // doing anything. + if (table == NULL) + { + return; + } + + // create a directory of loaded functions. + OrefSet(this, functions, new_directory()); + + while (table->style != 0) + { + // table names tend to be specified in friendly form, we need to + // convert them to uppercase because "normal" Rexx function names + // tend to be uppercase. + RexxString *target = new_upper_string(table->name)->upper(); + + RexxRoutine *func = OREF_NULL; + if (table->style == FUNCTION_CLASSIC_STYLE) + { + func = new RegisteredRoutine(libraryName, table->name, (PREGISTEREDROUTINE)table->entryPoint); + } + else + { + func = new RexxNativeRoutine(libraryName, table->name, (PNATIVEROUTINE)table->entryPoint); + } + + + // add this to the global function pool + PackageManager::addPackageFunction(target, new_routine(func)); + // step to the next table entry + table++; + } +} + + + +/** + * Locate a named method entry from the package registration + * table. + * + * @param name The target name. + * + * @return The entry associated with the target entry, if it exists. + * NULL indicates a not found condition. + */ +RexxMethodEntry *LibraryPackage::locateMethodEntry(RexxString *name) +{ + ooRexxMethodEntry *entry = package->methods; + + // scan the exported method table for the required method + while (entry->style != 0) + { + // is this one a name match? Make a method, add it to + // the table, and return. + if (name->strICompare(entry->name)) + { + return entry; + } + entry++; + } + return NULL; +} + + +/** + * Locate a named function entry from the package registration + * table. + * + * @param name The target name. + * + * @return A pointer to the located function structure. Returns NULL + * if the package doesn't exist. + */ +RexxRoutineEntry *LibraryPackage::locateFunctionEntry(RexxString *name) +{ + RexxRoutineEntry *entry = package->functions; + + // scan the exported method table for the required method + while (entry->style != 0) + { + // is this one a name match? Make a method, add it to + // the table, and return. + if (name->strICompare((stringchar_t *)entry->name)) + { + return entry; + } + entry++; + } + return NULL; +} + + +/** + * Get a NativeCode object for a method associated with a + * package. + * + * @param name Name of the target method. + * + * @return A RexxNativeCode object for this method, if located. + */ +RexxNativeMethod *LibraryPackage::resolveMethod(RexxString *name) +{ + // create our methods table if not yet created. + if (methods == OREF_NULL) + { + OrefSet(this, methods, new_directory()); + } + + // see if this is in the table yet. + RexxNativeMethod *code = (RexxNativeMethod *)methods->at(name); + if (code == OREF_NULL) + { + // find the package definition + RexxMethodEntry *entry = locateMethodEntry(name); + // if we found one with this name, create a native method out of it. + if (entry != NULL) + { + code = new RexxNativeMethod(libraryName, name, (PNATIVEMETHOD)entry->entryPoint); + methods->put((RexxObject *)code, name); + return code; + } + // This, we know from nothing.... + return OREF_NULL; + } + // had this cached already. + return code; +} + + +/** + * Resolve an entry point for a package method entry (used on a + * restore or reflatten); + * + * @param name Name of the target method. + * + * @return The target entry point. + */ +PNATIVEMETHOD LibraryPackage::resolveMethodEntry(RexxString *name) +{ + // find the package definition + RexxMethodEntry *entry = locateMethodEntry(name); + // if no entry, something bad has gone wrong + if (entry == NULL) + { + reportException(Error_Execution_library_method, name, libraryName); + } + return (PNATIVEMETHOD)entry->entryPoint; +} + + +/** + * Resolve an entry point for a package function entry (used on + * a restore or reflatten); + * + * @param name Name of the target function. + * + * @return The target entry point. + */ +PNATIVEROUTINE LibraryPackage::resolveFunctionEntry(RexxString *name) +{ + // find the package definition + RexxMethodEntry *entry = locateFunctionEntry(name); + // if no entry, something bad has gone wrong + if (entry == NULL) + { + reportException(Error_Execution_library_routine, name, libraryName); + } + + // style mismatch...this is incompatible + if (entry->style == FUNCTION_CLASSIC_STYLE) + { + reportException(Error_Execution_library_routine, name, libraryName); + } + return (PNATIVEROUTINE)entry->entryPoint; +} + + +/** + * Resolve an entry point for a package function entry (used on + * a restore or reflatten); + * + * @param name Name of the target function. + * + * @return The target entry point. + */ +PREGISTEREDROUTINE LibraryPackage::resolveRegisteredRoutineEntry(RexxString *name) +{ + // find the package definition + RexxMethodEntry *entry = locateFunctionEntry(name); + // if no entry, something bad has gone wrong + if (entry == NULL) + { + reportException(Error_Execution_library_routine, name, libraryName); + } + + // style mismatch...this is incompatible + if (entry->style != FUNCTION_CLASSIC_STYLE) + { + reportException(Error_Execution_library_routine, name, libraryName); + } + return (PREGISTEREDROUTINE)entry->entryPoint; +} + + +/** + * Refresh a non-internal package after an image restore. + */ +void LibraryPackage::reload() +{ + package = getPackageTable(); + if (package == OREF_NULL) + { + logic_error("Failure loading required base library"); + } +} + + +/** + * Refresh an internal package after an image restore. + * + * @param pack The internal package entry. + */ +void LibraryPackage::reload(RexxPackageEntry *pack) +{ + package = pack; +} + Copied: sandbox/rick/opt/kernel/runtime/LibraryPackage.hpp (from rev 2354, sandbox/rick/opt/kernel/runtime/Package.hpp) =================================================================== --- sandbox/rick/opt/kernel/runtime/LibraryPackage.hpp (rev 0) +++ sandbox/rick/opt/kernel/runtime/LibraryPackage.hpp 2008-02-15 00:49:06 UTC (rev 2360) @@ -0,0 +1,98 @@ +/*----------------------------------------------------------------------------*/ +/* */ +/* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */ +/* Copyright (c) 2005-2006 Rexx Language Association. All rights reserved. */ +/* */ +/* This program and the accompanying materials are made available under */ +/* the terms of the Common Public License v1.0 which accompanies this */ +/* distribution. A copy is also available at the following address: */ +/* http://www.ibm.com/developerworks/oss/CPLv1.0.htm */ +/* */ +/* Redistribution and use in source and binary forms, with or */ +/* without modification, are permitted provided that the following */ +/* conditions are met: */ +/* */ +/* Redistributions of source code must retain the above copyright */ +/* notice, this list of conditions and the following disclaimer. */ +/* Redistributions in binary form must reproduce the above copyright */ +/* notice, this list of conditions and the following disclaimer in */ +/* the documentation and/or other materials provided with the distribution. */ +/* */ +/* Neither the name of Rexx Language Association nor the names */ +/* of its contributors may be used to endorse or promote products */ +/* derived from this software without specific prior written permission. */ +/* */ +/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ +/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ +/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */ +/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ +/* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ +/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */ +/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */ +/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */ +/* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */ +/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */ +/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/* */ +/*----------------------------------------------------------------------------*/ +/******************************************************************************/ +/* REXX Kernel */ +/* */ +/* Primitive Rexx function/method package */ +/* */ +/******************************************************************************/ +#ifndef LibraryPackage_Included +#define LibraryPackage_Included + +#include "RexxCore.h" +#include "SysLibrary.hpp" +#include "RexxNativeCode.hpp" + +class PackageManager; +class RexxNativeMethod; + +typedef RexxPackageEntry * (RexxEntry *PACKAGE_LOADER)(); + +class LibraryPackage : public RexxInternalObject +{ +public: + inline void *operator new(size_t, void *ptr) {return ptr;} + inline void operator delete(void *, void *) {;} + void *operator new(size_t); + inline void operator delete(void *) {;} + + LibraryPackage(RexxString *n); + LibraryPackage(RexxString *n, RexxPackageEntry *p); + inline LibraryPackage(RESTORETYPE restoreType) { ; }; + + void live(size_t liveMark); + void liveGeneral(int reason); + bool load(); + void unload(); + RexxPackageEntry *getPackageTable(); + void loadPackage(RexxPackageEntry *p); + void loadFunctions(RexxRoutineEntry *table); + RexxMethodEntry *locateMethodEntry(RexxString *name); + RexxRoutineEntry *locateFunctionEntry(RexxString *name); + RexxNativeMethod *resolveMethod(RexxString *name); + PNATIVEMETHOD resolveMethodEntry(RexxString *name); + PNATIVEROUTINE resolveRoutineEntry(RexxString *name); + PREGISTEREDROUTINE resolveRegisteredRoutineEntry(RexxString *name); + void reload(); + void reload(RexxPackageEntry *pack); + inline bool isLoaded() { return loaded; } + inline bool isInternal() { return internal; } + +protected: + + RexxPackageEntry *package; // loaded package information + RexxString *libraryName; // the name of the library + RexxDirectory *functions; // loaded functions + RexxDirectory *methods; // loaded functions + SysLibrary lib; // the library management handle + bool loaded; // we've at least been able to load the library + bool internal; // this is an internal package...no library load required. +}; + +#endif + Deleted: sandbox/rick/opt/kernel/runtime/Package.cpp =================================================================== --- sandbox/rick/opt/kernel/runtime/Package.cpp 2008-02-14 00:39:59 UTC (rev 2359) +++ sandbox/rick/opt/kernel/runtime/Package.cpp 2008-02-15 00:49:06 UTC (rev 2360) @@ -1,471 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* */ -/* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */ -/* Copyright (c) 2005-2006 Rexx Language Association. All rights reserved. */ -/* */ -/* This program and the accompanying materials are made available under */ -/* the terms of the Common Public License v1.0 which accompanies this */ -/* distribution. A copy is also available at the following address: */ -/* http://www.ibm.com/developerworks/oss/CPLv1.0.htm */ -/* */ -/* Redistribution and use in source and binary forms, with or */ -/* without modification, are permitted provided that the following */ -/* conditions are met: */ -/* */ -/* Redistributions of source code must retain the above copyright */ -/* notice, this list of conditions and the following disclaimer. */ -/* Redistributions in binary form must reproduce the above copyright */ -/* notice, this list of conditions and the following disclaimer in */ -/* the documentation and/or other materials provided with the distribution. */ -/* */ -/* Neither the name of Rexx Language Association nor the names */ -/* of its contributors may be used to endorse or promote products */ -/* derived from this software without specific prior written permission. */ -/* */ -/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ -/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ -/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */ -/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ -/* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ -/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */ -/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */ -/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */ -/* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */ -/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */ -/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* */ -/*----------------------------------------------------------------------------*/ -/******************************************************************************/ -/* REXX Kernel */ -/* */ -/* Primitive Package management */ -/* */ -/******************************************************************************/ - -#include "RexxCore.h" -#include "Package.hpp" -#include "PackageManager.hpp" -#include "Interpreter.hpp" -#include "RexxNativeCode.hpp" - - -/** - * Create a new Package object instance. - * - * @param size Size of the object. - * - * @return Pointer to new object storage. - */ -void *Package::operator new(size_t size) -{ - return new_object(size, T_Package); -} - - -/** - * Constructor for a loaded package. - * - * @param n Name of the library associated with this package. This is - * also the name used to load the library when requested. - */ -Package::Package(RexxString *n) -{ - ClearObject(this); - OrefSet(this, libraryName, n); -} - -/** - * Constructor for a loaded package. - * - * @param n Name of the library associated with this package. This is - * also the name used to load the library when requested. - * @param m The package manager that orchestrates the loading operations. - * @param p The packag table attached to this package name. - */ -Package::Package(RexxString *n, RexxPackageEntry *p) -{ - ClearObject(this); - OrefSet(this, libraryName, n); - // this is an internal package. - internal = true; - loadPackage(p); -} - -/** - * Normal live marking. - */ -void Package::live(size_t liveMark) -{ - memory_mark(libraryName); - memory_mark(functions); - memory_mark(methods); -} - -/** - * Generalized live marking. - */ -void Package::liveGeneral() -{ - memory_mark_general(libraryName); - memory_mark_general(functions); - memory_mark_general(methods); -} - - -/** - * Perform the initial loading of a package. The loading - * process involves resolving the external library and - * attempting to resolve a Rexx package exporter routine - * in the library. If the library loads, but does not have - * the package exporter function, this is a classic library. - * - * If we do find a package exporter, then we can load all of - * the functions immediately. Method loads are deferred - * until the first request. - * - * @param manager The package manager we're attached to. - * - * @return True if we were able to load this as proper ooRexx package - * file, false if either step failed. We do not throw - * exceptions here, since these are usually loaded in the - * context of operations that return an error result instead - * of an exception. - */ -bool Package::load() -{ - // try to load the package table. - RexxPackageEntry *table = getPackageTable(); - // if this is NULL, return false to the manager - if (table == NULL) - { - return false; - } - // call the loader to get the package tables and set them up. - loadPackage(table); - return true; -} - - - -/** - * Unload a package library. - */ -void Package::unload() -{ - // the internal packages don't get unloaded - if (!loaded) - { - return; - } - - // call an unloader, if we have one. - if (unloader != NULL) - { - ActivityContext *context = currentActivity()->getActivityContext(); - // unload the package - unloader(context); - currentActivity()->releaseActivityContext(context); - } - lib.unload(); -} - - -/** - * Load a library and see if it is possible to retrieve - * a package entry from the library. - * - * @return A package table entry, if possible. A load failure or - * no package loading functions returns NULL. - */ -RexxPackageEntry *Package::getPackageTable() -{ - // first try to load the libary - PACKAGE_LOADER loader; - // reset the library handle that was saved in the image. - lib.reset(); - - if (!lib.load(libraryName->getStringData())) - { - // we don't report an exception here. This may have - // just been a probe attempt to see if we're real. We'll - // leave the exception decisions up to the package manager. - return NULL; - } - - // we're loaded now, vs. just a package fronting a name. - loaded = true; - // the try to resolve a package getting structure - // resolve the function address - PFN entry = (PFN)lib.getProcedure("ooRexxGetPackage"); - if (entry == NULL) - { - // again, this is not an exception...this could just be - // a classic style function registration. - return NULL; - } - loader = (PACKAGE_LOADER)entry; - // call the loader to get the package tables and set them up. - return (*loader)(); -} - - -/** - * Load a package with a provided package definition. - * - * @param manager The package manager instance we're attached to. - * @param p The package table entry. - */ -void Package::loadPackage(RexxPackageEntry *p) -{ - package = p; //NB: this is NOT an object, so OrefSet is not needed. - // load the function table - loadFunctions(package->functions); - - // call a loader, if we have one. - if (p->loader != NULL) - { - ActivityContext *context = currentActivity()->getActivityContext(); - // load the package - p->loader((RexxThreadContext *)context); - currentActivity()->releaseActivityContext(context); - } -} - - -/** - * Load all of the functions in a package, registering them - * with the package manager. - * - * @param manager The package manager we're associated with. - * @param table The package table describing this package. - */ -void Package::loadFunctions(RexxRoutineEntry *table) -{ - // no functions exported by this package? Just return without - // doing anything. - if (table == NULL) - { - return; - } - - // create a directory of loaded functions. - OrefSet(this, functions, new_directory()); - - while (table->style != 0) - { - // table names tend to be specified in friendly form, we need to - // convert them to uppercase because "normal" Rexx function names - // tend to be uppercase. - RexxString *target = new_upper_string(table->name)->upper(); - - RexxRoutine *func = OREF_NULL; - if (table->style == FUNCTION_CLASSIC_STYLE) - { - func = new RegisteredRoutine(libraryName, table->name, (PREGISTEREDROUTINE)table->entryPoint); - } - else - { - func = new RexxNativeRoutine(libraryName, table->name, (PNATIVEROUTINE)table->entryPoint); - } - - - // add this to the global function pool - PackageManager::addPackageFunction(target, new_routine(func)); - // step to the next table entry - table++; - } -} - - - -/** - * Locate a named method entry from the package registration - * table. - * - * @param name The target name. - * - * @return The entry associated with the target entry, if it exists. - * NULL indicates a not found condition. - */ -RexxMethodEntry *Package::locateMethodEntry(RexxString *name) -{ - ooRexxMethodEntry *entry = package->methods; - - // scan the exported method table for the required method - while (entry->style != 0) - { - // is this one a name match? Make a method, add it to - // the table, and return. - if (name->strICompare(entry->name)) - { - return entry; - } - entry++; - } - return NULL; -} - - -/** - * Locate a named function entry from the package registration - * table. - * - * @param name The target name. - * - * @return A pointer to the located function structure. Returns NULL - * if the package doesn't exist. - */ -RexxRoutineEntry *Package::locateFunctionEntry(RexxString *name) -{ - RexxRoutineEntry *entry = package->functions; - - // scan the exported method table for the required method - while (entry->style != 0) - { - // is this one a name match? Make a method, add it to - // the table, and return. - if (name->strICompare((stringchar_t *)entry->name)) - { - return entry; - } - entry++; - } - return NULL; -} - - -/** - * Get a NativeCode object for a method associated with a - * package. - * - * @param name Name of the target method. - * - * @return A RexxNativeCode object for this method, if located. - */ -RexxNativeMethod *Package::resolveMethod(RexxString *name) -{ - // create our methods table if not yet created. - if (methods == OREF_NULL) - { - OrefSet(this, methods, new_directory()); - } - - // see if this is in the table yet. - RexxNativeMethod *code = (RexxNativeMethod *)methods->at(name); - if (code == OREF_NULL) - { - // find the package definition - RexxMethodEntry *entry = locateMethodEntry(name); - // if we found one with this name, create a native method out of it. - if (entry != NULL) - { - code = new RexxNativeMethod(libraryName, name, (PNATIVEMETHOD)entry->entryPoint); - methods->put((RexxObject *)code, name); - return code; - } - // This, we know from nothing.... - return OREF_NULL; - } - // had this cached already. - return code; -} - - -/** - * Resolve an entry point for a package method entry (used on a - * restore or reflatten); - * - * @param name Name of the target method. - * - * @return The target entry point. - */ -PNATIVEMETHOD Package::resolveMethodEntry(RexxString *name) -{ - // find the package definition - RexxMethodEntry *entry = locateMethodEntry(name); - // if no entry, something bad has gone wrong - if (entry == NULL) - { - reportException(Error_Execution_package_method, name, libraryName); - } - return (PNATIVEMETHOD)entry->entryPoint; -} - - -/** - * Resolve an entry point for a package function entry (used on - * a restore or reflatten); - * - * @param name Name of the target function. - * - * @return The target entry point. - */ -PNATIVEROUTINE Package::resolveFunctionEntry(RexxString *name) -{ - // find the package definition - RexxMethodEntry *entry = locateFunctionEntry(name); - // if no entry, something bad has gone wrong - if (entry == NULL) - { - reportException(Error_Execution_package_routine, name, libraryName); - } - - // style mismatch...this is incompatible - if (entry->style == FUNCTION_CLASSIC_STYLE) - { - reportException(Error_Execution_package_routine, name, libraryName); - } - return (PNATIVEROUTINE)entry->entryPoint; -} - - -/** - * Resolve an entry point for a package function entry (used on - * a restore or reflatten); - * - * @param name Name of the target function. - * - * @return The target entry point. - */ -PREGISTEREDROUTINE Package::resolveRegisteredRoutineEntry(RexxString *name) -{ - // find the package definition - RexxMethodEntry *entry = locateFunctionEntry(name); - // if no entry, something bad has gone wrong - if (entry == NULL) - { - reportException(Error_Execution_package_routine, name, libraryName); - } - - // style mismatch...this is incompatible - if (entry->style != FUNCTION_CLASSIC_STYLE) - { - reportException(Error_Execution_package_routine, name, libraryName); - } - return (PREGISTEREDROUTINE)entry->entryPoint; -} - - -/** - * Refresh a non-internal package after an image restore. - */ -void Package::reload() -{ - package = getPackageTable(); - if (package == OREF_NULL) - { - logic_error("Failure loading required base library"); - } -} - - -/** - * Refresh an internal package after an image restore. - * - * @param pack The internal package entry. - */ -void Package::reload(RexxPackageEntry *pack) -{ - package = pack; -} - Deleted: sandbox/rick/opt/kernel/runtime/Package.hpp =================================================================== --- sandbox/rick/opt/kernel/runtime/Package.hpp 2008-02-14 00:39:59 UTC (rev 2359) +++ sandbox/rick/opt/kernel/runtime/Package.hpp 2008-02-15 00:49:06 UTC (rev 2360) @@ -1,100 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* */ -/* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */ -/* Copyright (c) 2005-2006 Rexx Language Association. All rights reserved. */ -/* */ -/* This program and the accompanying materials are made available under */ -/* the terms of the Common Public License v1.0 which accompanies this */ -/* distribution. A copy is also available at the following address: */ -/* http://www.ibm.com/developerworks/oss/CPLv1.0.htm */ -/* */ -/* Redistribution and use in source and binary forms, with or */ -/* without modification, are permitted provided that the following */ -/* conditions are met: */ -/* */ -/* Redistributions of source code must retain the above copyright */ -/* notice, this list of conditions and the following disclaimer. */ -/* Redistributions in binary form must reproduce the above copyright */ -/* notice, this list of conditions and the following disclaimer in */ -/* the documentation and/or other materials provided with the distribution. */ -/* */ -/* Neither the name of Rexx Language Association nor the names */ -/* of its contributors may be used to endorse or promote products */ -/* derived from this software without specific prior written permission. */ -/* */ -/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ -/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ -/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */ -/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ -/* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ -/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */ -/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */ -/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */ -/* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */ -/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */ -/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* */ -/*----------------------------------------------------------------------------*/ -/******************************************************************************/ -/* REXX Kernel */ -/* */ -/* Primitive Rexx function/method package */ -/* */ -/******************************************************************************/ -#ifndef Package_Included -#define Package_Included - -#include "RexxCore.h" -#include "SysLibrary.hpp" -#include "RexxNativeCode.hpp" - -class PackageManager; -class RexxNativeMethod; - -typedef RexxPackageEntry * (RexxEntry *PACKAGE_LOADER)(); - -class Package : public RexxInternalObject -{ -public: - inline void *operator new(size_t, void *ptr) {return ptr;} - inline void operator delete(void *, void *) {;} - void *operator new(size_t); - inline void operator delete(void *) {;} - - Package(RexxString *n); - Package(RexxString *n, RexxPackageEntry *p); - inline Package(RESTORETYPE restoreType) { ; }; - - void live(size_t liveMark); - void liveGeneral(int reason); - bool load(); - void unload(); - RexxPackageEntry *getPackageTable(); - void loadPackage(RexxPackageEntry *p); - void loadFunctions(RexxRoutineEntry *table); - RexxMethodEntry *locateMethodEntry(RexxString *name); - RexxRoutineEntry *locateFunctionEntry(RexxString *name); - RexxNativeMethod *resolveMethod(RexxString *name); - PNATIVEMETHOD resolveMethodEntry(RexxString *name); - PNATIVEROUTINE resolveRoutineEntry(RexxString *name); - PREGISTEREDROUTINE resolveRegisteredRoutineEntry(RexxString *name); - void reload(); - void reload(RexxPackageEntry *pack); - inline bool isLoaded() { return loaded; } - inline bool isInternal() { return internal; } - inline bool isPackage() { return ispackage; } - -protected: - - RexxPackageEntry *package; // loaded package information - RexxString *libraryName; // the name of the library - RexxDirectory *functions; // loaded functions - RexxDirectory *methods; // loaded functions - SysLibrary lib; // the library management handle - bool ispackage; // this is a valid package vs. classic oldstyle - bool loaded; // we've at least been able to load the library - bool internal; // this is an internal package...no library load required. -}; - -#endif - Modified: sandbox/rick/opt/kernel/runtime/PackageManager.cpp =================================================================== --- sandbox/rick/opt/kernel/runtime/PackageManager.cpp 2008-02-14 00:39:59 UTC (rev 2359) +++ sandbox/rick/opt/kernel/runtime/PackageManager.cpp 2008-02-15 00:49:06 UTC (rev 2360) @@ -44,7 +44,7 @@ #include "RexxCore.h" #include "PackageManager.hpp" -#include "Package.hpp" +#include "LibraryPackage.hpp" #include "Interpreter.hpp" #include "RexxNativeCode.hpp" #include "DirectoryClass.hpp" @@ -109,7 +109,7 @@ for (HashLink i = packages->first(); packages->available(i); i = packages->next(i)) { // get the next package - Package *package = (Package *)packages->value(i); + LibraryPackage *package = (LibraryPackage *)packages->value(i); // not one of the internal packages, so reload. if (!package->isInternal()) { @@ -154,15 +154,15 @@ * @return A resolved package...throws an exception if the package * is not loadable. */ -Package *PackageManager::getPackage(RexxString *name) +LibraryPackage *PackageManager::getPackage(RexxString *name) { // have we already loaded this package? // may need to bootstrap it up first. - Package *package = loadPackage(name); + LibraryPackage *package = loadPackage(name); if (package == NULL) { // this is an error - reportException(Error_Execution_package, name); + reportException(Error_Execution_library, name); } return package; } @@ -170,21 +170,21 @@ /** * Attempt to load a library without raising an error. Returns - * a Package object for the library if the load was successful. + * a LibraryPackage object for the library if the load was successful. * * @param name The target library name. * - * @return A Package object for the library, or OREF_NULL if was + * @return A LibraryPackage object for the library, or OREF_NULL if was * not resolvable. */ -Package *PackageManager::loadPackage(RexxString *name) +LibraryPackage *PackageManager::loadPackage(RexxString *name) { // have we already loaded this package? // may need to bootstrap it up first. - Package *package = (Package *)packages->at(name); + LibraryPackage *package = (LibraryPackage *)packages->at(name); if (package == NULL) { - package = new Package(name); + package = new LibraryPackage(name); // add this to our package list. packages->put((RexxObject *)packages, name); // now force the package to load. @@ -214,7 +214,7 @@ { // have we already loaded this package? // may need to bootstrap it up first. - Package *package = getPackage(packageName); + LibraryPackage *package = getPackage(packageName); // now see if this can be resolved. RexxNativeMethod *code = package->resolveMethod(methodName); @@ -349,7 +349,7 @@ void PackageManager::loadInternalPackage(RexxString *name, RexxPackageEntry *p) { // load up the package and add it to our cache - Package *package = new Package(name, p); + LibraryPackage *package = new LibraryPackage(name, p); // have we already loaded this package? packages->put(packages, name); } @@ -397,7 +397,7 @@ } // see if this package is resolveable/loadable. - Package *package = loadPackage(module); + LibraryPackage *package = loadPackage(module); if (package == OREF_NULL) { // See if this is resolvable in this context. If we got it, @@ -464,7 +464,7 @@ for (HashLink i = packages->first(); packages->available(i); i = packages->next(i)) { // get the next package - Package *package = (Package *)packages->value(i); + LibraryPackage *package = (LibraryPackage *)packages->value(i); // not one of the internal packages, so reload. if (!package->isInternal()) { @@ -706,12 +706,12 @@ */ PNATIVEMETHOD PackageManager::resolveMethodEntry(RexxString *packageName, RexxString *name) { - Package *package = loadPackage(packageName); + LibraryPackage *package = loadPackage(packageName); // if no entry, something bad has gone wrong if (package == NULL) { - reportException(Error_Execution_package_method, name, packageName); + reportException(Error_Execution_library_method, name, packageName); } return package->resolveMethodEntry(name); } @@ -727,12 +727,12 @@ */ PNATIVEROUTINE PackageManager::resolveRoutineEntry(RexxString *packageName, RexxString *name) { - Package *package = loadPackage(packageName); + LibraryPackage *package = loadPackage(packageName); // if no entry, something bad has gone wrong if (package == NULL) { - reportException(Error_Execution_package_method, name, packageName); + reportException(Error_Execution_library_method, name, packageName); } return package->resolveRoutineEntry(name); } @@ -760,18 +760,18 @@ // this is a failure if (entry == NULL) { - reportException(Error_Execution_package_routine, name); + reportException(Error_Execution_library_routine, name); } return (PREGISTEREDROUTINE)entry; } else { - Package *package = loadPackage(packageName); + LibraryPackage *package = loadPackage(packageName); // if no entry, something bad has gone wrong if (package == NULL) { - reportException(Error_Execution_package_routine, name, packageName); + reportException(Error_Execution_library_routine, name, packageName); } return package->resolveRegisteredRoutineEntry(name); } Modified: sandbox/rick/opt/kernel/runtime/PackageManager.hpp =================================================================== --- sandbox/rick/opt/kernel/runtime/PackageManager.hpp 2008-02-14 00:39:59 UTC (rev 2359) +++ sandbox/rick/opt/kernel/runtime/PackageManager.hpp 2008-02-15 00:49:06 UTC (rev 2360) @@ -45,7 +45,7 @@ #define PackageManager_Included #include "RexxCore.h" -#include "Package.hpp" +#include "LibraryPackage.hpp" class BaseCode; class RoutineClass; @@ -63,8 +63,8 @@ static void initialize(); static RexxArray *getImageData(); static void restore(RexxArray *imageArray); - static Package *getPackage(RexxString *name); - static Package *loadPackage(RexxString *name); + static LibraryPackage *getPackage(RexxString *name); + static LibraryPackage *loadPackage(RexxString *name); static void unload(); static RexxNativeMethod *resolveMethod(RexxString *packageName, RexxString *methodName); static RoutineClass *resolveRoutine(RexxString *function, RexxString *packageName, RexxString *procedure); Modified: sandbox/rick/opt/kernel/runtime/PrimitiveClasses.xml =================================================================== --- sandbox/rick/opt/kernel/runtime/PrimitiveClasses.xml 2008-02-14 00:39:59 UTC (rev 2359) +++ sandbox/rick/opt/kernel/runtime/PrimitiveClasses.xml 2008-02-15 00:49:06 UTC (rev 2360) @@ -55,11 +55,13 @@ <Class id="Buffer" class="RexxBuffer" include="BufferClass.hpp"/> <Class id="WeakReference" class="WeakReference" include="WeakReferenceClass.hpp"/> <Class id="Routine" class="RoutineClass" include="RoutineClass.hpp"/> +<Class id="Package" class="PackageClass" include="PackageClass.hpp"/> </Exported> <Internal> <Class id="NilObject" class="RexxNilObject" include="ObjectClass.hpp"/> <Class id="Behaviour" class="RexxBehaviour" include="RexxBehaviour.hpp"/> <Class id="RexxSource" class="RexxSource" include="SourceFile.hpp"/> +<Class id="LibraryPackage" class="LibraryPackage" include="LibraryPackage.hpp"/> <Class id="RexxCode" class="RexxCode" include="RexxCode.hpp"/> <Class id="NativeMethod" class="RexxNativeMethod" include="RexxNativeCode.hpp"/> <Class id="NativeRoutine" class="RexxNativeRoutine" include="RexxNativeCode.hpp"/> @@ -123,6 +125,10 @@ <Class id="TraceInstruction" class="RexxInstructionTrace" include="TraceInstruction.hpp"/> <Class id="UseInstruction" class="RexxInstructionUseStrict" include="UseStrictInstruction.hpp"/> +<Class id="ClassDirective" class="ClassDirective" include="ClassDirective"/> +<Class id="LibraryDirective" class="LibraryDirective" include="LibraryDirective"/> +<Class id="RequiresDirective" class="RequiresDirective" include="RequiresDirective"/> + <Class id="CompoundElement" class="RexxCompoundElement" include="RexxCompoundElement.hpp"/> <Class id="ParseTrigger" class="RexxTrigger" include="ParseTrigger.hpp"/> </Internal> Modified: sandbox/rick/opt/kernel/runtime/RexxActivation.cpp =================================================================== --- sandbox/rick/opt/kernel/runtime/RexxActivation.cpp 2008-02-14 00:39:59 UTC (rev 2359) +++ sandbox/rick/opt/kernel/runtime/RexxActivation.cpp 2008-02-15 00:49:06 UTC (rev 2360) @@ -2296,21 +2296,9 @@ { // this will cause the correct location to be used for error reporting this->current = instruction; - // get a fully resolved name for this....we might locate this under either name - RexxString *fullName = resolveProgramName(target); - ProtectedObject p; - RoutineClass *requiresFile = PackageManager::getRequires(activity, target, fullName, p); - - if (requiresFile == OREF_NULL) /* couldn't create this? */ - { - /* report an error */ - reportException(Error_Routine_not_found_requires, target); - } - /* now merge all of the info */ - this->settings.parent_code->mergeRequired(requiresFile->getSourceObject()); - - return requiresFile; + // the loading/merging is done by the source object + return getSourceObject()->loadRequired(target); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bigrixx@us...> - 2008-02-17 20:32:04
|
Revision: 2363 http://oorexx.svn.sourceforge.net/oorexx/?rev=2363&view=rev Author: bigrixx Date: 2008-02-17 12:32:08 -0800 (Sun, 17 Feb 2008) Log Message: ----------- incremental checkin Modified Paths: -------------- sandbox/rick/opt/kernel/instructions/ClassDirective.cpp sandbox/rick/opt/kernel/instructions/ClassDirective.hpp sandbox/rick/opt/kernel/instructions/LibraryDirective.cpp sandbox/rick/opt/kernel/instructions/LibraryDirective.hpp sandbox/rick/opt/kernel/instructions/RequiresDirective.cpp sandbox/rick/opt/kernel/instructions/RequiresDirective.hpp sandbox/rick/opt/kernel/parser/SourceFile.cpp sandbox/rick/opt/kernel/parser/SourceFile.hpp sandbox/rick/opt/kernel/runtime/PackageManager.cpp sandbox/rick/opt/kernel/runtime/PackageManager.hpp sandbox/rick/opt/kernel/runtime/RexxActivation.cpp sandbox/rick/opt/kernel/runtime/RexxActivation.hpp Modified: sandbox/rick/opt/kernel/instructions/ClassDirective.cpp =================================================================== --- sandbox/rick/opt/kernel/instructions/ClassDirective.cpp 2008-02-17 01:04:48 UTC (rev 2362) +++ sandbox/rick/opt/kernel/instructions/ClassDirective.cpp 2008-02-17 20:32:08 UTC (rev 2363) @@ -52,11 +52,13 @@ * Construct a ClassDirective. * * @param n The name of the requires target. + * @param p The public name of the requires target. * @param clause The source file clause containing the directive. */ -ClassDirective::ClassDirective(RexxString *n, RexxClause *clause) : RexxDirective(clause, KEYWORD_CLASS) +ClassDirective::ClassDirective(RexxString *n, RexxString *p, RexxClause *clause) : RexxDirective(clause, KEYWORD_CLASS) { name = n; + publicName = p; } /** @@ -71,6 +73,7 @@ memory_mark(this->idName); memory_mark(this->metaclassName); memory_mark(this->subclassName); + memory_mark(this->dependencies); } @@ -86,6 +89,7 @@ memory_mark_general(this->idName); memory_mark_general(this->metaclassName); memory_mark_general(this->subclassName); + memory_mark_general(this->dependencies); } @@ -103,6 +107,9 @@ flatten_reference(newThis->idName, envelope); flatten_reference(newThis->metaclassName, envelope); flatten_reference(newThis->subclassName, envelope); + // by this time, we should be finished with this, and it should + // already be null. Make sure this is the case. + newThis->dependencies = OREF_NULL; cleanUpFlatten } @@ -196,3 +203,136 @@ classObject->defineMethods(instanceMethods); } } + + +/** + * Check if a dependency this class has is based off of a + * class co-located in the same class package. + * + * @param name The class name. + * @param class_directives + * The global local classes list. + */ +void ClassDireective::checkDepdendency(RexxString *name, RexxDirectory *class_directives) +{ + if (name != OREF_NULL) + { + // if this is in install? */ + if (class_dependencies->entry(name) != OREF_NULL) + { + if (dependencies == OREF_NULL) + { + OrefSet(this, this->dependencies, new_directory()); + } + /* add to our pending list */ + dependencies->setEntry(name, name); + } + } +} + + +/** + * Check our class dependencies against the locally defined class + * list to develop a cross dependency list. + * + * @param class_directives + * The global set of defined classes in this package. + */ +void ClassDirective::addDependencies(RexxDirectory *class_directives) +{ + // When the class was created, a dependency directory was added as a marker to + // prevent duplicate classes from getting created. We now + RexxDirectory *dependencies = (RexxDirectory *)(class_dependencies->fastAt(publicName)); + + // now for each of our dependent classes, if this is defined locally, we + // an entry to our dependency list to aid the class ordering + + checkDependency(metaClassName, class_directives); + checkDependency(subclassName, class_directives); + // process each inherits item the same way + if (inherits != OREF_NULL) + { + for (size_t i = 1; i <= inherits->size(); i++) + { + checkDependency((RexxString *)(inherits->get(i))); + } + } +} + + +/** + * Check if this class has any additional in-package dependencies. + * + * @return true if all in-package dependencies have been resolved already. + */ +bool ClassDirective::dependenciesResolved() +{ + return dependencies == OREF_NULL; +} + + +/** + * Remove a class from the dependency list. + * + * @param name The name of the class that's next in the ordering. + */ +void ClassDirective::removeDependency(RexxString *name) +{ + // if we have a dependency list, remove this name from the + // list. If this is our last dependency item, we can junk + // the list entirely. + if (dependencies != OREF_NULL) + { + dependencies->remove(name); + if (dependencies->items() == 0) + { + OrefSet(this, this->dependencies, OREF_NULL); + } + } +} + + +/** + * Add an inherits class to the class definition. + * + * @param name The name of the inherited class. + */ +void ClassDirective::addInherits(RexxString *name) +{ + if (inheritsClasses == OREF_NULL) + { + OrefSet(this, this->inheritsClasses, new_list()); + } + inheritsClasses->append(name); +} + + +/** + * Retrieve the class methods directory for this class. + * + * @return The class methods directory. + */ +RexxDirectory *ClassDirective::getClassMethods() +{ + if (classMethods == OREF_NULL) + { + OrefSet(this, this->classMethods, new_directory()); + } + return classMethods; +} + + +/** + * Retrieve the instance methods directory for this class. + * + * @return The instance methods directory. + */ +RexxDirectory *ClassDirective::getClassMethods() +{ + if (instanceMethods == OREF_NULL) + { + OrefSet(this, this->instanceMethods, new_directory()); + } + return instanceMethods; +} + Modified: sandbox/rick/opt/kernel/instructions/ClassDirective.hpp =================================================================== --- sandbox/rick/opt/kernel/instructions/ClassDirective.hpp 2008-02-17 01:04:48 UTC (rev 2362) +++ sandbox/rick/opt/kernel/instructions/ClassDirective.hpp 2008-02-17 20:32:08 UTC (rev 2363) @@ -46,6 +46,8 @@ #include "RexxDirective.hpp" +class RexxDirectory; + class ClassDirective : public RexxDirective { friend class RexxSource; @@ -63,18 +65,32 @@ void flatten(RexxEnvelope *); inline RexxString *getName() { return publicName; } + void install(RexxSource *source, RexxActivation *activation); + void addDependencies(RexxDirectory *class_directives); + void checkDepdendency(RexxString *name, RexxDirectory *class_directives); + bool dependenciesResolved(); + void removeDependency(RexxString *name); + + inline RexxString *getMetaClass() { return metaClassName; } + inline void setMetaClass(RexxString *m) { OrefSet(this, this->metaClassName, m); } + inline RexxString *getSubClass() { return subclassName; } + inline void setSubClass(RexxString *m) { OrefSet(this, this->subclassName, m); } + inline void setMixinClass(RexxString *m) { OrefSet(this, this->subclassName, m); mixinClass = true; } + inline void setPublic() { publicClass = true; } + void addInherits(RexxString *name); + protected: RexxString *publicName; // the published name of the class RexxString *idName; // the internal ID name RexxString *metaClassName; // name of the class meta class RexxString *subclassName; // the class used for the subclassing operation. - RexxArray *inheritsClasses; // the names of inherited classes - RexxTable *instanceMethods; // the methods attached to this class - RexxTable *classMethods; // the set of class methods + RexxList *inheritsClasses; // the names of inherited classes + RexxDirectory *instanceMethods; // the methods attached to this class + RexxDirectory *classMethods; // the set of class methods bool publicClass; // this is a public class bool mixinClass; // this is a mixin class - + RexxDirectory *dependencies; // in-package dependencies }; #endif Modified: sandbox/rick/opt/kernel/instructions/LibraryDirective.cpp =================================================================== --- sandbox/rick/opt/kernel/instructions/LibraryDirective.cpp 2008-02-17 01:04:48 UTC (rev 2362) +++ sandbox/rick/opt/kernel/instructions/LibraryDirective.cpp 2008-02-17 20:32:08 UTC (rev 2363) @@ -121,6 +121,6 @@ */ void LibraryDirective::install(RexxActivation *context) { - context->resolvePackage(name, this); + context->loadLibrary(name, this); } Modified: sandbox/rick/opt/kernel/instructions/LibraryDirective.hpp =================================================================== --- sandbox/rick/opt/kernel/instructions/LibraryDirective.hpp 2008-02-17 01:04:48 UTC (rev 2362) +++ sandbox/rick/opt/kernel/instructions/LibraryDirective.hpp 2008-02-17 20:32:08 UTC (rev 2363) @@ -62,6 +62,7 @@ void flatten(RexxEnvelope *); inline RexxString *getName() { return name; } + void install(RexxActivation *context); protected: RexxString *name; // the name of the directive Modified: sandbox/rick/opt/kernel/instructions/RequiresDirective.cpp =================================================================== --- sandbox/rick/opt/kernel/instructions/RequiresDirective.cpp 2008-02-17 01:04:48 UTC (rev 2362) +++ sandbox/rick/opt/kernel/instructions/RequiresDirective.cpp 2008-02-17 20:32:08 UTC (rev 2363) @@ -118,7 +118,7 @@ * * @param activation The activation we're running under for the install. */ -PackageClass *RequiresDirective::install(RexxActivation *context) +void RequiresDirective::install(RexxActivation *context) { - return context->loadRequired(name, this); + context->loadRequired(name, this); } Modified: sandbox/rick/opt/kernel/instructions/RequiresDirective.hpp =================================================================== --- sandbox/rick/opt/kernel/instructions/RequiresDirective.hpp 2008-02-17 01:04:48 UTC (rev 2362) +++ sandbox/rick/opt/kernel/instructions/RequiresDirective.hpp 2008-02-17 20:32:08 UTC (rev 2363) @@ -62,6 +62,7 @@ void flatten(RexxEnvelope *); inline RexxString *getName() { return name; } + void install(RexxActivation *context); protected: RexxString *name; // the name of the directive Modified: sandbox/rick/opt/kernel/parser/SourceFile.cpp =================================================================== --- sandbox/rick/opt/kernel/parser/SourceFile.cpp 2008-02-17 01:04:48 UTC (rev 2362) +++ sandbox/rick/opt/kernel/parser/SourceFile.cpp 2008-02-17 20:32:08 UTC (rev 2363) @@ -80,6 +80,11 @@ #include "ProtectedObject.hpp" #include "CPPCode.hpp" #include "SystemInterpreter.hpp" +#include "PackageClass.hpp" +#include "InterpreterInstance.hpp" +#include "ClassDirective.hpp" +#include "LibraryDirective.hpp" +#include "RequiresDirective.hpp" #define HOLDSIZE 60 /* room for 60 temporaries */ @@ -488,7 +493,6 @@ memory_mark(this->libraries); memory_mark(this->loadedPackages); memory_mark(this->package); - memory_mark(this->nativeCode); memory_mark(this->classes); memory_mark(this->installed_public_classes); memory_mark(this->installed_classes); @@ -516,7 +520,6 @@ OrefSet(this, this->classes, OREF_NULL); OrefSet(this, this->routines, OREF_NULL); OrefSet(this, this->libraries, OREF_NULL); - OrefSet(this, this->nativeCode, OREF_NULL); OrefSet(this, this->installed_classes, OREF_NULL); OrefSet(this, this->installed_public_classes, OREF_NULL); OrefSet(this, this->merged_public_classes, OREF_NULL); @@ -557,7 +560,6 @@ memory_mark_general(this->libraries); memory_mark_general(this->loadedPackages); memory_mark_general(this->package); - memory_mark_general(this->nativeCode); memory_mark_general(this->classes); memory_mark_general(this->installed_public_classes); memory_mark_general(this->installed_classes); @@ -615,7 +617,6 @@ flatten_reference(newThis->libraries, envelope); flatten_reference(newThis->loadedPackages, envelope); flatten_reference(newThis->package, envelope); - flatten_reference(newThis->nativeCode, envelope); flatten_reference(newThis->classes, envelope); flatten_reference(newThis->installed_public_classes, envelope); flatten_reference(newThis->installed_classes, envelope); @@ -927,13 +928,15 @@ else { /* get the line */ - source_line = this->get(location.getLineNumber()); + RexxString *source_line = this->get(location.getLineNumber()); /* extract the end portion */ source_line = source_line->extract(location.getOffset(), source_line->getLength() - location.getOffset()); source->put(source_line, 1); /* insert the trailing piece */ } + + size_t i; /* loop until the last line */ - for (counter = location.getLineNumber() + 1, i = 2; counter < location.getEndLine(); counter++, i++) + for (size_t counter = location.getLineNumber() + 1, i = 2; counter < location.getEndLine(); counter++, i++) { /* copy over the entire line */ source->put(this->get(counter), i); @@ -1142,97 +1145,102 @@ /* program into the full public information of this program. */ /******************************************************************************/ { - // has the source already merged in some public routines? pull those in first, - // so that the direct set will override - if (source_merge_public_routines != OREF_NULL) - { - /* first merged attempt? */ - if (this->merged_public_routines == OREF_NULL) + // has the source already merged in some public routines? pull those in first, + // so that the direct set will override + if (source->merged_public_routines != OREF_NULL) { - /* get the directory */ - OrefSet(this, this->merged_public_routines, new_directory()); + /* first merged attempt? */ + if (this->merged_public_routines == OREF_NULL) + { + /* get the directory */ + OrefSet(this, this->merged_public_routines, new_directory()); + } + /* loop through the list of routines */ + for (size_t i = source->merged_public_routines->first(); source->merged_public_routines->available(i); i = source->merged_public_routines->next(i)) + { + /* copy the routine over */ + this->merged_public_routines->setEntry((RexxString *)source->merged_public_routines->index(i), source->merged_public_routines->value(i)); + } + } - /* loop through the list of routines */ - for (size_t i = source->merged_public_routines->first(); source->merged_public_routines->available(i); i = source->merged_public_routines->next(i)) - { - /* copy the routine over */ - this->merged_public_routines->setEntry((RexxString *)source->merged_public_routines->index(i), source->merged_public_routines->value(i)); - } - } - - // now process the direct set - if (source->public_routines != OREF_NULL) - { - /* first merged attempt? */ - if (this->merged_public_routines == OREF_NULL) + // now process the direct set + if (source->public_routines != OREF_NULL) { - /* get the directory */ - OrefSet(this, this->merged_public_routines, new_directory()); + /* first merged attempt? */ + if (this->merged_public_routines == OREF_NULL) + { + /* get the directory */ + OrefSet(this, this->merged_public_routines, new_directory()); + } + /* loop through the list of routines */ + for (size_t i = source->public_routines->first(); source->public_routines->available(i); i = source->public_routines->next(i)) + { + /* copy the routine over */ + this->merged_public_routines->setEntry((RexxString *)source->public_routines->index(i), source->public_routines->value(i)); + } } - /* loop through the list of routines */ - for (size_t i = source->public_routines->first(); source->public_routines->available(i); i = source->public_routines->next(i)) - { - /* copy the routine over */ - this->merged_public_routines->setEntry((RexxString *)source->public_routines->index(i), source->public_routines->value(i)); - } - } - // now do the same process for any of the class contexts - if (source->merged_public_classes != OREF_NULL) - { - if (this->merged_public_classes == OREF_NULL) - { - /* get the directory */ - OrefSet(this, this->merged_public_classes, new_directory()); - } - /* loop through the list of classes, */ - for (i = source->merged_public_classes->first(); source->merged_public_classes->available(i); i = source->merged_public_classes->next(i)) - { - /* copy the routine over */ - this->merged_public_classes->setEntry((RexxString *)source->merged_public_classes->index(i), source->merged_public_classes->value(i)); - } - } + // now do the same process for any of the class contexts + if (source->merged_public_classes != OREF_NULL) + { + if (this->merged_public_classes == OREF_NULL) + { + /* get the directory */ + OrefSet(this, this->merged_public_classes, new_directory()); + } + /* loop through the list of classes, */ + for (size_t i = source->merged_public_classes->first(); source->merged_public_classes->available(i); i = source->merged_public_classes->next(i)) + { + /* copy the routine over */ + this->merged_public_classes->setEntry((RexxString *)source->merged_public_classes->index(i), source->merged_public_classes->value(i)); + } + } - if (source->merged_public_classes != OREF_NULL) - { - if (this->merged_public_classes == OREF_NULL) - { - /* get the directory */ - OrefSet(this, this->merged_public_classes, new_directory()); - } - /* loop through the list of classes, */ - for (i = source->installed_public_classes->first(); source->merged_public_classes->available(i); i = source->merged_public_classes->next(i)) - { - /* copy the routine over */ - this->merged_public_classes->setEntry((RexxString *)source->merged_public_classes->index(i), source->merged_public_classes->value(i)); - } - } + if (source->merged_public_classes != OREF_NULL) + { + if (this->merged_public_classes == OREF_NULL) + { + /* get the directory */ + OrefSet(this, this->merged_public_classes, new_directory()); + } + /* loop through the list of classes, */ + for (size_t i = source->installed_public_classes->first(); source->merged_public_classes->available(i); i = source->merged_public_classes->next(i)) + { + /* copy the routine over */ + this->merged_public_classes->setEntry((RexxString *)source->merged_public_classes->index(i), source->merged_public_classes->value(i)); + } + } - /* have classes also? */ - if (source->installed_public_classes != OREF_NULL || source->merged_public_classes != OREF_NULL) { - /* first merged attempt? */ - if (this->merged_public_classes == OREF_NULL) - /* get the directory */ - OrefSet(this, this->merged_public_classes, new_directory()); - /* do the merged classes first */ - if (source->merged_public_classes != OREF_NULL) { - /* loop through the list of classes, */ - for (i = source->merged_public_classes->first(); source->merged_public_classes->available(i); i = source->merged_public_classes->next(i)) { - /* copy the routine over */ - this->merged_public_classes->setEntry((RexxString *)source->merged_public_classes->index(i), source->merged_public_classes->value(i)); - } + /* have classes also? */ + if (source->installed_public_classes != OREF_NULL || source->merged_public_classes != OREF_NULL) + { + /* first merged attempt? */ + if (this->merged_public_classes == OREF_NULL) + /* get the directory */ + OrefSet(this, this->merged_public_classes, new_directory()); + /* do the merged classes first */ + if (source->merged_public_classes != OREF_NULL) + { + /* loop through the list of classes, */ + for (size_t i = source->merged_public_classes->first(); source->merged_public_classes->available(i); i = source->merged_public_classes->next(i)) + { + /* copy the routine over */ + this->merged_public_classes->setEntry((RexxString *)source->merged_public_classes->index(i), source->merged_public_classes->value(i)); + } + } + /* have public classes? */ + if (source->installed_public_classes != OREF_NULL) + { + /* loop through the list of classes, */ + for (size_t i = source->installed_public_classes->first(); source->installed_public_classes->available(i); i = source->installed_public_classes->next(i)) + { + /* copy the routine over */ + this->merged_public_classes->setEntry((RexxString *)source->installed_public_classes->index(i), source->installed_public_classes->value(i)); + } + } } - /* have public classes? */ - if (source->installed_public_classes != OREF_NULL) { - /* loop through the list of classes, */ - for (i = source->installed_public_classes->first(); source->installed_public_classes->available(i); i = source->installed_public_classes->next(i)) { - /* copy the routine over */ - this->merged_public_classes->setEntry((RexxString *)source->installed_public_classes->index(i), source->installed_public_classes->value(i)); - } - } - } } @@ -1267,7 +1275,14 @@ } -RoutineClass *RoutineClass::resolvePublicRoutine(RexxString *name) +/** + * Resolve a public routine in this source context + * + * @param name The target name. + * + * @return A resolved Routine object, if found. + */ +RoutineClass *RexxSource::resolvePublicRoutine(RexxString *name) { // if we have one locally, then return it. if (this->merged_public_routines != OREF_NULL) @@ -1301,14 +1316,14 @@ */ RoutineClass *RexxSource::resolveRoutine(RexxString *routineName) { - BaseCode *routineObject = resolveLocalRoutine(routineName); + RoutineClass *routineObject = resolveLocalRoutine(routineName); if (routineObject != OREF_NULL) { return routineObject; } // now try for one pulled in from ::REQUIRES objects - return resolvePublicRoutine(name); + return resolvePublicRoutine(routineName); } @@ -1325,7 +1340,7 @@ */ RexxString *RexxSource::resolveProgramName(RexxActivity *activity, RexxString *name) { - return activity->resolveProgram(name, programDirectory, programExtension); + return activity->getInstance()->resolveProgramName(name, programDirectory, programExtension); } @@ -1412,10 +1427,10 @@ // give the security manager a go if (this->securityManager != OREF_NULL) { - classObject = securityManager->checkLocalAccess(internalName); + classObject = (RexxClass *)securityManager->checkLocalAccess(internalName); if (classObject != OREF_NULL) { - return classObject); + return classObject; } } @@ -1423,16 +1438,16 @@ classObject = (RexxClass *)(ActivityManager::localEnvironment->at(internalName)); if (classObject != OREF_NULL) { - return classObject); + return classObject; } /* normal execution? */ if (this->securityManager != OREF_NULL) { - classObject = securityManager->checkEnvironmentAccess(internalName); + classObject = (RexxClass *)securityManager->checkEnvironmentAccess(internalName); if (classObject != OREF_NULL) { - return classObject); + return classObject; } } @@ -1449,156 +1464,58 @@ /* processing all ::routines. */ /******************************************************************************/ { - /* turn the install flag off */ - /* immediately, otherwise we may */ - /* run into a recursion problem */ - /* when class init methods are */ - /* processed */ - this->flags &= ~_install; /* we are now installed */ + /* turn the install flag off */ + /* immediately, otherwise we may */ + /* run into a recursion problem */ + /* when class init methods are */ + /* processed */ + this->flags &= ~_install; /* we are now installed */ - // native packages are processed first. The requires might actually need - // functons loaded by the packages - if (this->libraries != OREF_NULL) - { - /* classes and routines */ - size_t size = this->libraries->size(); /* get the number to install */ - // now loop through the requires items - for (i = 1; i <= size; i++) + // native packages are processed first. The requires might actually need + // functons loaded by the packages + if (this->libraries != OREF_NULL) { - // and have it do the installs processing - LibraryDirective *library = (LibraryDirective *)(this->libraries->get(i)); - library->install(activation); + /* classes and routines */ + // now loop through the requires items + for (size_t i = libraries->firstIndex(); i != LIST_END; i = libraries->nextIndex(i)) + { + // and have it do the installs processing + LibraryDirective *library = (LibraryDirective *)this->libraries->getValue(i); + library->install(activation); + } } - } - // native methods and routines are lazy resolved on first use, so we don't - // need to process them here. + // native methods and routines are lazy resolved on first use, so we don't + // need to process them here. - if (this->requires != OREF_NULL) /* need to process ::requires? */ - { - /* classes and routines */ - size_t size = this->requires->size(); /* get the number to install */ - // now loop through the requires items - for (i = 1; i <= size; i++) + if (this->requires != OREF_NULL) /* need to process ::requires? */ { - // and have it do the installs processing - RequiresDirective *requires = (RequiresDirective *)(this->requires->get(i)); - requires->install(activation); + /* classes and routines */ + // now loop through the requires items + for (size_t i = requires->firstIndex(); i != LIST_END; i = requires->nextIndex(i)) + { + // and have it do the installs processing. This is a little roundabout, but + // we end up back in our own context while processing this, and the merge + // of the information happens then. + RequiresDirective *requires = (RequiresDirective *)this->requires->getValue(i); + requires->install(activation); + } } - } - if (this->classes != OREF_NULL) /* have classes to process? */ - { - /* get an installed classes directory*/ - OrefSet(this, this->installed_classes, new_directory()); - /* and the public classes */ - OrefSet(this, this->installed_public_classes, new_directory()); - size = this->classes->size(); /* get the number of classes */ - for (i = 1; i <= size; i++) /* process each class */ + // and finally process classes + if (this->classes != OREF_NULL) { - /* get the class info */ - current_class = (RexxArray *)(this->classes->get(i)); - /* get the public (uppercase) name */ - name = (RexxString *)(current_class->get(CLASS_PUBLIC_NAME)); - /* get the public flag */ - Public = current_class->get(CLASS_PUBLIC); - /* get the mixingclass flag */ - mixin = current_class->get(CLASS_MIXINCLASS); - /* the metaclass */ - metaclass_name = (RexxString *)(current_class->get(CLASS_METACLASS)); - /* and subclass */ - subclass_name = (RexxString *)(current_class->get(CLASS_SUBCLASS_NAME)); - /* set the current line for errors */ - activation->setCurrent((RexxInstruction *)current_class->get(CLASS_DIRECTIVE)); - /* get the class id */ - class_id = (RexxString *)(current_class->get(CLASS_NAME)); - if (metaclass_name == OREF_NULL) /* no metaclass? */ - { - metaclass = OREF_NULL; /* flag this */ - } - else /* have a real metaclass */ - { - /* resolve the class */ - metaclass = this->resolveClass(metaclass_name, activation); - if (metaclass == OREF_NULL) /* nothing found? */ + /* get an installed classes directory*/ + OrefSet(this, this->installed_classes, new_directory()); + /* and the public classes */ + OrefSet(this, this->installed_public_classes, new_directory()); + for (size_t i = classes->firstIndex(); i != LIST_END; i = classes->nextIndex(i)) { - /* not found in environment, error! */ - reportException(Error_Execution_nometaclass, metaclass_name); + /* get the class info */ + ClassDirective *current_class = (ClassDirective *)this->classes->getValue(i); + current_class->install(this, activation); } - } - - if (subclass_name == OREF_NULL) /* no subclass? */ - { - /* flag this */ - subclass = (RexxClass *)TheNilObject; - } - else /* have a real subclass */ - { - /* resolve the class */ - subclass = this->resolveClass(subclass_name, activation); - if (subclass == OREF_NULL) /* nothing found? */ - { - /* not found in environment, error! */ - reportException(Error_Execution_noclass, subclass_name); - } - } - /* get the inherits information */ - inherits = (RexxArray *)(current_class->get(CLASS_INHERIT)); - /* instance methods */ - _instanceMethods = (RexxDirectory *)(current_class->get(CLASS_METHODS)); - /* and class methods */ - class_methods = (RexxDirectory *)(current_class->get(CLASS_CLASS_METHODS)); - if (subclass == TheNilObject) /* no subclass? */ - { - /* use .object for the subclass */ - subclass = (RexxClass *)TheEnvironment->fastAt(OREF_OBJECTSYM); - } - if (metaclass == TheNilObject) /* no metaclass? */ - { - metaclass = OREF_NULL; /* just null out */ - } - if (mixin != OREF_NULL) /* this a mixin class? */ - { - classObject = (RexxClass *)(subclass->mixinclass(class_id, metaclass, (RexxTable *)class_methods)); - } - else - { - /* doing a subclassing */ - classObject = (RexxClass *)(subclass->subclass(class_id, metaclass, (RexxTable *)class_methods)); - } - /* add the class to the directory */ - this->installed_classes->put(classObject, name); - if (inherits != OREF_NULL) /* have inherits to process? */ - { - /* establish remainder of inheritance*/ - for (j = 1; j <= inherits->size(); j++) - { - /* get the next inherits name */ - subclass_name = (RexxString *)(inherits->get(j)); - /* go resolve the entry */ - subclass = this->resolveClass(subclass_name, activation); - if (subclass == OREF_NULL) /* not found? */ - { - /* not found in environment, error! */ - reportException(Error_Execution_noclass, subclass_name); - } - /* do the actual inheritance */ - classObject->sendMessage(OREF_INHERIT, subclass); - } - } - if (_instanceMethods != OREF_NULL)/* have instance methods to add? */ - { - /* define them to the class object */ - classObject->defineMethods((RexxTable *)_instanceMethods); - } - /* make public if required */ - if (Public != OREF_NULL) /* need to make this public? */ - { - /* add to public directory */ - this->installed_public_classes->setEntry(name, classObject); - } } - } } RexxCode *RexxSource::translate( @@ -1609,7 +1526,7 @@ { /* go translate the lead block */ RexxCode *newMethod = this->translateBlock(_labels); - this->saveObject(newMethod); /* make this safe */ + this->saveObject((RexxObject *)newMethod); /* make this safe */ if (!this->atEnd()) /* have directives to process? */ { /* create the routines directory */ @@ -1619,9 +1536,9 @@ /* and a directory of dependencies */ OrefSet(this, this->class_dependencies, new_directory()); /* create the requires directory */ - OrefSet(this, this->requires, (RexxArray *)new_list()); + OrefSet(this, this->requires, new_list()); /* create the classes list */ - OrefSet(this, this->classes, (RexxArray *)new_list()); + OrefSet(this, this->classes, new_list()); /* no active class definition */ OrefSet(this, this->active_class, OREF_NULL); /* translation stopped by a directive*/ @@ -1638,16 +1555,12 @@ { this->directive(); /* process the directive */ } - /* have a class already active? */ - if (this->active_class != OREF_NULL) - { - this->completeClass(); /* finish off currently active one */ - } this->resolveDependencies(); /* go resolve class dependencies */ } return newMethod; /* return the method */ } + void RexxSource::resolveDependencies() /*********************************************************************/ /* Function: Resolve dependencies between ::CLASS directives, */ @@ -1658,160 +1571,101 @@ /* order */ /*********************************************************************/ { - RexxArray *class_order; /* class ordering array */ - RexxArray *current_class; /* current class definition */ - RexxDirectory *dependencies; /* dependencies list */ - RexxString *metaclass_name; /* name of the metaclass */ - RexxString *subclass_name; /* name of the subclass */ - RexxArray *inherits; /* set of inherits */ - RexxArray *next_install; /* next class to install */ - RexxString *class_name; /* name of the class */ - RexxArray *_classes; /* array of classes */ - size_t size; /* count of classes */ - size_t i; /* loop counter */ - size_t j; /* loop counter */ - size_t next_class; /* next class position */ - - /* first convert class list to array */ - _classes = ((RexxList *)(this->classes))->makeArray(); - /* and cast off the list */ - OrefSet(this, this->classes, _classes); - size = _classes->size(); /* get the array size */ - if (size == 0) /* nothing to process? */ - { - /* clear out the classes list */ - OrefSet(this, this->classes, OREF_NULL); - } - else { /* have classes to process */ - /* now traverse the classes array, */ - for (i = 1; i <= size; i++) { /* building up a dependencies list */ - /* get the next class */ - current_class = (RexxArray *)(_classes->get(i)); - /* get the dependencies */ - dependencies = (RexxDirectory *)(this->class_dependencies->fastAt((RexxString *)current_class->get(CLASS_PUBLIC_NAME))); - /* get the subclassing info */ - metaclass_name = (RexxString *)(current_class->get(CLASS_METACLASS)); - subclass_name = (RexxString *)(current_class->get(CLASS_SUBCLASS_NAME)); - inherits = (RexxArray *)(current_class->get(CLASS_INHERIT)); - /* have a metaclass? */ - if (metaclass_name != OREF_NULL) { - /* in our list to install? */ - if (this->class_dependencies->entry(metaclass_name) != OREF_NULL) - /* add to our pending list */ - dependencies->setEntry(metaclass_name, metaclass_name); - } - if (subclass_name != OREF_NULL) {/* have a subclass? */ - /* in our list to install? */ - if (this->class_dependencies->entry(subclass_name) != OREF_NULL) - /* add to our pending list */ - dependencies->setEntry(subclass_name, subclass_name); - } - if (inherits != OREF_NULL) { - /* process each inherits */ - for (j = 1; j <= inherits->size(); j++) { - /* get the next class name */ - subclass_name = (RexxString *)(inherits->get(j)); - /* in our list to install? */ - if (this->class_dependencies->entry(subclass_name) != OREF_NULL) - /* add to our pending list */ - dependencies->setEntry(subclass_name, subclass_name); - } - } + // get our class list + if (classes->items() == 0) /* nothing to process? */ + { + /* clear out the classes list */ + OrefSet(this, this->classes, OREF_NULL); } - class_order = new_array(size); /* get the ordering array */ + else /* have classes to process */ + { + // run through the class list having each directive set up its + // dependencies + for (size_t i = classes->firstIndex(); i != LIST_END; i = classes->nextIndex(i)) + { + /* get the next class */ + ClassDirective *current_class = (ClassDirective *)(classes->getValue(i)); + // have the class figure out it's in-package dependencies + current_class->addDependencies(class_dependencies); + } + RexxList *class_order = new_list(); // get a list for doing the order + ProtectedObject p(class_order); + /* now we repeatedly scan the pending directory looking for a class */ /* with no in-program dependencies - it's an error if there isn't one */ /* as we build the classes we have to remove them (their names) from */ /* pending list and from the remaining dependencies */ - next_class = 1; /* inserting at the beginning */ - while (next_class <= size) { /* while still more to process */ - next_install = OREF_NULL; /* nothing located yet */ - for (i = 1; i <= size; i++) { /* loop through the list */ - /* get the next class */ - current_class = (RexxArray *)(_classes->get(i)); - if (current_class == OREF_NULL)/* already processed? */ - continue; /* go do the next one */ - /* get the dependencies */ - dependencies = (RexxDirectory *)(this->class_dependencies->fastAt((RexxString *)current_class->get(CLASS_PUBLIC_NAME))); - /* no dependencies? */ - if (dependencies->items() == 0) { - next_install = current_class;/* get the next one */ - break; /* go process this one */ + while (classes->items() < 0) + { + // this is the next one we process + ClassDirective *next_install = OREF_NULL; + for (size_t i = classes->firstIndex(); i != LIST_END; i = classes->nextIndex(i)) + { + /* get the next class */ + ClassDirective *current_class = (ClassDirective *)(classes->getValue(i)); + // if this class doesn't have any additional dependencies, pick it next. + if (current_class->dependenciesResolved()) + { + next_install = current_class; + // add this to the class ordering + class_order->append((RexxObject *)next_install); + // remove this from the processing list + classes->removeIndex(i); + } + } + if (next_install == OREF_NULL) /* nothing located? */ + { + /* raise an error */ + syntaxError(Error_Execution_cyclic, this->programName); + } + RexxString *class_name = current_class->getName(); + + // now go through the pending list telling each of the remaining classes that + // they can remove this dependency from their list + for (size_t i _classes->firstIndex(); i != LIST_END; i = classes->nextIndex(i)) + { /* go remove the dependencies */ + /* get a class */ + ClassDirective *current_class = (ClassDirective *)(classes->getValue(i)); + current_class->removeDependency(class_name); + } } - } - if (next_install == OREF_NULL) /* nothing located? */ - /* raise an error */ - syntaxError(Error_Execution_cyclic, this->programName); - /* get the class name */ - class_name = (RexxString *)(current_class->get(CLASS_PUBLIC_NAME)); - for (j = 1; j <= size; j++) { /* go remove the dependencies */ - /* get a class */ - current_class = (RexxArray *)(_classes->get(j)); - /* not installed yet? */ - if (current_class != OREF_NULL) { - /* get the dependencies list */ - dependencies = (RexxDirectory *)(this->class_dependencies->fastAt((RexxString *)current_class->get(CLASS_PUBLIC_NAME))); - /* remove from the dependencies */ - dependencies->remove(class_name); - } - } - /* insert into the install order */ - class_order->put(next_install, next_class); - next_class++; /* and step the position */ - _classes->put(OREF_NULL, i); /* remove the installed one */ + + /* replace the original class list */ + OrefSet(this, this->classes, class_order); + /* don't need the dependencies now */ + OrefSet(this, this->class_dependencies, OREF_NULL); } - /* replace the original class list */ - OrefSet(this, this->classes, class_order); - /* don't need the dependencies now */ - OrefSet(this, this->class_dependencies, OREF_NULL); - } - /* convert requires list to an array */ - OrefSet(this, this->requires, this->requires->makeArray()); - if (this->requires->size() == 0) /* nothing there? */ - /* just clear it out */ - OrefSet(this, this->requires, OREF_NULL); - if (this->routines->items() == 0) /* no routines to process? */ - /* just clear it out also */ - OrefSet(this, this->routines, OREF_NULL); - /* now finally the public routines */ - if (this->public_routines->items() == 0) - /* just clear it out also */ - OrefSet(this, this->public_routines, OREF_NULL); - if (this->methods->items() == 0) /* and also the methods directory */ - /* just clear it out also */ - OrefSet(this, this->methods, OREF_NULL); -} -void RexxSource::completeClass() -/*********************************************************************/ -/* Function: complete create of the active class definition */ -/*********************************************************************/ -{ - RexxArray *inherits; /* the inherits information */ - RexxDirectory *classMethods; /* methods directory */ - - /* get the inherits list */ - inherits = (RexxArray *)(this->active_class->get(CLASS_INHERIT)); - if (inherits != OREF_NULL) { /* have an inherits list? */ - /* convert to an array */ - inherits = ((RexxList *)inherits)->makeArray(); - /* replace the original list */ - this->active_class->put(inherits, CLASS_INHERIT); - } - /* get the class methods */ - classMethods = (RexxDirectory *)(this->active_class->get(CLASS_METHODS)); - if (classMethods->items() == 0) /* have any methods? */ - /* through away the directory */ - this->active_class->put(OREF_NULL, CLASS_METHODS); - /* now repeat for class methods */ - classMethods = (RexxDirectory *)(this->active_class->get(CLASS_CLASS_METHODS)); - - if (classMethods->items() == 0) /* have any methods? */ - /* throw away the directory */ - this->active_class->put(OREF_NULL, CLASS_CLASS_METHODS); + if (this->requires->items() == 0) /* nothing there? */ + { + /* just clear it out */ + OrefSet(this, this->requires, OREF_NULL); + } + if (this->libraries->items() == 0) /* nothing there? */ + { + /* just clear it out */ + OrefSet(this, this->libraries, OREF_NULL); + } + if (this->routines->items() == 0) /* no routines to process? */ + { + /* just clear it out also */ + OrefSet(this, this->routines, OREF_NULL); + } + /* now finally the public routines */ + if (this->public_routines->items() == 0) + { + /* just clear it out also */ + OrefSet(this, this->public_routines, OREF_NULL); + } + if (this->methods->items() == 0) /* and also the methods directory */ + { + /* just clear it out also */ + OrefSet(this, this->methods, OREF_NULL); + } } + #define DEFAULT_GUARD 0 /* using defualt guarding */ #define GUARDED_METHOD 1 /* method is a guarded one */ #define UNGUARDED_METHOD 2 /* method is unguarded */ @@ -1830,14 +1684,9 @@ void RexxSource::classDirective() { RexxToken *token; /* current token under processing */ - /* have a class already active? */ - if (this->active_class != OREF_NULL) - { - this->completeClass(); /* go finish this up */ - } - token = nextReal(); /* get the next token */ - /* not a symbol or a string */ + RexxToken *token = nextReal(); /* get the next token */ + /* not a symbol or a string */ if (!token->isSymbolOrLiteral()) { /* report an error */ @@ -1853,23 +1702,15 @@ syntaxError(Error_Translation_duplicate_class); } /* create a dependencies list */ - this->class_dependencies->put(new_directory(), public_name); this->flags |= _install; /* have information to install */ - /* create the class definition */ - OrefSet(this, this->active_class, new_array(CLASS_INFO_SIZE)); - /* add this to the class table */ - ((RexxList *)(this->classes))->addLast(this->active_class); - /* add the name to the information */ - this->active_class->put(name, CLASS_NAME); - /* add the name to the information */ - this->active_class->put(public_name, CLASS_PUBLIC_NAME); - /* create the method table */ - this->active_class->put(new_directory(), CLASS_METHODS); - /* and the class method tabel */ - this->active_class->put(new_directory(), CLASS_CLASS_METHODS); - /* save the ::class location */ - this->active_class->put((RexxObject *)new RexxInstruction(this->clause, KEYWORD_CLASS), CLASS_DIRECTIVE); - int Public = DEFAULT_ACCESS_SCOPE; /* haven't seen the keyword yet */ + + // create a class directive and add this to the dependency list + OrefSet(this, this->active_class, new ClassDirective(name, public_name, this->clause)); + this->class_dependencies->put(active_class, public_name); + // and also add to the classes list + this->classes->append(this->active_class); + + int Public = DEFAULT_ACCESS_SCOPE; /* haven't seen the keyword yet */ bool subclass = false; /* no subclass keyword yet */ RexxString *metaclass = OREF_NULL; /* no metaclass yet */ for (;;) @@ -1877,11 +1718,15 @@ token = nextReal(); /* get the next token */ /* reached the end? */ if (token->isEndOfClause()) + { break; /* get out of here */ + } /* not a symbol token? */ else if (!token->isSymbol()) + { /* report an error */ syntaxError(Error_Invalid_subkeyword_class, token); + } else { /* have some sort of option keyword */ /* get the keyword type */ @@ -1891,16 +1736,19 @@ /* ::CLASS name METACLASS metaclass */ case SUBDIRECTIVE_METACLASS: /* already had a METACLASS? */ - if (metaclass != OREF_NULL) + if (active_class->getMetaClass() != OREF_NULL) + { syntaxError(Error_Invalid_subkeyword_class, token); + } token = nextReal(); /* get the next token */ /* not a symbol or a string */ if (!token->isSymbolOrLiteral()) + { /* report an error */ syntaxError(Error_Symbol_or_string_metaclass, token); - metaclass = token->value;/* external name is token value */ + } /* tag the active class */ - this->active_class->put(metaclass, CLASS_METACLASS); + this->active_class->setMetaClass(token->value); break; @@ -1925,53 +1773,59 @@ break; /* ::CLASS name SUBCLASS sclass */ case SUBDIRECTIVE_SUBCLASS: - if (subclass) /* already had one of these? */ + // If we have a subclass set already, this is an error + if (active_class->getSubClass() != OREF_NULL) + { /* duplicates are invalid */ syntaxError(Error_Invalid_subkeyword_class, token); - subclass = true; /* turn on the seen flag */ + } token = nextReal(); /* get the next token */ /* not a symbol or a string */ if (!token->isSymbolOrLiteral()) + { /* report an error */ syntaxError(Error_Symbol_or_string_subclass); + } /* set the subclass information */ - this->active_class->put(token->value, CLASS_SUBCLASS_NAME); + this->active_class->setSubClass(token->value); break; /* ::CLASS name MIXINCLASS mclass */ case SUBDIRECTIVE_MIXINCLASS: - if (subclass) /* already had one of these? */ + // If we have a subclass set already, this is an error + if (active_class->getSubClass() != OREF_NULL) + { /* duplicates are invalid */ syntaxError(Error_Invalid_subkeyword_class, token); - subclass = true; /* turn on the seen flag */ + } token = nextReal(); /* get the next token */ /* not a symbol or a string */ if (!token->isSymbolOrLiteral()) + { /* report an error */ syntaxError(Error_Symbol_or_string_mixinclass); + } /* set the subclass information */ - this->active_class->put(token->value, CLASS_SUBCLASS_NAME); - /* this a mixin? */ - if (type == SUBDIRECTIVE_MIXINCLASS) - /* just set this as a public object */ - this->active_class->put((RexxObject *)TheTrueObject, CLASS_MIXINCLASS); + this->active_class->setMixinClass(token->value); break; /* ::CLASS name INHERIT iclasses */ case SUBDIRECTIVE_INHERIT: token = nextReal(); /* get the next token */ /* nothing after the keyword? */ if (token->isEndOfClause()) + { /* report an error */ syntaxError(Error_Symbol_or_string_inherit, token); - /* add an inherits list */ - this->active_class->put(new_list(), CLASS_INHERIT); + } while (!token->isEndOfClause()) { /* not a symbol or a string */ if (!token->isSymbolOrLiteral()) + { /* report an error */ syntaxError(Error_Symbol_or_string_inherit, token); + } /* add to the inherit list */ - ((RexxList *)(this->active_class->get(CLASS_INHERIT)))->addLast(token->value); + this->active_class->addInherits(token->value); token = nextReal(); /* step to the next token */ } previousToken(); /* step back a token */ @@ -2159,6 +2013,7 @@ } } + RexxDirectory *methodsDir; /* no previous ::CLASS directive? */ if (this->active_class == OREF_NULL) @@ -2175,14 +2030,15 @@ if (Class) /* class method? */ { /* add to the class method list */ - methodsDir = ((RexxDirectory *)(this->active_class->get(CLASS_CLASS_METHODS))); + methodsDir = active_class->getClassMethods(); } else { /* add to the method list */ - methodsDir = ((RexxDirectory *)(this->active_class->get(CLASS_METHODS))); + methodsDir = active_class->getInstanceMethods(); } } + /* duplicate method name? */ if (methodsDir->entry(internalname) != OREF_NULL) { @@ -2438,12 +2294,12 @@ if (Class) /* class method? */ { /* add to the class method list */ - methodsDir = ((RexxDirectory *)(this->active_class->get(CLASS_CLASS_METHODS))); + methodsDir = active_class->getClassMethods(); } else { /* add to the method list */ - methodsDir = ((RexxDirectory *)(this->active_class->get(CLASS_METHODS))); + methodsDir = active_class->getInstanceMethods(); } } @@ -2575,8 +2431,8 @@ else { // we add methods to both directories - classesDir = ((RexxDirectory *)(this->active_class->get(CLASS_CLASS_METHODS))); - methodsDir = ((RexxDirectory *)(this->active_class->get(CLASS_METHODS))); + classesDir = active_class->getClassMethods(); + methodsDir = active_class->getInstanceMethods(); } // create the method pair and quit. createConstantGetterMethod(classesDir, methodsDir, internalname, value); @@ -2929,41 +2785,44 @@ /* report an error */ syntaxError(Error_Symbol_or_string_requires, token); } - this->flags |= _install; /* have information to install */ RexxString *name = token->value; /* get the requires name */ token = nextReal(); /* get the next token */ if (!token->isEndOfClause()) /* something appear after this? */ { - /* this is a syntax error */ - syntaxError(Error_Invalid_subkeyword_requires, token); + // this is potentially a library directive + libraryDirective(name, token); } + this->flags |= _install; /* have information to install */ /* save the ::requires location */ - ((RexxList *)(this->requires))->addLast((RexxObject *)new RequiresDirective(name, this->clause)); + this->requires->append((RexxObject *)new RequiresDirective(name, this->clause)); } /** * Process a ::REQUIRES name LIBRARY directive. */ -void RexxSource::libraryDirective() +void RexxSource::libraryDirective(RexxString *name, RexxToken *token) { - RexxToken *token = nextReal(); /* get the next token */ - /* not a symbol or a string */ - if (token->classId != TOKEN_SYMBOL && token->classId != TOKEN_LITERAL) + // we have an extra token on a ::REQUIRES directive. The only thing accepted here + // is the token LIBRARY. + if (!token->isSymbol()) { - /* report an error */ - reportTokenError(Error_Symbol_or_string_library, token); + syntaxError(Error_Invalid_subkeyword_requires, token); } - this->flags |= _install; /* have information to install */ - RexxString *name = token->value; /* get the requires name */ + /* process each sub keyword */ + if (subDirective(token) != SUBDIRECTIVE_LIBRARY) + { + syntaxError(Error_Invalid_subkeyword_requires, token); + } token = nextReal(); /* get the next token */ - if (token->classId != TOKEN_EOC) /* something appear after this? */ + if (!token->isEndOfClause()) /* something appear after this? */ { - /* this is a syntax error */ - reportTokenError(Error_Invalid_subkeyword_package, token); + // nothing else allowed after this + syntaxError(Error_Invalid_subkeyword_requires, token); } - // add this to the package list - ((RexxList *)(this->libraries))->addLast((RexxObject *)new LibraryDirective(name, this->clause)); + this->flags |= _install; /* have information to install */ + // add this to the library list + this->libraries->append((RexxObject *)new LibraryDirective(name, this->clause)); } Modified: sandbox/rick/opt/kernel/parser/SourceFile.hpp =================================================================== --- sandbox/rick/opt/kernel/parser/SourceFile.hpp 2008-02-17 01:04:48 UTC (rev 2362) +++ sandbox/rick/opt/kernel/parser/SourceFile.hpp 2008-02-17 20:32:08 UTC (rev 2363) @@ -61,6 +61,7 @@ class RoutineClass; class RexxCode; class PackageClass; +class ClassDirective; /* handy defines to easy coding */ #define new_instruction(name, type) this->sourceNewObject(sizeof(RexxInstruction##type), The##type##InstructionBehaviour, KEYWORD_##name) @@ -151,15 +152,19 @@ PackageClass *getPackage(); void inheritSourceContext(RexxSource *source); RoutineClass *resolveRoutine(RexxString *); + RoutineClass *resolveLocalRoutine(RexxString *); + RoutineClass *resolvePublicRoutine(RexxString *); RexxClass *resolveClass(RexxString *); + RexxClass *resolveInstalledClass(RexxString *name); + RexxClass *resolvePublicClass(RexxString *name); RexxString *resolveProgramName(RexxActivity *activity, RexxString *name); void processInstall(RexxActivation *); RexxCode *translate(RexxDirectory *); void resolveDependencies(); - void completeClass(); void directive(); void routineDirective(); void requiresDirective(); + void libraryDirective(RexxString *name, RexxToken *token); void methodDirective(); void classDirective(); void attributeDirective(); @@ -363,10 +368,9 @@ RexxSource *parentSource; // a parent source context environment; RexxDirectory *routines; /* routines found on directives */ RexxDirectory *public_routines; /* PUBLIC routines directive routines*/ - RexxArray *packages; // packages requiring loading - RexxArray *requires; /* requires directives */ - RexxArray *classes; /* classes found on directives */ - RexxArray *nativeCode; // native funtions/methods requiring resolution + RexxList *libraries; // packages requiring loading + RexxList *requires; /* requires directives */ + RexxList *classes; /* classes found on directives */ /* all public installed classes */ RexxDirectory *installed_public_classes; RexxDirectory *installed_classes; /* entire list of installed classes */ @@ -385,7 +389,7 @@ RexxQueue *subTerms; /* stack for arguments lists, et al. */ RexxQueue *operators; /* stack of expression terms */ RexxDirectory *class_dependencies; /* dependencies between classes */ - RexxArray *active_class; /* currently active ::CLASS directive*/ + ClassDirective *active_class; /* currently active ::CLASS directive*/ /* start of block parsing section */ Modified: sandbox/rick/opt/kernel/runtime/PackageManager.cpp =================================================================== --- sandbox/rick/opt/kernel/runtime/PackageManager.cpp 2008-02-17 01:04:48 UTC (rev 2362) +++ sandbox/rick/opt/kernel/runtime/PackageManager.cpp 2008-02-17 20:32:08 UTC (rev 2363) @@ -73,7 +73,7 @@ registeredRoutines = new_directory(); loadedRequires = new_directory(); - loadPackage(OREF_REXXUTIL); // load the rexxutil package automatically + loadLibrary(OREF_REXXUTIL); // load the rexxutil package automatically } @@ -155,11 +155,11 @@ * @return A resolved package...throws an exception if the package * is not loadable. */ -LibraryPackage *PackageManager::getPackage(RexxString *name) +LibraryPackage *PackageManager::getLibrary(RexxString *name) { // have we already loaded this package? // may need to bootstrap it up first. - LibraryPackage *package = loadPackage(name); + LibraryPackage *package = loadLibrary(name); if (package == NULL) { // this is an error @@ -178,7 +178,7 @@ * @return A LibraryPackage object for the library, or OREF_NULL if was * not resolvable. */ -LibraryPackage *PackageManager::loadPackage(RexxString *name) +LibraryPackage *PackageManager::loadLibrary(RexxString *name) { // have we already loaded this package? // may need to bootstrap it up first. @@ -215,7 +215,7 @@ { // have we already loaded this package? // may need to bootstrap it up first. - LibraryPackage *package = getPackage(packageName); + LibraryPackage *package = getLibrary(packageName); // now see if this can be resolved. RexxNativeMethod *code = package->resolveMethod(methodName); @@ -398,7 +398,7 @@ } // see if this package is resolveable/loadable. - LibraryPackage *package = loadPackage(module); + LibraryPackage *package = loadLibrary(module); if (package == OREF_NULL) { // See if this is resolvable in this context. If we got it, @@ -751,7 +751,7 @@ */ PNATIVEMETHOD PackageManager::resolveMethodEntry(RexxString *packageName, RexxString *name) { - LibraryPackage *package = loadPackage(packageName); + LibraryPackage *package = loadLibrary(packageName); // if no entry, something bad has gone wrong if (package == NULL) @@ -772,7 +772,7 @@ */ PNATIVEROUTINE PackageManager::resolveRoutineEntry(RexxString *packageName, RexxString *name) { - LibraryPackage *package = loadPackage(packageName); + LibraryPackage *package = loadLibrary(packageName); // if no entry, something bad has gone wrong if (package == NULL) @@ -811,7 +811,7 @@ } else { - LibraryPackage *package = loadPackage(packageName); + LibraryPackage *package = loadLibrary(packageName); // if no entry, something bad has gone wrong if (package == NULL) Modified: sandbox/rick/opt/kernel/runtime/PackageManager.hpp =================================================================== --- sandbox/rick/opt/kernel/runtime/PackageManager.hpp 2008-02-17 01:04:48 UTC (rev 2362) +++ sandbox/rick/opt/kernel/runtime/PackageManager.hpp 2008-02-17 20:32:08 UTC (rev 2363) @@ -65,8 +65,8 @@ static void initialize(); static RexxArray *getImageData(); static void restore(RexxArray *imageArray); - static LibraryPackage *getPackage(RexxString *name); - static LibraryPackage *loadPackage(RexxString *name); + static LibraryPackage *getLibrary(RexxString *name); + static LibraryPackage *loadLibrary(RexxString *name); static void unload(); static RexxNativeMethod *resolveMethod(RexxString *packageName, RexxString *methodName); static RoutineClass *resolveRoutine(RexxString *function, RexxString *packageName, RexxString *procedure); Modified: sandbox/rick/opt/kernel/runtime/RexxActivation.cpp =================================================================== --- sandbox/rick/opt/kernel/runtime/RexxActivation.cpp 2008-02-17 01:04:48 UTC (rev 2362) +++ sandbox/rick/opt/kernel/runtime/RexxActivation.cpp 2008-02-17 20:32:08 UTC (rev 2363) @@ -2345,18 +2345,19 @@ /** - * Load a package defined by a ::PACKAGE directive. + * Load a package defined by a ::REQUIRES name LIBRARY + * directive. * * @param target The name of the package. * @param instruction - * The ::PACKAGE directive being loaded. + * The ::REQUIRES directive being loaded. */ -void RexxActivation::loadPackage(RexxString *target, RexxInstruction *instruction) +void RexxActivation::loadLibrary(RexxString *target, RexxInstruction *instruction) { // this will cause the correct location to be used for error reporting this->current = instruction; // have the package manager resolve the package - PackageManager::getPackage(target); + PackageManager::getLibrary(target); } Modified: sandbox/rick/opt/kernel/runtime/RexxActivation.hpp =================================================================== --- sandbox/rick/opt/kernel/runtime/RexxActivation.hpp 2008-02-17 01:04:48 UTC (rev 2362) +++ sandbox/rick/opt/kernel/runtime/RexxActivation.hpp 2008-02-17 20:32:08 UTC (rev 2363) @@ -311,7 +311,7 @@ void setDefaultAddress(RexxString *); bool internalMethod(); PackageClass * loadRequired(RexxString *, RexxInstruction *); - void loadPackage(RexxString *target, RexxInstruction *instruction); + void loadLibrary(RexxString *target, RexxInstruction *instruction); RexxObject * rexxVariable(RexxString *); void pushEnvironment(RexxObject *); RexxObject * popEnvironment(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bigrixx@us...> - 2008-02-21 22:12:01
|
Revision: 2374 http://oorexx.svn.sourceforge.net/oorexx/?rev=2374&view=rev Author: bigrixx Date: 2008-02-21 14:11:53 -0800 (Thu, 21 Feb 2008) Log Message: ----------- incremental checkin Modified Paths: -------------- sandbox/rick/opt/kernel/kernel.mak sandbox/rick/opt/kernel/runtime/RexxStartDispatcher.hpp Added Paths: ----------- sandbox/rick/opt/kernel/classes/RexQueueMethods.cpp Removed Paths: ------------- sandbox/rick/opt/kernel/classes/QueueFunctions.cpp Deleted: sandbox/rick/opt/kernel/classes/QueueFunctions.cpp =================================================================== --- sandbox/rick/opt/kernel/classes/QueueFunctions.cpp 2008-02-21 21:50:34 UTC (rev 2373) +++ sandbox/rick/opt/kernel/classes/QueueFunctions.cpp 2008-02-21 22:11:53 UTC (rev 2374) @@ -1,220 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* */ -/* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */ -/* Copyright (c) 2005-2006 Rexx Language Association. All rights reserved. */ -/* */ -/* This program and the accompanying materials are made available under */ -/* the terms of the Common Public License v1.0 which accompanies this */ -/* distribution. A copy is also available at the following address: */ -/* http://www.ibm.com/developerworks/oss/CPLv1.0.htm */ -/* */ -/* Redistribution and use in source and binary forms, with or */ -/* without modification, are permitted provided that the following */ -/* conditions are met: */ -/* */ -/* Redistributions of source code must retain the above copyright */ -/* notice, this list of conditions and the following disclaimer. */ -/* Redistributions in binary form must reproduce the above copyright */ -/* notice, this list of conditions and the following disclaimer in */ -/* the documentation and/or other materials provided with the distribution. */ -/* */ -/* Neither the name of Rexx Language Association nor the names */ -/* of its contributors may be used to endorse or promote products */ -/* derived from this software without specific prior written permission. */ -/* */ -/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ -/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ -/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */ -/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ -/* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ -/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */ -/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */ -/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */ -/* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */ -/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */ -/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* */ -/*----------------------------------------------------------------------------*/ -/*********************************************************************/ -/* */ -/* Function: Queue support routines */ -/* */ -/*********************************************************************/ - -#include <string.h> /* Get strcpy, strcat, etc. */ -#include <stdlib.h> - -#include "RexxCore.h" /* global REXX declarations */ -#include "StringClass.hpp" - -/********************************************************************************************/ -/* Rexx_query_queue */ -/********************************************************************************************/ -RexxMethod0(size_t, rexx_query_queue) -{ - RexxStringObject queue_name; /* current queue name */ - size_t count = 0; /* count of lines */ - - /* get the queue name */ - queue_name = context->GetObjectVariable("NAMED_QUEUE"); - /* query the queue */ - RexxQueryQueue(context->ObjectToStringValue(queue_name), &count); - - return count; -} - -/********************************************************************************************/ -/* Rexx_pull_queue */ -/********************************************************************************************/ -RexxMethod0(RexxObjectPtr, rexx_pull_queue) -{ - RXSTRING buf; /* pulled line buffer */ - RexxReturnCode rc; /* pull return code */ - - /* get the queue name */ - RexxObjectPtr queue_name = context->GetObjectVariable("NAMED_QUEUE"); - - buf.strptr = NULL; /* ask for a returned buffer */ - buf.strlength = 0; - /* pull a line */ - rc = RexxPullQueue(context->ObjectToStringValue(queue_name), &buf, NULL, RXQUEUE_NOWAIT); - - if (!rc) - { /* get a pulled line? */ - RexxObjectPtr result = context->NewString(buf.strptr, buf.strlength); - if (buf.strptr != OREF_NULL) - { - RexxFreeMemory(buf.strptr); - } - return result; - } - return context->NilObject(); /* give back a failure */ -} - -/********************************************************************************************/ -/* Rexx_linein_queue */ -/********************************************************************************************/ -RexxMethod0(RexxObjectPtr, rexx_linein_queue) -{ - RxString buf; /* pulled line buffer */ - RexxReturnCode rc; /* pull return code */ - RexxObjectPtr queue_name; /* current queue name */ - - /* get the queue name */ - queue_name = context->GetObjectVariable("NAMED_QUEUE"); - - buf.strptr = NULL; /* ask for a returned buffer */ - buf.strlength = 0; - /* pull a line */ - rc = RexxPullQueue(context->ObjectToStringValue(queue_name), &buf, NULL, RXQUEUE_WAIT); - - if (!rc) /* get a pulled line? */ - { - RexxObjectPtr result = context->NewString(buf.strptr, buf.strlength); - if (buf.strptr != OREF_NULL) - { - ooRexxFreeMemory(buf.strptr); - } - return result; - } - return context->NilObject(); /* give back a failure */ -} - -/********************************************************************************************/ -/* add a line to a rexx queue */ -/********************************************************************************************/ -RexxNumber rexx_add_queue( - RexxMethodContext *context, // the call context - RexxStringObject queue_line, /* line to add */ - int order ) /* queuing order */ -{ - char buffer = 0; // buffer for an empty string - CONSTRXSTRING rx_string; // rxstring to push - RexxReturnCode rc; // queue return code - - if (queue_line == NULLOBJECT) /* no line given? */ - { - // just use a null string value - MAKERXSTRING(rx_string, buffer, 0); - } - else - { - MAKERXSTRING(rx_string, context->StringData(queue_line), context->StringLength(queue_line)); - } - /* get the queue name */ - RexxObjectPtr queue_name = context->GetObjectVariable("NAMED_QUEUE"); - /* move the line to the queue */ - rc = RexxAddQueue(context->ObjectToStringValue(queue_name), &rx_string, order); - if (rc != 0) /* stream error? */ - { - context->RaiseException1(Rexx_Error_System_service_service, context->NewStringFromAsciiz("SYSTEM QUEUE")); - } - return rc; /* return the result */ -} - -/********************************************************************************************/ -/* Rexx_push_queue */ -/********************************************************************************************/ -RexxMethod1(RexxNumber, rexx_push_queue, - OPTIONAL_RexxStringObject, queue_line) /* line to queue */ -{ - /* push a line onto the queue */ - return rexx_add_queue(context, queue_line, RXQUEUE_LIFO); -} - -/********************************************************************************************/ -/* Rexx_queue_queue */ -/********************************************************************************************/ -RexxMethod1(RexxNumber, rexx_queue_queue, - OPTIONAL_RexxStringObject, queue_line) /* line to queue */ -{ - /* queue a line onto the queue */ - return rexx_add_queue(context, queue_line, RXQUEUE_FIFO); -} - -/********************************************************************************************/ -/* Rexx_create_queue */ -/********************************************************************************************/ -RexxMethod1(RexxStringObject, rexx_create_queue, - CSTRING, queue_name) /* current queue name */ -{ - char buf[MAX_QUEUE_NAME_LENGTH+1]; /* creation buffer */ - RexxReturnCode rc; /* creation return code */ - size_t dup_flag = 0; /* duplicate name flag */ - - /* create a queue */ - rc = RexxCreateQueue(buf, sizeof(buf), queue_name, &dup_flag); - - if (!rc) /* work ok? */ - { - return context->NewStringFromAsciiz(buf); - } - return context->NullString(); /* just return a null string */ -} - -/********************************************************************************************/ -/* Rexx_delete_queue */ -/********************************************************************************************/ -RexxMethod1(wholenumber_t, rexx_delete_queue, - CSTRING, queue_name) -{ - /* just delete the queue */ - return RexxDeleteQueue(queue_name); -} - - - -/********************************************************************************************/ -/* function_queueExit */ -/********************************************************************************************/ -RexxMethod1(REXXOBJECT, function_queueExit, - STRING, queue_name) /* the requested name */ -{ - NativeContextBlock context; - - RexxString *temp = (RexxString *)queue_name; - /* call the exit */ - RexxActivation *activation = ActivityManager::currentActivity->getCurrentRexxFrame(); - context.activity->callQueueNameExit(activation, temp); - return context.protect(temp); /* and just return the exit result */ -} Copied: sandbox/rick/opt/kernel/classes/RexQueueMethods.cpp (from rev 2373, sandbox/rick/opt/kernel/classes/QueueFunctions.cpp) =================================================================== --- sandbox/rick/opt/kernel/classes/RexQueueMethods.cpp (rev 0) +++ sandbox/rick/opt/kernel/classes/RexQueueMethods.cpp 2008-02-21 22:11:53 UTC (rev 2374) @@ -0,0 +1,220 @@ +/*----------------------------------------------------------------------------*/ +/* */ +/* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */ +/* Copyright (c) 2005-2006 Rexx Language Association. All rights reserved. */ +/* */ +/* This program and the accompanying materials are made available under */ +/* the terms of the Common Public License v1.0 which accompanies this */ +/* distribution. A copy is also available at the following address: */ +/* http://www.ibm.com/developerworks/oss/CPLv1.0.htm */ +/* */ +/* Redistribution and use in source and binary forms, with or */ +/* without modification, are permitted provided that the following */ +/* conditions are met: */ +/* */ +/* Redistributions of source code must retain the above copyright */ +/* notice, this list of conditions and the following disclaimer. */ +/* Redistributions in binary form must reproduce the above copyright */ +/* notice, this list of conditions and the following disclaimer in */ +/* the documentation and/or other materials provided with the distribution. */ +/* */ +/* Neither the name of Rexx Language Association nor the names */ +/* of its contributors may be used to endorse or promote products */ +/* derived from this software without specific prior written permission. */ +/* */ +/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ +/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ +/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */ +/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ +/* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ +/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */ +/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */ +/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */ +/* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */ +/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */ +/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/* */ +/*----------------------------------------------------------------------------*/ +/*********************************************************************/ +/* */ +/* Function: Queue support routines */ +/* */ +/*********************************************************************/ + +#include <string.h> /* Get strcpy, strcat, etc. */ +#include <stdlib.h> + +#include "RexxCore.h" /* global REXX declarations */ +#include "StringClass.hpp" + +/********************************************************************************************/ +/* Rexx_query_queue */ +/********************************************************************************************/ +RexxMethod0(size_t, rexx_query_queue) +{ + RexxStringObject queue_name; /* current queue name */ + size_t count = 0; /* count of lines */ + + /* get the queue name */ + queue_name = context->GetObjectVariable("NAMED_QUEUE"); + /* query the queue */ + RexxQueryQueue(context->ObjectToStringValue(queue_name), &count); + + return count; +} + +/********************************************************************************************/ +/* Rexx_pull_queue */ +/********************************************************************************************/ +RexxMethod0(RexxObjectPtr, rexx_pull_queue) +{ + RXSTRING buf; /* pulled line buffer */ + RexxReturnCode rc; /* pull return code */ + + /* get the queue name */ + RexxObjectPtr queue_name = context->GetObjectVariable("NAMED_QUEUE"); + + buf.strptr = NULL; /* ask for a returned buffer */ + buf.strlength = 0; + /* pull a line */ + rc = RexxPullQueue(context->ObjectToStringValue(queue_name), &buf, NULL, RXQUEUE_NOWAIT); + + if (!rc) + { /* get a pulled line? */ + RexxObjectPtr result = context->NewString(buf.strptr, buf.strlength); + if (buf.strptr != OREF_NULL) + { + RexxFreeMemory(buf.strptr); + } + return result; + } + return context->NilObject(); /* give back a failure */ +} + +/********************************************************************************************/ +/* Rexx_linein_queue */ +/********************************************************************************************/ +RexxMethod0(RexxObjectPtr, rexx_linein_queue) +{ + RxString buf; /* pulled line buffer */ + RexxReturnCode rc; /* pull return code */ + RexxObjectPtr queue_name; /* current queue name */ + + /* get the queue name */ + queue_name = context->GetObjectVariable("NAMED_QUEUE"); + + buf.strptr = NULL; /* ask for a returned buffer */ + buf.strlength = 0; + /* pull a line */ + rc = RexxPullQueue(context->ObjectToStringValue(queue_name), &buf, NULL, RXQUEUE_WAIT); + + if (!rc) /* get a pulled line? */ + { + RexxObjectPtr result = context->NewString(buf.strptr, buf.strlength); + if (buf.strptr != OREF_NULL) + { + ooRexxFreeMemory(buf.strptr); + } + return result; + } + return context->NilObject(); /* give back a failure */ +} + +/********************************************************************************************/ +/* add a line to a rexx queue */ +/********************************************************************************************/ +RexxNumber rexx_add_queue( + RexxMethodContext *context, // the call context + RexxStringObject queue_line, /* line to add */ + int order ) /* queuing order */ +{ + char buffer = 0; // buffer for an empty string + CONSTRXSTRING rx_string; // rxstring to push + RexxReturnCode rc; // queue return code + + if (queue_line == NULLOBJECT) /* no line given? */ + { + // just use a null string value + MAKERXSTRING(rx_string, buffer, 0); + } + else + { + MAKERXSTRING(rx_string, context->StringData(queue_line), context->StringLength(queue_line)); + } + /* get the queue name */ + RexxObjectPtr queue_name = context->GetObjectVariable("NAMED_QUEUE"); + /* move the line to the queue */ + rc = RexxAddQueue(context->ObjectToStringValue(queue_name), &rx_string, order); + if (rc != 0) /* stream error? */ + { + context->RaiseException1(Rexx_Error_System_service_service, context->NewStringFromAsciiz("SYSTEM QUEUE")); + } + return rc; /* return the result */ +} + +/********************************************************************************************/ +/* Rexx_push_queue */ +/********************************************************************************************/ +RexxMethod1(RexxNumber, rexx_push_queue, + OPTIONAL_RexxStringObject, queue_line) /* line to queue */ +{ + /* push a line onto the queue */ + return rexx_add_queue(context, queue_line, RXQUEUE_LIFO); +} + +/********************************************************************************************/ +/* Rexx_queue_queue */ +/********************************************************************************************/ +RexxMethod1(RexxNumber, rexx_queue_queue, + OPTIONAL_RexxStringObject, queue_line) /* line to queue */ +{ + /* queue a line onto the queue */ + return rexx_add_queue(context, queue_line, RXQUEUE_FIFO); +} + +/********************************************************************************************/ +/* Rexx_create_queue */ +/********************************************************************************************/ +RexxMethod1(RexxStringObject, rexx_create_queue, + CSTRING, queue_name) /* current queue name */ +{ + char buf[MAX_QUEUE_NAME_LENGTH+1]; /* creation buffer */ + RexxReturnCode rc; /* creation return code */ + size_t dup_flag = 0; /* duplicate name flag */ + + /* create a queue */ + rc = RexxCreateQueue(buf, sizeof(buf), queue_name, &dup_flag); + + if (!rc) /* work ok? */ + { + return context->NewStringFromAsciiz(buf); + } + return context->NullString(); /* just return a null string */ +} + +/********************************************************************************************/ +/* Rexx_delete_queue */ +/********************************************************************************************/ +RexxMethod1(wholenumber_t, rexx_delete_queue, + CSTRING, queue_name) +{ + /* just delete the queue */ + return RexxDeleteQueue(queue_name); +} + + + +/********************************************************************************************/ +/* function_queueExit */ +/********************************************************************************************/ +RexxMethod1(REXXOBJECT, function_queueExit, + STRING, queue_name) /* the requested name */ +{ + NativeContextBlock context; + + RexxString *temp = (RexxString *)queue_name; + /* call the exit */ + RexxActivation *activation = ActivityManager::currentActivity->getCurrentRexxFrame(); + context.activity->callQueueNameExit(activation, temp); + return context.protect(temp); /* and just return the exit result */ +} Modified: sandbox/rick/opt/kernel/kernel.mak =================================================================== --- sandbox/rick/opt/kernel/kernel.mak 2008-02-21 21:50:34 UTC (rev 2373) +++ sandbox/rick/opt/kernel/kernel.mak 2008-02-21 22:11:53 UTC (rev 2374) @@ -124,7 +124,7 @@ $(OR_OUTDIR)\MemoryStats.$(OBJ) $(OR_OUTDIR)\MessageClass.$(OBJ) \ $(OR_OUTDIR)\StemClass.$(OBJ) $(OR_OUTDIR)\ObjectClass.$(OBJ) $(OR_OUTDIR)\RexxCompoundTail.$(OBJ) \ $(OR_OUTDIR)\RexxCompoundElement.$(OBJ) $(OR_OUTDIR)\RexxCompoundTable.$(OBJ) -OKPOBJ4=$(OR_OUTDIR)\QueueClass.$(OBJ) $(OR_OUTDIR)\SupplierClass.$(OBJ) \ +OKPOBJ4=$(OR_OUTDIR)\QueueClass.$(OBJ) $(OR_OUTDIR)\SupplierClass.$(OBJ) $(OR_OUTDIR)\RexxQueueMethods.$(OBJ) \ $(OR_OUTDIR)\RelationClass.$(OBJ) $(OR_OUTDIR)\TableClass.$(OBJ) \ $(OR_OUTDIR)\PrimitiveBehaviours.$(OBJ) $(OR_OUTDIR)\VirtualFunctionTable.$(OBJ) OKPOBJ5=$(OR_OUTDIR)\IntegerClass.$(OBJ) $(OR_OUTDIR)\NumberStringClass.$(OBJ) Modified: sandbox/rick/opt/kernel/runtime/RexxStartDispatcher.hpp =================================================================== --- sandbox/rick/opt/kernel/runtime/RexxStartDispatcher.hpp 2008-02-21 21:50:34 UTC (rev 2373) +++ sandbox/rick/opt/kernel/runtime/RexxStartDispatcher.hpp 2008-02-21 22:11:53 UTC (rev 2374) @@ -70,7 +70,6 @@ virtual ~CallRoutineDispatcher() { ; } virtual void run(); - virtual void handleError(wholenumber_t, RexxDirectory *); ProtectedObject result; @@ -87,7 +86,6 @@ virtual ~CallProgramDispatcher() { ; } virtual void run(); - virtual void handleError(wholenumber_t, RexxDirectory *); ProtectedObject result; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bigrixx@us...> - 2008-02-26 00:29:36
|
Revision: 2378 http://oorexx.svn.sourceforge.net/oorexx/?rev=2378&view=rev Author: bigrixx Date: 2008-02-25 16:29:33 -0800 (Mon, 25 Feb 2008) Log Message: ----------- incremental checkin Modified Paths: -------------- sandbox/rick/opt/kernel/classes/MethodClass.cpp sandbox/rick/opt/kernel/classes/MethodClass.hpp sandbox/rick/opt/kernel/classes/ObjectClass.cpp sandbox/rick/opt/kernel/classes/ObjectClass.hpp sandbox/rick/opt/kernel/classes/PackageClass.cpp sandbox/rick/opt/kernel/classes/PackageClass.hpp sandbox/rick/opt/kernel/classes/RoutineClass.cpp sandbox/rick/opt/kernel/classes/RoutineClass.hpp sandbox/rick/opt/kernel/parser/Scanner.cpp sandbox/rick/opt/kernel/parser/SourceFile.cpp sandbox/rick/opt/kernel/parser/SourceFile.hpp sandbox/rick/opt/kernel/runtime/LibraryPackage.cpp sandbox/rick/opt/kernel/runtime/PackageManager.cpp sandbox/rick/opt/kernel/runtime/PackageManager.hpp sandbox/rick/opt/kernel/runtime/RexxBehaviour.cpp sandbox/rick/opt/kernel/runtime/RexxBehaviour.hpp sandbox/rick/opt/kernel/runtime/RexxConstants.hpp sandbox/rick/opt/kernel/runtime/RexxCore.h sandbox/rick/opt/kernel/runtime/RexxMemory.hpp sandbox/rick/opt/kernel/runtime/Setup.cpp Modified: sandbox/rick/opt/kernel/classes/MethodClass.cpp =================================================================== --- sandbox/rick/opt/kernel/classes/MethodClass.cpp 2008-02-24 01:18:25 UTC (rev 2377) +++ sandbox/rick/opt/kernel/classes/MethodClass.cpp 2008-02-26 00:29:33 UTC (rev 2378) @@ -60,6 +60,7 @@ #include "RexxInternalApis.h" #include "RoutineClass.hpp" #include "Interpreter.hpp" +#include "RexxCode.hpp" // singleton class instance RexxClass *RexxMethod::classInstance = OREF_NULL; @@ -136,26 +137,117 @@ } -RexxMethod::RexxMethod(BaseCode *codeObj) -/******************************************************************************/ -/* Function: Initialize a method object */ -/******************************************************************************/ + +/** + * Generate a method directly from a source object. + * + * @param source The source object. + */ +RexxMethod::RexxMethod(RexxString *name, RexxSource *source) { this->clearObject(); /* start out fresh */ - this->methodFlags = 0; /* clear all of the flags */ + ProtectedObject p2(source); + OrefSet(this, this->executableName, name); + // generate our code object and make the file hook up. + RexxCode *codeObj = source->generateCode(); + OrefSet(this, this->code, codeObj); +} + + +/** + * Initialize a Routine object from a generated code object. Generally + * used for routines generated from ::METHOD directives. + * + * @param name The routine name. + * @param codeObj The associated code object. + */ +RexxMethod::RexxMethod(RexxString *name, BaseCode *codeObj) +{ + this->clearObject(); /* start out fresh */ + OrefSet(this, this->executableName, name); OrefSet(this, this->code, codeObj); /* store the code */ } -RexxMethod::RexxMethod(RexxSource *source) -/******************************************************************************/ -/* Function: Initialize a method object */ -/******************************************************************************/ + +/** + * Initialize a RexxMethod object from a file source. + * + * @param name The routine name (and the resolved name of the file). + */ +RexxMethod::RexxMethod(RexxString *name) { this->clearObject(); /* start out fresh */ - this->methodFlags = 0; /* clear all of the flags */ - OrefSet(this, this->code, source->generateCode()); /* store the code */ + ProtectedObject p(this); // protect during processing + OrefSet(this, this->executableName, name); + // get a source object to generat this from + RexxSource *source = new RexxSource(name); + ProtectedObject p2(source); + // generate our code object and make the file hook up. + RexxCode *codeObj = source->generateCode(); + OrefSet(this, this->code, codeObj); } + +/** + * Initialize a Routine object using a buffered source. + * + * @param name The name of the routine. + * @param source the source buffer. + */ +RexxMethod::RexxMethod(RexxString *name, RexxBuffer *buf) +{ + this->clearObject(); /* start out fresh */ + ProtectedObject p(this); // protect during processing + OrefSet(this, this->executableName, name); + // get a source object to generat this from + RexxSource *source = new RexxSource(name, buf); + ProtectedObject p2(source); + // generate our code object and make the file hook up. + RexxCode *codeObj = source->generateCode(); + OrefSet(this, this->code, codeObj); +} + + +/** + * Initialize a Routine object using directly provided source. + * + * @param name The name of the routine. + * @param data The source data buffer pointer. + * @param length the length of the source buffer. + */ +RexxMethod::RexxMethod(RexxString *name, const char *data, size_t length) +{ + this->clearObject(); /* start out fresh */ + ProtectedObject p(this); // protect during processing + OrefSet(this, this->executableName, name); + // get a source object to generat this from + RexxSource *source = new RexxSource(name, data, length); + ProtectedObject p2(source); + // generate our code object and make the file hook up. + RexxCode *codeObj = source->generateCode(); + OrefSet(this, this->code, codeObj); +} + + +/** + * Initialize a Routine object using an array source. + * + * @param name The name of the routine. + * @param source the source buffer. + */ +RexxMethod::RexxMethod(RexxString *name, RexxArray *s) +{ + this->clearObject(); /* start out fresh */ + ProtectedObject p(this); // protect during processing + OrefSet(this, this->executableName, name); + // get a source object to generat this from + RexxSource *source = new RexxSource(name, s); + ProtectedObject p2(source); + // generate our code object and make the file hook up. + RexxCode *codeObj = source->generateCode(); + OrefSet(this, this->code, codeObj); +} + void RexxMethod::live(size_t liveMark) /******************************************************************************/ /* Function: Normal garbage collection live marking */ @@ -163,6 +255,7 @@ { memory_mark(this->scope); memory_mark(this->code); + memory_mark(this->executableName); memory_mark(this->objectVariables); } @@ -173,6 +266,7 @@ { memory_mark_general(this->scope); memory_mark_general(this->code); + memory_mark_general(this->executableName); memory_mark_general(this->objectVariables); } @@ -185,6 +279,7 @@ flatten_reference(newThis->scope, envelope); flatten_reference(newThis->code, envelope); + flatten_reference(newThis->executableName, envelope); flatten_reference(newThis->objectVariables, envelope); cleanUpFlatten @@ -216,19 +311,20 @@ /* Function: Create a new method with a given scope */ /******************************************************************************/ { - RexxMethod *newMethod; /* the copied method */ - - if (this->scope == OREF_NULL) { /* nothing set yet? */ - OrefSet(this, this->scope, _scope); /* just set it directly */ - return this; /* and pass back unchanged */ - } - else { - /* copy the method */ - newMethod= (RexxMethod *)this->copy(); - /* give the method the new scope */ - OrefSet(newMethod, newMethod->scope, _scope); - return newMethod; /* and return it */ - } + // if this doesn't have a scope yet, we can just override what's here + if (this->scope == OREF_NULL) + { + OrefSet(this, this->scope, _scope); /* just set it directly */ + return this; /* and pass back unchanged */ + } + else + { + /* copy the method */ + RexxMethod *newMethod= (RexxMethod *)this->copy(); + /* give the method the new scope */ + OrefSet(newMethod, newMethod->scope, _scope); + return newMethod; /* and return it */ + } } @@ -369,25 +465,6 @@ } -RexxMethod *RexxMethod::newRexxMethod( - RexxSource *source, /* source object for the method */ - RexxClass *scope) /* scope to use */ -/******************************************************************************/ -/* Function: Convert a new source object to a method with the given scope */ -/******************************************************************************/ -{ - - - /* create a new method object */ - RexxMethod *newMethod = new RexxMethod(source); - if (scope != OREF_NULL) /* given a scope too? */ - { - newMethod->setScope(scope); /* set the scope */ - } - return newMethod; /* return the new method object */ -} - - /** * Static method used for constructing new method objects in * various contexts (such as the define method on the Class class). @@ -450,12 +527,8 @@ } } - /* create a source object */ - RexxSource *newSource = new RexxSource (pgmname, newSourceArray); + RexxMethod *result = new RexxMethod(pgmname, newSourceArray); - ProtectedObject p(newSource); - RexxMethod *result = RexxMethod::newRexxMethod(newSource, OREF_NULL); - // if we've been provided with a scope, use it if (parentSource == OREF_NULL) { @@ -470,7 +543,7 @@ // if there is a parent source, then merge in the scope information if (parentSource != OREF_NULL) { - newSource->inheritSourceContext(parentSource); + result->getSourceObject()->inheritSourceContext(parentSource); } return result; @@ -546,70 +619,24 @@ /* Function: Create a method from a fully resolved file name */ /******************************************************************************/ { - /* get the method name as a string */ - filename = REQUIRED_STRING(filename, ARG_ONE); - /* create a source object */ - RexxSource *source = RexxSource::classNewFile(filename); - ProtectedObject p(source); - /* finish up processing of this */ - RexxMethod * newMethod = newRexxMethod(source, (RexxClass *)TheNilObject); - ProtectedObject p2(newMethod); - /* Give new object its behaviour */ - newMethod->setBehaviour(((RexxClass *)this)->getInstanceBehaviour()); - if (((RexxClass *)this)->hasUninitDefined()) /* does object have an UNINT method */ - { - newMethod->hasUninit(); /* Make sure everyone is notified. */ - } - /* now send an INIT message */ - newMethod->sendMessage(OREF_INIT); - return newMethod; + /* get the method name as a string */ + filename = REQUIRED_STRING(filename, ARG_ONE); + /* create a source object */ + RexxMethod *newMethod = new RexxMethod(filename); + ProtectedObject p(newMethod); + newMethod->setScope((RexxClass *)TheNilObject); + /* Give new object its behaviour */ + newMethod->setBehaviour(((RexxClass *)this)->getInstanceBehaviour()); + if (((RexxClass *)this)->hasUninitDefined()) /* does object have an UNINT method */ + { + newMethod->hasUninit(); /* Make sure everyone is notified. */ + } + /* now send an INIT message */ + newMethod->sendMessage(OREF_INIT); + return newMethod; } -RexxMethod *RexxMethod::newRexxBuffer( - RexxString *pgmname, /* file name to process */ - RexxBuffer *source, /* String or buffer with source */ - RexxClass *scope) /* Scope for this method */ -/******************************************************************************/ -/* Function: Build a new method object from buffered REXX source */ -/******************************************************************************/ -{ - if (source == OREF_NULL) /* didn't get source? */ - { - /* raise an error */ - reportException(Error_Incorrect_method_noarg, IntegerTwo); - } - /* create a source object */ - RexxSource *newSource = RexxSource::classNewBuffered(pgmname, source); - // we need to protect this source object until parsing is complete - ProtectedObject p(newSource); - /* now complete method creation */ - return newRexxMethod(newSource, scope); -} - - - - -/** - * Create a method object from an in-store source. - * - * @param pgmname The program name (as an ASCII-Z string). - * @param source The pointer to the program source. - * @param length The length of the source. - * - * @return A translated Method object. - */ -RexxMethod *RexxMethod::newRexxBuffer(const char *pgmname, const char *source, size_t length) -{ - /* create a source object */ - RexxSource *newSource = RexxSource::classNewBuffered(new_string(pgmname), source, length); - // we need to protect this source object until parsing is complete - ProtectedObject p(newSource); - /* now complete method creation */ - return newRexxMethod(newSource, OREF_NULL); -} - - RexxMethod *RexxMethod::restore( RexxBuffer *buffer, /* buffer containing the method */ char *startPointer) /* first character of the method */ @@ -630,21 +657,6 @@ } -RexxMethod *RexxMethod::newFile( - RexxString *filename) /* name of the target file */ -/******************************************************************************/ -/* Function: Create a method from a fully resolved file name */ -/******************************************************************************/ -{ - /* create a source object */ - RexxSource *source = RexxSource::classNewFile(filename); - ProtectedObject p(source); - /* finish up processing of this */ - return newRexxMethod(source, (RexxClass *)TheNilObject); -} - - - /** * Run this code as a method invocation. * Modified: sandbox/rick/opt/kernel/classes/MethodClass.hpp =================================================================== --- sandbox/rick/opt/kernel/classes/MethodClass.hpp 2008-02-24 01:18:25 UTC (rev 2377) +++ sandbox/rick/opt/kernel/classes/MethodClass.hpp 2008-02-26 00:29:33 UTC (rev 2378) @@ -92,6 +92,7 @@ BaseExecutable *setSourceObject(RexxSource *s); protected: + RexxString *executableName; // the created name of this routine BaseCode *code; // the backing code object }; @@ -101,8 +102,12 @@ public: void *operator new(size_t); inline void *operator new(size_t size, void *ptr) { return ptr; }; - RexxMethod(BaseCode *_code); - RexxMethod(RexxSource *source); + RexxMethod(RexxString *name, BaseCode *_code); + RexxMethod(RexxString *name, RexxSource *source); + RexxMethod(RexxString *name); + RexxMethod(RexxString *name, RexxBuffer *source); + RexxMethod(RexxString *name, const char *data, size_t length); + RexxMethod(RexxString *name, RexxArray *source); inline RexxMethod(RESTORETYPE restoreType) { ; }; void execute(RexxObject *, RexxObject *); @@ -140,13 +145,8 @@ RexxMethod *newRexx(RexxObject **, size_t); RexxMethod *newFileRexx(RexxString *); - static RexxMethod *newRexxMethod(RexxSource *, RexxClass *); static RexxMethod *newMethodObject(RexxString *, RexxObject *, RexxObject *, RexxSource *a); - static RexxMethod *newRexxBuffer(RexxString *, RexxBuffer *, RexxClass *); - static RexxMethod *newRexxBuffer(const char *, const char *, size_t); - static RexxMethod *newEntry(PNATIVEMETHOD); static RexxMethod *restore(RexxBuffer *, char *); - static RexxMethod *newFile(RexxString *); static RexxClass *classInstance; @@ -162,9 +162,4 @@ RexxClass *scope; /* pointer to the method scope */ }; - - -inline RexxMethod *new_method(BaseCode *c) { return new RexxMethod(c); } - - #endif Modified: sandbox/rick/opt/kernel/classes/ObjectClass.cpp =================================================================== --- sandbox/rick/opt/kernel/classes/ObjectClass.cpp 2008-02-24 01:18:25 UTC (rev 2377) +++ sandbox/rick/opt/kernel/classes/ObjectClass.cpp 2008-02-26 00:29:33 UTC (rev 2378) @@ -1130,6 +1130,7 @@ } } + RexxString *RexxObject::requiredString( size_t position ) /* required argument position */ /******************************************************************************/ @@ -1137,19 +1138,52 @@ /* the object MUST have a string value. */ /******************************************************************************/ { - RexxObject *string_value; /* converted object */ + RexxObject *string_value; /* converted object */ - if (this->isBaseClass()) /* primitive object? */ - string_value = this->makeString(); /* get the string representation */ - else /* do a full request for this */ - string_value = this->sendMessage(OREF_REQUEST, OREF_STRINGSYM); - /* didn't convert? */ - if (string_value == TheNilObject) - /* this is an error */ - reportException(Error_Incorrect_method_nostring, position); - return (RexxString *)string_value; /* return the converted form */ + if (this->isBaseClass()) /* primitive object? */ + { + string_value = this->makeString(); /* get the string representation */ + } + else /* do a full request for this */ + { + string_value = this->sendMessage(OREF_REQUEST, OREF_STRINGSYM); + } + /* didn't convert? */ + if (string_value == TheNilObject) + { + /* this is an error */ + reportException(Error_Incorrect_method_nostring, position); + } + return(RexxString *)string_value; /* return the converted form */ } + +RexxString *RexxObject::requiredString( + const char *name) /* required argument position */ +/******************************************************************************/ +/* Function: Handle a string request for a REXX object in a context where */ +/* the object MUST have a string value. */ +/******************************************************************************/ +{ + RexxObject *string_value; /* converted object */ + + if (this->isBaseClass()) /* primitive object? */ + { + string_value = this->makeString(); /* get the string representation */ + } + else /* do a full request for this */ + { + string_value = this->sendMessage(OREF_REQUEST, OREF_STRINGSYM); + } + /* didn't convert? */ + if (string_value == TheNilObject) + { + /* this is an error */ + reportException(Error_Incorrect_argument_string, name); + } + return(RexxString *)string_value; /* return the converted form */ +} + /** * Handle a string request for a required string value where * the caller wishes to handle the error itself. Modified: sandbox/rick/opt/kernel/classes/ObjectClass.hpp =================================================================== --- sandbox/rick/opt/kernel/classes/ObjectClass.hpp 2008-02-24 01:18:25 UTC (rev 2377) +++ sandbox/rick/opt/kernel/classes/ObjectClass.hpp 2008-02-26 00:29:33 UTC (rev 2378) @@ -391,6 +391,7 @@ bool requestUnsignedNumber(stringsize_t &, size_t); RexxArray *requestArray(); RexxString *requiredString(size_t); + RexxString *requiredString(const char *); RexxString *requiredString(); RexxInteger *requiredInteger(size_t, size_t); wholenumber_t requiredNumber(size_t position, size_t precision = Numerics::DEFAULT_DIGITS); Modified: sandbox/rick/opt/kernel/classes/PackageClass.cpp =================================================================== --- sandbox/rick/opt/kernel/classes/PackageClass.cpp 2008-02-24 01:18:25 UTC (rev 2377) +++ sandbox/rick/opt/kernel/classes/PackageClass.cpp 2008-02-26 00:29:33 UTC (rev 2378) @@ -80,6 +80,7 @@ /******************************************************************************/ { memory_mark(this->source); + memory_mark(this->objectVariables); } void PackageClass::liveGeneral(int reason) @@ -88,6 +89,7 @@ /******************************************************************************/ { memory_mark_general(this->source); + memory_mark_general(this->objectVariables); } void PackageClass::flatten(RexxEnvelope *envelope) @@ -98,6 +100,7 @@ setUpFlatten(PackageClass) flatten_reference(newThis->source, envelope); + flatten_reference(newThis->objectVariables, envelope); cleanUpFlatten } @@ -154,6 +157,17 @@ /** + * Get the number of source lines in the package + * + * @return the count of lines + */ +RexxInteger *PackageClass::getSourceSize() +{ + return new_integer(source->sourceSize()); +} + + +/** * Retrieve all classes defined by this package. * * @return A directory of all of the classes defined by this package. @@ -354,6 +368,74 @@ /** + * Add a routine to this package's private routine list. + * + * @param routine The routine to add. + * + * @return The target package object. + */ +RexxObject *PackageClass::addRoutine(RexxString *name, RoutineClass *routine) +{ + name = REQUIRED_STRING(name, "name"); + REQUIRED_INSTANCE(routine, TheRoutineClass, "routine"); + + source->addInstalledRoutine(name, routine, false); + return this; +} + + +/** + * Add a routine to this package's public routine list. + * + * @param routine The routine to add. + * + * @return The target package object. + */ +RexxObject *PackageClass::addPublicRoutine(RoutineClass *routine) +{ + name = REQUIRED_STRING(name, "name"); + REQUIRED_INSTANCE(routine, TheRoutineClass, "routine"); + + source->addInstalledRoutine(name, routine, true); + return this; +} + + +/** + * Add a class to this package's class list. + * + * @param clazz The class to add. + * + * @return The target package object. + */ +RexxObject *PackageClass::addClass(RexxClass *clazz) +{ + name = REQUIRED_STRING(name, "name"); + REQUIRED_INSTANCE(clazz, TheClassClass, "class"); + + source->addInstalledClass(name, clazz, false); + return this; +} + + +/** + * Add a class to this package's public class list. + * + * @param clazz The class to add. + * + * @return The target package object. + */ +RexxObject *PackageClass::addPublicClass(RexxClass *clazz) +{ + name = REQUIRED_STRING(name, "name"); + REQUIRED_INSTANCE(clazz, TheClassClass, "class"); + + source->addInstalledClass(name, clazz, true); + return this; +} + + +/** * Resolve a class in the context of a package. * * @param name The required class name. @@ -364,3 +446,48 @@ { return source->resolveClass(name); } + + +PackageClass *PackageClass::newRexx( + RexxObject **init_args, /* subclass init arguments */ + size_t argCount) /* number of arguments passed */ +/******************************************************************************/ +/* Function: Create a new packag from REXX code contained in a file or an */ +/* array */ +/******************************************************************************/ +{ + RexxObject *pgmname; /* method name */ + RexxObject *source; /* Array or string object */ + RexxObject *option = OREF_NULL; + size_t initCount = 0; /* count of arguments we pass along */ + + /* break up the arguments */ + + process_new_args(init_args, argCount, &init_args, &initCount, 2, (RexxObject **)&pgmname, (RexxObject **)&source); + + PackageClass *package = OREF_NULL; + + /* get the package name as a string */ + RexxString *nameString = REQUIRED_STRING(pgmname, ARG_ONE); + if (source == OREF_NULL) + { + RexxString *resolvedName = ActivityManager::currentActivity->getInstance()->resolveProgramName(pgmname, OREF_NULL, OREF_NULL); + package = PackageManager::loadRequires(ActivityManager::currentActivity, pgmname, resolvedName, package); + } + else + { + RexxArray *sourceArray = REQUIRED_ARRAY(soource, IntegerTwo); + package = PackageManager::loadRequires(ActivityManager::currentActivity, pgmname, sourceArray, package); + } + + ProtectedObject p(package); + /* Give new object its behaviour */ + newRoutine->setBehaviour(((RexxClass *)this)->getInstanceBehaviour()); + if (((RexxClass *)this)->hasUninitDefined()) + { + newRoutine->hasUninit(); /* Make sure everyone is notified. */ + } + /* now send an INIT message */ + newRoutine->sendMessage(OREF_INIT, init_args, initCount); + return newRoutine; /* return the new method */ +} Modified: sandbox/rick/opt/kernel/classes/PackageClass.hpp =================================================================== --- sandbox/rick/opt/kernel/classes/PackageClass.hpp 2008-02-24 01:18:25 UTC (rev 2377) +++ sandbox/rick/opt/kernel/classes/PackageClass.hpp 2008-02-26 00:29:33 UTC (rev 2378) @@ -62,7 +62,9 @@ RexxString *getName(); RexxArray *getSource(); RexxString *getSourceLine(size_t); + RexxInteger *getSourceSize(); RexxString *getSourceLineRexx(RexxObject *); + RexxObject *setSecurityManager(RexxObject *); RexxDirectory *getClasses(); RexxDirectory *getPublicClasses(); @@ -72,10 +74,17 @@ RexxDirectory *getPublicRoutines(); RexxDirectory *getImportedRoutines(); RexxArray *getImportedPackages(); - PackageClass *loadPackage(RexxString *name); + PackageClass *loadPackage(RexxString *name, RexxArray *source); RexxObject *addPackage(PackageClass *package); - RexxClass *resolveClass(RexxString *name); + RexxClass *findClass(RexxString *name); + RoutineClass *findRoutine(RexxString *name); + RexxObject *addRoutine(RexxString *name, RoutineClass *routine); + RexxObject *addPublicRoutine(RexxString *name, RoutineClass *routine); + RexxObject *addClass(RexxString *name, RexxClass *clazz); + RexxObject *addPublicClass(RexxString *name, RexxClass *clazz); + PackageClass *newRexx(RexxString *name, RexxArray *source); + inline RexxSource *getSourceObject() { return source; } protected: Modified: sandbox/rick/opt/kernel/classes/RoutineClass.cpp =================================================================== --- sandbox/rick/opt/kernel/classes/RoutineClass.cpp 2008-02-24 01:18:25 UTC (rev 2377) +++ sandbox/rick/opt/kernel/classes/RoutineClass.cpp 2008-02-26 00:29:33 UTC (rev 2378) @@ -68,21 +68,109 @@ RexxClass *RoutineClass::classInstance = OREF_NULL; -RoutineClass::RoutineClass(BaseCode *codeObj) -/******************************************************************************/ -/* Function: Initialize a method object */ -/******************************************************************************/ +/** + * Initialize a Routine object from a generated code object. Generally + * used for routines generated from ::ROUTINE directives. + * + * @param name The routine name. + * @param codeObj The associated code object. + */ +RoutineClass::RoutineClass(RexxString *name, BaseCode *codeObj) { this->clearObject(); /* start out fresh */ OrefSet(this, this->code, codeObj); /* store the code */ + OrefSet(this, this->executableName, name); } + +/** + * Initialize a RoutineClass object from a file source. + * + * @param name The routine name (and the resolved name of the file). + */ +RoutineClass::RoutineClass(RexxString *name) +{ + this->clearObject(); /* start out fresh */ + ProtectedObject p(this); // protect during processing + OrefSet(this, this->executableName, name); + // get a source object to generat this from + RexxSource *source = new RexxSource(name); + ProtectedObject p2(source); + // generate our code object and make the file hook up. + RexxCode *codeObj = source->generateCode(); + OrefSet(this, this->code, codeObj); +} + + +/** + * Initialize a Routine object using a buffered source. + * + * @param name The name of the routine. + * @param source the source buffer. + */ +RoutineClass::RoutineClass(RexxString *name, RexxBuffer *s) +{ + this->clearObject(); /* start out fresh */ + ProtectedObject p(this); // protect during processing + OrefSet(this, this->executableName, name); + // get a source object to generat this from + RexxSource *source = new RexxSource(name, s); + ProtectedObject p2(source); + // generate our code object and make the file hook up. + RexxCode *codeObj = source->generateCode(); + OrefSet(this, this->code, codeObj); +} + + +/** + * Initialize a Routine object using directly provided source. + * + * @param name The name of the routine. + * @param data The source data buffer pointer. + * @param length the length of the source buffer. + */ +RoutineClass::RoutineClass(RexxString *name, const char *data, size_t length) +{ + this->clearObject(); /* start out fresh */ + ProtectedObject p(this); // protect during processing + OrefSet(this, this->executableName, name); + // get a source object to generat this from + RexxSource *source = new RexxSource(name, data, length); + ProtectedObject p2(source); + // generate our code object and make the file hook up. + RexxCode *codeObj = source->generateCode(); + OrefSet(this, this->code, codeObj); +} + + +/** + * Initialize a Routine object using an array source. + * + * @param name The name of the routine. + * @param source the source buffer. + */ +RoutineClass::RoutineClass(RexxString *name, RexxArray *s) +{ + this->clearObject(); /* start out fresh */ + ProtectedObject p(this); // protect during processing + OrefSet(this, this->executableName, name); + // get a source object to generat this from + RexxSource *source = new RexxSource(name, s); + ProtectedObject p2(source); + // generate our code object and make the file hook up. + RexxCode *codeObj = source->generateCode(); + OrefSet(this, this->code, codeObj); +} + + void RoutineClass::live(size_t liveMark) /******************************************************************************/ /* Function: Normal garbage collection live marking */ /******************************************************************************/ { memory_mark(this->code); + memory_mark(this->executableName); + memory_mark(this->objectVariables); } void RoutineClass::liveGeneral(int reason) @@ -91,6 +179,8 @@ /******************************************************************************/ { memory_mark_general(this->code); + memory_mark_general(this->executableName); + memory_mark_general(this->objectVariables); } void RoutineClass::flatten(RexxEnvelope *envelope) @@ -101,6 +191,8 @@ setUpFlatten(RoutineClass) flatten_reference(newThis->code, envelope); + flatten_reference(newThis->executableName, envelope); + flatten_reference(newThis->objectVariables, envelope); cleanUpFlatten } @@ -141,6 +233,43 @@ } +/** + * Call a routine object from Rexx-level code. + * + * @param args The call arguments. + * @param count The count of arguments. + * + * @return The call result (if any). + */ +RexxObject *RoutineClass::callRexx(RexxObject **args, size_t count) +{ + ProtectedObject result; + + code->call(ActivityManager::currentActivity, this, executableName, args, count, result); + return (RexxObject *)result; +} + + +/** + * Call a routine object from Rexx-level code. + * + * @param args The call arguments. + * + * @return The call result (if any). + */ +RexxObject *RoutineClass::callWithRexx(RexxArray *args) +{ + // this is required and must be an array + args = REQUIRED_ARRAY(args, 1); + + ProtectedObject result; + + code->call(ActivityManager::currentActivity, this, executableName, args->data(), args->size(), result); + return (RexxObject *)result; +} + + + void RoutineClass::runProgram( RexxActivity *activity, RexxString * calltype, /* type of invocation */ @@ -254,20 +383,6 @@ /** - * Create a new Routine object from a source object. This - * creates a top-level routine object. - * - * @param source The original source object. - * - * @return A RoutineClass instance. - */ -RoutineClass *RoutineClass::newRoutine(RexxSource *source) -{ - // generate a new routine from the base source - return new_routine(source->generateCode()); -} - -/** * Construct a Routine using different forms of in-memory * source file. * @@ -327,13 +442,10 @@ } } } + // create the routine + RoutineClass *result = new RoutineClass(pgmname, newSourceArray); + ProtectedObject p(result); - /* create a source object */ - RexxSource *newSource = new RexxSource (pgmname, newSourceArray); - - ProtectedObject p(newSource); - RoutineClass *result = newRoutine(newSource); - p = result; // switch the protectiong // if we've been provided with a scope, use it @@ -357,6 +469,63 @@ } +/** + * Construct a Routine using different forms of in-memory + * source file. + * + * @param pgmname The name of the program. + * @param source The program source. This can be a string or an array of strings. + * @param position The argument position used for error reporting. + * @param parentSource + * A parent source context used to provide additional class and + * routine definitions. + * + * @return A constructed Routine object. + */ +RoutineClass *RoutineClass::newRoutineObject(RexxString *pgmname, RexxArray *source, RexxObject *position) +{ + // request this as an array. If not convertable, then we'll use it as a string + RexxArray *newSourceArray = source->requestArray(); + /* couldn't convert? */ + if (newSourceArray == (RexxArray *)TheNilObject) + { + /* raise an error */ + reportException(Error_Incorrect_method_no_method, position); + } + else /* have an array, make sure all */ + { + /* is it single dimensional? */ + if (newSourceArray->getDimension() != 1) + { + /* raise an error */ + reportException(Error_Incorrect_method_noarray, position); + } + /* element are strings. */ + /* Make a source array safe. */ + ProtectedObject p(newSourceArray); + /* Make sure all elements in array */ + for (size_t counter = 1; counter <= newSourceArray->size(); counter++) + { + /* Get element as string object */ + RexxString *sourceString = newSourceArray ->get(counter)->makeString(); + /* Did it convert? */ + if (sourceString == (RexxString *)TheNilObject) + { + /* and report the error. */ + reportException(Error_Incorrect_method_nostring_inarray, IntegerTwo); + } + else + { + /* itsa string add to source array */ + newSourceArray ->put(sourceString, counter); + } + } + } + // create the routine + return new RoutineClass(pgmname, newSourceArray); +} + + RoutineClass *RoutineClass::newRexx( RexxObject **init_args, /* subclass init arguments */ size_t argCount) /* number of arguments passed */ @@ -428,11 +597,8 @@ { /* get the method name as a string */ filename = REQUIRED_STRING(filename, ARG_ONE); - /* create a source object */ - RexxSource *source = RexxSource::classNewFile(filename); - ProtectedObject p(source); /* finish up processing of this */ - RoutineClass * newMethod = newRoutine(source); + RoutineClass * newMethod = new RoutineClass(filename); ProtectedObject p2(newMethod); /* Give new object its behaviour */ newMethod->setBehaviour(((RexxClass *)this)->getInstanceBehaviour()); @@ -447,48 +613,7 @@ } -RoutineClass *RoutineClass::newRexxBuffer( - RexxString *pgmname, /* file name to process */ - RexxBuffer *source) /* String or buffer with source */ -/******************************************************************************/ -/* Function: Build a new method object from buffered REXX source */ -/******************************************************************************/ -{ - if (source == OREF_NULL) /* didn't get source? */ - { - /* raise an error */ - reportException(Error_Incorrect_method_noarg, IntegerTwo); - } - /* create a source object */ - RexxSource *newSource = (RexxSource *)RexxSource::classNewBuffered(pgmname, source); - // we need to protect this source object until parsing is complete - ProtectedObject p(newSource); - /* now complete method creation */ - return newRoutine(newSource); -} - - /** - * Create a routine object from an in-store source. - * - * @param pgmname The program name (as an ASCII-Z string). - * @param source The pointer to the program source. - * @param length The length of the source. - * - * @return A translated Routine object. - */ -RoutineClass *RoutineClass::newRexxBuffer(RexxString *pgmname, const char *source, size_t length) -{ - /* create a source object */ - RexxSource *newSource = RexxSource::classNewBuffered(pgmname, source, length); - // we need to protect this source object until parsing is complete - ProtectedObject p(newSource); - /* now complete method creation */ - return newRoutine(newSource); -} - - -/** * Create a routine from a macrospace source. * * @param name The name of the macrospace item. @@ -553,7 +678,7 @@ } /* translate this source */ - RoutineClass *routine = newRexxBuffer(name, source_buffer); + RoutineClass *routine = new RoutineClass(name, source_buffer); /* return this back in instore[1] */ routine->save(&instore[1]); return routine; /* return translated source */ @@ -682,6 +807,21 @@ /** + * Set a security manager on a package. + * + * @param manager The security manager object. + * + * @return The security manager object. + */ +RexxObject *RoutineClass::setSecurityManager( + RexxObject *manager) /* supplied security manager */ +{ + source->setSecurityManager(manager); + return TheTrueObject; +} + + +/** * Retrieve a routine object from a file. This will first attempt * to restore a previously translated image, then will try to * translate the source if that fails. @@ -699,7 +839,7 @@ } // process this from the source - return newFile(filename); + return new RoutineClass(filename); } @@ -723,16 +863,4 @@ } -RoutineClass *RoutineClass::newFile( - RexxString *filename) /* name of the target file */ -/******************************************************************************/ -/* Function: Create a method from a fully resolved file name */ -/******************************************************************************/ -{ - /* create a source object */ - RexxSource *source = RexxSource::classNewFile(filename); - ProtectedObject p(source); - /* finish up processing of this */ - return newRoutine(source); -} Modified: sandbox/rick/opt/kernel/classes/RoutineClass.hpp =================================================================== --- sandbox/rick/opt/kernel/classes/RoutineClass.hpp 2008-02-24 01:18:25 UTC (rev 2377) +++ sandbox/rick/opt/kernel/classes/RoutineClass.hpp 2008-02-26 00:29:33 UTC (rev 2378) @@ -51,7 +51,11 @@ public: void *operator new(size_t); inline void *operator new(size_t size, void *ptr) { return ptr; }; - RoutineClass(BaseCode *_code); + RoutineClass(RexxString *n, BaseCode *_code); + RoutineClass(RexxString *name); + RoutineClass(RexxString *name, RexxBuffer *source); + RoutineClass(RexxString *name, const char *data, size_t length); + RoutineClass(RexxString *name, RexxArray *source); inline RoutineClass(RESTORETYPE restoreType) { ; }; void execute(RexxObject *, RexxObject *); @@ -64,6 +68,9 @@ void runProgram(RexxActivity *activity, RexxString * calltype, RexxString * environment, RexxObject **arguments, size_t argCount, ProtectedObject &result); void runProgram(RexxActivity *activity, RexxObject **arguments, size_t argCount, ProtectedObject &result); + RexxObject *callRexx(RexxObject **, size_t); + RexxObject *callWithRexx(RexxArray *); + RexxBuffer *save(); void save(PRXSTRING outBuffer); void save(const char *filename); @@ -81,19 +88,15 @@ static RoutineClass *fromFile(RexxString *filename); static RoutineClass *restoreFromFile(RexxString *filename); - static RoutineClass *newRoutine(RexxSource *); static RoutineClass *newRoutineObject(RexxString *, RexxObject *, RexxObject *, RexxSource *s); - static RoutineClass *newRexxBuffer(RexxString *, RexxBuffer *); - static RoutineClass *newRexxBuffer(RexxString *, const char *, size_t); + static RoutineClass *newRoutineObject(RexxString *, RexxArray *, RexxObject *); - static RoutineClass *newFile(RexxString *); - static RoutineClass *processInstore(PRXSTRING instore, RexxString * name ); static RexxClass *classInstance; }; -inline RoutineClass *new_routine(BaseCode *c) { return new RoutineClass(c); } +inline RoutineClass *new_routine(RexxString *n, BaseCode *c) { return new RoutineClass(n, c); } #endif Modified: sandbox/rick/opt/kernel/parser/Scanner.cpp =================================================================== --- sandbox/rick/opt/kernel/parser/Scanner.cpp 2008-02-24 01:18:25 UTC (rev 2377) +++ sandbox/rick/opt/kernel/parser/Scanner.cpp 2008-02-26 00:29:33 UTC (rev 2378) @@ -118,25 +118,6 @@ } } -RexxSource::RexxSource( - RexxString *programname, /* source program name */ - RexxArray *source_array ) /* program source array */ -/******************************************************************************/ -/* Function: Initialize a source object */ -/******************************************************************************/ -{ - this->clearObject(); /* start completely clean */ - /* fill in the name */ - OrefSet(this, this->programName, programname); - /* fill in the source array */ - OrefSet(this, this->sourceArray, source_array); - if (this->sourceArray) { /* have an array? */ - /* fill in the source size */ - this->line_count = sourceArray->size(); - this->position(1, 0); /* set position at the first line */ - } -} - /********************************************************************* * The following table detects alphanumeric characters and * * special characters that can be part of an REXX symbol. * Modified: sandbox/rick/opt/kernel/parser/SourceFile.cpp =================================================================== --- sandbox/rick/opt/kernel/parser/SourceFile.cpp 2008-02-24 01:18:25 UTC (rev 2377) +++ sandbox/rick/opt/kernel/parser/SourceFile.cpp 2008-02-26 00:29:33 UTC (rev 2378) @@ -43,7 +43,6 @@ /******************************************************************************/ #include <ctype.h> #include <string.h> -#define INCL_REXX_STREAM /* bring in all stream defines */ #include "RexxCore.h" #include "StringClass.hpp" #include "ArrayClass.hpp" @@ -96,6 +95,87 @@ #define line_delimiters "\r\n" /* stream file line end characters */ #define ctrl_z 0x0a // the end of file marker + +/** + * Create a source object with source provided from an array. + * + * @param programname + * The name of the program. + * @param source_array + * The array of the source lines. + */ +RexxSource::RexxSource(RexxString *programname, RexxArray *source_array) +{ + this->clearObject(); /* start completely clean */ + /* fill in the name */ + OrefSet(this, this->programName, programname); + /* fill in the source array */ + OrefSet(this, this->sourceArray, source_array); + /* fill in the source size */ + this->line_count = sourceArray->size(); + this->position(1, 0); /* set position at the first line */ +} + + +/** + * Create a source object with source provided from a buffer. + * + * @param programname + * The name of the program. + * @param source_buffer + * The source buffer holding the source data. + */ +RexxSource::RexxSource(RexxString *programname, RexxBuffer *source_buffer) +{ + this->clearObject(); /* start completely clean */ + /* fill in the name */ + OrefSet(this, this->programName, programname); + // we require a bit of protection while doing this + ProtectedObject p(this); + // initialize from the buffer data + initBuffered(source_buffer); +} + + +/** + * Create a source object with source provided from a a data buffer + * (not a buffer object). + * + * @param programname + * The name of the program. + * @param data The data buffer pointer. + * @param length the size of the source buffer. + */ +RexxSource::RexxSource(RexxString *programname, const char *data, size_t length) +{ + this->clearObject(); /* start completely clean */ + /* fill in the name */ + OrefSet(this, this->programName, programname); + // we require a bit of protection while doing this + ProtectedObject p(this); + // initialize from the buffer data + initBuffered(new_buffer(data, length)); +} + + +/** + * Create a source object with source provided from a filo. + * + * @param programname + * The name of the program (also the file name) + */ +RexxSource::RexxSource(RexxString *programname) +{ + this->clearObject(); /* start completely clean */ + /* fill in the name */ + OrefSet(this, this->programName, programname); + // we require a bit of protection while doing this + ProtectedObject p(this); + // read the file data and initialize. + initFile(); +} + + void RexxSource::initBuffered( RexxBuffer *source_buffer) /* containing source buffer */ /******************************************************************************/ @@ -2745,7 +2825,7 @@ { /* go do the next block of code */ RexxCode *code = this->translateBlock(OREF_NULL); - RoutineClass *routine = new_routine(code); + RoutineClass *routine = new_routine(name, code); /* add to the routine directory */ this->routines->setEntry(name, routine); if (Public == PUBLIC_SCOPE) /* a public routine? */ @@ -5115,48 +5195,7 @@ return newObject; /* return the new object */ } -RexxSource *RexxSource::classNewBuffered( - RexxString *programname, /* name of the program */ - RexxBuffer *source_buffer ) /* buffer containing the source */ -/******************************************************************************/ -/* Function: Create a new source object, using buffered input */ -/******************************************************************************/ -{ - RexxSource *newObject; /* newly created source object */ - ProtectedObject p(source_buffer); - newObject = new RexxSource (programname, OREF_NULL); - ProtectedObject p1(newObject); - /* process the buffering */ - newObject->initBuffered(source_buffer); - return newObject; /* return the new source object */ -} - -RexxSource *RexxSource::classNewBuffered(RexxString *programname, const char *source, size_t length) -{ - RexxSource *newObject = new RexxSource (programname, OREF_NULL); - ProtectedObject p1(newObject); - /* process the buffering */ - newObject->initBuffered(new_buffer(source, length)); - return newObject; /* return the new source object */ -} - -RexxSource *RexxSource::classNewFile( - RexxString *programname ) /* program file name */ -/******************************************************************************/ -/* Function: Create a source object from a file. */ -/******************************************************************************/ -{ - RexxSource *newObject; /* newly created source object */ - - /* create a new source object */ - newObject = new RexxSource (programname, OREF_NULL); - ProtectedObject p(newObject); - newObject->initFile(); /* go process the file */ - return newObject; /* return the new object */ -} - - /** * Generate a code object from a source file. * @@ -5167,13 +5206,11 @@ */ RexxCode *RexxSource::generateCodeFromFile(RexxString *programname ) { - RexxSource *newObject; /* newly created source object */ - - /* create a new source object */ - newObject = new RexxSource (programname, OREF_NULL); - ProtectedObject p(newObject); - newObject->initFile(); /* go process the file */ - return newObject->generateCode(); // generate a code object + // create a new source object from the file + RexxObject *newObject = new RexxSource(programname); + ProtectedObject p(newObject); + // now generate a code object from this file + return newObject->generateCode(); } @@ -5607,3 +5644,25 @@ installed_public_classes->setEntry(name, classObject); } } + + +/** + * Add an installed routine to this source package + * + * @param name The routine name + * @param classObject + * The routine object + * @param publicClass + * Indicates whether this needs to be added to the public list as well. + */ +void RexxSource::addInstalledClass(RexxString *name, RoutineClass *routinebject, bool publicRoutine) +{ + installed_routines->setEntry(name, routinedObject); + if (publicRoutine) + { + installed_public_routines->setEntry(name, routineObject); + } +} + + + Modified: sandbox/rick/opt/kernel/parser/SourceFile.hpp =================================================================== --- sandbox/rick/opt/kernel/parser/SourceFile.hpp 2008-02-24 01:18:25 UTC (rev 2377) +++ sandbox/rick/opt/kernel/parser/SourceFile.hpp 2008-02-26 00:29:33 UTC (rev 2378) @@ -98,6 +98,9 @@ inline void operator delete(void *) { ; } inline void operator delete(void *, void *) { ; } RexxSource(RexxString *, RexxArray *); + RexxSource(RexxString *programname, RexxBuffer *source_buffer); + RexxSource(RexxString *programname, const char *data, size_t length); + RexxSource(RexxString *programname); inline RexxSource(RESTORETYPE restoreType) { ; }; void initBuffered(RexxBuffer *); void initFile(); @@ -221,9 +224,6 @@ void errorPosition(int, RexxToken *); void errorToken(int, RexxToken *); void blockError(RexxInstruction *); - static RexxSource *classNewBuffered(RexxString *, RexxBuffer *); - static RexxSource *classNewBuffered(RexxString *, const char *, size_t length); - static RexxSource *classNewFile(RexxString *); static RexxCode *generateCodeFromFile(RexxString *); RexxObject *sourceNewObject(size_t, RexxBehaviour *, int); void parseTraceSetting(RexxString *, size_t *, size_t *); @@ -337,6 +337,7 @@ } void addInstalledClass(RexxString *name, RexxClass *classObject, bool publicClass); + void addInstalledRoutine(RexxString *name, RoutineClass *routineObject, bool publicRoutine); RexxDirectory *getInstalledClasses() { return installed_classes; } RexxDirectory *getInstalledPublicClasses() { return installed_public_classes; } Modified: sandbox/rick/opt/kernel/runtime/LibraryPackage.cpp =================================================================== --- sandbox/rick/opt/kernel/runtime/LibraryPackage.cpp 2008-02-24 01:18:25 UTC (rev 2377) +++ sandbox/rick/opt/kernel/runtime/LibraryPackage.cpp 2008-02-26 00:29:33 UTC (rev 2378) @@ -257,23 +257,24 @@ // convert them to uppercase because "normal" Rexx function names // tend to be uppercase. RexxString *target = new_upper_string(table->name)->upper(); + RexxString *routineName = new_string(table->name); RexxRoutine *func = OREF_NULL; if (table->style == ROUTINE_CLASSIC_STYLE) { - func = new RegisteredRoutine(libraryName, new_string(table->name), (PREGISTEREDROUTINE)table->entryPoint); + func = new RegisteredRoutine(libraryName, routineName, (PREGISTEREDROUTINE)table->entryPoint); } else { - func = new RexxNativeRoutine(libraryName, new_string(table->name), (PNATIVEROUTINE)table->entryPoint); + func = new RexxNativeRoutine(libraryName, routineName, (PNATIVEROUTINE)table->entryPoint); } - RoutineClass *routine = new_routine(func); + RoutineClass *routine = new_routine(name, func); // add this to our local table routines->put(routine, target); // add this to the global function pool - PackageManager::addPackageRoutine(target, new_routine(func)); + PackageManager::addPackageRoutine(target, routine); // step to the next table entry table++; } Modified: sandbox/rick/opt/kernel/runtime/PackageManager.cpp =================================================================== --- sandbox/rick/opt/kernel/runtime/PackageManager.cpp 2008-02-24 01:18:25 UTC (rev 2377) +++ sandbox/rick/opt/kernel/runtime/PackageManager.cpp 2008-02-26 00:29:33 UTC (rev 2378) @@ -573,20 +573,15 @@ return OREF_NULL; } + // first check this using the specified name. Since we need to perform checks in the // macro space, it's possible this will be loaded under the simple name. We'll need to check // table again using the fully resolved name afterward. - WeakReference *requiresRef = (WeakReference *)loadedRequires->get(shortName); - if (requiresRef != OREF_NULL) + + PackageClass *package = checkRequiresCache(shortName, result); + if (package != OREF_NULL) { - PackageClass *resolved = (PackageClass *)requiresRef->get(); - if (resolved != OREF_NULL) - { - result = resolved; - return resolved; - } - // this was garbage collected, remove it from the table - loadedRequires->remove(shortName); + return package; } unsigned short macroPosition; // a macrospace position marker @@ -612,21 +607,14 @@ } - // first check this using the specified name. Since we need to perform checks in the - // macro space, it's possible this will be loaded under the simple name. We'll need to check - // table again using the fully resolved name afterward. - requiresRef = (WeakReference *)loadedRequires->get(resolvedName); - if (requiresRef != OREF_NULL) + // now check again using the longer name + package = checkRequiresCache(resolvedName, result); + if (package != OREF_NULL) { - PackageClass *resolved = (PackageClass *)requiresRef->get(); - if (resolved != OREF_NULL) - { - result = resolved; - return resolved; - } - // this was garbage collected, remove it from the table - loadedRequires->remove(resolvedName); + return package; } + + // load the file version of this. return getRequiresFile(activity, resolvedName, securityManager, result); } @@ -717,7 +705,64 @@ */ PackageClass *PackageManager::loadRequires(RexxActivity *activity, RexxString *name, const char *data, size_t length, ProtectedObject &result) { + // first check this using the specified name. + PackageClass *resolved = checkRequiresCache(name, result); + if (resolved != OREF_NULL) + { + return resolved; + } + RoutineClass *code = RoutineClass::newRexxBuffer(name, data, length); + PackageClass *package = code->getPackage(); + result = package; + + runRequires(activity, name, code); + + + WeakReference *ref = new WeakReference(package); + loadedRequires->put(ref, name); + return package; +} + + +/** + * Loade a requires file from an array source. NOTE: This is + * not cached like the other requires files + * + * @param activity The current activity. + * @param name The fully resolved file name. + * @param result The return routine object. + * + * @return The return Routine instance. + */ +PackageClass *PackageManager::loadRequires(RexxActivity *activity, RexxString *name, RexxArray *data, ProtectedObject &result) +{ + // first check this using the specified name. + PackageClass *resolved = checkRequiresCache(name, result); + if (resolved == OREF_NULL) + { + RoutineClass *code = RoutineClass::newRexxObject(name, data); + resolved = code->getPackage(); + result = resolved; + + runRequires(activity, name, code); + + WeakReference *ref = new WeakReference(resolved); + loadedRequires->put(ref, name); + } + return resolved; +} + + +/** + * Check for a package already in the requires cache. + * + * @param name The name of the target. + * + * @return The PackageClass instance, if any. + */ +PackageClass *checkRequiresCache(RexxString *name, ProtectedObject &result) +{ // first check this using the specified name. Since we need to perform checks in the // macro space, it's possible this will be loaded under the simple name. We'll need to check // table again using the fully resolved name afterward. @@ -733,17 +778,7 @@ // this was garbage collected, remove it from the table loadedRequires->remove(name); } - - RoutineClass *code = RoutineClass::newRexxBuffer(name, data, length); - PackageClass *package = code->getPackage(); - result = package; - - runRequires(activity, name, code); - - - WeakReference *ref = new WeakReference(package); - loadedRequires->put(ref, name); - return package; + return OREF_NULL; } Modified: sandbox/rick/opt/kernel/runtime/PackageManager.hpp =================================================================== --- sandbox/rick/opt/kernel/runtime/PackageManager.hpp 2008-02-24 01:18:25 UTC (rev 2377) +++ sandbox/rick/opt/kernel/runtime/PackageManager.hpp 2008-02-26 00:29:33 UTC (rev 2378) @@ -90,6 +90,7 @@ static PackageClass *getRequiresFile(RexxActivity *activity, RexxString *name, RexxObject *securityManager, ProtectedObject &result); static void runRequires(RexxActivity *activity, RexxString *name, RoutineClass *code); static PackageClass *loadRequires(RexxActivity *activity, RexxString *name, const char *data, size_t length, ProtectedObject &result); + static PackageClass *loadRequires(RexxActivity *activity, RexxString *name, RexxArray *data, ProtectedObject &result); protected: enum Modified: sandbox/rick/opt/kernel/runtime/RexxBehaviour.cpp =================================================================== --- sandbox/rick/opt/kernel/runtime/RexxBehaviour.cpp 2008-02-24 01:18:25 UTC (rev 2377) +++ sandbox/rick/opt/kernel/runtime/RexxBehaviour.cpp 2008-02-26 00:29:33 UTC (rev 2378) @@ -229,6 +229,24 @@ } +/** + * Define a native kernel method on this behaviour. + * + * @param name The method name. + * @param entryPoint The method entry point + * @param arguments The argument definition. + * + * @return The created method object. + */ +RexxMethod *RexxBehaviour::define(const char *name, PCPPM entryPoint, size_t arguments) +{ + RexxString *name = RexxMemory::getGlobalName(name); + RexxMethod *method = new RexxMethod(name, CPPCode::resolveExportedMethod(entryPoint, arguments)); + define(name, method); + return method; +} + + RexxObject *RexxBehaviour::define( RexxString *methodName, /* name of the defined method */ RexxMethod *method) /* method to add to the behaviour */ Modified: sandbox/rick/opt/kernel/runtime/RexxBehaviour.hpp =================================================================== --- sandbox/rick/opt/kernel/runtime/RexxBehaviour.hpp 2008-02-24 01:18:25 UTC (rev 2377) +++ sandbox/rick/opt/kernel/runtime/RexxBehaviour.hpp 2008-02-26 00:29:33 UTC (rev 2378) @@ -63,6 +63,7 @@ RexxObject *copy(); void copyBehaviour(RexxBehaviour *source); RexxObject *define(RexxString *, RexxMethod *); + RexxMethod *define(const char *, PCPPM, size_t); void addMethod(RexxString *, RexxMethod *); void removeMethod(RexxString *); RexxMethod *methodObject(RexxString *); Modified: sandbox/rick/opt/kernel/runtime/RexxConstants.hpp =================================================================== --- sandbox/rick/opt/kernel/runtime/RexxConstants.hpp 2008-02-24 01:18:25 UTC (rev 2377) +++ sandbox/rick/opt/kernel/runtime/RexxConstants.hpp 2008-02-26 00:29:33 UTC (rev 2378) @@ -62,6 +62,10 @@ CHARCONSTANT(ACTIVITY, "ACTIVITY"); CHARCONSTANT(ADD, "ADD"); CHARCONSTANT(ADDCLASS, "ADDCLASS"); +CHARCONSTANT(ADDROUTINE, "ADDROUTINE"); +CHARCONSTANT(ADDPUBLICCLASS, "ADDPUBLICCLASS"); +CHARCONSTANT(ADDPUBLICROUTINE, "ADDPUBLICROUTINE"); +CHARCONSTANT(ADDPACKAGE, "ADDPACKAGE"); CHARCONSTANT(ADDITIONAL, "ADDITIONAL"); CHARCONSTANT(ALLAT, "ALLAT"); CHARCONSTANT(ALLINDEX, "ALLINDEX"); @@ -81,6 +85,7 @@ CHARCONSTANT(BLANK, " "); CHARCONSTANT(BUFFER, "BUFFER"); CHARCONSTANT(CALL, "CALL"); +CHARCONSTANT(CALLWITH, "CALLWITH"); CHARCONSTANT(CASELESSCOMPARETO, "CASELESSCOMPARETO"); CHARCONSTANT(CASELESSCOMPARE, "CASELESSCOMPARE"); CHARCONSTANT(CASELESSEQUALS, "CASELESSEQUALS"); @@ -90,6 +95,7 @@ CHARCONSTANT(CASELESSPOS, "CASELESSPOS"); CHARCONSTANT(CHAR, "CHAR"); CHARCONSTANT(CLASS, "CLASS"); +CHARCONSTANT(CLASSES, "CLASSES"); CHARCONSTANT(CLOSE, "CLOSE"); CHARCONSTANT(CODE, "CODE"); CHARCONSTANT(COMMAND, "COMMAND"); @@ -105,6 +111,7 @@ CHARCONSTANT(DECODEBASE64, "DECODEBASE64"); CHARCONSTANT(DEFAULTNAME, "DEFAULTNAME"); CHARCONSTANT(DEFINE, "DEFINE"); +CHARCONSTANT(DEFINEDMETHODS, "DEFINEDMETHODS"); CHARCONSTANT(DEFINE_METHODS, "!DEFINE_METHODS"); CHARCONSTANT(DELAY, "DELAY"); CHARCONSTANT(DELETE, "DELETE"); @@ -131,6 +138,8 @@ CHARCONSTANT(FALSE, "FALSE"); CHARCONSTANT(FILE, "FILE"); CHARCONSTANT(FILESYSTEM, "FILESYSTEM"); +CHARCONSTANT(FINDCLASS, "FINDCLASS"); +CHARCONSTANT(FINDROUTINE, "FINDROUTINE"); CHARCONSTANT(FIRST, "FIRST"); CHARCONSTANT(FIRSTITEM, "FIRSTITEM"); CHARCONSTANT(FORWARD, "FORWARD"); @@ -139,6 +148,7 @@ CHARCONSTANT(GUARDED, "GUARDED"); CHARCONSTANT(GET, "GET"); CHARCONSTANT(GETBUFFERSIZE, "GETBUFFERSIZE"); +CHARCONSTANT(GETDEFINEDMETHODS, "GETDEFINEDMETHODS"); CHARCONSTANT(GLOBAL_STRINGS, "GLOBAL_STRINGS"); CHARCONSTANT(HALT, "HALT"); CHARCONSTANT(HASENTRY, "HASENTRY"); @@ -147,6 +157,9 @@ CHARCONSTANT(HASITEM, "HASITEM"); CHARCONSTANT(HASMETHOD, "HASMETHOD"); CHARCONSTANT(ID, "ID"); +CHARCONSTANT(IMPORTEDCLASSES, IMPORTEDCLASSES); +CHARCONSTANT(IMPORTEDPACKAGES, IMPORTEDPACKAGES); +CHARCONSTANT(IMPORTEDROUTINES, IMPORTEDROUTINES); CHARCONSTANT(INDEX, "INDEX"); CHARCONSTANT(INHERIT, "INHERIT"); CHARCONSTANT(INIT, "INIT"); @@ -173,6 +186,7 @@ CHARCONSTANT(LIST, "LIST"); CHARCONSTANT(LIT, "LIT"); CHARCONSTANT(LOCAL, "LOCAL"); +CHARCONSTANT(LOADPACKAGE, "LOADPACKAGE"); CHARCONSTANT(LOSTDIGITS, "LOSTDIGITS"); CHARCONSTANT(MAKE, "MAKE"); CHARCONSTANT(MAKEARRAY, "MAKEARRAY"); @@ -218,6 +232,7 @@ CHARCONSTANT(ON, "ON"); CHARCONSTANT(ORDEREDCOLLECTION, "ORDEREDCOLLECTION"); CHARCONSTANT(OUTPUT, "OUTPUT"); +CHARCONSTANT(PACKAGE, "PACKAGE"); CHARCONSTANT(PARSE, "PARSE"); CHARCONSTANT(PEEK, "PEEK"); CHARCONSTANT(PERIOD, "."); @@ -229,6 +244,8 @@ CHARCONSTANT(PROPAGATED, "PROPAGATED"); CHARCONSTANT(PROTECTED, "PROTECTED"); CHARCONSTANT(PUBLIC, "PUBLIC"); +CHARCONSTANT(PUBLICCLASSES, "PUBLICCLASSES"); +CHARCONSTANT(PUBLICROUTINES, "PUBLICROUTINES"); CHARCONSTANT(PUT, "PUT"); CHARCONSTANT(QUEUE, "QUEUE"); CHARCONSTANT(QUEUEEXIT, "!QUEUEEXIT"); @@ -437,6 +454,7 @@ CHARCONSTANT(SAY, "SAY"); CHARCONSTANT(SIGN, "SIGN"); CHARCONSTANT(SOURCELINE, "SOURCELINE"); +CHARCONSTANT(SOURCESIZE, "SOURCESIZE"); CHARCONSTANT(SPACE, "SPACE"); CHARCONSTANT(STREAM, "STREAM"); CHARCONSTANT(STRIP, "STRIP"); Modified: sandbox/rick/opt/kernel/runtime/RexxCore.h =================================================================== --- sandbox/rick/opt/kernel/runtime/RexxCore.h 2008-02-24 01:18:25 UTC (rev 2377) +++ sandbox/rick/opt/kernel/runtime/RexxCore.h 2008-02-26 00:29:33 UTC (rev 2378) @@ -322,15 +322,18 @@ return (isOfClass(String, object) ? (RexxString *)object : (object)->requestString()); } + /* The next routine is specifically for REQUESTing a STRING needed as a method*/ /* argument. This raises an error if the object cannot be converted to a */ /* string value. */ inline RexxString * REQUIRED_STRING(RexxObject *object, size_t position) { - if (object == OREF_NULL) /* missing argument? */ - missing_argument(position); /* raise an error */ - /* force to a string value */ - return object->requiredString(position); + if (object == OREF_NULL) /* missing argument? */ + { + missing_argument(position); /* raise an error */ + } + /* force to a string value */ + return object->requiredString(position); } @@ -341,22 +344,53 @@ /* single dimensional array item */ inline RexxArray * REQUIRED_ARRAY(RexxObject *object, size_t position) { - if (object == OREF_NULL) /* missing argument? */ - { - missing_argument(position); /* raise an error */ - } - /* force to array form */ - RexxArray *array = object->requestArray(); - /* not an array? */ - if (array == TheNilObject || array->getDimension() != 1) - { - /* raise an error */ - reportException(Error_Execution_noarray, object); - } - return array; + if (object == OREF_NULL) /* missing argument? */ + { + missing_argument(position); /* raise an error */ + } + /* force to array form */ + RexxArray *array = object->requestArray(); + /* not an array? */ + if (array == TheNilObject || array->getDimension() != 1) + { + /* raise an error */ + reportException(Error_Execution_noarray, object); + } + return array; } +/* The next routine is specifically for REQUESTing a STRING needed as a method*/ +/* argument. This raises an error if the object cannot be converted to a */ +/* string value. */ +inline RexxString * REQUIRED_STRING(RexxObject *object, const char *name) +{ + if (object == OREF_NULL) /* missing argument? */ + { + reportException(Error_Invalid_argument_noarg, name); + } + /* force to a string value */ + return object->requiredString(name); +} + + +/* The next routine is specifically for REQUESTing a STRING needed as a method*/ +/* argument. This raises an error if the object cannot be converted to a */ +/* string value. */ +inline void REQUIRED_INSTANCE(RexxObject *object, RexxClass *clazz, const char *name) +{ + if (object == OREF_NULL) /* missing argument? */ + { + reportException(Error_Invalid_argument_noarg, name); + } + + if (!object->isInstanceOf(clazz)) + { + reportException(Error_Invalid_argument_noclass, name, clazz->getId()); + } +} + + /* The next macro is specifically for REQUESTing an ARRAY, since there are */ /* six primitive classes that can produce array equivalents. It will trap on */ /* OREF_NULL. */ Modified: sandbox/rick/opt/kernel/runtime/RexxMemory.hpp =================================================================== --- sandbox/rick/opt/kernel/runtime/RexxMemory.hpp 2008-02-24 01:18:25 UTC (rev 2377) +++ sandbox/rick/opt/kernel/runtime/RexxMemory.hpp 2008-02-26 00:29:33 UTC (rev 2378) @@ -328,12 +328,9 @@ bool objectReferenceOK(RexxObject *o); void restoreImage(); - static RexxMethod *createKernelMethod(PCPPM entryPoint, size_t arguments); - static RexxMethod *createProtectedKernelMethod(PCPPM entryPoint, size_t arguments); - static RexxMethod *createPrivateKernelMethod(PCPPM entryPoint, size_t arguments); - static void defineKernelMethod(const char *name, RexxBehaviour * behaviour, PCPPM entryPoint, size_t arguments); - static void defineProtectedKernelMethod(const char *name, RexxBehaviour * behaviour, PCPPM entryPoint, size_t arguments); - static void definePrivateKernelMethod(const char *name, RexxBehaviour * behaviour, PCPPM entryPoint, size_t arguments); + static void defineKernelMethod(const char *name, RexxBehaviour * behaviour, PCPPM entryPoint, size_t arguments); + static void defineProtectedKernelMethod(const char *name, RexxBehaviour * behaviour, PCPPM entryPoint, size_t arguments); + static void definePrivateKernelMethod(const char *name, RexxBehaviour * behaviour, PCPPM entryPoint, size_t arguments); RexxStack *liveStack; RexxStack *flattenStack; Modified: sandbox/rick/opt/kernel/runtime/Setup.cpp =================================================================== --- sandbox/rick/opt/kernel/runtime/Setup.cpp 2008-02-24 01:18:25 UTC (rev 2377) +++ sandbox/rick/opt/kernel/runtime/Setup.cpp 2008-02-26 00:29:33 UTC (rev 2378) @@ -81,52 +81,10 @@ #include "CPPCode.hpp" #include "Interpreter.hpp" #include "InterpreterInstance.hpp" +#include "PackageManager.hpp" +#include "PackageClass.hpp" -/*****************************************************************************/ -/* Initialisation and build of the Object REXX image */ -/*****************************************************************************/ - -RexxMethod *RexxMemory::createKernelMethod( - PCPPM entryPoint, /* method entry point */ - size_t arguments) /* count of arguments */ -/******************************************************************************/ -/* Function: Create a primitive, C++ method object */ -/******************************************************************************/ -{ - /* create a new kernel method */ - return new RexxMethod(CPPCode::resolveExportedMethod(entryPoint, arguments)); -} - -RexxMethod *RexxMemory::createProtectedKernelMethod( - PCPPM entryPoint, /* method entry point */ - size_t arguments) /* count of arguments */ -/******************************************************************************/ -/* Function: Create a primitive, C++ method object */ -/******************************************************************************/ -{ - RexxMethod *method; /* created method */ - /* create a new kernel method */ - method = new RexxMethod(CPPCode::resolveExportedMethod(entryPoint, arguments)); - method->setProtected(); /* make this protected */ - return method; /* return the method */ -} - -RexxMethod *RexxMemory::createPrivateKernelMethod( - PCPPM entryPoint, /* method entry point */ - size_t arguments) /* count of arguments */ -/******************************************************************************/ -/* Function: Create a primitive, C++ method object */ -/******************************************************************************/ -{ - RexxMethod *method; /* created method */ - /* create a new kernel method */ - method = new RexxMethod(CPPCode::resolveExportedMethod(entryPoint, arguments)); - method->setProtected(); /* make this protected */ - method->setPrivate(); /* and private */ - return method; /* return the method */ -} - void RexxMemory::defineKernelMethod( const char * name, /* ASCII-Z name for the method */ RexxBehaviour * behaviour, /* behaviour to use */ @@ -136,7 +94,7 @@ /* Function: Add a C++ method to an object's behaviour */ /******************************************************************************/ { - behaviour->define(getGlobalName(name), createKernelMethod(entryPoint, arguments)); + behaviour->define(name, entryPoint, arguments); } void RexxMemory::defineProtectedKernelMethod( @@ -148,9 +106,11 @@ /* Function: Add a C++ method to an object's behaviour */ /******************************************************************************/ { - behaviour->define(getGlobalName(name), createProtectedKernelMethod(entryPoint, arguments)); + RexxMethod *method = behaviour->define(name, entryPoint, arguments); + method->setProtected(); /* make this protected */ } + void RexxMemory::definePrivateKernelMethod( const char * name, /* ASCII-Z name for the method */ RexxBehaviour * behaviour, /* behaviour to use */ @@ -160,7 +120,9 @@ /* Function: Add a C++ method to an object's behaviour */ /******************************************************************************/ { - behaviour->define(getGlobalName(name), createPrivateKernelMethod(entryPoint, arguments)); + RexxMethod *method = behaviour->define(name, entryPoint, arguments); + method->setProtected(); /* make this protected */ + method->setPrivate(); /* make this protected */ } @@ -567,6 +529,7 @@ defineProtectedKernelMethod(CHAR_SETPROTECTED ,TheMethodBehaviour, CPPM(RexxMethod::setProtectedRexx), 0); defineProtectedKernelMethod(CHAR_SETSECURITYMANAGER ,TheMethodBehaviour, CPPM(RexxMethod::setSecurityManager), 1); defineKernelMethod(CHAR_SOURCE ,TheMethodBehaviour, CPPM(BaseExecutable::source), 0); + defineKernelMethod(CHAR_PACKAGE ,TheMethodBehaviour, CPPM(BaseExecutable::getPackage), 0); /* set the scope of the methods to */ /* this classes oref */ TheMethodBehaviour->setMethodDictionaryScope(TheMethodClass); @@ -591,6 +554,9 @@ /* instance behaviour mdict */ defineProtectedKernelMethod(CHAR_SETSECURITYMANAGER ,TheRoutineBehaviour, CPPM(RoutineClass::setSecurityManager), 1); defineKernelMethod(CHAR_SOURCE ,TheRoutineBehaviour, CPPM(BaseExecutable::source), 0); + defineKernelMethod(CHAR_PACKAGE ,TheRoutineBehaviour, CPPM(BaseExecutable::getPackage), 0); + defineKernelMethod(CHAR_CALL ,TheRoutineBehaviour, CPPM(RoutineClass::callRexx), A_COUNT); + defineKernelMethod(CHAR_CALLWITH ,TheRoutineBehaviour, CPPM(RoutineClass::callWithRexx), 1); /* set the scope of the methods to */ /* this classes oref */ TheRoutineBehaviour->setMethodDictionaryScope(TheRoutineClass); @@ -599,7 +565,48 @@ /* method */ TheRoutineClass->subClassable(true); + /***************************************************************************/ + /* Package */ + /***************************************************************************/ + + /* Add the NEW methods to the */ + /* class behaviour */ + defineKernelMethod(CHAR_NEW , ThePackageClassBehaviour, CPPM(PackageClass::newRexx), A_COUNT); + /* set the scope of the methods to */ + /* this classes oref */ + ThePackageClassBehaviour->setMethodDictionaryScope(ThePackageClass); + + /* Add the instance methods to the */ + /* instance behaviour mdict */ + defineProtectedKernelMethod(CHAR_SETSECURITYMANAGER ,ThePackageBehaviour, CPPM(PackageClass::setSecurityManager), 1); + defineKernelMethod(CHAR_SOURCE ,ThePackageBehaviour, CPPM(PackageClass::getSource), 0); + defineKernelMethod(CHAR_SOURCELINE ,ThePackageBehaviour, CPPM(PackageClass::getSourceLineRexx), 1); + defineKernelMethod(CHAR_SOURCESIZE ,ThePackageBehaviour, CPPM(PackageClass::getSourceSize), 0); + defineKernelMethod(CHAR_CLASSES ,ThePackageBehaviour, CPPM(PackageClass::getClasses), 0); + defineKernelMethod(CHAR_PUBLICCLASSES ,ThePackageBehaviour, CPPM(PackageClass::getPublicClasses), 0); + defineKernelMethod(CHAR_IMPORTEDCLASSES ,ThePackageBehaviour, CPPM(PackageClass::getImportedClasses), 0); + defineKernelMethod(CHAR_DEFINEDMETHODS, ThePackageBehaviour, CPPM(PackageClass::getMethods), 0); + defineKernelMethod(CHAR_ROUTINES ,ThePackageBehaviour, CPPM(PackageClass::getRoutines), 0); + defineKernelMethod(CHAR_PUBLICROUTINES ,ThePackageBehaviour, CPPM(PackageClass::getPublicRoutines), 0); + defineKernelMethod(CHAR_IMPORTEDPACKAGES ,ThePackageBehaviour, CPPM(PackageClass::getImportedPackages), 0); + defineKernelMethod(CHAR_LOADPACKAGE ,ThePackageBehaviour, CPPM(PackageClass::loadPackage), 2); + defineKernelMethod(CHAR_ADDPACKAGE ,ThePackageBehaviour, CPPM(PackageClass::addPackage), 1); + defineKernelMethod(CHAR_FINDCLASS ,ThePackageBehaviour, CPPM(PackageClass::findClass), 1); + defineKernelMethod(CHAR_FINDROUTINE ,ThePackageBehaviour, CPPM(PackageClass::findRoutine), 1); + defineKernelMethod(CHAR_ADDROUTINE ,ThePackageBehaviour, CPPM(PackageClass::addRoutine), 2); + defineKernelMethod(CHAR_ADDPUBLICROUTINE ,ThePackageBehaviour, CPPM(PackageClass::addPublicRoutine), 2); + defineKernelMethod(CHAR_ADDCLASS ,ThePackageBehaviour, CPPM(PackageClass::addClass), 2); + defineKernelMethod(CHAR_ADDPUBLICCLASS ,ThePackageBehaviour, CPPM(PackageClass::addPublicClass), 2); + /* set the scope of the methods to */ + /* this classes oref */ + ThePackageBehaviour->setMethodDictionaryScope(ThePackageClass); + + /* Now call the class subclassable */ + /* method */ + ThePackageClass->subClassable(true); + + /***************************************************************************/ /* QUEUE */ /***************************************************************************/ @@ -1239,7 +1246,7 @@ /* create a kernel methods directory */ RexxDirectory *kernel_methods = new_directory(); ProtectedObject p1(kernel_methods); // protect from GC - kernel_methods->put(createKernelMethod(CPPM(RexxLocal::local), 0), getGlobalName(CHAR_LOCAL)); + kernel_methods->put(new RexxMethod(getGlobalName(CHAR_LOCAL), CPPCode::resolveExportedMethod(CPPM(RexxLocal::local), 0)), getGlobalName(CHAR_LOCAL)); /* create the BaseClasses method and run it*/ RexxString *symb = getGlobalName(BASEIMAGELOAD); /* get a name version of the string */ @@ -1250,7 +1257,7 @@ try { /* create a method object out of this*/ - RoutineClass *loader = RoutineClass::newFile(programName); + RoutineClass *loader = new RoutineClass(programName); RexxObject *args = kernel_methods; // temporary to avoid type-punning warnings This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bigrixx@us...> - 2008-02-28 01:20:35
|
Revision: 2379 http://oorexx.svn.sourceforge.net/oorexx/?rev=2379&view=rev Author: bigrixx Date: 2008-02-27 17:20:41 -0800 (Wed, 27 Feb 2008) Log Message: ----------- incremental checkin Modified Paths: -------------- sandbox/rick/opt/kernel/api/MethodContextStubs.cpp sandbox/rick/opt/kernel/api/ThreadContextStubs.cpp sandbox/rick/opt/kernel/classes/ArrayClass.cpp sandbox/rick/opt/kernel/classes/ArrayClass.hpp sandbox/rick/opt/kernel/classes/BufferClass.cpp sandbox/rick/opt/kernel/classes/ClassClass.cpp sandbox/rick/opt/kernel/classes/DirectoryClass.cpp sandbox/rick/opt/kernel/classes/DirectoryClass.hpp sandbox/rick/opt/kernel/classes/IntegerClass.cpp sandbox/rick/opt/kernel/classes/IntegerClass.hpp sandbox/rick/opt/kernel/classes/ListClass.cpp sandbox/rick/opt/kernel/classes/ListClass.hpp sandbox/rick/opt/kernel/classes/MessageClass.cpp sandbox/rick/opt/kernel/classes/MessageClass.hpp sandbox/rick/opt/kernel/classes/MethodClass.cpp sandbox/rick/opt/kernel/classes/MethodClass.hpp sandbox/rick/opt/kernel/classes/MutableBufferClass.cpp sandbox/rick/opt/kernel/classes/MutableBufferClass.hpp sandbox/rick/opt/kernel/classes/NumberStringClass.cpp sandbox/rick/opt/kernel/classes/NumberStringClass.hpp sandbox/rick/opt/kernel/classes/NumberStringMath.cpp sandbox/rick/opt/kernel/classes/NumberStringMath2.cpp sandbox/rick/opt/kernel/classes/ObjectClass.cpp sandbox/rick/opt/kernel/classes/ObjectClass.hpp sandbox/rick/opt/kernel/classes/PackageClass.cpp sandbox/rick/opt/kernel/classes/PackageClass.hpp sandbox/rick/opt/kernel/classes/QueueClass.cpp sandbox/rick/opt/kernel/classes/QueueClass.hpp sandbox/rick/opt/kernel/classes/RelationClass.cpp sandbox/rick/opt/kernel/classes/RelationClass.hpp sandbox/rick/opt/kernel/classes/RoutineClass.cpp sandbox/rick/opt/kernel/classes/RoutineClass.hpp sandbox/rick/opt/kernel/classes/StackClass.cpp sandbox/rick/opt/kernel/classes/StemClass.cpp sandbox/rick/opt/kernel/classes/StemClass.hpp sandbox/rick/opt/kernel/classes/StringClass.cpp sandbox/rick/opt/kernel/classes/StringClass.hpp sandbox/rick/opt/kernel/classes/SupplierClass.cpp sandbox/rick/opt/kernel/classes/SupplierClass.hpp sandbox/rick/opt/kernel/classes/TableClass.cpp sandbox/rick/opt/kernel/classes/TableClass.hpp sandbox/rick/opt/kernel/expression/ExpressionDotVariable.cpp sandbox/rick/opt/kernel/instructions/ClassDirective.cpp sandbox/rick/opt/kernel/parser/SourceFile.cpp sandbox/rick/opt/kernel/parser/SourceFile.hpp sandbox/rick/opt/kernel/runtime/CPPCode.cpp sandbox/rick/opt/kernel/runtime/CreateRoutineDispatcher.cpp sandbox/rick/opt/kernel/runtime/Interpreter.cpp sandbox/rick/opt/kernel/runtime/Interpreter.hpp sandbox/rick/opt/kernel/runtime/LibraryPackage.cpp sandbox/rick/opt/kernel/runtime/MemorySegment.cpp sandbox/rick/opt/kernel/runtime/MemoryStats.cpp sandbox/rick/opt/kernel/runtime/PackageManager.cpp sandbox/rick/opt/kernel/runtime/PackageManager.hpp sandbox/rick/opt/kernel/runtime/RexxActivation.cpp sandbox/rick/opt/kernel/runtime/RexxActivation.hpp sandbox/rick/opt/kernel/runtime/RexxActivationStack.cpp sandbox/rick/opt/kernel/runtime/RexxBehaviour.cpp sandbox/rick/opt/kernel/runtime/RexxCode.hpp sandbox/rick/opt/kernel/runtime/RexxCollection.cpp sandbox/rick/opt/kernel/runtime/RexxCompoundElement.cpp sandbox/rick/opt/kernel/runtime/RexxCompoundTable.cpp sandbox/rick/opt/kernel/runtime/RexxCompoundTail.cpp sandbox/rick/opt/kernel/runtime/RexxConstants.hpp sandbox/rick/opt/kernel/runtime/RexxCore.h sandbox/rick/opt/kernel/runtime/RexxEnvelope.cpp sandbox/rick/opt/kernel/runtime/RexxHashTable.cpp sandbox/rick/opt/kernel/runtime/RexxListTable.cpp sandbox/rick/opt/kernel/runtime/RexxLocalVariables.cpp sandbox/rick/opt/kernel/runtime/RexxMemory.cpp sandbox/rick/opt/kernel/runtime/RexxNativeActivation.cpp sandbox/rick/opt/kernel/runtime/RexxNativeActivation.hpp sandbox/rick/opt/kernel/runtime/RexxNativeCode.cpp sandbox/rick/opt/kernel/runtime/RexxNativeCode.hpp sandbox/rick/opt/kernel/runtime/RexxSmartBuffer.cpp sandbox/rick/opt/kernel/runtime/RexxStartDispatcher.cpp sandbox/rick/opt/kernel/runtime/RexxVariable.cpp sandbox/rick/opt/kernel/runtime/RexxVariableDictionary.cpp sandbox/rick/opt/kernel/runtime/Setup.cpp sandbox/rick/opt/kernel/runtime/TranslateDispatcher.cpp Modified: sandbox/rick/opt/kernel/api/MethodContextStubs.cpp =================================================================== --- sandbox/rick/opt/kernel/api/MethodContextStubs.cpp 2008-02-26 00:29:33 UTC (rev 2378) +++ sandbox/rick/opt/kernel/api/MethodContextStubs.cpp 2008-02-28 01:20:41 UTC (rev 2379) @@ -233,7 +233,7 @@ { // convert the name to a string instance, and check the environments. RexxString *name = new_upper_string(n); - return (RexxClassObject)context.ret(context.context->resolveClass(name)); + return (RexxClassObject)context.ret(context.context->findClass(name)); } catch (ActivityException) { Modified: sandbox/rick/opt/kernel/api/ThreadContextStubs.cpp =================================================================== --- sandbox/rick/opt/kernel/api/ThreadContextStubs.cpp 2008-02-26 00:29:33 UTC (rev 2378) +++ sandbox/rick/opt/kernel/api/ThreadContextStubs.cpp 2008-02-28 01:20:41 UTC (rev 2379) @@ -316,7 +316,7 @@ { // convert the name to a string instance, and check the environments. RexxString *name = new_upper_string(n); - return (RexxClassObject)context.ret(context.context->resolveClass(name)); + return (RexxClassObject)context.ret(context.context->findClass(name)); } catch (ActivityException) @@ -333,7 +333,7 @@ { // convert the name to a string instance, and check the environments. RexxString *name = new_upper_string(n); - return (RexxClassObject)context.ret(((PackageClass *)m)->resolveClass(name)); + return (RexxClassObject)context.ret(((PackageClass *)m)->findClass(name)); } catch (ActivityException) @@ -421,7 +421,7 @@ try { // convert the name to a string instance, and check the environments. - return (RexxMethodObject)context.ret(RexxMethod::newRexxBuffer(name, source, length)); + return (RexxMethodObject)context.ret(new RexxMethod(new_string(name), source, length)); } catch (ActivityException) { @@ -436,7 +436,7 @@ try { // convert the name to a string instance, and check the environments. - return (RexxRoutineObject)context.ret(RoutineClass::newRexxBuffer(new_string(name), source, length)); + return (RexxRoutineObject)context.ret(new RoutineClass(new_string(name), source, length)); } catch (ActivityException) { Modified: sandbox/rick/opt/kernel/classes/ArrayClass.cpp =================================================================== --- sandbox/rick/opt/kernel/classes/ArrayClass.cpp 2008-02-26 00:29:33 UTC (rev 2378) +++ sandbox/rick/opt/kernel/classes/ArrayClass.cpp 2008-02-28 01:20:41 UTC (rev 2379) @@ -84,6 +84,16 @@ RexxArray *RexxArray::nullArray = OREF_NULL; +/** + * Create initial class object at bootstrap time. + */ +void RexxArray::createInstance() +{ + CLASS_CREATE(Array, "Array", RexxClass); + nullArray = new_array((size_t)0); /* set up a null array */ +} + + void RexxArray::init(size_t _size, size_t maxSize) /******************************************************************************/ /* Function: Initialize an array */ @@ -102,21 +112,22 @@ /* Function: create a copy of array and expansion array. */ /******************************************************************************/ { - RexxArray *newArray; /* new array object */ - - /* make a copy of ourself */ - newArray = (RexxArray *) this->RexxObject::copy(); - /* this array contain the data? */ - if (this->expansionArray != OREF_NULL && this->expansionArray != this) { - /* no, make sure we get a copy of */ - /* array containing data. */ - newArray->setExpansion(this->expansionArray->copy()); - } - else - /* no, make sure we get a copy of */ - /* array containing data. */ - newArray->setExpansion(newArray); /* make sure we point to ourself! */ - return (RexxObject *)newArray; /* return the new array */ + /* make a copy of ourself */ + RexxArray *newArray = (RexxArray *) this->RexxObject::copy(); + /* this array contain the data? */ + if (this->expansionArray != OREF_NULL && this->expansionArray != this) + { + /* no, make sure we get a copy of */ + /* array containing data. */ + newArray->setExpansion(this->expansionArray->copy()); + } + else + { + /* no, make sure we get a copy of */ + /* array containing data. */ + newArray->setExpansion(newArray); /* make sure we point to ourself! */ + } + return(RexxObject *)newArray; /* return the new array */ } void RexxArray::live(size_t liveMark) @@ -142,13 +153,11 @@ /* Function: Generalized object marking */ /******************************************************************************/ { - RexxObject **arrayPtr; - memory_mark_general(this->dimensions); memory_mark_general(this->objectVariables); memory_mark_general(this->expansionArray); - for (arrayPtr = this->objects; arrayPtr < this->objects + this->arraySize; arrayPtr++) + for (RexxObject **arrayPtr = this->objects; arrayPtr < this->objects + this->arraySize; arrayPtr++) { memory_mark_general(*arrayPtr); } @@ -161,14 +170,14 @@ { setUpFlatten(RexxArray) - size_t i; + flatten_reference(newThis->dimensions, envelope); + flatten_reference(newThis->objectVariables, envelope); + flatten_reference(newThis->expansionArray, envelope); + for (size_t i = 0; i < this->arraySize; i++) + { + flatten_reference(newThis->objects[i], envelope); + } - flatten_reference(newThis->dimensions, envelope); - flatten_reference(newThis->objectVariables, envelope); - flatten_reference(newThis->expansionArray, envelope); - for (i = 0; i < this->arraySize; i++) - flatten_reference(newThis->objects[i], envelope); - cleanUpFlatten } @@ -178,12 +187,12 @@ /* Function: Place an object in the array */ /******************************************************************************/ { - OrefSet(this->expansionArray, (this->data())[pos -1], eref); - // check the last set element - if (pos > lastElement) - { - lastElement = pos; - } + OrefSet(this->expansionArray, (this->data())[pos -1], eref); + // check the last set element + if (pos > lastElement) + { + lastElement = pos; + } } RexxObject *RexxArray::putRexx(RexxObject **arguments, size_t argCount) @@ -191,20 +200,21 @@ /* Function: Performs REXX-level puts to arrays. */ /******************************************************************************/ { - RexxObject *value; /* assigned value */ - size_t position; /* array position */ + size_t position; /* array position */ - value = arguments[0]; /* get the value to assign */ - /* no real value? */ - if (argCount == 0 || value == OREF_NULL) - /* this is an error */ - missing_argument(ARG_ONE); /* this is an error */ - /* go validate the index */ - /* have array expanded if necessary */ - this->validateIndex(arguments + 1, argCount - 1, 2, RaiseBoundsInvalid | ExtendUpper | RaiseBoundsTooMany, position); + RexxObject *value = arguments[0]; /* get the value to assign */ + /* no real value? */ + if (argCount == 0 || value == OREF_NULL) + { + /* this is an error */ + missing_argument(ARG_ONE); /* this is an error */ + } + /* go validate the index */ + /* have array expanded if necessary */ + this->validateIndex(arguments + 1, argCount - 1, 2, RaiseBoundsInvalid | ExtendUpper | RaiseBoundsTooMany, position); - this->put(value, position); /* set the new value */ - return OREF_NULL; /* Make sure RESULT gets dropped */ + this->put(value, position); /* set the new value */ + return OREF_NULL; /* Make sure RESULT gets dropped */ } @@ -215,7 +225,6 @@ */ RexxObject *RexxArray::empty() { - // if not working with an oldspace object (VERY likely), we can just use memset to clear // everything. if (this->isNewSpace()) @@ -279,20 +288,23 @@ /* Function: Performs REXX-level gets from arrays. */ /******************************************************************************/ { - size_t position; /* array position */ - RexxObject * _result; /* returned result */ + size_t position; /* array position */ + RexxObject * _result; /* returned result */ - /* go validate the index */ - if (!this->validateIndex(arguments, argCount, 1, RaiseBoundsTooMany | RaiseBoundsInvalid, position)) - { - _result = TheNilObject; /* just return .nil */ - } - else { /* return that element */ - _result = *(this->data() + position - 1); - if (_result == OREF_NULL) /* no object there? */ - _result = TheNilObject; /* just return .nil */ - } - return _result; /* return the result */ + /* go validate the index */ + if (!this->validateIndex(arguments, argCount, 1, RaiseBoundsTooMany | RaiseBoundsInvalid, position)) + { + _result = TheNilObject; /* just return .nil */ + } + else + { /* return that element */ + _result = *(this->data() + position - 1); + if (_result == OREF_NULL) /* no object there? */ + { + _result = TheNilObject; /* just return .nil */ + } + } + return _result; /* return the result */ } @@ -359,29 +371,32 @@ /* Function: Remove an item from the array */ /******************************************************************************/ { - RexxObject *result; /* removed object */ + RexxObject *result; /* removed object */ - /* within the bounds? */ - if (_index > 0 && _index <= this->size() && *(this->data() + _index - 1) != OREF_NULL) { - /* get the item */ - result = *(this->data() + _index - 1); - /* clear it out */ - OrefSet(this->expansionArray, *(this->data() + _index - 1), OREF_NULL); - // if we removed the last element, we need to scan backwards to find - // the last one - if (_index == lastElement) + /* within the bounds? */ + if (_index > 0 && _index <= this->size() && *(this->data() + _index - 1) != OREF_NULL) { - // back off at least one position, then scan for the new last one - lastElement--; - while (lastElement != 0 && *(this->data() + lastElement - 1) == OREF_NULL) + /* get the item */ + result = *(this->data() + _index - 1); + /* clear it out */ + OrefSet(this->expansionArray, *(this->data() + _index - 1), OREF_NULL); + // if we removed the last element, we need to scan backwards to find + // the last one + if (_index == lastElement) { + // back off at least one position, then scan for the new last one lastElement--; + while (lastElement != 0 && *(this->data() + lastElement - 1) == OREF_NULL) + { + lastElement--; + } } + return result; /* and return */ } - return result; /* and return */ - } - else - return OREF_NULL; /* return nothing */ + else + { + return OREF_NULL; /* return nothing */ + } } RexxObject *RexxArray::removeRexx(RexxObject **arguments, size_t argCount) @@ -390,32 +405,35 @@ /* is returned if the item does not exist */ /******************************************************************************/ { - RexxObject *result; /* returned result */ - size_t position; /* array position */ + RexxObject *result; /* returned result */ + size_t position; /* array position */ - /* go validate the index */ - if (!this->validateIndex(arguments, argCount, 1, RaiseBoundsTooMany | RaiseBoundsInvalid, position)) - { - result = TheNilObject; /* yup, return .nil. */ - } - else { - /* get the current element */ - result = *(this->data() + position - 1); - /* remove the item from the array */ - OrefSet(this->expansionArray, *(this->data() + position - 1), OREF_NULL); - if (position == lastElement) + /* go validate the index */ + if (!this->validateIndex(arguments, argCount, 1, RaiseBoundsTooMany | RaiseBoundsInvalid, position)) { - // back off at least one position, then scan for the new last one - lastElement--; - while (lastElement != 0 && *(this->data() + lastElement - 1) == OREF_NULL) + result = TheNilObject; /* yup, return .nil. */ + } + else + { + /* get the current element */ + result = *(this->data() + position - 1); + /* remove the item from the array */ + OrefSet(this->expansionArray, *(this->data() + position - 1), OREF_NULL); + if (position == lastElement) { + // back off at least one position, then scan for the new last one lastElement--; + while (lastElement != 0 && *(this->data() + lastElement - 1) == OREF_NULL) + { + lastElement--; + } } + if (result == OREF_NULL) /* no existing value? */ + { + result = TheNilObject; /* return .nil instead */ + } } - if (result == OREF_NULL) /* no existing value? */ - result = TheNilObject; /* return .nil instead */ - } - return result; /* return this value */ + return result; /* return this value */ } size_t RexxArray::numItems(void) @@ -423,19 +441,21 @@ /* Function: Return count of actual items in an array */ /******************************************************************************/ { - size_t count; /* actual count of items in array */ - RexxArray *realArray; /* array item pointer */ + size_t count; /* actual count of items in array */ + RexxArray *realArray; /* array item pointer */ - count = 0; /* no items yet */ - realArray = this->expansionArray; /* Get array with data */ - /* loop through all array items */ - for (size_t i = 0; i < realArray->arraySize; i++) { - /* have a real item here? */ - if (realArray->objects[i] != OREF_NULL) { - count++; /* bump the item counter */ + count = 0; /* no items yet */ + realArray = this->expansionArray; /* Get array with data */ + /* loop through all array items */ + for (size_t i = 0; i < realArray->arraySize; i++) + { + /* have a real item here? */ + if (realArray->objects[i] != OREF_NULL) + { + count++; /* bump the item counter */ + } } - } - return count; /* return the count object */ + return count; /* return the count object */ } RexxObject *RexxArray::items() @@ -454,10 +474,14 @@ /* Function: Query array dimension information */ /******************************************************************************/ { - if (this->dimensions == OREF_NULL) /* no dimensions array? */ - return 1; /* one dimension array */ - else - return this->dimensions->size(); /* return size of dimensions array */ + if (this->dimensions == OREF_NULL) /* no dimensions array? */ + { + return 1; /* one dimension array */ + } + else + { + return this->dimensions->size(); /* return size of dimensions array */ + } } RexxObject *RexxArray::dimension( /* query dimensions of an array */ @@ -466,46 +490,55 @@ /* Function: Query array dimension information */ /******************************************************************************/ { - RexxObject *result; /* query result */ - size_t position; /* requested position */ - size_t tempSize; - - if (target == OREF_NULL) { /* non-specific query? */ - if (this->dimensions == OREF_NULL) { - if (this->size() == 0) - /* unknown dimension */ - result = (RexxObject*)IntegerZero; - else - /* one dimension array */ - result = (RexxObject *)IntegerOne; + if (target == OREF_NULL) + { /* non-specific query? */ + if (this->dimensions == OREF_NULL) + { + if (this->size() == 0) + { + /* unknown dimension */ + return IntegerZero; + } + else + { + /* one dimension array */ + return IntegerOne; + } + } + else + { /* return size of dimensions array */ + return new_integer(this->dimensions->size()); + } } - else { /* return size of dimensions array */ - tempSize = this->dimensions->size(); - result = (RexxObject *)new_integer(tempSize); + else + { + /* convert to a number */ + size_t position = target->requiredPositive(ARG_ONE); + /* asking for dimension of single? */ + if (this->dimensions == OREF_NULL) + { + if (position == 1) + { /* first dimension? */ + /* just give back the size */ + return new_integer(this->size()); + } + else + { + /* no size in this dimension */ + return IntegerZero; + } + } + /* out of range? */ + else if (position > this->dimensions->size()) + { + /* no size in this dimension */ + return IntegerZero; + } + else /* return the specific dimension */ + { + return this->dimensions->get(position); + } } - } - else { - /* convert to a number */ - position = target->requiredPositive(ARG_ONE); - /* asking for dimension of single? */ - if (this->dimensions == OREF_NULL) { - if (position == 1) { /* first dimension? */ - tempSize = this->size(); /* get the size */ - /* just give back the size */ - result = (RexxObject *)new_integer(tempSize); - } - else - /* no size in this dimension */ - result = (RexxObject *)IntegerZero; - } - /* out of range? */ - else if (position > this->dimensions->size()) - /* no size in this dimension */ - result = (RexxObject *)IntegerZero; - else /* return the specific dimension */ - result = this->dimensions->get(position); - } - return result; /* return the final result */ } RexxObject *RexxArray::supplier() @@ -513,36 +546,30 @@ /* Function: create a supplier for this array */ /******************************************************************************/ { - size_t itemCount; /* items in the array */ - RexxArray *values; /* returned values */ - RexxArray *indexes; /* returned index values */ - size_t slotCount; /* array size */ - RexxObject *item; /* inserted value item */ - size_t i; /* loop counter */ - size_t count; /* count added to the array */ + size_t slotCount = this->size(); /* get the array size */ + size_t itemCount = this->numItems(); /* and the actual count in the array */ - slotCount = this->size(); /* get the array size */ - itemCount = this->numItems(); /* and the actual count in the array */ + RexxArray *values = new_array(itemCount); /* get the values array */ + RexxArray *indexes = new_array(itemCount); /* and an index array */ - values = new_array(itemCount); /* get the values array */ - indexes = new_array(itemCount); /* and an index array */ + ProtectedObject v(values); + ProtectedObject s(indexes); - ProtectedObject v(values); - ProtectedObject s(indexes); + size_t count = 1; /* next place to add */ + for (size_t i = 1; i <= slotCount; i++) + { /* loop through the array */ + RexxObject *item = this->get(i); /* get the next item */ + if (item != OREF_NULL) + { /* got an item here */ + values->put(item, count); /* copy over to the values array */ - count = 1; /* next place to add */ - for (i = 1; i <= slotCount; i++) { /* loop through the array */ - item = this->get(i); /* get the next item */ - if (item != OREF_NULL) { /* got an item here */ - values->put(item, count); /* copy over to the values array */ - - /* add the index location */ - indexes->put((RexxObject*)convertIndex(i), count); - count++; /* step the location */ + /* add the index location */ + indexes->put((RexxObject*)convertIndex(i), count); + count++; /* step the location */ + } } - } - return (RexxObject *)new_supplier(values, indexes); + return new_supplier(values, indexes); } @@ -551,7 +578,7 @@ /* Function: Set a new expansion array item */ /******************************************************************************/ { - OrefSet(this, this->expansionArray, (RexxArray *)expansion); + OrefSet(this, this->expansionArray, (RexxArray *)expansion); } RexxInteger *RexxArray::available(size_t position) @@ -559,9 +586,10 @@ /* Function: Determine if a position element is "out-of-bounds" */ /******************************************************************************/ { - return (RexxInteger *) ((position < this->size()) ? TheTrueObject : TheFalseObject); + return (RexxInteger *) ((position < this->size()) ? TheTrueObject : TheFalseObject); } + bool RexxArray::validateIndex( /* validate an array index */ RexxObject **_index, /* array index (possibly multi-dim) */ size_t indexCount, /* size of the index array */ @@ -575,155 +603,194 @@ /* checking parameter. */ /******************************************************************************/ { - RexxObject *value; /* individual index value */ - size_t numsubs; /* number of subscripts */ - size_t i; /* loop counter */ - size_t multiplier; /* accumlation factor */ - size_t offset; /* accumulated offset */ - size_t _dimension; /* current working dimension */ - size_t numSize; /* temporary long variable */ + RexxObject *value; /* individual index value */ + size_t numsubs; /* number of subscripts */ + size_t i; /* loop counter */ + size_t multiplier; /* accumlation factor */ + size_t offset; /* accumulated offset */ + size_t _dimension; /* current working dimension */ + size_t numSize; /* temporary long variable */ - // do we really have a single index item given as an array? - if (indexCount == 1 && _index[0] != OREF_NULL && isOfClass(Array, _index[0])) - { - // we process this exactly the same way, but swap the count and - // pointers around to be the array data. - RexxArray *indirect = (RexxArray *)_index[0]; - indexCount = indirect->numItems(); - _index = indirect->data(); - } + // do we really have a single index item given as an array? + if (indexCount == 1 && _index[0] != OREF_NULL && isOfClass(Array, _index[0])) + { + // we process this exactly the same way, but swap the count and + // pointers around to be the array data. + RexxArray *indirect = (RexxArray *)_index[0]; + indexCount = indirect->numItems(); + _index = indirect->data(); + } - /* Is this array one-dimensional? */ - if (this->dimensions == OREF_NULL || this->dimensions->size() == 1) { - /* Too many subscripts? Say so. */ - if (indexCount > 1) { - /* should the array be extended? */ - if ((bounds_error & ExtendUpper) && this->dimensions == OREF_NULL) { - /* anytyhing in the array? */ - /* or explicitly created array with 0*/ - /* elements (.array~new(0)) */ - if (this->size() != 0) { - /* Yes, number of dims can't change */ - /* report apropriate bounds */ - reportException(Error_Incorrect_method_maxsub, IntegerOne); + /* Is this array one-dimensional? */ + if (this->dimensions == OREF_NULL || this->dimensions->size() == 1) + { + /* Too many subscripts? Say so. */ + if (indexCount > 1) + { + /* should the array be extended? */ + if ((bounds_error & ExtendUpper) && this->dimensions == OREF_NULL) + { + /* anytyhing in the array? */ + /* or explicitly created array with 0*/ + /* elements (.array~new(0)) */ + if (this->size() != 0) + { + /* Yes, number of dims can't change */ + /* report apropriate bounds */ + reportException(Error_Incorrect_method_maxsub, IntegerOne); + } + else + { + /* its empty, entendarray for new siz*/ + /* extend the array. */ + this->extendMulti(_index, indexCount, _start); + /* Call us again to get position, now*/ + /* That the array is extended. */ + return this->validateIndex(_index, indexCount, _start, bounds_error, position); + } + } + + else if (bounds_error & RaiseBoundsTooMany) + { + /* anytyhing in the array? */ + /* or explicitly created array with 0*/ + /* elements (.array~new(0)) */ + if (this->dimensions != OREF_NULL || this->size() != 0) + { + /* report apropriate bounds */ + reportException(Error_Incorrect_method_maxsub, IntegerOne); + } + else + { + return false; /* just report not here */ + } + } + else + { + return false; /* not fixed yet, but don't complain */ + } } - else { - /* its empty, entendarray for new siz*/ - /* extend the array. */ - this->extendMulti(_index, indexCount, _start); - /* Call us again to get position, now*/ - /* That the array is extended. */ - return this->validateIndex(_index, indexCount, _start, bounds_error, position); + /* Too few? subscripts? Say so. */ + else if (indexCount == 0) + { + /* report apropriate bounds */ + reportException(Error_Incorrect_method_minarg, _start); } - } + /* validate integer index */ + position = _index[0]->requiredPositive((int)_start); + /* out of bounds? */ + if (position > this->size() ) + { + if (position >= MAX_FIXEDARRAY_SIZE) + { + reportException(Error_Incorrect_method_array_too_big); + } + /* are we to expand the array? */ + if (bounds_error & ExtendUpper) + { + /* yes, compute amount to expand */ + this->extend(position - this->size()); - else if (bounds_error & RaiseBoundsTooMany) { - /* anytyhing in the array? */ - /* or explicitly created array with 0*/ - /* elements (.array~new(0)) */ - if (this->dimensions != OREF_NULL || this->size() != 0) - /* report apropriate bounds */ - reportException(Error_Incorrect_method_maxsub, IntegerOne); - else - return false; /* just report not here */ - } - else - return false; /* not fixed yet, but don't complain */ + } + /* need to raise an error? */ + else if (bounds_error & RaiseBoundsUpper) + { + reportException(Error_Incorrect_method_array, position); + } + else + { + return false; /* just return indicator */ + } + } } - /* Too few? subscripts? Say so. */ - else if (indexCount == 0) - /* report apropriate bounds */ - reportException(Error_Incorrect_method_minarg, _start); - /* validate integer index */ - position = _index[0]->requiredPositive((int)_start); - /* out of bounds? */ - if (position > this->size() ) { - if (position >= MAX_FIXEDARRAY_SIZE) - reportException(Error_Incorrect_method_array_too_big); - /* are we to expand the array? */ - if (bounds_error & ExtendUpper) { - /* yes, compute amount to expand */ - this->extend(position - this->size()); + else + { /* multidimensional array */ + /* get the number of subscripts */ + numsubs = indexCount; + numSize = this->dimensions->size();/* Get the size of dimension */ + /* right number of subscripts? */ + if (numsubs == numSize) + { + multiplier = 1; /* multiply by 1 for first dimension */ + offset = 0; /* no accumulated offset */ - } - /* need to raise an error? */ - else if (bounds_error & RaiseBoundsUpper) - reportException(Error_Incorrect_method_array, position); - else - return false; /* just return indicator */ - } - } - else { /* multidimensional array */ - /* get the number of subscripts */ - numsubs = indexCount; - numSize = this->dimensions->size();/* Get the size of dimension */ - /* right number of subscripts? */ - if (numsubs == numSize) { - multiplier = 1; /* multiply by 1 for first dimension */ - offset = 0; /* no accumulated offset */ + for (i = numsubs; i > 0; i--) + { /* loop through the dimensions */ - for (i = numsubs; i > 0; i--) { /* loop through the dimensions */ + value = _index[i - 1]; - value = _index[i - 1]; - - if (value == OREF_NULL) /* not given? */ - /* this is an error too */ - reportException(Error_Incorrect_method_noarg, i + _start); - /* validate integer index */ - position = value->requiredPositive((int)i); - /* get the current dimension */ - _dimension = ((RexxInteger *)this->dimensions->get(i))->getValue(); - if (position > _dimension) { /* too large? */ - /* should the array be extended? */ - if (bounds_error & ExtendUpper) { - /* go extend it. */ - this->extendMulti(_index, indexCount, _start); - /* Call us again to get position, now*/ - /* That the array is extended. */ - return this->validateIndex(_index, indexCount, _start, bounds_error, position); - } - /* need to raise an error? */ - else if (bounds_error & RaiseBoundsUpper) - reportException(Error_Incorrect_method_array, position); - else - return false; /* just return indicator */ + if (value == OREF_NULL) /* not given? */ + { + /* this is an error too */ + reportException(Error_Incorrect_method_noarg, i + _start); + } + /* validate integer index */ + position = value->requiredPositive((int)i); + /* get the current dimension */ + _dimension = ((RexxInteger *)this->dimensions->get(i))->getValue(); + if (position > _dimension) + { /* too large? */ + /* should the array be extended? */ + if (bounds_error & ExtendUpper) + { + /* go extend it. */ + this->extendMulti(_index, indexCount, _start); + /* Call us again to get position, now*/ + /* That the array is extended. */ + return this->validateIndex(_index, indexCount, _start, bounds_error, position); + } + /* need to raise an error? */ + else if (bounds_error & RaiseBoundsUpper) + { + reportException(Error_Incorrect_method_array, position); + } + else + { + return false; /* just return indicator */ + } + } + /* calculate next offset */ + offset += multiplier * (position - 1); + multiplier *= _dimension; /* step the multiplier */ + } + position = offset + 1; /* get accumulated position */ } - /* calculate next offset */ - offset += multiplier * (position - 1); - multiplier *= _dimension; /* step the multiplier */ - } - position = offset + 1; /* get accumulated position */ - } - /* Not enough subscripts? */ - else if (numsubs < numSize) - reportException(Error_Incorrect_method_minsub, numSize); - else /* Must be too many subscripts */ - /* should the array be extended? */ + /* Not enough subscripts? */ + else if (numsubs < numSize) + { + reportException(Error_Incorrect_method_minsub, numSize); + } + else /* Must be too many subscripts */ + /* should the array be extended? */ #ifdef EXTEND_DIMENSIONS - if (bounds_error & ExtendUpper) { - /* anytyhing in the array? */ - if (this->size() != 0) { - /* Yes, number of dims can't change */ - /* report apropriate bounds */ - reportException(Error_Incorrect_method_maxarg, numSize); - } - else { - /* array empty, extend the array */ - this->extendMuti(_index, indexCount, _start); - /* Call us again to get position, now*/ - /* That the array is extended. */ - return this->validateIndex(_index, indexCount, _start, bounds_error, position); - } - } - else { - reportException(Error_Incorrect_method_maxsub, numSize); - } + if (bounds_error & ExtendUpper) + { + /* anytyhing in the array? */ + if (this->size() != 0) + { + /* Yes, number of dims can't change */ + /* report apropriate bounds */ + reportException(Error_Incorrect_method_maxarg, numSize); + } + else + { + /* array empty, extend the array */ + this->extendMuti(_index, indexCount, _start); + /* Call us again to get position, now*/ + /* That the array is extended. */ + return this->validateIndex(_index, indexCount, _start, bounds_error, position); + } + } + else + { + reportException(Error_Incorrect_method_maxsub, numSize); + } #else - reportException(Error_Incorrect_method_maxsub, numSize); + reportException(Error_Incorrect_method_maxsub, numSize); #endif - } - return true; /* return the position */ + } + return true; /* return the position */ } @@ -755,7 +822,7 @@ /* Function: Return the array size as an integer object */ /******************************************************************************/ { - return (RexxInteger *)new_integer(this->size()); + return new_integer(this->size()); } RexxArray * RexxArray::section(size_t _start, size_t _end) @@ -763,29 +830,36 @@ /* Function: Section an array for a given size */ /******************************************************************************/ { - size_t newSize; /* Size for new array. */ - RexxArray *newArray; /* The new array. */ + size_t newSize; /* Size for new array. */ + RexxArray *newArray; /* The new array. */ - if (_start == 0) /* starting position specified? */ - _start = 1; /* nope, start at begining */ + if (_start == 0) /* starting position specified? */ + { + _start = 1; /* nope, start at begining */ + } - /* ending position omitted */ - /* or, End pos past end of array? */ - if (_end == 0 || _end > this->size()) - _end = this->size(); /* yes, use end of array */ - if (_start <= _end) { /* is start before end? */ - newSize = _end + 1 - _start; /* yes, compute new size */ - /* Get new array, of needed size */ - newArray = (RexxArray *)new_array(newSize); - // a new array cannot be oldspace, by definition. It's safe to use - // memcpy to copy the data. - /* yes, we can do a memcpy */ - memcpy(newArray->data(), &(this->expansionArray->objects[_start-1]), sizeof(RexxObject *) * newSize); - } else { - /* return 0 element array */ - newArray = (RexxArray *)new_array((size_t)0); - } - return newArray; /* return the newly created array */ + /* ending position omitted */ + /* or, End pos past end of array? */ + if (_end == 0 || _end > this->size()) + { + _end = this->size(); /* yes, use end of array */ + } + if (_start <= _end) + { /* is start before end? */ + newSize = _end + 1 - _start; /* yes, compute new size */ + /* Get new array, of needed size */ + newArray = (RexxArray *)new_array(newSize); + // a new array cannot be oldspace, by definition. It's safe to use + // memcpy to copy the data. + /* yes, we can do a memcpy */ + memcpy(newArray->data(), &(this->expansionArray->objects[_start-1]), sizeof(RexxObject *) * newSize); + } + else + { + /* return 0 element array */ + newArray = (RexxArray *)new_array((size_t)0); + } + return newArray; /* return the newly created array */ } RexxObject *RexxArray::sectionRexx( @@ -795,46 +869,62 @@ /* Function: Rexx level section method */ /******************************************************************************/ { - size_t nstart, nend, i; - RexxArray *rref; + size_t nstart, nend, i; + RexxArray *rref; - required_arg(_start, ONE); /* need a start position */ - /* Start specified - check it out */ - nstart = _start->requiredPositive(ARG_ONE); - if (_end == OREF_NULL) /* If no end position specified, */ - nend = this->size(); /* Defaults to last element */ - else { /* End specified - check it out */ - nend = _end->requiredNonNegative(ARG_TWO); - } - /* multidimensional array? */ - if (this->dimensions != OREF_NULL && this->dimensions->size() != 1) - /* this is an error */ - reportException(Error_Incorrect_method_section); - if (!isOfClass(Array, this)) /* actually an array subclass? */ - /* need to do this the slow way */ - return this->sectionSubclass(nstart, nend); - if (nstart > this->size()) /* too big? */ + required_arg(_start, ONE); /* need a start position */ + /* Start specified - check it out */ + nstart = _start->requiredPositive(ARG_ONE); + if (_end == OREF_NULL) /* If no end position specified, */ + { + nend = this->size(); /* Defaults to last element */ + } + else + { /* End specified - check it out */ + nend = _end->requiredNonNegative(ARG_TWO); + } + /* multidimensional array? */ + if (this->dimensions != OREF_NULL && this->dimensions->size() != 1) + { + /* this is an error */ + reportException(Error_Incorrect_method_section); + } + if (!isOfClass(Array, this)) /* actually an array subclass? */ + { + /* need to do this the slow way */ + return this->sectionSubclass(nstart, nend); + } + if (nstart > this->size()) /* too big? */ + { - rref = (RexxArray *)(((RexxArray *)TheNullArray)->copy()); - /* return zero elements */ - else { - /* go past the bounds? */ - if (nend > this->size() - nstart + 1) - nend = this->size() - nstart + 1;/* truncate to the end */ - if (nend == 0) /* requesting zero? */ - /* return zero elements */ - rref = (RexxArray *)(((RexxArray *)TheNullArray)->copy()); - else { /* real sectioning to do */ - /* create a new array */ - rref = (RexxArray *)new_array(nend); - for (i = 1; i <= nend; i++) { /* loop through the elements */ - /* copy an element */ - rref->put(this->get(nstart + i - 1), i); - } + rref = (RexxArray *)(((RexxArray *)TheNullArray)->copy()); } - } - return rref; /* return the new array */ + /* return zero elements */ + else + { + /* go past the bounds? */ + if (nend > this->size() - nstart + 1) + { + nend = this->size() - nstart + 1;/* truncate to the end */ + } + if (nend == 0) /* requesting zero? */ + { + /* return zero elements */ + rref = (RexxArray *)(((RexxArray *)TheNullArray)->copy()); + } + else + { /* real sectioning to do */ + /* create a new array */ + rref = (RexxArray *)new_array(nend); + for (i = 1; i <= nend; i++) + { /* loop through the elements */ + /* copy an element */ + rref->put(this->get(nstart + i - 1), i); + } + } + } + return rref; /* return the new array */ } RexxObject *RexxArray::sectionSubclass( @@ -844,38 +934,42 @@ /* Function: Rexx level section method */ /******************************************************************************/ { - size_t i; /* loop counter */ - RexxArray *newArray; /* returned array */ - ProtectedObject result; + size_t i; /* loop counter */ + RexxArray *newArray; /* returned array */ + ProtectedObject result; - if (_start > this->size()) /* too big? */ - { - this->behaviour->getOwningClass()->sendMessage(OREF_NEW, IntegerZero, result); - newArray = (RexxArray *)(RexxObject *)result; - } - /* return a zero element one */ - else { - if (_end > this->size() - _start + 1) - /* go past the bounds? */ - _end = this->size() - _start + 1;/* truncate to the end */ - if (_end == 0) /* requesting zero? */ + if (_start > this->size()) /* too big? */ { this->behaviour->getOwningClass()->sendMessage(OREF_NEW, IntegerZero, result); newArray = (RexxArray *)(RexxObject *)result; } - /* return a zero element one */ - else { /* real sectioning to do */ - /* create a new array */ - this->behaviour->getOwningClass()->sendMessage(OREF_NEW, new_integer(_end), result); - newArray = (RexxArray *)(RexxObject *)result; - for (i = 1; i <= _end; i++) /* loop through the elements */ - { - /* copy an element */ - newArray->sendMessage(OREF_PUT, this->get(_start + i - 1), new_integer(i)); - } + /* return a zero element one */ + else + { + if (_end > this->size() - _start + 1) + { + /* go past the bounds? */ + _end = this->size() - _start + 1;/* truncate to the end */ + } + if (_end == 0) /* requesting zero? */ + { + this->behaviour->getOwningClass()->sendMessage(OREF_NEW, IntegerZero, result); + newArray = (RexxArray *)(RexxObject *)result; + } + /* return a zero element one */ + else + { /* real sectioning to do */ + /* create a new array */ + this->behaviour->getOwningClass()->sendMessage(OREF_NEW, new_integer(_end), result); + newArray = (RexxArray *)(RexxObject *)result; + for (i = 1; i <= _end; i++) /* loop through the elements */ + { + /* copy an element */ + newArray->sendMessage(OREF_PUT, this->get(_start + i - 1), new_integer(i)); + } + } } - } - return newArray; /* return the new array */ + return newArray; /* return the new array */ } RexxObject *RexxArray::firstRexx(void) @@ -884,26 +978,27 @@ /* object */ /******************************************************************************/ { - size_t i; /* counter for the loop */ - RexxObject *result; - RexxObject **thisObject; - size_t _arraySize; /* size of the array */ + size_t i; /* counter for the loop */ + RexxObject **thisObject; + size_t _arraySize; /* size of the array */ - /* get the address of the first */ - /*element in the array */ - thisObject = this->expansionArray->objects; - _arraySize = this->size(); /* get the size of the array */ - /* find first position in the */ - /*array with data */ - for (i = 0; i < _arraySize && thisObject[i] == OREF_NULL; i++); + /* get the address of the first */ + /*element in the array */ + thisObject = this->expansionArray->objects; + _arraySize = this->size(); /* get the size of the array */ + /* find first position in the */ + /*array with data */ + for (i = 0; i < _arraySize && thisObject[i] == OREF_NULL; i++); - if (i == _arraySize) /* is array empty */ - result = TheNilObject; /* return nil object */ - else - /* return index of the first entry */ - result = (RexxObject *)convertIndex(i + 1); - - return result; + if (i == _arraySize) /* is array empty */ + { + return TheNilObject; /* return nil object */ + } + else + { + /* return index of the first entry */ + return convertIndex(i + 1); + } } RexxObject *RexxArray::lastRexx(void) @@ -934,32 +1029,31 @@ /* Function: Return the next entry after a given array index */ /******************************************************************************/ { - size_t i; - RexxObject *result; - RexxObject **thisObject; - size_t _arraySize; /* size of the array */ - stringsize_t position; - /* go validate the index */ - if (!this->validateIndex(arguments, argCount, 1, RaiseBoundsTooMany | RaiseBoundsInvalid, position)) - { - // out of bounds results in the .nil object - return TheNilObject; - } - /* get the address of the first */ - /*element in the array */ - thisObject = this->data(); - _arraySize = this->size(); /* get the size of the array */ - /* find next entry in the array with */ - /*data */ - for (i = position; i < _arraySize && thisObject[i] == OREF_NULL; i++); + size_t i; + stringsize_t position; + /* go validate the index */ + if (!this->validateIndex(arguments, argCount, 1, RaiseBoundsTooMany | RaiseBoundsInvalid, position)) + { + // out of bounds results in the .nil object + return TheNilObject; + } + /* get the address of the first */ + /*element in the array */ + RexxObject **thisObject = this->data(); + size_t _arraySize = this->size(); /* get the size of the array */ + /* find next entry in the array with */ + /*data */ + for (i = position; i < _arraySize && thisObject[i] == OREF_NULL; i++); - if (i >= this->size()) - result = TheNilObject; /* return nil object */ - else - /* return index of the next entry */ - result = (RexxObject *)convertIndex(i + 1); - - return result; + if (i >= this->size()) + { + return TheNilObject; /* return nil object */ + } + else + { + /* return index of the next entry */ + return convertIndex(i + 1); + } } RexxObject *RexxArray::previousRexx(RexxObject **arguments, size_t argCount) @@ -967,42 +1061,46 @@ /* Function: Return the index preceeding a given index */ /******************************************************************************/ { - size_t i; /* counter for the loop */ - RexxObject *result; - RexxObject **thisObject; - size_t _arraySize; /* size of the array */ - stringsize_t position; + size_t i; /* counter for the loop */ + RexxObject **thisObject; + size_t _arraySize; /* size of the array */ + stringsize_t position; - this->validateIndex(arguments, argCount, 1, RaiseBoundsTooMany | RaiseBoundsInvalid, position); - /* get the index object into an */ - /*integer object */ - i = position; + this->validateIndex(arguments, argCount, 1, RaiseBoundsTooMany | RaiseBoundsInvalid, position); + /* get the index object into an */ + /*integer object */ + i = position; - _arraySize = this->size(); /* get the size of the array */ + _arraySize = this->size(); /* get the size of the array */ - if (i > _arraySize) /* beyond the size of the array? */ - /* set i to one more than the last */ - /*entry */ - i = _arraySize; - else - i = i-1; /* Account for 0 based 'C' arrays */ + if (i > _arraySize) /* beyond the size of the array? */ + { + /* set i to one more than the last */ + /*entry */ + i = _arraySize; + } + else + { + i = i-1; /* Account for 0 based 'C' arrays */ + } - /* get the address of the first */ - /*element in the array */ - thisObject = this->expansionArray->objects; - /* find previous entry in the */ - /*array with data */ - for (; i > 0 && thisObject[i-1] == OREF_NULL; - i--); + /* get the address of the first */ + /*element in the array */ + thisObject = this->expansionArray->objects; + /* find previous entry in the */ + /*array with data */ + for (; i > 0 && thisObject[i-1] == OREF_NULL; i--); - if (i == 0) - result = TheNilObject; /* return nil object */ - else - /* return the index to the */ - /*previous entry */ - result = (RexxObject *)convertIndex(i); - - return result; + if (i == 0) + { + return TheNilObject; /* return nil object */ + } + else + { + /* return the index to the */ + /*previous entry */ + return convertIndex(i); + } } @@ -1011,13 +1109,17 @@ /* Function: Determine if an individual array element exists */ /******************************************************************************/ { - size_t i; + size_t i; - if (isOfClass(Integer,_index) && (i = ((RexxInteger *)_index)->getValue()) > 0 && i <= this->size() && - *(this->data()+i-1) != OREF_NULL) - return (RexxInteger *)TheTrueObject; - else - return (RexxInteger *)TheFalseObject; + if (isOfClass(Integer,_index) && (i = ((RexxInteger *)_index)->getValue()) > 0 && i <= this->size() && + *(this->data()+i-1) != OREF_NULL) + { + return TheTrueObject; + } + else + { + return TheFalseObject; + } } RexxObject *RexxArray::hasIndexRexx(RexxObject ** _index, size_t _indexCount) @@ -1027,25 +1129,29 @@ /* being used. The only error produced is if no parms were passed. */ /******************************************************************************/ { - stringsize_t position; /* array position */ + stringsize_t position; /* array position */ - /* go validate the index */ - if (!this->validateIndex(_index, _indexCount, 1, RaiseBoundsTooMany | RaiseBoundsInvalid, position)) - { - /* this is false */ - return (RexxObject *)TheFalseObject; + /* go validate the index */ + if (!this->validateIndex(_index, _indexCount, 1, RaiseBoundsTooMany | RaiseBoundsInvalid, position)) + { + /* this is false */ + return TheFalseObject; - } - else /* check the position */ - { - /* have a real entry? */ - if (*(this->data() + position - 1) != OREF_NULL) - /* got a true */ - return (RexxObject *)TheTrueObject; - else - /* no index here */ - return (RexxObject *)TheFalseObject; - } + } + else /* check the position */ + { + /* have a real entry? */ + if (*(this->data() + position - 1) != OREF_NULL) + { + /* got a true */ + return TheTrueObject; + } + else + { + /* no index here */ + return TheFalseObject; + } + } } bool RexxArray::hasIndexNative(size_t _index) @@ -1053,11 +1159,15 @@ /* Function: Determine if an element exist for a position */ /******************************************************************************/ { - /* in bounds and here? */ - if (_index > 0 && _index <= this->size() && *(this->data() + _index - 1) != OREF_NULL) - return true; /* this is true */ - else - return false; /* nope, don't have it */ + /* in bounds and here? */ + if (_index > 0 && _index <= this->size() && *(this->data() + _index - 1) != OREF_NULL) + { + return true; /* this is true */ + } + else + { + return false; /* nope, don't have it */ + } } RexxArray *RexxArray::makeArray(void) @@ -1132,7 +1242,7 @@ /* Function: Handle a REQUEST('STRING') request for a REXX string object */ /******************************************************************************/ { - return this->makeString((RexxString *)OREF_NULL); /* forward to the real makestring method */ + return this->makeString((RexxString *)OREF_NULL); /* forward to the real makestring method */ } #endif @@ -1148,93 +1258,103 @@ /* Function: Make a string out of an array */ /******************************************************************************/ { - size_t _items; - size_t i; - RexxArray *newArray; /* New array */ - RexxString *newString; - RexxString *line_end_string; /* converted substitution value */ - RexxMutableBuffer *mutbuffer; - RexxObject *item; /* inserted value item */ - int i_form = 0; /* 1 == line, 2 == char */ + size_t _items; + size_t i; + RexxArray *newArray; /* New array */ + RexxString *newString; + RexxString *line_end_string; /* converted substitution value */ + RexxMutableBuffer *mutbuffer; + RexxObject *item; /* inserted value item */ + int i_form = 0; /* 1 == line, 2 == char */ - mutbuffer = ((RexxMutableBufferClass*) TheMutableBufferClass)->newRexx(NULL, 0); - ProtectedObject p1(mutbuffer); + mutbuffer = ((RexxMutableBufferClass*) TheMutableBufferClass)->newRexx(NULL, 0); + ProtectedObject p1(mutbuffer); - newArray = this->makeArray(); /* maybe multidimensional, make onedimensional */ - ProtectedObject p2(newArray); + newArray = this->makeArray(); /* maybe multidimensional, make onedimensional */ + ProtectedObject p2(newArray); - _items = newArray->numItems(); /* and the actual count in the array */ + _items = newArray->numItems(); /* and the actual count in the array */ - if (format != OREF_NULL) - { - // a string value is required here - format = REQUIRED_STRING(format, ARG_ONE); - } + if (format != OREF_NULL) + { + // a string value is required here + format = REQUIRED_STRING(format, ARG_ONE); + } - if (format == OREF_NULL) - i_form = 2; /* treat item as LINE by default */ - else if (toupper((format->getStringData()[0])) == 'C') - i_form = 1; - else if (toupper((format->getStringData()[0])) == 'L') - i_form = 2; - else - reportException(Error_Incorrect_method_option, "CL", format); + if (format == OREF_NULL) + { + i_form = 2; /* treat item as LINE by default */ + } + else if (toupper((format->getStringData()[0])) == 'C') + { + i_form = 1; + } + else if (toupper((format->getStringData()[0])) == 'L') + { + i_form = 2; + } + else + { + reportException(Error_Incorrect_method_option, "CL", format); + } - if (i_form == 1) /* character oriented processing */ - { - if (separator != OREF_NULL) + if (i_form == 1) /* character oriented processing */ { - reportException(Error_Incorrect_method_maxarg, IntegerOne); + if (separator != OREF_NULL) + { + reportException(Error_Incorrect_method_maxarg, IntegerOne); + } + + for (i = 1; i <=_items ; i++) /* loop through the array */ + { + item = newArray->get(i); /* get the next item */ + if (item != OREF_NULL) + { + RexxObject * _stringValue = item->requiredString(); + if (_stringValue != TheNilObject) + { + mutbuffer->append(_stringValue); + } + } + } } - - for (i = 1; i <=_items ; i++) /* loop through the array */ + else if (i_form == 2) /* line oriented processing */ { - item = newArray->get(i); /* get the next item */ - if (item != OREF_NULL) - { - RexxObject * _stringValue = item->requiredString(); - if (_stringValue != TheNilObject) - { - mutbuffer->append(_stringValue); - } - } - } - } - else if (i_form == 2) /* line oriented processing */ - { - if (separator != OREF_NULL) - { - line_end_string = REQUIRED_STRING(separator, ARG_TWO); - } - else - line_end_string = new_string(line_end); + if (separator != OREF_NULL) + { + line_end_string = REQUIRED_STRING(separator, ARG_TWO); + } + else + { + line_end_string = new_string(line_end); + } - ProtectedObject p3(line_end_string); - bool first = true; + ProtectedObject p3(line_end_string); + bool first = true; - for (i = 1; i <= _items; i++) /* loop through the array */ - { - item = newArray->get(i); /* get the next item */ - if (item != OREF_NULL) - { - // append a linend between the previous item and this one. - if (!first) - { - mutbuffer->append((RexxObject *) line_end_string); - } - RexxObject *_stringValue = item->requiredString(); - if (_stringValue != TheNilObject) - { - mutbuffer->append(_stringValue); - } - first = false; - } - } - } + for (i = 1; i <= _items; i++) /* loop through the array */ + { + item = newArray->get(i); /* get the next item */ + if (item != OREF_NULL) + { + // append a linend between the previous item and this one. + if (!first) + { + mutbuffer->append((RexxObject *) line_end_string); + } + RexxObject *_stringValue = item->requiredString(); + if (_stringValue != TheNilObject) + { + mutbuffer->append(_stringValue); + } + first = false; + } + } + } - newString = mutbuffer->makeString(); - return newString; + newString = mutbuffer->makeString(); + return newString; } RexxObject *RexxArray::join( /* join two arrays into one */ @@ -1243,17 +1363,16 @@ /* Function: Join two arrays into one array */ /******************************************************************************/ { - RexxArray *newArray; /* result array of the join */ - /* get new array, total size is size */ - /* of both arrays. */ - newArray = (RexxArray*)new_array(this->size() + other->size()); - // it's safe to just copy the references because the newArray will be new space - /* copy first array into new one */ - memcpy(newArray->data(), this->data(), ((char *)&(this->data()[this->size()])) - ((char *)this->data())); - /* copy 2nd array into the new one */ - /* after the first one. */ - memcpy((void *)&(newArray->data()[this->size()]), other->data(), ((char *)&(other->data()[other->size()])) - ((char *)other->data())); - return newArray; /* All done, return joined array */ + /* get new array, total size is size */ + /* of both arrays. */ + RexxArray *newArray = (RexxArray*)new_array(this->size() + other->size()); + // it's safe to just copy the references because the newArray will be new space + /* copy first array into new one */ + memcpy(newArray->data(), this->data(), ((char *)&(this->data()[this->size()])) - ((char *)this->data())); + /* copy 2nd array into the new one */ + /* after the first one. */ + memcpy((void *)&(newArray->data()[this->size()]), other->data(), ((char *)&(other->data()[other->size()])) - ((char *)other->data())); + return newArray; /* All done, return joined array */ } @@ -1263,22 +1382,26 @@ /* portion of this array. */ /******************************************************************************/ { - size_t i; - /* Has the array already been */ - /* expanded ? */ - if (this->expansionArray == this) { - /* no, then we resize the array */ - /* is this array in OldSpace ? */ - if (this->isOldSpace()) { - /* Old Space, remove any reference */ - /* to new space from memory tables */ - for (i = 0; i < this->arraySize; i++) - OrefSet(this, this->objects[i], OREF_NULL); + size_t i; + /* Has the array already been */ + /* expanded ? */ + if (this->expansionArray == this) + { + /* no, then we resize the array */ + /* is this array in OldSpace ? */ + if (this->isOldSpace()) + { + /* Old Space, remove any reference */ + /* to new space from memory tables */ + for (i = 0; i < this->arraySize; i++) + { + OrefSet(this, this->objects[i], OREF_NULL); + } + } + /* resize the array object */ + memoryObject.reSize(this, sizeof(RexxArray)); + this->arraySize = 0; /* outer array has no elements */ } - /* resize the array object */ - memoryObject.reSize(this, sizeof(RexxArray)); - this->arraySize = 0; /* outer array has no elements */ - } } void RexxArray::shrink( @@ -1288,18 +1411,16 @@ /* Single Dimension ONLY */ /******************************************************************************/ { - size_t newSize; /* new array size */ - size_t i; /* loop counter */ - size_t _size; /* existing size */ + size_t _size = this->size(); /* get the size */ + size_t newSize = _size - amount; /* get the new size */ - _size = this->size(); /* get the size */ - newSize = _size - amount; /* get the new size */ - - i = newSize + 1; /* address first removed element */ - for (i = newSize + 1; i <= _size; i++)/* for all removed elements */ - this->put(OREF_NULL, i); /* clear out the element */ - /* adjust the size . */ - this->expansionArray->arraySize = newSize; + size_t i = newSize + 1; /* address first removed element */ + for (i = newSize + 1; i <= _size; i++)/* for all removed elements */ + { + this->put(OREF_NULL, i); /* clear out the element */ + } + /* adjust the size . */ + this->expansionArray->arraySize = newSize; } size_t RexxArray::indexOf( @@ -1309,15 +1430,15 @@ /* the index */ /*****************************************************************************/ { - size_t i; /* current array index */ - size_t _size; /* array size */ - - _size = this->size(); /* get the array size */ - for (i = 1; i <= _size; i++) { /* spin through the array */ - if (this->get(i) == target) /* is this the one? */ - return i; /* return the index */ - } - return 0; /* not found here */ + size_t _size = this->size(); /* get the array size */ + for (size_t i = 1; i <= _size; i++) + { /* spin through the array */ + if (this->get(i) == target) /* is this the one? */ + { + return i; /* return the index */ + } + } + return 0; /* not found here */ } void RexxArray::deleteItem( @@ -1327,15 +1448,13 @@ /* and moving the relevent items */ /*****************************************************************************/ { - size_t i; /* current array index */ - size_t _size; /* array size */ - - _size = this->size(); /* get the array size */ - /* spin through the array */ - for (i = targetIndex; i < _size; i++) { - this->put(this->get(i +1), i); /* move down each item */ - } - this->shrink(1); /* now shrink the array */ + size_t _size = this->size(); /* get the array size */ + /* spin through the array */ + for (size_t i = targetIndex; i < _size; i++) + { + this->put(this->get(i +1), i); /* move down each item */ + } + this->shrink(1); /* now shrink the array */ } void RexxArray::insertItem( @@ -1346,14 +1465,13 @@ /* and moving the relevent items */ /*****************************************************************************/ { - size_t i; /* current array index */ - - this->extend(1); /* extend the array size */ - /* spin through the array */ - for (i = this->size(); i > targetIndex; i--) { - this->put(this->get(i - 1), i); /* move up each item */ - } - this->put(newItem, targetIndex); /* insert the new item */ + this->extend(1); /* extend the array size */ + /* spin through the array */ + for (size_t i = this->size(); i > targetIndex; i--) + { + this->put(this->get(i - 1), i); /* move up each item */ + } + this->put(newItem, targetIndex); /* insert the new item */ } RexxArray *RexxArray::extend( /* join two arrays into one */ @@ -1363,48 +1481,48 @@ /* Single Dimension ONLY */ /******************************************************************************/ { - RexxArray *newArray; /* result array of the extend */ + /* do we really need to extend array */ + /* or just adjust size. */ + if (this->size() + extension <= this->maximumSize) + { + /* adjust the size . */ + this->expansionArray->arraySize += extension; + return this; + } - /* do we really need to extend array */ - /* or just adjust size. */ - if (this->size() + extension <= this->maximumSize) { - /* adjust the size . */ - this->expansionArray->arraySize += extension; - return this; - } + size_t newSize = this->size() + extension; + size_t extendSize; + /* are we still a relative small array? */ + if (newSize < ARRAY_EXTEND_EXTRA_LARGE_SIZE) + { + /* just bump this the small extra amount */ + extendSize = ARRAY_EXTEND_EXTRA_SIZE; + } + else + { + /* we're getting large. We'll start bumping by a larger amount. */ + extendSize = this->size() / 2; /* add 50% to the size */ + } - size_t newSize = this->size() + extension; - size_t extendSize; - /* are we still a relative small array? */ - if (newSize < ARRAY_EXTEND_EXTRA_LARGE_SIZE) { - /* just bump this the small extra amount */ - extendSize = ARRAY_EXTEND_EXTRA_SIZE; - } - else { - /* we're getting large. We'll start bumping by a larger amount. */ -/* extendSize = ARRAY_EXTEND_EXTRA_LARGE_SIZE; */ - extendSize = this->size() / 2; /* add 50% to the size */ - } + /* get a new array, total size is */ + /* size of both arrays. */ + RexxArray *newArray = (RexxArray *)new_array(newSize + extendSize); + /* If none of the objects are in */ + /* OldSpace, we can skip the */ + /* OrefSets and just copy */ + /* copy ourselves into the new array */ + memcpy(newArray->data(), this->data(), ((char *)&(this->data()[this->size()])) - ((char *)this->data())); + this->resize(); /* adjust ourself to be null arrayobj*/ - /* get a new array, total size is */ - /* size of both arrays. */ - newArray = (RexxArray *)new_array(newSize + extendSize); - /* If none of the objects are in */ - /* OldSpace, we can skip the */ - /* OrefSets and just copy */ - /* copy ourselves into the new array */ - memcpy(newArray->data(), this->data(), ((char *)&(this->data()[this->size()])) - ((char *)this->data())); - this->resize(); /* adjust ourself to be null arrayobj*/ - - newArray->setExpansion(OREF_NULL); /* clear the new expansion array */ - /* set new expansion array */ - OrefSet(this, this->expansionArray, newArray); - /* keep max Size value in synch */ - /* with expansion. */ - this->maximumSize = newArray->maximumSize; - /* make sure size is correct. */ - newArray->arraySize = newSize; - return this; /* All done, return array */ + newArray->setExpansion(OREF_NULL); /* clear the new expansion array */ + /* set new expansion array */ + OrefSet(this, this->expansionArray, newArray); + /* keep max Size value in synch */ + /* with expansion. */ + this->maximumSize = newArray->maximumSize; + /* make sure size is correct. */ + newArray->arraySize = newSize; + return this; /* All done, return array */ } @@ -1468,30 +1586,30 @@ */ RexxObject* RexxArray::indexToArray(size_t idx) { - // work with an origin-origin zero version of the index, which is easier - // do work with. - idx--; - // get the number of dimensions specified. - size_t dims = this->dimensions->size(); - // get an array we fill in as we go - RexxArray * _index = new_array(dims); + // work with an origin-origin zero version of the index, which is easier + // do work with. + idx--; + // get the number of dimensions specified. + size_t dims = this->dimensions->size(); + // get an array we fill in as we go + RexxArray * _index = new_array(dims); - ProtectedObject p(_index); + ProtectedObject p(_index); - for (size_t i = dims; i > 0; i--) - { - // get the next dimension size - size_t _dimension = ((RexxInteger *)this->dimensions->get(i))->getValue(); - // now get the remainder. This tells us the position within this - // dimension of the array. Make an integer object and store in the - // array. - size_t digit = idx % _dimension; - // the digit is origin-zero, but the Rexx index is origin-one. - _index->put(new_integer(digit + 1), i); - // now strip out that portion of the index. - idx = (idx - digit) / _dimension; - } - return _index; + for (size_t i = dims; i > 0; i--) + { + // get the next dimension size + size_t _dimension = ((RexxInteger *)this->dimensions->get(i))->getValue(); + // now get the remainder. This tells us the position within this + // dimension of the array. Make an integer object and store in the + // array. + size_t digit = idx % _dimension; + // the digit is origin-zero, but the Rexx index is origin-one. + _index->put(new_integer(digit + 1), i); + // now strip out that portion of the index. + idx = (idx - digit) / _dimension; + } + return _index; } @@ -1572,68 +1690,75 @@ /* to another. */ /******************************************************************************/ { - size_t skipAmount; /* amount to skip for increased */ - /* dimension. */ - size_t newDimSize; - size_t oldDimSize; - size_t oldDimension; - size_t i; /* count for each subscript at */ - /* this dimension */ + size_t skipAmount; /* amount to skip for increased */ + /* dimension. */ + size_t newDimSize; + size_t oldDimSize; + size_t oldDimension; + size_t i; /* count for each subscript at */ + /* this dimension */ - /* At the point where we can */ - /* copy elements? */ - /* ending condition for recusion */ - if (newDimension == parm->firstChangedDimension) { - /* is new array in OldSpace? */ - if (parm->newArray->isOldSpace()) { - /* Yes,need to do OrefSets */ - /* For each element to copy */ - for (i = 1; i <= parm->copyElements; i++, parm->startNew++, parm->startOld++ ) { - /* set the newvalue. */ - OrefSet(parm->newArray, *parm->startNew, *parm->startOld); - } - } - else { - /* not old Spcae we can do memcpy */ - memcpy(parm->startNew, parm->startOld, sizeof(RexxObject *) * parm->copyElements); - /* update pointers */ - parm->startNew += parm->copyElements; - parm->startOld += parm->copyElements; - } - /* now bump past space for */ - /* additional size of dimension */ - parm->startNew += parm->skipElements; - } - else { - /* Compute the old dimension num */ - oldDimension = newDimension - parm->deltaDimSize; - /* Get size for new Dimension */ - newDimSize = ((RexxInteger *)parm->newDimArray->get(newDimension))->getValue(); - /* Get size for old Dimension */ - oldDimSize = ((RexxInteger *)parm->oldDimArray->get(oldDimension))->getValue(); - /* For each subscript at this */ - for (i= 1; i <= oldDimSize; i++) {/* dimension, (of old size) */ - /* copy elelments. */ - copyElements(parm, newDimension + 1); - } - if (newDimSize > oldDimSize) { /* Was this dimension expanded? */ - /* compute total space need for */ - /* block of all lower dimensions */ - for (i = parm->newDimArray->size(), skipAmount = 1; - i > newDimension; - skipAmount *= ((RexxInteger *)parm->newDimArray->get(i))->getValue(), i--); - /* multiple by delta add at this */ - /* dimension. */ - skipAmount *= (newDimSize - oldDimSize); - /* Bump our start pointer past */ - /* empty space added for this */ - /* dimension. */ - parm->startNew += skipAmount; - } - } - /* all done at this level return */ - /* to caller. */ - return; + /* At the point where we can */ + /* copy elements? */ + /* ending condition for recusion */ + if (newDimension == parm->firstChangedDimension) + { + /* is new array in OldSpace? */ + if (parm->newArray->isOldSpace()) + { + /* Yes,need to do OrefSets */ + /* For each element to copy */ + for (i = 1; i <= parm->copyElements; i++, parm->startNew++, parm->startOld++ ) + { + /* set the newvalue. */ + OrefSet(parm->newArray, *parm->startNew, *parm->startOld); + } + } + else + { + /* not old Spcae we can do memcpy */ + memcpy(parm->startNew, parm->startOld, sizeof(RexxObject *) * parm->copyElements); + /* update pointers */ + parm->startNew += parm->copyElements; + parm->startOld += parm->copyElements; + } + /* now bump past space for */ + /* additional size of dimension */ + parm->startNew += parm->skipElements; + } + else + { + /* Compute the old dimension num */ + oldDimension = newDimension - parm->deltaDimSize; + /* Get size for new Dimension */ + newDimSize = ((RexxInteger *)parm->newDimArray->get(newDimension))->getValue(); + /* Get size for old Dimension */ + oldDimSize = ((RexxInteger *)parm->oldDimArray->get(oldDimension))->getValue(); + /* For each subscript at this */ + for (i= 1; i <= oldDimSize; i++) + {/* dimension, (of old size) */ + /* copy elelments. */ + copyElements(parm, newDimension + 1); + } + if (newDimSize > oldDimSize) + { /* Was this dimension expanded? */ + /* compute total space need for */ + /* block of all lower dimensions */ + for (i = parm->newDimArray->size(), skipAmount = 1; + i > newDimension; + skipAmount *= ((RexxInteger *)parm->newDimArray->get(i))->getValue(), i--); + /* multiple by delta add at this */ + /* dimension. */ + skipAmount *= (newDimSize - oldDimSize); + /* Bump our start pointer past */ + /* empty space added for this */ + /* dimension. */ + parm->startNew += skipAmount; + } + } + /* all done at this level return */ + /* to caller. */ + return; } @@ -1658,163 +1783,178 @@ /* */ /******************************************************************************/ { - size_t currDimSize; /* Current size of Dimension */ - size_t additionalDim; /* Number of additional DImension */ - size_t newDimSize; /* New size for this Dimension */ - size_t newDimension; /* Current dimension */ - size_t oldDimension; /* Current dimension */ - size_t i; - RexxArray *newArray; - RexxArray *newDimArray; /* Array containing new dimension */ - size_t newDimArraySize; /* Size of Dimension Array */ - size_t accumSize; - size_t firstDimChanged = 0; /* First Dimension to grow */ - COPYELEMENTPARM copyParm; /* Structure for copyElement */ - size_t tempSize; + size_t currDimSize; /* Current size of Dimension */ + size_t additionalDim; /* Number of additional DImension */ + size_t newDimSize; /* New size for this Dimension */ + size_t newDimension; /* Current dimension */ + size_t oldDimension; /* Current dimension */ + size_t i; + RexxArray *newArray; + RexxArray *newDimArray; /* Array containing new dimension */ + size_t newDimArraySize; /* Size of Dimension Array */ + size_t accumSize; + size_t firstDimChanged = 0; /* First Dimension to grow */ + COPYELEMENTPARM copyParm; /* Structure for copyElement */ + size_t tempSize; - /* New dimension array size of */ - /* index array. */ - /* index is actually 1 bigger tha */ - /* dimension size, since it */ - /* contains the new value at 1st */ - /* position */ + /* New dimension array size of */ + /* index array. */ + /* index is actually 1 bigger tha */ + /* dimension size, since it */ + /* contains the new value at 1st */ + /* position */ - /* Compute new Size for DimArray */ - newDimArraySize = _indexCount; - newDimArray = new_array(newDimArraySize); - ProtectedObject p(newDimArray); - /* extending from single Dimensio */ - /* to a multi Dimensionsal array */ - if (this->dimensions == OREF_NULL) { - /* Get value for 1st dimension */ - /* its the last element */ - i = newDimArraySize - 1; - newDimSize = _index[i]->requiredPositive((int)i); - /* Yes, is 1st Dimension going to */ - /* be bigger than current size? */ - if (newDimSize > this->size()) - /* Yes, use new size + buffer for */ - /* 1st Dimension */ - newDimArray->put(new_integer(newDimSize), newDimArraySize); - else { - /* nope, use same size for Dim */ - tempSize = this->size(); - newDimArray->put(new_integer(tempSize), newDimArraySize); + /* Compute new Size for DimArray */ + newDimArraySize = _indexCount; + newDimArray = new_array(newDimArraySize); + ProtectedObject p(newDimArray); + /* extending from single Dimensio */ + /* to a multi Dimensionsal array */ + if (this->dimensions == OREF_NULL) + { + /* Get value for 1st dimension */ + /* its the last element */ + i = newDimArraySize - 1; + newDimSize = _index[i]->requiredPositive((int)i); + /* Yes, is 1st Dimension going to */ + /* be bigger than current size? */ + if (newDimSize > this->size()) + /* Yes, use new size + buffer for */ + /* 1st Dimension */ + newDimArray->put(new_integer(newDimSize), newDimArraySize); + else + { + /* nope, use same size for Dim */ + tempSize = this->size(); + newDimArray->put(new_integer(tempSize), newDimArraySize); + } } - } - else { - for (oldDimension = this->dimensions->size(), newDimension = newDimArraySize; - oldDimension > 0 ; - oldDimension--, newDimension--) { - /* Get current size of this dimension*/ - currDimSize = ((RexxInteger *)this->dimensions->get(oldDimension))->getValue(); - /* Get indexd size of this dimension*/ + else + { + for (oldDimension = this->dimensions->size(), newDimension = newDimArraySize; + oldDimension > 0 ; + oldDimension--, newDimension--) + { + /* Get current size of this dimension*/ + currDimSize = ((RexxInteger *)this->dimensions->get(oldDimension))->getValue(); + /* Get indexd size of this dimension*/ - newDimSize = _index[newDimension - 1]->requiredPositive((int)newDimension); - /* does this dimension need to be */ - /* expanded. */ - if (newDimSize > currDimSize) { - newDimArray->put((RexxObject *)new_integer(newDimSize), newDimension); - /* has a dimension already been chang*/ - if (!firstDimChanged) { - /* remember the first dimenion chenge*/ - firstDimChanged = newDimension; + newDimSize = _index[newDimension - 1]->requiredPositive((int)newDimension); + /* does this dimension need to be */ + /* expanded. */ + if (newDimSize > currDimSize) + { + newDimArray->put((RexxObject *)new_integer(newDimSize), newDimension); + /* has a dimension already been chang*/ + if (!firstDimChanged) + { + /* remember the first dimenion chenge*/ + firstDimChanged = newDimension; + } + } + else + { + newDimArray->put(this->dimensions->get(oldDimension), newDimension); + } } - } - else { - newDimArray->put(this->dimensions->get(oldDimension), newDimension); - } } - } - /* Was original array single dim */ @@ Diff output truncated at 100000 characters. @@ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bigrixx@us...> - 2008-02-29 00:23:28
|
Revision: 2380 http://oorexx.svn.sourceforge.net/oorexx/?rev=2380&view=rev Author: bigrixx Date: 2008-02-28 16:23:22 -0800 (Thu, 28 Feb 2008) Log Message: ----------- incremental checkin Modified Paths: -------------- sandbox/rick/opt/kernel/classes/ClassClass.cpp sandbox/rick/opt/kernel/classes/ClassClass.hpp sandbox/rick/opt/kernel/classes/ListClass.cpp sandbox/rick/opt/kernel/classes/NumberStringClass.cpp sandbox/rick/opt/kernel/classes/StringClassBit.cpp sandbox/rick/opt/kernel/classes/StringClassConversion.cpp sandbox/rick/opt/kernel/classes/StringClassMisc.cpp sandbox/rick/opt/kernel/classes/StringClassSub.cpp sandbox/rick/opt/kernel/classes/StringClassUtil.cpp sandbox/rick/opt/kernel/classes/StringClassWord.cpp sandbox/rick/opt/kernel/classes/StringUtil.cpp sandbox/rick/opt/kernel/classes/StringUtil.hpp sandbox/rick/opt/kernel/classes/SupplierClass.cpp sandbox/rick/opt/kernel/classes/TableClass.cpp sandbox/rick/opt/kernel/classes/TableClass.hpp sandbox/rick/opt/kernel/platform/unix/SysInterpreterInstance.cpp sandbox/rick/opt/kernel/platform/unix/SysInterpreterInstance.hpp sandbox/rick/opt/kernel/platform/windows/SysInterpreterInstance.cpp sandbox/rick/opt/kernel/platform/windows/SysInterpreterInstance.hpp sandbox/rick/opt/kernel/runtime/RexxBuiltinFunctions.h sandbox/rick/opt/kernel/runtime/RexxMemory.cpp sandbox/rick/opt/kernel/runtime/Setup.cpp Modified: sandbox/rick/opt/kernel/classes/ClassClass.cpp =================================================================== --- sandbox/rick/opt/kernel/classes/ClassClass.cpp 2008-02-28 01:20:41 UTC (rev 2379) +++ sandbox/rick/opt/kernel/classes/ClassClass.cpp 2008-02-29 00:23:22 UTC (rev 2380) @@ -1534,7 +1534,7 @@ return new_class; /* return the new class */ } -void RexxClass::createClass() +void RexxClass::createInstance() /******************************************************************************/ /* Function: Create the initial class object */ /******************************************************************************/ Modified: sandbox/rick/opt/kernel/classes/ClassClass.hpp =================================================================== --- sandbox/rick/opt/kernel/classes/ClassClass.hpp 2008-02-28 01:20:41 UTC (rev 2379) +++ sandbox/rick/opt/kernel/classes/ClassClass.hpp 2008-02-29 00:23:22 UTC (rev 2380) @@ -126,7 +126,7 @@ void removeSubclass(RexxClass *c); - static void createClass(); + static void createInstance(); // singleton class instance; static RexxClass *classInstance; Modified: sandbox/rick/opt/kernel/classes/ListClass.cpp =================================================================== --- sandbox/rick/opt/kernel/classes/ListClass.cpp 2008-02-28 01:20:41 UTC (rev 2379) +++ sandbox/rick/opt/kernel/classes/ListClass.cpp 2008-02-29 00:23:22 UTC (rev 2380) @@ -1189,7 +1189,7 @@ RexxList *newList = new RexxList; /* Give new object its behaviour */ newList->setBehaviour(((RexxClass *)this)->getInstanceBehaviour()); - if (((RexxList *)this)->hasUninitDefined()) + if (((RexxClass *)this)->hasUninitDefined()) { newList->hasUninit(); } Modified: sandbox/rick/opt/kernel/classes/NumberStringClass.cpp =================================================================== --- sandbox/rick/opt/kernel/classes/NumberStringClass.cpp 2008-02-28 01:20:41 UTC (rev 2379) +++ sandbox/rick/opt/kernel/classes/NumberStringClass.cpp 2008-02-29 00:23:22 UTC (rev 2380) @@ -53,6 +53,7 @@ #include "NumberStringMath.hpp" #include "RexxBuiltinFunctions.h" /* Gneral purpose BIF Header file */ #include "Numerics.hpp" +#include "StringUtil.hpp": @@ -3053,12 +3054,12 @@ } if (type == true) /* need to pack? */ { - Retval = PackHex(Scan, ResultSize);/* yes, pack to character */ + Retval = StringUtil::packHex(Scan, ResultSize);/* yes, pack to character */ } else { /* allocate result string */ - Retval = (RexxString *)new_string(Scan, ResultSize); + Retval = new_string(Scan, ResultSize); } return Retval; /* return proper result */ } Modified: sandbox/rick/opt/kernel/classes/StringClassBit.cpp =================================================================== --- sandbox/rick/opt/kernel/classes/StringClassBit.cpp 2008-02-28 01:20:41 UTC (rev 2379) +++ sandbox/rick/opt/kernel/classes/StringClassBit.cpp 2008-02-29 00:23:22 UTC (rev 2380) @@ -36,7 +36,7 @@ /* */ /*----------------------------------------------------------------------------*/ /******************************************************************************/ -/* REXX Kernel okbbits.c */ +/* REXX Kernel StringClassBit.cpp */ /* */ /* REXX string BITxxx methods */ /* */ @@ -48,7 +48,7 @@ #include <math.h> #include "RexxCore.h" #include "StringClass.hpp" -#include "RexxBuiltinFunctions.h" /* General purpose BIF Header file */ +#include "RexxBuiltinFunctions.h" /******************************************************************************/ /* Arguments: String to bitand with self */ @@ -59,59 +59,63 @@ RexxString *RexxString::bitAnd(RexxString *string2, RexxString *pad) { - char PadChar; /* pad character */ - const char *String1; /* string 1 pointer */ - const char *PadString; /* padded string part */ - const char *String2; /* string 2 pointer */ - size_t String1Len; /* string 1 length */ - size_t String2Len; /* string 2 length */ - size_t MinLength; /* length of shorter string */ - size_t PadLength; /* length to pad */ - size_t MaxLength; /* longest length */ - RexxString *Retval; /* return value */ - const char *Source; /* source string pointer */ - char *Target; /* target string pointer */ + char PadChar; /* pad character */ + const char *String1; /* string 1 pointer */ + const char *PadString; /* padded string part */ + const char *String2; /* string 2 pointer */ + size_t String1Len; /* string 1 length */ + size_t String2Len; /* string 2 length */ + size_t MinLength; /* length of shorter string */ + size_t PadLength; /* length to pad */ + size_t MaxLength; /* longest length */ + RexxString *Retval; /* return value */ + const char *Source; /* source string pointer */ + char *Target; /* target string pointer */ - /* get string we will be doing bit */ - /* stuff to... */ - string2 = optional_string(string2, OREF_NULLSTRING, ARG_ONE); - String2Len = string2->getLength(); /* get the string length */ - String2 = string2->getStringData(); /* get the string data pointer */ - /* get the pad character */ - PadChar = get_pad(pad, 0xff, ARG_TWO); + /* get string we will be doing bit */ + /* stuff to... */ + string2 = optional_string(string2, OREF_NULLSTRING, ARG_ONE); + String2Len = string2->getLength(); /* get the string length */ + String2 = string2->getStringData(); /* get the string data pointer */ + /* get the pad character */ + PadChar = get_pad(pad, 0xff, ARG_TWO); - String1 = this->getStringData(); /* point to the first string */ - String1Len = this->getLength(); /* get the length */ - if (String1Len <= String2Len) { /* string 1 shorter or equal? */ - MinLength = String1Len; /* string 1 is the shorter */ - MaxLength = String2Len; /* string 2 is the longer */ - PadString = String2; /* padding is done on string2 */ - Source = String1; /* operate from string 1 */ - } - else { - MinLength = String2Len; /* string 2 is the shorter */ - MaxLength = String1Len; /* string 1 is the longer */ - PadString = String1; /* padding is done on string1 */ - Source = String2; /* operate from string 2 */ - } - PadLength = MaxLength - MinLength; /* get the padding length */ - /* Duplicate Longer */ - Retval = raw_string(MaxLength); - Target = Retval->getWritableData(); /* point to the tArget */ - memcpy(Target, PadString, MaxLength);/* now copy in the longer one */ + String1 = this->getStringData(); /* point to the first string */ + String1Len = this->getLength(); /* get the length */ + if (String1Len <= String2Len) + { /* string 1 shorter or equal? */ + MinLength = String1Len; /* string 1 is the shorter */ + MaxLength = String2Len; /* string 2 is the longer */ + PadString = String2; /* padding is done on string2 */ + Source = String1; /* operate from string 1 */ + } + else + { + MinLength = String2Len; /* string 2 is the shorter */ + MaxLength = String1Len; /* string 1 is the longer */ + PadString = String1; /* padding is done on string1 */ + Source = String2; /* operate from string 2 */ + } + PadLength = MaxLength - MinLength; /* get the padding length */ + /* Duplicate Longer */ + Retval = raw_string(MaxLength); + Target = Retval->getWritableData(); /* point to the tArget */ + memcpy(Target, PadString, MaxLength);/* now copy in the longer one */ - while (MinLength--) { /* while shorter has data */ - /* and in each character */ - *Target = *Target & *Source++; - Target++; /* step the target */ - } + while (MinLength--) + { /* while shorter has data */ + /* and in each character */ + *Target = *Target & *Source++; + Target++; /* step the target */ + } - while (PadLength--) { /* while pad needed */ - /* and in a pad character */ - *Target = *Target & PadChar; - Target++; /* step the target */ - } - return Retval; /* return result string */ + while (PadLength--) + { /* while pad needed */ + /* and in a pad character */ + *Target = *Target & PadChar; + Target++; /* step the target */ + } + return Retval; /* return result string */ } /* the BITOR function */ @@ -124,59 +128,63 @@ RexxString *RexxString::bitOr(RexxString *string2, RexxString *pad) { - char PadChar; /* pad character */ - const char *String1; /* string 1 pointer */ - const char *PadString; /* padded string part */ - const char *String2; /* string 2 pointer */ - size_t String1Len; /* string 1 length */ - size_t String2Len; /* string 2 length */ - size_t MinLength; /* length of shorter string */ - size_t PadLength; /* length to pad */ - size_t MaxLength; /* longest length */ - RexxString *Retval; /* return value */ - const char *Source; /* source string pointer */ - char *Target; /* tArget string pointer */ + char PadChar; /* pad character */ + const char *String1; /* string 1 pointer */ + const char *PadString; /* padded string part */ + const char *String2; /* string 2 pointer */ + size_t String1Len; /* string 1 length */ + size_t String2Len; /* string 2 length */ + size_t MinLength; /* length of shorter string */ + size_t PadLength; /* length to pad */ + size_t MaxLength; /* longest length */ + RexxString *Retval; /* return value */ + const char *Source; /* source string pointer */ + char *Target; /* tArget string pointer */ - /* get string we will be doing bit */ - /* stuff to... */ - string2 = optional_string(string2, OREF_NULLSTRING, ARG_ONE); - String2Len = string2->getLength(); /* get the string length */ - String2 = string2->getStringData(); /* get the string data pointer */ - /* get the pad character */ - PadChar = get_pad(pad, 0x00, ARG_TWO); + /* get string we will be doing bit */ + /* stuff to... */ + string2 = optional_string(string2, OREF_NULLSTRING, ARG_ONE); + String2Len = string2->getLength(); /* get the string length */ + String2 = string2->getStringData(); /* get the string data pointer */ + /* get the pad character */ + PadChar = get_pad(pad, 0x00, ARG_TWO); - String1 = this->getStringData(); /* point to the first string */ - String1Len = this->getLength(); /* get the length */ - if (String1Len <= String2Len) { /* string 1 shorter or equal? */ - MinLength = String1Len; /* string 1 is the shorter */ - MaxLength = String2Len; /* string 2 is the longer */ - PadString = String2; /* padding is done on string2 */ - Source = String1; /* operate from string 1 */ - } - else { - MinLength = String2Len; /* string 2 is the shorter */ - MaxLength = String1Len; /* string 1 is the longer */ - PadString = String1; /* padding is done on string1 */ - Source = String2; /* operate from string 2 */ - } - PadLength = MaxLength - MinLength; /* get the padding length */ - /* Duplicate Longer */ - Retval = raw_string(MaxLength); - Target = Retval->getWritableData(); /* point to the tArget */ - memcpy(Target, PadString, MaxLength);/* now copy in the longer one */ + String1 = this->getStringData(); /* point to the first string */ + String1Len = this->getLength(); /* get the length */ + if (String1Len <= String2Len) + { /* string 1 shorter or equal? */ + MinLength = String1Len; /* string 1 is the shorter */ + MaxLength = String2Len; /* string 2 is the longer */ + PadString = String2; /* padding is done on string2 */ + Source = String1; /* operate from string 1 */ + } + else + { + MinLength = String2Len; /* string 2 is the shorter */ + MaxLength = String1Len; /* string 1 is the longer */ + PadString = String1; /* padding is done on string1 */ + Source = String2; /* operate from string 2 */ + } + PadLength = MaxLength - MinLength; /* get the padding length */ + /* Duplicate Longer */ + Retval = raw_string(MaxLength); + Target = Retval->getWritableData(); /* point to the tArget */ + memcpy(Target, PadString, MaxLength);/* now copy in the longer one */ - while (MinLength--) { /* while shorter has data */ - /* and in each character */ - *Target = *Target | *Source++; - Target++; /* step the target */ - } + while (MinLength--) + { /* while shorter has data */ + /* and in each character */ + *Target = *Target | *Source++; + Target++; /* step the target */ + } - while (PadLength--) { /* while pad needed */ - /* and in a pad character */ - *Target = *Target | PadChar; - Target++; /* step the target */ - } - return Retval; /* return result string */ + while (PadLength--) + { /* while pad needed */ + /* and in a pad character */ + *Target = *Target | PadChar; + Target++; /* step the target */ + } + return Retval; /* return result string */ } /* the BITXOR function */ @@ -189,58 +197,62 @@ RexxString *RexxString::bitXor(RexxString *string2, RexxString *pad) { - char PadChar; /* pad character */ - const char *String1; /* string 1 pointer */ - const char *PadString; /* padded string part */ - const char *String2; /* string 2 pointer */ - size_t String1Len; /* string 1 length */ - size_t String2Len; /* string 2 length */ - size_t MinLength; /* length of shorter string */ - size_t PadLength; /* length to pad */ - size_t MaxLength; /* longest length */ - RexxString *Retval; /* return value */ - const char *Source; /* source string pointer */ - char *Target; /* tArget string pointer */ + char PadChar; /* pad character */ + const char *String1; /* string 1 pointer */ + const char *PadString; /* padded string part */ + const char *String2; /* string 2 pointer */ + size_t String1Len; /* string 1 length */ + size_t String2Len; /* string 2 length */ + size_t MinLength; /* length of shorter string */ + size_t PadLength; /* length to pad */ + size_t MaxLength; /* longest length */ + RexxString *Retval; /* return value */ + const char *Source; /* source string pointer */ + char *Target; /* tArget string pointer */ - /* get string we will be doing bit */ - /* stuff to... */ - string2 = optional_string(string2, OREF_NULLSTRING, ARG_ONE); - String2Len = string2->getLength(); /* get the string length */ - String2 = string2->getStringData(); /* get the string data pointer */ - /* get the pad character */ - PadChar = get_pad(pad, 0x00, ARG_TWO); + /* get string we will be doing bit */ + /* stuff to... */ + string2 = optional_string(string2, OREF_NULLSTRING, ARG_ONE); + String2Len = string2->getLength(); /* get the string length */ + String2 = string2->getStringData(); /* get the string data pointer */ + /* get the pad character */ + PadChar = get_pad(pad, 0x00, ARG_TWO); - String1 = this->getStringData(); /* point to the first string */ - String1Len = this->getLength(); /* get the length */ - if (String1Len <= String2Len) { /* string 1 shorter or equal? */ - MinLength = String1Len; /* string 1 is the shorter */ - MaxLength = String2Len; /* string 2 is the longer */ - PadString = String2; /* padding is done on string2 */ - Source = String1; /* operate from string 1 */ - } - else { - MinLength = String2Len; /* string 2 is the shorter */ - MaxLength = String1Len; /* string 1 is the longer */ - PadString = String1; /* padding is done on string1 */ - Source = String2; /* operate from string 2 */ - } - PadLength = MaxLength - MinLength; /* get the padding length */ - /* Duplicate Longer */ - Retval = raw_string(MaxLength); - Target = Retval->getWritableData(); /* point to the tArget */ - memcpy(Target, PadString, MaxLength);/* now copy in the longer one */ + String1 = this->getStringData(); /* point to the first string */ + String1Len = this->getLength(); /* get the length */ + if (String1Len <= String2Len) + { /* string 1 shorter or equal? */ + MinLength = String1Len; /* string 1 is the shorter */ + MaxLength = String2Len; /* string 2 is the longer */ + PadString = String2; /* padding is done on string2 */ + Source = String1; /* operate from string 1 */ + } + else + { + MinLength = String2Len; /* string 2 is the shorter */ + MaxLength = String1Len; /* string 1 is the longer */ + PadString = String1; /* padding is done on string1 */ + Source = String2; /* operate from string 2 */ + } + PadLength = MaxLength - MinLength; /* get the padding length */ + /* Duplicate Longer */ + Retval = raw_string(MaxLength); + Target = Retval->getWritableData(); /* point to the tArget */ + memcpy(Target, PadString, MaxLength);/* now copy in the longer one */ - while (MinLength--) { /* while shorter has data */ - /* and in each character */ - *Target = *Target ^ *Source++; - Target++; /* step the target */ - } + while (MinLength--) + { /* while shorter has data */ + /* and in each character */ + *Target = *Target ^ *Source++; + Target++; /* step the target */ + } - while (PadLength--) { /* while pad needed */ - /* and in a pad character */ - *Target = *Target ^ PadChar; - Target++; /* step the target */ - } - return Retval; /* return result string */ + while (PadLength--) + { /* while pad needed */ + /* and in a pad character */ + *Target = *Target ^ PadChar; + Target++; /* step the target */ + } + return Retval; /* return result string */ } Modified: sandbox/rick/opt/kernel/classes/StringClassConversion.cpp =================================================================== --- sandbox/rick/opt/kernel/classes/StringClassConversion.cpp 2008-02-28 01:20:41 UTC (rev 2379) +++ sandbox/rick/opt/kernel/classes/StringClassConversion.cpp 2008-02-29 00:23:22 UTC (rev 2380) @@ -36,7 +36,7 @@ /* */ /*----------------------------------------------------------------------------*/ /******************************************************************************/ -/* REXX Kernel okbconv.c */ +/* REXX Kernel StringClassConversion.cpp */ /* */ /* REXX string conversion methods */ /* */ @@ -48,305 +48,13 @@ #include "RexxCore.h" #include "StringClass.hpp" #include "BufferClass.hpp" -#include "RexxBuiltinFunctions.h" /* Gneral purpose BIF Header file */ +#include "RexxBuiltinFunctions.h" #include "NumberStringMath.hpp" #include "ActivityManager.hpp" +#include "StringUtil.hpp" -/*********************************************************************/ -/* */ -/* Returns: The numerical value of the hex */ -/* digit (between 0 and 15, inclusive). */ -/* If the argument is not a valid */ -/* hexadecimal digit, then 0 is */ -/* returned, but no error is reported. */ -/* */ -/*********************************************************************/ -int HexDigitToInt( - char ch) /* input hex digit */ -{ - int Retval; /* return value */ - - if (isdigit(ch)) /* if real digit */ - Retval = ch - '0'; /* convert that */ - else - Retval = toupper(ch) - 'A' + 10; /* convert alphabetic */ - return Retval; /* return conversion */ -} - -/*********************************************************************/ -/* */ -/* Returns: The value of the buffer contents */ -/* interpreted as the binary expansion */ -/* of a byte, with most significant */ -/* bit in s[0] and least significant */ -/* bit in s[7]. */ -/* */ -/*********************************************************************/ - -char PackByte( - const char *String ) /* string to pack */ -{ - char Result; /* returned byte */ - int i; - - Result = 0; /* start off at zero */ - for (i = 0; i < 8; i++) /* loop thru 8 chars */ - if (String[i] == '1') /* if 'bit' set */ - Result |= (1<<(7-i)); /* or with mask */ - return Result; /* return packed byte */ -} - -/*********************************************************************/ -/* */ -/* Returns: The value of the buffer contents */ -/* interpreted as the binary expansion */ -/* of a byte, with most significant */ -/* bit in s[0] and least significant */ -/* bit in s[7]. */ -/* */ -/*********************************************************************/ - -char PackNibble( - const char *String ) /* string to pack */ -{ - char Buf[8]; /* temporary buffer */ - int i; /* table index */ - - memset(Buf, '0', 4); /* set first 4 bytes to zero */ - memcpy(Buf+4, String, 4); /* copy next 4 bytes */ - i = PackByte(Buf); /* pack to a single byte */ - return "0123456789ABCDEF"[i]; /* convert to a printable character */ -} - -/*********************************************************************/ -/* */ -/* Name: PackByte2 */ -/* */ -/* Descriptive name: Pack 2 0123456789ABCDEFabcdef chars into */ -/* byte */ -/* */ -/* Returns: The value of the buffer contents */ -/* interpreted as the hex expansion */ -/* of a byte, with most significant */ -/* nibble in s[0] and least significant */ -/* nibble in s[2]. */ -/* */ -/*********************************************************************/ - -char PackByte2( - const char *Byte ) /* location to pack */ -{ - int Nibble1; /* first nibble */ - int Nibble2; /* second nibble */ - - /* convert each digit */ - Nibble1 = HexDigitToInt(Byte[0]); - Nibble2 = HexDigitToInt(Byte[1]); - /* combine the two digits */ - - return ((Nibble1 << 4) | Nibble2); -} - -/*********************************************************************/ -/* */ -/* Name: ValidateSet */ -/* */ -/* Descriptive name: Validate blocks in string */ -/* */ -/* A string is considered valid if consists */ -/* of zero or more characters belonging to */ -/* the null-terminated C string set in */ -/* groups of size modulus. The first group */ -/* may have fewer than modulus characters. */ -/* The groups are optionally separated by */ -/* one or more blanks. */ -/* */ -/*********************************************************************/ - -size_t ValidateSet( - const char *String, /* string to validate */ - size_t Length, /* string length */ - const char *Set, /* character set */ - int Modulus, /* smallest group size */ - bool Hex ) /* HEX or BIN flag */ -{ - char c; /* current character */ - size_t Count; /* # set members found */ - const char *Current; /* current location */ - const char *SpaceLocation = NULL; /* location of last space */ - int SpaceFound; /* space found yet? */ - size_t Residue = 0; /* if space_found, # set */ - /* members */ - - if (*String == ch_SPACE) /* if no leading blank */ - if (Hex) /* hex version? */ - /* raise the hex message */ - reportException(Error_Incorrect_method_hexblank, IntegerOne); - else - /* need the binary version */ - reportException(Error_Incorrect_method_binblank, IntegerOne); - SpaceFound = 0; /* set initial space flag */ - Count = 0; /* start count with zero */ - Current = String; /* point to start */ - - for (; Length; Length--) { /* process entire string */ - c = *Current++; /* get char and step pointer */ - /* if c in set */ - if (c != '\0' && strchr(Set, c) != NULL) - Count++; /* bump count */ - else { - if (c == ch_SPACE) { /* if c blank */ - SpaceLocation = Current; /* save the space location */ - if (!SpaceFound) { /* if 1st blank */ - /* save position */ - Residue = (Count % Modulus); - SpaceFound = 1; /* we have the first space */ - } - /* else if bad position */ - else if (Residue != (Count % Modulus)) { - if (Hex) /* hex version? */ - /* raise the hex message */ - reportException(Error_Incorrect_method_hexblank, SpaceLocation - String); - else - /* need the binary version */ - reportException(Error_Incorrect_method_binblank, SpaceLocation - String); - } - } - else { - - if (Hex) /* hex version? */ - /* raise the hex message */ - reportException(Error_Incorrect_method_invhex, new_string((char *)&c, 1)); - else - reportException(Error_Incorrect_method_invbin, new_string((char *)&c, 1)); - } - } - } - /* if trailing blank or grouping bad */ - if (c == ch_SPACE || SpaceFound && (Count % Modulus) != Residue) { - if (Hex) /* hex version? */ - /* raise the hex message */ - reportException(Error_Incorrect_method_hexblank, SpaceLocation - String); - else - /* need the binary version */ - reportException(Error_Incorrect_method_binblank, SpaceLocation - String); - } - return Count; /* return count of chars */ -} - -/*********************************************************************/ -/* */ -/* Descriptive name: Scan string for next members of */ -/* character set */ -/* */ -/*********************************************************************/ -size_t ChGetSm( - char *Destination, /* destination string */ - const char *Source, /* source string */ - size_t Length, /* length of string */ - size_t Count, /* size of string */ - const char *Set, /* allowed set of chars */ - size_t *ScannedSize) /* size scanned off */ -{ - char c; /* current scanned character */ - const char *Current; /* current scan pointer */ - size_t Found; /* number of characters found */ - size_t Scanned; /* number of character scanned*/ - - Scanned = 0; /* nothing scanned yet */ - Found = 0; /* nothing found yet */ - Current = Source; /* get pointer to string */ - - for (; Length; Length--) { /* scan entire string */ - c = *Current++; /* get char and step pointer */ - Scanned++; /* remember scan count */ - /* if c in set */ - if (c != '\0' && strchr(Set, c) != NULL) { - *Destination++ = c; /* copy c */ - if (++Found == Count) /* if all found */ - break; /* we are all done */ - } - } - *ScannedSize = Scanned; /* return characters scanned */ - return Found; /* and number found */ -} - -/*********************************************************************/ -/* */ -/* Descriptive Name: pack a string of 'hex' digits in place */ -/* */ -/* Function: take two alpha chars and make into one byte */ -/* */ -/*********************************************************************/ - -RexxString *PackHex( - const char *String, /* packed string */ - size_t StringLength ) /* packed string */ -{ - size_t Nibbles; /* count of nibbles to pack */ - size_t n; - const char *Source; /* pack source */ - char * Destination; /* packing destination */ - size_t b; /* nibble odd count */ - char Buf[8]; /* temp pack buffer */ - size_t jjj; /* copies nibbles */ - RexxString *Retval; /* result value */ - - if (StringLength) { /* if not a null string */ - Source = String; /* get pointer */ - /* validate the information */ - Nibbles = ValidateSet(Source, StringLength, "0123456789ABCDEFabcdef", 2, true); - /* get a result string */ - Retval = raw_string((Nibbles + 1) / 2); - /* initialize destination */ - Destination = Retval->getWritableData(); - - while (Nibbles > 0) { /* while chars to process */ - - b = Nibbles%2; /* get nibbles for next byte */ - if (b == 0) /* even number */ - b = 2; /* use two bytes */ - else /* odd number, */ - memset(Buf, '0', 2); /* pad with zeroes */ - - jjj = 2 - b; /* copy nibbles into buff */ - ChGetSm(Buf+jjj, Source, StringLength, b, "0123456789ABCDEFabcdef", &n); - *Destination++ = PackByte2(Buf); /* pack into destination */ - Source += n; /* advance source location */ - StringLength -= n; /* reduce the length */ - Nibbles -= b; /* decrement the count */ - } - } - else - /* this is a null string */ - Retval = OREF_NULLSTRING; - return Retval; /* return the packed string */ -} - -/*********************************************************************/ -/* */ -/* Descriptive name: convert nibble to 4 '0'/'1' chars */ -/* */ -/* Outputs: p[0], ..., p[3]: the four '0'/'1' */ -/* chars representing the nibble */ -/* */ -/* Note: No terminating null character is */ -/* produced */ -/* */ -/*********************************************************************/ - -void UnpackNibble( - int Val, /* nibble to unpack */ - char *p ) /* nibble output location */ -{ - p[0] = (Val & 0x08) != 0 ?'1':'0'; - p[1] = (Val & 0x04) != 0 ?'1':'0'; - p[2] = (Val & 0x02) != 0 ?'1':'0'; - p[3] = (Val & 0x01) != 0 ?'1':'0'; -} - /** * Convert the character string into the same string with the * characters converted into a Base64 encoding. @@ -505,37 +213,41 @@ /* Function: Process the string C2X method/function */ /******************************************************************************/ { - size_t InputLength; /* length of converted string */ - RexxString *Retval; /* return value */ - const char *Source; /* input string pointer */ - char * Destination; /* output string pointer */ - char ch; /* current character */ + size_t InputLength; /* length of converted string */ + RexxString *Retval; /* return value */ + const char *Source; /* input string pointer */ + char * Destination; /* output string pointer */ + char ch; /* current character */ - InputLength = this->getLength(); /* get length of string */ - if (!InputLength) /* null string? */ - Retval = OREF_NULLSTRING; /* converts to a null string */ - else { /* real data to convert */ - /* allocate output string */ - Retval = raw_string(InputLength * 2); - Source = this->getStringData(); /* point to converted string */ - /* point to output area */ - Destination = Retval->getWritableData(); - while (InputLength--) { /* while more string */ - ch = *Source++; /* get next character */ - /***********************************************************/ - /* get upper nibble after shifting out lower nibble and do */ - /* logical ANDING with F to convert to integer then convert*/ - /* to hex value and put it in destination */ - /***********************************************************/ - *Destination++ = IntToHexDigit((ch>>4) & 0xF); - /***********************************************************/ - /* logical AND with F to convert lower nibble to integer */ - /* then convert to hex value and put it in destination */ - /***********************************************************/ - *Destination++ = IntToHexDigit(ch & 0xF); + InputLength = this->getLength(); /* get length of string */ + if (!InputLength) /* null string? */ + { + Retval = OREF_NULLSTRING; /* converts to a null string */ } - } - return Retval; /* return converted string */ + else + { /* real data to convert */ + /* allocate output string */ + Retval = raw_string(InputLength * 2); + Source = this->getStringData(); /* point to converted string */ + /* point to output area */ + Destination = Retval->getWritableData(); + while (InputLength--) + { /* while more string */ + ch = *Source++; /* get next character */ + /***********************************************************/ + /* get upper nibble after shifting out lower nibble and do */ + /* logical ANDING with F to convert to integer then convert*/ + /* to hex value and put it in destination */ + /***********************************************************/ + *Destination++ = IntToHexDigit((ch>>4) & 0xF); + /***********************************************************/ + /* logical AND with F to convert lower nibble to integer */ + /* then convert to hex value and put it in destination */ + /***********************************************************/ + *Destination++ = IntToHexDigit(ch & 0xF); + } + } + return Retval; /* return converted string */ } RexxString *RexxString::d2c(RexxInteger *_length) @@ -543,15 +255,15 @@ /* Function: Process the string D2C method/function */ /******************************************************************************/ { - RexxNumberString *numberstring; /* converted number string version */ - - /* convert to a numberstring */ - numberstring = this->numberString(); - if (numberstring == OREF_NULL) /* not a valid number? */ - /* report this */ - reportException(Error_Incorrect_method_d2c, this); - /* format as a string value */ - return numberstring->d2xD2c(_length, true); + /* convert to a numberstring */ + RexxNumberString *numberstring = this->numberString(); + if (numberstring == OREF_NULL) /* not a valid number? */ + { + /* report this */ + reportException(Error_Incorrect_method_d2c, this); + } + /* format as a string value */ + return numberstring->d2xD2c(_length, true); } RexxString *RexxString::d2x(RexxInteger *_length) @@ -559,15 +271,15 @@ /* Function: Process the string D2X method/function */ /******************************************************************************/ { - RexxNumberString *numberstring; /* converted number string version */ - - /* convert to a numberstring */ - numberstring = this->numberString(); - if (numberstring == OREF_NULL) /* not a valid number? */ - /* report this */ - reportException(Error_Incorrect_method_d2x, this); - /* format as a string value */ - return numberstring->d2xD2c(_length, false); + /* convert to a numberstring */ + RexxNumberString *numberstring = this->numberString(); + if (numberstring == OREF_NULL) /* not a valid number? */ + { + /* report this */ + reportException(Error_Incorrect_method_d2x, this); + } + /* format as a string value */ + return numberstring->d2xD2c(_length, false); } RexxString *RexxString::x2c() @@ -575,17 +287,16 @@ /* Function: Process the string X2C method/function */ /******************************************************************************/ { - size_t InputLength; /* length of converted string */ - RexxString *Retval; /* return value */ - - InputLength = this->getLength(); /* get length of string */ - if (!InputLength) /* null string? */ - Retval = OREF_NULLSTRING; /* converts to a null string */ - - else /* real data to convert */ - /* try to pack the data */ - Retval = PackHex(this->getStringData(), InputLength); - return Retval; /* return the packed string */ + size_t InputLength = this->getLength(); /* get length of string */ + if (InputLength== 0) /* null string? */ + { + return OREF_NULLSTRING; /* converts to a null string */ + } + else /* real data to convert */ + { + /* try to pack the data */ + return StringUtil::packHex(this->getStringData(), InputLength); + } } RexxString *RexxString::x2d(RexxInteger *_length) @@ -594,7 +305,7 @@ /******************************************************************************/ { /* forward to the common routine */ - return this->x2dC2d(_length, false); + return this->x2dC2d(_length, false); } @@ -604,184 +315,229 @@ /* Function: Common X2D/X2C processing routine */ /******************************************************************************/ { - size_t ResultSize; /* size of result string */ - size_t TempSize; /* temporary size value */ - int ch; /* addition character */ - size_t StringLength; /* input string length */ - char *Scan; /* scan pointer */ - char *HighDigit; /* high digit position */ - char * Accumulator; /* accumulator pointer */ - bool Negative; /* have a negative number */ - RexxString *String; /* converted string */ - char *StringPtr; /* string value pointer */ - size_t BytePosition; /* position of high byte */ - size_t NibblePosition; /* position of high nibble */ - size_t DecLength; /* length of accumulator */ - size_t TempLength; /* length of accumulator */ - RexxString *Retval; /* function return value */ - RexxBuffer *Buffer; /* first math buffer */ - size_t CurrentDigits; /* current digits setting */ + size_t ResultSize; /* size of result string */ + size_t TempSize; /* temporary size value */ + int ch; /* addition character */ + size_t StringLength; /* input string length */ + char *Scan; /* scan pointer */ + char *HighDigit; /* high digit position */ + char * Accumulator; /* accumulator pointer */ + bool Negative; /* have a negative number */ + RexxString *String; /* converted string */ + char *StringPtr; /* string value pointer */ + size_t BytePosition; /* position of high byte */ + size_t NibblePosition; /* position of high nibble */ + size_t DecLength; /* length of accumulator */ + size_t TempLength; /* length of accumulator */ + RexxString *Retval; /* function return value */ + RexxBuffer *Buffer; /* first math buffer */ + size_t CurrentDigits; /* current digits setting */ - CurrentDigits = number_digits(); /* get the current digits setting */ - StringLength = this->getLength(); /* get Argument string length */ - /* get the target length */ - ResultSize = optional_length(_length, -1, ARG_ONE); - if (!ResultSize) /* zero requested */ - return (RexxString *)IntegerZero; /* always returns zero */ + CurrentDigits = number_digits(); /* get the current digits setting */ + StringLength = this->getLength(); /* get Argument string length */ + /* get the target length */ + ResultSize = optional_length(_length, -1, ARG_ONE); + if (!ResultSize) /* zero requested */ + { + return(RexxString *)IntegerZero; /* always returns zero */ + } - String = this; /* use this string directly */ - StringPtr = this->getWritableData(); /* get a string pointer */ - NibblePosition = 0; /* assume an even nibble number */ + String = this; /* use this string directly */ + StringPtr = this->getWritableData(); /* get a string pointer */ + NibblePosition = 0; /* assume an even nibble number */ - if (type == true) { /* dealing with character? */ - if (_length == OREF_NULL) { /* no size specified? */ - Negative = false; /* can't be negative */ - ResultSize = StringLength; /* use entire string */ - } - else { /* have to check for negative */ - if (ResultSize > StringLength) /* longer than string? */ - Negative = false; /* can't be negative */ - else { /* have to check sign bit */ - /* step to byte position */ - StringPtr += StringLength - ResultSize; - StringLength = ResultSize; /* adjust the size down */ + if (type == true) + { /* dealing with character? */ + if (_length == OREF_NULL) + { /* no size specified? */ + Negative = false; /* can't be negative */ + ResultSize = StringLength; /* use entire string */ + } + else + { /* have to check for negative */ + if (ResultSize > StringLength) /* longer than string? */ + { + Negative = false; /* can't be negative */ + } + else + { /* have to check sign bit */ + /* step to byte position */ + StringPtr += StringLength - ResultSize; + StringLength = ResultSize; /* adjust the size down */ - if (*StringPtr & 0x80) { /* first bit on? */ - Negative = true; /* this is a negative number */ - /* copy the string */ - String = (RexxString *)this->copy(); - /* point to the string */ - StringPtr = String->getWritableData() + this->getLength() - ResultSize; + if (*StringPtr & 0x80) + { /* first bit on? */ + Negative = true; /* this is a negative number */ + /* copy the string */ + String = (RexxString *)this->copy(); + /* point to the string */ + StringPtr = String->getWritableData() + this->getLength() - ResultSize; + } + else /* still a positive number */ + { + Negative = false; /* remember for later */ + } + } } - else /* still a positive number */ - Negative = false; /* remember for later */ - } } - } - else { /* x2d function */ - /* pack the string */ - String = (RexxString *)PackHex(StringPtr, StringLength); - /* get the packed length */ - StringLength = String->getLength(); - /* point to the packed data */ - StringPtr = String->getWritableData(); - if (_length == OREF_NULL) { /* no size specified? */ - Negative = false; /* can't be negative */ - ResultSize = StringLength; /* use entire string */ - } - else { /* have to check for negative */ + else + { /* x2d function */ + /* pack the string */ + String = (RexxString *)StringUtil::packHex(StringPtr, StringLength); + /* get the packed length */ + StringLength = String->getLength(); + /* point to the packed data */ + StringPtr = String->getWritableData(); + if (_length == OREF_NULL) + { /* no size specified? */ + Negative = false; /* can't be negative */ + ResultSize = StringLength; /* use entire string */ + } + else + { /* have to check for negative */ - BytePosition = ResultSize / 2; /* Get position of sign bit */ - /* get nibble position */ - NibblePosition = ResultSize % 2; - /* Get result size */ - ResultSize = (BytePosition + NibblePosition); - if (ResultSize > StringLength) { /* longer than string? */ - Negative = false; /* can't be negative */ - NibblePosition = 0; /* leave the high nibble alone */ - } - else { /* have to check sign bit */ - /* step to byte position */ - StringPtr += StringLength - ResultSize; - StringLength = ResultSize; /* adjust the size down */ + BytePosition = ResultSize / 2; /* Get position of sign bit */ + /* get nibble position */ + NibblePosition = ResultSize % 2; + /* Get result size */ + ResultSize = (BytePosition + NibblePosition); + if (ResultSize > StringLength) + { /* longer than string? */ + Negative = false; /* can't be negative */ + NibblePosition = 0; /* leave the high nibble alone */ + } + else + { /* have to check sign bit */ + /* step to byte position */ + StringPtr += StringLength - ResultSize; + StringLength = ResultSize; /* adjust the size down */ - if ((NibblePosition && /* odd number of nibbles */ - /* and low nibble negative? */ - *StringPtr & 0x08) || - (!NibblePosition && /* or even number of nibbles */ - *StringPtr & 0x80)) /* and high nibble negative? */ - Negative = true; /* this is a negative number */ - else /* still a positive number */ - Negative = false; /* remember for later */ - } + if ((NibblePosition && /* odd number of nibbles */ + /* and low nibble negative? */ + *StringPtr & 0x08) || + (!NibblePosition && /* or even number of nibbles */ + *StringPtr & 0x80)) /* and high nibble negative? */ + { + Negative = true; /* this is a negative number */ + } + else /* still a positive number */ + { + Negative = false; /* remember for later */ + } + } + } } - } - if (Negative) { /* need to negate string? */ - Scan = StringPtr; /* copy the pointer */ - TempSize = StringLength; /* copy the size */ + if (Negative) + { /* need to negate string? */ + Scan = StringPtr; /* copy the pointer */ + TempSize = StringLength; /* copy the size */ - while (TempSize--) { /* reverse each byte */ - /* exclusive or with foxes */ - *Scan = *Scan ^ 0xff; - Scan++; /* step the pointer */ + while (TempSize--) + { /* reverse each byte */ + /* exclusive or with foxes */ + *Scan = *Scan ^ 0xff; + Scan++; /* step the pointer */ + } + /* point to the first byte */ + Scan = StringPtr + StringLength - 1; + TempSize = StringLength; /* copy the size */ + while (TempSize--) + { /* now add one to the number */ + ch = (*Scan & 0xff); /* get the character */ + ch++; /* increment */ + if (ch <= 0xff) + { /* no carry over? */ + *Scan = ch; /* set value back */ + break; /* we're finished */ + } + else + { /* carried out */ + *Scan = 0; /* this is zero now */ + Scan--; /* step back one pointer */ + } + } } - /* point to the first byte */ - Scan = StringPtr + StringLength - 1; - TempSize = StringLength; /* copy the size */ - while (TempSize--) { /* now add one to the number */ - ch = (*Scan & 0xff); /* get the character */ - ch++; /* increment */ - if (ch <= 0xff) { /* no carry over? */ - *Scan = ch; /* set value back */ - break; /* we're finished */ - } - else { /* carried out */ - *Scan = 0; /* this is zero now */ - Scan--; /* step back one pointer */ - } + if (NibblePosition) /* Odd number of nibbles? */ + { + *StringPtr &= 0x0f; /* zero out the highest nibble */ } - } - if (NibblePosition) /* Odd number of nibbles? */ - *StringPtr &= 0x0f; /* zero out the highest nibble */ - Scan = StringPtr; /* point to the string */ - /* allocate a temp buffer */ - Buffer = (RexxBuffer *)new_buffer(CurrentDigits + OVERFLOWSPACE + 1); - /* set accumulator pointer */ - Accumulator = Buffer->getData() + CurrentDigits + OVERFLOWSPACE; - /* clear the buffer */ - memset(Buffer->getData(), '\0', CurrentDigits + OVERFLOWSPACE + 1); - HighDigit = Accumulator - 1; /* set initial high point */ + Scan = StringPtr; /* point to the string */ + /* allocate a temp buffer */ + Buffer = (RexxBuffer *)new_buffer(CurrentDigits + OVERFLOWSPACE + 1); + /* set accumulator pointer */ + Accumulator = Buffer->getData() + CurrentDigits + OVERFLOWSPACE; + /* clear the buffer */ + memset(Buffer->getData(), '\0', CurrentDigits + OVERFLOWSPACE + 1); + HighDigit = Accumulator - 1; /* set initial high point */ - while (StringLength--) { /* while more digits */ - ch = *Scan++; /* get the character */ - /* add high order nibble */ - HighDigit = AddToBaseTen((ch & 0xf0) >> 4, Accumulator, HighDigit); - /* multiply by 16 */ - HighDigit = MultiplyBaseTen(Accumulator, HighDigit); - /* get accumulator length */ - DecLength = (Accumulator - HighDigit); - if (DecLength > CurrentDigits) { /* grown too long? */ - if (type == true) /* c2d version? */ - reportException(Error_Incorrect_method_c2dbig, CurrentDigits); - else /* this is the x2d function */ - reportException(Error_Incorrect_method_x2dbig, CurrentDigits); + while (StringLength--) + { /* while more digits */ + ch = *Scan++; /* get the character */ + /* add high order nibble */ + HighDigit = AddToBaseTen((ch & 0xf0) >> 4, Accumulator, HighDigit); + /* multiply by 16 */ + HighDigit = MultiplyBaseTen(Accumulator, HighDigit); + /* get accumulator length */ + DecLength = (Accumulator - HighDigit); + if (DecLength > CurrentDigits) + { /* grown too long? */ + if (type == true) /* c2d version? */ + { + reportException(Error_Incorrect_method_c2dbig, CurrentDigits); + } + else /* this is the x2d function */ + { + reportException(Error_Incorrect_method_x2dbig, CurrentDigits); + } + } + /* add high order nibble */ + HighDigit = AddToBaseTen(ch & 0x0f, Accumulator, HighDigit); + if (StringLength != 0) /* not the last one? */ + { + /* multiply by 16 */ + HighDigit = MultiplyBaseTen(Accumulator, HighDigit); + } + /* get accumulator length */ + DecLength = (Accumulator - HighDigit); + if (DecLength > CurrentDigits) + { /* grown too long? */ + if (type == true) /* c2d version? */ + { + reportException(Error_Incorrect_method_c2dbig, CurrentDigits); + } + else /* this is the x2d function */ + { + reportException(Error_Incorrect_method_x2dbig, CurrentDigits); + } + } } - /* add high order nibble */ - HighDigit = AddToBaseTen(ch & 0x0f, Accumulator, HighDigit); - if (StringLength != 0) /* not the last one? */ - /* multiply by 16 */ - HighDigit = MultiplyBaseTen(Accumulator, HighDigit); - /* get accumulator length */ + /* get accumulator length */ DecLength = (Accumulator - HighDigit); - if (DecLength > CurrentDigits) { /* grown too long? */ - if (type == true) /* c2d version? */ - reportException(Error_Incorrect_method_c2dbig, CurrentDigits); - else /* this is the x2d function */ - reportException(Error_Incorrect_method_x2dbig, CurrentDigits); + TempLength = DecLength; /* copy the length */ + Scan = HighDigit + 1; /* point to the first digit */ + while (TempLength--) + { /* make into real digits again */ + /* add zero to each digit */ + *Scan = *Scan + '0'; + Scan++; /* step the pointer */ } - } - /* get accumulator length */ - DecLength = (Accumulator - HighDigit); - TempLength = DecLength; /* copy the length */ - Scan = HighDigit + 1; /* point to the first digit */ - while (TempLength--) { /* make into real digits again */ - /* add zero to each digit */ - *Scan = *Scan + '0'; - Scan++; /* step the pointer */ - } - ResultSize = DecLength; /* get the result size */ - if (Negative) /* negative number? */ - ResultSize++; /* add in space for the sign */ - Retval = raw_string(ResultSize); /* allocate output buffer */ - Scan = Retval->getWritableData(); /* point to output location */ - if (Negative) /* need a sign? */ - *Scan++ = '-'; /* add to the front */ - /* copy in the number */ - memcpy(Scan, Accumulator - DecLength + 1, DecLength); - return Retval; /* return converted string */ + ResultSize = DecLength; /* get the result size */ + if (Negative) /* negative number? */ + { + ResultSize++; /* add in space for the sign */ + } + Retval = raw_string(ResultSize); /* allocate output buffer */ + Scan = Retval->getWritableData(); /* point to output location */ + if (Negative) /* need a sign? */ + { + *Scan++ = '-'; /* add to the front */ + } + /* copy in the number */ + memcpy(Scan, Accumulator - DecLength + 1, DecLength); + return Retval; /* return converted string */ } RexxString *RexxString::b2x() @@ -789,43 +545,50 @@ /* Function: Common B2X processing routine */ /******************************************************************************/ { - RexxString *Retval; /* function result */ - size_t Bits; /* number of bits in string */ - const char *Source; /* current source pointer */ - char *Destination; /* destination pointer */ - size_t Excess; /* section boundary */ - char Nibble[4]; /* current nibble string */ - size_t Jump; /* string movement offset */ - size_t Length; /* total string length */ + RexxString *Retval; /* function result */ + size_t Bits; /* number of bits in string */ + const char *Source; /* current source pointer */ + char *Destination; /* destination pointer */ + size_t Excess; /* section boundary */ + char Nibble[4]; /* current nibble string */ + size_t Jump; /* string movement offset */ + size_t Length; /* total string length */ - if (this->getLength() == 0) /* null input, i.e. zerolength */ - /* string */ - Retval = OREF_NULLSTRING; /* return null */ - else { /* need to do conversion */ - /* validate the string */ - Bits = ValidateSet(this->getStringData(), this->getLength(), "01", 4, false); - /* allocate space for result */ - Retval = raw_string((Bits + 3) / 4); - /* point to the data */ - Destination = Retval->getWritableData(); - Source = this->getStringData(); /* point to the source */ - Length = this->getLength(); /* get the string length */ + if (this->getLength() == 0) /* null input, i.e. zerolength */ + { + Retval = OREF_NULLSTRING; /* return null */ + } + else + { /* need to do conversion */ + /* validate the string */ + Bits = StringUtil::validateSet(this->getStringData(), this->getLength(), "01", 4, false); + /* allocate space for result */ + Retval = raw_string((Bits + 3) / 4); + /* point to the data */ + Destination = Retval->getWritableData(); + Source = this->getStringData(); /* point to the source */ + Length = this->getLength(); /* get the string length */ - while (Bits > 0) { /* process the string */ - Excess = Bits % 4; /* calculate section size */ - if (Excess == 0) /* zero is a multiple of 4 */ - Excess = 4; /* so use 4 */ - else - memset(Nibble, '0', 4); /* pad the nibble with zeroes */ - ChGetSm(&Nibble[0] + (4 - Excess), Source, Length, Excess, "01", &Jump); - /* pack into destination */ - *Destination++ = PackNibble(Nibble); - Source += Jump; /* advance source pointer */ - Length -= Jump; /* reduce remaining length */ - Bits -= Excess; /* reduce remaining amount */ + while (Bits > 0) + { /* process the string */ + Excess = Bits % 4; /* calculate section size */ + if (Excess == 0) /* zero is a multiple of 4 */ + { + Excess = 4; /* so use 4 */ + } + else + { + memset(Nibble, '0', 4); /* pad the nibble with zeroes */ + } + StringUtil::chGetSm(&Nibble[0] + (4 - Excess), Source, Length, Excess, "01", &Jump); + /* pack into destination */ + *Destination++ = StringUtil::packNibble(Nibble); + Source += Jump; /* advance source pointer */ + Length -= Jump; /* reduce remaining length */ + Bits -= Excess; /* reduce remaining amount */ + } } - } - return Retval; /* return packed string */ + return Retval; /* return packed string */ } RexxString *RexxString::c2d(RexxInteger *_length) @@ -834,7 +597,7 @@ /******************************************************************************/ { /* forward to the common routine */ - return this->x2dC2d(_length, true); + return this->x2dC2d(_length, true); } RexxString *RexxString::x2b() @@ -842,37 +605,42 @@ /* Function: Common X2B processing routine */ /******************************************************************************/ { - RexxString *Retval; /* function result */ - size_t Nibbles; /* nibbles in hex string */ - const char *Source; /* current source pointer */ - char *Destination; /* destination pointer */ - char Nibble[4]; /* current nibble string */ - char ch; /* current string character */ - int Val; /* converted nible */ + RexxString *Retval; /* function result */ + size_t Nibbles; /* nibbles in hex string */ + const char *Source; /* current source pointer */ + char *Destination; /* destination pointer */ + char Nibble[4]; /* current nibble string */ + char ch; /* current string character */ + int Val; /* converted nible */ - if (this->getLength() == 0) /* null input, i.e. zerolength */ - /* string */ - Retval = OREF_NULLSTRING; /* return null */ - else { /* have real data to pack */ - Nibbles = ValidateSet(this->getStringData(), this->getLength(), "0123456789ABCDEFabcdef", 2, true); - Retval = raw_string(Nibbles * 4); /* allocate result string */ - /* point to the data */ - Destination = Retval->getWritableData(); - Source = this->getStringData(); /* point to the source */ + if (this->getLength() == 0) /* null input, i.e. zerolength */ + { + /* string */ + Retval = OREF_NULLSTRING; /* return null */ + } + else + { /* have real data to pack */ + Nibbles = StringUtil::validateSet(this->getStringData(), this->getLength(), "0123456789ABCDEFabcdef", 2, true); + Retval = raw_string(Nibbles * 4); /* allocate result string */ + /* point to the data */ + Destination = Retval->getWritableData(); + Source = this->getStringData(); /* point to the source */ - while (Nibbles > 0) { /* while still string to pack */ - ch = *Source++; /* get current char and bump */ - /* pointer */ - if (ch != ch_SPACE) { /* if not a filler space */ - Val = HexDigitToInt(ch); /* convert hex to int first */ - UnpackNibble(Val, Nibble); /* then convert to binary */ - /* digits */ - /* copy to the destination */ - memcpy(Destination, Nibble, 4); - Destination += 4; /* bump destination pointer */ - Nibbles--; /* Reduce nibbles count */ - } + while (Nibbles > 0) + { /* while still string to pack */ + ch = *Source++; /* get current char and bump */ + /* pointer */ + if (ch != ch_SPACE) + { /* if not a filler space */ + Val = StringUtil::hexDigitToInt(ch); /* convert hex to int first */ + StringUtil::unpackNibble(Val, Nibble); /* then convert to binary */ + /* digits */ + /* copy to the destination */ + memcpy(Destination, Nibble, 4); + Destination += 4; /* bump destination pointer */ + Nibbles--; /* Reduce nibbles count */ + } + } } - } - return Retval; /* return the expanded string */ + return Retval; /* return the expanded string */ } Modified: sandbox/rick/opt/kernel/classes/StringClassMisc.cpp =================================================================== --- sandbox/rick/opt/kernel/classes/StringClassMisc.cpp 2008-02-28 01:20:41 UTC (rev 2379) +++ sandbox/rick/opt/kernel/classes/StringClassMisc.cpp 2008-02-29 00:23:22 UTC (rev 2380) @@ -48,101 +48,11 @@ #include <math.h> #include "RexxCore.h" #include "StringClass.hpp" -#include "RexxBuiltinFunctions.h" /* General purpose BIF Header file */ +#include "RexxBuiltinFunctions.h" #include "SourceFile.hpp" #include "ActivityManager.hpp" #include "StringUtil.hpp" -const char *Memcpbrk( - const char *String, /* search string */ - const char *Set, /* reference set */ - size_t Length ) /* size of string */ -/*********************************************************************/ -/* Function: Find first occurence of set nonmember in block */ -/*********************************************************************/ -{ - const char *Retval; /* returned value */ - - Retval = NULL; /* nothing found yet */ - while (Length--) { /* search through string */ - /* find a match in ref set? */ - if (*String == '\0' || !strchr(Set, *String)) { - Retval = String; /* copy position */ - break; /* quit the loop */ - } - String++; /* step the pointer */ - } - return Retval; /* return matched position */ -} - -int ValSet( - const char *String, /* string to validate */ - size_t Length, /* string length */ - const char *Set, /* character set */ - int Modulus, /* smallest group size */ - size_t *PackedSize ) /* total packed size */ -/*********************************************************************/ -/* Function: Validate blocks in string */ -/* */ -/* A string is considered valid if consists */ -/* of zero or more characters belonging to */ -/* the null-terminated C string set in */ -/* groups of size modulus. The first group */ -/* may have fewer than modulus characters. */ -/* The groups are optionally separated by */ -/* one or more blanks. */ -/*********************************************************************/ -{ - char c = '\0'; /* current character */ - size_t Count; /* # set members found */ - const char *Current; /* current location */ - int SpaceFound; /* space found yet? */ - size_t Residue = 0; /* if space_found, # set members */ - int rc; /* return code */ - - rc = false; /* default to failure */ - if (*String != ' ' && *String != '\t') { /* if no leading blank */ - SpaceFound = 0; /* set initial space flag */ - Count = 0; /* start count with zero */ - Current = String; /* point to start */ - - rc = true; /* default to good now */ - for (; Length; Length--) { /* process entire string */ - c = *Current++; /* get char and step pointer */ - /* if c in set */ - if (c != '\0' && strchr(Set, c) != NULL) - Count++; /* bump count */ - else { - if (c == ' ' || c == '\t') { /* if c blank */ - if (!SpaceFound) { /* if 1st blank */ - /* save position */ - Residue = (Count % Modulus); - SpaceFound = 1; /* we have the first space */ - } - /* else if bad position */ - else if (Residue != (Count % Modulus)) { - rc = false; /* this is an error */ - break; /* report error */ - } - } - else { - rc = false; /* this is an error */ - break; /* report error */ - } - } - } - if (rc) { /* still good? */ - if (c == ' ' || c == '\t') /* if trailing blank */ - rc = false; /* report error */ - else if (SpaceFound && (Count % Modulus) != Residue) - rc = false; /* grouping problem */ - else - *PackedSize = Count; /* return count of chars */ - } - } - return rc; /* return success/failure */ -} - int RexxString::isSymbol() /*********************************************************************/ /* */ @@ -152,225 +62,125 @@ /* */ /*********************************************************************/ { - const char *Scan; /* string scan pointer */ - size_t Compound; /* count of periods */ - size_t i; /* loop counter */ - const char *Linend; /* end of line */ - int Type; /* return type */ + const char *Scan; /* string scan pointer */ + size_t Compound; /* count of periods */ + size_t i; /* loop counter */ + const char *Linend; /* end of line */ + int Type; /* return type */ - /* name too long */ - /* or too short */ - if (this->getLength() > (size_t)MAX_SYMBOL_LENGTH || this->getLength() == 0) - return STRING_BAD_VARIABLE; /* set a bad type */ + /* name too long */ + /* or too short */ + if (this->getLength() > (size_t)MAX_SYMBOL_LENGTH || this->getLength() == 0) + { + return STRING_BAD_VARIABLE; /* set a bad type */ + } - /* step to end */ - Linend = this->getStringData() + this->getLength(); + /* step to end */ + Linend = this->getStringData() + this->getLength(); - Compound = 0; /* set compound name is no */ - Scan = this->getStringData(); /* save start position */ - /* while still part of symbol */ - while (Scan < Linend && RexxSource::isSymbolCharacter(*Scan)) { + Compound = 0; /* set compound name is no */ + Scan = this->getStringData(); /* save start position */ + /* while still part of symbol */ + while (Scan < Linend && RexxSource::isSymbolCharacter(*Scan)) + { - if (*Scan == '.') /* a dot found.. */ - Compound++; /* indicate a compound var */ + if (*Scan == '.') /* a dot found.. */ + { + Compound++; /* indicate a compound var */ + } - Scan++; /* step the pointer */ - } /* len of symbol */ - /* now check for exponent */ - if (((Scan + 1) < Linend) && - (*Scan == '-' || *Scan == '+') && - (isdigit(this->getChar(0)) || *Scan == '.') && - (toupper(*(Scan - 1)) == 'E')) { - Scan++; /* step to next */ + Scan++; /* step the pointer */ + } /* len of symbol */ + /* now check for exponent */ + if (((Scan + 1) < Linend) && + (*Scan == '-' || *Scan == '+') && + (isdigit(this->getChar(0)) || *Scan == '.') && + (toupper(*(Scan - 1)) == 'E')) + { + Scan++; /* step to next */ - while (Scan < Linend) { /* while more characters */ - if (!isdigit(*Scan)) /* if not a digit */ - return STRING_BAD_VARIABLE; /* this isn't valid */ - Scan++; /* step to next char */ - } - } - if (Scan < Linend) /* use the entire string? */ - return STRING_BAD_VARIABLE; /* no, can't be good */ - /* now determine symbol type */ - /* possible number? */ - if (this->getChar(0) == '.' || isdigit(this->getChar(0))) { - - /* only a period? */ - if (Compound == 1 && this->getLength() == 1) - Type = STRING_LITERAL_DOT; /* yes, set the token type */ - else if (Compound > 1) /* too many periods? */ - Type = STRING_LITERAL; /* yes, just a literal token */ - else { /* check for a real number */ - Type = STRING_NUMERIC; /* assume numeric for now */ - Scan = this->getStringData(); /* point to symbol */ - /* scan symbol, validating */ - for (i = this->getLength() ; i; i-- ) { - if (!isdigit(*Scan) && /* if not a digit and */ - *Scan != '.') /* and not a period... */ - break; /* finished */ - Scan++; /* step to next character */ - } - if (i > 1 && /* if tripped over an 'E' */ - toupper(*Scan) == 'E') { /* could be exponential */ - Scan++; /* step past E */ - i--; /* count the character */ - /* +/- case already validated */ - if (*Scan != '+' && *Scan != '-') { - for(; i; i--) { /* scan rest of symbol */ - if (!isdigit(*Scan)) { /* if not a digit... */ - Type = STRING_LITERAL; /* not a number */ - break; + while (Scan < Linend) + { /* while more characters */ + if (!isdigit(*Scan)) /* if not a digit */ + { + return STRING_BAD_VARIABLE; /* this isn't valid */ } - Scan++; /* step to next character */ - } + Scan++; /* step to next char */ } - } - else if (i) /* literal if stuff left */ - Type = STRING_LITERAL; /* yes, just a literal token */ } - } + if (Scan < Linend) /* use the entire string? */ + { + return STRING_BAD_VARIABLE; /* no, can't be good */ + } + /* now determine symbol type */ + /* possible number? */ + if (this->getChar(0) == '.' || isdigit(this->getChar(0))) + { - else if (!Compound) { /* not a compound so... */ - Type = STRING_NAME; /* set the token type */ - } - /* is it a stem? */ - else if (Compound == 1 && *(Scan - 1) == '.') - Type = STRING_STEM; /* yes, set the token type */ - else - Type = STRING_COMPOUND_NAME; /* otherwise just plain */ - /* compound */ - return Type; /* return the type info */ -} - -RexxObject *DataType( - RexxString *String, /* string value */ - char Option ) /* requested option */ -/*********************************************************************/ -/* Function: Perform primitive datatype validation */ -/*********************************************************************/ -{ - size_t Len; /* validated string length */ - RexxObject *Answer; /* validation result */ - RexxObject *Temp; /* temporary value */ - const char *Scanp; /* string data pointer */ - size_t Count; /* hex nibble count */ - int Type; /* validated symbol type */ - RexxNumberString *TempNum; - - Len = String->getLength(); /* get validated string len */ - Option = toupper(Option); /* get the first character */ - - /* assume failure on checking */ - Answer = (RexxObject *)TheFalseObject; - /* get a scan pointer */ - Scanp = String->getStringData(); - - switch (Option) { /* based on type to confirm */ - - case DATATYPE_ALPHANUMERIC: /* Alphanumeric */ - /* all in the set? */ - if (Len != 0 && !Memcpbrk(Scanp, ALPHANUM, Len)) - /* this is a good string */ - Answer = (RexxObject *)TheTrueObject; - break; - - case DATATYPE_BINARY: /* Binary string */ @@ Diff output truncated at 100000 characters. @@ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bigrixx@us...> - 2008-06-16 13:10:27
|
Revision: 2543 http://oorexx.svn.sourceforge.net/oorexx/?rev=2543&view=rev Author: bigrixx Date: 2008-06-16 06:10:10 -0700 (Mon, 16 Jun 2008) Log Message: ----------- incremental checkin Modified Paths: -------------- sandbox/rick/opt/kernel/platform/unix/SysFile.cpp sandbox/rick/opt/kernel/platform/windows/SysFile.cpp sandbox/rick/opt/kernel/runtime/RexxActivation.cpp sandbox/rick/opt/kernel/runtime/RexxActivation.hpp sandbox/rick/opt/kernel/runtime/RexxNativeActivation.cpp sandbox/rick/opt/kernel/streamLibrary/StreamNative.cpp Modified: sandbox/rick/opt/kernel/platform/unix/SysFile.cpp =================================================================== --- sandbox/rick/opt/kernel/platform/unix/SysFile.cpp 2008-06-15 23:36:46 UTC (rev 2542) +++ sandbox/rick/opt/kernel/platform/unix/SysFile.cpp 2008-06-16 13:10:10 UTC (rev 2543) @@ -72,19 +72,20 @@ mode = 0; share = 0; filename = NULL; - buffered = true; + buffered = false; transient = false; device = false; writeable = false; readable = false; isTTY = false; buffer = NULL; - bufferSize = 0; + bufferSize = DEFAULT_BUFFER_SIZE; bufferPosition = 0; bufferedInput = 0; append = true; filePointer = 0; ungetchar = 0; + writeBuffer = false; // no pending write operations } /** @@ -109,7 +110,7 @@ ungetchar = 0xFF; // 0xFF indicates no char // is this append mode? - if (flags & RX_O_APPEND) + if ((flags & RX_O_APPEND) != 0) { // mark this true, and position at the end append = true; @@ -423,7 +424,7 @@ if (!transient) { // opened in append mode? - if (flags & O_APPEND) + if ((flags & O_APPEND) != 0) { // seek to the end of the file, return if there is an error if (lseek(fileHandle, 0, SEEK_END) < 0) @@ -539,6 +540,7 @@ i--; buffer[i] = '\n'; } + i++; // we need to step the position so that the null terminator doesn't overwrite break; } } @@ -548,7 +550,7 @@ // this is the length minus the terminating null bytesRead = i; // return an error state, but not EOF status. - return error(); + return !error(); } /** @@ -856,7 +858,7 @@ if (fstat(fileHandle, &fileInfo) == 0) { // regular file? return the defined size - if (fileInfo.st_mode & S_IFREG) + if ((fileInfo.st_mode & S_IFREG) != 0) { size = fileInfo.st_size; } @@ -885,7 +887,7 @@ if (stat(name, &fileInfo) == 0) { // regular file? return the defined size - if (fileInfo.st_mode & S_IFREG) + if ((fileInfo.st_mode & S_IFREG) != 0) { size = fileInfo.st_size; } @@ -918,7 +920,7 @@ if (fstat(fileHandle, &fileInfo) == 0) { // regular file? return the defined size - if (fileInfo.st_mode & S_IFREG) + if ((fileInfo.st_mode & S_IFREG) != 0) { time = ctime(&fileInfo.st_mtime); } @@ -943,7 +945,7 @@ if (stat(name, &fileInfo) == 0) { // regular file? return the defined size - if (fileInfo.st_mode & S_IFREG) + if ((fileInfo.st_mode & S_IFREG) != 0) { time = ctime(&fileInfo.st_mtime); } @@ -975,18 +977,18 @@ if (fstat(fileHandle, &fileInfo) == 0) { // regular file? return the defined size - if ((fileInfo.st_mode & S_IFREG) == 0) + if ((fileInfo.st_mode & S_IFREG) != 0) { device = true; transient = true; } - if ((fileInfo.st_mode & S_IWRITE) == 0) + if ((fileInfo.st_mode & S_IWRITE) != 0) { writeable = true; } - if ((fileInfo.st_mode & S_IREAD) == 0) + if ((fileInfo.st_mode & S_IREAD) != 0) { readable = true; } @@ -1004,6 +1006,7 @@ openedHandle = false; ungetchar = 0xFF; // -1 indicates no char getStreamTypeInfo(); + setBuffering(false, 0); } /** @@ -1017,6 +1020,7 @@ openedHandle = false; ungetchar = 0xFF; // -1 indicates no char getStreamTypeInfo(); + setBuffering(false, 0); } /** @@ -1030,6 +1034,7 @@ openedHandle = false; ungetchar = 0xFF; // -1 indicates no char getStreamTypeInfo(); + setBuffering(false, 0); } Modified: sandbox/rick/opt/kernel/platform/windows/SysFile.cpp =================================================================== --- sandbox/rick/opt/kernel/platform/windows/SysFile.cpp 2008-06-15 23:36:46 UTC (rev 2542) +++ sandbox/rick/opt/kernel/platform/windows/SysFile.cpp 2008-06-16 13:10:10 UTC (rev 2543) @@ -67,12 +67,13 @@ readable = false; isTTY = false; buffer = NULL; - bufferSize = 0; + bufferSize = DEFAULT_BUFFER_SIZE; bufferPosition = 0; bufferedInput = 0; append = true; filePointer = 0; ungetchar = 0; + writeBuffered = false; // no pending write operations } @@ -105,7 +106,7 @@ ungetchar = -1; // -1 indicates no char // is this append mode? - if (flags & RX_O_APPEND) + if ((flags & RX_O_APPEND) != 0) { // mark this true, and position at the end append = true; @@ -414,7 +415,7 @@ if (!transient) { // opened in append mode? - if (flags & _O_APPEND) + if ((flags & _O_APPEND) != 0) { // seek to the end of the file, return if there is an error if (_lseeki64(fileHandle, 0, SEEK_END) < 0) @@ -504,7 +505,7 @@ bool SysFile::gets(char *buffer, size_t bufferLen, size_t &bytesRead) { size_t i; - for ( i = 0; i < bufferLen - 1; i++) + for (i = 0; i < bufferLen - 1; i++) { size_t len; @@ -530,6 +531,7 @@ i--; buffer[i] = '\n'; } + i++; // we need to step the position so that the null terminator doesn't overwrite break; } } @@ -539,7 +541,7 @@ // this is the length minus the terminating null bytesRead = i; // return an error state, but not EOF status. - return error(); + return !error(); } /** @@ -642,7 +644,7 @@ // this is the length including the line terminators bytesRead = len; // return an error state, but not EOF status. - return error(); + return !error(); } bool SysFile::seekForwardLines(int64_t startPosition, int64_t &lineCount, int64_t &endPosition) @@ -847,7 +849,7 @@ if (_fstati64(fileHandle, &fileInfo) == 0) { // regular file? return the defined size - if (fileInfo.st_mode & _S_IFREG) + if ((fileInfo.st_mode & _S_IFREG) != 0) { size = fileInfo.st_size; } @@ -876,7 +878,7 @@ if (_stati64(name, &fileInfo) == 0) { // regular file? return the defined size - if (fileInfo.st_mode & _S_IFREG) + if ((fileInfo.st_mode & _S_IFREG) != 0) { size = fileInfo.st_size; } @@ -909,7 +911,7 @@ if (_fstati64(fileHandle, &fileInfo) == 0) { // regular file? return the defined size - if (fileInfo.st_mode & _S_IFREG) + if ((fileInfo.st_mode & _S_IFREG) != 0) { time = ctime(&fileInfo.st_mtime); } @@ -934,7 +936,7 @@ if (_stati64(name, &fileInfo) == 0) { // regular file? return the defined size - if (fileInfo.st_mode & _S_IFREG) + if ((fileInfo.st_mode & _S_IFREG) != 0) { time = ctime(&fileInfo.st_mtime); } @@ -966,18 +968,18 @@ if (_fstati64(fileHandle, &fileInfo) == 0) { // regular file? return the defined size - if ((fileInfo.st_mode & _S_IFREG) == 0) + if ((fileInfo.st_mode & _S_IFREG) != 0) { device = true; transient = true; } - if ((fileInfo.st_mode & _S_IWRITE) == 0) + if ((fileInfo.st_mode & _S_IWRITE) != 0) { writeable = true; } - if ((fileInfo.st_mode & _S_IREAD) == 0) + if ((fileInfo.st_mode & _S_IREAD) != 0) { readable = true; } @@ -995,6 +997,7 @@ openedHandle = false; ungetchar = -1; // -1 indicates no char getStreamTypeInfo(); + setBuffering(false, 0); } /** @@ -1008,6 +1011,7 @@ openedHandle = false; ungetchar = -1; // -1 indicates no char getStreamTypeInfo(); + setBuffering(false, 0); } /** @@ -1021,6 +1025,7 @@ openedHandle = false; ungetchar = -1; // -1 indicates no char getStreamTypeInfo(); + setBuffering(false, 0); } Modified: sandbox/rick/opt/kernel/runtime/RexxActivation.cpp =================================================================== --- sandbox/rick/opt/kernel/runtime/RexxActivation.cpp 2008-06-15 23:36:46 UTC (rev 2542) +++ sandbox/rick/opt/kernel/runtime/RexxActivation.cpp 2008-06-16 13:10:10 UTC (rev 2543) @@ -127,8 +127,7 @@ this->executable = _method; // save this as the base executable this->settings.intermediate_trace = false; this->activation_context = METHODCALL; // the context is a method call - /* save the sender activation */ - this->sender = _activity->getCurrentRexxFrame(); + this->parent = OREF_NULL; // we don't have a parent stack frame when invoked as a method this->execution_state = ACTIVE; /* we are now in active execution */ this->object_scope = SCOPE_RELEASED; /* scope not reserved yet */ /* create a new evaluation stack. This must be done before a */ @@ -190,8 +189,8 @@ } this->activation_context = context; /* save the context */ this->settings.intermediate_trace = false; - /* save the sender activation */ - this->sender = _activity->getCurrentRexxFrame(); + // the sender is our parent activity + this->parent = _parent; this->execution_state = ACTIVE; /* we are now in active execution */ this->object_scope = SCOPE_RELEASED; /* scope not reserved yet */ /* create a new evaluation stack. This must be done before a */ @@ -247,8 +246,7 @@ this->activation_context = context; /* save the context */ this->settings.intermediate_trace = false; - /* save the sender activation */ - this->sender = _activity->getCurrentRexxFrame(); + this->parent = OREF_NULL; // there's no parent for a top level call this->execution_state = ACTIVE; /* we are now in active execution */ this->object_scope = SCOPE_RELEASED; /* scope not reserved yet */ /* create a new evaluation stack. This must be done before a */ @@ -470,17 +468,17 @@ if (this->isInterpret()) { /* save the nested setting */ - bool nested = this->sender->settings.local_variables.isNested(); + bool nested = this->parent->settings.local_variables.isNested(); /* propagate parent's settings back */ - this->sender->getSettings(this->settings); + this->parent->getSettings(this->settings); if (!nested) { /* if our calling variable context was not nested, we */ /* need to clear it. */ - this->sender->settings.local_variables.clearNested(); + this->parent->settings.local_variables.clearNested(); } /* merge any pending conditions */ - this->sender->mergeTraps(this->condition_queue, this->handler_queue); + this->parent->mergeTraps(this->condition_queue, this->handler_queue); } resultObj = this->result; /* save the result */ this->activity->popStackFrame(false); /* now pop the current activity */ @@ -532,8 +530,6 @@ this->settings.flags |= transfer_failed; } } - /* we're now the top activation */ - this->sender = OREF_NULL; this->activity->run(); /* continue running the new activity */ oldActivity->yieldControl(); /* give other activity a chance to go*/ } @@ -826,7 +822,7 @@ memory_mark(this->settings.securityManager); memory_mark(this->receiver); memory_mark(this->activity); - memory_mark(this->sender); + memory_mark(this->parent); memory_mark(this->dostack); /* the stack and the local variables handle their own marking. */ this->stack.live(liveMark); @@ -876,7 +872,7 @@ memory_mark_general(this->settings.securityManager); memory_mark_general(this->receiver); memory_mark_general(this->activity); - memory_mark_general(this->sender); + memory_mark_general(this->parent); memory_mark_general(this->dostack); /* the stack and the local variables handle their own marking. */ this->stack.liveGeneral(reason); @@ -953,8 +949,8 @@ { this->execution_state = RETURNED; /* this is a returned state */ this->next = OREF_NULL; /* turn off execution engine */ - /* cause a return in the sender */ - this->sender->returnFrom(resultObj); /* activity */ + /* cause a return in the parent */ + this->parent->returnFrom(resultObj); /* activity */ } else { @@ -1111,7 +1107,7 @@ /* now expose each individual variable */ for (size_t i = 0; i < count; i++) { - variables[i]->procedureExpose(this, sender, &stack); + variables[i]->procedureExpose(this, parent, &stack); } } @@ -1384,7 +1380,7 @@ /* along */ if (this->isInternalLevelCall()) { - return this->sender->external(); /* get our sender method */ + return this->parent->external(); /* get our sender method */ } else { @@ -1414,7 +1410,7 @@ } /* reached the top level? */ - if (this->sender == OREF_NULL) + if (this->parent == OREF_NULL) { this->exitFrom(resultObj); /* turn into an exit instruction */ } @@ -1430,7 +1426,7 @@ this->termination(); /* remove guarded status on object */ this->activity->popStackFrame(false); /* pop ourselves off active list */ /* propogate the condition backward */ - this->sender->raiseExit(condition, rc, description, additional, resultObj, conditionobj); + this->parent->raiseExit(condition, rc, description, additional, resultObj, conditionobj); } } @@ -1446,7 +1442,6 @@ /* Function: Raise a give REXX condition */ /******************************************************************************/ { - RexxActivation *_sender; /* "invoker" of current activation */ bool propagated; /* propagated syntax condition */ /* propagating an existing condition?*/ @@ -1511,16 +1506,14 @@ { /* normal condition trapping */ /* get the sender object (if any) */ // find a predecessor Rexx activation - _sender = this->senderActivation(); + RexxActivation *_sender = this->senderActivation(); /* do we have a sender that is */ /* trapping this condition? */ /* do we have a sender? */ - - //TODO: This is likely all screwed up. if (_sender != OREF_NULL) { /* "tickle them" with this */ - this->sender->trap(condition, conditionobj); + _sender->trap(condition, conditionobj); } this->returnFrom(resultObj); /* process the return part */ throw this; /* unwind and process the termination*/ @@ -1568,7 +1561,7 @@ { /* alway's use caller's for internal */ /* call, external call or interpret */ - this->settings.streams = this->sender->getStreams(); + this->settings.streams = this->parent->getStreams(); } } return this->settings.streams; /* return the stream table */ @@ -1586,7 +1579,7 @@ { this->execution_state = RETURNED; /* signal interpret termination */ this->next = OREF_NULL; /* turn off execution engine */ - this->sender->signalTo(target); /* propogate the signal backward */ + this->parent->signalTo(target); /* propogate the signal backward */ } else { @@ -1860,16 +1853,16 @@ { if (this->settings.flags&forwarded) {/* in the act of forwarding? */ - RexxActivation *activation = this->sender; /* get the sender activation */ + RexxActivationBase *activation = this->getPreviousStackFrame(); /* get the sender activation */ /* have a predecessor? */ - while (activation != OREF_NULL) + while (activation != OREF_NULL && isOfClass(Activation, activation)) { if (!activation->isForwarded()) /* non forwarded? */ { /* pretend he is we */ return activation->trap(condition, exception_object); } - activation = activation->sender; /* step to the next one */ + activation = activation->getPreviousStackFrame(); /* step to the next one */ } return false; /* not really here, can't handle */ } @@ -1960,15 +1953,15 @@ if (handler->isType(KEYWORD_SIGNAL)) { /* not an Interpret instruction? */ - if (this->isInterpret()) + if (!this->isInterpret()) { throw this; /* unwind and process the trap */ } else { /* unwind interpret activations */ /* merge the traps */ - this->sender->mergeTraps(this->condition_queue, this->handler_queue); - this->sender->unwindTrap(this);/* go unwind this */ + this->parent->mergeTraps(this->condition_queue, this->handler_queue); + this->parent->unwindTrap(this);/* go unwind this */ } } else @@ -2054,8 +2047,7 @@ } -void RexxActivation::unwindTrap( - RexxActivation * child ) /* child interpret activation */ +void RexxActivation::unwindTrap(RexxActivation * child ) /******************************************************************************/ /* Function: Unwind a chain of interpret activations to process a SIGNAL ON */ /* or PROPAGATE condition trap. This ensures that the SIGNAL */ @@ -2066,8 +2058,8 @@ if (this->isInterpret()) { /* merge the traps */ - this->sender->mergeTraps(this->condition_queue, this->handler_queue); - this->sender->unwindTrap(child); /* unwind another level */ + this->parent->mergeTraps(this->condition_queue, this->handler_queue); + this->parent->unwindTrap(child); /* unwind another level */ } else /* reached the "parent" level */ { @@ -2077,15 +2069,16 @@ } } + RexxActivation * RexxActivation::senderActivation() /******************************************************************************/ /* Function: Retrieve the activation that activated this activation (whew) */ /******************************************************************************/ { /* get the sender from the activity */ - RexxActivationBase *_sender = this->sender; + RexxActivationBase *_sender = this->getPreviousStackFrame(); /* spin down to non-native activation*/ - while (_sender != OREF_NULL && isOfClass(NativeActivation,sender)) + while (_sender != OREF_NULL && isOfClass(NativeActivation, _sender)) { _sender = _sender->getPreviousStackFrame(); } @@ -2176,7 +2169,7 @@ // the context that calls the interpret. if (this->isInterpret()) { - return sender->rexxVariable(name); + return parent->rexxVariable(name); } else { @@ -2606,7 +2599,7 @@ if (this->isInternalLevelCall()) { /* forward along */ - return this->sender->getRandomSeed(seed); + return this->parent->getRandomSeed(seed); } /* have a seed supplied? */ if (seed != OREF_NULL) @@ -3557,7 +3550,7 @@ else /* nope, process up the chain. */ { /* Yes, forward on the message. */ - this->sender->pushEnvironment(environment); + this->parent->pushEnvironment(environment); } } @@ -3585,7 +3578,7 @@ else { /* nope, pass on up the chain. */ /* Yes, forward on the message. */ - return this->sender->popEnvironment(); + return this->parent->popEnvironment(); } } Modified: sandbox/rick/opt/kernel/runtime/RexxActivation.hpp =================================================================== --- sandbox/rick/opt/kernel/runtime/RexxActivation.hpp 2008-06-15 23:36:46 UTC (rev 2542) +++ sandbox/rick/opt/kernel/runtime/RexxActivation.hpp 2008-06-16 13:10:10 UTC (rev 2543) @@ -559,7 +559,7 @@ /* the caller. */ if (isInternalLevelCall() && settings.local_variables.isNested()) { - sender->setLocalVariableDictionary(settings.local_variables.getNestedDictionary()); + parent->setLocalVariableDictionary(settings.local_variables.getNestedDictionary()); } else { @@ -586,7 +586,7 @@ RexxClass *scope; // scope of any active method call RexxObject *receiver; /* target of a message invocation */ RexxActivity *activity; /* current running activation */ - RexxActivation *sender; /* previous running activation */ + RexxActivation *parent; // previous running activation for internal call/interpret RexxObject **arglist; /* activity argument list */ size_t argcount; /* the count of arguments */ RexxDoBlock *dostack; /* stack of DO loops */ Modified: sandbox/rick/opt/kernel/runtime/RexxNativeActivation.cpp =================================================================== --- sandbox/rick/opt/kernel/runtime/RexxNativeActivation.cpp 2008-06-15 23:36:46 UTC (rev 2542) +++ sandbox/rick/opt/kernel/runtime/RexxNativeActivation.cpp 2008-06-16 13:10:10 UTC (rev 2543) @@ -601,7 +601,10 @@ { switch (value->type) { - case REXX_VALUE_RexxObjectPtr: /* Object reference */ + case REXX_VALUE_RexxObjectPtr: // object reference. All object types get + case REXX_VALUE_RexxStringObject: // returned as a Rexx object + case REXX_VALUE_RexxArrayObject: + case REXX_VALUE_RexxStemObject: { return (RexxObject *)value->value.value_RexxObjectPtr; // just return the object value } @@ -1125,11 +1128,12 @@ /* give up reference to receiver so that it can be garbage collected */ this->receiver = OREF_NULL; + checkConditions(); // see if we have conditions to raise now + // set the return value and get outta here resultObj = this->result; this->argcount = 0; /* make sure we don't try to mark any arguments */ - checkConditions(); // see if we have conditions to raise now this->activity->popStackFrame(this); /* pop this from the activity */ this->setHasNoReferences(); /* mark this as not having references in case we get marked */ @@ -1208,11 +1212,12 @@ /* give up reference to receiver so that it can be garbage collected */ this->receiver = OREF_NULL; - // set the return value and get outta here + checkConditions(); // see if we have conditions to raise now + + // set the return value and get outta here. resultObj = this->result; this->argcount = 0; /* make sure we don't try to mark any arguments */ - checkConditions(); // see if we have conditions to raise now this->activity->popStackFrame(this); /* pop this from the activity */ this->setHasNoReferences(); /* mark this as not having references in case we get marked */ } @@ -1487,9 +1492,35 @@ // base of the stack, there's nothing left to handle this. if (!isStackBase()) { - // this prevents us from trying to trap this again - reraising = true; - activity->reraiseException(conditionObj); + /* get the original condition name */ + RexxString *condition = (RexxString *)conditionObj->at(OREF_CONDITION); + + /* fatal SYNTAX error? */ + if (condition->strCompare(CHAR_SYNTAX)) + { + // this prevents us from trying to trap this again + reraising = true; + /* go propagate the condition */ + activity->reraiseException(conditionObj); + } + else + { /* normal condition trapping */ + /* get the sender object (if any) */ + // find a predecessor Rexx activation + RexxActivationBase *_sender = this->getPreviousStackFrame(); + /* do we have a sender that is */ + /* trapping this condition? */ + /* do we have a sender? */ + + if (_sender != OREF_NULL) + { + /* "tickle them" with this */ + _sender->trap(condition, conditionObj); + } + // if the trap is not handled, then we return directly. The return + // value (if any) is stored in the condition object + result = conditionObj->at(OREF_RESULT); + } } } } Modified: sandbox/rick/opt/kernel/streamLibrary/StreamNative.cpp =================================================================== --- sandbox/rick/opt/kernel/streamLibrary/StreamNative.cpp 2008-06-15 23:36:46 UTC (rev 2542) +++ sandbox/rick/opt/kernel/streamLibrary/StreamNative.cpp 2008-06-16 13:10:10 UTC (rev 2543) @@ -490,8 +490,6 @@ append = 1; } - // the resolved name is the same as the input name. - strcpy(qualified_name, stream_name); // check to see if buffering is allowed. if (options != NULL && !Utilities::stricmp(options, "NOBUFFER")) { @@ -501,6 +499,9 @@ { nobuffer = 0; /* buffering is used */ } + + // the resolved name is the same as the input name. + strcpy(qualified_name, stream_name); // we're open, and ready isopen = true; @@ -508,6 +509,19 @@ // and also record the transient nature of this transient = fileInfo.isTransient(); + + // don't buffer if this is a transient stream or we've explicitly requested no buffering. + // in either case, make sure the initial buffer has been allocated. + if (transient || nobuffer) + { + // we do not buffer buffer file + fileInfo.setBuffering(false, 0); + } + else + { + // we buffer file + fileInfo.setBuffering(true, 0); + } // this was successful. return "READY:"; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bigrixx@us...> - 2008-06-17 21:37:42
|
Revision: 2547 http://oorexx.svn.sourceforge.net/oorexx/?rev=2547&view=rev Author: bigrixx Date: 2008-06-17 14:37:17 -0700 (Tue, 17 Jun 2008) Log Message: ----------- fix stream errors Modified Paths: -------------- sandbox/rick/opt/kernel/platform/unix/SysFile.cpp sandbox/rick/opt/kernel/platform/windows/SysFile.cpp sandbox/rick/opt/kernel/streamLibrary/StreamNative.cpp Modified: sandbox/rick/opt/kernel/platform/unix/SysFile.cpp =================================================================== --- sandbox/rick/opt/kernel/platform/unix/SysFile.cpp 2008-06-17 17:00:20 UTC (rev 2546) +++ sandbox/rick/opt/kernel/platform/unix/SysFile.cpp 2008-06-17 21:37:17 UTC (rev 2547) @@ -120,6 +120,8 @@ // set eof flag fileeof = false; + // set the default buffer size (and allocate the buffer) + setBuffering(true, 0); getStreamTypeInfo(); return true; } @@ -139,6 +141,8 @@ openedHandle = false; fileHandle = handle; ungetchar = 0xFF; // 0xFF indicates no char + // set the default buffer size (and allocate the buffer) + setBuffering(true, 0); getStreamTypeInfo(); return true; } Modified: sandbox/rick/opt/kernel/platform/windows/SysFile.cpp =================================================================== --- sandbox/rick/opt/kernel/platform/windows/SysFile.cpp 2008-06-17 17:00:20 UTC (rev 2546) +++ sandbox/rick/opt/kernel/platform/windows/SysFile.cpp 2008-06-17 21:37:17 UTC (rev 2547) @@ -114,6 +114,8 @@ } getStreamTypeInfo(); + // set the default buffer size (and allocate the buffer) + setBuffering(true, 0); return true; } @@ -133,6 +135,8 @@ fileHandle = handle; ungetchar = -1; // -1 indicates no char getStreamTypeInfo(); + // set the default buffer size (and allocate the buffer) + setBuffering(true, 0); return true; } Modified: sandbox/rick/opt/kernel/streamLibrary/StreamNative.cpp =================================================================== --- sandbox/rick/opt/kernel/streamLibrary/StreamNative.cpp 2008-06-17 17:00:20 UTC (rev 2546) +++ sandbox/rick/opt/kernel/streamLibrary/StreamNative.cpp 2008-06-17 21:37:17 UTC (rev 2547) @@ -661,7 +661,7 @@ binaryRecordLength = 0; read_only = false; write_only = false; - read_write = true; /* try for read/write */ + read_write = false; stdstream = false; append = false; opened_as_handle = false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <miesfeld@us...> - 2008-06-19 17:11:10
|
Revision: 2549 http://oorexx.svn.sourceforge.net/oorexx/?rev=2549&view=rev Author: miesfeld Date: 2008-06-19 10:11:14 -0700 (Thu, 19 Jun 2008) Log Message: ----------- A few simple fixes for the updated stream libray. Modified Paths: -------------- sandbox/rick/opt/kernel/platform/windows/SysFile.cpp sandbox/rick/opt/kernel/streamLibrary/StreamNative.cpp Modified: sandbox/rick/opt/kernel/platform/windows/SysFile.cpp =================================================================== --- sandbox/rick/opt/kernel/platform/windows/SysFile.cpp 2008-06-18 14:29:41 UTC (rev 2548) +++ sandbox/rick/opt/kernel/platform/windows/SysFile.cpp 2008-06-19 17:11:14 UTC (rev 2549) @@ -246,6 +246,8 @@ // update the real output position filePointer += written; // and invalidate the buffer + bufferPosition = 0; + bufferedInput = 0; } } return true; @@ -971,8 +973,8 @@ struct _stati64 fileInfo; if (_fstati64(fileHandle, &fileInfo) == 0) { - // regular file? return the defined size - if ((fileInfo.st_mode & _S_IFREG) != 0) + // character device? set those characteristics + if ((fileInfo.st_mode & _S_IFCHR) != 0) { device = true; transient = true; Modified: sandbox/rick/opt/kernel/streamLibrary/StreamNative.cpp =================================================================== --- sandbox/rick/opt/kernel/streamLibrary/StreamNative.cpp 2008-06-18 14:29:41 UTC (rev 2548) +++ sandbox/rick/opt/kernel/streamLibrary/StreamNative.cpp 2008-06-19 17:11:14 UTC (rev 2549) @@ -379,11 +379,6 @@ { eof(); } - else - { - // must be an error, so raise that using the file error information - notreadyError(); - } } @@ -1021,7 +1016,6 @@ */ void StreamInfo::setPosition(int64_t position, int64_t &newPosition) { - position--; // convert to system position type // seek to the target position, if possible. The request position // is a 1-based character number. We need to convert this into // a zero-based one before moving. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <miesfeld@us...> - 2008-06-19 20:44:35
|
Revision: 2556 http://oorexx.svn.sourceforge.net/oorexx/?rev=2556&view=rev Author: miesfeld Date: 2008-06-19 13:44:19 -0700 (Thu, 19 Jun 2008) Log Message: ----------- When a StreamInfo object is constructed be sure bufferAddress is null. Modified Paths: -------------- sandbox/rick/opt/kernel/platform/unix/SysFile.cpp sandbox/rick/opt/kernel/platform/windows/SysFile.cpp sandbox/rick/opt/kernel/streamLibrary/StreamNative.cpp Modified: sandbox/rick/opt/kernel/platform/unix/SysFile.cpp =================================================================== --- sandbox/rick/opt/kernel/platform/unix/SysFile.cpp 2008-06-19 19:33:40 UTC (rev 2555) +++ sandbox/rick/opt/kernel/platform/unix/SysFile.cpp 2008-06-19 20:44:19 UTC (rev 2556) @@ -267,7 +267,7 @@ * @param len The requested number of bytes to read. * @param bytesRead The actual number of bytes read. * - * @return True if or or more bytes are read into buf, otherwise false. + * @return True if one or more bytes are read into buf, otherwise false. */ bool SysFile::read(char *buf, size_t len, size_t &bytesRead) { Modified: sandbox/rick/opt/kernel/platform/windows/SysFile.cpp =================================================================== --- sandbox/rick/opt/kernel/platform/windows/SysFile.cpp 2008-06-19 19:33:40 UTC (rev 2555) +++ sandbox/rick/opt/kernel/platform/windows/SysFile.cpp 2008-06-19 20:44:19 UTC (rev 2556) @@ -260,7 +260,7 @@ * @param len The requested number of bytes to read. * @param bytesRead The actual number of bytes read. * - * @return True if or or more bytes are read into buf, otherwise false. + * @return True if one or more bytes are read into buf, otherwise false. */ bool SysFile::read(char *buf, size_t len, size_t &bytesRead) { Modified: sandbox/rick/opt/kernel/streamLibrary/StreamNative.cpp =================================================================== --- sandbox/rick/opt/kernel/streamLibrary/StreamNative.cpp 2008-06-19 19:33:40 UTC (rev 2555) +++ sandbox/rick/opt/kernel/streamLibrary/StreamNative.cpp 2008-06-19 20:44:19 UTC (rev 2556) @@ -667,6 +667,8 @@ lineReadCharPosition = 1; lineWriteCharPosition = 1; nobuffer = false; + bufferAddress = NULL; + bufferLength = 0; last_op_was_read = true; transient = false; record_based = false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bigrixx@us...> - 2008-06-22 21:57:32
|
Revision: 2565 http://oorexx.svn.sourceforge.net/oorexx/?rev=2565&view=rev Author: bigrixx Date: 2008-06-22 14:57:40 -0700 (Sun, 22 Jun 2008) Log Message: ----------- Fix errors attempting to load a ::requires file Modified Paths: -------------- sandbox/rick/opt/kernel/parser/SourceFile.cpp sandbox/rick/opt/kernel/runtime/RexxCode.cpp sandbox/rick/opt/kernel/runtime/RexxCode.hpp Modified: sandbox/rick/opt/kernel/parser/SourceFile.cpp =================================================================== --- sandbox/rick/opt/kernel/parser/SourceFile.cpp 2008-06-22 21:33:21 UTC (rev 2564) +++ sandbox/rick/opt/kernel/parser/SourceFile.cpp 2008-06-22 21:57:40 UTC (rev 2565) @@ -5648,11 +5648,18 @@ */ void RexxSource::addPackage(PackageClass *p) { - // we only add a given package item once. - if (loadedPackages->hasItem(p) == TheTrueObject) + // we only create this on the first use + if (loadedPackages == OREF_NULL) { - return; + loadedPackages = new_list(); } + else { + // we only add a given package item once. + if (loadedPackages->hasItem(p) == TheTrueObject) + { + return; + } + } // add this to the list and merge the information loadedPackages->append(p); Modified: sandbox/rick/opt/kernel/runtime/RexxCode.cpp =================================================================== --- sandbox/rick/opt/kernel/runtime/RexxCode.cpp 2008-06-22 21:33:21 UTC (rev 2564) +++ sandbox/rick/opt/kernel/runtime/RexxCode.cpp 2008-06-22 21:57:40 UTC (rev 2565) @@ -75,6 +75,23 @@ } +/** + * Process a detached ::requires type call. + * + * @param activity The current activity, + * @param routine The routine object we're executing. + * @param msgname The name this was invoked under. + * @param argPtr The pointer to the call arguments, + * @param argcount The count of arguments, + * @param result The returned result. + */ +void RexxCode::call(RexxActivity *activity, RoutineClass *routine, RexxString *msgname, RexxObject**argPtr, size_t argcount, ProtectedObject &result) +{ + // just forward to the more general method + this->call(activity, routine, msgname, argPtr, argcount, OREF_NULL, OREF_NULL, EXTERNALCALL, result); +} + + void RexxCode::call( RexxActivity *activity, /* activity running under */ RoutineClass *routine, // top level routine instance Modified: sandbox/rick/opt/kernel/runtime/RexxCode.hpp =================================================================== --- sandbox/rick/opt/kernel/runtime/RexxCode.hpp 2008-06-22 21:33:21 UTC (rev 2564) +++ sandbox/rick/opt/kernel/runtime/RexxCode.hpp 2008-06-22 21:57:40 UTC (rev 2565) @@ -93,6 +93,7 @@ inline void mergeRequired(RexxSource *s) { source->mergeRequired(s); } virtual void run(RexxActivity *, RexxMethod *, RexxObject *, RexxString *, RexxObject **, size_t, ProtectedObject &); virtual void call(RexxActivity *, RoutineClass *, RexxString *, RexxObject **, size_t, RexxString *, RexxString *, int, ProtectedObject &); + virtual void call(RexxActivity *, RoutineClass *, RexxString *, RexxObject **, size_t, ProtectedObject &); protected: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bigrixx@us...> - 2008-06-24 21:48:43
|
Revision: 2572 http://oorexx.svn.sourceforge.net/oorexx/?rev=2572&view=rev Author: bigrixx Date: 2008-06-24 14:48:17 -0700 (Tue, 24 Jun 2008) Log Message: ----------- Fix problems in SysFileTree() Modified Paths: -------------- sandbox/rick/opt/kernel/runtime/RexxActivity.cpp sandbox/rick/opt/kernel/runtime/RexxNativeActivation.cpp sandbox/rick/opt/kernel/runtime/RexxNativeActivation.hpp sandbox/rick/opt/kernel/streamLibrary/StreamNative.cpp Modified: sandbox/rick/opt/kernel/runtime/RexxActivity.cpp =================================================================== --- sandbox/rick/opt/kernel/runtime/RexxActivity.cpp 2008-06-24 16:37:07 UTC (rev 2571) +++ sandbox/rick/opt/kernel/runtime/RexxActivity.cpp 2008-06-24 21:48:17 UTC (rev 2572) @@ -2887,58 +2887,56 @@ */ void RexxActivity::run(ActivityDispatcher &target) { - SYSEXCEPTIONBLOCK exreg; /* system specific exception info */ - size_t startDepth; /* starting depth of activation stack*/ - NestedActivityState saveInfo; /* saved activity info */ + SYSEXCEPTIONBLOCK exreg; /* system specific exception info */ + size_t startDepth; /* starting depth of activation stack*/ + NestedActivityState saveInfo; /* saved activity info */ - /* make sure we have the stack base */ - this->nestedInfo.stackptr = SysGetThreadStackBase(TOTAL_STACK_SIZE); - this->generateRandomNumberSeed(); /* get a fresh random seed */ - /* Push marker onto stack so we know */ - this->createNewActivationStack(); /* what level we entered. */ - startDepth = stackFrameDepth; /* Remember activation stack depth */ + /* make sure we have the stack base */ + this->nestedInfo.stackptr = SysGetThreadStackBase(TOTAL_STACK_SIZE); + this->generateRandomNumberSeed(); /* get a fresh random seed */ + /* Push marker onto stack so we know */ + this->createNewActivationStack(); /* what level we entered. */ + startDepth = stackFrameDepth; /* Remember activation stack depth */ - SysRegisterSignals(&exreg); /* register our signal handlers */ + SysRegisterSignals(&exreg); /* register our signal handlers */ - // save the actitivation level in case there's an error unwind for an unhandled - // exception; - size_t activityLevel = getActivationLevel(); - // create a new native activation - RexxNativeActivation *newNActa = new RexxNativeActivation(this); - pushStackFrame(newNActa); /* push it on the activity stack */ + // save the actitivation level in case there's an error unwind for an unhandled + // exception; + size_t activityLevel = getActivationLevel(); + // create a new native activation + RexxNativeActivation *newNActa = new RexxNativeActivation(this); + pushStackFrame(newNActa); /* push it on the activity stack */ - try - { - // go run the target under the new activation - newNActa->run(target); - } - catch (ActivityException) - { - // if we're not the current kernel holder when things return, make sure we - // get the lock before we continue - if (ActivityManager::currentActivity != this) - { - requestAccess(); - } + try + { + // go run the target under the new activation + newNActa->run(target); + } + catch (ActivityException) + { + // if we're not the current kernel holder when things return, make sure we + // get the lock before we continue + if (ActivityManager::currentActivity != this) + { + requestAccess(); + } - // now do error processing - wholenumber_t rc = this->error(); /* do error cleanup */ - target.handleError(rc, conditionobj); - } + // now do error processing + wholenumber_t rc = this->error(); /* do error cleanup */ + target.handleError(rc, conditionobj); + } - // make sure we get restored to the same base activation level. - restoreActivationLevel(activityLevel); - // give uninit objects a chance to run - memoryObject.runUninits(); - this->restoreNestedInfo(saveInfo); /* now restore to previous nesting */ - SysDeregisterSignals(&exreg); /* deregister the signal handlers */ - // unwind to the same stack depth as the start, removing all new entries - unwindToDepth(startDepth); + // make sure we get restored to the same base activation level. + restoreActivationLevel(activityLevel); + // give uninit objects a chance to run + memoryObject.runUninits(); + this->restoreNestedInfo(saveInfo); /* now restore to previous nesting */ + SysDeregisterSignals(&exreg); /* deregister the signal handlers */ + // unwind to the same stack depth as the start, removing all new entries + unwindToDepth(startDepth); } - - /** * Run a task under the context of an activity. This will be * a task that calls out from the interpreter, which the Modified: sandbox/rick/opt/kernel/runtime/RexxNativeActivation.cpp =================================================================== --- sandbox/rick/opt/kernel/runtime/RexxNativeActivation.cpp 2008-06-24 16:37:07 UTC (rev 2571) +++ sandbox/rick/opt/kernel/runtime/RexxNativeActivation.cpp 2008-06-24 21:48:17 UTC (rev 2572) @@ -1097,6 +1097,7 @@ processArguments(argcount, arglist, types, arguments, MAX_NATIVE_ARGUMENTS); size_t activityLevel = this->activity->getActivationLevel(); + trapErrors = true; // we trap errors from here try { activity->releaseAccess(); /* force this to "safe" mode */ @@ -1117,6 +1118,7 @@ { activity->requestAccess(); } + trapErrors = false; // no more error trapping this->guardOff(); /* release any variable locks */ this->argcount = 0; /* make sure we don't try to mark any arguments */ // the lock holder gets here by longjmp from a kernel reentry. We need to @@ -1160,6 +1162,7 @@ arglist = list; argcount = count; activationType = FUNCTION_ACTIVATION; // this is for running a method + accessCallerContext(); // we need this to access the caller's context ValueDescriptor arguments[MAX_NATIVE_ARGUMENTS]; @@ -1185,6 +1188,7 @@ processArguments(argcount, arglist, types, arguments, MAX_NATIVE_ARGUMENTS); size_t activityLevel = this->activity->getActivationLevel(); + trapErrors = true; // we trap error conditions now try { activity->releaseAccess(); /* force this to "safe" mode */ @@ -1205,6 +1209,8 @@ { activity->requestAccess(); } + + trapErrors = false; // no more error trapping // belt and braces...this restores the activity level to whatever // level we had when we made the callout. this->activity->restoreActivationLevel(activityLevel); @@ -1239,6 +1245,7 @@ executable = _routine; arglist = list; argcount = count; + accessCallerContext(); // we need this to access the caller's context activationType = FUNCTION_ACTIVATION; // this is for running a method // use the default security manager @@ -1300,8 +1307,11 @@ MAKERXSTRING(funcresult, default_return_buffer, sizeof(default_return_buffer)); size_t activityLevel = this->activity->getActivationLevel(); + + trapErrors = true; // trap errors from here try { + enableVariablepool(); // enable the variable pool interface here activity->releaseAccess(); /* force this to "safe" mode */ // now process the function call functionrc = (*methp)(functionName->getStringData(), count, argPtr, queuename, &funcresult); @@ -1350,6 +1360,9 @@ return; } + trapErrors = false; // no more error trapping + disableVariablepool(); // disable the variable pool from here + // belt and braces...this restores the activity level to whatever // level we had when we made the callout. this->activity->restoreActivationLevel(activityLevel); @@ -1444,6 +1457,7 @@ // use the default security manager securityManager = activity->getInstanceSecurityManager(); size_t activityLevel = this->activity->getActivationLevel(); + trapErrors = true; // trap errors on try { // make the activation hookup @@ -1466,6 +1480,8 @@ activity->requestAccess(); } + trapErrors = false; // back to normal mode for error trapping + // belt and braces...this restores the activity level to whatever // level we had when we made the callout. this->activity->restoreActivationLevel(activityLevel); @@ -1480,6 +1496,16 @@ /** + * Establish the caller's context for native activations + * that require access to the caller's context. + */ +void RexxNativeActivation::accessCallerContext() +{ + activation = (RexxActivation *)getPreviousStackFrame(); +} + + +/** * Check to see if there are deferred syntax errors that need * to be raised on return from a native activation. */ @@ -1499,7 +1525,7 @@ if (condition->strCompare(CHAR_SYNTAX)) { // this prevents us from trying to trap this again - reraising = true; + trapErrors = false; /* go propagate the condition */ activity->reraiseException(conditionObj); } @@ -2209,7 +2235,7 @@ // we end up seeing this a second time if we're raising the exception on // return from an external call or method. - if (!reraising) + if (trapErrors) { // record this in case any callers want to know about it. setConditionInfo(exception_object); Modified: sandbox/rick/opt/kernel/runtime/RexxNativeActivation.hpp =================================================================== --- sandbox/rick/opt/kernel/runtime/RexxNativeActivation.hpp 2008-06-24 16:37:07 UTC (rev 2571) +++ sandbox/rick/opt/kernel/runtime/RexxNativeActivation.hpp 2008-06-24 21:48:17 UTC (rev 2572) @@ -110,6 +110,7 @@ inline void termination() { this->guardOff();} + void accessCallerContext(); inline char getVpavailable() {return this->vpavailable;} inline RexxString *getMessageName() {return this->msgname;} inline size_t nextVariable() {return this->nextvariable;} @@ -201,6 +202,6 @@ bool vpavailable; /* Variable pool access flag */ int object_scope; /* reserve/release state of variables*/ bool stackBase; // this is a stack base marker - bool reraising; // we're reraising an exception, don't trap + bool trapErrors; // we're trapping errors from external callers }; #endif Modified: sandbox/rick/opt/kernel/streamLibrary/StreamNative.cpp =================================================================== --- sandbox/rick/opt/kernel/streamLibrary/StreamNative.cpp 2008-06-24 16:37:07 UTC (rev 2571) +++ sandbox/rick/opt/kernel/streamLibrary/StreamNative.cpp 2008-06-24 21:48:17 UTC (rev 2572) @@ -1217,6 +1217,12 @@ */ void StreamInfo::lineReadIncrement() { + // transient streams don't have moveable positions + if (transient) + { + return; + } + if ( !fileInfo.getPosition(charReadPosition) ) { notreadyError(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bigrixx@us...> - 2008-06-26 22:43:19
|
Revision: 2588 http://oorexx.svn.sourceforge.net/oorexx/?rev=2588&view=rev Author: bigrixx Date: 2008-06-26 15:43:20 -0700 (Thu, 26 Jun 2008) Log Message: ----------- linein not raising NOTREADY on eof Modified Paths: -------------- sandbox/rick/opt/kernel/platform/unix/SysFile.cpp sandbox/rick/opt/kernel/platform/windows/SysFile.cpp sandbox/rick/opt/kernel/streamLibrary/StreamNative.cpp Modified: sandbox/rick/opt/kernel/platform/unix/SysFile.cpp =================================================================== --- sandbox/rick/opt/kernel/platform/unix/SysFile.cpp 2008-06-26 22:25:01 UTC (rev 2587) +++ sandbox/rick/opt/kernel/platform/unix/SysFile.cpp 2008-06-26 22:43:20 UTC (rev 2588) @@ -381,8 +381,25 @@ } + + +/** + * write data to the stream + * + * @param data The data buffer to write. + * @param len The length to write + * @param bytesWritten + * The number bytes actually written (return value). + * + * @return true if the write succeeded, false for any errors. + */ bool SysFile::write(const char *data, size_t len, size_t &bytesWritten) { + // writing zero bytes is a NOP + if (len == 0) + { + return true; + } // are we buffering? if (buffered) { @@ -572,6 +589,12 @@ } } + // if there is no data read at all, this is an eof failure; + if (i == 0) + { + return false; + } + // null terminate, set the length, and return buffer[i] = '\0'; // this is the length minus the terminating null Modified: sandbox/rick/opt/kernel/platform/windows/SysFile.cpp =================================================================== --- sandbox/rick/opt/kernel/platform/windows/SysFile.cpp 2008-06-26 22:25:01 UTC (rev 2587) +++ sandbox/rick/opt/kernel/platform/windows/SysFile.cpp 2008-06-26 22:43:20 UTC (rev 2588) @@ -377,8 +377,23 @@ } +/** + * write data to the stream + * + * @param data The data buffer to write. + * @param len The length to write + * @param bytesWritten + * The number bytes actually written (return value). + * + * @return true if the write succeeded, false for any errors. + */ bool SysFile::write(const char *data, size_t len, size_t &bytesWritten) { + // writing zero bytes is a NOP + if (len == 0) + { + return true; + } // are we buffering? if (buffered) { @@ -568,6 +583,12 @@ } } + // if there is no data read at all, this is an eof failure; + if (i == 0) + { + return false; + } + // null terminate, set the length, and return buffer[i] = '\0'; // this is the length minus the terminating null Modified: sandbox/rick/opt/kernel/streamLibrary/StreamNative.cpp =================================================================== --- sandbox/rick/opt/kernel/streamLibrary/StreamNative.cpp 2008-06-26 22:25:01 UTC (rev 2587) +++ sandbox/rick/opt/kernel/streamLibrary/StreamNative.cpp 2008-06-26 22:43:20 UTC (rev 2588) @@ -866,8 +866,9 @@ if (!fileInfo.read(buffer, length, bytesRead)) { - notreadyError(); + checkEof(); } + if (bytesRead == 0) /* work ok? */ { // must be an eof condition @@ -1193,7 +1194,7 @@ size_t bytesRead = 0; if (!fileInfo.gets(readPosition, bufferSize - currentLength, bytesRead)) { - notreadyError(); + checkEof(); } // Check for new line character first. If we are at eof and the last This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bigrixx@us...> - 2008-06-27 01:07:58
|
Revision: 2589 http://oorexx.svn.sourceforge.net/oorexx/?rev=2589&view=rev Author: bigrixx Date: 2008-06-26 18:08:05 -0700 (Thu, 26 Jun 2008) Log Message: ----------- fix argument reporting for external routines/methods Modified Paths: -------------- sandbox/rick/opt/kernel/messages/DocErrorMessages.sgml sandbox/rick/opt/kernel/messages/RexxErrorCodes.h sandbox/rick/opt/kernel/messages/RexxMessageNumbers.h sandbox/rick/opt/kernel/messages/RexxMessageTable.h sandbox/rick/opt/kernel/messages/rexxmsg.xml sandbox/rick/opt/kernel/platform/windows/winmsgtb.rc sandbox/rick/opt/kernel/runtime/RexxNativeActivation.cpp sandbox/rick/opt/kernel/runtime/RexxNativeActivation.hpp Modified: sandbox/rick/opt/kernel/messages/DocErrorMessages.sgml =================================================================== --- sandbox/rick/opt/kernel/messages/DocErrorMessages.sgml 2008-06-26 22:43:20 UTC (rev 2588) +++ sandbox/rick/opt/kernel/messages/DocErrorMessages.sgml 2008-06-27 01:08:05 UTC (rev 2589) @@ -2571,6 +2571,24 @@ <para>Argument <emphasis>argument</emphasis> is not in valid pointer format; found "<emphasis>value</emphasis>"</para> </listitem> </varlistentry> +<varlistentry> +<term>920</term> +<listitem> +<para>Argument <emphasis>argument</emphasis> must have a stem object or stem name value; found "<emphasis>value</emphasis>"</para> +</listitem> +</varlistentry> +<varlistentry> +<term>921</term> +<listitem> +<para>Argument <emphasis>argument</emphasis> must be a valid double value; found "<emphasis>value</emphasis>"</para> +</listitem> +</varlistentry> +<varlistentry> +<term>922</term> +<listitem> +<para>Too many arguments in invocation; <emphasis>number</emphasis> expected</para> +</listitem> +</varlistentry> </variablelist> </section> <section id="ERR89"> Modified: sandbox/rick/opt/kernel/messages/RexxErrorCodes.h =================================================================== --- sandbox/rick/opt/kernel/messages/RexxErrorCodes.h 2008-06-26 22:43:20 UTC (rev 2588) +++ sandbox/rick/opt/kernel/messages/RexxErrorCodes.h 2008-06-27 01:08:05 UTC (rev 2589) @@ -414,6 +414,9 @@ #define Error_Invalid_argument_general 88917 #define Error_Invalid_argument_format 88918 #define Error_Invalid_argument_pointer 88919 +#define Error_Invalid_argument_nostem 88920 +#define Error_Invalid_argument_double 88921 +#define Error_Invalid_argument_maxarg 88922 #define Error_Variable_expected 89000 #define Error_Variable_expected_USE 89001 #define Error_Variable_expected_PARSE 89002 Modified: sandbox/rick/opt/kernel/messages/RexxMessageNumbers.h =================================================================== --- sandbox/rick/opt/kernel/messages/RexxMessageNumbers.h 2008-06-26 22:43:20 UTC (rev 2588) +++ sandbox/rick/opt/kernel/messages/RexxMessageNumbers.h 2008-06-27 01:08:05 UTC (rev 2589) @@ -608,6 +608,9 @@ #define Error_Incorrect_call_nostem_msg 702 #define Error_Incorrect_method_nostem_msg 703 #define Error_Invalid_argument_pointer_msg 704 +#define Error_Invalid_argument_nostem_msg 705 +#define Error_Invalid_argument_double_msg 706 +#define Error_Invalid_argument_maxarg_msg 707 #endif Modified: sandbox/rick/opt/kernel/messages/RexxMessageTable.h =================================================================== --- sandbox/rick/opt/kernel/messages/RexxMessageTable.h 2008-06-26 22:43:20 UTC (rev 2588) +++ sandbox/rick/opt/kernel/messages/RexxMessageTable.h 2008-06-27 01:08:05 UTC (rev 2589) @@ -416,6 +416,9 @@ MINOR(Error_Invalid_argument_general) MINOR(Error_Invalid_argument_format) MINOR(Error_Invalid_argument_pointer) + MINOR(Error_Invalid_argument_nostem) + MINOR(Error_Invalid_argument_double) + MINOR(Error_Invalid_argument_maxarg) MAJOR(Error_Variable_expected) MINOR(Error_Variable_expected_USE) MINOR(Error_Variable_expected_PARSE) Modified: sandbox/rick/opt/kernel/messages/rexxmsg.xml =================================================================== --- sandbox/rick/opt/kernel/messages/rexxmsg.xml 2008-06-26 22:43:20 UTC (rev 2588) +++ sandbox/rick/opt/kernel/messages/rexxmsg.xml 2008-06-27 01:08:05 UTC (rev 2589) @@ -3482,6 +3482,33 @@ <SymbolicName>Error_Invalid_argument_pointer</SymbolicName> <Text>Argument <Sub position="1" name="argument"/> is not in valid pointer format; found <q><Sub position="2" name="value"/></q></Text> </SubMessage> + <SubMessage> + <Code>88</Code> + <Subcode>920</Subcode> + <MessageNumber>705</MessageNumber> + <Component>Rexx</Component> + <Severity>Warning</Severity> + <SymbolicName>Error_Invalid_argument_nostem</SymbolicName> + <Text>Argument <Sub position="1" name="argument"/> must have a stem object or stem name value; found <q><Sub position="2" name="value"/></q></Text> + </SubMessage> + <SubMessage> + <Code>88</Code> + <Subcode>921</Subcode> + <MessageNumber>706</MessageNumber> + <Component>Rexx</Component> + <Severity>Warning</Severity> + <SymbolicName>Error_Invalid_argument_double</SymbolicName> + <Text>Argument <Sub position="1" name="argument"/> must be a valid double value; found <q><Sub position="2" name="value"/></q></Text> + </SubMessage> + <SubMessage> + <Code>88</Code> + <Subcode>922</Subcode> + <MessageNumber>707</MessageNumber> + <Component>Rexx</Component> + <Severity>Warning</Severity> + <SymbolicName>Error_Invalid_argument_maxarg</SymbolicName> + <Text>Too many arguments in invocation; <Sub position="1" name="number"/> expected</Text> + </SubMessage> </Subcodes> </Message> <Message> Modified: sandbox/rick/opt/kernel/platform/windows/winmsgtb.rc =================================================================== --- sandbox/rick/opt/kernel/platform/windows/winmsgtb.rc 2008-06-26 22:43:20 UTC (rev 2588) +++ sandbox/rick/opt/kernel/platform/windows/winmsgtb.rc 2008-06-27 01:08:05 UTC (rev 2589) @@ -608,6 +608,9 @@ Error_Incorrect_call_nostem "Argument &1 must have a stem object or stem name value; found ""&2""" Error_Incorrect_method_nostem "Method argument &1 must have a stem object value; found ""&2""" Error_Invalid_argument_pointer "Argument &1 is not in valid pointer format; found ""&2""" + Error_Invalid_argument_nostem "Argument &1 must have a stem object or stem name value; found ""&2""" + Error_Invalid_argument_double "Argument &1 must be a valid double value; found ""&2""" + Error_Invalid_argument_maxarg "Too many arguments in invocation; &1 expected" END Modified: sandbox/rick/opt/kernel/runtime/RexxNativeActivation.cpp =================================================================== --- sandbox/rick/opt/kernel/runtime/RexxNativeActivation.cpp 2008-06-26 22:43:20 UTC (rev 2588) +++ sandbox/rick/opt/kernel/runtime/RexxNativeActivation.cpp 2008-06-27 01:08:05 UTC (rev 2589) @@ -175,14 +175,7 @@ /* Function: Report a method signature error */ /******************************************************************************/ { - if (activationType == METHOD_ACTIVATION) - { - reportException(Error_Incorrect_method_nostem, position + 1, object); - } - else - { - reportException(Error_Incorrect_call_nostem, position + 1, object); - } + reportException(Error_Invalid_argument_nostem, position + 1, object); } @@ -384,14 +377,14 @@ case REXX_VALUE_double: /* double value */ { - descriptors[outputIndex].value.value_double = this->getDoubleValue(argument); + descriptors[outputIndex].value.value_double = this->getDoubleValue(argument, inputIndex); break; } case REXX_VALUE_float: /* float value */ { - descriptors[outputIndex].value.value_float = (float)this->getDoubleValue(argument); + descriptors[outputIndex].value.value_float = (float)this->getDoubleValue(argument, inputIndex); break; } @@ -505,7 +498,8 @@ // if this was not an option argument if (!isOptional) { - missing_argument(inputIndex + 1); + /* just raise the error */ + reportException(Error_Invalid_argument_noarg, inputIndex + 1); } // this is a non-specified argument @@ -561,7 +555,7 @@ if (inputIndex < argcount && !usedArglist) /* extra, unwanted arguments? */ { /* got too many */ - reportException(Error_Incorrect_method_maxarg, inputIndex); + reportException(Error_Invalid_argument_maxarg, inputIndex); } } @@ -1615,16 +1609,7 @@ // convert using the whole value range if (!Numerics::objectToWholeNumber(o, temp, maxValue, minValue)) { - if (activationType == METHOD_ACTIVATION) - { - /* this is an error */ - reportException(Error_Incorrect_method_whole, position + 1, o); - } - else - { - /* this is an error */ - reportException(Error_Incorrect_call_whole, position + 1, o); - } + reportException(Error_Invalid_argument_whole, position + 1, o); } return temp; } @@ -1647,16 +1632,7 @@ // convert using the whole value range if (!Numerics::objectToStringSize(o, temp, maxValue)) { - if (activationType == METHOD_ACTIVATION) - { - /* this is an error */ - reportException(Error_Incorrect_method_whole, position + 1, o); - } - else - { - /* this is an error */ - reportException(Error_Incorrect_call_whole, position + 1, o); - } + reportException(Error_Invalid_argument_whole, position + 1, o); } return temp; } @@ -1677,16 +1653,7 @@ // convert using the whole value range if (!Numerics::objectToInt64(o, temp)) { - if (activationType == METHOD_ACTIVATION) - { - /* this is an error */ - reportException(Error_Incorrect_method_whole, position + 1, o); - } - else - { - /* this is an error */ - reportException(Error_Incorrect_call_whole, position + 1, o); - } + reportException(Error_Invalid_argument_whole, position + 1, o); } return temp; } @@ -1707,16 +1674,7 @@ // convert using the whole value range if (!Numerics::objectToUnsignedInt64(o, temp)) { - if (activationType == METHOD_ACTIVATION) - { - /* this is an error */ - reportException(Error_Incorrect_method_whole, position + 1, o); - } - else - { - /* this is an error */ - reportException(Error_Incorrect_call_whole, position + 1, o); - } + reportException(Error_Invalid_argument_whole, position + 1, o); } return temp; } @@ -1761,8 +1719,7 @@ } -double RexxNativeActivation::getDoubleValue( - RexxObject *object) /* object to convert */ +double RexxNativeActivation::getDoubleValue(RexxObject *object, size_t position) /******************************************************************************/ /* Function: Convert an object to a double */ /******************************************************************************/ @@ -1772,7 +1729,7 @@ if (!object->doubleValue(r)) { /* conversion error */ - reportException(Error_Execution_nodouble, object); + reportException(Error_Invalid_argument_double, position + 1, object); } return r; /* return converted number */ } Modified: sandbox/rick/opt/kernel/runtime/RexxNativeActivation.hpp =================================================================== --- sandbox/rick/opt/kernel/runtime/RexxNativeActivation.hpp 2008-06-26 22:43:20 UTC (rev 2588) +++ sandbox/rick/opt/kernel/runtime/RexxNativeActivation.hpp 2008-06-27 01:08:05 UTC (rev 2589) @@ -80,7 +80,7 @@ int64_t int64Value(RexxObject *o, size_t position); uint64_t unsignedInt64Value(RexxObject *o, size_t position); const char *cstring(RexxObject *); - double getDoubleValue(RexxObject *); + double getDoubleValue(RexxObject *, size_t position); bool isDouble(RexxObject *); void *cself(); void *buffer(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |