/*
Invokes app.hello.world.someFn(...) with the correct arguments.
The thisPtr in someFn is set to world.
543019
function invokeCallExpression(callExpression, app, argsDict) {
  const memberExpression = callExpression.callee;
  const functionPath = getPathFromMemberExpression(memberExpression);
  const [fnPtr, thisPtr] = functionPath.reduce(([_fn, _this], item) =>  [_fn[item], _fn], [app, undefined])

  const args = callExpression.arguments.map(a => {
    if (a.type === "Identifier") {
      return argsDict[a.name];
    } else if (a.type === "Literal") {
      return a.value;
    } else {
      throw new Error(`Expected Identifier or Literal but got ${a.type}.`);
    }
  });

  return fnPtr.apply(thisPtr, args)
}
1017834
public boolean invoke() {
        if (mClickListener != null &&
            mClickListener.onMenuItemClick(this)) {
            return true;
        }

        if (mMenu.dispatchMenuItemSelected(mMenu.getRootMenu(), this)) {
            return true;
        }

        if (mItemCallback != null) {
            mItemCallback.run();
            return true;
        }

        if (mIntent != null) {
            try {
                mMenu.getContext().startActivity(mIntent);
                return true;
            } catch (ActivityNotFoundException e) {
                Log.e(TAG, "Can't find activity to handle intent; ignoring", e);
            }
        }

        if (mActionProvider != null && mActionProvider.onPerformDefaultAction()) {
            return true;
        }

        return false;
    }
225336
public void invoke()
    {
        assert state == State.READ_FRAME_COMPLETE : "Invoke called in invalid state: " + state;

        TTransport inTrans = getInputTransport();
        TProtocol inProt = thriftFactories.inputProtocolFactory.getProtocol(inTrans);
        TProtocol outProt = thriftFactories.outputProtocolFactory.getProtocol(getOutputTransport());

        try
        {
            thriftFactories.processorFactory.getProcessor(inTrans).process(inProt, outProt);
            responseReady();
            return;
        }
        catch (TException te)
        {
            logger.warn("Exception while invoking!", te);
        }
        catch (Throwable t)
        {
            logger.error("Unexpected throwable while invoking!", t);
        }

        // This will only be reached when there is a throwable.
        state = State.AWAITING_CLOSE;
        changeSelectInterests();
    }
1091140
function(e) {
		gui.Spirit.prototype.onevent.call(this, e);
		switch (e.type) {
			case 'message':
				this._onmessage(e.data, e.origin, e.source);
				break;
			case 'load':
				// now what?
				break;
		}
	}
330148
protected void invokeCallbacks(ThreadLocalRandom r) {
        final Set<SelectionKey> selectedKeys = m_selector.selectedKeys();
        final int keyCount = selectedKeys.size();
        int startInx = r.nextInt(keyCount);
        int itInx = 0;
        Iterator<SelectionKey> it = selectedKeys.iterator();
        while(itInx < startInx) {
            it.next();
            itInx++;
        }
        while(itInx < keyCount) {
            final Object obj = it.next().attachment();
            if (obj == null) {
                continue;
            }
            final VoltPort port = (VoltPort)obj;
            callPort(port);
            itInx++;
        }
        itInx = 0;
        it = selectedKeys.iterator();
        while(itInx < startInx) {
            final Object obj = it.next().attachment();
            if (obj == null) {
                continue;
            }
            final VoltPort port = (VoltPort)obj;
            callPort(port);
            itInx++;
        }
        selectedKeys.clear();
    }
1065172
function caller() {
  const returnedArgs = Array.prototype.slice.call(arguments)
  const fn = returnedArgs.shift()
  const self = this

  return wrapPromise(function (resolve, reject) {
    returnedArgs.push(function (err, args) {
      if (err) {
        reject(err)
        return
      }

      resolve(args)
    })

    fn.apply(self, returnedArgs)
  })
}
1091920
function workFn() {
      var modules = currentSpec.$modules || [];

      modules.unshift('ngMock');
      modules.unshift('ng');
      var injector = currentSpec.$injector;
      if (!injector) {
        injector = currentSpec.$injector = angular.injector(modules);
      }
      for(var i = 0, ii = blockFns.length; i < ii; i++) {
        try {
          /* jshint -W040 *//* Jasmine explicitly provides a `this` object when calling functions */
          injector.invoke(blockFns[i] || angular.noop, this);
          /* jshint +W040 */
        } catch (e) {
          if(e.stack && errorForStack) e.stack +=  '\n' + errorForStack.stack;
          throw e;
        } finally {
          errorForStack = null;
        }
      }
    }
