Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Replacing (broken) noPropFound hook with getValueHook and making glob…

…als hidden from the interpreter a configurable property
  • Loading branch information...
commit e00404a5fde5d7147a0bc00f3175fbab91798539 1 parent b681ad1
@taustin taustin authored
Showing with 9 additions and 6 deletions.
  1. +3 −5 lib/jsdefs.js
  2. +6 −1 lib/jsexec.js
View
8 lib/jsdefs.js
@@ -54,7 +54,9 @@
var narcissus = {
options: {
- version: 185
+ version: 185,
+ // Global variables to hide from the interpreter
+ hiddenHostGlobals: { Narcissus: true }
},
hostSupportsEvalConst: (function() {
try {
@@ -468,9 +470,6 @@ Narcissus.definitions = (function() {
};
}
- // default function used when looking for a property in the global object
- function noPropFound() { return undefined; }
-
var hasOwnProperty = ({}).hasOwnProperty;
function hasOwn(obj, name) {
@@ -674,7 +673,6 @@ Narcissus.definitions = (function() {
whitelistHandler: whitelistHandler,
blacklistHandler: blacklistHandler,
makePassthruHandler: makePassthruHandler,
- noPropFound: noPropFound,
StringMap: StringMap,
ObjectMap: ObjectMap,
Stack: Stack
View
7 lib/jsexec.js
@@ -211,7 +211,8 @@ Narcissus.interpreter = (function() {
});
}
- var hostHandler = definitions.blacklistHandler(hostGlobal, { Narcissus: true });
+ var hostHandler = definitions.blacklistHandler(hostGlobal,
+ Narcissus.options.hiddenHostGlobals);
var hostHandlerGet = hostHandler.get;
hostHandler.get = function(receiver, name) {
return wrapNative(name, hostHandlerGet(receiver, name));
@@ -320,6 +321,10 @@ Narcissus.interpreter = (function() {
function getValue(v) {
if (v instanceof Reference) {
if (!v.base) {
+ // Hook needed for Zaphod
+ if (Narcissus.interpreter.getValueHook) {
+ return Narcissus.interpreter.getValueHook(v.propertyName);
+ }
throw new ReferenceError(v.propertyName + " is not defined",
v.node.filename, v.node.lineno);
}
Please sign in to comment.
Something went wrong with that request. Please try again.