As a first step I have been trying to correct the code to accept compiled Rexx scripts as method code (using the .method's newFile).
This seems to have been successful, decoding now works. However, when assigning the method object to a class and then sending an object of that class the message to execute the method, I get the runtime error message (Rexx test script at the end): 15 *-* say .context~name", return value:" o~aha(1,2,3) Error 97 running G:\oorexx.tmp\oorexxBuild\debug32.trunk\bin\testrgf.rex line 15: Object method not found. Error 97.3: Object "a TEST" cannot accept package scope message "AHA" from a different package caller. The compiled Rexx code for the method gets successfully processed in a new method defined in ProgramMetaData.cpp: MethodClass *ProgramMetaData::restoreMethod(RexxString *name, BufferClass *buffer) { ProgramMetaData *metaData; // check to see if this is already translated if (!processRestoreData(name, buffer, metaData)) { // nope, can't restore this return OREF_NULL; } // make sure this is valid for interpreter if (!metaData->validate(name)) { return OREF_NULL; } // this should be valid...try to restore. Protected<MethodClass> method = MethodClass::restore(buffer, metaData->getImageData(), metaData->getImageSize()); // change the program name to match the file this was restored from method->getPackageObject()->setProgramName(name); return method; } The question is, how can I inhibit the runtime error 97.3, what do I need to do to the method object? The starting point is in LanguageParser the new method: MethodClass* LanguageParser::createMethod(RexxString *name, PackageClass *sourceContext) { // load the file into a buffer Protected<BufferClass> program_buffer = FileProgramSource::readProgram(name->getStringData()); // if this failed, report an error now. if (program_buffer == (BufferClass *)OREF_NULL) { reportException(Error_Program_unreadable_name, name); } // try to restore a flattened program first Protected<MethodClass> method = MethodClass::restore(name, program_buffer); if (method != (MethodClass *)OREF_NULL) { return method; } // create the appropriate program source, then the parser, then generate the // code. Protected<ProgramSource> programSource = new BufferProgramSource(program_buffer); Protected<LanguageParser> parser = new LanguageParser(name, programSource); return parser->generateMethod(sourceContext); } Hence it would be possible to pass the sourceContext as the third arguemtn via the new method MethodClass::restore() to ProgramMetaData::restoreMethod(...). But then, how can I set the scope from the sourceContext which is a PackageClass, bet MethodClass::setScope expects a RexxClass? ---rony P.S.: Here the Rexx test script that generates the above runtime error: fnames="testmethod.rex", "testmethod-compiled.rex", "testmethod-compiled-encoded.rex" say "testing routine code from external files:" do fn over fnames o=.routine~newFile(fn) say .context~name", return value:" o[1,2,3] say end say "--------------------" say "testing method code from external files:" do fn over fnames o=.test~new~~addMethod("aha", .method~newFile(fn)) say .context~name", return value:" o~aha(1,2,3) /* <--- line # 15 */ say end ::class test ::method addMethod use strict arg name, method self~setmethod(name, method, "object") Here the three external files: testmethod-compiled.rex ... copmiled with rexxc testmethod-compiled-encoded.rex ... compiled with the "/e" switch of rexxc.exe testmethod.rex ... source code: parse source s say .dateTime~new": number of args:" arg() say .dateTime~new": args :" arg(1,'A')~toString(,",") say .dateTime~new": parse source :" s say .dateTime~new": .context~name :" .context~name return .dateTime~new Here the output of running the above test script including the runtime error: G:\oorexx.tmp\oorexxBuild\debug32.trunk\bin>rexx testrgf.rex testing routine code from external files: 2020-08-06T13:53:14.998000: number of args: 3 2020-08-06T13:53:14.998000: args : 1,2,3 2020-08-06T13:53:14.998000: parse source : WindowsNT SUBROUTINE testmethod.rex 2020-08-06T13:53:14.998000: .context~name : testmethod.rex G:\oorexx.tmp\oorexxBuild\debug32.trunk\bin\testrgf.rex, return value: 2020-08-06T13:53:14.998000 2020-08-06T13:53:14.998000: number of args: 3 2020-08-06T13:53:14.998000: args : 1,2,3 2020-08-06T13:53:14.998000: parse source : WindowsNT SUBROUTINE testmethod-compiled.rex 2020-08-06T13:53:14.998000: .context~name : G:\oorexx.tmp\oorexxBuild\debug32.trunk\bin\testmethod.rex G:\oorexx.tmp\oorexxBuild\debug32.trunk\bin\testrgf.rex, return value: 2020-08-06T13:53:14.998000 2020-08-06T13:53:15.014000: number of args: 3 2020-08-06T13:53:15.014000: args : 1,2,3 2020-08-06T13:53:15.014000: parse source : WindowsNT SUBROUTINE testmethod-compiled-encoded.rex 2020-08-06T13:53:15.014000: .context~name : G:\oorexx.tmp\oorexxBuild\debug32.trunk\bin\testmethod.rex G:\oorexx.tmp\oorexxBuild\debug32.trunk\bin\testrgf.rex, return value: 2020-08-06T13:53:15.014000 -------------------- testing method code from external files: 2020-08-06T13:53:15.014000: number of args: 3 2020-08-06T13:53:15.014000: args : 1,2,3 2020-08-06T13:53:15.014000: parse source : WindowsNT METHOD testmethod.rex 2020-08-06T13:53:15.014000: .context~name : AHA G:\oorexx.tmp\oorexxBuild\debug32.trunk\bin\testrgf.rex, return value: 2020-08-06T13:53:15.014000 15 *-* say .context~name", return value:" o~aha(1,2,3) Error 97 running G:\oorexx.tmp\oorexxBuild\debug32.trunk\bin\testrgf.rex line 15: Object method not found. Error 97.3: Object "a TEST" cannot accept package scope message "AHA" from a different package caller.
_______________________________________________ Oorexx-devel mailing list Oorexx-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/oorexx-devel