122454
protected void demo() throws Throwable {
	    MethodHandles.Lookup lookup = MethodHandles.lookup();
	    MethodType type = MethodType.methodType(String.class, int.class, int.class);
	    MethodHandle mh = lookup.findVirtual(String.class, "substring", type);
	    String str = (String) mh.invokeExact("Hello World", 1, 3);
	    System.out.println(str);
	}
595704
function RequestCallbackHandler(callback, thisp) {
    var self = this;
    self.callback = callback;
    self.thisp = thisp || self;
}
133158
function(action, thisp) {
			var is = this.initialized;
			if (arguments.length) {
				if (is) {
					action.call(thisp);
				} else {
					this._initcallbacks = this._initcallbacks || [];
					this._initcallbacks.push(function() {
						if (gui.debug) {
							try {
								action.call(thisp);
							} catch (exception) {
								console.error(action.toString());
								throw exception;
							}
						} else {
							action.call(thisp);
						}
					});
				}
			}
			return is;
		}
689251
function invoke() {
        parent::invoke();

        $result = true;

        // Set own core attributes
        $this->does_generate = ACTION_GENERATE_HTML;

        // These are always here
        global $CFG, $XMLDB, $SESSION, $DB;

        // Get lastused
        $o = '';
        if (isset($SESSION->lastused)) {
            if ($lastused = $SESSION->lastused) {
                // Print link
                $o .= '<p class="centerpara"><a href="#lastused">' . $this->str['gotolastused'] . '</a></p>';
            }
        } else {
            $lastused = NULL;
        }

        // Calculate the buttons
        $b = '<p class="centerpara buttons">';
        // The reserved_words button
        $b .= '&nbsp;<a href="index.php?action=view_reserved_words">[' . $this->str['reservedwords'] . ']</a>';
        // The docs button
        $b .= '&nbsp;<a href="index.php?action=generate_all_documentation">[' . $this->str['doc'] . ']</a>';
        // The check indexes button
        $b .= '&nbsp;<a href="index.php?action=check_indexes&amp;sesskey=' . sesskey() . '">[' . $this->str['checkindexes'] . ']</a>';
        // The check defaults button
        $b .= '&nbsp;<a href="index.php?action=check_defaults&amp;sesskey=' . sesskey() . '">[' . $this->str['checkdefaults'] . ']</a>';
        // The check bigints button (only for MySQL and PostgreSQL) MDL-11038a
        if ($DB->get_dbfamily() == 'mysql' || $DB->get_dbfamily() == 'postgres') {
            $b .= '&nbsp;<a href="index.php?action=check_bigints&amp;sesskey=' . sesskey() . '">[' . $this->str['checkbigints'] . ']</a>';
        }
        // The check semantics button (only for Oracle) MDL-29416
        if ($DB->get_dbfamily() == 'oracle') {
            $b .= '&nbsp;<a href="index.php?action=check_oracle_semantics&amp;sesskey=' . sesskey() . '">[' . $this->str['checkoraclesemantics'] . ']</a>';
        }
        $b .= '&nbsp;<a href="index.php?action=check_foreign_keys&amp;sesskey=' . sesskey() . '">[' . $this->str['checkforeignkeys'] . ']</a>';
        $b .= '</p>';
        // Send buttons to output
        $o .= $b;

        // Do the job

        // Get the list of DB directories
        $result = $this->launch('get_db_directories');
        // Display list of DB directories if everything is ok
        if ($result && !empty($XMLDB->dbdirs)) {
            $o .= '<table id="listdirectories" border="0" cellpadding="5" cellspacing="1" class="admintable generaltable">';
            $row = 0;
            foreach ($XMLDB->dbdirs as $key => $dbdir) {
                // Detect if this is the lastused dir
                $hithis = false;
                if (str_replace($CFG->dirroot, '', $key) == $lastused) {
                    $hithis = true;
                }
                $elementtext = str_replace($CFG->dirroot . '/', '', $key);
                // Calculate the dbdir has_changed field if needed
                if (!isset($dbdir->has_changed) && isset($dbdir->xml_loaded)) {
                    $dbdir->xml_changed = false;
                    if (isset($XMLDB->editeddirs[$key])) {
                        $editeddir = $XMLDB->editeddirs[$key];
                        if (isset($editeddir->xml_file)) {
                            $structure = $editeddir->xml_file->getStructure();
                            if ($structure->hasChanged()) {
                                $dbdir->xml_changed = true;
                                $editeddir->xml_changed = true;
                            }
                        }
                    }
                }
                // The file name (link to edit if the file is loaded)
                if ($dbdir->path_exists &&
                    file_exists($key . '/install.xml') &&
                    is_readable($key . '/install.xml') &&
                    is_readable($key) &&
                    !empty($dbdir->xml_loaded)) {
                    $f = '<a href="index.php?action=edit_xml_file&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $key)) . '">' . $elementtext . '</a>';
                } else {
                    $f = $elementtext;
                }
                // Calculate the buttons
                $b = ' <td class="button cell">';
                // The create button
                if ($dbdir->path_exists &&
                    !file_exists($key . '/install.xml') &&
                    is_writeable($key)) {
                    $b .= '<a href="index.php?action=create_xml_file&amp;sesskey=' . sesskey() . '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $key)) . '&amp;time=' . time() . '&amp;postaction=main_view#lastused">[' . $this->str['create'] . ']</a>';
                } else {
                    $b .= '[' . $this->str['create'] . ']';
                }
                $b .= '</td><td class="button cell">';
                // The load button
                if ($dbdir->path_exists &&
                    file_exists($key . '/install.xml') &&
                    is_readable($key . '/install.xml') &&
                    empty($dbdir->xml_loaded)) {
                    $b .= '<a href="index.php?action=load_xml_file&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $key)) . '&amp;time=' . time() . '&amp;postaction=main_view#lastused">[' . $this->str['load'] . ']</a>';
                } else {
                    $b .= '[' . $this->str['load'] . ']';
                }
                $b .= '</td><td class="button cell">';
                // The edit button
                if ($dbdir->path_exists &&
                    file_exists($key . '/install.xml') &&
                    is_readable($key . '/install.xml') &&
                    is_readable($key) &&
                    !empty($dbdir->xml_loaded)) {
                    $b .= '<a href="index.php?action=edit_xml_file&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $key)) . '">[' . $this->str['edit'] . ']</a>';
                } else {
                    $b .= '[' . $this->str['edit'] . ']';
                }
                $b .= '</td><td class="button cell">';
                // The save button
                if ($dbdir->path_exists &&
                    file_exists($key . '/install.xml') &&
                    is_writeable($key . '/install.xml') &&
                    is_writeable($key) &&
                    !empty($dbdir->xml_loaded) &&
                    !empty($dbdir->xml_changed)) {
                    $b .= '<a href="index.php?action=save_xml_file&amp;sesskey=' . sesskey() . '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $key)) . '&amp;time=' . time() . '&amp;postaction=main_view#lastused">[' . $this->str['save'] . ']</a>';
                    // Check if the file has been manually edited while being modified in the editor
                    if ($dbdir->filemtime != filemtime($key . '/install.xml')) {
                        // File manually modified. Add to action error, will be displayed inline.
                        $this->errormsg = $this->str['filemodifiedoutfromeditor'];
                    }
                } else {
                    $b .= '[' . $this->str['save'] . ']';
                }
                $b .= '</td><td class="button cell">';
                // The document button
                if ($dbdir->path_exists &&
                    file_exists($key . '/install.xml') &&
                    is_readable($key . '/install.xml') &&
                    is_readable($key)) {
                    $b .= '<a href="index.php?action=generate_documentation&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $key)) . '">[' . $this->str['doc'] . ']</a>';
                } else {
                    $b .= '[' . $this->str['doc'] . ']';
                }
                $b .= '</td><td class="button cell">';
                // The view xml button
                if ($dbdir->path_exists &&
                    file_exists($key . '/install.xml') &&
                    is_readable($key . '/install.xml')) {
                    $b .= '<a href="index.php?action=view_xml&amp;file=' . urlencode(str_replace($CFG->dirroot, '', $key) . '/install.xml') . '">[' . $this->str['viewxml'] . ']</a>';
                } else {
                    $b .= '[' . $this->str['viewxml'] . ']';
                }
                $b .= '</td><td class="button cell">';
                // The revert button
                if ($dbdir->path_exists &&
                    file_exists($key . '/install.xml') &&
                    is_readable($key . '/install.xml') &&
                    is_writeable($key) &&
                    !empty($dbdir->xml_loaded) &&
                    !empty($dbdir->xml_changed)) {
                    $b .= '<a href="index.php?action=revert_changes&amp;sesskey=' . sesskey() . '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $key)) . '">[' . $this->str['revert'] . ']</a>';
                } else {
                    $b .= '[' . $this->str['revert'] . ']';
                }
                $b .= '</td><td class="button cell">';
                // The unload button
                if ($dbdir->path_exists &&
                    file_exists($key . '/install.xml') &&
                    is_readable($key . '/install.xml') &&
                    !empty($dbdir->xml_loaded) &&
                    empty($dbdir->xml_changed)) {
                    $b .= '<a href="index.php?action=unload_xml_file&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $key)) . '&amp;time=' . time() . '&amp;postaction=main_view#lastused">[' . $this->str['unload'] . ']</a>';
                } else {
                    $b .= '[' . $this->str['unload'] . ']';
                }
                $b .= '</td><td class="button cell">';
                // The delete button
                if ($dbdir->path_exists &&
                    file_exists($key . '/install.xml') &&
                    is_readable($key . '/install.xml') &&
                    is_writeable($key) &&
                    empty($dbdir->xml_loaded)) {
                    $b .= '<a href="index.php?action=delete_xml_file&amp;sesskey=' . sesskey() . '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $key)) . '">[' . $this->str['delete'] . ']</a>';
                } else {
                    $b .= '[' . $this->str['delete'] . ']';
                }
                $b .= '</td>';
                // include the higlight
                if ($hithis) {
                    $o .= '<tr class="highlight"><td class="directory cell"><a name="lastused" />' . $f . '</td>' . $b . '</tr>';
                } else {
                    $o .= '<tr class="r' . $row . '"><td class="directory cell">' . $f . '</td>' . $b . '</tr>';
                }
                $row = ($row + 1) % 2;
                // show errors if they exist
                if (isset($dbdir->xml_file)) {
                    if ($structure = $dbdir->xml_file->getStructure()) {
                        $errors = !empty($this->errormsg) ? array($this->errormsg) : array();
                        $structureerrors = $structure->getAllErrors();
                        if ($structureerrors) {
                            $errors = array_merge($errors, $structureerrors);
                        }
                        if (!empty($errors)) {
                            if ($hithis) {
                                $o .= '<tr class="highlight"><td class="error cell" colspan="10">' . implode (', ', $errors) . '</td></tr>';
                            } else {
                                $o .= '<tr class="r' . $row . '"><td class="error cell" colspan="10">' . implode (', ', $errors) . '</td></tr>';
                            }
                        }
                    }
                }
                // If there are changes pending to be saved, but the file cannot be written... inform here
                if ($dbdir->path_exists &&
                    file_exists($key . '/install.xml') &&
                    !empty($dbdir->xml_loaded) &&
                    !empty($dbdir->xml_changed) &&
                    (!is_writeable($key . '/install.xml') || !is_writeable($key))) {

                    if ($hithis) {
                        $o .= '<tr class="highlight"><td class="error cell" colspan="10">';
                    } else {
                        $o .= '<tr class="r' . $row . '"><td class="error cell" colspan="10">';
                    }
                    $o .= $this->str['pendingchangescannotbesavedreload'];
                    $o .= '</td></tr>';
                }
            }
            $o .= '</table>';

            // Set the output
            $this->output = $o;
        }

        // Finally, return result
        return $result;
    }
