-
-
Notifications
You must be signed in to change notification settings - Fork 925
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not persist filename in IR; require it when loading.
Fixes #3109 Because compiled scripts may be moved around or loaded from locations different than when they were compiled, we must pass filename into the decoding process to allow the script to reflect the new filename.
Showing
11 changed files
with
80 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.jruby.ir.operands; | ||
|
||
import org.jruby.ir.persistence.IRReaderDecoder; | ||
import org.jruby.ir.persistence.IRWriterEncoder; | ||
import org.jruby.util.ByteList; | ||
|
||
/** | ||
* Represents the script's __FILE__. Isolated as its own operand because we need to be able to replace it when loading | ||
* persisted IR from a location different than original script. | ||
*/ | ||
public class Filename extends StringLiteral { | ||
public Filename(ByteList filename) { | ||
super(OperandType.FILENAME, filename, 0); | ||
} | ||
|
||
@Override | ||
public boolean hasKnownValue() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void encode(IRWriterEncoder e) { | ||
// we only do base encoding because filename must be provided while deserializing (#3109) | ||
e.encode(getOperandType().getCoded()); | ||
} | ||
|
||
public static Filename decode(IRReaderDecoder d) { | ||
return new Filename(d.getFilename()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
you probably want a hard failure here