public ExecutionContext createFunctionExecutionContext( Object functionReference, JSFunction function, Object thisArg, Object... arguments) { // 10.4.3 Object thisBinding = null; if (function.isStrict()) { thisBinding = thisArg; } else { if (thisArg == null || thisArg == Types.NULL || thisArg == Types.UNDEFINED) { thisBinding = this.getLexicalEnvironment().getGlobalObject(); } else if (!(thisArg instanceof JSObject)) { // thisBinding = Types.toObject(this, thisArg); thisBinding = Types.toThisObject(this, thisArg); } else { thisBinding = thisArg; } } LexicalEnvironment scope = function.getScope(); LexicalEnvironment localEnv = LexicalEnvironment.newDeclarativeEnvironment(scope); ExecutionContext context = new ExecutionContext(this, localEnv, localEnv, thisBinding, function.isStrict()); context.performDeclarationBindingInstantiation(function, arguments); context.fileName = function.getFileName(); // System.err.println( "debug null: " + ( function.getDebugContext() == null ? function : "not // null") ); context.debugContext = function.getDebugContext(); context.functionReference = functionReference; return context; }
public void onMessage( String channel, String sender, String login, String hostname, String message) { JSFunction onMessage = (JSFunction) _things.get("onMessage"); if (onMessage == null) return; JSObjectBase o = new JSObjectBase(); o.set("channel", channel); o.set("sender", sender); o.set("login", login); o.set("hostname", hostname); o.set("message", message); onMessage.call(onMessage.getScope(), o); }
protected void onDisconnect() { JSFunction onDisconnect = (JSFunction) _things.get("onDisconnect"); if (onDisconnect == null) return; onDisconnect.call(onDisconnect.getScope()); }