315879
public Object call( Object object, String name, Object[] args )
        throws BSFException
    {
        /*
            If object is null use the interpreter's global scope.
        */
        if ( object == null )
            try {
                object = interpreter.get("global");
            } catch ( EvalError e ) {
                throw new BSFException(BSFException.REASON_OTHER_ERROR, "bsh internal error: "+e, e);
            }

        if ( object instanceof bsh.This )
            try
            {
                Object value = ((bsh.This)object).invokeMethod( name, args );
                return Primitive.unwrap( value );
            } catch ( InterpreterError e )
            {
                throw new BSFException(BSFException.REASON_UNKNOWN_LANGUAGE,
                    "BeanShell interpreter internal error: "+e, e);
            } catch ( TargetError e2 )
            {
                throw new BSFException(BSFException.REASON_EXECUTION_ERROR,
                    "The application script threw an exception: "
                    + e2.getTarget(), e2 );
            } catch ( EvalError e3 )
            {
                throw new BSFException(BSFException.REASON_OTHER_ERROR, "BeanShell script error: "+e3, e3);
            }
        else
            throw new BSFException(
                "Cannot invoke method: "+name
                +". Object: "+object +" is not a BeanShell scripted object.");
    }
152053
function FunctionCall( fn , isAsync , thisArg , ... args ) {
	this.function = fn ;
	this.isAsync = isAsync ;
	this.this = thisArg ;
	this.args = args ;
	this.hasThrown = false ;
	this.error = undefined ;
	this.return = undefined ;

	try {
		this.return = this.function.call( this.this || null , ... this.args ) ;
	}
	catch ( error ) {
		this.hasThrown = true ;
		this.error = error ;
	}

	if ( this.isAsync ) {
		if ( this.hasThrown ) {
			this.promise = Promise.resolve() ;
		}
		else {
			this.promise = Promise.resolve( this.return )
				.then(
					value => this.return = value ,
					error => {
						this.hasThrown = true ;
						this.error = error ;
					}
				) ;
		}
	}
}
971568
public boolean invokeOnComponent(FacesContext context, String clientId,
                                     ContextCallback callback)
            throws FacesException {
        return super.invokeOnComponent(context, clientId, callback);
    }
