From: <jfa...@us...> - 2011-07-24 22:04:10
|
Revision: 7077 http://oorexx.svn.sourceforge.net/oorexx/?rev=7077&view=rev Author: jfaucher Date: 2011-07-24 22:04:03 +0000 (Sun, 24 Jul 2011) Log Message: ----------- Added options COMMANDS & NOCOMMANDS More work on source literals Modified Paths: -------------- sandbox/jlf/_diary.txt sandbox/jlf/trunk/interpreter/classes/ContextualSourceClass.cpp sandbox/jlf/trunk/interpreter/classes/ContextualSourceClass.hpp sandbox/jlf/trunk/interpreter/execution/CPPCode.cpp sandbox/jlf/trunk/interpreter/execution/RexxActivation.cpp sandbox/jlf/trunk/interpreter/execution/RexxActivation.hpp sandbox/jlf/trunk/interpreter/instructions/CommandInstruction.cpp sandbox/jlf/trunk/interpreter/instructions/OptionsInstruction.cpp sandbox/jlf/trunk/interpreter/memory/Setup.cpp sandbox/jlf/trunk/interpreter/messages/gencat.inp sandbox/jlf/trunk/interpreter/parser/KeywordConstants.cpp sandbox/jlf/trunk/interpreter/parser/SourceFile.cpp sandbox/jlf/trunk/interpreter/parser/SourceFile.hpp sandbox/jlf/trunk/interpreter/parser/Token.hpp sandbox/jlf/trunk/interpreter/runtime/RexxConstants.hpp Modified: sandbox/jlf/_diary.txt =================================================================== --- sandbox/jlf/_diary.txt 2011-07-24 18:56:01 UTC (rev 7076) +++ sandbox/jlf/_diary.txt 2011-07-24 22:04:03 UTC (rev 7077) @@ -43,6 +43,68 @@ =============================================================================== +2011 july 21 + +[expression evaluation] +Added an option to control execution of commands : + ::options COMMANDS + ::options NOCOMMANDS + options "COMMANDS" + options "NOCOMMANDS" +By default, a clause consisting of an expression only is interpreted as a command string. +When using the option NOCOMMANDS, the value of the expression is stored in the +variable RESULT, and not interpreted as a command string. + + +[source literal] +Removed method RexxSourceLiteral::setSource +Removed method RexxContextualSource::setSource +Removed method RexxContextualSource~"source=" +This assignment of source is not needed, and moreover was buggy (overwriting directly +the literal source in the directory of literals). + + +[source literal] +Now RexxSourceLiteral::getSource returns an array of strings, no longer a monoline string. +The monoline string was buggy, because continuation characters were not supported correctly. +And that's how the sources are managed everywhere else. + + +[source literal] +To investigate... +When a routine or method is created, a new RexxSource is created. So all the settings +defined on the package level (i.e. RexxSource) have the default values. +It's possible to pass a context from which a RexxSource is taken (called parentSource) +which allows the created routine/method to inherit class and routine lookup scope from +another source. Nothing else is inherited. + [inherited from context] + routines + merged_public_routines + installed_classes + merged_public_classes + [currently never inherited from context] + digits + fuzz + form + trace + enableCommands +See RoutineClass::newRoutineObject and RexxMethod::newMethodObject, there is a call to +getSourceObject()->inheritSourceContext(parentSource). +This chained context is managed in the following methods : + RexxSource::findLocalRoutine (search in routines) + RexxSource::findPublicRoutine (search in merged_public_routines) + RexxSource::findInstalledClass (search in installed_classes) + RexxSource::findPublicClass (search in merged_public_classes) +A source literal is somewhat special, because it's supposed to have all the settings of +the package in which it's defined (well, I suppose...). So, should find a way to +initialize the RexxSource of the source literal with the settings of the package. +Then, I have the same need for the settings of the RexxActivation in which the executable +created from the RexxContextualSource will run. I think that the closure will be the right +place to manage that, since the closure is a snapshot of the RexxActivation in which the +RexxContextualSource is created. + + +=============================================================================== 2011 july 11 More work on pipe. Modified: sandbox/jlf/trunk/interpreter/classes/ContextualSourceClass.cpp =================================================================== --- sandbox/jlf/trunk/interpreter/classes/ContextualSourceClass.cpp 2011-07-24 18:56:01 UTC (rev 7076) +++ sandbox/jlf/trunk/interpreter/classes/ContextualSourceClass.cpp 2011-07-24 22:04:03 UTC (rev 7077) @@ -97,25 +97,11 @@ RexxSourceLiteral::RexxSourceLiteral(RexxString *s, PackageClass *p) { - // Convert the multiline string s to a monoline string, using ';' as separator. - // Could convert the multiline string s to an array, but I find easier to work on a single string when transforming the source - RexxString *scopy = (RexxString *)s->copy(); - char *data = scopy->getWritableData(); - for (sizeB_t i=0; i < scopy->getBLength(); i++) - { - if (data[i] == '\n') data[i] = ';'; - } - OrefSet(this, this->source, scopy); + OrefSet(this, this->source, s->makeArray(NULL)); // use default separator \n OrefSet(this, this->package, p); } -void RexxSourceLiteral::setSource(RexxString *s) -{ - OrefSet(this, this->source, s); -} - - RexxObject *RexxSourceLiteral::evaluate( RexxActivation *context, /* current activation context */ RexxExpressionStack *stack ) /* evaluation stack */ @@ -205,9 +191,9 @@ } -RexxString *RexxContextualSource::getSource() +RexxArray *RexxContextualSource::getSource() { - return sourceLiteral->getSource(); + return (RexxArray *)(sourceLiteral->getSource()->copy()); } @@ -223,15 +209,6 @@ } -RexxObject *RexxContextualSource::setSource(RexxObject *source) -{ - requiredArgument(source, ARG_ONE); - source = stringArgument(source, ARG_ONE); - this->sourceLiteral->setSource((RexxString *)source); - return OREF_NULL; -} - - void RexxContextualSource::live(size_t liveMark) /******************************************************************************/ /* Function: Normal garbage collection live marking */ Modified: sandbox/jlf/trunk/interpreter/classes/ContextualSourceClass.hpp =================================================================== --- sandbox/jlf/trunk/interpreter/classes/ContextualSourceClass.hpp 2011-07-24 18:56:01 UTC (rev 7076) +++ sandbox/jlf/trunk/interpreter/classes/ContextualSourceClass.hpp 2011-07-24 22:04:03 UTC (rev 7077) @@ -65,15 +65,13 @@ RexxSourceLiteral(RexxString *, PackageClass *); inline RexxSourceLiteral(RESTORETYPE restoreType) { ; }; - RexxString *getSource() { return source; } + RexxArray *getSource() { return source; } PackageClass *getPackage() { return package; } - void setSource(RexxString *); - RexxObject *evaluate(RexxActivation *, RexxExpressionStack *); protected: - RexxString *source; + RexxArray *source; PackageClass *package; }; @@ -96,12 +94,10 @@ RexxObject *newRexx(RexxObject **args, size_t argc); RexxObject *copyRexx(); - RexxString *getSource(); + RexxArray *getSource(); PackageClass *getPackage(); RexxContext *getContext(); - RexxObject *setSource(RexxObject *); - static void createInstance(); static RexxClass *classInstance; // singleton class instance Modified: sandbox/jlf/trunk/interpreter/execution/CPPCode.cpp =================================================================== --- sandbox/jlf/trunk/interpreter/execution/CPPCode.cpp 2011-07-24 18:56:01 UTC (rev 7076) +++ sandbox/jlf/trunk/interpreter/execution/CPPCode.cpp 2011-07-24 22:04:03 UTC (rev 7077) @@ -1012,7 +1012,6 @@ CPPM(RexxContextualSource::newRexx), CPPM(RexxContextualSource::copyRexx), CPPM(RexxContextualSource::getSource), -CPPM(RexxContextualSource::setSource), CPPM(RexxContextualSource::getPackage), CPPM(RexxContextualSource::getContext), Modified: sandbox/jlf/trunk/interpreter/execution/RexxActivation.cpp =================================================================== --- sandbox/jlf/trunk/interpreter/execution/RexxActivation.cpp 2011-07-24 18:56:01 UTC (rev 7076) +++ sandbox/jlf/trunk/interpreter/execution/RexxActivation.cpp 2011-07-24 22:04:03 UTC (rev 7077) @@ -106,6 +106,8 @@ const size_t RexxActivation::trace_results_flags = (trace_all | trace_labels | trace_results | trace_commands); const size_t RexxActivation::trace_intermediates_flags = (trace_all | trace_labels | trace_results | trace_commands | trace_intermediates); +const bool RexxActivation::default_enable_commands = true; + const size_t RexxActivation::single_step = 0x00000800; /* we are single stepping execution */ const size_t RexxActivation::single_step_nested = 0x00001000; /* this is a nested stepping */ const size_t RexxActivation::debug_prompt_issued = 0x00002000; /* debug prompt already issued */ @@ -188,6 +190,7 @@ this->settings.numericSettings.fuzz = sourceObject->getFuzz(); this->settings.numericSettings.form = sourceObject->getForm(); setTrace(sourceObject->getTraceSetting(), sourceObject->getTraceFlags()); + this->settings.enableCommands = sourceObject->getEnableCommands(); if (_method->isGuarded()) // make sure we set the appropriate guarded state { @@ -332,6 +335,7 @@ this->settings.numericSettings.fuzz = sourceObject->getFuzz(); this->settings.numericSettings.form = sourceObject->getForm(); setTrace(sourceObject->getTraceSetting(), sourceObject->getTraceFlags()); + this->settings.enableCommands = sourceObject->getEnableCommands(); /* save the source also */ this->settings.parent_code = this->code; @@ -1941,6 +1945,14 @@ return this->settings.numericSettings.form; } +bool RexxActivation::enableCommands() +/******************************************************************************/ +/* Function: Return the current COMMANDS setting */ +/******************************************************************************/ +{ + return this->settings.enableCommands; +} + /** * Set the digits setting to the package-defined default */ @@ -1994,6 +2006,15 @@ } +void RexxActivation::enableCommands(bool status) +/******************************************************************************/ +/* Function: Set the new current ENABLE_COMMANDS setting */ +/******************************************************************************/ +{ + this->settings.enableCommands = status; +} + + /** * Return the Rexx context this operates under. Depending on the * context, this could be null. Modified: sandbox/jlf/trunk/interpreter/execution/RexxActivation.hpp =================================================================== --- sandbox/jlf/trunk/interpreter/execution/RexxActivation.hpp 2011-07-24 18:56:01 UTC (rev 7076) +++ sandbox/jlf/trunk/interpreter/execution/RexxActivation.hpp 2011-07-24 22:04:03 UTC (rev 7077) @@ -123,6 +123,7 @@ int return_status; /* command return status */ size_t traceindent; /* trace indentation */ NumericSettings numericSettings; /* globally effective settings */ + bool enableCommands; /* are commands enabled ? */ int64_t elapsed_time; /* elapsed time clock */ RexxDateTime timestamp; /* current timestamp */ bool intermediate_trace; /* very quick test for intermediate trace */ @@ -173,9 +174,11 @@ size_t digits(); size_t fuzz(); bool form(); + bool enableCommands(); void setDigits(size_t); void setFuzz(size_t); void setForm(bool); + void enableCommands(bool); void setDigits(); void setFuzz(); void setForm(); @@ -651,6 +654,8 @@ static const size_t trace_results_flags; // flag set for trace results static const size_t trace_intermediates_flags; // flag set for trace intermediates + static const bool default_enable_commands; + static const size_t single_step; /* we are single stepping execution */ static const size_t single_step_nested; /* this is a nested stepping */ static const size_t debug_prompt_issued; /* debug prompt already issued */ Modified: sandbox/jlf/trunk/interpreter/instructions/CommandInstruction.cpp =================================================================== --- sandbox/jlf/trunk/interpreter/instructions/CommandInstruction.cpp 2011-07-24 18:56:01 UTC (rev 7076) +++ sandbox/jlf/trunk/interpreter/instructions/CommandInstruction.cpp 2011-07-24 22:04:03 UTC (rev 7077) @@ -67,14 +67,31 @@ context->traceCommand(this); /* trace if necessary */ /* get the expression value */ RexxObject *result = this->expression->evaluate(context, stack); - RexxString *command = REQUEST_STRING(result); /* force to string form */ - /* are we tracing commands? */ - if (context->tracingCommands()) + if (context->enableCommands()) { - /* then we always trace full command */ - context->traceValue((RexxObject *)command, TRACE_PREFIX_RESULT); + RexxString *command = REQUEST_STRING(result); /* force to string form */ + /* are we tracing commands? */ + if (context->tracingCommands()) + { + /* then we always trace full command */ + context->traceValue((RexxObject *)command, TRACE_PREFIX_RESULT); + } + /* go process the command */ + context->command(context->getAddress(), command); } - /* go process the command */ - context->command(context->getAddress(), command); + else + { + if (result != OREF_NULL) /* result returned? */ + { + /* set the RESULT variable to the */ + /* message return value */ + context->setLocalVariable(OREF_RESULT, VARIABLE_RESULT, (RexxObject *)result); + context->traceResult((RexxObject *)result); /* trace if necessary */ + } + else /* drop the variable RESULT */ + { + context->dropLocalVariable(OREF_RESULT, VARIABLE_RESULT); + } + } } Modified: sandbox/jlf/trunk/interpreter/instructions/OptionsInstruction.cpp =================================================================== --- sandbox/jlf/trunk/interpreter/instructions/OptionsInstruction.cpp 2011-07-24 18:56:01 UTC (rev 7076) +++ sandbox/jlf/trunk/interpreter/instructions/OptionsInstruction.cpp 2011-07-24 22:04:03 UTC (rev 7077) @@ -82,6 +82,16 @@ break; /* if length of word = 0 then stop */ } + if (word->strCaselessCompare(CHAR_COMMANDS)) + { + context->enableCommands(true); + } + + if (word->strCaselessCompare(CHAR_NOCOMMANDS)) + { + context->enableCommands(false); + } + #ifdef _DEBUG if (word->strCaselessCompare("DUMPMEMORY")) { Modified: sandbox/jlf/trunk/interpreter/memory/Setup.cpp =================================================================== --- sandbox/jlf/trunk/interpreter/memory/Setup.cpp 2011-07-24 18:56:01 UTC (rev 7076) +++ sandbox/jlf/trunk/interpreter/memory/Setup.cpp 2011-07-24 22:04:03 UTC (rev 7077) @@ -1393,7 +1393,6 @@ defineKernelMethod(CHAR_COPY ,TheRexxContextualSourceBehaviour, CPPM(RexxContextualSource::copyRexx), 0); defineKernelMethod(CHAR_SOURCE ,TheRexxContextualSourceBehaviour, CPPM(RexxContextualSource::getSource), 0); - defineKernelMethod(CHAR_SOURCEEQUALS ,TheRexxContextualSourceBehaviour, CPPM(RexxContextualSource::setSource), 1); defineKernelMethod(CHAR_PACKAGE ,TheRexxContextualSourceBehaviour, CPPM(RexxContextualSource::getPackage), 0); defineKernelMethod(CHAR_CONTEXT ,TheRexxContextualSourceBehaviour, CPPM(RexxContextualSource::getContext), 0); Modified: sandbox/jlf/trunk/interpreter/messages/gencat.inp =================================================================== --- sandbox/jlf/trunk/interpreter/messages/gencat.inp 2011-07-24 18:56:01 UTC (rev 7076) +++ sandbox/jlf/trunk/interpreter/messages/gencat.inp 2011-07-24 22:04:03 UTC (rev 7077) @@ -147,10 +147,10 @@ 35 Invalid expression $ Error_Unmatched_parenthesis -36 Unmatched "(" or "[" in expression +36 Unmatched "(" or "[" or "{" in expression $ Error_Unexpected_comma -37 Unexpected ",", ")", or "]" +37 Unexpected ",", ")", "]", or "}" $ Error_Invalid_template 38 Invalid template or pattern @@ -1757,7 +1757,22 @@ $ Error_Invalid_expression_call 718 Missing expression for calculated CALL name +$ Message_Translations_routine_invocation +719 Routine &1 in package &2 +$ Message_Translations_method_invocation +720 Method &1 with scope "&2" in package &3 + +$ Error_Incorrect_method_multi_dimension +721 Method argument &1 cannot have more than a single dimension + +$ Error_Unmatched_parenthesis_curly +722 Curly bracket "{" in position &1 on line &2 requires a corresponding right curly bracket "}" + +$ Error_Unexpected_curly_bracket +723 Unexpected "}" + + $ * -------------------------------------------------------------------------- */ $ * -- ================================================== -- */ $ * -- DO NOT CHANGE THIS FILE, ALL CHANGES WILL BE LOST! -- */ Modified: sandbox/jlf/trunk/interpreter/parser/KeywordConstants.cpp =================================================================== --- sandbox/jlf/trunk/interpreter/parser/KeywordConstants.cpp 2011-07-24 18:56:01 UTC (rev 7076) +++ sandbox/jlf/trunk/interpreter/parser/KeywordConstants.cpp 2011-07-24 22:04:03 UTC (rev 7077) @@ -376,6 +376,7 @@ KeywordEntry(CHAR_ABSTRACT, SUBDIRECTIVE_ABSTRACT), KeywordEntry(CHAR_ATTRIBUTE, SUBDIRECTIVE_ATTRIBUTE), KeywordEntry(CHAR_CLASS, SUBDIRECTIVE_CLASS), + KeywordEntry(CHAR_COMMANDS, SUBDIRECTIVE_COMMANDS), KeywordEntry(CHAR_DIGITS, SUBDIRECTIVE_DIGITS), KeywordEntry(CHAR_EXTERNAL, SUBDIRECTIVE_EXTERNAL), KeywordEntry(CHAR_FORM, SUBDIRECTIVE_FORM), @@ -386,6 +387,7 @@ KeywordEntry(CHAR_LIBRARY, SUBDIRECTIVE_LIBRARY), KeywordEntry(CHAR_METACLASS, SUBDIRECTIVE_METACLASS), KeywordEntry(CHAR_MIXINCLASS, SUBDIRECTIVE_MIXINCLASS), + KeywordEntry(CHAR_NOCOMMANDS, SUBDIRECTIVE_NOCOMMANDS), KeywordEntry(CHAR_PRIVATE, SUBDIRECTIVE_PRIVATE), KeywordEntry(CHAR_PROTECTED, SUBDIRECTIVE_PROTECTED), KeywordEntry(CHAR_PUBLIC, SUBDIRECTIVE_PUBLIC), Modified: sandbox/jlf/trunk/interpreter/parser/SourceFile.cpp =================================================================== --- sandbox/jlf/trunk/interpreter/parser/SourceFile.cpp 2011-07-24 18:56:01 UTC (rev 7076) +++ sandbox/jlf/trunk/interpreter/parser/SourceFile.cpp 2011-07-24 22:04:03 UTC (rev 7077) @@ -1751,6 +1751,7 @@ digits = Numerics::DEFAULT_DIGITS; form = Numerics::DEFAULT_FORM; fuzz = Numerics::DEFAULT_FUZZ; + enableCommands = RexxActivation::default_enable_commands; traceSetting = DEFAULT_TRACE_SETTING; traceFlags = RexxActivation::default_trace_flags; @@ -2598,6 +2599,18 @@ } break; } + // ::OPTIONS COMMANDS + case SUBDIRECTIVE_COMMANDS: + { + enableCommands = true; + break; + } + // ::OPTIONS NOCOMMANDS + case SUBDIRECTIVE_NOCOMMANDS: + { + enableCommands = false; + break; + } default: /* invalid keyword */ /* this is an error */ Modified: sandbox/jlf/trunk/interpreter/parser/SourceFile.hpp =================================================================== --- sandbox/jlf/trunk/interpreter/parser/SourceFile.hpp 2011-07-24 18:56:01 UTC (rev 7076) +++ sandbox/jlf/trunk/interpreter/parser/SourceFile.hpp 2011-07-24 22:04:03 UTC (rev 7077) @@ -403,6 +403,7 @@ size_t getTraceSetting() { return traceSetting; } size_t getTraceFlags() { return traceFlags; } RexxString *getTrace() { return formatTraceSetting(traceSetting); } + bool getEnableCommands() { return enableCommands; } static pbuiltin builtinTable[]; /* table of builtin function stubs */ @@ -480,6 +481,7 @@ bool form; /* numeric form setting */ size_t traceSetting; // the package trace setting size_t traceFlags; // version optimized for quick setting at startup + bool enableCommands; // are commands enabled ? intptr_t reserved1; // some reserved values for compatible expansion intptr_t reserved2; // some reserved values for compatible expansion intptr_t reserved3; // some reserved values for compatible expansion Modified: sandbox/jlf/trunk/interpreter/parser/Token.hpp =================================================================== --- sandbox/jlf/trunk/interpreter/parser/Token.hpp 2011-07-24 18:56:01 UTC (rev 7076) +++ sandbox/jlf/trunk/interpreter/parser/Token.hpp 2011-07-24 22:04:03 UTC (rev 7077) @@ -278,6 +278,8 @@ #define SUBDIRECTIVE_FORM 2519 #define SUBDIRECTIVE_FUZZ 2520 #define SUBDIRECTIVE_TRACE 2521 +#define SUBDIRECTIVE_COMMANDS 2522 +#define SUBDIRECTIVE_NOCOMMANDS 2523 /* condition keywords */ Modified: sandbox/jlf/trunk/interpreter/runtime/RexxConstants.hpp =================================================================== --- sandbox/jlf/trunk/interpreter/runtime/RexxConstants.hpp 2011-07-24 18:56:01 UTC (rev 7076) +++ sandbox/jlf/trunk/interpreter/runtime/RexxConstants.hpp 2011-07-24 22:04:03 UTC (rev 7077) @@ -98,6 +98,7 @@ CHARCONSTANT(CLOSE, "CLOSE"); CHARCONSTANT(CODE, "CODE"); CHARCONSTANT(COMMAND, "COMMAND"); +CHARCONSTANT(COMMANDS, "COMMANDS"); CHARCONSTANT(COMMON_RETRIEVERS, "COMMON_RETRIEVERS"); CHARCONSTANT(COMPARETO, "COMPARETO"); CHARCONSTANT(COMPARABLE, "COMPARABLE"); @@ -219,6 +220,7 @@ CHARCONSTANT(NEXT, "NEXT"); CHARCONSTANT(NIL, "NIL"); CHARCONSTANT(NMETHOD, "NMETHOD"); +CHARCONSTANT(NOCOMMANDS, "NOCOMMANDS"); CHARCONSTANT(NOEXMODE, "NOEXMODE"); CHARCONSTANT(NOMETHOD, "NOMETHOD"); CHARCONSTANT(NONE, "<none>"); @@ -312,7 +314,6 @@ CHARCONSTANT(SIZE, "SIZE"); CHARCONSTANT(SORT, "SORT"); CHARCONSTANT(SORTWITH, "SORTWITH"); -CHARCONSTANT(SOURCEEQUALS, "SOURCE="); CHARCONSTANT(SOURCE, "SOURCE"); CHARCONSTANT(STABLESORT, "STABLESORT"); CHARCONSTANT(STABLESORTWITH, "STABLESORTWITH"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |