text:
dir=${0%/*}
if [ -d "$dir" ]; then
  cd "$dir"
fi

# set up your app name, version number, and background image file name
APP_NAME="OpenSkyStacker"
VERSION="0.3.0"
DMG_BACKGROUND_PATH="../images"
DMG_BACKGROUND_IMG="dng-background.png"
APP_PATH="../../bin"

# you should not need to change these
APP_EXE="${APP_NAME}.app/Contents/MacOS/${APP_NAME}"

VOL_NAME="${APP_NAME} ${VERSION}"   # volume name will be "SuperCoolApp 1.0.0"
DMG_TMP="${VOL_NAME}-temp.dmg"
DMG_FINAL="${APP_NAME}-${VERSION}-macos.dmg"         # final DMG name will be "SuperCoolApp 1.0.0.dmg"
STAGING_DIR="./Install"             # we copy all our stuff into this dir

# Check the background image DPI and convert it if it isn't 72x72
_BACKGROUND_IMAGE_DPI_H=`sips -g dpiHeight ${DMG_BACKGROUND_PATH}/${DMG_BACKGROUND_IMG} | grep -Eo '[0-9]+\.[0-9]+'`
_BACKGROUND_IMAGE_DPI_W=`sips -g dpiWidth ${DMG_BACKGROUND_PATH}/${DMG_BACKGROUND_IMG} | grep -Eo '[0-9]+\.[0-9]+'`

if [ $(echo " $_BACKGROUND_IMAGE_DPI_H != 72.0 " | bc) -eq 1 -o $(echo " $_BACKGROUND_IMAGE_DPI_W != 72.0 " | bc) -eq 1 ]; then
   echo "WARNING: The background image's DPI is not 72.  This will result in distorted backgrounds on Mac OS X 10.7+."
   echo "         I will convert it to 72 DPI for you."

   _DMG_BACKGROUND_TMP="${DMG_BACKGROUND_IMG%.*}"_dpifix."${DMG_BACKGROUND_IMG##*.}"

   sips -s dpiWidth 72 -s dpiHeight 72 ${DMG_BACKGROUND_PATH}/${DMG_BACKGROUND_IMG} --out ${DMG_BACKGROUND_PATH}/${_DMG_BACKGROUND_TMP}

   DMG_BACKGROUND_IMG="${_DMG_BACKGROUND_TMP}"
fi

# clear out any old data
rm -rf "${STAGING_DIR}" "${DMG_TMP}" "${DMG_FINAL}"

# copy over the stuff we want in the final disk image to our staging dir
mkdir -p "${STAGING_DIR}"
cp -rpf "${APP_PATH}/${APP_NAME}.app" "${STAGING_DIR}"
# ... cp anything else you want in the DMG - documentation, etc.

pushd "${STAGING_DIR}"

# strip the executable
# echo "Stripping ${APP_EXE}..."
# strip -u -r "${APP_EXE}"

# compress the executable if we have upx in PATH
#  UPX: http://upx.sourceforge.net/
if hash upx 2>/dev/null; then
   echo "Compressing (UPX) ${APP_EXE}..."
   upx -9 "${APP_EXE}"
fi

# ... perform any other stripping/compressing of libs and executables

popd

# figure out how big our DMG needs to be
#  assumes our contents are at least 1M!
SIZE=`du -sh "${STAGING_DIR}" | sed 's/\([0-9\.]*\)M\(.*\)/\1/'`
SIZE=`echo "${SIZE} + 1.0" | bc | awk '{print int($1+0.5)}'`

if [ $? -ne 0 ]; then
   echo "Error: Cannot compute size of staging dir"
   exit
fi

# create the temp DMG file
hdiutil create -srcfolder "${STAGING_DIR}" -volname "${VOL_NAME}" -fs HFS+ \
      -fsargs "-c c=64,a=16,e=16" -format UDRW -size ${SIZE}M "${DMG_TMP}"

echo "Created DMG: ${DMG_TMP}"

# mount it and save the device
DEVICE=$(hdiutil attach -readwrite -noverify "${DMG_TMP}" | \
         egrep '^/dev/' | sed 1q | awk '{print $1}')

sleep 2

# add a link to the Applications dir
echo "Add link to /Applications"
pushd /Volumes/"${VOL_NAME}"
ln -s /Applications
popd

# add a background image
mkdir /Volumes/"${VOL_NAME}"/.background
cp "${DMG_BACKGROUND_PATH}/${DMG_BACKGROUND_IMG}" /Volumes/"${VOL_NAME}"/.background/${DMG_BACKGROUND_IMG}

# tell the Finder to resize the window, set the background,
#  change the icon size, place the icons in the right position, etc.
echo '
   tell application "Finder"
     tell disk "'${VOL_NAME}'"
           open
           set current view of container window to icon view
           set toolbar visible of container window to false
           set statusbar visible of container window to false
           set the bounds of container window to {400, 100, 1200, 700}
           set viewOptions to the icon view options of container window
           set arrangement of viewOptions to not arranged
           set icon size of viewOptions to 72
           set background picture of viewOptions to file ".background:'${DMG_BACKGROUND_IMG}'"
           set position of item "'${APP_NAME}'.app" of container window to {250, 295}
           set position of item "Applications" of container window to {520, 295}
           close
           open
           update without registering applications
           delay 2
     end tell
   end tell
' | osascript

sync

# unmount it
hdiutil detach "${DEVICE}"

# now make the final image a compressed disk image
echo "Creating compressed image"
hdiutil convert "${DMG_TMP}" -format UDZO -imagekey zlib-level=9 -o "${DMG_FINAL}"

# clean up
rm -rf "${DMG_TMP}"
rm -rf "${STAGING_DIR}"

echo 'Done.'

exit


text:
{% extends "base.html" %}
{% block title %}Bookit{% endblock %}
{% block banner %}
Welcome to Bookit.
{% endblock %}
{% block main %}

Book a slot on available equipment:

			{% for equipment in equipment_list %}

{{ equipment.name }}

			{% endfor %}

Submit a repair ticket:

			{% for equipment in equipment_list %}

{{ equipment.name }}

			{% endfor %}

View equipment details and status:

			{% for equipment in equipment_list %}

{{ equipment.name }}

			{% endfor %}

Equipment status:

			{% for equipment in equipment_list %}

{{ equipment.name }} -
				{% if equipment.status  %} ✅
					{% if equipment.status and equipment.next_booking %}Next booking: {{ equipment.next_booking.start_timestring }}
					{% else %}No bookings reserved.
					{% endif %}
				{% else %}❗ offline
				{% endif %}

			{% endfor %}

Recent messages: {% for msg in message_objs %}

				{{ msg.msg |linebreaksbr |truncatechars:175 }} {% comment %} {% if msg.msg|length >= 175 %}
				[+] {% endif %} {% endcomment %}
				Posted by: {{ msg.user}} on {{ msg.created }}

			{% endfor %}

View more...

By booking the associated equipment, you are
        responsible for practicing reasonable care and respect for the instruments.
        Remember, instruments are very expnsive, incredibly time consuming to maintain, and can easily need to be placed offline for repairs for extended duration--months. Do your best to ensure that these instruments remain online and in top condition for everyone in the group. You further acknowledge that disregard for the following guidelines and practices may impact future instrument privileges.

		{% for info_bit in information_list %}

{{ info_bit.header }}

{{ info_bit.body }}

		{% endfor %}

{% endblock %}

redpajama_set_name: RedPajamaGithub


text:
int main(int argc, char *argv[]) {
    // OPTIONS

    std::string filenameExactResults;
    std::string filenameApproximateResults;
    std::string filenameQueryMatrix;
    std::string filenameProbeMatrix;
    bool querySideLeft;
    int numElements, k;
    int r, m, n;

    boost::program_options::options_description desc("Options");
    desc.add_options()
            ("help", "produce help message")
            ("exact", boost::program_options::value<string>(&filenameExactResults), "file containing the exact results")
            ("approximate", boost::program_options::value<string>(&filenameApproximateResults), "file containing the approximate results")
            ("Q^T", boost::program_options::value<string>(&filenameQueryMatrix), "file containing the query matrix (left side)")
            ("P", boost::program_options::value<string>(&filenameProbeMatrix), "file containing the probe matrix (right side)")
            ("querySideLeft", boost::program_options::value<bool>(&querySideLeft)->default_value(true), "1 if Q^T contains the queries (default). Interesting for Row-Top-k")
            ("k", boost::program_options::value<int>(&k), "top k")
            ("r", boost::program_options::value<int>(&r)->default_value(0), "num of coordinates in each vector (needed when reading from csv files)")
            ("m", boost::program_options::value<int>(&m)->default_value(0), "num of vectors in Q^T (needed when reading from csv files)")
            ("n", boost::program_options::value<int>(&n)->default_value(0), "num of vectors in P (needed when reading from csv files)")
            ;

    boost::program_options::positional_options_description pdesc;
    pdesc.add("exact", 1);
    pdesc.add("approximate", 2);
    pdesc.add("Q^T", 3);
    pdesc.add("P", 4);
    pdesc.add("k", 5);

    boost::program_options::variables_map vm;
    boost::program_options::store(boost::program_options::command_line_parser(argc, argv).options(desc).positional(pdesc).run(), vm);
    boost::program_options::notify(vm);

    if (vm.count("help") || vm.count("exact") == 0 || vm.count("approximate") == 0 || vm.count("Q^T") == 0 || vm.count("P") == 0 || vm.count("k") == 0) {
        std::cout << "run compare [options] <exact> <approximate> <Q^T> <P> <k>" << std::endl << std::endl;
        std::cout << desc << std::endl;
        return 1;
    }

    // COMPARING

    // reading matrices
    std::cout << "reading query matrix and probe matrix" << std::endl;
    mips::VectorMatrix queryMatrix, probeMatrix;
    if (querySideLeft) {
        queryMatrix.readFromFile(filenameQueryMatrix, r, m, true);
        probeMatrix.readFromFile(filenameProbeMatrix, r, n, false);
    } else {
        queryMatrix.readFromFile(filenameProbeMatrix, r, n, false);
        probeMatrix.readFromFile(filenameQueryMatrix, r, m, true);
    }
    numElements = queryMatrix.rowNum;

    std::ifstream fileExact(filenameExactResults.c_str(), std::ios_base::in);
    std::vector< std::vector <std::pair<int, double> > > resultsExact(numElements);
    std::ifstream fileApproximate(filenameApproximateResults.c_str(), std::ios_base::in);
    std::vector< std::vector <std::pair<int, double> > > resultsApproximate(numElements);

    if (fileExact && fileApproximate) {
        // reading exact
	std::cout << "reading " << filenameExactResults << " (exact results)" << std::endl;
        if(fileExact.good()) {
            for(int i = 0; i < numElements * k; i++) {
                int query;
                fileExact >> query;

                int id;
                fileExact >> id;

                // not used but need to read the value
                double value;
                fileExact >> value;

                double ip =  probeMatrix.innerProduct(id, queryMatrix.getMatrixRowPtr(query));

                resultsExact[query].push_back(std::make_pair(id, ip));
            }
        }

        // sorting exact
        std::cout << "sorting exact results (descending)" << std::endl;
        for(int i = 0; i < numElements; i++) {
            // descending
            std::sort(resultsExact[i].begin(), resultsExact[i].end(), [](const std::pair<int, double> &left, const std::pair<int, double> &right) {return left.second > right.second;});
        }

        // reading approximate
        std::cout << "reading " << filenameApproximateResults << " (approximate results)" << std::endl;
        if(fileApproximate.good()) {
            for(int i = 0; i < numElements * k; i++) {
                int query;
                fileApproximate >> query;

                int id;
                fileApproximate >> id;

                // not used but need to read the value
                double value;
                fileApproximate >> value;

                double ip =  probeMatrix.innerProduct(id, queryMatrix.getMatrixRowPtr(query));

                resultsApproximate[query].push_back(std::make_pair(id, ip));
            }
        }

        // sorting approximate
        std::cout << "sorting approximate results (descending)" << std::endl;
        for(int i = 0; i < numElements; i++) {
            // descending
            std::sort(resultsApproximate[i].begin(), resultsApproximate[i].end(), [](const std::pair<int, double> &left, const std::pair<int, double> &right) {return left.second > right.second;});
        }

        // calculate recall
        std::cout << "calculating recall" << std::endl;
	int same = 0;
        for(int i = 0; i < numElements; i++) {
            for(int j = 0; j < k; j++) {
                for(int n = 0; n < k; n++) {
                    if(resultsExact[i][j].first == resultsApproximate[i][n].first) {
                        same++;
			break;
                    }
		}
            }
	}
        double recall = static_cast<double>(same)/(numElements * k);

        // calculate rmse
        std::cout << "calculating rmse" << std::endl;
        double rmse = 0;
        double absoluteMax = 0;
        for(int i = 0; i < numElements; i++) {
            double sum = 0;
            for(int j = 0; j < k; j++) {
                double absoluteError = abs(resultsExact[i][j].second - resultsApproximate[i][j].second);

                if(absoluteError > absoluteMax) {
                    absoluteMax = absoluteError;
                }

                sum += absoluteError * absoluteError;
            }
            rmse += sqrt(sum/k);
        }
        double rmseAverage = rmse/numElements;

        // calculate are
        std::cout << "calculating are" << std::endl;
        double are = 0;
        double relativeMax = 0;
        for(int i = 0; i < numElements; i++) {
            double sum = 0;
            for(int j = 0; j < k; j++) {
                double relativeError = abs((resultsExact[i][j].second - resultsApproximate[i][j].second)/resultsExact[i][j].second);

                if(relativeError > relativeMax) {
                    relativeMax = relativeError;
                }

                sum += relativeError;
            }
            are += sum/k;
        }
        double areAverage = are/numElements;

        // print results
	std::cout << std::endl << same << " out of " << (numElements * k) << " results are the same" << std::endl;
        std::cout << "recall = " << recall << std::endl;
        std::cout << "rmse (average) = " << rmseAverage << std::endl;
        std::cout << "absolute error (maximum) = " << absoluteMax << std::endl;
        std::cout << "are (average) = " << areAverage << std::endl;
        std::cout << "relative error (maximum) = " << relativeMax << std::endl;
    }

}


text:
package com.purejadeite.jadegreen.option.table;

import static com.purejadeite.util.collection.RoughlyMapUtils.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import com.purejadeite.jadegreen.content.ContentInterface;
import com.purejadeite.jadegreen.definition.DefinitionInterface;
import com.purejadeite.util.SimpleValidator;

/**
 * 行のChainコンバーター
 * chainIdの値と他の行のkeyIdの値が等しい場合、
 * chainIdの値を他の行そのものと置き換えます
 *
 * @author mitsuhiroseino
 *
 */
public class Chain extends AbstractTableOption {

	protected static final String CFG_KEY_ID = "keyId";

	protected static final String CFG_CHAIN_ID = "chainId";

	/**
	 * 必須項目名称
	 */
	private static final String[] CONFIG = { CFG_KEY_ID, CFG_CHAIN_ID };

	/**
	 * キー項目の定義ID
	 */
	protected String keyId;

	/**
	 * 接続先項目の定義ID
	 */
	protected String chainId;

	/**
	 * コンストラクタ
	 *
	 * @param config
	 *            コンバーターのコンフィグ
	 */
	public Chain(DefinitionInterface<?> definition, Map<String, Object> config) {
		super(definition);
		SimpleValidator.containsKey(config, CONFIG);
		this.keyId = getString(config, CFG_KEY_ID);
		this.chainId = getString(config, CFG_CHAIN_ID);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	protected Object applyImpl(List<Map<String, Object>> values, ContentInterface<?, ?> content) {
		// まだchainされていないlineを保持するMap
		// キーになるIDでレコードの取得ができるMapを作る
		Map<Object, Map<String, Object>> keyMap = new HashMap<>();
		for (Map<String, Object> line: values) {
			keyMap.put(line.get(keyId), line);
		}

		Map<Object, Map<String, Object>> newValues = new LinkedHashMap<>();
		for (int i = 0; i < values.size(); i++) {
			Map<String, Object> line0 = values.get(i);
			Object keyValue = line0.get(keyId);
			if (keyMap.containsKey(keyValue)) {
				// まだどこかにリンクされて無いものはルートに追加
				newValues.put(keyValue, line0);
			} else {
				// すでにどこかにリンクされているものはルートから外す
				if (newValues.containsKey(keyValue)) {
					newValues.remove(keyValue);
				}
			}

			// つなぎ先を取得
			List<String> chainValues = getList(line0, chainId);
			if (chainValues == null) {
				Object chainValue = line0.get(chainId);
				if (chainValue == null) {
					continue;
				} else {
					// つなぎ先が一つの場合
					Map<String, Object> line1 = keyMap.get(chainValue);
					if (line1 != null && !line0.equals(line1)) {
						// keyMapにあるならば置き換え
						line0.put(chainId, line1);
						keyMap.remove(line1.get(keyId));
					}
				}
			} else {
				// つなぎ先が複数ある場合
				List<Object> newLinkValues = new ArrayList<>();
				for (int j = 0; j < chainValues.size(); j++) {
					Object chainValue = chainValues.get(j);
					if (chainValue != null) {
						// つなぎ先が一つの場合
						Map<String, Object> line1 = keyMap.get(chainValue);
						if (line1 != null && !line0.equals(line1)) {
							// keyMapにあるならば置き換え
							newLinkValues.add(line1);
							keyMap.remove(line1.get(keyId));
							continue;
						}
					}
					newLinkValues.add(chainValues.get(j));
				}
				line0.put(chainId, newLinkValues);
			}
		}
		return new ArrayList<>(newValues.values());
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public Map<String, Object> toMap() {
		Map<String, Object> map = super.toMap();
		map.put("keyId", keyId);
		map.put("chainId", chainId);
		return map;
	}
}


text:
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <link rel="stylesheet" href="/static/css/default.css" />
  <link rel="stylesheet" href="/static/css/print.css" media="print" />
  {% if state.command_url not in ("/auth/login/", "/auth/logout/") %}
  <link rel="stylesheet" href="/jsapi/as.css?ts={{ config.version }}-{{ config.timestamp }}" />
  {% endif %}

  <!-- Apple Icons -->
  <link rel="apple-touch-icon" sizes="57x57" href="/static/img/apple-touch-icon.png" />
  <link rel="apple-touch-icon" sizes="72x72" href="/static/img/apple-touch-icon-72x72.png" />
  <link rel="apple-touch-icon" sizes="114x114" href="/static/img/apple-touch-icon-114x114.png" />

  <!-- Favicon -->
  <link rel="shortcut icon" id="basic-favicon" href="/static/img/favicon.png" />
  <link rel="icon" id="basic-favicon" type="image/png" href="/static/img/favicon.png" />

  <!-- JS Global Libraries -->
  <script src="/static/js/jquery.min.js"></script>
  <script src="/static/js/libraries.min.js"></script>
  {% if state.command_url not in ("/auth/login/", "/auth/logout/", "/setup/welcome/") %}
  <script src="/api/0/jsapi/as.js?ts={{ config.version }}-{{ config.timestamp }}"></script>
  {% if state.command_url in ("/message/draft/", "/message/") %}
  <script src="/static/js/plupload.full.min.js"></script>
  {% endif %}

  <!-- JS - App Specific -->
  {% if state.command_url not in ("/setup/crypto/") %}
  <script>
  {% if result.data and result.data.addresses %}
    {% set addresses_json = result.data.addresses|json %}
  {% endif %}
  {% if result.data and result.data.messages %}
    {% set messages_json = result.data.messages|json %}
  {% endif %}
  {% if result.data and result.data.metadata %}
    {% set metadata_json = result.data.metadata|json %}
  {% endif %}
  {% set tags_json = mailpile("tags", "display=*", "mode=flat").result.tags|json %}
  $(document).ready(function() {

    // Print JSON for JS Use
    Mailpile.instance = {
     "command": "{{ command }}",
     "state": {{state|json|safe}},
     "args": "{{ args }}",
     "addresses": {% if result.data and result.data.addresses %}{{ addresses_json|safe }}{% else %}{}{% endif %},
     "messages": {% if result.data and result.data.messages %}{{ messages_json|safe }}{% else %}{}{% endif %},
     "metadata": {% if result.data and result.data.metadata %}{{ metadata_json|safe }}{% else %}{}{% endif %},
     "search_tag_ids": {% if result.search_tag_ids %}{{result.search_tag_ids|safe }}{% else %}[]{% endif %},
     "search_addresses": [],
     "tags": {{ tags_json|safe }}
    };

    // Nagifications
    {% if show_nagification(config.web.nag_backup_key) %}
    Mailpile.notification({
      status: 'warning',
      message: '{{_("Back up your encryption key & passphrase")}}',
      type: 'nagify',
      action: '/settings/backup-keys.html'
    });
    {% endif %}

    // HTML5 Browser Notifications
    if (Notification.permission == "granted") {
      $('#notifications-permission-option').text("{{_("Browser notifications allowed")}}")
    }

    $('#notifications-permission-option').click(function() {
      Notification.requestPermission();
    });

  });

  /* Plugins */
  $(document).ready(
    {{ui_elements_setup('.plugin-activity-%(name)s', get_ui_elements('activities', state, '/'))}}
  );
  </script>
  <script src="/api/0/jsapi/app.js?ts={{ config.version }}-{{ config.timestamp }}"></script>
  {% endif %}
  {% endif %}


text:
import iso8601
import mock

from nova import servicegroup
from nova import test
from oslo_utils import timeutils

class MemcachedServiceGroupTestCase(test.NoDBTestCase):

    @mock.patch('nova.cache_utils.get_memcached_client')
    def setUp(self, mgc_mock):
        super(MemcachedServiceGroupTestCase, self).setUp()
        self.mc_client = mock.MagicMock()
        mgc_mock.return_value = self.mc_client
        self.flags(servicegroup_driver='mc')
        self.servicegroup_api = servicegroup.API()

    def test_is_up(self):
        service_ref = {
            'host': 'fake-host',
            'topic': 'compute'
        }
        self.mc_client.get.return_value = None

        self.assertFalse(self.servicegroup_api.service_is_up(service_ref))
        self.mc_client.get.assert_called_once_with('compute:fake-host')
        self.mc_client.reset_mock()
        self.mc_client.get.return_value = True
        self.assertTrue(self.servicegroup_api.service_is_up(service_ref))
        self.mc_client.get.assert_called_once_with('compute:fake-host')

    def test_join(self):
        service = mock.MagicMock(report_interval=1)

        self.servicegroup_api.join('fake-host', 'fake-topic', service)
        fn = self.servicegroup_api._driver._report_state
        service.tg.add_timer.assert_called_once_with(1, fn, 5, service)

    def test_report_state(self):
        service_ref = {
            'host': 'fake-host',
            'topic': 'compute'
        }
        service = mock.MagicMock(model_disconnected=False,
                                 service_ref=service_ref)
        fn = self.servicegroup_api._driver._report_state
        fn(service)
        self.mc_client.set.assert_called_once_with('compute:fake-host',
                                                   mock.ANY)

    def test_get_updated_time(self):
        updated_at_time = timeutils.parse_strtime("2016-04-18T02:56:25.198871")
        service_ref = {
            'host': 'fake-host',
            'topic': 'compute',
            'updated_at': updated_at_time.replace(tzinfo=iso8601.UTC)
        }

        # If no record returned from the mc, return record from DB
        self.mc_client.get.return_value = None
        self.assertEqual(service_ref['updated_at'],
                         self.servicegroup_api.get_updated_time(service_ref))
        self.mc_client.get.assert_called_once_with('compute:fake-host')
        # If the record in mc is newer than DB, return record from mc
        self.mc_client.reset_mock()
        retval = timeutils.utcnow()
        self.mc_client.get.return_value = retval
        self.assertEqual(retval.replace(tzinfo=iso8601.UTC),
                         self.servicegroup_api.get_updated_time(service_ref))
        self.mc_client.get.assert_called_once_with('compute:fake-host')
        # If the record in DB is newer than mc, return record from DB
        self.mc_client.reset_mock()
        service_ref['updated_at'] = \
            retval.replace(tzinfo=iso8601.UTC)
        self.mc_client.get.return_value = updated_at_time
        self.assertEqual(service_ref['updated_at'],
                         self.servicegroup_api.get_updated_time(service_ref))
        self.mc_client.get.assert_called_once_with('compute:fake-host')
        # If no record returned from the DB, return the record from mc
        self.mc_client.reset_mock()
        service_ref['updated_at'] = None
        self.mc_client.get.return_value = updated_at_time
        self.assertEqual(updated_at_time.replace(tzinfo=iso8601.UTC),
                         self.servicegroup_api.get_updated_time(service_ref))
        self.mc_client.get.assert_called_once_with('compute:fake-host')


text:
namespace peloton {
namespace planner {
class AbstractPlan;
}

namespace parser {
class AbstractParse;
class SQLStatementList;
}

namespace optimizer {

//===--------------------------------------------------------------------===//
// Abstract Optimizer
//===--------------------------------------------------------------------===//
class AbstractOptimizer {
 public:
  AbstractOptimizer(const AbstractOptimizer &) = delete;
  AbstractOptimizer &operator=(const AbstractOptimizer &) = delete;
  AbstractOptimizer(AbstractOptimizer &&) = delete;
  AbstractOptimizer &operator=(AbstractOptimizer &&) = delete;

  AbstractOptimizer();
  virtual ~AbstractOptimizer();

  virtual std::shared_ptr<planner::AbstractPlan> BuildPelotonPlanTree(
      const std::unique_ptr<parser::SQLStatementList> &parse_tree) = 0;

  virtual void Reset(){};
};

}  // namespace optimizer
}  // namespace peloton


text:
package engine.ranker;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

import com.sleepycat.persist.EntityCursor;

import engine.persistence.Link;
import engine.persistence.LinksDB;

public class PageRank {
	/*
	 * Regarding the number of iterations:
	 * "We see that we get a good approximation of the real PageRank values after
	 * only a few iterations. According to publications of Lawrence Page
	 * and Sergey Brin, about 100 iterations are necessary to get a good approximation
	 * of the PageRank values of the whole web"
	 * Cited from http://pr.efactory.de/e-pagerank-algorithm.shtml
	 */
	public final static int NUMBER_ITERATIONS = 100;
	public final static double DAMPING_FACTOR = 0.85;

	/*
	 * This method computes PageRank for each website stored in the database.
	 * The ranks are stored in a separated index
	 */
	public static void computePageRank(){

		//Get an iterator from the index of links
		LinksDB linksDB = LinksDB.getInstance();

		double totalIngoingLinks = 0;
		double factor = (1-DAMPING_FACTOR);
		for(int iteration=0; iteration<NUMBER_ITERATIONS; iteration++){
			//for each website
			EntityCursor<Link> links = linksDB.getCursorLinks();
			for(Link link = links.first(); link!=null; link=links.next()){

				totalIngoingLinks = 0;
				//for each outgoing link from current link. Sum all of them
				ArrayList<String> ingoingLinks=link.getIngoingLinks();
				for(int i=0; i<ingoingLinks.size(); i++){
					Link l = linksDB.getLink(ingoingLinks.get(i));
					totalIngoingLinks+= l.getCurrentPageRank()/l.getNumberOutgoingLinks();
					//System.out.println("ingoinglink "+link.getURL()+"<---"+ingoingLinks.get(i)+ "  "+totalIngoingLinks);
				}
				//final pagerank for the link
				double pageRank = factor + DAMPING_FACTOR*totalIngoingLinks;
				//System.out.println("PageRank for "+link.getURL()+" "+pageRank);
				link.setCurrentPageRank(pageRank);
				linksDB.putLink(link);
				//linksDB.syncStore();
			}
			System.out.println("Iteration "+iteration+" done...");
		}

		//Reflect changes in database
		linksDB.syncStore();

	}

	public static void printHighestPageRanks(int top) {
		// TODO Auto-generated method stub
		LinksDB linksDB = LinksDB.getInstance();
		EntityCursor<Link> links = linksDB.getCursorLinks();
		ArrayList<Link> arrayList = new ArrayList<Link>();
		for(Link link = links.first(); link!=null; link=links.next()){
			arrayList.add(link);
		}

		Collections.sort(arrayList, new Comparator<Link>(){
			public int compare(Link l1, Link l2){
				return l1.compareTo(l2);
			}
		});

		System.out.println("Pagerank websites Top "+top);
		for(int i=arrayList.size()-1; i>=arrayList.size()-top; i--){
			System.out.println((i+1)+") "+arrayList.get(i).getURL()+":  "+arrayList.get(i).getCurrentPageRank());
		}
	}

	/*
	 * Method to reset all pageranks to 1 (default value)
	 */
	public static void resetPageRanks() {
		// TODO Auto-generated method stub
		LinksDB linksDB = LinksDB.getInstance();
		EntityCursor<Link> links = linksDB.getCursorLinks();
		for(Link link = links.first(); link!=null; link=links.next()){
			link.setCurrentPageRank(1);
		}
	}

}


text:
#ifndef ISL_MAP_H
#define ISL_MAP_H

#include <stdio.h>

#include <isl/ctx.h>
#include <isl/space_type.h>
#include <isl/vec.h>
#include <isl/mat.h>
#include <isl/printer.h>
#include <isl/local_space.h>
#include <isl/aff_type.h>
#include <isl/list.h>
#include <isl/map_type.h>
#include <isl/val_type.h>
#include <isl/stdint.h>
#include <isl/stride_info.h>
#include <isl/fixed_box.h>

#if defined(__cplusplus)
extern "C" {
#endif

isl_size isl_basic_map_total_dim(__isl_keep const isl_basic_map *bmap);
isl_size isl_basic_map_dim(__isl_keep isl_basic_map *bmap,
				enum isl_dim_type type);

isl_size isl_map_dim(__isl_keep isl_map *map, enum isl_dim_type type);

isl_ctx *isl_basic_map_get_ctx(__isl_keep isl_basic_map *bmap);
isl_ctx *isl_map_get_ctx(__isl_keep isl_map *map);
__isl_give isl_space *isl_basic_map_get_space(__isl_keep isl_basic_map *bmap);
__isl_export
__isl_give isl_space *isl_map_get_space(__isl_keep isl_map *map);

__isl_give isl_aff *isl_basic_map_get_div(__isl_keep isl_basic_map *bmap,
	int pos);

__isl_give isl_local_space *isl_basic_map_get_local_space(
	__isl_keep isl_basic_map *bmap);

__isl_give isl_basic_map *isl_basic_map_set_tuple_name(
	__isl_take isl_basic_map *bmap, enum isl_dim_type type, const char *s);
const char *isl_basic_map_get_tuple_name(__isl_keep isl_basic_map *bmap,
	enum isl_dim_type type);
isl_bool isl_map_has_tuple_name(__isl_keep isl_map *map,
	enum isl_dim_type type);
const char *isl_map_get_tuple_name(__isl_keep isl_map *map,
	enum isl_dim_type type);
__isl_give isl_map *isl_map_set_tuple_name(__isl_take isl_map *map,
	enum isl_dim_type type, const char *s);
const char *isl_basic_map_get_dim_name(__isl_keep isl_basic_map *bmap,
	enum isl_dim_type type, unsigned pos);
isl_bool isl_map_has_dim_name(__isl_keep isl_map *map,
	enum isl_dim_type type, unsigned pos);
const char *isl_map_get_dim_name(__isl_keep isl_map *map,
	enum isl_dim_type type, unsigned pos);
__isl_give isl_basic_map *isl_basic_map_set_dim_name(
	__isl_take isl_basic_map *bmap,
	enum isl_dim_type type, unsigned pos, const char *s);
__isl_give isl_map *isl_map_set_dim_name(__isl_take isl_map *map,
	enum isl_dim_type type, unsigned pos, const char *s);

__isl_give isl_basic_map *isl_basic_map_set_tuple_id(
	__isl_take isl_basic_map *bmap,
	enum isl_dim_type type, __isl_take isl_id *id);
__isl_give isl_map *isl_map_set_dim_id(__isl_take isl_map *map,
	enum isl_dim_type type, unsigned pos, __isl_take isl_id *id);
isl_bool isl_basic_map_has_dim_id(__isl_keep isl_basic_map *bmap,
	enum isl_dim_type type, unsigned pos);
isl_bool isl_map_has_dim_id(__isl_keep isl_map *map,
	enum isl_dim_type type, unsigned pos);
__isl_give isl_id *isl_map_get_dim_id(__isl_keep isl_map *map,
	enum isl_dim_type type, unsigned pos);
__isl_give isl_map *isl_map_set_tuple_id(__isl_take isl_map *map,
	enum isl_dim_type type, __isl_take isl_id *id);
__isl_give isl_map *isl_map_reset_tuple_id(__isl_take isl_map *map,
	enum isl_dim_type type);
isl_bool isl_map_has_tuple_id(__isl_keep isl_map *map, enum isl_dim_type type);
__isl_give isl_id *isl_map_get_tuple_id(__isl_keep isl_map *map,
	enum isl_dim_type type);
__isl_give isl_map *isl_map_reset_user(__isl_take isl_map *map);

int isl_basic_map_find_dim_by_name(__isl_keep isl_basic_map *bmap,
	enum isl_dim_type type, const char *name);
int isl_map_find_dim_by_id(__isl_keep isl_map *map, enum isl_dim_type type,
	__isl_keep isl_id *id);
int isl_map_find_dim_by_name(__isl_keep isl_map *map, enum isl_dim_type type,
	const char *name);

isl_bool isl_basic_map_is_rational(__isl_keep isl_basic_map *bmap);

__isl_give isl_basic_map *isl_basic_map_identity(__isl_take isl_space *space);
__isl_null isl_basic_map *isl_basic_map_free(__isl_take isl_basic_map *bmap);
__isl_give isl_basic_map *isl_basic_map_copy(__isl_keep isl_basic_map *bmap);
__isl_give isl_basic_map *isl_basic_map_equal(
	__isl_take isl_space *space, unsigned n_equal);
__isl_give isl_basic_map *isl_basic_map_less_at(__isl_take isl_space *space,
	unsigned pos);
__isl_give isl_basic_map *isl_basic_map_more_at(__isl_take isl_space *space,
	unsigned pos);
__isl_give isl_basic_map *isl_basic_map_empty(__isl_take isl_space *space);
__isl_give isl_basic_map *isl_basic_map_universe(__isl_take isl_space *space);
__isl_give isl_basic_map *isl_basic_map_nat_universe(
	__isl_take isl_space *space);
__isl_give isl_basic_map *isl_basic_map_remove_redundancies(
	__isl_take isl_basic_map *bmap);
__isl_give isl_map *isl_map_remove_redundancies(__isl_take isl_map *map);
__isl_give isl_basic_map *isl_map_simple_hull(__isl_take isl_map *map);
__isl_export
__isl_give isl_basic_map *isl_map_unshifted_simple_hull(
	__isl_take isl_map *map);
__isl_give isl_basic_map *isl_map_plain_unshifted_simple_hull(
	__isl_take isl_map *map);
__isl_give isl_basic_map *isl_map_unshifted_simple_hull_from_map_list(
	__isl_take isl_map *map, __isl_take isl_map_list *list);

__isl_export
__isl_give isl_basic_map *isl_basic_map_intersect_domain(
		__isl_take isl_basic_map *bmap,
		__isl_take isl_basic_set *bset);
__isl_export
__isl_give isl_basic_map *isl_basic_map_intersect_range(
		__isl_take isl_basic_map *bmap,
		__isl_take isl_basic_set *bset);
__isl_export
__isl_give isl_basic_map *isl_basic_map_intersect(
		__isl_take isl_basic_map *bmap1,
		__isl_take isl_basic_map *bmap2);
__isl_give isl_basic_map *isl_basic_map_list_intersect(
	__isl_take isl_basic_map_list *list);
__isl_export
__isl_give isl_map *isl_basic_map_union(
		__isl_take isl_basic_map *bmap1,
		__isl_take isl_basic_map *bmap2);
__isl_export
__isl_give isl_basic_map *isl_basic_map_apply_domain(
		__isl_take isl_basic_map *bmap1,
		__isl_take isl_basic_map *bmap2);
__isl_export
__isl_give isl_basic_map *isl_basic_map_apply_range(
		__isl_take isl_basic_map *bmap1,
		__isl_take isl_basic_map *bmap2);
__isl_export
__isl_give isl_basic_map *isl_basic_map_affine_hull(
		__isl_take isl_basic_map *bmap);
__isl_give isl_basic_map *isl_basic_map_preimage_domain_multi_aff(
	__isl_take isl_basic_map *bmap, __isl_take isl_multi_aff *ma);
__isl_give isl_basic_map *isl_basic_map_preimage_range_multi_aff(
	__isl_take isl_basic_map *bmap, __isl_take isl_multi_aff *ma);
__isl_export
__isl_give isl_basic_map *isl_basic_map_reverse(__isl_take isl_basic_map *bmap);
__isl_give isl_basic_set *isl_basic_map_domain(__isl_take isl_basic_map *bmap);
__isl_give isl_basic_set *isl_basic_map_range(__isl_take isl_basic_map *bmap);
__isl_give isl_basic_map *isl_basic_map_domain_map(
	__isl_take isl_basic_map *bmap);
__isl_give isl_basic_map *isl_basic_map_range_map(
	__isl_take isl_basic_map *bmap);
__isl_give isl_basic_map *isl_basic_map_remove_dims(
	__isl_take isl_basic_map *bmap,
	enum isl_dim_type type, unsigned first, unsigned n);
__isl_give isl_basic_map *isl_basic_map_eliminate(
	__isl_take isl_basic_map *bmap,
	enum isl_dim_type type, unsigned first, unsigned n);
__isl_export
__isl_give isl_basic_map *isl_basic_map_sample(__isl_take isl_basic_map *bmap);
__isl_export
__isl_give isl_basic_map *isl_basic_map_detect_equalities(
						__isl_take isl_basic_map *bmap);
__isl_give isl_basic_map *isl_basic_map_read_from_file(isl_ctx *ctx,
	FILE *input);
__isl_constructor
__isl_give isl_basic_map *isl_basic_map_read_from_str(isl_ctx *ctx,
	const char *str);
__isl_give isl_map *isl_map_read_from_file(isl_ctx *ctx, FILE *input);
__isl_constructor
__isl_give isl_map *isl_map_read_from_str(isl_ctx *ctx, const char *str);
void isl_basic_map_dump(__isl_keep isl_basic_map *bmap);
void isl_map_dump(__isl_keep isl_map *map);
__isl_give char *isl_basic_map_to_str(__isl_keep isl_basic_map *bmap);
__isl_give isl_printer *isl_printer_print_basic_map(
	__isl_take isl_printer *printer, __isl_keep isl_basic_map *bmap);
__isl_give char *isl_map_to_str(__isl_keep isl_map *map);
__isl_give isl_printer *isl_printer_print_map(__isl_take isl_printer *printer,
	__isl_keep isl_map *map);
__isl_give isl_basic_map *isl_basic_map_fix_si(__isl_take isl_basic_map *bmap,
		enum isl_dim_type type, unsigned pos, int value);
__isl_give isl_basic_map *isl_basic_map_fix_val(__isl_take isl_basic_map *bmap,
	enum isl_dim_type type, unsigned pos, __isl_take isl_val *v);
__isl_give isl_basic_map *isl_basic_map_lower_bound_si(
		__isl_take isl_basic_map *bmap,
		enum isl_dim_type type, unsigned pos, int value);
__isl_give isl_basic_map *isl_basic_map_upper_bound_si(
	__isl_take isl_basic_map *bmap,
	enum isl_dim_type type, unsigned pos, int value);
__isl_overload
__isl_give isl_map *isl_map_lower_bound_multi_val(__isl_take isl_map *map,
	__isl_take isl_multi_val *lower);
__isl_overload
__isl_give isl_map *isl_map_upper_bound_multi_val(__isl_take isl_map *map,
	__isl_take isl_multi_val *upper);
__isl_overload
__isl_give isl_map *isl_map_lower_bound_multi_pw_aff(__isl_take isl_map *map,
	__isl_take isl_multi_pw_aff *lower);
__isl_overload
__isl_give isl_map *isl_map_upper_bound_multi_pw_aff(__isl_take isl_map *map,
	__isl_take isl_multi_pw_aff *upper);

__isl_give isl_basic_map *isl_basic_map_sum(__isl_take isl_basic_map *bmap1,
	__isl_take isl_basic_map *bmap2);
__isl_give isl_basic_map *isl_basic_map_neg(__isl_take isl_basic_map *bmap);

__isl_give isl_map *isl_map_sum(__isl_take isl_map *map1,
	__isl_take isl_map *map2);
__isl_give isl_map *isl_map_neg(__isl_take isl_map *map);
__isl_give isl_map *isl_map_floordiv_val(__isl_take isl_map *map,
	__isl_take isl_val *d);

__isl_export
isl_bool isl_basic_map_is_equal(__isl_keep isl_basic_map *bmap1,
	__isl_keep isl_basic_map *bmap2);
isl_bool isl_basic_map_is_disjoint(__isl_keep isl_basic_map *bmap1,
	__isl_keep isl_basic_map *bmap2);

__isl_give isl_map *isl_basic_map_partial_lexmax(
		__isl_take isl_basic_map *bmap, __isl_take isl_basic_set *dom,
		__isl_give isl_set **empty);
__isl_give isl_map *isl_basic_map_partial_lexmin(
		__isl_take isl_basic_map *bmap, __isl_take isl_basic_set *dom,
		__isl_give isl_set **empty);
__isl_give isl_map *isl_map_partial_lexmax(
		__isl_take isl_map *map, __isl_take isl_set *dom,
		__isl_give isl_set **empty);
__isl_give isl_map *isl_map_partial_lexmin(
		__isl_take isl_map *map, __isl_take isl_set *dom,
		__isl_give isl_set **empty);
__isl_export
__isl_give isl_map *isl_basic_map_lexmin(__isl_take isl_basic_map *bmap);
__isl_export
__isl_give isl_map *isl_basic_map_lexmax(__isl_take isl_basic_map *bmap);
__isl_export
__isl_give isl_map *isl_map_lexmin(__isl_take isl_map *map);
__isl_export
__isl_give isl_map *isl_map_lexmax(__isl_take isl_map *map);
__isl_give isl_pw_multi_aff *isl_basic_map_partial_lexmin_pw_multi_aff(
	__isl_take isl_basic_map *bmap, __isl_take isl_basic_set *dom,
	__isl_give isl_set **empty);
__isl_give isl_pw_multi_aff *isl_basic_map_partial_lexmax_pw_multi_aff(
	__isl_take isl_basic_map *bmap, __isl_take isl_basic_set *dom,
	__isl_give isl_set **empty);
__isl_give isl_pw_multi_aff *isl_basic_map_lexmin_pw_multi_aff(
	__isl_take isl_basic_map *bmap);
__isl_export
__isl_give isl_pw_multi_aff *isl_map_lexmin_pw_multi_aff(
	__isl_take isl_map *map);
__isl_export
__isl_give isl_pw_multi_aff *isl_map_lexmax_pw_multi_aff(
	__isl_take isl_map *map);

void isl_basic_map_print_internal(__isl_keep isl_basic_map *bmap,
	FILE *out, int indent);

__isl_give isl_val *isl_basic_map_plain_get_val_if_fixed(
	__isl_keep isl_basic_map *bmap,
	enum isl_dim_type type, unsigned pos);

isl_bool isl_basic_map_image_is_bounded(__isl_keep isl_basic_map *bmap);
isl_bool isl_basic_map_plain_is_universe(__isl_keep isl_basic_map *bmap);
isl_bool isl_basic_map_is_universe(__isl_keep isl_basic_map *bmap);
isl_bool isl_basic_map_plain_is_empty(__isl_keep isl_basic_map *bmap);
__isl_export
isl_bool isl_basic_map_is_empty(__isl_keep isl_basic_map *bmap);
__isl_export
isl_bool isl_basic_map_is_subset(__isl_keep isl_basic_map *bmap1,
		__isl_keep isl_basic_map *bmap2);
isl_bool isl_basic_map_is_strict_subset(__isl_keep isl_basic_map *bmap1,
		__isl_keep isl_basic_map *bmap2);

__isl_export
__isl_give isl_map *isl_map_universe(__isl_take isl_space *space);
__isl_give isl_map *isl_map_nat_universe(__isl_take isl_space *dim);
__isl_export
__isl_give isl_map *isl_map_empty(__isl_take isl_space *space);
__isl_give isl_map *isl_map_identity(__isl_take isl_space *dim);
__isl_give isl_map *isl_map_lex_lt_first(__isl_take isl_space *dim, unsigned n);
__isl_give isl_map *isl_map_lex_le_first(__isl_take isl_space *dim, unsigned n);
__isl_give isl_map *isl_map_lex_lt(__isl_take isl_space *set_dim);
__isl_give isl_map *isl_map_lex_le(__isl_take isl_space *set_dim);
__isl_give isl_map *isl_map_lex_gt_first(__isl_take isl_space *dim, unsigned n);
__isl_give isl_map *isl_map_lex_ge_first(__isl_take isl_space *dim, unsigned n);
__isl_give isl_map *isl_map_lex_gt(__isl_take isl_space *set_dim);
__isl_give isl_map *isl_map_lex_ge(__isl_take isl_space *set_dim);
__isl_null isl_map *isl_map_free(__isl_take isl_map *map);
__isl_give isl_map *isl_map_copy(__isl_keep isl_map *map);
__isl_export
__isl_give isl_map *isl_map_reverse(__isl_take isl_map *map);
__isl_export
__isl_give isl_map *isl_map_range_reverse(__isl_take isl_map *map);
__isl_export
__isl_give isl_map *isl_map_union(
		__isl_take isl_map *map1,
		__isl_take isl_map *map2);
__isl_give isl_map *isl_map_union_disjoint(
		__isl_take isl_map *map1, __isl_take isl_map *map2);
__isl_export
__isl_give isl_map *isl_map_intersect_domain(
		__isl_take isl_map *map,
		__isl_take isl_set *set);
__isl_export
__isl_give isl_map *isl_map_intersect_range(
		__isl_take isl_map *map,
		__isl_take isl_set *set);
__isl_give isl_map *isl_map_intersect_domain_factor_range(
	__isl_take isl_map *map, __isl_take isl_map *factor);
__isl_give isl_map *isl_map_intersect_range_factor_domain(
	__isl_take isl_map *map, __isl_take isl_map *factor);
__isl_give isl_map *isl_map_intersect_range_factor_range(
	__isl_take isl_map *map, __isl_take isl_map *factor);
__isl_export
__isl_give isl_map *isl_map_apply_domain(
		__isl_take isl_map *map1,
		__isl_take isl_map *map2);
__isl_export
__isl_give isl_map *isl_map_apply_range(
		__isl_take isl_map *map1,
		__isl_take isl_map *map2);
__isl_overload
__isl_give isl_map *isl_map_preimage_domain_multi_aff(__isl_take isl_map *map,
	__isl_take isl_multi_aff *ma);
__isl_overload
__isl_give isl_map *isl_map_preimage_range_multi_aff(__isl_take isl_map *map,
	__isl_take isl_multi_aff *ma);
__isl_overload
__isl_give isl_map *isl_map_preimage_domain_pw_multi_aff(
	__isl_take isl_map *map, __isl_take isl_pw_multi_aff *pma);
__isl_overload
__isl_give isl_map *isl_map_preimage_range_pw_multi_aff(
	__isl_take isl_map *map, __isl_take isl_pw_multi_aff *pma);
__isl_overload
__isl_give isl_map *isl_map_preimage_domain_multi_pw_aff(
	__isl_take isl_map *map, __isl_take isl_multi_pw_aff *mpa);
__isl_give isl_basic_map *isl_basic_map_product(
	__isl_take isl_basic_map *bmap1, __isl_take isl_basic_map *bmap2);
__isl_give isl_map *isl_map_product(__isl_take isl_map *map1,
	__isl_take isl_map *map2);
__isl_give isl_basic_map *isl_basic_map_domain_product(
	__isl_take isl_basic_map *bmap1, __isl_take isl_basic_map *bmap2);
__isl_give isl_basic_map *isl_basic_map_range_product(
	__isl_take isl_basic_map *bmap1, __isl_take isl_basic_map *bmap2);
__isl_export
__isl_give isl_map *isl_map_domain_product(__isl_take isl_map *map1,
	__isl_take isl_map *map2);
__isl_export
__isl_give isl_map *isl_map_range_product(__isl_take isl_map *map1,
	__isl_take isl_map *map2);
__isl_give isl_basic_map *isl_basic_map_flat_product(
	__isl_take isl_basic_map *bmap1, __isl_take isl_basic_map *bmap2);
__isl_give isl_map *isl_map_flat_product(__isl_take isl_map *map1,
	__isl_take isl_map *map2);
__isl_give isl_basic_map *isl_basic_map_flat_range_product(
	__isl_take isl_basic_map *bmap1, __isl_take isl_basic_map *bmap2);
__isl_give isl_map *isl_map_flat_domain_product(__isl_take isl_map *map1,
	__isl_take isl_map *map2);
__isl_give isl_map *isl_map_flat_range_product(__isl_take isl_map *map1,
	__isl_take isl_map *map2);
isl_bool isl_map_domain_is_wrapping(__isl_keep isl_map *map);
isl_bool isl_map_range_is_wrapping(__isl_keep isl_map *map);
isl_bool isl_map_is_product(__isl_keep isl_map *map);
__isl_export
__isl_give isl_map *isl_map_factor_domain(__isl_take isl_map *map);
__isl_export
__isl_give isl_map *isl_map_factor_range(__isl_take isl_map *map);
__isl_export
__isl_give isl_map *isl_map_domain_factor_domain(__isl_take isl_map *map);
__isl_export
__isl_give isl_map *isl_map_domain_factor_range(__isl_take isl_map *map);
__isl_export
__isl_give isl_map *isl_map_range_factor_domain(__isl_take isl_map *map);
__isl_export
__isl_give isl_map *isl_map_range_factor_range(__isl_take isl_map *map);
__isl_export
__isl_give isl_map *isl_map_intersect(__isl_take isl_map *map1,
				      __isl_take isl_map *map2);
__isl_export
__isl_give isl_map *isl_map_intersect_params(__isl_take isl_map *map,
		__isl_take isl_set *params);
__isl_export
__isl_give isl_map *isl_map_subtract(
		__isl_take isl_map *map1,
		__isl_take isl_map *map2);
__isl_give isl_map *isl_map_subtract_domain(__isl_take isl_map *map,
	__isl_take isl_set *dom);
__isl_give isl_map *isl_map_subtract_range(__isl_take isl_map *map,
	__isl_take isl_set *dom);
__isl_export
__isl_give isl_map *isl_map_complement(__isl_take isl_map *map);
struct isl_map *isl_map_fix_input_si(struct isl_map *map,
		unsigned input, int value);
__isl_give isl_map *isl_map_fix_si(__isl_take isl_map *map,
		enum isl_dim_type type, unsigned pos, int value);
__isl_give isl_map *isl_map_fix_val(__isl_take isl_map *map,
	enum isl_dim_type type, unsigned pos, __isl_take isl_val *v);
__isl_give isl_map *isl_map_lower_bound_si(__isl_take isl_map *map,
		enum isl_dim_type type, unsigned pos, int value);
__isl_give isl_map *isl_map_lower_bound_val(__isl_take isl_map *map,
	enum isl_dim_type type, unsigned pos, __isl_take isl_val *value);
__isl_give isl_map *isl_map_upper_bound_si(__isl_take isl_map *map,
	enum isl_dim_type type, unsigned pos, int value);
__isl_give isl_map *isl_map_upper_bound_val(__isl_take isl_map *map,
	enum isl_dim_type type, unsigned pos, __isl_take isl_val *value);
__isl_export
__isl_give isl_basic_set *isl_basic_map_deltas(__isl_take isl_basic_map *bmap);
__isl_export
__isl_give isl_set *isl_map_deltas(__isl_take isl_map *map);
__isl_give isl_basic_map *isl_basic_map_deltas_map(
	__isl_take isl_basic_map *bmap);
__isl_give isl_map *isl_map_deltas_map(__isl_take isl_map *map);
__isl_export
__isl_give isl_map *isl_map_detect_equalities(__isl_take isl_map *map);
__isl_export
__isl_give isl_basic_map *isl_map_affine_hull(__isl_take isl_map *map);
__isl_give isl_basic_map *isl_map_convex_hull(__isl_take isl_map *map);
__isl_export
__isl_give isl_basic_map *isl_map_polyhedral_hull(__isl_take isl_map *map);
__isl_give isl_basic_map *isl_basic_map_add_dims(__isl_take isl_basic_map *bmap,
		enum isl_dim_type type, unsigned n);
__isl_give isl_map *isl_map_add_dims(__isl_take isl_map *map,
		enum isl_dim_type type, unsigned n);
__isl_give isl_basic_map *isl_basic_map_insert_dims(
	__isl_take isl_basic_map *bmap, enum isl_dim_type type,
	unsigned pos, unsigned n);
__isl_give isl_map *isl_map_insert_dims(__isl_take isl_map *map,
		enum isl_dim_type type, unsigned pos, unsigned n);
__isl_give isl_basic_map *isl_basic_map_move_dims(
	__isl_take isl_basic_map *bmap,
	enum isl_dim_type dst_type, unsigned dst_pos,
	enum isl_dim_type src_type, unsigned src_pos, unsigned n);
__isl_give isl_map *isl_map_move_dims(__isl_take isl_map *map,
	enum isl_dim_type dst_type, unsigned dst_pos,
	enum isl_dim_type src_type, unsigned src_pos, unsigned n);
__isl_give isl_basic_map *isl_basic_map_project_out(
		__isl_take isl_basic_map *bmap,
		enum isl_dim_type type, unsigned first, unsigned n);
__isl_give isl_map *isl_map_project_out(__isl_take isl_map *map,
		enum isl_dim_type type, unsigned first, unsigned n);
__isl_export
__isl_give isl_map *isl_map_project_out_all_params(__isl_take isl_map *map);
__isl_give isl_basic_map *isl_basic_map_remove_divs(
	__isl_take isl_basic_map *bmap);
__isl_give isl_map *isl_map_remove_unknown_divs(__isl_take isl_map *map);
__isl_give isl_map *isl_map_remove_divs(__isl_take isl_map *map);
__isl_give isl_map *isl_map_eliminate(__isl_take isl_map *map,
	enum isl_dim_type type, unsigned first, unsigned n);
__isl_give isl_map *isl_map_remove_dims(__isl_take isl_map *map,
	enum isl_dim_type type, unsigned first, unsigned n);
__isl_give isl_basic_map *isl_basic_map_remove_divs_involving_dims(
	__isl_take isl_basic_map *bmap,
	enum isl_dim_type type, unsigned first, unsigned n);
__isl_give isl_map *isl_map_remove_divs_involving_dims(__isl_take isl_map *map,
	enum isl_dim_type type, unsigned first, unsigned n);
struct isl_map *isl_map_remove_inputs(struct isl_map *map,
	unsigned first, unsigned n);

__isl_give isl_basic_map *isl_basic_map_equate(__isl_take isl_basic_map *bmap,
	enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2);
__isl_give isl_basic_map *isl_basic_map_order_ge(__isl_take isl_basic_map *bmap,
	enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2);
__isl_give isl_map *isl_map_order_ge(__isl_take isl_map *map,
	enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2);
__isl_give isl_map *isl_map_order_le(__isl_take isl_map *map,
	enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2);
__isl_give isl_map *isl_map_equate(__isl_take isl_map *map,
	enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2);
__isl_give isl_map *isl_map_oppose(__isl_take isl_map *map,
	enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2);
__isl_give isl_map *isl_map_order_lt(__isl_take isl_map *map,
	enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2);
__isl_give isl_basic_map *isl_basic_map_order_gt(__isl_take isl_basic_map *bmap,
	enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2);
__isl_give isl_map *isl_map_order_gt(__isl_take isl_map *map,
	enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2);

__isl_export
__isl_give isl_map *isl_set_identity(__isl_take isl_set *set);

__isl_export
isl_bool isl_basic_set_is_wrapping(__isl_keep isl_basic_set *bset);
__isl_export
isl_bool isl_set_is_wrapping(__isl_keep isl_set *set);
__isl_give isl_basic_set *isl_basic_map_wrap(__isl_take isl_basic_map *bmap);
__isl_export
__isl_give isl_set *isl_map_wrap(__isl_take isl_map *map);
__isl_give isl_basic_map *isl_basic_set_unwrap(__isl_take isl_basic_set *bset);
__isl_export
__isl_give isl_map *isl_set_unwrap(__isl_take isl_set *set);
__isl_export
__isl_give isl_basic_map *isl_basic_map_flatten(__isl_take isl_basic_map *bmap);
__isl_export
__isl_give isl_map *isl_map_flatten(__isl_take isl_map *map);
__isl_export
__isl_give isl_basic_map *isl_basic_map_flatten_domain(
	__isl_take isl_basic_map *bmap);
__isl_export
__isl_give isl_basic_map *isl_basic_map_flatten_range(
	__isl_take isl_basic_map *bmap);
__isl_export
__isl_give isl_map *isl_map_flatten_domain(__isl_take isl_map *map);
__isl_export
__isl_give isl_map *isl_map_flatten_range(__isl_take isl_map *map);
__isl_export
__isl_give isl_basic_set *isl_basic_set_flatten(__isl_take isl_basic_set *bset);
__isl_export
__isl_give isl_set *isl_set_flatten(__isl_take isl_set *set);
__isl_give isl_map *isl_set_flatten_map(__isl_take isl_set *set);
__isl_give isl_set *isl_map_params(__isl_take isl_map *map);
__isl_export
__isl_give isl_set *isl_map_domain(__isl_take isl_map *bmap);
__isl_export
__isl_give isl_set *isl_map_range(__isl_take isl_map *map);
__isl_give isl_map *isl_map_domain_map(__isl_take isl_map *map);
__isl_give isl_map *isl_map_range_map(__isl_take isl_map *map);
__isl_give isl_map *isl_set_wrapped_domain_map(__isl_take isl_set *set);
__isl_constructor
__isl_give isl_map *isl_map_from_basic_map(__isl_take isl_basic_map *bmap);
__isl_give isl_map *isl_map_from_domain(__isl_take isl_set *set);
__isl_give isl_basic_map *isl_basic_map_from_domain(
	__isl_take isl_basic_set *bset);
__isl_give isl_basic_map *isl_basic_map_from_range(
	__isl_take isl_basic_set *bset);
__isl_give isl_map *isl_map_from_range(__isl_take isl_set *set);
__isl_give isl_basic_map *isl_basic_map_from_domain_and_range(
	__isl_take isl_basic_set *domain, __isl_take isl_basic_set *range);
__isl_give isl_map *isl_map_from_domain_and_range(__isl_take isl_set *domain,
	__isl_take isl_set *range);
__isl_export
__isl_give isl_basic_map *isl_map_sample(__isl_take isl_map *map);

__isl_export
__isl_give isl_set *isl_map_bind_domain(__isl_take isl_map *map,
	__isl_take isl_multi_id *tuple);
__isl_export
__isl_give isl_set *isl_map_bind_range(__isl_take isl_map *map,
	__isl_take isl_multi_id *tuple);

isl_bool isl_map_plain_is_empty(__isl_keep isl_map *map);
isl_bool isl_map_plain_is_universe(__isl_keep isl_map *map);
__isl_export
isl_bool isl_map_is_empty(__isl_keep isl_map *map);
__isl_export
isl_bool isl_map_is_subset(__isl_keep isl_map *map1, __isl_keep isl_map *map2);
__isl_export
isl_bool isl_map_is_strict_subset(__isl_keep isl_map *map1,
	__isl_keep isl_map *map2);
__isl_export
isl_bool isl_map_is_equal(__isl_keep isl_map *map1, __isl_keep isl_map *map2);
__isl_export
isl_bool isl_map_is_disjoint(__isl_keep isl_map *map1,
	__isl_keep isl_map *map2);
isl_bool isl_basic_map_is_single_valued(__isl_keep isl_basic_map *bmap);
isl_bool isl_map_plain_is_single_valued(__isl_keep isl_map *map);
__isl_export
isl_bool isl_map_is_single_valued(__isl_keep isl_map *map);
isl_bool isl_map_plain_is_injective(__isl_keep isl_map *map);
__isl_export
isl_bool isl_map_is_injective(__isl_keep isl_map *map);
__isl_export
isl_bool isl_map_is_bijective(__isl_keep isl_map *map);
isl_bool isl_map_is_identity(__isl_keep isl_map *map);
int isl_map_is_translation(__isl_keep isl_map *map);
isl_bool isl_map_has_equal_space(__isl_keep isl_map *map1,
	__isl_keep isl_map *map2);

isl_bool isl_basic_map_can_zip(__isl_keep isl_basic_map *bmap);
isl_bool isl_map_can_zip(__isl_keep isl_map *map);
__isl_give isl_basic_map *isl_basic_map_zip(__isl_take isl_basic_map *bmap);
__isl_give isl_map *isl_map_zip(__isl_take isl_map *map);

isl_bool isl_basic_map_can_curry(__isl_keep isl_basic_map *bmap);
isl_bool isl_map_can_curry(__isl_keep isl_map *map);
__isl_give isl_basic_map *isl_basic_map_curry(__isl_take isl_basic_map *bmap);
__isl_export
__isl_give isl_map *isl_map_curry(__isl_take isl_map *map);

isl_bool isl_map_can_range_curry(__isl_keep isl_map *map);
__isl_give isl_map *isl_map_range_curry(__isl_take isl_map *map);

isl_bool isl_basic_map_can_uncurry(__isl_keep isl_basic_map *bmap);
isl_bool isl_map_can_uncurry(__isl_keep isl_map *map);
__isl_give isl_basic_map *isl_basic_map_uncurry(__isl_take isl_basic_map *bmap);
__isl_export
__isl_give isl_map *isl_map_uncurry(__isl_take isl_map *map);

__isl_give isl_map *isl_map_make_disjoint(__isl_take isl_map *map);
__isl_give isl_map *isl_basic_map_compute_divs(__isl_take isl_basic_map *bmap);
__isl_give isl_map *isl_map_compute_divs(__isl_take isl_map *map);
ISL_DEPRECATED
__isl_give isl_map *isl_map_align_divs(__isl_take isl_map *map);

__isl_give isl_basic_map *isl_basic_map_drop_constraints_involving_dims(
	__isl_take isl_basic_map *bmap,
	enum isl_dim_type type, unsigned first, unsigned n);
__isl_give isl_basic_map *isl_basic_map_drop_constraints_not_involving_dims(
	__isl_take isl_basic_map *bmap,
	enum isl_dim_type type, unsigned first, unsigned n);
__isl_give isl_map *isl_map_drop_constraints_involving_dims(
	__isl_take isl_map *map,
	enum isl_dim_type type, unsigned first, unsigned n);
__isl_give isl_map *isl_map_drop_constraints_not_involving_dims(
	__isl_take isl_map *map,
	enum isl_dim_type type, unsigned first, unsigned n);

isl_bool isl_basic_map_involves_dims(__isl_keep isl_basic_map *bmap,
	enum isl_dim_type type, unsigned first, unsigned n);
isl_bool isl_map_involves_dims(__isl_keep isl_map *map,
	enum isl_dim_type type, unsigned first, unsigned n);

void isl_map_print_internal(__isl_keep isl_map *map, FILE *out, int indent);

__isl_give isl_val *isl_map_plain_get_val_if_fixed(__isl_keep isl_map *map,
	enum isl_dim_type type, unsigned pos);

__isl_give isl_basic_map *isl_basic_map_gist_domain(
	__isl_take isl_basic_map *bmap, __isl_take isl_basic_set *context);
__isl_export
__isl_give isl_basic_map *isl_basic_map_gist(__isl_take isl_basic_map *bmap,
	__isl_take isl_basic_map *context);
__isl_export
__isl_give isl_map *isl_map_gist(__isl_take isl_map *map,
	__isl_take isl_map *context);
__isl_export
__isl_give isl_map *isl_map_gist_domain(__isl_take isl_map *map,
	__isl_take isl_set *context);
__isl_give isl_map *isl_map_gist_range(__isl_take isl_map *map,
	__isl_take isl_set *context);
__isl_give isl_map *isl_map_gist_params(__isl_take isl_map *map,
	__isl_take isl_set *context);
__isl_give isl_map *isl_map_gist_basic_map(__isl_take isl_map *map,
	__isl_take isl_basic_map *context);

__isl_give isl_stride_info *isl_map_get_range_stride_info(
	__isl_keep isl_map *map, int pos);
__isl_export
__isl_give isl_fixed_box *isl_map_get_range_simple_fixed_box_hull(
	__isl_keep isl_map *map);

__isl_export
__isl_give isl_map *isl_map_coalesce(__isl_take isl_map *map);

isl_bool isl_map_plain_is_equal(__isl_keep isl_map *map1,
	__isl_keep isl_map *map2);

uint32_t isl_map_get_hash(__isl_keep isl_map *map);

isl_size isl_map_n_basic_map(__isl_keep isl_map *map);
__isl_export
isl_stat isl_map_foreach_basic_map(__isl_keep isl_map *map,
	isl_stat (*fn)(__isl_take isl_basic_map *bmap, void *user), void *user);
__isl_give isl_basic_map_list *isl_map_get_basic_map_list(
	__isl_keep isl_map *map);

__isl_give isl_map *isl_map_fixed_power_val(__isl_take isl_map *map,
	__isl_take isl_val *exp);
__isl_give isl_map *isl_map_power(__isl_take isl_map *map, isl_bool *exact);
__isl_give isl_map *isl_map_reaching_path_lengths(__isl_take isl_map *map,
	isl_bool *exact);
__isl_give isl_map *isl_map_transitive_closure(__isl_take isl_map *map,
	isl_bool *exact);

__isl_give isl_map *isl_map_lex_le_map(__isl_take isl_map *map1,
	__isl_take isl_map *map2);
__isl_give isl_map *isl_map_lex_lt_map(__isl_take isl_map *map1,
	__isl_take isl_map *map2);
__isl_give isl_map *isl_map_lex_ge_map(__isl_take isl_map *map1,
	__isl_take isl_map *map2);
__isl_give isl_map *isl_map_lex_gt_map(__isl_take isl_map *map1,
	__isl_take isl_map *map2);

__isl_give isl_basic_map *isl_basic_map_align_params(
	__isl_take isl_basic_map *bmap, __isl_take isl_space *model);
__isl_give isl_map *isl_map_align_params(__isl_take isl_map *map,
	__isl_take isl_space *model);
__isl_give isl_basic_map *isl_basic_map_drop_unused_params(
	__isl_take isl_basic_map *bmap);
__isl_give isl_map *isl_map_drop_unused_params(__isl_take isl_map *map);

__isl_give isl_mat *isl_basic_map_equalities_matrix(
		__isl_keep isl_basic_map *bmap, enum isl_dim_type c1,
		enum isl_dim_type c2, enum isl_dim_type c3,
		enum isl_dim_type c4, enum isl_dim_type c5);
__isl_give isl_mat *isl_basic_map_inequalities_matrix(
		__isl_keep isl_basic_map *bmap, enum isl_dim_type c1,
		enum isl_dim_type c2, enum isl_dim_type c3,
		enum isl_dim_type c4, enum isl_dim_type c5);
__isl_give isl_basic_map *isl_basic_map_from_constraint_matrices(
	__isl_take isl_space *dim,
	__isl_take isl_mat *eq, __isl_take isl_mat *ineq, enum isl_dim_type c1,
	enum isl_dim_type c2, enum isl_dim_type c3,
	enum isl_dim_type c4, enum isl_dim_type c5);

__isl_give isl_basic_map *isl_basic_map_from_aff(__isl_take isl_aff *aff);
__isl_give isl_basic_map *isl_basic_map_from_multi_aff(
	__isl_take isl_multi_aff *maff);
__isl_give isl_basic_map *isl_basic_map_from_aff_list(
	__isl_take isl_space *domain_space, __isl_take isl_aff_list *list);

__isl_give isl_map *isl_map_from_aff(__isl_take isl_aff *aff);
__isl_give isl_map *isl_map_from_multi_aff(__isl_take isl_multi_aff *maff);

__isl_give isl_pw_aff *isl_map_dim_min(__isl_take isl_map *map, int pos);
__isl_give isl_pw_aff *isl_map_dim_max(__isl_take isl_map *map, int pos);

ISL_DECLARE_LIST_FN(basic_map)
ISL_DECLARE_LIST_FN(map)

#if defined(__cplusplus)
}
#endif

#endif


text:
#ifndef THRIFT_ASYNC_TASYNCSIGNALHANDLER_H_
#define THRIFT_ASYNC_TASYNCSIGNALHANDLER_H_ 1

#include <thrift/lib/cpp/thrift_config.h>
#include <thrift/lib/cpp/async/TEventBase.h>
#include <event.h>
#include <map>

namespace apache { namespace thrift { namespace async {

/**
 * A handler to receive notification about POSIX signals.
 *
 * TAsyncSignalHandler allows code to process signals from within a TEventBase
 * loop.  Standard signal handlers interrupt execution of the main thread, and
 * are run while the main thread is paused.  As a result, great care must be
 * taken to avoid race conditions if the signal handler has to access or modify
 * any data used by the main thread.
 *
 * TAsyncSignalHandler solves this problem by running the TAsyncSignalHandler
 * callback in normal thread of execution, as a TEventBase callback.
 *
 * TAsyncSignalHandler may only be used in a single thread.  It will only
 * process signals received by the thread where the TAsyncSignalHandler is
 * registered.  It is the user's responsibility to ensure that signals are
 * delivered to the desired thread in multi-threaded programs.
 */
class TAsyncSignalHandler {
 public:
  /**
   * Create a new TAsyncSignalHandler.
   */
  TAsyncSignalHandler(TEventBase* eventBase);
  virtual ~TAsyncSignalHandler();

  /**
   * Register to receive callbacks about the specified signal.
   *
   * Once the handler has been registered for a particular signal,
   * signalReceived() will be called each time this thread receives this
   * signal.
   *
   * Throws a TException if an error occurs, or if this handler is already
   * registered for this signal.
   */
  void registerSignalHandler(int signum);

  /**
   * Unregister for callbacks about the specified signal.
   *
   * Throws a TException if an error occurs, or if this signal was not
   * registered.
   */
  void unregisterSignalHandler(int signum);

  /**
   * signalReceived() will called to indicate that the specified signal has
   * been received.
   *
   * signalReceived() will always be invoked from the TEventBase loop (i.e.,
   * after the main POSIX signal handler has returned control to the TEventBase
   * thread).
   */
  virtual void signalReceived(int signum) noexcept = 0;

 private:
  typedef std::map<int, struct event> SignalEventMap;

  // Forbidden copy constructor and assignment operator
  TAsyncSignalHandler(TAsyncSignalHandler const &);
  TAsyncSignalHandler& operator=(TAsyncSignalHandler const &);

  static void libeventCallback(int signum, short events, void* arg);

  TEventBase* eventBase_;
  SignalEventMap signalEvents_;
};

}}} // apache::thrift::async

#endif // THRIFT_ASYNC_TASYNCSIGNALHANDLER_H_


text:
==============================================
Kaleidoscope: Adding JIT and Optimizer Support
==============================================

.. contents::
   :local:

Chapter 4 Introduction
======================

Welcome to Chapter 4 of the "`Implementing a language with
LLVM <index.html>`_" tutorial. Chapters 1-3 described the implementation
of a simple language and added support for generating LLVM IR. This
chapter describes two new techniques: adding optimizer support to your
language, and adding JIT compiler support. These additions will
demonstrate how to get nice, efficient code for the Kaleidoscope
language.

Trivial Constant Folding
========================

Our demonstration for Chapter 3 is elegant and easy to extend.
Unfortunately, it does not produce wonderful code. The IRBuilder,
however, does give us obvious optimizations when compiling simple code:

::

    ready> def test(x) 1+2+x;
    Read function definition:
    define double @test(double %x) {
    entry:
            %addtmp = fadd double 3.000000e+00, %x
            ret double %addtmp
    }

This code is not a literal transcription of the AST built by parsing the
input. That would be:

::

    ready> def test(x) 1+2+x;
    Read function definition:
    define double @test(double %x) {
    entry:
            %addtmp = fadd double 2.000000e+00, 1.000000e+00
            %addtmp1 = fadd double %addtmp, %x
            ret double %addtmp1
    }

Constant folding, as seen above, in particular, is a very common and
very important optimization: so much so that many language implementors
implement constant folding support in their AST representation.

With LLVM, you don't need this support in the AST. Since all calls to
build LLVM IR go through the LLVM IR builder, the builder itself checked
to see if there was a constant folding opportunity when you call it. If
so, it just does the constant fold and return the constant instead of
creating an instruction.

Well, that was easy :). In practice, we recommend always using
``IRBuilder`` when generating code like this. It has no "syntactic
overhead" for its use (you don't have to uglify your compiler with
constant checks everywhere) and it can dramatically reduce the amount of
LLVM IR that is generated in some cases (particular for languages with a
macro preprocessor or that use a lot of constants).

On the other hand, the ``IRBuilder`` is limited by the fact that it does
all of its analysis inline with the code as it is built. If you take a
slightly more complex example:

::

    ready> def test(x) (1+2+x)*(x+(1+2));
    ready> Read function definition:
    define double @test(double %x) {
    entry:
            %addtmp = fadd double 3.000000e+00, %x
            %addtmp1 = fadd double %x, 3.000000e+00
            %multmp = fmul double %addtmp, %addtmp1
            ret double %multmp
    }

In this case, the LHS and RHS of the multiplication are the same value.
We'd really like to see this generate "``tmp = x+3; result = tmp*tmp;``"
instead of computing "``x+3``" twice.

Unfortunately, no amount of local analysis will be able to detect and
correct this. This requires two transformations: reassociation of
expressions (to make the add's lexically identical) and Common
Subexpression Elimination (CSE) to delete the redundant add instruction.
Fortunately, LLVM provides a broad range of optimizations that you can
use, in the form of "passes".

LLVM Optimization Passes
========================

LLVM provides many optimization passes, which do many different sorts of
things and have different tradeoffs. Unlike other systems, LLVM doesn't
hold to the mistaken notion that one set of optimizations is right for
all languages and for all situations. LLVM allows a compiler implementor
to make complete decisions about what optimizations to use, in which
order, and in what situation.

As a concrete example, LLVM supports both "whole module" passes, which
look across as large of body of code as they can (often a whole file,
but if run at link time, this can be a substantial portion of the whole
program). It also supports and includes "per-function" passes which just
operate on a single function at a time, without looking at other
functions. For more information on passes and how they are run, see the
`How to Write a Pass <../WritingAnLLVMPass.html>`_ document and the
`List of LLVM Passes <../Passes.html>`_.

For Kaleidoscope, we are currently generating functions on the fly, one
at a time, as the user types them in. We aren't shooting for the
ultimate optimization experience in this setting, but we also want to
catch the easy and quick stuff where possible. As such, we will choose
to run a few per-function optimizations as the user types the function
in. If we wanted to make a "static Kaleidoscope compiler", we would use
exactly the code we have now, except that we would defer running the
optimizer until the entire file has been parsed.

In order to get per-function optimizations going, we need to set up a
`FunctionPassManager <../WritingAnLLVMPass.html#what-passmanager-doesr>`_ to hold
and organize the LLVM optimizations that we want to run. Once we have
that, we can add a set of optimizations to run. We'll need a new
FunctionPassManager for each module that we want to optimize, so we'll
write a function to create and initialize both the module and pass manager
for us:

.. code-block:: c++

    void InitializeModuleAndPassManager(void) {
      // Open a new module.
      Context LLVMContext;
      TheModule = llvm::make_unique<Module>("my cool jit", LLVMContext);
      TheModule->setDataLayout(TheJIT->getTargetMachine().createDataLayout());

      // Create a new pass manager attached to it.
      TheFPM = llvm::make_unique<FunctionPassManager>(TheModule.get());

      // Provide basic AliasAnalysis support for GVN.
      TheFPM.add(createBasicAliasAnalysisPass());
      // Do simple "peephole" optimizations and bit-twiddling optzns.
      TheFPM.add(createInstructionCombiningPass());
      // Reassociate expressions.
      TheFPM.add(createReassociatePass());
      // Eliminate Common SubExpressions.
      TheFPM.add(createGVNPass());
      // Simplify the control flow graph (deleting unreachable blocks, etc).
      TheFPM.add(createCFGSimplificationPass());

      TheFPM.doInitialization();
    }

This code initializes the global module ``TheModule``, and the function pass
manager ``TheFPM``, which is attached to ``TheModule``. Once the pass manager is
set up, we use a series of "add" calls to add a bunch of LLVM passes.

In this case, we choose to add five passes: one analysis pass (alias analysis),
and four optimization passes. The passes we choose here are a pretty standard set
of "cleanup" optimizations that are useful for a wide variety of code. I won't
delve into what they do but, believe me, they are a good starting place :).

Once the PassManager is set up, we need to make use of it. We do this by
running it after our newly created function is constructed (in
``FunctionAST::codegen()``), but before it is returned to the client:

.. code-block:: c++

      if (Value *RetVal = Body->codegen()) {
        // Finish off the function.
        Builder.CreateRet(RetVal);

        // Validate the generated code, checking for consistency.
        verifyFunction(*TheFunction);

        // Optimize the function.
        TheFPM->run(*TheFunction);

        return TheFunction;
      }

As you can see, this is pretty straightforward. The
``FunctionPassManager`` optimizes and updates the LLVM Function\* in
place, improving (hopefully) its body. With this in place, we can try
our test above again:

::

    ready> def test(x) (1+2+x)*(x+(1+2));
    ready> Read function definition:
    define double @test(double %x) {
    entry:
            %addtmp = fadd double %x, 3.000000e+00
            %multmp = fmul double %addtmp, %addtmp
            ret double %multmp
    }

As expected, we now get our nicely optimized code, saving a floating
point add instruction from every execution of this function.

LLVM provides a wide variety of optimizations that can be used in
certain circumstances. Some `documentation about the various
passes <../Passes.html>`_ is available, but it isn't very complete.
Another good source of ideas can come from looking at the passes that
``Clang`` runs to get started. The "``opt``" tool allows you to
experiment with passes from the command line, so you can see if they do
anything.

Now that we have reasonable code coming out of our front-end, lets talk
about executing it!

Adding a JIT Compiler
=====================

Code that is available in LLVM IR can have a wide variety of tools
applied to it. For example, you can run optimizations on it (as we did
above), you can dump it out in textual or binary forms, you can compile
the code to an assembly file (.s) for some target, or you can JIT
compile it. The nice thing about the LLVM IR representation is that it
is the "common currency" between many different parts of the compiler.

In this section, we'll add JIT compiler support to our interpreter. The
basic idea that we want for Kaleidoscope is to have the user enter
function bodies as they do now, but immediately evaluate the top-level
expressions they type in. For example, if they type in "1 + 2;", we
should evaluate and print out 3. If they define a function, they should
be able to call it from the command line.

In order to do this, we first declare and initialize the JIT. This is
done by adding a global variable ``TheJIT``, and initializing it in
``main``:

.. code-block:: c++

    static std::unique_ptr<KaleidoscopeJIT> TheJIT;
    ...
    int main() {
      ..
      TheJIT = llvm::make_unique<KaleidoscopeJIT>();

      // Run the main "interpreter loop" now.
      MainLoop();

      return 0;
    }

The KaleidoscopeJIT class is a simple JIT built specifically for these
tutorials. In later chapters we will look at how it works and extend it with
new features, but for now we will take it as given. Its API is very simple::
``addModule`` adds an LLVM IR module to the JIT, making its functions
available for execution; ``removeModule`` removes a module, freeing any
memory associated with the code in that module; and ``findSymbol`` allows us
to look up pointers to the compiled code.

We can take this simple API and change our code that parses top-level expressions to
look like this:

.. code-block:: c++

    static void HandleTopLevelExpression() {
      // Evaluate a top-level expression into an anonymous function.
      if (auto FnAST = ParseTopLevelExpr()) {
        if (FnAST->codegen()) {

          // JIT the module containing the anonymous expression, keeping a handle so
          // we can free it later.
          auto H = TheJIT->addModule(std::move(TheModule));
          InitializeModuleAndPassManager();

          // Search the JIT for the __anon_expr symbol.
          auto ExprSymbol = TheJIT->findSymbol("__anon_expr");
          assert(ExprSymbol && "Function not found");

          // Get the symbol's address and cast it to the right type (takes no
          // arguments, returns a double) so we can call it as a native function.
          double (*FP)() = (double (*)())(intptr_t)ExprSymbol.getAddress();
          fprintf(stderr, "Evaluated to %f\n", FP());

          // Delete the anonymous expression module from the JIT.
          TheJIT->removeModule(H);
        }

If parsing and codegen succeeed, the next step is to add the module containing
the top-level expression to the JIT. We do this by calling addModule, which
triggers code generation for all the functions in the module, and returns a
handle that can be used to remove the module from the JIT later. Once the module
has been added to the JIT it can no longer be modified, so we also open a new
module to hold subsequent code by calling ``InitializeModuleAndPassManager()``.

Once we've added the module to the JIT we need to get a pointer to the final
generated code. We do this by calling the JIT's findSymbol method, and passing
the name of the top-level expression function: ``__anon_expr``. Since we just
added this function, we assert that findSymbol returned a result.

Next, we get the in-memory address of the ``__anon_expr`` function by calling
``getAddress()`` on the symbol. Recall that we compile top-level expressions
into a self-contained LLVM function that takes no arguments and returns the
computed double. Because the LLVM JIT compiler matches the native platform ABI,
this means that you can just cast the result pointer to a function pointer of
that type and call it directly. This means, there is no difference between JIT
compiled code and native machine code that is statically linked into your
application.

Finally, since we don't support re-evaluation of top-level expressions, we
remove the module from the JIT when we're done to free the associated memory.
Recall, however, that the module we created a few lines earlier (via
``InitializeModuleAndPassManager``) is still open and waiting for new code to be
added.

With just these two changes, lets see how Kaleidoscope works now!

::

    ready> 4+5;
    Read top-level expression:
    define double @0() {
    entry:
      ret double 9.000000e+00
    }

    Evaluated to 9.000000

Well this looks like it is basically working. The dump of the function
shows the "no argument function that always returns double" that we
synthesize for each top-level expression that is typed in. This
demonstrates very basic functionality, but can we do more?

::

    ready> def testfunc(x y) x + y*2;
    Read function definition:
    define double @testfunc(double %x, double %y) {
    entry:
      %multmp = fmul double %y, 2.000000e+00
      %addtmp = fadd double %multmp, %x
      ret double %addtmp
    }

    ready> testfunc(4, 10);
    Read top-level expression:
    define double @1() {
    entry:
      %calltmp = call double @testfunc(double 4.000000e+00, double 1.000000e+01)
      ret double %calltmp
    }

    Evaluated to 24.000000

    ready> testfunc(5, 10);
    ready> LLVM ERROR: Program used external function 'testfunc' which could not be resolved!

Function definitions and calls also work, but something went very wrong on that
last line. The call looks valid, so what happened? As you may have guessed from
the the API a Module is a unit of allocation for the JIT, and testfunc was part
of the same module that contained anonymous expression. When we removed that
module from the JIT to free the memory for the anonymous expression, we deleted
the definition of ``testfunc`` along with it. Then, when we tried to call
testfunc a second time, the JIT could no longer find it.

The easiest way to fix this is to put the anonymous expression in a separate
module from the rest of the function definitions. The JIT will happily resolve
function calls across module boundaries, as long as each of the functions called
has a prototype, and is added to the JIT before it is called. By putting the
anonymous expression in a different module we can delete it without affecting
the rest of the functions.

In fact, we're going to go a step further and put every function in its own
module. Doing so allows us to exploit a useful property of the KaleidoscopeJIT
that will make our environment more REPL-like: Functions can be added to the
JIT more than once (unlike a module where every function must have a unique
definition). When you look up a symbol in KaleidoscopeJIT it will always return
the most recent definition:

::

    ready> def foo(x) x + 1;
    Read function definition:
    define double @foo(double %x) {
    entry:
      %addtmp = fadd double %x, 1.000000e+00
      ret double %addtmp
    }

    ready> foo(2);
    Evaluated to 3.000000

    ready> def foo(x) x + 2;
    define double @foo(double %x) {
    entry:
      %addtmp = fadd double %x, 2.000000e+00
      ret double %addtmp
    }

    ready> foo(2);
    Evaluated to 4.000000

To allow each function to live in its own module we'll need a way to
re-generate previous function declarations into each new module we open:

.. code-block:: c++

    static std::unique_ptr<KaleidoscopeJIT> TheJIT;

    ...

    Function *getFunction(std::string Name) {
      // First, see if the function has already been added to the current module.
      if (auto *F = TheModule->getFunction(Name))
        return F;

      // If not, check whether we can codegen the declaration from some existing
      // prototype.
      auto FI = FunctionProtos.find(Name);
      if (FI != FunctionProtos.end())
        return FI->second->codegen();

      // If no existing prototype exists, return null.
      return nullptr;
    }

    ...

    Value *CallExprAST::codegen() {
      // Look up the name in the global module table.
      Function *CalleeF = getFunction(Callee);

    ...

    Function *FunctionAST::codegen() {
      // Transfer ownership of the prototype to the FunctionProtos map, but keep a
      // reference to it for use below.
      auto &P = *Proto;
      FunctionProtos[Proto->getName()] = std::move(Proto);
      Function *TheFunction = getFunction(P.getName());
      if (!TheFunction)
        return nullptr;

To enable this, we'll start by adding a new global, ``FunctionProtos``, that
holds the most recent prototype for each function. We'll also add a convenience
method, ``getFunction()``, to replace calls to ``TheModule->getFunction()``.
Our convenience method searches ``TheModule`` for an existing function
declaration, falling back to generating a new declaration from FunctionProtos if
it doesn't find one. In ``CallExprAST::codegen()`` we just need to replace the
call to ``TheModule->getFunction()``. In ``FunctionAST::codegen()`` we need to
update the FunctionProtos map first, then call ``getFunction()``. With this
done, we can always obtain a function declaration in the current module for any
previously declared function.

We also need to update HandleDefinition and HandleExtern:

.. code-block:: c++

    static void HandleDefinition() {
      if (auto FnAST = ParseDefinition()) {
        if (auto *FnIR = FnAST->codegen()) {
          fprintf(stderr, "Read function definition:");
          FnIR->dump();
          TheJIT->addModule(std::move(TheModule));
          InitializeModuleAndPassManager();
        }
      } else {
        // Skip token for error recovery.
         getNextToken();
      }
    }

    static void HandleExtern() {
      if (auto ProtoAST = ParseExtern()) {
        if (auto *FnIR = ProtoAST->codegen()) {
          fprintf(stderr, "Read extern: ");
          FnIR->dump();
          FunctionProtos[ProtoAST->getName()] = std::move(ProtoAST);
        }
      } else {
        // Skip token for error recovery.
        getNextToken();
      }
    }

In HandleDefinition, we add two lines to transfer the newly defined function to
the JIT and open a new module. In HandleExtern, we just need to add one line to
add the prototype to FunctionProtos.

With these changes made, lets try our REPL again (I removed the dump of the
anonymous functions this time, you should get the idea by now :) :

::

    ready> def foo(x) x + 1;
    ready> foo(2);
    Evaluated to 3.000000

    ready> def foo(x) x + 2;
    ready> foo(2);
    Evaluated to 4.000000

It works!

Even with this simple code, we get some surprisingly powerful capabilities -
check this out:

::

    ready> extern sin(x);
    Read extern:
    declare double @sin(double)

    ready> extern cos(x);
    Read extern:
    declare double @cos(double)

    ready> sin(1.0);
    Read top-level expression:
    define double @2() {
    entry:
      ret double 0x3FEAED548F090CEE
    }

    Evaluated to 0.841471

    ready> def foo(x) sin(x)*sin(x) + cos(x)*cos(x);
    Read function definition:
    define double @foo(double %x) {
    entry:
      %calltmp = call double @sin(double %x)
      %multmp = fmul double %calltmp, %calltmp
      %calltmp2 = call double @cos(double %x)
      %multmp4 = fmul double %calltmp2, %calltmp2
      %addtmp = fadd double %multmp, %multmp4
      ret double %addtmp
    }

    ready> foo(4.0);
    Read top-level expression:
    define double @3() {
    entry:
      %calltmp = call double @foo(double 4.000000e+00)
      ret double %calltmp
    }

    Evaluated to 1.000000

Whoa, how does the JIT know about sin and cos? The answer is surprisingly
simple: The KaleidoscopeJIT has a straightforward symbol resolution rule that
it uses to find symbols that aren't available in any given module: First
it searches all the modules that have already been added to the JIT, from the
most recent to the oldest, to find the newest definition. If no definition is
found inside the JIT, it falls back to calling "``dlsym("sin")``" on the
Kaleidoscope process itself. Since "``sin``" is defined within the JIT's
address space, it simply patches up calls in the module to call the libm
version of ``sin`` directly.

In the future we'll see how tweaking this symbol resolution rule can be used to
enable all sorts of useful features, from security (restricting the set of
symbols available to JIT'd code), to dynamic code generation based on symbol
names, and even lazy compilation.

One immediate benefit of the symbol resolution rule is that we can now extend
the language by writing arbitrary C++ code to implement operations. For example,
if we add:

.. code-block:: c++

    /// putchard - putchar that takes a double and returns 0.
    extern "C" double putchard(double X) {
      fputc((char)X, stderr);
      return 0;
    }

Now we can produce simple output to the console by using things like:
"``extern putchard(x); putchard(120);``", which prints a lowercase 'x'
on the console (120 is the ASCII code for 'x'). Similar code could be
used to implement file I/O, console input, and many other capabilities
in Kaleidoscope.

This completes the JIT and optimizer chapter of the Kaleidoscope
tutorial. At this point, we can compile a non-Turing-complete
programming language, optimize and JIT compile it in a user-driven way.
Next up we'll look into `extending the language with control flow
constructs <LangImpl5.html>`_, tackling some interesting LLVM IR issues
along the way.

Full Code Listing
=================

Here is the complete code listing for our running example, enhanced with
the LLVM JIT and optimizer. To build this example, use:

.. code-block:: bash

    # Compile
    clang++ -g toy.cpp `llvm-config --cxxflags --ldflags --system-libs --libs core mcjit native` -O3 -o toy
    # Run
    ./toy

If you are compiling this on Linux, make sure to add the "-rdynamic"
option as well. This makes sure that the external functions are resolved
properly at runtime.

Here is the code:

.. literalinclude:: ../../examples/Kaleidoscope/Chapter4/toy.cpp
   :language: c++

`Next: Extending the language: control flow <LangImpl05.html>`_


text:
<?php

namespace Drupal\Tests\Core\Menu;

use Drupal\Core\Plugin\Discovery\ContainerDerivativeDiscoveryDecorator;
use Drupal\Core\Plugin\Discovery\YamlDiscovery;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpFoundation\RequestStack;

/**
 * Defines a base unit test for testing existence of local tasks.
 *
 * @todo Add tests for access checking and url building,
 *   https://www.drupal.org/node/2112245.
 */
abstract class LocalTaskIntegrationTestBase extends UnitTestCase {

  /**
   * A list of module directories used for YAML searching.
   *
   * @var array
   */
  protected $directoryList;

  /**
   * The module handler.
   *
   * @var \Drupal\Core\Extension\ModuleHandlerInterface|\PHPUnit\Framework\MockObject\MockObject
   */
  protected $moduleHandler;

  /**
   * The container.
   *
   * @var \Symfony\Component\DependencyInjection\ContainerBuilder
   */
  protected $container;

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    parent::setUp();

    $container = new ContainerBuilder();
    $config_factory = $this->getConfigFactoryStub([]);
    $container->set('config.factory', $config_factory);
    $container->setParameter('app.root', $this->root);
    \Drupal::setContainer($container);
    $this->container = $container;
  }

  /**
   * Sets up the local task manager for the test.
   */
  protected function getLocalTaskManager($module_dirs, $route_name, $route_params) {
    $manager = $this
      ->getMockBuilder('Drupal\Core\Menu\LocalTaskManager')
      ->disableOriginalConstructor()
      ->onlyMethods([])
      ->getMock();

    $argumentResolver = $this->createMock('Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface');
    $property = new \ReflectionProperty('Drupal\Core\Menu\LocalTaskManager', 'argumentResolver');
    $property->setAccessible(TRUE);
    $property->setValue($manager, $argumentResolver);

    // todo mock a request with a route.
    $request_stack = new RequestStack();
    $property = new \ReflectionProperty('Drupal\Core\Menu\LocalTaskManager', 'requestStack');
    $property->setAccessible(TRUE);
    $property->setValue($manager, $request_stack);

    $accessManager = $this->createMock('Drupal\Core\Access\AccessManagerInterface');
    $property = new \ReflectionProperty('Drupal\Core\Menu\LocalTaskManager', 'accessManager');
    $property->setAccessible(TRUE);
    $property->setValue($manager, $accessManager);

    $route_provider = $this->createMock('Drupal\Core\Routing\RouteProviderInterface');
    $property = new \ReflectionProperty('Drupal\Core\Menu\LocalTaskManager', 'routeProvider');
    $property->setAccessible(TRUE);
    $property->setValue($manager, $route_provider);

    $module_handler = $this->getMockBuilder('Drupal\Core\Extension\ModuleHandlerInterface')
      ->disableOriginalConstructor()
      ->getMock();
    $property = new \ReflectionProperty('Drupal\Core\Menu\LocalTaskManager', 'moduleHandler');
    $property->setAccessible(TRUE);
    $property->setValue($manager, $module_handler);
    // Set all the modules as being existent.
    $module_handler->expects($this->any())
      ->method('moduleExists')
      ->willReturnCallback(function ($module) use ($module_dirs) {
        return isset($module_dirs[$module]);
      });

    $pluginDiscovery = new YamlDiscovery('links.task', $module_dirs);
    $pluginDiscovery = new ContainerDerivativeDiscoveryDecorator($pluginDiscovery);
    $property = new \ReflectionProperty('Drupal\Core\Menu\LocalTaskManager', 'discovery');
    $property->setAccessible(TRUE);
    $property->setValue($manager, $pluginDiscovery);

    $method = new \ReflectionMethod('Drupal\Core\Menu\LocalTaskManager', 'alterInfo');
    $method->setAccessible(TRUE);
    $method->invoke($manager, 'local_tasks');

    $plugin_stub = $this->createMock('Drupal\Core\Menu\LocalTaskInterface');
    $factory = $this->createMock('Drupal\Component\Plugin\Factory\FactoryInterface');
    $factory->expects($this->any())
      ->method('createInstance')
      ->will($this->returnValue($plugin_stub));
    $property = new \ReflectionProperty('Drupal\Core\Menu\LocalTaskManager', 'factory');
    $property->setAccessible(TRUE);
    $property->setValue($manager, $factory);

    $cache_backend = $this->createMock('Drupal\Core\Cache\CacheBackendInterface');
    $manager->setCacheBackend($cache_backend, 'local_task.en', ['local_task']);

    return $manager;
  }

  /**
   * Tests integration for local tasks.
   *
   * @param $route_name
   *   Route name to base task building on.
   * @param $expected_tasks
   *   A list of tasks groups by level expected at the given route
   * @param array $route_params
   *   (optional) A list of route parameters used to resolve tasks.
   */
  protected function assertLocalTasks($route_name, $expected_tasks, $route_params = []) {

    $directory_list = [];
    foreach ($this->directoryList as $key => $value) {
      $directory_list[$key] = $this->root . '/' . $value;
    }

    $manager = $this->getLocalTaskManager($directory_list, $route_name, $route_params);

    $tmp_tasks = $manager->getLocalTasksForRoute($route_name);

    // At this point we're just testing existence so pull out keys and then
    // compare.
    //
    // Deeper testing would require a functioning factory which because we are
    // using the DefaultPluginManager base means we get into dependency soup
    // because its factories create method and pulling services off the \Drupal
    // container.
    $tasks = [];
    foreach ($tmp_tasks as $level => $level_tasks) {
      $tasks[$level] = array_keys($level_tasks);
    }
    $this->assertEquals($expected_tasks, $tasks);
  }

}


text:
/**
 * Created by Administrator on 2017/3/31.
 */
import { Component } from '@angular/core';

@Component({
    selector: 'breadcrumb',
    templateUrl: 'app/layout/breadcrumb/breadcrumb.component.html',
    styleUrls: ['app/layout/breadcrumb/breadcrumb.component.css']
})
export class breadcrumbComponent { }


text:
@(content: String)

@import cobase.util.Linkify

@{ val l = new Linkify()
    Html(l.convert(content).replace("\n", "<br/>"))
}


text:
#ifndef __USBUSER_H__
#define __USBUSER_H__

/* USB Device Events Callback Functions */
extern void USB_Power_Event     (BOOL  power);
extern void USB_Reset_Event     (void);
extern void USB_Suspend_Event   (void);
extern void USB_Resume_Event    (void);
extern void USB_WakeUp_Event    (void);
extern void USB_SOF_Event       (void);
extern void USB_Error_Event     (DWORD error);

/* USB Endpoint Callback Events */
#define USB_EVT_SETUP       1   /* Setup Packet */
#define USB_EVT_OUT         2   /* OUT Packet */
#define USB_EVT_IN          3   /*  IN Packet */
#define USB_EVT_OUT_NAK     4   /* OUT Packet - Not Acknowledged */
#define USB_EVT_IN_NAK      5   /*  IN Packet - Not Acknowledged */
#define USB_EVT_OUT_STALL   6   /* OUT Packet - Stalled */
#define USB_EVT_IN_STALL    7   /*  IN Packet - Stalled */
#define USB_EVT_OUT_DMA_EOT 8   /* DMA OUT EP - End of Transfer */
#define USB_EVT_IN_DMA_EOT  9   /* DMA  IN EP - End of Transfer */
#define USB_EVT_OUT_DMA_NDR 10  /* DMA OUT EP - New Descriptor Request */
#define USB_EVT_IN_DMA_NDR  11  /* DMA  IN EP - New Descriptor Request */
#define USB_EVT_OUT_DMA_ERR 12  /* DMA OUT EP - Error */
#define USB_EVT_IN_DMA_ERR  13  /* DMA  IN EP - Error */

/* USB Endpoint Events Callback Pointers */
extern void (* const USB_P_EP[16])(DWORD event);

/* USB Endpoint Events Callback Functions */
extern void USB_EndPoint0  (DWORD event);
extern void USB_EndPoint1  (DWORD event);
extern void USB_EndPoint2  (DWORD event);
extern void USB_EndPoint3  (DWORD event);
extern void USB_EndPoint4  (DWORD event);
extern void USB_EndPoint5  (DWORD event);
extern void USB_EndPoint6  (DWORD event);
extern void USB_EndPoint7  (DWORD event);
extern void USB_EndPoint8  (DWORD event);
extern void USB_EndPoint9  (DWORD event);
extern void USB_EndPoint10 (DWORD event);
extern void USB_EndPoint11 (DWORD event);
extern void USB_EndPoint12 (DWORD event);
extern void USB_EndPoint13 (DWORD event);
extern void USB_EndPoint14 (DWORD event);
extern void USB_EndPoint15 (DWORD event);

/* USB Core Events Callback Functions */
extern void USB_Configure_Event (void);
extern void USB_Interface_Event (void);
extern void USB_Feature_Event   (void);

#endif  /* __USBUSER_H__ */


text:
package ch.heigvd.res.mygitsandboxproject;

/**
 *
 * @author Olivier Liechti
 */
public class Bob {

}


text:
/*
	These styles are just for the example. The base styles are in SelectBox.css.
*/
body { font-family: "Lucida Grande", Arial, Helvetica, sans-serif; }
h1 { font-size: 24px; line-height: 1; }
h2 { font-size: 16px; }
p { font-size: 12px; }
#example-1 .customSelect { clear: both; margin-bottom: 10px; }
#example-2 .cities dd { padding: 0 5px; }

/* COUNTRY SELECTBOX */
/* This should be a sprite... but this is quicker for examples sake */
dd span, .selectedValue span {
	position: relative;
	top: 2px;
	display: block;
	height: 12px;
	width: 20px;
	float: left;
	clear: right;
}
dd span.usa, .selectedValue span.usa {
	background: url("../img/us.png") no-repeat;
}
dd span.germany, .selectedValue span.germany {
	background: url("../img/de.png") no-repeat;
}
dd span.france, .selectedValue span.france {
	background: url("../img/fr.png") no-repeat;
}
dd span.italy, .selectedValue span.italy {
	background: url("../img/it.png") no-repeat;
}


text:
package com.oficina.saude.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.oficina.saude.model.PedidoMedicamento;
import com.oficina.saude.model.Receita;
import com.oficina.saude.repository.Receitas;

@RestController
public class ReceitaController {

	@Autowired
	private Receitas receitas;

	@RequestMapping(value="/receita/pesquisa", method=RequestMethod.GET, consumes={MediaType.APPLICATION_JSON_VALUE})
	public @ResponseBody List<PedidoMedicamento> pesquisaUm(@RequestParam Long codigo){
		Receita ret1 = receitas.findOne(codigo);
		return ret1.getPedidos();
	}

}


text:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"

    package="com.zdf.zrouter.api">

    <application android:allowBackup="true" android:label="@string/app_name"
        android:supportsRtl="true">

    </application>

</manifest>


text:
require 'spec_helper'
require 'puppet/pops'

describe Puppet::Pops::Parser::Parser do
  it "should instantiate a parser" do
    parser = Puppet::Pops::Parser::Parser.new()
    parser.class.should == Puppet::Pops::Parser::Parser
  end

  it "should parse a code string and return a model" do
    parser = Puppet::Pops::Parser::Parser.new()
    model = parser.parse_string("$a = 10").current
    model.class.should == Puppet::Pops::Model::AssignmentExpression
  end
end


text:
'use strict';

/**
 * @ngdoc function
 * @name tagrefineryGuiApp.controller:SpellcheckingparamsCtrl
 * @description
 * # SpellcheckingparamsCtrl
 * Controller of the tagrefineryGuiApp
 */
angular.module('tagrefineryGuiApp')
  .controller('SpellcheckingparamsCtrl', ["$scope", "socket", function ($scope, socket) {

    // Get instance of the class
    var that = this;

    that.minWordSize = 0;
    that.newMinWordSize = 0;

    ////////////////////////////////////////////////
    // Socket functions
    ////////////////////////////////////////////////

    socket.on('spellMinWordSize', function (data) {
      that.minWordSize = data;
      that.newMinWordSize = that.minWordSize;
    });

    that.applyWatch = $scope.$on("apply", function() {
      if(that.params.$dirty)
      {
        socket.emit("applySpellMinWordSize", that.newMinWordSize);

        that.params.$setPristine();
      }
    });

    $scope.$on('$destroy', function() {
      that.applyWatch();

      socket.removeAllListeners('spellMinWordSize');
    });

    that.undo = function()
    {
      that.newMinWordSize = that.minWordSize;

      that.params.$setPristine();
    }

  }]);


text:
class AddLookingToMissing < ActiveRecord::Migration
  def change
    add_reference :missings, :looking, index: true, foreign_key: true
  end
end


text:
require "gapic/common"
require "gapic/config"
require "gapic/config/method"

require "google/cloud/dataflow/v1beta3/version"

require "google/cloud/dataflow/v1beta3/metrics/credentials"
require "google/cloud/dataflow/v1beta3/metrics/client"

module Google
  module Cloud
    module Dataflow
      module V1beta3
        ##
        # The Dataflow Metrics API lets you monitor the progress of Dataflow
        # jobs.
        #
        # To load this service and instantiate a client:
        #
        #     require "google/cloud/dataflow/v1beta3/metrics"
        #     client = ::Google::Cloud::Dataflow::V1beta3::Metrics::Client.new
        #
        module Metrics
        end
      end
    end
  end
end

helper_path = ::File.join __dir__, "metrics", "helpers.rb"
require "google/cloud/dataflow/v1beta3/metrics/helpers" if ::File.file? helper_path