303703
public void invoke(String serviceName, String methodName, Object[] args, String id, Transport transport)
            throws IOException, WsonrpcException {
        if (methodName == null) {
            throw new NullPointerException("methodName");
        }

        String method;
        if (serviceName == null) {
            method = methodName;
        } else {
            method = serviceName + "." + methodName;
        }
        Node[] params = null;
        if (args != null) {
            params = new Node[args.length];
            for (int i = 0; i < args.length; i++) {
                params[i] = jsonImpl.convert(args[i]);
            }
        }

        transmit(transport, new JsonRpcRequest(id, method, params));
    }
1210817
public static void main(String[] args) throws TwiMLException, URISyntaxException {

        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

        Iterable<Record> usage = Record.reader().read();
        for (Record record : usage) {
            System.out.println(record);
        }

        // Get a number
        IncomingPhoneNumber number = buyNumber();
        System.out.println(number.getPhoneNumber());

        // Send a text message
        Message message = Message.creator(
            ACCOUNT_SID,
            PHONE_NUMBER,
            number.getPhoneNumber(),
            "Hello world!"
        ).create();

        System.out.println(message.getSid());
        System.out.println(message.getBody());

        // Make a phone call
        Call call = new CallCreator(
            ACCOUNT_SID,
            PHONE_NUMBER,
            number.getPhoneNumber(),
            URI.create("https://twilio.com")
        ).create();
        System.out.println(call.getSid());

        // Print all the messages
        Iterable<Message> messages = Message.reader().read();
        for (Message m : messages) {
            System.out.println(m.getSid());
            System.out.println(m.getBody());
        }

        // Get some calls
        Iterable<Call> calls = Call.reader().pageSize(2).read();
        for (Call c : calls) {
            System.out.println(c.getSid());
        }

        Trunk trunk = new TrunkCreator()
            .setFriendlyName("shiny trunk")
            .setSecure(false)
            .create();

        System.out.println(trunk);

        // TwiML
        TwiML twiml = new VoiceResponse.Builder()
            .say(new Say.Builder("Hello World!").build())
            .play(new Play.Builder().url(new URI("https://api.twilio.com/cowbell.mp3")).loop(5).build())
            .build();
        System.out.println(twiml.toXml());
    }
69506
public static Object callN(Callable fun, Scriptable thisObj,
                               Object[] args,
                               Context cx, Scriptable scope)
    {
        return fun.call(cx, scope, thisObj, args);
    }