Closed Bug 114583 Opened 23 years ago Closed 22 years ago

script compile/decompile bug

Categories

(Rhino Graveyard :: Compiler, defect)

Other
Neutrino
defect
Not set
normal

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: bugzilla, Assigned: norrisboyd)

References

Details

Attachments

(1 file)

the following code :

>	    	Context cx = Context.enter();
>		Scriptable scope = cx.initStandardObjects( null );
>
>	        cx.setGeneratingDebug( true );
>	        cx.setGeneratingSource( true );
>
>		String src = " var x = 5; var y = 10; "; 
>		StringReader sr = new StringReader( src ); 
>		Script script = null;
>		
>		try {
>			script = cx.compileReader( scope, sr, "Test", 1, null );
>		} catch ( Exception e ) {
>		}
>		System.out.println( cx.decompileScript( script, scope, 4 ) );
>		System.exit( 1 );
		
gives :

	function () {
		[native code]
	}

whereas the following :

>	    	Context cx = Context.enter();
>		Scriptable scope = cx.initStandardObjects( null );
>
>	        cx.setGeneratingDebug( true );
>	        cx.setGeneratingSource( true );
>
>		String src = " var x = 5; var y = 10; "; 
>		StringReader sr = new StringReader( src ); 
>		Script script = null;
>		
>		try {
>			script = cx.compileReader( scope, sr, "Test", 1, null );
>			script.exec(cx, scope);
>		} catch ( Exception e ) {
>		}
>		System.out.println( cx.decompileScript( script, scope, 4 ) );
>		System.exit( 1 );


behaves as expected (by printing the decompiled script). 
( there is a added exec() call to "script" )
This is fixed as a byproduct of recent changes in decompilation support, for
test see the following java source.
Attached file Full program for test case β€”
Marking FIXED.

I successfully compiled and ran Igor's test "Y.java".
I got this output:

[//c/WinNT/profiles/pschwartau/Desktop]
$ java -classpath "D:\JS_trunk\mozilla\js\rhino\build\rhino1_5R4pre\js.jar;." Y
function () {
        [native code, arity=0]
}
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Marking Verified -
Status: RESOLVED → VERIFIED
*** Bug 61579 has been marked as a duplicate of this bug. ***
Just to double-check with Igor: was my output above correct?

function () {
        [native code, arity=0]
}
OOPS!!! I had my directories mixed up, and was using an old Rhino tree.
The bug is indeed fixed. Now that I've updated the correct tree, we can
compare rhino1_5R3pre vs. rhino1_5R4pre:


[//c/WinNT/profiles/pschwartau/Desktop]
$ java -classpath "D:\JS_TRUNK\mozilla\js\rhino\build\rhino1_5R3pre\js.jar; ." Y
function () {
        [native code]
}


[//c/WinNT/profiles/pschwartau/Desktop]
$ java -classpath "D:\JS_TRUNK\mozilla\js\rhino\build\rhino1_5R4pre\js.jar; ." Y

    var x = 5;
    var y = 10;


And this shows the effect of the bug fix -
Targeting as resolved against 1.5R4
Target Milestone: --- → 1.5R4
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: