text
stringlengths
5
1.04M
// Copyright (c) 2001-2011 Hartmut Kaiser // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #if !defined(BOOST_SPIRIT_REPOSITORY_QI_ITER_POS_NOV_20_2009_1245PM) #define BOOST_SPIRIT_REPOSITORY_QI_ITER_POS_NOV_20_2009_1245PM #include <boost/spirit/include/qi_parse.hpp> /////////////////////////////////////////////////////////////////////////////// // definition the place holder namespace boost { namespace spirit { namespace repository { namespace qi { BOOST_SPIRIT_TERMINAL(iter_pos) } } // namespace repository } // namespace spirit } // namespace boost /////////////////////////////////////////////////////////////////////////////// // implementation the enabler namespace boost { namespace spirit { // We want custom_parser::iter_pos to be usable as a terminal only, // and only for parser expressions (qi::domain). template <> struct use_terminal<qi::domain, repository::qi::tag::iter_pos> : mpl::true_ {}; } // namespace spirit } // namespace boost /////////////////////////////////////////////////////////////////////////////// // implementation of the parser namespace boost { namespace spirit { namespace repository { namespace qi { struct iter_pos_parser : boost::spirit::qi::primitive_parser<iter_pos_parser> { // Define the attribute type exposed by this parser component template <typename Context, typename Iterator> struct attribute { typedef Iterator type; }; // This function is called during the actual parsing process template <typename Iterator, typename Context, typename Skipper, typename Attribute> bool parse(Iterator &first, Iterator const &last, Context &, Skipper const &skipper, Attribute &attr) const { boost::spirit::qi::skip_over(first, last, skipper); boost::spirit::traits::assign_to(first, attr); return true; } // This function is called during error handling to create // a human readable string for the error context. template <typename Context> boost::spirit::info what(Context &) const { return boost::spirit::info("iter_pos"); } }; } // namespace qi } // namespace repository } // namespace spirit } // namespace boost /////////////////////////////////////////////////////////////////////////////// // instantiation of the parser namespace boost { namespace spirit { namespace qi { // This is the factory function object invoked in order to create // an instance of our iter_pos_parser. template <typename Modifiers> struct make_primitive<repository::qi::tag::iter_pos, Modifiers> { typedef repository::qi::iter_pos_parser result_type; result_type operator()(unused_type, unused_type) const { return result_type(); } }; } // namespace qi } // namespace spirit } // namespace boost #endif
#define USE_FILE_IO #define NDEBUG #define ALPHA 0.805 #include <cassert> #include <cstring> #include <climits> #include <vector> #include <random> #include <fstream> #include <sstream> #include <algorithm> using namespace std; #ifndef USE_FILE_IO #include <iostream> using std::cin; using std::cout; #else static ifstream cin("tree.in"); static ofstream cout("tree.out"); #endif // IFNDEF USE_FILE_IO inline void initialize() { #ifndef USE_FILE_IO ios::sync_with_stdio(false); #endif }; struct Node { Node() = default; Node(int _key = 0, int _value = 0, Node *_left = nullptr, Node *_right = nullptr) : key(_key) , value(_value) , size(1) , left(_left) , right(_right) , deleted(false) {} int key = 0; int value = 0; int size = 1; Node *left = nullptr; Node *right = nullptr; bool deleted = false; void update() { size = (deleted ? 0 : 1) + (left ? left->size : 0) + (right ? right->size : 0); } std::string print_node() { stringstream buffer; buffer << key; buffer << "[label=\"" << key << "\" color=" << (deleted ? "red" : "black") << "]"; buffer << ";"; if (left != nullptr) { buffer << key << ":sw -> " << left->key << "[style=bold];"; } if (right != nullptr) { buffer << key << ":se -> " << right->key << "[style=bold];"; } return buffer.str(); } }; // struct Node static int size = 0; static int deleted_count = 0; static Node *tree = nullptr; #define MEMORY_SIZE 10000000 static size_t current; static Node *memory[MEMORY_SIZE]; inline void refresh() { current = 0; } inline void push(Node *node) { memory[++current] = node; } Node *rebalance(Node *h); Node *insert(Node *h, int key, int value); Node *remove(Node *h, int key); Node *query(Node *h, int key); void print_tree(Node *node); void print_tree(Node *node, std::string &data); int main() { initialize(); char command; int key = INT_MAX, value = INT_MAX; while (cin >> command) { switch (command) { case 'A': cin >> key >> value; tree = insert(tree, key, value); break; case 'D': cin >> key; tree = remove(tree, key); break; case 'Q': cin >> key; { auto ptr = query(tree, key); if (ptr) cout << ptr->value << "\n"; else cout << "-1\n"; } break; case 'B': tree = rebalance(tree); break; } // switch to command #ifndef NDEBUG if (command == 'P') { print_tree(tree); } #endif // IFNDEF NDEBUG } // while return 0; } // function main void print_tree(Node *node) { std::string data; data = "digraph{\nnode [shape=circle];"; print_tree(node, data); data += "}"; ofstream file("/tmp/tree.tmp.dot"); file << data; file.close(); system("showdot /tmp/tree.tmp.dot"); } void print_tree(Node *node, std::string &data) { if (node == nullptr) return; data += node->print_node(); print_tree(node->left, data); print_tree(node->right, data); } static void travel(Node *h) { if (!h) return; travel(h->left); if (!h->deleted) push(h); travel(h->right); if (h->deleted) delete h; } static Node *rebalance(int left, int right) { if (right < left) return nullptr; int mid = (left + right) >> 1; Node *node = memory[mid]; node->left = rebalance(left, mid - 1); node->right = rebalance(mid + 1, right); node->update(); return node; } Node *rebalance(Node *h) { refresh(); travel(h); return rebalance(1, current); } static Node *insert(Node *h, int key, int value, bool &balanced) { if (!h) { size++; return new Node(key, value); } if (key == h->key) { h->value = value; if (h->deleted) h->deleted = false; } else if (key < h->key) h->left = insert(h->left, key, value); else h->right = insert(h->right, key, value); h->update(); if (!balanced && ((h->left && h->left->size > ALPHA * h->size) || ((h->right && h->right->size > ALPHA * h->size)))) { balanced = true; return rebalance(h); } else return h; } Node *insert(Node *h, int key, int value) { bool balanced = false; return insert(h, key, value, balanced); } static Node *_remove(Node *h, int key) { if (!h) return nullptr; if (!h->deleted && key == h->key) { h->deleted = true; deleted_count++; } else if (key < h->key) h->left = _remove(h->left, key); else h->right = _remove(h->right, key); return h; } Node *remove(Node *h, int key) { h = _remove(h, key); if (deleted_count > size / 2) { size -= deleted_count; deleted_count = 0; return rebalance(h); } else return h; } Node *query(Node *h, int key) { if (!h) return nullptr; if (!h->deleted && key == h->key) return h; else if (key < h->key) return query(h->left, key); else return query(h->right, key); }
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE415_Double_Free__new_delete_array_char_17.cpp Label Definition File: CWE415_Double_Free__new_delete_array.label.xml Template File: sources-sinks-17.tmpl.cpp */ /* * @description * CWE: 415 Double Free * BadSource: Allocate data using new and Deallocae data using delete * GoodSource: Allocate data using new * Sinks: * GoodSink: do nothing * BadSink : Deallocate data using delete * Flow Variant: 17 Control flow: for loops * */ #include "std_testcase.h" #include <wchar.h> namespace CWE415_Double_Free__new_delete_array_char_17 { #ifndef OMITBAD void bad() { int i,j; char * data; /* Initialize data */ data = NULL; for(i = 0; i < 1; i++) { data = new char[100]; /* POTENTIAL FLAW: delete the array data in the source - the bad sink deletes the array data as well */ delete [] data; } for(j = 0; j < 1; j++) { /* POTENTIAL FLAW: Possibly deleting memory twice */ delete [] data; } } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodB2G() - use badsource and goodsink in the for statements */ static void goodB2G() { int i,k; char * data; /* Initialize data */ data = NULL; for(i = 0; i < 1; i++) { data = new char[100]; /* POTENTIAL FLAW: delete the array data in the source - the bad sink deletes the array data as well */ delete [] data; } for(k = 0; k < 1; k++) { /* do nothing */ /* FIX: Don't attempt to delete the memory */ ; /* empty statement needed for some flow variants */ } } /* goodG2B() - use goodsource and badsink in the for statements */ static void goodG2B() { int h,j; char * data; /* Initialize data */ data = NULL; for(h = 0; h < 1; h++) { data = new char[100]; /* FIX: Do NOT delete the array data in the source - the bad sink deletes the array data */ } for(j = 0; j < 1; j++) { /* POTENTIAL FLAW: Possibly deleting memory twice */ delete [] data; } } void good() { goodB2G(); goodG2B(); } #endif /* OMITGOOD */ } /* close namespace */ /* Below is the main(). It is only used when building this testcase on its own for testing or for building a binary to use in testing binary analysis tools. It is not used when compiling all the testcases as one application, which is how source code analysis tools are tested. */ #ifdef INCLUDEMAIN using namespace CWE415_Double_Free__new_delete_array_char_17; /* so that we can use good and bad easily */ int main(int argc, char * argv[]) { /* seed randomness */ srand( (unsigned)time(NULL) ); #ifndef OMITGOOD printLine("Calling good()..."); good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
/*Author: Hemanth Kumar Veeranki */ /*handle: harry7*/ /*header files*/ #include<bits/stdc++.h> using namespace std; /*debugging*/ #define out1(x)cout<<#x<<" is "<<x<<endl #define out2(x,y)cout<<#x<<" is "<<x<<" "<<#y <<" is "<<y<<endl #define out3(x,y,z)cout<<#x<<" is "<<x<<" "<<#y<<" is "<<y<<" "<<#z<<" is "<<z<<endl; #define out4(a,b,c,d)cout<<#a<<" is "<<a<<" "<<#b<<" is "<<b<<" "<<#c<<" is "<<c<<" "<<#d<<" is "<<d<<endl; #define show(i,a,n) for(i=0;i<n;i++)cout<<a[i]<<" ";cout<<endl; #define sz(a) cout<<"size of "<<#a<<" is "<<a.size() #define exectime() cout<<"execution time "<<(double)(clock() - tStart)/CLOCKS_PER_SEC<<endl; /*standard values*/ #define INF 1e18 #define PI 3.14159265359 /*Frequent functions*/ #define PB push_back #define MP make_pair #define F first #define S second #define si(n) scanf("%d",&n) #define sl(n) scanf("%lld",&n) #define pu putchar #define gu getchar #define FastIn std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) /*loops and initialisation*/ #define init(a,b) memset(a,b,sizeof(a)) #define rep(i,a,b) for(i=a;i<=b;i++) #define repi(i,a,b) for(i=a;i>=b;i--) #define repdf(i,a,b,d) for(i=a;i<=b;i+=d) #define repdb(i,a,b,d) for(i=a;i>=b;i-=d) #define TC() int t;cin>>t;while(t--) /*typedef's for frequently used*/ typedef long long int ll; typedef vector<int>VI; typedef vector<ll>VLI; typedef pair<int,int> ipair; typedef pair<ll,ll> lpair; typedef unsigned long long int ull; /*space for global variables*/ #define mod 1000000007 int dp[1000006]; /*Functions */ void solve(int r,int b){ int i,j,k,h,ans=0; dp[0]=dp[1]=1; if(r>b){ r=r+b; b=r-b; r=r-b; } rep(i,1,1000) if((i*(i+1))/2>(r+b)){h=i-1;break;} rep(i,2,h) repi(j,r,0){ k=(i*(i+1))/2-j; int tmp=0; if(j>=i)tmp=(tmp+dp[j-i])%mod; if(k>=i)tmp=(tmp+dp[j])%mod; dp[j]=tmp; } int lim=(h*(h+1))/2; for(i=r;i>=0&& lim-i<=b;i--)ans=(ans+dp[i])%mod; cout<<ans%mod<<endl; } /*main code*/ int main() { FastIn; clock_t tStart = clock();/* for execution time caluclation*/ int r,b; cin>>r>>b; solve(r,b); return 0; }
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "views/ime/input_method_win.h" #include "base/basictypes.h" #include "base/logging.h" #include "base/string_util.h" #include "ui/base/keycodes/keyboard_codes.h" #include "views/events/event.h" namespace views { InputMethodWin::InputMethodWin(internal::InputMethodDelegate* delegate) : active_(false), direction_(base::i18n::UNKNOWN_DIRECTION), pending_requested_direction_(base::i18n::UNKNOWN_DIRECTION) { set_delegate(delegate); } InputMethodWin::~InputMethodWin() { if (widget()) ime_input_.DisableIME(hwnd()); } void InputMethodWin::Init(Widget* widget) { InputMethodBase::Init(widget); // Gets the initial input locale and text direction information. OnInputLangChange(0, 0); } void InputMethodWin::OnFocus() { DCHECK(!widget_focused()); InputMethodBase::OnFocus(); UpdateIMEState(); } void InputMethodWin::OnBlur() { DCHECK(widget_focused()); ConfirmCompositionText(); InputMethodBase::OnBlur(); } void InputMethodWin::DispatchKeyEvent(const KeyEvent& key) { // Handles ctrl-shift key to change text direction and layout alignment. if (ui::ImeInput::IsRTLKeyboardLayoutInstalled() && !IsTextInputTypeNone()) { ui::KeyboardCode code = key.key_code(); if (key.type() == ui::ET_KEY_PRESSED) { if (code == ui::VKEY_SHIFT) { base::i18n::TextDirection dir; if (ui::ImeInput::IsCtrlShiftPressed(&dir)) pending_requested_direction_ = dir; } else if (code != ui::VKEY_CONTROL) { pending_requested_direction_ = base::i18n::UNKNOWN_DIRECTION; } } else if (key.type() == ui::ET_KEY_RELEASED && (code == ui::VKEY_SHIFT || code == ui::VKEY_CONTROL) && pending_requested_direction_ != base::i18n::UNKNOWN_DIRECTION) { GetTextInputClient()->ChangeTextDirectionAndLayoutAlignment( pending_requested_direction_); pending_requested_direction_ = base::i18n::UNKNOWN_DIRECTION; } } DispatchKeyEventPostIME(key); } void InputMethodWin::OnTextInputTypeChanged(View* view) { if (IsViewFocused(view)) { ime_input_.CancelIME(hwnd()); UpdateIMEState(); } } void InputMethodWin::OnCaretBoundsChanged(View* view) { gfx::Rect rect; if (!IsViewFocused(view) || !GetCaretBoundsInWidget(&rect)) return; ime_input_.UpdateCaretRect(hwnd(), rect); } void InputMethodWin::CancelComposition(View* view) { if (IsViewFocused(view)) ime_input_.CancelIME(hwnd()); } std::string InputMethodWin::GetInputLocale() { return locale_; } base::i18n::TextDirection InputMethodWin::GetInputTextDirection() { return direction_; } bool InputMethodWin::IsActive() { return active_; } void InputMethodWin::FocusedViewWillChange() { ConfirmCompositionText(); } void InputMethodWin::FocusedViewDidChange() { UpdateIMEState(); } void InputMethodWin::OnInputLangChange(DWORD character_set, HKL input_language_id) { active_ = ime_input_.SetInputLanguage(); locale_ = ime_input_.GetInputLanguageName(); direction_ = ime_input_.GetTextDirection(); OnInputMethodChanged(); } LRESULT InputMethodWin::OnImeSetContext( UINT message, WPARAM wparam, LPARAM lparam, BOOL* handled) { active_ = (wparam == TRUE); if (active_) ime_input_.CreateImeWindow(hwnd()); OnInputMethodChanged(); return ime_input_.SetImeWindowStyle(hwnd(), message, wparam, lparam, handled); } LRESULT InputMethodWin::OnImeStartComposition( UINT message, WPARAM wparam, LPARAM lparam, BOOL* handled) { // We have to prevent WTL from calling ::DefWindowProc() because the function // calls ::ImmSetCompositionWindow() and ::ImmSetCandidateWindow() to // over-write the position of IME windows. *handled = TRUE; if (IsTextInputTypeNone()) return 0; // Reset the composition status and create IME windows. ime_input_.CreateImeWindow(hwnd()); ime_input_.ResetComposition(hwnd()); return 0; } LRESULT InputMethodWin::OnImeComposition( UINT message, WPARAM wparam, LPARAM lparam, BOOL* handled) { // We have to prevent WTL from calling ::DefWindowProc() because we do not // want for the IMM (Input Method Manager) to send WM_IME_CHAR messages. *handled = TRUE; if (IsTextInputTypeNone()) return 0; // At first, update the position of the IME window. ime_input_.UpdateImeWindow(hwnd()); // Retrieve the result string and its attributes of the ongoing composition // and send it to a renderer process. ui::CompositionText composition; if (ime_input_.GetResult(hwnd(), lparam, &composition.text)) { GetTextInputClient()->InsertText(composition.text); ime_input_.ResetComposition(hwnd()); // Fall though and try reading the composition string. // Japanese IMEs send a message containing both GCS_RESULTSTR and // GCS_COMPSTR, which means an ongoing composition has been finished // by the start of another composition. } // Retrieve the composition string and its attributes of the ongoing // composition and send it to a renderer process. if (ime_input_.GetComposition(hwnd(), lparam, &composition)) GetTextInputClient()->SetCompositionText(composition); return 0; } LRESULT InputMethodWin::OnImeEndComposition( UINT message, WPARAM wparam, LPARAM lparam, BOOL* handled) { // Let WTL call ::DefWindowProc() and release its resources. *handled = FALSE; if (IsTextInputTypeNone()) return 0; if (GetTextInputClient()->HasCompositionText()) GetTextInputClient()->ClearCompositionText(); ime_input_.ResetComposition(hwnd()); ime_input_.DestroyImeWindow(hwnd()); return 0; } LRESULT InputMethodWin::OnChar( UINT message, WPARAM wparam, LPARAM lparam, BOOL* handled) { *handled = TRUE; // We need to send character events to the focused text input client event if // its text input type is ui::TEXT_INPUT_TYPE_NONE. if (!GetTextInputClient()) return 0; int flags = 0; flags |= (::GetKeyState(VK_MENU) & 0x80)? ui::EF_ALT_DOWN : 0; flags |= (::GetKeyState(VK_SHIFT) & 0x80)? ui::EF_SHIFT_DOWN : 0; flags |= (::GetKeyState(VK_CONTROL) & 0x80)? ui::EF_CONTROL_DOWN : 0; GetTextInputClient()->InsertChar(static_cast<char16>(wparam), flags); return 0; } LRESULT InputMethodWin::OnDeadChar( UINT message, WPARAM wparam, LPARAM lparam, BOOL* handled) { *handled = TRUE; if (IsTextInputTypeNone()) return 0; // Shows the dead character as a composition text, so that the user can know // what dead key was pressed. ui::CompositionText composition; composition.text.assign(1, static_cast<char16>(wparam)); composition.selection = ui::Range(0, 1); composition.underlines.push_back( ui::CompositionUnderline(0, 1, SK_ColorBLACK, false)); GetTextInputClient()->SetCompositionText(composition); return 0; } void InputMethodWin::ConfirmCompositionText() { if (!IsTextInputTypeNone()) { ime_input_.CleanupComposition(hwnd()); // Though above line should confirm the client's composition text by sending // a result text to us, in case the input method and the client are in // inconsistent states, we check the client's composition state again. if (GetTextInputClient()->HasCompositionText()) GetTextInputClient()->ConfirmCompositionText(); } } void InputMethodWin::UpdateIMEState() { // Use switch here in case we are going to add more text input types. // We disable input method in password field. switch (GetTextInputType()) { case ui::TEXT_INPUT_TYPE_NONE: case ui::TEXT_INPUT_TYPE_PASSWORD: ime_input_.DisableIME(hwnd()); break; default: ime_input_.EnableIME(hwnd()); break; } } } // namespace views
#pragma once namespace Input { // esc27 del127 enter13 space32 enum KeyKind { Enter = 13, Esc = 27, Space = 32, Del = 127 }; void Init(); void InputKbd(unsigned char key, int x, int y); void ReleaseKbd(unsigned char key, int x, int y); int GetInput(unsigned char key); bool IsPressed(unsigned char key); bool IsClicked(unsigned char key); void Update(); } // namespace Input
/**************************************************************************** ** Meta object code from reading C++ file 'QvisKeyframePlotRangeWidget.h' ** ** Created: Wed Nov 4 16:17:58 2015 ** by: The Qt Meta Object Compiler version 63 (Qt 4.8.3) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include "QvisKeyframePlotRangeWidget.h" #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'QvisKeyframePlotRangeWidget.h' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 63 #error "This file was generated using the moc from 4.8.3. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif QT_BEGIN_MOC_NAMESPACE static const uint qt_meta_data_QvisKeyframePlotRangeWidget[] = { // content: 6, // revision 0, // classname 0, 0, // classinfo 1, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 1, // signalCount // signals: signature, parameters, type, tag, flags 28, 45, 45, 45, 0x05, 0 // eod }; static const char qt_meta_stringdata_QvisKeyframePlotRangeWidget[] = { "QvisKeyframePlotRangeWidget\0" "commit(QWidget*)\0\0" }; void QvisKeyframePlotRangeWidget::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { if (_c == QMetaObject::InvokeMetaMethod) { Q_ASSERT(staticMetaObject.cast(_o)); QvisKeyframePlotRangeWidget *_t = static_cast<QvisKeyframePlotRangeWidget *>(_o); switch (_id) { case 0: _t->commit((*reinterpret_cast< QWidget*(*)>(_a[1]))); break; default: ; } } } const QMetaObjectExtraData QvisKeyframePlotRangeWidget::staticMetaObjectExtraData = { 0, qt_static_metacall }; const QMetaObject QvisKeyframePlotRangeWidget::staticMetaObject = { { &QWidget::staticMetaObject, qt_meta_stringdata_QvisKeyframePlotRangeWidget, qt_meta_data_QvisKeyframePlotRangeWidget, &staticMetaObjectExtraData } }; #ifdef Q_NO_DATA_RELOCATION const QMetaObject &QvisKeyframePlotRangeWidget::getStaticMetaObject() { return staticMetaObject; } #endif //Q_NO_DATA_RELOCATION const QMetaObject *QvisKeyframePlotRangeWidget::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; } void *QvisKeyframePlotRangeWidget::qt_metacast(const char *_clname) { if (!_clname) return 0; if (!strcmp(_clname, qt_meta_stringdata_QvisKeyframePlotRangeWidget)) return static_cast<void*>(const_cast< QvisKeyframePlotRangeWidget*>(this)); return QWidget::qt_metacast(_clname); } int QvisKeyframePlotRangeWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 1) qt_static_metacall(this, _c, _id, _a); _id -= 1; } return _id; } // SIGNAL 0 void QvisKeyframePlotRangeWidget::commit(QWidget * _t1) { void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) }; QMetaObject::activate(this, &staticMetaObject, 0, _a); } QT_END_MOC_NAMESPACE
/******************************************************************************* * Copyright 2020 Intel Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions * and limitations under the License. * * * SPDX-License-Identifier: Apache-2.0 *******************************************************************************/ #include <cstdint> #include <cstdlib> #include <iostream> #include <limits> #include <vector> #include <CL/sycl.hpp> #include "cblas.h" #include "oneapi/mkl/detail/config.hpp" #include "oneapi/mkl.hpp" #include "onemkl_blas_helper.hpp" #include "reference_blas_templates.hpp" #include "test_common.hpp" #include "test_helper.hpp" #include <gtest/gtest.h> using namespace cl::sycl; using std::vector; extern std::vector<cl::sycl::device *> devices; namespace { template <typename fp, typename fp_scalar> int test(device *dev, oneapi::mkl::layout layout) { // Catch asynchronous exceptions. auto exception_handler = [](exception_list exceptions) { for (std::exception_ptr const &e : exceptions) { try { std::rethrow_exception(e); } catch (exception const &e) { std::cout << "Caught asynchronous SYCL exception during ROTG:\n" << e.what() << std::endl << "OpenCL status: " << e.get_cl_code() << std::endl; } } }; queue main_queue(*dev, exception_handler); context cxt = main_queue.get_context(); event done; std::vector<event> dependencies; // Prepare data. fp a, b, s, a_ref, b_ref, s_ref; fp_scalar c, c_ref; a = rand_scalar<fp>(); b = rand_scalar<fp>(); s = rand_scalar<fp>(); c = rand_scalar<fp_scalar>(); a_ref = a; b_ref = b; s_ref = s; c_ref = c; // Call Reference ROTG. using fp_ref = typename ref_type_info<fp>::type; ::rotg((fp_ref *)&a_ref, (fp_ref *)&b_ref, (fp_scalar *)&c_ref, (fp_ref *)&s_ref); // Call DPC++ ROTG. fp *a_p = (fp *)oneapi::mkl::malloc_shared(64, sizeof(fp), *dev, cxt); fp *b_p = (fp *)oneapi::mkl::malloc_shared(64, sizeof(fp), *dev, cxt); fp *s_p = (fp *)oneapi::mkl::malloc_shared(64, sizeof(fp), *dev, cxt); fp_scalar *c_p = (fp_scalar *)oneapi::mkl::malloc_shared(64, sizeof(fp_scalar), *dev, cxt); a_p[0] = a; b_p[0] = b; s_p[0] = s; c_p[0] = c; try { #ifdef CALL_RT_API switch (layout) { case oneapi::mkl::layout::column_major: done = oneapi::mkl::blas::column_major::rotg(main_queue, a_p, b_p, c_p, s_p, dependencies); break; case oneapi::mkl::layout::row_major: done = oneapi::mkl::blas::row_major::rotg(main_queue, a_p, b_p, c_p, s_p, dependencies); break; default: break; } done.wait(); #else switch (layout) { case oneapi::mkl::layout::column_major: TEST_RUN_CT_SELECT(main_queue, oneapi::mkl::blas::column_major::rotg, a_p, b_p, c_p, s_p, dependencies); break; case oneapi::mkl::layout::row_major: TEST_RUN_CT_SELECT(main_queue, oneapi::mkl::blas::row_major::rotg, a_p, b_p, c_p, s_p, dependencies); break; default: break; } main_queue.wait(); #endif } catch (exception const &e) { std::cout << "Caught synchronous SYCL exception during ROTG:\n" << e.what() << std::endl << "OpenCL status: " << e.get_cl_code() << std::endl; } catch (const oneapi::mkl::unimplemented &e) { return test_skipped; } catch (const std::runtime_error &error) { std::cout << "Error raised during execution of ROTG:\n" << error.what() << std::endl; } // Compare the results of reference implementation and DPC++ implementation. bool good_a = check_equal(a_p[0], a_ref, 4, std::cout); bool good_b = check_equal(b_p[0], b_ref, 4, std::cout); bool good_s = check_equal(s_p[0], s_ref, 4, std::cout); bool good_c = check_equal(c_p[0], c_ref, 4, std::cout); bool good = good_a && good_b && good_c && good_s; oneapi::mkl::free_shared(a_p, cxt); oneapi::mkl::free_shared(b_p, cxt); oneapi::mkl::free_shared(s_p, cxt); oneapi::mkl::free_shared(c_p, cxt); return (int)good; } class RotgUsmTests : public ::testing::TestWithParam<std::tuple<cl::sycl::device *, oneapi::mkl::layout>> {}; TEST_P(RotgUsmTests, RealSinglePrecision) { EXPECT_TRUEORSKIP((test<float, float>(std::get<0>(GetParam()), std::get<1>(GetParam())))); } TEST_P(RotgUsmTests, RealDoublePrecision) { EXPECT_TRUEORSKIP((test<double, double>(std::get<0>(GetParam()), std::get<1>(GetParam())))); } TEST_P(RotgUsmTests, ComplexSinglePrecision) { EXPECT_TRUEORSKIP( (test<std::complex<float>, float>(std::get<0>(GetParam()), std::get<1>(GetParam())))); } TEST_P(RotgUsmTests, ComplexDoublePrecision) { EXPECT_TRUEORSKIP( (test<std::complex<double>, double>(std::get<0>(GetParam()), std::get<1>(GetParam())))); } INSTANTIATE_TEST_SUITE_P(RotgUsmTestSuite, RotgUsmTests, ::testing::Combine(testing::ValuesIn(devices), testing::Values(oneapi::mkl::layout::column_major, oneapi::mkl::layout::row_major)), ::LayoutDeviceNamePrint()); } // anonymous namespace
// XXX uniqID XXX af507f9e5788c84ed796ba260a7033a7 XXX #include <gba_types.h> #include "bullet.hpp" #include "fixed.hpp" #include "oohara/cutting_edge_of_notion.hpp" extern const BulletStepFunc bullet_8690863efe7c1e7a074b9ca31515d7e9_af507f9e5788c84ed796ba260a7033a7[] = { stepfunc_a709677a62e4f4990b9653a27109770e_af507f9e5788c84ed796ba260a7033a7, stepfunc_7742cab2561794272306404cead64324_af507f9e5788c84ed796ba260a7033a7, stepfunc_92ccea75b91c7afacafbeee1a3469348_af507f9e5788c84ed796ba260a7033a7, stepfunc_686a7ceb6b80bd0a37687bf31721efad_af507f9e5788c84ed796ba260a7033a7, stepfunc_03a25a8cbb01125b898d7f596f01b7c1_af507f9e5788c84ed796ba260a7033a7, NULL}; extern const BulletStepFunc bullet_7848ba96ef7008c5db8dc3986ec0dcf5_af507f9e5788c84ed796ba260a7033a7[] = { stepfunc_a709677a62e4f4990b9653a27109770e_af507f9e5788c84ed796ba260a7033a7, stepfunc_fed7d8b5822b6c27a6fd988410a8290e_af507f9e5788c84ed796ba260a7033a7, stepfunc_2cc398bd33a118d61324c149c6d6ec66_af507f9e5788c84ed796ba260a7033a7, stepfunc_56505defdee021eb3496be544ae1e4ec_af507f9e5788c84ed796ba260a7033a7, stepfunc_955d7160098e09924348517bb57a616b_af507f9e5788c84ed796ba260a7033a7, NULL}; extern const BulletStepFunc bullet_fcd365e67d96d855ed3398481decbed5_af507f9e5788c84ed796ba260a7033a7[] = { stepfunc_a709677a62e4f4990b9653a27109770e_af507f9e5788c84ed796ba260a7033a7, stepfunc_13b3e09970869de3f9a0b5f23fbc302a_af507f9e5788c84ed796ba260a7033a7, stepfunc_540915180e57eebc9e43c19ba8c6048c_af507f9e5788c84ed796ba260a7033a7, stepfunc_19b745d80d968aa10f9fd1070d290fa2_af507f9e5788c84ed796ba260a7033a7, stepfunc_7f9e4e049df44078956c3f8deeea13c6_af507f9e5788c84ed796ba260a7033a7, NULL}; extern const BulletStepFunc bullet_1a4f716cad83f2708acbe3d2a1470f23_af507f9e5788c84ed796ba260a7033a7[] = { stepfunc_a709677a62e4f4990b9653a27109770e_af507f9e5788c84ed796ba260a7033a7, stepfunc_6cd13e242c9f2cfe731c8339206f65c8_af507f9e5788c84ed796ba260a7033a7, stepfunc_41d9c7fa09a44877ef827d52ee0c9044_af507f9e5788c84ed796ba260a7033a7, stepfunc_2eec58e57868ece6bca1b16db00625de_af507f9e5788c84ed796ba260a7033a7, stepfunc_7641a8ae61aeb23cc3c277f38f03477d_af507f9e5788c84ed796ba260a7033a7, NULL}; extern const BulletStepFunc bullet_3ffe4abe08e8242c352d007f7b8f13d9_af507f9e5788c84ed796ba260a7033a7[] = { stepfunc_a709677a62e4f4990b9653a27109770e_af507f9e5788c84ed796ba260a7033a7, stepfunc_e5a947db689c0dfefda03526250da4a0_af507f9e5788c84ed796ba260a7033a7, stepfunc_bde3a359acabdf1a0b232e790e3d3e32_af507f9e5788c84ed796ba260a7033a7, stepfunc_071da56b7966bf00f78a949bef9e03ff_af507f9e5788c84ed796ba260a7033a7, stepfunc_7759a0959b92f89d8219d1d3e3314dfc_af507f9e5788c84ed796ba260a7033a7, NULL}; extern const BulletStepFunc bullet_2f3c49cab2dc74e7b5eeeb4c75bb47e8_af507f9e5788c84ed796ba260a7033a7[] = { stepfunc_a709677a62e4f4990b9653a27109770e_af507f9e5788c84ed796ba260a7033a7, stepfunc_866451f64d8a9e3b14257c2204734819_af507f9e5788c84ed796ba260a7033a7, stepfunc_57da2bccf73dedaffd14745400091583_af507f9e5788c84ed796ba260a7033a7, stepfunc_78d23eddb39cf146a389fd8093917286_af507f9e5788c84ed796ba260a7033a7, stepfunc_69603691afc08096dd5e7ad7bb2fc92a_af507f9e5788c84ed796ba260a7033a7, NULL}; extern const BulletStepFunc bullet_cf4c6d24bc36fdf2e0f51403f40db1f5_af507f9e5788c84ed796ba260a7033a7[] = { stepfunc_a709677a62e4f4990b9653a27109770e_af507f9e5788c84ed796ba260a7033a7, stepfunc_dcc8094098d49485bbb6e3c9c01d26ec_af507f9e5788c84ed796ba260a7033a7, stepfunc_622feaebe19ccda5d628ddde101d91ff_af507f9e5788c84ed796ba260a7033a7, stepfunc_ea7aad2888bd6ea2d6cc5928538a64a2_af507f9e5788c84ed796ba260a7033a7, stepfunc_8d5179b05f0b0665decd93ad2057750f_af507f9e5788c84ed796ba260a7033a7, NULL}; extern const BulletStepFunc bullet_acba9c815e89e70aa1ec4e50d1a1a03c_af507f9e5788c84ed796ba260a7033a7[] = { stepfunc_a709677a62e4f4990b9653a27109770e_af507f9e5788c84ed796ba260a7033a7, stepfunc_3af6a0e6a3b76b3558faf489b3f19be5_af507f9e5788c84ed796ba260a7033a7, stepfunc_a83f9fcd516f1c904400a07703bb6015_af507f9e5788c84ed796ba260a7033a7, stepfunc_39384e278c33984f20acd7b5d7a09dc2_af507f9e5788c84ed796ba260a7033a7, stepfunc_628becdb3820cb4c329628b07d0db404_af507f9e5788c84ed796ba260a7033a7, NULL}; extern const BulletStepFunc bullet_7539e32afc96496e4ce0ec23e702916e_af507f9e5788c84ed796ba260a7033a7[] = { stepfunc_a709677a62e4f4990b9653a27109770e_af507f9e5788c84ed796ba260a7033a7, stepfunc_c28083350dc7c1a894bf932518763df7_af507f9e5788c84ed796ba260a7033a7, stepfunc_7039d3891f78374667d084dac920736f_af507f9e5788c84ed796ba260a7033a7, stepfunc_44187d8c32295fd4e3cb63e6a2033da6_af507f9e5788c84ed796ba260a7033a7, stepfunc_5c22955622de823e1754dea26e3dddfe_af507f9e5788c84ed796ba260a7033a7, NULL}; extern const BulletStepFunc bullet_8bcada1411608aeb408f8369b96b7906_af507f9e5788c84ed796ba260a7033a7[] = { stepfunc_a709677a62e4f4990b9653a27109770e_af507f9e5788c84ed796ba260a7033a7, stepfunc_9cbba1f357ece7a8554b3666c927f00a_af507f9e5788c84ed796ba260a7033a7, stepfunc_842908a731f21a60b92f8d51561dfe66_af507f9e5788c84ed796ba260a7033a7, stepfunc_bd02da9978e155a68553317a540ed412_af507f9e5788c84ed796ba260a7033a7, stepfunc_790395326ef8152dd68178fe83d9952b_af507f9e5788c84ed796ba260a7033a7, NULL}; extern const BulletStepFunc bullet_d99f9b850803f93dd57cd6412176b6f8_af507f9e5788c84ed796ba260a7033a7[] = { stepfunc_a709677a62e4f4990b9653a27109770e_af507f9e5788c84ed796ba260a7033a7, stepfunc_5b211b19401f6a0b9814fb0a16c356de_af507f9e5788c84ed796ba260a7033a7, stepfunc_eb87c7af49e8a024200138a2e9dd2090_af507f9e5788c84ed796ba260a7033a7, stepfunc_b288c780d37f96e21b83ef31d3887da2_af507f9e5788c84ed796ba260a7033a7, stepfunc_721dd13e5deb5fbb21ca9a8be9158097_af507f9e5788c84ed796ba260a7033a7, NULL}; extern const BulletStepFunc bullet_9faa370433def7c9847d3f6f0b62f624_af507f9e5788c84ed796ba260a7033a7[] = { stepfunc_a709677a62e4f4990b9653a27109770e_af507f9e5788c84ed796ba260a7033a7, stepfunc_11211a95966b2ab7f9d77aa376a7a588_af507f9e5788c84ed796ba260a7033a7, stepfunc_a9bd35cbeb0a66dd9da1f8ed70e3c42b_af507f9e5788c84ed796ba260a7033a7, stepfunc_fa8cac91ed21d0e4c07801433bc9d58a_af507f9e5788c84ed796ba260a7033a7, stepfunc_b0c0e1948334fa109d4eeab0810ed973_af507f9e5788c84ed796ba260a7033a7, NULL}; extern const BulletStepFunc bullet_aa7133376ce2c466e1e7a89691ad0bcf_af507f9e5788c84ed796ba260a7033a7[] = { stepfunc_4b32421d681e4189cb57de5502b5edc0_af507f9e5788c84ed796ba260a7033a7, stepfunc_204d69c4aed20b817681714f74c0037d_af507f9e5788c84ed796ba260a7033a7, stepfunc_a6cef6cfcf75986fbd07f283ddb1d3b1_af507f9e5788c84ed796ba260a7033a7, stepfunc_07426dabc9299ccaee218936d67147ff_af507f9e5788c84ed796ba260a7033a7, stepfunc_9cada49b03620571c061480a4300121f_af507f9e5788c84ed796ba260a7033a7, stepfunc_c8cf26702b980a6cf55d3ffc870f93c4_af507f9e5788c84ed796ba260a7033a7, stepfunc_8d3ea35018c5596ceb0786fa406b2d24_af507f9e5788c84ed796ba260a7033a7, stepfunc_1b1bcfd013f28da8159e96f6f66cacad_af507f9e5788c84ed796ba260a7033a7, stepfunc_4b32421d681e4189cb57de5502b5edc0_af507f9e5788c84ed796ba260a7033a7, stepfunc_204d69c4aed20b817681714f74c0037d_af507f9e5788c84ed796ba260a7033a7, stepfunc_a6cef6cfcf75986fbd07f283ddb1d3b1_af507f9e5788c84ed796ba260a7033a7, stepfunc_07426dabc9299ccaee218936d67147ff_af507f9e5788c84ed796ba260a7033a7, stepfunc_9cada49b03620571c061480a4300121f_af507f9e5788c84ed796ba260a7033a7, stepfunc_c8cf26702b980a6cf55d3ffc870f93c4_af507f9e5788c84ed796ba260a7033a7, stepfunc_8d3ea35018c5596ceb0786fa406b2d24_af507f9e5788c84ed796ba260a7033a7, stepfunc_1b1bcfd013f28da8159e96f6f66cacad_af507f9e5788c84ed796ba260a7033a7, stepfunc_4b32421d681e4189cb57de5502b5edc0_af507f9e5788c84ed796ba260a7033a7, stepfunc_204d69c4aed20b817681714f74c0037d_af507f9e5788c84ed796ba260a7033a7, stepfunc_a6cef6cfcf75986fbd07f283ddb1d3b1_af507f9e5788c84ed796ba260a7033a7, stepfunc_07426dabc9299ccaee218936d67147ff_af507f9e5788c84ed796ba260a7033a7, stepfunc_9cada49b03620571c061480a4300121f_af507f9e5788c84ed796ba260a7033a7, stepfunc_c8cf26702b980a6cf55d3ffc870f93c4_af507f9e5788c84ed796ba260a7033a7, stepfunc_8d3ea35018c5596ceb0786fa406b2d24_af507f9e5788c84ed796ba260a7033a7, stepfunc_1b1bcfd013f28da8159e96f6f66cacad_af507f9e5788c84ed796ba260a7033a7, stepfunc_4b32421d681e4189cb57de5502b5edc0_af507f9e5788c84ed796ba260a7033a7, stepfunc_204d69c4aed20b817681714f74c0037d_af507f9e5788c84ed796ba260a7033a7, stepfunc_a6cef6cfcf75986fbd07f283ddb1d3b1_af507f9e5788c84ed796ba260a7033a7, stepfunc_07426dabc9299ccaee218936d67147ff_af507f9e5788c84ed796ba260a7033a7, stepfunc_9cada49b03620571c061480a4300121f_af507f9e5788c84ed796ba260a7033a7, stepfunc_c8cf26702b980a6cf55d3ffc870f93c4_af507f9e5788c84ed796ba260a7033a7, stepfunc_8d3ea35018c5596ceb0786fa406b2d24_af507f9e5788c84ed796ba260a7033a7, stepfunc_1b1bcfd013f28da8159e96f6f66cacad_af507f9e5788c84ed796ba260a7033a7, stepfunc_4b32421d681e4189cb57de5502b5edc0_af507f9e5788c84ed796ba260a7033a7, stepfunc_204d69c4aed20b817681714f74c0037d_af507f9e5788c84ed796ba260a7033a7, stepfunc_a6cef6cfcf75986fbd07f283ddb1d3b1_af507f9e5788c84ed796ba260a7033a7, stepfunc_07426dabc9299ccaee218936d67147ff_af507f9e5788c84ed796ba260a7033a7, stepfunc_9cada49b03620571c061480a4300121f_af507f9e5788c84ed796ba260a7033a7, stepfunc_c8cf26702b980a6cf55d3ffc870f93c4_af507f9e5788c84ed796ba260a7033a7, stepfunc_8d3ea35018c5596ceb0786fa406b2d24_af507f9e5788c84ed796ba260a7033a7, stepfunc_1b1bcfd013f28da8159e96f6f66cacad_af507f9e5788c84ed796ba260a7033a7, stepfunc_4b32421d681e4189cb57de5502b5edc0_af507f9e5788c84ed796ba260a7033a7, stepfunc_204d69c4aed20b817681714f74c0037d_af507f9e5788c84ed796ba260a7033a7, stepfunc_a6cef6cfcf75986fbd07f283ddb1d3b1_af507f9e5788c84ed796ba260a7033a7, stepfunc_07426dabc9299ccaee218936d67147ff_af507f9e5788c84ed796ba260a7033a7, stepfunc_9cada49b03620571c061480a4300121f_af507f9e5788c84ed796ba260a7033a7, stepfunc_c8cf26702b980a6cf55d3ffc870f93c4_af507f9e5788c84ed796ba260a7033a7, stepfunc_8d3ea35018c5596ceb0786fa406b2d24_af507f9e5788c84ed796ba260a7033a7, stepfunc_1b1bcfd013f28da8159e96f6f66cacad_af507f9e5788c84ed796ba260a7033a7, stepfunc_4b32421d681e4189cb57de5502b5edc0_af507f9e5788c84ed796ba260a7033a7, stepfunc_204d69c4aed20b817681714f74c0037d_af507f9e5788c84ed796ba260a7033a7, stepfunc_a6cef6cfcf75986fbd07f283ddb1d3b1_af507f9e5788c84ed796ba260a7033a7, stepfunc_07426dabc9299ccaee218936d67147ff_af507f9e5788c84ed796ba260a7033a7, stepfunc_9cada49b03620571c061480a4300121f_af507f9e5788c84ed796ba260a7033a7, stepfunc_c8cf26702b980a6cf55d3ffc870f93c4_af507f9e5788c84ed796ba260a7033a7, stepfunc_8d3ea35018c5596ceb0786fa406b2d24_af507f9e5788c84ed796ba260a7033a7, stepfunc_1b1bcfd013f28da8159e96f6f66cacad_af507f9e5788c84ed796ba260a7033a7, stepfunc_4b32421d681e4189cb57de5502b5edc0_af507f9e5788c84ed796ba260a7033a7, stepfunc_204d69c4aed20b817681714f74c0037d_af507f9e5788c84ed796ba260a7033a7, stepfunc_a6cef6cfcf75986fbd07f283ddb1d3b1_af507f9e5788c84ed796ba260a7033a7, stepfunc_07426dabc9299ccaee218936d67147ff_af507f9e5788c84ed796ba260a7033a7, stepfunc_9cada49b03620571c061480a4300121f_af507f9e5788c84ed796ba260a7033a7, stepfunc_c8cf26702b980a6cf55d3ffc870f93c4_af507f9e5788c84ed796ba260a7033a7, stepfunc_8d3ea35018c5596ceb0786fa406b2d24_af507f9e5788c84ed796ba260a7033a7, stepfunc_1b1bcfd013f28da8159e96f6f66cacad_af507f9e5788c84ed796ba260a7033a7, stepfunc_4b32421d681e4189cb57de5502b5edc0_af507f9e5788c84ed796ba260a7033a7, stepfunc_204d69c4aed20b817681714f74c0037d_af507f9e5788c84ed796ba260a7033a7, stepfunc_a6cef6cfcf75986fbd07f283ddb1d3b1_af507f9e5788c84ed796ba260a7033a7, stepfunc_07426dabc9299ccaee218936d67147ff_af507f9e5788c84ed796ba260a7033a7, stepfunc_9cada49b03620571c061480a4300121f_af507f9e5788c84ed796ba260a7033a7, stepfunc_c8cf26702b980a6cf55d3ffc870f93c4_af507f9e5788c84ed796ba260a7033a7, stepfunc_8d3ea35018c5596ceb0786fa406b2d24_af507f9e5788c84ed796ba260a7033a7, stepfunc_1b1bcfd013f28da8159e96f6f66cacad_af507f9e5788c84ed796ba260a7033a7, stepfunc_4b32421d681e4189cb57de5502b5edc0_af507f9e5788c84ed796ba260a7033a7, stepfunc_204d69c4aed20b817681714f74c0037d_af507f9e5788c84ed796ba260a7033a7, stepfunc_a6cef6cfcf75986fbd07f283ddb1d3b1_af507f9e5788c84ed796ba260a7033a7, stepfunc_07426dabc9299ccaee218936d67147ff_af507f9e5788c84ed796ba260a7033a7, stepfunc_9cada49b03620571c061480a4300121f_af507f9e5788c84ed796ba260a7033a7, stepfunc_c8cf26702b980a6cf55d3ffc870f93c4_af507f9e5788c84ed796ba260a7033a7, stepfunc_8d3ea35018c5596ceb0786fa406b2d24_af507f9e5788c84ed796ba260a7033a7, stepfunc_1b1bcfd013f28da8159e96f6f66cacad_af507f9e5788c84ed796ba260a7033a7, stepfunc_4b32421d681e4189cb57de5502b5edc0_af507f9e5788c84ed796ba260a7033a7, stepfunc_204d69c4aed20b817681714f74c0037d_af507f9e5788c84ed796ba260a7033a7, stepfunc_a6cef6cfcf75986fbd07f283ddb1d3b1_af507f9e5788c84ed796ba260a7033a7, stepfunc_07426dabc9299ccaee218936d67147ff_af507f9e5788c84ed796ba260a7033a7, stepfunc_9cada49b03620571c061480a4300121f_af507f9e5788c84ed796ba260a7033a7, stepfunc_c8cf26702b980a6cf55d3ffc870f93c4_af507f9e5788c84ed796ba260a7033a7, stepfunc_8d3ea35018c5596ceb0786fa406b2d24_af507f9e5788c84ed796ba260a7033a7, stepfunc_1b1bcfd013f28da8159e96f6f66cacad_af507f9e5788c84ed796ba260a7033a7, stepfunc_4b32421d681e4189cb57de5502b5edc0_af507f9e5788c84ed796ba260a7033a7, stepfunc_204d69c4aed20b817681714f74c0037d_af507f9e5788c84ed796ba260a7033a7, stepfunc_a6cef6cfcf75986fbd07f283ddb1d3b1_af507f9e5788c84ed796ba260a7033a7, stepfunc_07426dabc9299ccaee218936d67147ff_af507f9e5788c84ed796ba260a7033a7, stepfunc_9cada49b03620571c061480a4300121f_af507f9e5788c84ed796ba260a7033a7, stepfunc_c8cf26702b980a6cf55d3ffc870f93c4_af507f9e5788c84ed796ba260a7033a7, stepfunc_8d3ea35018c5596ceb0786fa406b2d24_af507f9e5788c84ed796ba260a7033a7, stepfunc_1b1bcfd013f28da8159e96f6f66cacad_af507f9e5788c84ed796ba260a7033a7, stepfunc_4b32421d681e4189cb57de5502b5edc0_af507f9e5788c84ed796ba260a7033a7, stepfunc_204d69c4aed20b817681714f74c0037d_af507f9e5788c84ed796ba260a7033a7, stepfunc_a6cef6cfcf75986fbd07f283ddb1d3b1_af507f9e5788c84ed796ba260a7033a7, stepfunc_07426dabc9299ccaee218936d67147ff_af507f9e5788c84ed796ba260a7033a7, stepfunc_9cada49b03620571c061480a4300121f_af507f9e5788c84ed796ba260a7033a7, stepfunc_c8cf26702b980a6cf55d3ffc870f93c4_af507f9e5788c84ed796ba260a7033a7, stepfunc_8d3ea35018c5596ceb0786fa406b2d24_af507f9e5788c84ed796ba260a7033a7, stepfunc_1b1bcfd013f28da8159e96f6f66cacad_af507f9e5788c84ed796ba260a7033a7, stepfunc_4b32421d681e4189cb57de5502b5edc0_af507f9e5788c84ed796ba260a7033a7, stepfunc_204d69c4aed20b817681714f74c0037d_af507f9e5788c84ed796ba260a7033a7, stepfunc_a6cef6cfcf75986fbd07f283ddb1d3b1_af507f9e5788c84ed796ba260a7033a7, stepfunc_07426dabc9299ccaee218936d67147ff_af507f9e5788c84ed796ba260a7033a7, stepfunc_9cada49b03620571c061480a4300121f_af507f9e5788c84ed796ba260a7033a7, stepfunc_c8cf26702b980a6cf55d3ffc870f93c4_af507f9e5788c84ed796ba260a7033a7, stepfunc_8d3ea35018c5596ceb0786fa406b2d24_af507f9e5788c84ed796ba260a7033a7, stepfunc_1b1bcfd013f28da8159e96f6f66cacad_af507f9e5788c84ed796ba260a7033a7, stepfunc_4b32421d681e4189cb57de5502b5edc0_af507f9e5788c84ed796ba260a7033a7, stepfunc_204d69c4aed20b817681714f74c0037d_af507f9e5788c84ed796ba260a7033a7, stepfunc_a6cef6cfcf75986fbd07f283ddb1d3b1_af507f9e5788c84ed796ba260a7033a7, stepfunc_07426dabc9299ccaee218936d67147ff_af507f9e5788c84ed796ba260a7033a7, stepfunc_9cada49b03620571c061480a4300121f_af507f9e5788c84ed796ba260a7033a7, stepfunc_c8cf26702b980a6cf55d3ffc870f93c4_af507f9e5788c84ed796ba260a7033a7, stepfunc_8d3ea35018c5596ceb0786fa406b2d24_af507f9e5788c84ed796ba260a7033a7, stepfunc_1b1bcfd013f28da8159e96f6f66cacad_af507f9e5788c84ed796ba260a7033a7, stepfunc_ae9f735c6401a821cc04ce1cd68278bf_af507f9e5788c84ed796ba260a7033a7, NULL}; void stepfunc_a709677a62e4f4990b9653a27109770e_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { p->wait = static_cast<u16>(((15.0))); } void stepfunc_7742cab2561794272306404cead64324_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle((90.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((0.8 + 1.8 * 1.0)) * (1.73205) - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(((15.0))); } void stepfunc_92ccea75b91c7afacafbeee1a3469348_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle((-30.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((0.8 + 1.8 * 1.0)) - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(((15.0))); } void stepfunc_686a7ceb6b80bd0a37687bf31721efad_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle(-(90.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((0.8 + 1.8 * 1.0)) * (1.73205) - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(((15.0)) * 3.0); } void stepfunc_03a25a8cbb01125b898d7f596f01b7c1_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle(-(-30.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((0.8 + 1.8 * 1.0)) - p->getSpeed();p->setAccel(speed, life);} } void stepfunc_fed7d8b5822b6c27a6fd988410a8290e_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle((-90.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((0.8 + 1.8 * 1.0)) * (1.73205) - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(((15.0))); } void stepfunc_2cc398bd33a118d61324c149c6d6ec66_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle((30.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((0.8 + 1.8 * 1.0)) - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(((15.0))); } void stepfunc_56505defdee021eb3496be544ae1e4ec_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle(-(-90.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((0.8 + 1.8 * 1.0)) * (1.73205) - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(((15.0)) * 3.0); } void stepfunc_955d7160098e09924348517bb57a616b_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle(-(30.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((0.8 + 1.8 * 1.0)) - p->getSpeed();p->setAccel(speed, life);} } void stepfunc_13b3e09970869de3f9a0b5f23fbc302a_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle((0.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((0.8 + 1.8 * 1.0)) * (1.0) - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(((15.0))); } void stepfunc_540915180e57eebc9e43c19ba8c6048c_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle((0.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((0.8 + 1.8 * 1.0)) - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(((15.0))); } void stepfunc_19b745d80d968aa10f9fd1070d290fa2_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle(-(0.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((0.8 + 1.8 * 1.0)) * (1.0) - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(((15.0)) * 3.0); } void stepfunc_7f9e4e049df44078956c3f8deeea13c6_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle(-(0.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((0.8 + 1.8 * 1.0)) - p->getSpeed();p->setAccel(speed, life);} } void stepfunc_6cd13e242c9f2cfe731c8339206f65c8_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle((90.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((1.0 + 1.8 * 1.0)) * (1.73205) - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(((15.0))); } void stepfunc_41d9c7fa09a44877ef827d52ee0c9044_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle((-30.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((1.0 + 1.8 * 1.0)) - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(((15.0))); } void stepfunc_2eec58e57868ece6bca1b16db00625de_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle(-(90.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((1.0 + 1.8 * 1.0)) * (1.73205) - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(((15.0)) * 3.0); } void stepfunc_7641a8ae61aeb23cc3c277f38f03477d_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle(-(-30.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((1.0 + 1.8 * 1.0)) - p->getSpeed();p->setAccel(speed, life);} } void stepfunc_e5a947db689c0dfefda03526250da4a0_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle((-90.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((1.0 + 1.8 * 1.0)) * (1.73205) - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(((15.0))); } void stepfunc_bde3a359acabdf1a0b232e790e3d3e32_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle((30.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((1.0 + 1.8 * 1.0)) - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(((15.0))); } void stepfunc_071da56b7966bf00f78a949bef9e03ff_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle(-(-90.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((1.0 + 1.8 * 1.0)) * (1.73205) - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(((15.0)) * 3.0); } void stepfunc_7759a0959b92f89d8219d1d3e3314dfc_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle(-(30.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((1.0 + 1.8 * 1.0)) - p->getSpeed();p->setAccel(speed, life);} } void stepfunc_866451f64d8a9e3b14257c2204734819_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle((0.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((1.0 + 1.8 * 1.0)) * (1.0) - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(((15.0))); } void stepfunc_57da2bccf73dedaffd14745400091583_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle((0.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((1.0 + 1.8 * 1.0)) - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(((15.0))); } void stepfunc_78d23eddb39cf146a389fd8093917286_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle(-(0.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((1.0 + 1.8 * 1.0)) * (1.0) - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(((15.0)) * 3.0); } void stepfunc_69603691afc08096dd5e7ad7bb2fc92a_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle(-(0.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((1.0 + 1.8 * 1.0)) - p->getSpeed();p->setAccel(speed, life);} } void stepfunc_dcc8094098d49485bbb6e3c9c01d26ec_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle((90.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((1.4 + 1.8 * 1.0)) * (1.73205) - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(((15.0))); } void stepfunc_622feaebe19ccda5d628ddde101d91ff_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle((-30.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((1.4 + 1.8 * 1.0)) - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(((15.0))); } void stepfunc_ea7aad2888bd6ea2d6cc5928538a64a2_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle(-(90.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((1.4 + 1.8 * 1.0)) * (1.73205) - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(((15.0)) * 3.0); } void stepfunc_8d5179b05f0b0665decd93ad2057750f_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle(-(-30.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((1.4 + 1.8 * 1.0)) - p->getSpeed();p->setAccel(speed, life);} } void stepfunc_3af6a0e6a3b76b3558faf489b3f19be5_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle((-90.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((1.4 + 1.8 * 1.0)) * (1.73205) - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(((15.0))); } void stepfunc_a83f9fcd516f1c904400a07703bb6015_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle((30.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((1.4 + 1.8 * 1.0)) - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(((15.0))); } void stepfunc_39384e278c33984f20acd7b5d7a09dc2_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle(-(-90.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((1.4 + 1.8 * 1.0)) * (1.73205) - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(((15.0)) * 3.0); } void stepfunc_628becdb3820cb4c329628b07d0db404_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle(-(30.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((1.4 + 1.8 * 1.0)) - p->getSpeed();p->setAccel(speed, life);} } void stepfunc_c28083350dc7c1a894bf932518763df7_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle((0.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((1.4 + 1.8 * 1.0)) * (1.0) - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(((15.0))); } void stepfunc_7039d3891f78374667d084dac920736f_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle((0.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((1.4 + 1.8 * 1.0)) - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(((15.0))); } void stepfunc_44187d8c32295fd4e3cb63e6a2033da6_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle(-(0.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((1.4 + 1.8 * 1.0)) * (1.0) - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(((15.0)) * 3.0); } void stepfunc_5c22955622de823e1754dea26e3dddfe_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle(-(0.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((1.4 + 1.8 * 1.0)) - p->getSpeed();p->setAccel(speed, life);} } void stepfunc_9cbba1f357ece7a8554b3666c927f00a_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle((90.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((1.2 + 1.8 * 1.0)) * (1.73205) - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(((15.0))); } void stepfunc_842908a731f21a60b92f8d51561dfe66_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle((-30.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((1.2 + 1.8 * 1.0)) - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(((15.0))); } void stepfunc_bd02da9978e155a68553317a540ed412_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle(-(90.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((1.2 + 1.8 * 1.0)) * (1.73205) - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(((15.0)) * 3.0); } void stepfunc_790395326ef8152dd68178fe83d9952b_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle(-(-30.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((1.2 + 1.8 * 1.0)) - p->getSpeed();p->setAccel(speed, life);} } void stepfunc_5b211b19401f6a0b9814fb0a16c356de_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle((-90.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((1.2 + 1.8 * 1.0)) * (1.73205) - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(((15.0))); } void stepfunc_eb87c7af49e8a024200138a2e9dd2090_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle((30.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((1.2 + 1.8 * 1.0)) - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(((15.0))); } void stepfunc_b288c780d37f96e21b83ef31d3887da2_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle(-(-90.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((1.2 + 1.8 * 1.0)) * (1.73205) - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(((15.0)) * 3.0); } void stepfunc_721dd13e5deb5fbb21ca9a8be9158097_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle(-(30.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((1.2 + 1.8 * 1.0)) - p->getSpeed();p->setAccel(speed, life);} } void stepfunc_11211a95966b2ab7f9d77aa376a7a588_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle((0.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((1.2 + 1.8 * 1.0)) * (1.0) - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(((15.0))); } void stepfunc_a9bd35cbeb0a66dd9da1f8ed70e3c42b_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle((0.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((1.2 + 1.8 * 1.0)) - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(((15.0))); } void stepfunc_fa8cac91ed21d0e4c07801433bc9d58a_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle(-(0.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((1.2 + 1.8 * 1.0)) * (1.0) - p->getSpeed();p->setAccel(speed, life);} p->wait = static_cast<u16>(((15.0)) * 3.0); } void stepfunc_b0c0e1948334fa109d4eeab0810ed973_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { u16 life = static_cast<u16>(1.0); FixedPointNum speed = p->getAngle() + (FixedPointNum::degree2angle(-(0.0))) - p->getAngle();p->setRound(speed, life);} { u16 life = static_cast<u16>(1.0); FixedPointNum speed = ((1.2 + 1.8 * 1.0)) - p->getSpeed();p->setAccel(speed, life);} } void stepfunc_4b32421d681e4189cb57de5502b5edc0_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(40.0)); p->lastBulletSpeed = ((1.2 + 1.8 * 1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_d99f9b850803f93dd57cd6412176b6f8_af507f9e5788c84ed796ba260a7033a7); } } { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(20.0)); p->lastBulletSpeed = ((1.2 + 1.8 * 1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_d99f9b850803f93dd57cd6412176b6f8_af507f9e5788c84ed796ba260a7033a7); } } { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(0.0)); p->lastBulletSpeed = ((1.2 + 1.8 * 1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_9faa370433def7c9847d3f6f0b62f624_af507f9e5788c84ed796ba260a7033a7); } } { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(-20.0)); p->lastBulletSpeed = ((1.2 + 1.8 * 1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_8bcada1411608aeb408f8369b96b7906_af507f9e5788c84ed796ba260a7033a7); } } { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(-40.0)); p->lastBulletSpeed = ((1.2 + 1.8 * 1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_8bcada1411608aeb408f8369b96b7906_af507f9e5788c84ed796ba260a7033a7); } } p->wait = static_cast<u16>(4.0); } void stepfunc_204d69c4aed20b817681714f74c0037d_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(45.0)); p->lastBulletSpeed = ((1.2 + 1.8 * 1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_d99f9b850803f93dd57cd6412176b6f8_af507f9e5788c84ed796ba260a7033a7); } } { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(15.0)); p->lastBulletSpeed = ((1.2 + 1.8 * 1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_d99f9b850803f93dd57cd6412176b6f8_af507f9e5788c84ed796ba260a7033a7); } } { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(-15.0)); p->lastBulletSpeed = ((1.2 + 1.8 * 1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_8bcada1411608aeb408f8369b96b7906_af507f9e5788c84ed796ba260a7033a7); } } { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(-45.0)); p->lastBulletSpeed = ((1.2 + 1.8 * 1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_8bcada1411608aeb408f8369b96b7906_af507f9e5788c84ed796ba260a7033a7); } } p->wait = static_cast<u16>(4.0); } void stepfunc_a6cef6cfcf75986fbd07f283ddb1d3b1_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(40.0)); p->lastBulletSpeed = ((1.4 + 1.8 * 1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_acba9c815e89e70aa1ec4e50d1a1a03c_af507f9e5788c84ed796ba260a7033a7); } } { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(20.0)); p->lastBulletSpeed = ((1.4 + 1.8 * 1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_acba9c815e89e70aa1ec4e50d1a1a03c_af507f9e5788c84ed796ba260a7033a7); } } { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(0.0)); p->lastBulletSpeed = ((1.4 + 1.8 * 1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_7539e32afc96496e4ce0ec23e702916e_af507f9e5788c84ed796ba260a7033a7); } } { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(-20.0)); p->lastBulletSpeed = ((1.4 + 1.8 * 1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_cf4c6d24bc36fdf2e0f51403f40db1f5_af507f9e5788c84ed796ba260a7033a7); } } { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(-40.0)); p->lastBulletSpeed = ((1.4 + 1.8 * 1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_cf4c6d24bc36fdf2e0f51403f40db1f5_af507f9e5788c84ed796ba260a7033a7); } } p->wait = static_cast<u16>(4.0); } void stepfunc_07426dabc9299ccaee218936d67147ff_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(45.0)); p->lastBulletSpeed = ((1.4 + 1.8 * 1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_acba9c815e89e70aa1ec4e50d1a1a03c_af507f9e5788c84ed796ba260a7033a7); } } { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(15.0)); p->lastBulletSpeed = ((1.4 + 1.8 * 1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_acba9c815e89e70aa1ec4e50d1a1a03c_af507f9e5788c84ed796ba260a7033a7); } } { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(-15.0)); p->lastBulletSpeed = ((1.4 + 1.8 * 1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_cf4c6d24bc36fdf2e0f51403f40db1f5_af507f9e5788c84ed796ba260a7033a7); } } { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(-45.0)); p->lastBulletSpeed = ((1.4 + 1.8 * 1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_cf4c6d24bc36fdf2e0f51403f40db1f5_af507f9e5788c84ed796ba260a7033a7); } } p->wait = static_cast<u16>(4.0); } void stepfunc_9cada49b03620571c061480a4300121f_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(40.0)); p->lastBulletSpeed = ((1.0 + 1.8 * 1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_3ffe4abe08e8242c352d007f7b8f13d9_af507f9e5788c84ed796ba260a7033a7); } } { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(20.0)); p->lastBulletSpeed = ((1.0 + 1.8 * 1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_3ffe4abe08e8242c352d007f7b8f13d9_af507f9e5788c84ed796ba260a7033a7); } } { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(0.0)); p->lastBulletSpeed = ((1.0 + 1.8 * 1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_2f3c49cab2dc74e7b5eeeb4c75bb47e8_af507f9e5788c84ed796ba260a7033a7); } } { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(-20.0)); p->lastBulletSpeed = ((1.0 + 1.8 * 1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_1a4f716cad83f2708acbe3d2a1470f23_af507f9e5788c84ed796ba260a7033a7); } } { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(-40.0)); p->lastBulletSpeed = ((1.0 + 1.8 * 1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_1a4f716cad83f2708acbe3d2a1470f23_af507f9e5788c84ed796ba260a7033a7); } } p->wait = static_cast<u16>(4.0); } void stepfunc_c8cf26702b980a6cf55d3ffc870f93c4_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(45.0)); p->lastBulletSpeed = ((1.0 + 1.8 * 1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_3ffe4abe08e8242c352d007f7b8f13d9_af507f9e5788c84ed796ba260a7033a7); } } { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(15.0)); p->lastBulletSpeed = ((1.0 + 1.8 * 1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_3ffe4abe08e8242c352d007f7b8f13d9_af507f9e5788c84ed796ba260a7033a7); } } { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(-15.0)); p->lastBulletSpeed = ((1.0 + 1.8 * 1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_1a4f716cad83f2708acbe3d2a1470f23_af507f9e5788c84ed796ba260a7033a7); } } { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(-45.0)); p->lastBulletSpeed = ((1.0 + 1.8 * 1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_1a4f716cad83f2708acbe3d2a1470f23_af507f9e5788c84ed796ba260a7033a7); } } p->wait = static_cast<u16>(4.0); } void stepfunc_8d3ea35018c5596ceb0786fa406b2d24_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(40.0)); p->lastBulletSpeed = ((0.8 + 1.8 * 1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_7848ba96ef7008c5db8dc3986ec0dcf5_af507f9e5788c84ed796ba260a7033a7); } } { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(20.0)); p->lastBulletSpeed = ((0.8 + 1.8 * 1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_7848ba96ef7008c5db8dc3986ec0dcf5_af507f9e5788c84ed796ba260a7033a7); } } { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(0.0)); p->lastBulletSpeed = ((0.8 + 1.8 * 1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_fcd365e67d96d855ed3398481decbed5_af507f9e5788c84ed796ba260a7033a7); } } { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(-20.0)); p->lastBulletSpeed = ((0.8 + 1.8 * 1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_8690863efe7c1e7a074b9ca31515d7e9_af507f9e5788c84ed796ba260a7033a7); } } { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(-40.0)); p->lastBulletSpeed = ((0.8 + 1.8 * 1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_8690863efe7c1e7a074b9ca31515d7e9_af507f9e5788c84ed796ba260a7033a7); } } p->wait = static_cast<u16>(4.0); } void stepfunc_1b1bcfd013f28da8159e96f6f66cacad_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(45.0)); p->lastBulletSpeed = ((0.8 + 1.8 * 1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_7848ba96ef7008c5db8dc3986ec0dcf5_af507f9e5788c84ed796ba260a7033a7); } } { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(15.0)); p->lastBulletSpeed = ((0.8 + 1.8 * 1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_7848ba96ef7008c5db8dc3986ec0dcf5_af507f9e5788c84ed796ba260a7033a7); } } { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(-15.0)); p->lastBulletSpeed = ((0.8 + 1.8 * 1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_8690863efe7c1e7a074b9ca31515d7e9_af507f9e5788c84ed796ba260a7033a7); } } { BulletInfo *bi; p->lastBulletAngle = SelfPos::getAngle(p) + (FixedPointNum::degree2angle(-45.0)); p->lastBulletSpeed = ((0.8 + 1.8 * 1.0)); bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(p->getType() << 1, p->getPosX(), p->getPosY(), p->lastBulletAngle, p->lastBulletSpeed, bullet_8690863efe7c1e7a074b9ca31515d7e9_af507f9e5788c84ed796ba260a7033a7); } } p->wait = static_cast<u16>(4.0); } void stepfunc_ae9f735c6401a821cc04ce1cd68278bf_af507f9e5788c84ed796ba260a7033a7(BulletInfo *p) { ListBullets::stepFuncDrop(p);} BulletInfo *genBulletFunc_af507f9e5788c84ed796ba260a7033a7(FixedPointNum posx, FixedPointNum posy) { BulletInfo * bi; bi = ListBullets::makeNewBullet(); if (bi != NULL) { bi->initialize(BULLET_TYPE_ROOT, posx, posy, BulletInfo::DEFAULT_ANGLE, 0, bullet_aa7133376ce2c466e1e7a89691ad0bcf_af507f9e5788c84ed796ba260a7033a7); } return bi;}
/* * Copyright 2013 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include "include/core/SkStrokeRec.h" #include "src/core/SkRRectPriv.h" #include "src/gpu/GrCaps.h" #include "src/gpu/GrDrawOpTest.h" #include "src/gpu/GrGeometryProcessor.h" #include "src/gpu/GrOpFlushState.h" #include "src/gpu/GrProcessor.h" #include "src/gpu/GrProgramInfo.h" #include "src/gpu/GrResourceProvider.h" #include "src/gpu/GrShaderCaps.h" #include "src/gpu/GrStyle.h" #include "src/gpu/GrVertexWriter.h" #include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h" #include "src/gpu/glsl/GrGLSLGeometryProcessor.h" #include "src/gpu/glsl/GrGLSLProgramDataManager.h" #include "src/gpu/glsl/GrGLSLUniformHandler.h" #include "src/gpu/glsl/GrGLSLVarying.h" #include "src/gpu/glsl/GrGLSLVertexGeoBuilder.h" #include "src/gpu/ops/GrMeshDrawOp.h" #include "src/gpu/ops/GrOvalOpFactory.h" #include "src/gpu/ops/GrSimpleMeshDrawOpHelper.h" #include <utility> namespace { static inline bool circle_stays_circle(const SkMatrix& m) { return m.isSimilarity(); } // Produces TriStrip vertex data for an origin-centered rectangle from [-x, -y] to [x, y] static inline GrVertexWriter::TriStrip<float> origin_centered_tri_strip(float x, float y) { return GrVertexWriter::TriStrip<float>{ -x, -y, x, y }; }; } /////////////////////////////////////////////////////////////////////////////// /** * The output of this effect is a modulation of the input color and coverage for a circle. It * operates in a space normalized by the circle radius (outer radius in the case of a stroke) * with origin at the circle center. Three vertex attributes are used: * vec2f : position in device space of the bounding geometry vertices * vec4ub: color * vec4f : (p.xy, outerRad, innerRad) * p is the position in the normalized space. * outerRad is the outerRadius in device space. * innerRad is the innerRadius in normalized space (ignored if not stroking). * Additional clip planes are supported for rendering circular arcs. The additional planes are * either intersected or unioned together. Up to three planes are supported (an initial plane, * a plane intersected with the initial plane, and a plane unioned with the first two). Only two * are useful for any given arc, but having all three in one instance allows combining different * types of arcs. * Round caps for stroking are allowed as well. The caps are specified as two circle center points * in the same space as p.xy. */ class CircleGeometryProcessor : public GrGeometryProcessor { public: static GrGeometryProcessor* Make(SkArenaAlloc* arena, bool stroke, bool clipPlane, bool isectPlane, bool unionPlane, bool roundCaps, bool wideColor, const SkMatrix& localMatrix) { return arena->make<CircleGeometryProcessor>(stroke, clipPlane, isectPlane, unionPlane, roundCaps, wideColor, localMatrix); } const char* name() const override { return "CircleGeometryProcessor"; } void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override { GLSLProcessor::GenKey(*this, caps, b); } GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override { return new GLSLProcessor(); } private: friend class ::SkArenaAlloc; // for access to ctor CircleGeometryProcessor(bool stroke, bool clipPlane, bool isectPlane, bool unionPlane, bool roundCaps, bool wideColor, const SkMatrix& localMatrix) : INHERITED(kCircleGeometryProcessor_ClassID) , fLocalMatrix(localMatrix) , fStroke(stroke) { fInPosition = {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType}; fInColor = MakeColorAttribute("inColor", wideColor); fInCircleEdge = {"inCircleEdge", kFloat4_GrVertexAttribType, kFloat4_GrSLType}; if (clipPlane) { fInClipPlane = {"inClipPlane", kFloat3_GrVertexAttribType, kHalf3_GrSLType}; } if (isectPlane) { fInIsectPlane = {"inIsectPlane", kFloat3_GrVertexAttribType, kHalf3_GrSLType}; } if (unionPlane) { fInUnionPlane = {"inUnionPlane", kFloat3_GrVertexAttribType, kHalf3_GrSLType}; } if (roundCaps) { SkASSERT(stroke); SkASSERT(clipPlane); fInRoundCapCenters = {"inRoundCapCenters", kFloat4_GrVertexAttribType, kFloat4_GrSLType}; } this->setVertexAttributes(&fInPosition, 7); } class GLSLProcessor : public GrGLSLGeometryProcessor { public: GLSLProcessor() {} void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override { const CircleGeometryProcessor& cgp = args.fGP.cast<CircleGeometryProcessor>(); GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder; GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler; GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; // emit attributes varyingHandler->emitAttributes(cgp); fragBuilder->codeAppend("float4 circleEdge;"); varyingHandler->addPassThroughAttribute(cgp.fInCircleEdge, "circleEdge"); if (cgp.fInClipPlane.isInitialized()) { fragBuilder->codeAppend("half3 clipPlane;"); varyingHandler->addPassThroughAttribute(cgp.fInClipPlane, "clipPlane"); } if (cgp.fInIsectPlane.isInitialized()) { fragBuilder->codeAppend("half3 isectPlane;"); varyingHandler->addPassThroughAttribute(cgp.fInIsectPlane, "isectPlane"); } if (cgp.fInUnionPlane.isInitialized()) { SkASSERT(cgp.fInClipPlane.isInitialized()); fragBuilder->codeAppend("half3 unionPlane;"); varyingHandler->addPassThroughAttribute(cgp.fInUnionPlane, "unionPlane"); } GrGLSLVarying capRadius(kFloat_GrSLType); if (cgp.fInRoundCapCenters.isInitialized()) { fragBuilder->codeAppend("float4 roundCapCenters;"); varyingHandler->addPassThroughAttribute(cgp.fInRoundCapCenters, "roundCapCenters"); varyingHandler->addVarying("capRadius", &capRadius, GrGLSLVaryingHandler::Interpolation::kCanBeFlat); // This is the cap radius in normalized space where the outer radius is 1 and // circledEdge.w is the normalized inner radius. vertBuilder->codeAppendf("%s = (1.0 - %s.w) / 2.0;", capRadius.vsOut(), cgp.fInCircleEdge.name()); } // setup pass through color varyingHandler->addPassThroughAttribute(cgp.fInColor, args.fOutputColor); // Setup position this->writeOutputPosition(vertBuilder, gpArgs, cgp.fInPosition.name()); this->writeLocalCoord(vertBuilder, uniformHandler, gpArgs, cgp.fInPosition.asShaderVar(), cgp.fLocalMatrix, &fLocalMatrixUniform); fragBuilder->codeAppend("float d = length(circleEdge.xy);"); fragBuilder->codeAppend("half distanceToOuterEdge = half(circleEdge.z * (1.0 - d));"); fragBuilder->codeAppend("half edgeAlpha = saturate(distanceToOuterEdge);"); if (cgp.fStroke) { fragBuilder->codeAppend( "half distanceToInnerEdge = half(circleEdge.z * (d - circleEdge.w));"); fragBuilder->codeAppend("half innerAlpha = saturate(distanceToInnerEdge);"); fragBuilder->codeAppend("edgeAlpha *= innerAlpha;"); } if (cgp.fInClipPlane.isInitialized()) { fragBuilder->codeAppend( "half clip = half(saturate(circleEdge.z * dot(circleEdge.xy, " "clipPlane.xy) + clipPlane.z));"); if (cgp.fInIsectPlane.isInitialized()) { fragBuilder->codeAppend( "clip *= half(saturate(circleEdge.z * dot(circleEdge.xy, " "isectPlane.xy) + isectPlane.z));"); } if (cgp.fInUnionPlane.isInitialized()) { fragBuilder->codeAppend( "clip = saturate(clip + half(saturate(circleEdge.z * dot(circleEdge.xy," " unionPlane.xy) + unionPlane.z)));"); } fragBuilder->codeAppend("edgeAlpha *= clip;"); if (cgp.fInRoundCapCenters.isInitialized()) { // We compute coverage of the round caps as circles at the butt caps produced // by the clip planes. The inverse of the clip planes is applied so that there // is no double counting. fragBuilder->codeAppendf( "half dcap1 = half(circleEdge.z * (%s - length(circleEdge.xy - " " roundCapCenters.xy)));" "half dcap2 = half(circleEdge.z * (%s - length(circleEdge.xy - " " roundCapCenters.zw)));" "half capAlpha = (1 - clip) * (max(dcap1, 0) + max(dcap2, 0));" "edgeAlpha = min(edgeAlpha + capAlpha, 1.0);", capRadius.fsIn(), capRadius.fsIn()); } } fragBuilder->codeAppendf("%s = half4(edgeAlpha);", args.fOutputCoverage); } static void GenKey(const GrGeometryProcessor& gp, const GrShaderCaps&, GrProcessorKeyBuilder* b) { const CircleGeometryProcessor& cgp = gp.cast<CircleGeometryProcessor>(); uint32_t key; key = cgp.fStroke ? 0x01 : 0x0; key |= cgp.fInClipPlane.isInitialized() ? 0x02 : 0x0; key |= cgp.fInIsectPlane.isInitialized() ? 0x04 : 0x0; key |= cgp.fInUnionPlane.isInitialized() ? 0x08 : 0x0; key |= cgp.fInRoundCapCenters.isInitialized() ? 0x10 : 0x0; key |= (ComputeMatrixKey(cgp.fLocalMatrix) << 16); b->add32(key); } void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& primProc, const CoordTransformRange& transformRange) override { this->setTransformDataHelper(pdman, transformRange); this->setTransform(pdman, fLocalMatrixUniform, primProc.cast<CircleGeometryProcessor>().fLocalMatrix, &fLocalMatrix); } private: typedef GrGLSLGeometryProcessor INHERITED; SkMatrix fLocalMatrix = SkMatrix::InvalidMatrix(); UniformHandle fLocalMatrixUniform; }; SkMatrix fLocalMatrix; Attribute fInPosition; Attribute fInColor; Attribute fInCircleEdge; // Optional attributes. Attribute fInClipPlane; Attribute fInIsectPlane; Attribute fInUnionPlane; Attribute fInRoundCapCenters; bool fStroke; GR_DECLARE_GEOMETRY_PROCESSOR_TEST typedef GrGeometryProcessor INHERITED; }; GR_DEFINE_GEOMETRY_PROCESSOR_TEST(CircleGeometryProcessor); #if GR_TEST_UTILS GrGeometryProcessor* CircleGeometryProcessor::TestCreate(GrProcessorTestData* d) { bool stroke = d->fRandom->nextBool(); bool roundCaps = stroke ? d->fRandom->nextBool() : false; bool wideColor = d->fRandom->nextBool(); bool clipPlane = d->fRandom->nextBool(); bool isectPlane = d->fRandom->nextBool(); bool unionPlane = d->fRandom->nextBool(); const SkMatrix& matrix = GrTest::TestMatrix(d->fRandom); return CircleGeometryProcessor::Make(d->allocator(), stroke, clipPlane, isectPlane, unionPlane, roundCaps, wideColor, matrix); } #endif class ButtCapDashedCircleGeometryProcessor : public GrGeometryProcessor { public: static GrGeometryProcessor* Make(SkArenaAlloc* arena, bool wideColor, const SkMatrix& localMatrix) { return arena->make<ButtCapDashedCircleGeometryProcessor>(wideColor, localMatrix); } ~ButtCapDashedCircleGeometryProcessor() override {} const char* name() const override { return "ButtCapDashedCircleGeometryProcessor"; } void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override { GLSLProcessor::GenKey(*this, caps, b); } GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override { return new GLSLProcessor(); } private: friend class ::SkArenaAlloc; // for access to ctor ButtCapDashedCircleGeometryProcessor(bool wideColor, const SkMatrix& localMatrix) : INHERITED(kButtCapStrokedCircleGeometryProcessor_ClassID) , fLocalMatrix(localMatrix) { fInPosition = {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType}; fInColor = MakeColorAttribute("inColor", wideColor); fInCircleEdge = {"inCircleEdge", kFloat4_GrVertexAttribType, kFloat4_GrSLType}; fInDashParams = {"inDashParams", kFloat4_GrVertexAttribType, kFloat4_GrSLType}; this->setVertexAttributes(&fInPosition, 4); } class GLSLProcessor : public GrGLSLGeometryProcessor { public: GLSLProcessor() {} void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override { const ButtCapDashedCircleGeometryProcessor& bcscgp = args.fGP.cast<ButtCapDashedCircleGeometryProcessor>(); GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder; GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler; GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; // emit attributes varyingHandler->emitAttributes(bcscgp); fragBuilder->codeAppend("float4 circleEdge;"); varyingHandler->addPassThroughAttribute(bcscgp.fInCircleEdge, "circleEdge"); fragBuilder->codeAppend("float4 dashParams;"); varyingHandler->addPassThroughAttribute( bcscgp.fInDashParams, "dashParams", GrGLSLVaryingHandler::Interpolation::kCanBeFlat); GrGLSLVarying wrapDashes(kHalf4_GrSLType); varyingHandler->addVarying("wrapDashes", &wrapDashes, GrGLSLVaryingHandler::Interpolation::kCanBeFlat); GrGLSLVarying lastIntervalLength(kHalf_GrSLType); varyingHandler->addVarying("lastIntervalLength", &lastIntervalLength, GrGLSLVaryingHandler::Interpolation::kCanBeFlat); vertBuilder->codeAppendf("float4 dashParams = %s;", bcscgp.fInDashParams.name()); // Our fragment shader works in on/off intervals as specified by dashParams.xy: // x = length of on interval, y = length of on + off. // There are two other parameters in dashParams.zw: // z = start angle in radians, w = phase offset in radians in range -y/2..y/2. // Each interval has a "corresponding" dash which may be shifted partially or // fully out of its interval by the phase. So there may be up to two "visual" // dashes in an interval. // When computing coverage in an interval we look at three dashes. These are the // "corresponding" dashes from the current, previous, and next intervals. Any of these // may be phase shifted into our interval or even when phase=0 they may be within half a // pixel distance of a pixel center in the interval. // When in the first interval we need to check the dash from the last interval. And // similarly when in the last interval we need to check the dash from the first // interval. When 2pi is not perfectly divisible dashParams.y this is a boundary case. // We compute the dash begin/end angles in the vertex shader and apply them in the // fragment shader when we detect we're in the first/last interval. vertBuilder->codeAppend(R"( // The two boundary dash intervals are stored in wrapDashes.xy and .zw and fed // to the fragment shader as a varying. float4 wrapDashes; half lastIntervalLength = mod(6.28318530718, half(dashParams.y)); // We can happen to be perfectly divisible. if (0 == lastIntervalLength) { lastIntervalLength = half(dashParams.y); } // Let 'l' be the last interval before reaching 2 pi. // Based on the phase determine whether (l-1)th, l-th, or (l+1)th interval's // "corresponding" dash appears in the l-th interval and is closest to the 0-th // interval. half offset = 0; if (-dashParams.w >= lastIntervalLength) { offset = half(-dashParams.y); } else if (dashParams.w > dashParams.y - lastIntervalLength) { offset = half(dashParams.y); } wrapDashes.x = -lastIntervalLength + offset - dashParams.w; // The end of this dash may be beyond the 2 pi and therefore clipped. Hence the // min. wrapDashes.y = min(wrapDashes.x + dashParams.x, 0); // Based on the phase determine whether the -1st, 0th, or 1st interval's // "corresponding" dash appears in the 0th interval and is closest to l. offset = 0; if (dashParams.w >= dashParams.x) { offset = half(dashParams.y); } else if (-dashParams.w > dashParams.y - dashParams.x) { offset = half(-dashParams.y); } wrapDashes.z = lastIntervalLength + offset - dashParams.w; wrapDashes.w = wrapDashes.z + dashParams.x; // The start of the dash we're considering may be clipped by the start of the // circle. wrapDashes.z = max(wrapDashes.z, lastIntervalLength); )"); vertBuilder->codeAppendf("%s = half4(wrapDashes);", wrapDashes.vsOut()); vertBuilder->codeAppendf("%s = lastIntervalLength;", lastIntervalLength.vsOut()); fragBuilder->codeAppendf("half4 wrapDashes = %s;", wrapDashes.fsIn()); fragBuilder->codeAppendf("half lastIntervalLength = %s;", lastIntervalLength.fsIn()); // setup pass through color varyingHandler->addPassThroughAttribute( bcscgp.fInColor, args.fOutputColor, GrGLSLVaryingHandler::Interpolation::kCanBeFlat); // Setup position this->writeOutputPosition(vertBuilder, gpArgs, bcscgp.fInPosition.name()); this->writeLocalCoord(vertBuilder, uniformHandler, gpArgs, bcscgp.fInPosition.asShaderVar(), bcscgp.fLocalMatrix, &fLocalMatrixUniform); GrShaderVar fnArgs[] = { GrShaderVar("angleToEdge", kFloat_GrSLType), GrShaderVar("diameter", kFloat_GrSLType), }; SkString fnName; fragBuilder->emitFunction(kFloat_GrSLType, "coverage_from_dash_edge", SK_ARRAY_COUNT(fnArgs), fnArgs, R"( float linearDist; angleToEdge = clamp(angleToEdge, -3.1415, 3.1415); linearDist = diameter * sin(angleToEdge / 2); return saturate(linearDist + 0.5); )", &fnName); fragBuilder->codeAppend(R"( float d = length(circleEdge.xy) * circleEdge.z; // Compute coverage from outer/inner edges of the stroke. half distanceToOuterEdge = half(circleEdge.z - d); half edgeAlpha = saturate(distanceToOuterEdge); half distanceToInnerEdge = half(d - circleEdge.z * circleEdge.w); half innerAlpha = saturate(distanceToInnerEdge); edgeAlpha *= innerAlpha; half angleFromStart = half(atan(circleEdge.y, circleEdge.x) - dashParams.z); angleFromStart = mod(angleFromStart, 6.28318530718); float x = mod(angleFromStart, dashParams.y); // Convert the radial distance from center to pixel into a diameter. d *= 2; half2 currDash = half2(half(-dashParams.w), half(dashParams.x) - half(dashParams.w)); half2 nextDash = half2(half(dashParams.y) - half(dashParams.w), half(dashParams.y) + half(dashParams.x) - half(dashParams.w)); half2 prevDash = half2(half(-dashParams.y) - half(dashParams.w), half(-dashParams.y) + half(dashParams.x) - half(dashParams.w)); half dashAlpha = 0; )"); fragBuilder->codeAppendf(R"( if (angleFromStart - x + dashParams.y >= 6.28318530718) { dashAlpha += half(%s(x - wrapDashes.z, d) * %s(wrapDashes.w - x, d)); currDash.y = min(currDash.y, lastIntervalLength); if (nextDash.x >= lastIntervalLength) { // The next dash is outside the 0..2pi range, throw it away nextDash.xy = half2(1000); } else { // Clip the end of the next dash to the end of the circle nextDash.y = min(nextDash.y, lastIntervalLength); } } )", fnName.c_str(), fnName.c_str()); fragBuilder->codeAppendf(R"( if (angleFromStart - x - dashParams.y < -0.01) { dashAlpha += half(%s(x - wrapDashes.x, d) * %s(wrapDashes.y - x, d)); currDash.x = max(currDash.x, 0); if (prevDash.y <= 0) { // The previous dash is outside the 0..2pi range, throw it away prevDash.xy = half2(1000); } else { // Clip the start previous dash to the start of the circle prevDash.x = max(prevDash.x, 0); } } )", fnName.c_str(), fnName.c_str()); fragBuilder->codeAppendf(R"( dashAlpha += half(%s(x - currDash.x, d) * %s(currDash.y - x, d)); dashAlpha += half(%s(x - nextDash.x, d) * %s(nextDash.y - x, d)); dashAlpha += half(%s(x - prevDash.x, d) * %s(prevDash.y - x, d)); dashAlpha = min(dashAlpha, 1); edgeAlpha *= dashAlpha; )", fnName.c_str(), fnName.c_str(), fnName.c_str(), fnName.c_str(), fnName.c_str(), fnName.c_str()); fragBuilder->codeAppendf("%s = half4(edgeAlpha);", args.fOutputCoverage); } static void GenKey(const GrGeometryProcessor& gp, const GrShaderCaps&, GrProcessorKeyBuilder* b) { const ButtCapDashedCircleGeometryProcessor& bcscgp = gp.cast<ButtCapDashedCircleGeometryProcessor>(); b->add32(ComputeMatrixKey(bcscgp.fLocalMatrix)); } void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& primProc, const CoordTransformRange& transformRange) override { this->setTransformDataHelper(pdman, transformRange); this->setTransform(pdman, fLocalMatrixUniform, primProc.cast<ButtCapDashedCircleGeometryProcessor>().fLocalMatrix, &fLocalMatrix); } private: typedef GrGLSLGeometryProcessor INHERITED; SkMatrix fLocalMatrix = SkMatrix::InvalidMatrix(); UniformHandle fLocalMatrixUniform; }; SkMatrix fLocalMatrix; Attribute fInPosition; Attribute fInColor; Attribute fInCircleEdge; Attribute fInDashParams; GR_DECLARE_GEOMETRY_PROCESSOR_TEST typedef GrGeometryProcessor INHERITED; }; #if GR_TEST_UTILS GrGeometryProcessor* ButtCapDashedCircleGeometryProcessor::TestCreate(GrProcessorTestData* d) { bool wideColor = d->fRandom->nextBool(); const SkMatrix& matrix = GrTest::TestMatrix(d->fRandom); return ButtCapDashedCircleGeometryProcessor::Make(d->allocator(), wideColor, matrix); } #endif /////////////////////////////////////////////////////////////////////////////// /** * The output of this effect is a modulation of the input color and coverage for an axis-aligned * ellipse, specified as a 2D offset from center, and the reciprocals of the outer and inner radii, * in both x and y directions. * * We are using an implicit function of x^2/a^2 + y^2/b^2 - 1 = 0. */ class EllipseGeometryProcessor : public GrGeometryProcessor { public: static GrGeometryProcessor* Make(SkArenaAlloc* arena, bool stroke, bool wideColor, bool useScale, const SkMatrix& localMatrix) { return arena->make<EllipseGeometryProcessor>(stroke, wideColor, useScale, localMatrix); } ~EllipseGeometryProcessor() override {} const char* name() const override { return "EllipseGeometryProcessor"; } void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override { GLSLProcessor::GenKey(*this, caps, b); } GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override { return new GLSLProcessor(); } private: friend class ::SkArenaAlloc; // for access to ctor EllipseGeometryProcessor(bool stroke, bool wideColor, bool useScale, const SkMatrix& localMatrix) : INHERITED(kEllipseGeometryProcessor_ClassID) , fLocalMatrix(localMatrix) , fStroke(stroke) , fUseScale(useScale) { fInPosition = {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType}; fInColor = MakeColorAttribute("inColor", wideColor); if (useScale) { fInEllipseOffset = {"inEllipseOffset", kFloat3_GrVertexAttribType, kFloat3_GrSLType}; } else { fInEllipseOffset = {"inEllipseOffset", kFloat2_GrVertexAttribType, kFloat2_GrSLType}; } fInEllipseRadii = {"inEllipseRadii", kFloat4_GrVertexAttribType, kFloat4_GrSLType}; this->setVertexAttributes(&fInPosition, 4); } class GLSLProcessor : public GrGLSLGeometryProcessor { public: GLSLProcessor() {} void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override { const EllipseGeometryProcessor& egp = args.fGP.cast<EllipseGeometryProcessor>(); GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder; GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler; GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; // emit attributes varyingHandler->emitAttributes(egp); GrSLType offsetType = egp.fUseScale ? kFloat3_GrSLType : kFloat2_GrSLType; GrGLSLVarying ellipseOffsets(offsetType); varyingHandler->addVarying("EllipseOffsets", &ellipseOffsets); vertBuilder->codeAppendf("%s = %s;", ellipseOffsets.vsOut(), egp.fInEllipseOffset.name()); GrGLSLVarying ellipseRadii(kFloat4_GrSLType); varyingHandler->addVarying("EllipseRadii", &ellipseRadii); vertBuilder->codeAppendf("%s = %s;", ellipseRadii.vsOut(), egp.fInEllipseRadii.name()); GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; // setup pass through color varyingHandler->addPassThroughAttribute(egp.fInColor, args.fOutputColor); // Setup position this->writeOutputPosition(vertBuilder, gpArgs, egp.fInPosition.name()); this->writeLocalCoord(vertBuilder, uniformHandler, gpArgs, egp.fInPosition.asShaderVar(), egp.fLocalMatrix, &fLocalMatrixUniform); // For stroked ellipses, we use the full ellipse equation (x^2/a^2 + y^2/b^2 = 1) // to compute both the edges because we need two separate test equations for // the single offset. // For filled ellipses we can use a unit circle equation (x^2 + y^2 = 1), and warp // the distance by the gradient, non-uniformly scaled by the inverse of the // ellipse size. // On medium precision devices, we scale the denominator of the distance equation // before taking the inverse square root to minimize the chance that we're dividing // by zero, then we scale the result back. // for outer curve fragBuilder->codeAppendf("float2 offset = %s.xy;", ellipseOffsets.fsIn()); if (egp.fStroke) { fragBuilder->codeAppendf("offset *= %s.xy;", ellipseRadii.fsIn()); } fragBuilder->codeAppend("float test = dot(offset, offset) - 1.0;"); if (egp.fUseScale) { fragBuilder->codeAppendf("float2 grad = 2.0*offset*(%s.z*%s.xy);", ellipseOffsets.fsIn(), ellipseRadii.fsIn()); } else { fragBuilder->codeAppendf("float2 grad = 2.0*offset*%s.xy;", ellipseRadii.fsIn()); } fragBuilder->codeAppend("float grad_dot = dot(grad, grad);"); // avoid calling inversesqrt on zero. if (args.fShaderCaps->floatIs32Bits()) { fragBuilder->codeAppend("grad_dot = max(grad_dot, 1.1755e-38);"); } else { fragBuilder->codeAppend("grad_dot = max(grad_dot, 6.1036e-5);"); } if (egp.fUseScale) { fragBuilder->codeAppendf("float invlen = %s.z*inversesqrt(grad_dot);", ellipseOffsets.fsIn()); } else { fragBuilder->codeAppend("float invlen = inversesqrt(grad_dot);"); } fragBuilder->codeAppend("float edgeAlpha = saturate(0.5-test*invlen);"); // for inner curve if (egp.fStroke) { fragBuilder->codeAppendf("offset = %s.xy*%s.zw;", ellipseOffsets.fsIn(), ellipseRadii.fsIn()); fragBuilder->codeAppend("test = dot(offset, offset) - 1.0;"); if (egp.fUseScale) { fragBuilder->codeAppendf("grad = 2.0*offset*(%s.z*%s.zw);", ellipseOffsets.fsIn(), ellipseRadii.fsIn()); } else { fragBuilder->codeAppendf("grad = 2.0*offset*%s.zw;", ellipseRadii.fsIn()); } fragBuilder->codeAppend("grad_dot = dot(grad, grad);"); if (!args.fShaderCaps->floatIs32Bits()) { fragBuilder->codeAppend("grad_dot = max(grad_dot, 6.1036e-5);"); } if (egp.fUseScale) { fragBuilder->codeAppendf("invlen = %s.z*inversesqrt(grad_dot);", ellipseOffsets.fsIn()); } else { fragBuilder->codeAppend("invlen = inversesqrt(grad_dot);"); } fragBuilder->codeAppend("edgeAlpha *= saturate(0.5+test*invlen);"); } fragBuilder->codeAppendf("%s = half4(half(edgeAlpha));", args.fOutputCoverage); } static void GenKey(const GrGeometryProcessor& gp, const GrShaderCaps&, GrProcessorKeyBuilder* b) { const EllipseGeometryProcessor& egp = gp.cast<EllipseGeometryProcessor>(); uint32_t key = egp.fStroke ? 0x1 : 0x0; key |= ComputeMatrixKey(egp.fLocalMatrix) << 1; b->add32(key); } void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& primProc, const CoordTransformRange& transformRange) override { const EllipseGeometryProcessor& egp = primProc.cast<EllipseGeometryProcessor>(); this->setTransformDataHelper(pdman, transformRange); this->setTransform(pdman, fLocalMatrixUniform, egp.fLocalMatrix, &fLocalMatrix); } private: typedef GrGLSLGeometryProcessor INHERITED; SkMatrix fLocalMatrix = SkMatrix::InvalidMatrix(); UniformHandle fLocalMatrixUniform; }; Attribute fInPosition; Attribute fInColor; Attribute fInEllipseOffset; Attribute fInEllipseRadii; SkMatrix fLocalMatrix; bool fStroke; bool fUseScale; GR_DECLARE_GEOMETRY_PROCESSOR_TEST typedef GrGeometryProcessor INHERITED; }; GR_DEFINE_GEOMETRY_PROCESSOR_TEST(EllipseGeometryProcessor); #if GR_TEST_UTILS GrGeometryProcessor* EllipseGeometryProcessor::TestCreate(GrProcessorTestData* d) { return EllipseGeometryProcessor::Make(d->allocator(), d->fRandom->nextBool(), d->fRandom->nextBool(), d->fRandom->nextBool(), GrTest::TestMatrix(d->fRandom)); } #endif /////////////////////////////////////////////////////////////////////////////// /** * The output of this effect is a modulation of the input color and coverage for an ellipse, * specified as a 2D offset from center for both the outer and inner paths (if stroked). The * implict equation used is for a unit circle (x^2 + y^2 - 1 = 0) and the edge corrected by * using differentials. * * The result is device-independent and can be used with any affine matrix. */ enum class DIEllipseStyle { kStroke = 0, kHairline, kFill }; class DIEllipseGeometryProcessor : public GrGeometryProcessor { public: static GrGeometryProcessor* Make(SkArenaAlloc* arena, bool wideColor, bool useScale, const SkMatrix& viewMatrix, DIEllipseStyle style) { return arena->make<DIEllipseGeometryProcessor>(wideColor, useScale, viewMatrix, style); } ~DIEllipseGeometryProcessor() override {} const char* name() const override { return "DIEllipseGeometryProcessor"; } void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override { GLSLProcessor::GenKey(*this, caps, b); } GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override { return new GLSLProcessor(); } private: friend class ::SkArenaAlloc; // for access to ctor DIEllipseGeometryProcessor(bool wideColor, bool useScale, const SkMatrix& viewMatrix, DIEllipseStyle style) : INHERITED(kDIEllipseGeometryProcessor_ClassID) , fViewMatrix(viewMatrix) , fUseScale(useScale) , fStyle(style) { fInPosition = {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType}; fInColor = MakeColorAttribute("inColor", wideColor); if (useScale) { fInEllipseOffsets0 = {"inEllipseOffsets0", kFloat3_GrVertexAttribType, kFloat3_GrSLType}; } else { fInEllipseOffsets0 = {"inEllipseOffsets0", kFloat2_GrVertexAttribType, kFloat2_GrSLType}; } fInEllipseOffsets1 = {"inEllipseOffsets1", kFloat2_GrVertexAttribType, kFloat2_GrSLType}; this->setVertexAttributes(&fInPosition, 4); } class GLSLProcessor : public GrGLSLGeometryProcessor { public: GLSLProcessor() : fViewMatrix(SkMatrix::InvalidMatrix()) {} void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override { const DIEllipseGeometryProcessor& diegp = args.fGP.cast<DIEllipseGeometryProcessor>(); GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder; GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler; GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; // emit attributes varyingHandler->emitAttributes(diegp); GrSLType offsetType = (diegp.fUseScale) ? kFloat3_GrSLType : kFloat2_GrSLType; GrGLSLVarying offsets0(offsetType); varyingHandler->addVarying("EllipseOffsets0", &offsets0); vertBuilder->codeAppendf("%s = %s;", offsets0.vsOut(), diegp.fInEllipseOffsets0.name()); GrGLSLVarying offsets1(kFloat2_GrSLType); varyingHandler->addVarying("EllipseOffsets1", &offsets1); vertBuilder->codeAppendf("%s = %s;", offsets1.vsOut(), diegp.fInEllipseOffsets1.name()); GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; varyingHandler->addPassThroughAttribute(diegp.fInColor, args.fOutputColor); // Setup position this->writeOutputPosition(vertBuilder, uniformHandler, gpArgs, diegp.fInPosition.name(), diegp.fViewMatrix, &fViewMatrixUniform); gpArgs->fLocalCoordVar = diegp.fInPosition.asShaderVar(); // for outer curve fragBuilder->codeAppendf("float2 scaledOffset = %s.xy;", offsets0.fsIn()); fragBuilder->codeAppend("float test = dot(scaledOffset, scaledOffset) - 1.0;"); fragBuilder->codeAppendf("float2 duvdx = dFdx(%s.xy);", offsets0.fsIn()); fragBuilder->codeAppendf("float2 duvdy = dFdy(%s.xy);", offsets0.fsIn()); fragBuilder->codeAppendf( "float2 grad = float2(%s.x*duvdx.x + %s.y*duvdx.y," " %s.x*duvdy.x + %s.y*duvdy.y);", offsets0.fsIn(), offsets0.fsIn(), offsets0.fsIn(), offsets0.fsIn()); if (diegp.fUseScale) { fragBuilder->codeAppendf("grad *= %s.z;", offsets0.fsIn()); } fragBuilder->codeAppend("float grad_dot = 4.0*dot(grad, grad);"); // avoid calling inversesqrt on zero. if (args.fShaderCaps->floatIs32Bits()) { fragBuilder->codeAppend("grad_dot = max(grad_dot, 1.1755e-38);"); } else { fragBuilder->codeAppend("grad_dot = max(grad_dot, 6.1036e-5);"); } fragBuilder->codeAppend("float invlen = inversesqrt(grad_dot);"); if (diegp.fUseScale) { fragBuilder->codeAppendf("invlen *= %s.z;", offsets0.fsIn()); } if (DIEllipseStyle::kHairline == diegp.fStyle) { // can probably do this with one step fragBuilder->codeAppend("float edgeAlpha = saturate(1.0-test*invlen);"); fragBuilder->codeAppend("edgeAlpha *= saturate(1.0+test*invlen);"); } else { fragBuilder->codeAppend("float edgeAlpha = saturate(0.5-test*invlen);"); } // for inner curve if (DIEllipseStyle::kStroke == diegp.fStyle) { fragBuilder->codeAppendf("scaledOffset = %s.xy;", offsets1.fsIn()); fragBuilder->codeAppend("test = dot(scaledOffset, scaledOffset) - 1.0;"); fragBuilder->codeAppendf("duvdx = float2(dFdx(%s));", offsets1.fsIn()); fragBuilder->codeAppendf("duvdy = float2(dFdy(%s));", offsets1.fsIn()); fragBuilder->codeAppendf( "grad = float2(%s.x*duvdx.x + %s.y*duvdx.y," " %s.x*duvdy.x + %s.y*duvdy.y);", offsets1.fsIn(), offsets1.fsIn(), offsets1.fsIn(), offsets1.fsIn()); if (diegp.fUseScale) { fragBuilder->codeAppendf("grad *= %s.z;", offsets0.fsIn()); } fragBuilder->codeAppend("grad_dot = 4.0*dot(grad, grad);"); if (!args.fShaderCaps->floatIs32Bits()) { fragBuilder->codeAppend("grad_dot = max(grad_dot, 6.1036e-5);"); } fragBuilder->codeAppend("invlen = inversesqrt(grad_dot);"); if (diegp.fUseScale) { fragBuilder->codeAppendf("invlen *= %s.z;", offsets0.fsIn()); } fragBuilder->codeAppend("edgeAlpha *= saturate(0.5+test*invlen);"); } fragBuilder->codeAppendf("%s = half4(half(edgeAlpha));", args.fOutputCoverage); } static void GenKey(const GrGeometryProcessor& gp, const GrShaderCaps&, GrProcessorKeyBuilder* b) { const DIEllipseGeometryProcessor& diegp = gp.cast<DIEllipseGeometryProcessor>(); uint32_t key = static_cast<uint32_t>(diegp.fStyle); key |= ComputeMatrixKey(diegp.fViewMatrix) << 10; b->add32(key); } void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& gp, const CoordTransformRange& transformRange) override { const DIEllipseGeometryProcessor& diegp = gp.cast<DIEllipseGeometryProcessor>(); this->setTransform(pdman, fViewMatrixUniform, diegp.fViewMatrix, &fViewMatrix); this->setTransformDataHelper(pdman, transformRange); } private: SkMatrix fViewMatrix; UniformHandle fViewMatrixUniform; typedef GrGLSLGeometryProcessor INHERITED; }; Attribute fInPosition; Attribute fInColor; Attribute fInEllipseOffsets0; Attribute fInEllipseOffsets1; SkMatrix fViewMatrix; bool fUseScale; DIEllipseStyle fStyle; GR_DECLARE_GEOMETRY_PROCESSOR_TEST typedef GrGeometryProcessor INHERITED; }; GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DIEllipseGeometryProcessor); #if GR_TEST_UTILS GrGeometryProcessor* DIEllipseGeometryProcessor::TestCreate(GrProcessorTestData* d) { return DIEllipseGeometryProcessor::Make(d->allocator(), d->fRandom->nextBool(), d->fRandom->nextBool(), GrTest::TestMatrix(d->fRandom), (DIEllipseStyle)(d->fRandom->nextRangeU(0, 2))); } #endif /////////////////////////////////////////////////////////////////////////////// // We have two possible cases for geometry for a circle: // In the case of a normal fill, we draw geometry for the circle as an octagon. static const uint16_t gFillCircleIndices[] = { // enter the octagon // clang-format off 0, 1, 8, 1, 2, 8, 2, 3, 8, 3, 4, 8, 4, 5, 8, 5, 6, 8, 6, 7, 8, 7, 0, 8 // clang-format on }; // For stroked circles, we use two nested octagons. static const uint16_t gStrokeCircleIndices[] = { // enter the octagon // clang-format off 0, 1, 9, 0, 9, 8, 1, 2, 10, 1, 10, 9, 2, 3, 11, 2, 11, 10, 3, 4, 12, 3, 12, 11, 4, 5, 13, 4, 13, 12, 5, 6, 14, 5, 14, 13, 6, 7, 15, 6, 15, 14, 7, 0, 8, 7, 8, 15, // clang-format on }; // Normalized geometry for octagons that circumscribe and lie on a circle: static constexpr SkScalar kOctOffset = 0.41421356237f; // sqrt(2) - 1 static constexpr SkPoint kOctagonOuter[] = { SkPoint::Make(-kOctOffset, -1), SkPoint::Make( kOctOffset, -1), SkPoint::Make( 1, -kOctOffset), SkPoint::Make( 1, kOctOffset), SkPoint::Make( kOctOffset, 1), SkPoint::Make(-kOctOffset, 1), SkPoint::Make(-1, kOctOffset), SkPoint::Make(-1, -kOctOffset), }; // cosine and sine of pi/8 static constexpr SkScalar kCosPi8 = 0.923579533f; static constexpr SkScalar kSinPi8 = 0.382683432f; static constexpr SkPoint kOctagonInner[] = { SkPoint::Make(-kSinPi8, -kCosPi8), SkPoint::Make( kSinPi8, -kCosPi8), SkPoint::Make( kCosPi8, -kSinPi8), SkPoint::Make( kCosPi8, kSinPi8), SkPoint::Make( kSinPi8, kCosPi8), SkPoint::Make(-kSinPi8, kCosPi8), SkPoint::Make(-kCosPi8, kSinPi8), SkPoint::Make(-kCosPi8, -kSinPi8), }; static const int kIndicesPerFillCircle = SK_ARRAY_COUNT(gFillCircleIndices); static const int kIndicesPerStrokeCircle = SK_ARRAY_COUNT(gStrokeCircleIndices); static const int kVertsPerStrokeCircle = 16; static const int kVertsPerFillCircle = 9; static int circle_type_to_vert_count(bool stroked) { return stroked ? kVertsPerStrokeCircle : kVertsPerFillCircle; } static int circle_type_to_index_count(bool stroked) { return stroked ? kIndicesPerStrokeCircle : kIndicesPerFillCircle; } static const uint16_t* circle_type_to_indices(bool stroked) { return stroked ? gStrokeCircleIndices : gFillCircleIndices; } /////////////////////////////////////////////////////////////////////////////// class CircleOp final : public GrMeshDrawOp { private: using Helper = GrSimpleMeshDrawOpHelper; public: DEFINE_OP_CLASS_ID /** Optional extra params to render a partial arc rather than a full circle. */ struct ArcParams { SkScalar fStartAngleRadians; SkScalar fSweepAngleRadians; bool fUseCenter; }; static std::unique_ptr<GrDrawOp> Make(GrRecordingContext* context, GrPaint&& paint, const SkMatrix& viewMatrix, SkPoint center, SkScalar radius, const GrStyle& style, const ArcParams* arcParams = nullptr) { SkASSERT(circle_stays_circle(viewMatrix)); if (style.hasPathEffect()) { return nullptr; } const SkStrokeRec& stroke = style.strokeRec(); SkStrokeRec::Style recStyle = stroke.getStyle(); if (arcParams) { // Arc support depends on the style. switch (recStyle) { case SkStrokeRec::kStrokeAndFill_Style: // This produces a strange result that this op doesn't implement. return nullptr; case SkStrokeRec::kFill_Style: // This supports all fills. break; case SkStrokeRec::kStroke_Style: // Strokes that don't use the center point are supported with butt and round // caps. if (arcParams->fUseCenter || stroke.getCap() == SkPaint::kSquare_Cap) { return nullptr; } break; case SkStrokeRec::kHairline_Style: // Hairline only supports butt cap. Round caps could be emulated by slightly // extending the angle range if we ever care to. if (arcParams->fUseCenter || stroke.getCap() != SkPaint::kButt_Cap) { return nullptr; } break; } } return Helper::FactoryHelper<CircleOp>(context, std::move(paint), viewMatrix, center, radius, style, arcParams); } CircleOp(const Helper::MakeArgs& helperArgs, const SkPMColor4f& color, const SkMatrix& viewMatrix, SkPoint center, SkScalar radius, const GrStyle& style, const ArcParams* arcParams) : GrMeshDrawOp(ClassID()) , fHelper(helperArgs, GrAAType::kCoverage) { const SkStrokeRec& stroke = style.strokeRec(); SkStrokeRec::Style recStyle = stroke.getStyle(); fRoundCaps = false; viewMatrix.mapPoints(&center, 1); radius = viewMatrix.mapRadius(radius); SkScalar strokeWidth = viewMatrix.mapRadius(stroke.getWidth()); bool isStrokeOnly = SkStrokeRec::kStroke_Style == recStyle || SkStrokeRec::kHairline_Style == recStyle; bool hasStroke = isStrokeOnly || SkStrokeRec::kStrokeAndFill_Style == recStyle; SkScalar innerRadius = -SK_ScalarHalf; SkScalar outerRadius = radius; SkScalar halfWidth = 0; if (hasStroke) { if (SkScalarNearlyZero(strokeWidth)) { halfWidth = SK_ScalarHalf; } else { halfWidth = SkScalarHalf(strokeWidth); } outerRadius += halfWidth; if (isStrokeOnly) { innerRadius = radius - halfWidth; } } // The radii are outset for two reasons. First, it allows the shader to simply perform // simpler computation because the computed alpha is zero, rather than 50%, at the radius. // Second, the outer radius is used to compute the verts of the bounding box that is // rendered and the outset ensures the box will cover all partially covered by the circle. outerRadius += SK_ScalarHalf; innerRadius -= SK_ScalarHalf; bool stroked = isStrokeOnly && innerRadius > 0.0f; fViewMatrixIfUsingLocalCoords = viewMatrix; // This makes every point fully inside the intersection plane. static constexpr SkScalar kUnusedIsectPlane[] = {0.f, 0.f, 1.f}; // This makes every point fully outside the union plane. static constexpr SkScalar kUnusedUnionPlane[] = {0.f, 0.f, 0.f}; static constexpr SkPoint kUnusedRoundCaps[] = {{1e10f, 1e10f}, {1e10f, 1e10f}}; SkRect devBounds = SkRect::MakeLTRB(center.fX - outerRadius, center.fY - outerRadius, center.fX + outerRadius, center.fY + outerRadius); if (arcParams) { // The shader operates in a space where the circle is translated to be centered at the // origin. Here we compute points on the unit circle at the starting and ending angles. SkPoint startPoint, stopPoint; startPoint.fY = SkScalarSin(arcParams->fStartAngleRadians); startPoint.fX = SkScalarCos(arcParams->fStartAngleRadians); SkScalar endAngle = arcParams->fStartAngleRadians + arcParams->fSweepAngleRadians; stopPoint.fY = SkScalarSin(endAngle); stopPoint.fX = SkScalarCos(endAngle); // Adjust the start and end points based on the view matrix (to handle rotated arcs) startPoint = viewMatrix.mapVector(startPoint.fX, startPoint.fY); stopPoint = viewMatrix.mapVector(stopPoint.fX, stopPoint.fY); startPoint.normalize(); stopPoint.normalize(); // We know the matrix is a similarity here. Detect mirroring which will affect how we // should orient the clip planes for arcs. SkASSERT(viewMatrix.isSimilarity()); auto upperLeftDet = viewMatrix.getScaleX()*viewMatrix.getScaleY() - viewMatrix.getSkewX() *viewMatrix.getSkewY(); if (upperLeftDet < 0) { std::swap(startPoint, stopPoint); } fRoundCaps = style.strokeRec().getWidth() > 0 && style.strokeRec().getCap() == SkPaint::kRound_Cap; SkPoint roundCaps[2]; if (fRoundCaps) { // Compute the cap center points in the normalized space. SkScalar midRadius = (innerRadius + outerRadius) / (2 * outerRadius); roundCaps[0] = startPoint * midRadius; roundCaps[1] = stopPoint * midRadius; } else { roundCaps[0] = kUnusedRoundCaps[0]; roundCaps[1] = kUnusedRoundCaps[1]; } // Like a fill without useCenter, butt-cap stroke can be implemented by clipping against // radial lines. We treat round caps the same way, but tack coverage of circles at the // center of the butts. // However, in both cases we have to be careful about the half-circle. // case. In that case the two radial lines are equal and so that edge gets clipped // twice. Since the shared edge goes through the center we fall back on the !useCenter // case. auto absSweep = SkScalarAbs(arcParams->fSweepAngleRadians); bool useCenter = (arcParams->fUseCenter || isStrokeOnly) && !SkScalarNearlyEqual(absSweep, SK_ScalarPI); if (useCenter) { SkVector norm0 = {startPoint.fY, -startPoint.fX}; SkVector norm1 = {stopPoint.fY, -stopPoint.fX}; // This ensures that norm0 is always the clockwise plane, and norm1 is CCW. if (arcParams->fSweepAngleRadians < 0) { std::swap(norm0, norm1); } norm0.negate(); fClipPlane = true; if (absSweep > SK_ScalarPI) { fCircles.emplace_back(Circle{ color, innerRadius, outerRadius, {norm0.fX, norm0.fY, 0.5f}, {kUnusedIsectPlane[0], kUnusedIsectPlane[1], kUnusedIsectPlane[2]}, {norm1.fX, norm1.fY, 0.5f}, {roundCaps[0], roundCaps[1]}, devBounds, stroked}); fClipPlaneIsect = false; fClipPlaneUnion = true; } else { fCircles.emplace_back(Circle{ color, innerRadius, outerRadius, {norm0.fX, norm0.fY, 0.5f}, {norm1.fX, norm1.fY, 0.5f}, {kUnusedUnionPlane[0], kUnusedUnionPlane[1], kUnusedUnionPlane[2]}, {roundCaps[0], roundCaps[1]}, devBounds, stroked}); fClipPlaneIsect = true; fClipPlaneUnion = false; } } else { // We clip to a secant of the original circle. startPoint.scale(radius); stopPoint.scale(radius); SkVector norm = {startPoint.fY - stopPoint.fY, stopPoint.fX - startPoint.fX}; norm.normalize(); if (arcParams->fSweepAngleRadians > 0) { norm.negate(); } SkScalar d = -norm.dot(startPoint) + 0.5f; fCircles.emplace_back( Circle{color, innerRadius, outerRadius, {norm.fX, norm.fY, d}, {kUnusedIsectPlane[0], kUnusedIsectPlane[1], kUnusedIsectPlane[2]}, {kUnusedUnionPlane[0], kUnusedUnionPlane[1], kUnusedUnionPlane[2]}, {roundCaps[0], roundCaps[1]}, devBounds, stroked}); fClipPlane = true; fClipPlaneIsect = false; fClipPlaneUnion = false; } } else { fCircles.emplace_back( Circle{color, innerRadius, outerRadius, {kUnusedIsectPlane[0], kUnusedIsectPlane[1], kUnusedIsectPlane[2]}, {kUnusedIsectPlane[0], kUnusedIsectPlane[1], kUnusedIsectPlane[2]}, {kUnusedUnionPlane[0], kUnusedUnionPlane[1], kUnusedUnionPlane[2]}, {kUnusedRoundCaps[0], kUnusedRoundCaps[1]}, devBounds, stroked}); fClipPlane = false; fClipPlaneIsect = false; fClipPlaneUnion = false; } // Use the original radius and stroke radius for the bounds so that it does not include the // AA bloat. radius += halfWidth; this->setBounds( {center.fX - radius, center.fY - radius, center.fX + radius, center.fY + radius}, HasAABloat::kYes, IsHairline::kNo); fVertCount = circle_type_to_vert_count(stroked); fIndexCount = circle_type_to_index_count(stroked); fAllFill = !stroked; } const char* name() const override { return "CircleOp"; } void visitProxies(const VisitProxyFunc& func) const override { if (fProgramInfo) { fProgramInfo->visitFPProxies(func); } else { fHelper.visitProxies(func); } } #ifdef SK_DEBUG SkString dumpInfo() const override { SkString string; for (int i = 0; i < fCircles.count(); ++i) { string.appendf( "Color: 0x%08x Rect [L: %.2f, T: %.2f, R: %.2f, B: %.2f]," "InnerRad: %.2f, OuterRad: %.2f\n", fCircles[i].fColor.toBytes_RGBA(), fCircles[i].fDevBounds.fLeft, fCircles[i].fDevBounds.fTop, fCircles[i].fDevBounds.fRight, fCircles[i].fDevBounds.fBottom, fCircles[i].fInnerRadius, fCircles[i].fOuterRadius); } string += fHelper.dumpInfo(); string += INHERITED::dumpInfo(); return string; } #endif GrProcessorSet::Analysis finalize( const GrCaps& caps, const GrAppliedClip* clip, bool hasMixedSampledCoverage, GrClampType clampType) override { SkPMColor4f* color = &fCircles.front().fColor; return fHelper.finalizeProcessors(caps, clip, hasMixedSampledCoverage, clampType, GrProcessorAnalysisCoverage::kSingleChannel, color, &fWideColor); } FixedFunctionFlags fixedFunctionFlags() const override { return fHelper.fixedFunctionFlags(); } private: GrProgramInfo* programInfo() override { return fProgramInfo; } void onCreateProgramInfo(const GrCaps* caps, SkArenaAlloc* arena, const GrSurfaceProxyView* writeView, GrAppliedClip&& appliedClip, const GrXferProcessor::DstProxyView& dstProxyView) override { SkMatrix localMatrix; if (!fViewMatrixIfUsingLocalCoords.invert(&localMatrix)) { return; } GrGeometryProcessor* gp = CircleGeometryProcessor::Make(arena, !fAllFill, fClipPlane, fClipPlaneIsect, fClipPlaneUnion, fRoundCaps, fWideColor, localMatrix); fProgramInfo = fHelper.createProgramInfo(caps, arena, writeView, std::move(appliedClip), dstProxyView, gp, GrPrimitiveType::kTriangles); } void onPrepareDraws(Target* target) override { if (!fProgramInfo) { this->createProgramInfo(target); if (!fProgramInfo) { return; } } sk_sp<const GrBuffer> vertexBuffer; int firstVertex; GrVertexWriter vertices{target->makeVertexSpace(fProgramInfo->primProc().vertexStride(), fVertCount, &vertexBuffer, &firstVertex)}; if (!vertices.fPtr) { SkDebugf("Could not allocate vertices\n"); return; } sk_sp<const GrBuffer> indexBuffer = nullptr; int firstIndex = 0; uint16_t* indices = target->makeIndexSpace(fIndexCount, &indexBuffer, &firstIndex); if (!indices) { SkDebugf("Could not allocate indices\n"); return; } int currStartVertex = 0; for (const auto& circle : fCircles) { SkScalar innerRadius = circle.fInnerRadius; SkScalar outerRadius = circle.fOuterRadius; GrVertexColor color(circle.fColor, fWideColor); const SkRect& bounds = circle.fDevBounds; // The inner radius in the vertex data must be specified in normalized space. innerRadius = innerRadius / outerRadius; SkPoint radii = { outerRadius, innerRadius }; SkPoint center = SkPoint::Make(bounds.centerX(), bounds.centerY()); SkScalar halfWidth = 0.5f * bounds.width(); SkVector geoClipPlane = { 0, 0 }; SkScalar offsetClipDist = SK_Scalar1; if (!circle.fStroked && fClipPlane && fClipPlaneIsect && (circle.fClipPlane[0] * circle.fIsectPlane[0] + circle.fClipPlane[1] * circle.fIsectPlane[1]) < 0.0f) { // Acute arc. Clip the vertices to the perpendicular half-plane. We've constructed // fClipPlane to be clockwise, and fISectPlane to be CCW, so we can can rotate them // each 90 degrees to point "out", then average them. We back off by 1/2 pixel so // the AA can extend just past the center of the circle. geoClipPlane.set(circle.fClipPlane[1] - circle.fIsectPlane[1], circle.fIsectPlane[0] - circle.fClipPlane[0]); SkAssertResult(geoClipPlane.normalize()); offsetClipDist = 0.5f / halfWidth; } for (int i = 0; i < 8; ++i) { // This clips the normalized offset to the half-plane we computed above. Then we // compute the vertex position from this. SkScalar dist = std::min(kOctagonOuter[i].dot(geoClipPlane) + offsetClipDist, 0.0f); SkVector offset = kOctagonOuter[i] - geoClipPlane * dist; vertices.write(center + offset * halfWidth, color, offset, radii); if (fClipPlane) { vertices.write(circle.fClipPlane); } if (fClipPlaneIsect) { vertices.write(circle.fIsectPlane); } if (fClipPlaneUnion) { vertices.write(circle.fUnionPlane); } if (fRoundCaps) { vertices.write(circle.fRoundCapCenters); } } if (circle.fStroked) { // compute the inner ring for (int i = 0; i < 8; ++i) { vertices.write(center + kOctagonInner[i] * circle.fInnerRadius, color, kOctagonInner[i] * innerRadius, radii); if (fClipPlane) { vertices.write(circle.fClipPlane); } if (fClipPlaneIsect) { vertices.write(circle.fIsectPlane); } if (fClipPlaneUnion) { vertices.write(circle.fUnionPlane); } if (fRoundCaps) { vertices.write(circle.fRoundCapCenters); } } } else { // filled vertices.write(center, color, SkPoint::Make(0, 0), radii); if (fClipPlane) { vertices.write(circle.fClipPlane); } if (fClipPlaneIsect) { vertices.write(circle.fIsectPlane); } if (fClipPlaneUnion) { vertices.write(circle.fUnionPlane); } if (fRoundCaps) { vertices.write(circle.fRoundCapCenters); } } const uint16_t* primIndices = circle_type_to_indices(circle.fStroked); const int primIndexCount = circle_type_to_index_count(circle.fStroked); for (int i = 0; i < primIndexCount; ++i) { *indices++ = primIndices[i] + currStartVertex; } currStartVertex += circle_type_to_vert_count(circle.fStroked); } fMesh = target->allocMesh(); fMesh->setIndexed(std::move(indexBuffer), fIndexCount, firstIndex, 0, fVertCount - 1, GrPrimitiveRestart::kNo, std::move(vertexBuffer), firstVertex); } void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override { if (!fProgramInfo || !fMesh) { return; } flushState->bindPipelineAndScissorClip(*fProgramInfo, chainBounds); flushState->bindTextures(fProgramInfo->primProc(), nullptr, fProgramInfo->pipeline()); flushState->drawMesh(*fMesh); } CombineResult onCombineIfPossible(GrOp* t, GrRecordingContext::Arenas*, const GrCaps& caps) override { CircleOp* that = t->cast<CircleOp>(); // can only represent 65535 unique vertices with 16-bit indices if (fVertCount + that->fVertCount > 65536) { return CombineResult::kCannotCombine; } if (!fHelper.isCompatible(that->fHelper, caps, this->bounds(), that->bounds())) { return CombineResult::kCannotCombine; } if (fHelper.usesLocalCoords() && !SkMatrixPriv::CheapEqual(fViewMatrixIfUsingLocalCoords, that->fViewMatrixIfUsingLocalCoords)) { return CombineResult::kCannotCombine; } // Because we've set up the ops that don't use the planes with noop values // we can just accumulate used planes by later ops. fClipPlane |= that->fClipPlane; fClipPlaneIsect |= that->fClipPlaneIsect; fClipPlaneUnion |= that->fClipPlaneUnion; fRoundCaps |= that->fRoundCaps; fWideColor |= that->fWideColor; fCircles.push_back_n(that->fCircles.count(), that->fCircles.begin()); fVertCount += that->fVertCount; fIndexCount += that->fIndexCount; fAllFill = fAllFill && that->fAllFill; return CombineResult::kMerged; } struct Circle { SkPMColor4f fColor; SkScalar fInnerRadius; SkScalar fOuterRadius; SkScalar fClipPlane[3]; SkScalar fIsectPlane[3]; SkScalar fUnionPlane[3]; SkPoint fRoundCapCenters[2]; SkRect fDevBounds; bool fStroked; }; SkMatrix fViewMatrixIfUsingLocalCoords; Helper fHelper; SkSTArray<1, Circle, true> fCircles; int fVertCount; int fIndexCount; bool fAllFill; bool fClipPlane; bool fClipPlaneIsect; bool fClipPlaneUnion; bool fRoundCaps; bool fWideColor; GrSimpleMesh* fMesh = nullptr; GrProgramInfo* fProgramInfo = nullptr; typedef GrMeshDrawOp INHERITED; }; class ButtCapDashedCircleOp final : public GrMeshDrawOp { private: using Helper = GrSimpleMeshDrawOpHelper; public: DEFINE_OP_CLASS_ID static std::unique_ptr<GrDrawOp> Make(GrRecordingContext* context, GrPaint&& paint, const SkMatrix& viewMatrix, SkPoint center, SkScalar radius, SkScalar strokeWidth, SkScalar startAngle, SkScalar onAngle, SkScalar offAngle, SkScalar phaseAngle) { SkASSERT(circle_stays_circle(viewMatrix)); SkASSERT(strokeWidth < 2 * radius); return Helper::FactoryHelper<ButtCapDashedCircleOp>(context, std::move(paint), viewMatrix, center, radius, strokeWidth, startAngle, onAngle, offAngle, phaseAngle); } ButtCapDashedCircleOp(const Helper::MakeArgs& helperArgs, const SkPMColor4f& color, const SkMatrix& viewMatrix, SkPoint center, SkScalar radius, SkScalar strokeWidth, SkScalar startAngle, SkScalar onAngle, SkScalar offAngle, SkScalar phaseAngle) : GrMeshDrawOp(ClassID()) , fHelper(helperArgs, GrAAType::kCoverage) { SkASSERT(circle_stays_circle(viewMatrix)); viewMatrix.mapPoints(&center, 1); radius = viewMatrix.mapRadius(radius); strokeWidth = viewMatrix.mapRadius(strokeWidth); // Determine the angle where the circle starts in device space and whether its orientation // has been reversed. SkVector start; bool reflection; if (!startAngle) { start = {1, 0}; } else { start.fY = SkScalarSin(startAngle); start.fX = SkScalarCos(startAngle); } viewMatrix.mapVectors(&start, 1); startAngle = SkScalarATan2(start.fY, start.fX); reflection = (viewMatrix.getScaleX() * viewMatrix.getScaleY() - viewMatrix.getSkewX() * viewMatrix.getSkewY()) < 0; auto totalAngle = onAngle + offAngle; phaseAngle = SkScalarMod(phaseAngle + totalAngle / 2, totalAngle) - totalAngle / 2; SkScalar halfWidth = 0; if (SkScalarNearlyZero(strokeWidth)) { halfWidth = SK_ScalarHalf; } else { halfWidth = SkScalarHalf(strokeWidth); } SkScalar outerRadius = radius + halfWidth; SkScalar innerRadius = radius - halfWidth; // The radii are outset for two reasons. First, it allows the shader to simply perform // simpler computation because the computed alpha is zero, rather than 50%, at the radius. // Second, the outer radius is used to compute the verts of the bounding box that is // rendered and the outset ensures the box will cover all partially covered by the circle. outerRadius += SK_ScalarHalf; innerRadius -= SK_ScalarHalf; fViewMatrixIfUsingLocalCoords = viewMatrix; SkRect devBounds = SkRect::MakeLTRB(center.fX - outerRadius, center.fY - outerRadius, center.fX + outerRadius, center.fY + outerRadius); // We store whether there is a reflection as a negative total angle. if (reflection) { totalAngle = -totalAngle; } fCircles.push_back(Circle{ color, outerRadius, innerRadius, onAngle, totalAngle, startAngle, phaseAngle, devBounds }); // Use the original radius and stroke radius for the bounds so that it does not include the // AA bloat. radius += halfWidth; this->setBounds( {center.fX - radius, center.fY - radius, center.fX + radius, center.fY + radius}, HasAABloat::kYes, IsHairline::kNo); fVertCount = circle_type_to_vert_count(true); fIndexCount = circle_type_to_index_count(true); } const char* name() const override { return "ButtCappedDashedCircleOp"; } void visitProxies(const VisitProxyFunc& func) const override { if (fProgramInfo) { fProgramInfo->visitFPProxies(func); } else { fHelper.visitProxies(func); } } #ifdef SK_DEBUG SkString dumpInfo() const override { SkString string; for (int i = 0; i < fCircles.count(); ++i) { string.appendf( "Color: 0x%08x Rect [L: %.2f, T: %.2f, R: %.2f, B: %.2f]," "InnerRad: %.2f, OuterRad: %.2f, OnAngle: %.2f, TotalAngle: %.2f, " "Phase: %.2f\n", fCircles[i].fColor.toBytes_RGBA(), fCircles[i].fDevBounds.fLeft, fCircles[i].fDevBounds.fTop, fCircles[i].fDevBounds.fRight, fCircles[i].fDevBounds.fBottom, fCircles[i].fInnerRadius, fCircles[i].fOuterRadius, fCircles[i].fOnAngle, fCircles[i].fTotalAngle, fCircles[i].fPhaseAngle); } string += fHelper.dumpInfo(); string += INHERITED::dumpInfo(); return string; } #endif GrProcessorSet::Analysis finalize( const GrCaps& caps, const GrAppliedClip* clip, bool hasMixedSampledCoverage, GrClampType clampType) override { SkPMColor4f* color = &fCircles.front().fColor; return fHelper.finalizeProcessors(caps, clip, hasMixedSampledCoverage, clampType, GrProcessorAnalysisCoverage::kSingleChannel, color, &fWideColor); } FixedFunctionFlags fixedFunctionFlags() const override { return fHelper.fixedFunctionFlags(); } private: GrProgramInfo* programInfo() override { return fProgramInfo; } void onCreateProgramInfo(const GrCaps* caps, SkArenaAlloc* arena, const GrSurfaceProxyView* writeView, GrAppliedClip&& appliedClip, const GrXferProcessor::DstProxyView& dstProxyView) override { SkMatrix localMatrix; if (!fViewMatrixIfUsingLocalCoords.invert(&localMatrix)) { return; } // Setup geometry processor GrGeometryProcessor* gp = ButtCapDashedCircleGeometryProcessor::Make(arena, fWideColor, localMatrix); fProgramInfo = fHelper.createProgramInfo(caps, arena, writeView, std::move(appliedClip), dstProxyView, gp, GrPrimitiveType::kTriangles); } void onPrepareDraws(Target* target) override { if (!fProgramInfo) { this->createProgramInfo(target); if (!fProgramInfo) { return; } } sk_sp<const GrBuffer> vertexBuffer; int firstVertex; GrVertexWriter vertices{target->makeVertexSpace(fProgramInfo->primProc().vertexStride(), fVertCount, &vertexBuffer, &firstVertex)}; if (!vertices.fPtr) { SkDebugf("Could not allocate vertices\n"); return; } sk_sp<const GrBuffer> indexBuffer; int firstIndex = 0; uint16_t* indices = target->makeIndexSpace(fIndexCount, &indexBuffer, &firstIndex); if (!indices) { SkDebugf("Could not allocate indices\n"); return; } int currStartVertex = 0; for (const auto& circle : fCircles) { // The inner radius in the vertex data must be specified in normalized space so that // length() can be called with smaller values to avoid precision issues with half // floats. auto normInnerRadius = circle.fInnerRadius / circle.fOuterRadius; const SkRect& bounds = circle.fDevBounds; bool reflect = false; struct { float onAngle, totalAngle, startAngle, phaseAngle; } dashParams = { circle.fOnAngle, circle.fTotalAngle, circle.fStartAngle, circle.fPhaseAngle }; if (dashParams.totalAngle < 0) { reflect = true; dashParams.totalAngle = -dashParams.totalAngle; dashParams.startAngle = -dashParams.startAngle; } GrVertexColor color(circle.fColor, fWideColor); // The bounding geometry for the circle is composed of an outer bounding octagon and // an inner bounded octagon. // Compute the vertices of the outer octagon. SkPoint center = SkPoint::Make(bounds.centerX(), bounds.centerY()); SkScalar halfWidth = 0.5f * bounds.width(); auto reflectY = [=](const SkPoint& p) { return SkPoint{ p.fX, reflect ? -p.fY : p.fY }; }; for (int i = 0; i < 8; ++i) { vertices.write(center + kOctagonOuter[i] * halfWidth, color, reflectY(kOctagonOuter[i]), circle.fOuterRadius, normInnerRadius, dashParams); } // Compute the vertices of the inner octagon. for (int i = 0; i < 8; ++i) { vertices.write(center + kOctagonInner[i] * circle.fInnerRadius, color, reflectY(kOctagonInner[i]) * normInnerRadius, circle.fOuterRadius, normInnerRadius, dashParams); } const uint16_t* primIndices = circle_type_to_indices(true); const int primIndexCount = circle_type_to_index_count(true); for (int i = 0; i < primIndexCount; ++i) { *indices++ = primIndices[i] + currStartVertex; } currStartVertex += circle_type_to_vert_count(true); } fMesh = target->allocMesh(); fMesh->setIndexed(std::move(indexBuffer), fIndexCount, firstIndex, 0, fVertCount - 1, GrPrimitiveRestart::kNo, std::move(vertexBuffer), firstVertex); } void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override { if (!fProgramInfo || !fMesh) { return; } flushState->bindPipelineAndScissorClip(*fProgramInfo, chainBounds); flushState->bindTextures(fProgramInfo->primProc(), nullptr, fProgramInfo->pipeline()); flushState->drawMesh(*fMesh); } CombineResult onCombineIfPossible(GrOp* t, GrRecordingContext::Arenas*, const GrCaps& caps) override { ButtCapDashedCircleOp* that = t->cast<ButtCapDashedCircleOp>(); // can only represent 65535 unique vertices with 16-bit indices if (fVertCount + that->fVertCount > 65536) { return CombineResult::kCannotCombine; } if (!fHelper.isCompatible(that->fHelper, caps, this->bounds(), that->bounds())) { return CombineResult::kCannotCombine; } if (fHelper.usesLocalCoords() && !SkMatrixPriv::CheapEqual(fViewMatrixIfUsingLocalCoords, that->fViewMatrixIfUsingLocalCoords)) { return CombineResult::kCannotCombine; } fCircles.push_back_n(that->fCircles.count(), that->fCircles.begin()); fVertCount += that->fVertCount; fIndexCount += that->fIndexCount; fWideColor |= that->fWideColor; return CombineResult::kMerged; } struct Circle { SkPMColor4f fColor; SkScalar fOuterRadius; SkScalar fInnerRadius; SkScalar fOnAngle; SkScalar fTotalAngle; SkScalar fStartAngle; SkScalar fPhaseAngle; SkRect fDevBounds; }; SkMatrix fViewMatrixIfUsingLocalCoords; Helper fHelper; SkSTArray<1, Circle, true> fCircles; int fVertCount; int fIndexCount; bool fWideColor; GrSimpleMesh* fMesh = nullptr; GrProgramInfo* fProgramInfo = nullptr; typedef GrMeshDrawOp INHERITED; }; /////////////////////////////////////////////////////////////////////////////// class EllipseOp : public GrMeshDrawOp { private: using Helper = GrSimpleMeshDrawOpHelper; struct DeviceSpaceParams { SkPoint fCenter; SkScalar fXRadius; SkScalar fYRadius; SkScalar fInnerXRadius; SkScalar fInnerYRadius; }; public: DEFINE_OP_CLASS_ID static std::unique_ptr<GrDrawOp> Make(GrRecordingContext* context, GrPaint&& paint, const SkMatrix& viewMatrix, const SkRect& ellipse, const SkStrokeRec& stroke) { DeviceSpaceParams params; // do any matrix crunching before we reset the draw state for device coords params.fCenter = SkPoint::Make(ellipse.centerX(), ellipse.centerY()); viewMatrix.mapPoints(&params.fCenter, 1); SkScalar ellipseXRadius = SkScalarHalf(ellipse.width()); SkScalar ellipseYRadius = SkScalarHalf(ellipse.height()); params.fXRadius = SkScalarAbs(viewMatrix[SkMatrix::kMScaleX] * ellipseXRadius + viewMatrix[SkMatrix::kMSkewX] * ellipseYRadius); params.fYRadius = SkScalarAbs(viewMatrix[SkMatrix::kMSkewY] * ellipseXRadius + viewMatrix[SkMatrix::kMScaleY] * ellipseYRadius); // do (potentially) anisotropic mapping of stroke SkVector scaledStroke; SkScalar strokeWidth = stroke.getWidth(); scaledStroke.fX = SkScalarAbs( strokeWidth * (viewMatrix[SkMatrix::kMScaleX] + viewMatrix[SkMatrix::kMSkewY])); scaledStroke.fY = SkScalarAbs( strokeWidth * (viewMatrix[SkMatrix::kMSkewX] + viewMatrix[SkMatrix::kMScaleY])); SkStrokeRec::Style style = stroke.getStyle(); bool isStrokeOnly = SkStrokeRec::kStroke_Style == style || SkStrokeRec::kHairline_Style == style; bool hasStroke = isStrokeOnly || SkStrokeRec::kStrokeAndFill_Style == style; params.fInnerXRadius = 0; params.fInnerYRadius = 0; if (hasStroke) { if (SkScalarNearlyZero(scaledStroke.length())) { scaledStroke.set(SK_ScalarHalf, SK_ScalarHalf); } else { scaledStroke.scale(SK_ScalarHalf); } // we only handle thick strokes for near-circular ellipses if (scaledStroke.length() > SK_ScalarHalf && (0.5f * params.fXRadius > params.fYRadius || 0.5f * params.fYRadius > params.fXRadius)) { return nullptr; } // we don't handle it if curvature of the stroke is less than curvature of the ellipse if (scaledStroke.fX * (params.fXRadius * params.fYRadius) < (scaledStroke.fY * scaledStroke.fY) * params.fXRadius || scaledStroke.fY * (params.fXRadius * params.fXRadius) < (scaledStroke.fX * scaledStroke.fX) * params.fYRadius) { return nullptr; } // this is legit only if scale & translation (which should be the case at the moment) if (isStrokeOnly) { params.fInnerXRadius = params.fXRadius - scaledStroke.fX; params.fInnerYRadius = params.fYRadius - scaledStroke.fY; } params.fXRadius += scaledStroke.fX; params.fYRadius += scaledStroke.fY; } // For large ovals with low precision floats, we fall back to the path renderer. // To compute the AA at the edge we divide by the gradient, which is clamped to a // minimum value to avoid divides by zero. With large ovals and low precision this // leads to blurring at the edge of the oval. const SkScalar kMaxOvalRadius = 16384; if (!context->priv().caps()->shaderCaps()->floatIs32Bits() && (params.fXRadius >= kMaxOvalRadius || params.fYRadius >= kMaxOvalRadius)) { return nullptr; } return Helper::FactoryHelper<EllipseOp>(context, std::move(paint), viewMatrix, params, stroke); } EllipseOp(const Helper::MakeArgs& helperArgs, const SkPMColor4f& color, const SkMatrix& viewMatrix, const DeviceSpaceParams& params, const SkStrokeRec& stroke) : INHERITED(ClassID()) , fHelper(helperArgs, GrAAType::kCoverage) , fUseScale(false) { SkStrokeRec::Style style = stroke.getStyle(); bool isStrokeOnly = SkStrokeRec::kStroke_Style == style || SkStrokeRec::kHairline_Style == style; fEllipses.emplace_back(Ellipse{color, params.fXRadius, params.fYRadius, params.fInnerXRadius, params.fInnerYRadius, SkRect::MakeLTRB(params.fCenter.fX - params.fXRadius, params.fCenter.fY - params.fYRadius, params.fCenter.fX + params.fXRadius, params.fCenter.fY + params.fYRadius)}); this->setBounds(fEllipses.back().fDevBounds, HasAABloat::kYes, IsHairline::kNo); // Outset bounds to include half-pixel width antialiasing. fEllipses[0].fDevBounds.outset(SK_ScalarHalf, SK_ScalarHalf); fStroked = isStrokeOnly && params.fInnerXRadius > 0 && params.fInnerYRadius > 0; fViewMatrixIfUsingLocalCoords = viewMatrix; } const char* name() const override { return "EllipseOp"; } void visitProxies(const VisitProxyFunc& func) const override { if (fProgramInfo) { fProgramInfo->visitFPProxies(func); } else { fHelper.visitProxies(func); } } #ifdef SK_DEBUG SkString dumpInfo() const override { SkString string; string.appendf("Stroked: %d\n", fStroked); for (const auto& geo : fEllipses) { string.appendf( "Color: 0x%08x Rect [L: %.2f, T: %.2f, R: %.2f, B: %.2f], " "XRad: %.2f, YRad: %.2f, InnerXRad: %.2f, InnerYRad: %.2f\n", geo.fColor.toBytes_RGBA(), geo.fDevBounds.fLeft, geo.fDevBounds.fTop, geo.fDevBounds.fRight, geo.fDevBounds.fBottom, geo.fXRadius, geo.fYRadius, geo.fInnerXRadius, geo.fInnerYRadius); } string += fHelper.dumpInfo(); string += INHERITED::dumpInfo(); return string; } #endif GrProcessorSet::Analysis finalize( const GrCaps& caps, const GrAppliedClip* clip, bool hasMixedSampledCoverage, GrClampType clampType) override { fUseScale = !caps.shaderCaps()->floatIs32Bits() && !caps.shaderCaps()->hasLowFragmentPrecision(); SkPMColor4f* color = &fEllipses.front().fColor; return fHelper.finalizeProcessors(caps, clip, hasMixedSampledCoverage, clampType, GrProcessorAnalysisCoverage::kSingleChannel, color, &fWideColor); } FixedFunctionFlags fixedFunctionFlags() const override { return fHelper.fixedFunctionFlags(); } private: GrProgramInfo* programInfo() override { return fProgramInfo; } void onCreateProgramInfo(const GrCaps* caps, SkArenaAlloc* arena, const GrSurfaceProxyView* writeView, GrAppliedClip&& appliedClip, const GrXferProcessor::DstProxyView& dstProxyView) override { SkMatrix localMatrix; if (!fViewMatrixIfUsingLocalCoords.invert(&localMatrix)) { return; } GrGeometryProcessor* gp = EllipseGeometryProcessor::Make(arena, fStroked, fWideColor, fUseScale, localMatrix); fProgramInfo = fHelper.createProgramInfo(caps, arena, writeView, std::move(appliedClip), dstProxyView, gp, GrPrimitiveType::kTriangles); } void onPrepareDraws(Target* target) override { if (!fProgramInfo) { this->createProgramInfo(target); if (!fProgramInfo) { return; } } QuadHelper helper(target, fProgramInfo->primProc().vertexStride(), fEllipses.count()); GrVertexWriter verts{helper.vertices()}; if (!verts.fPtr) { SkDebugf("Could not allocate vertices\n"); return; } for (const auto& ellipse : fEllipses) { GrVertexColor color(ellipse.fColor, fWideColor); SkScalar xRadius = ellipse.fXRadius; SkScalar yRadius = ellipse.fYRadius; // Compute the reciprocals of the radii here to save time in the shader struct { float xOuter, yOuter, xInner, yInner; } invRadii = { SkScalarInvert(xRadius), SkScalarInvert(yRadius), SkScalarInvert(ellipse.fInnerXRadius), SkScalarInvert(ellipse.fInnerYRadius) }; SkScalar xMaxOffset = xRadius + SK_ScalarHalf; SkScalar yMaxOffset = yRadius + SK_ScalarHalf; if (!fStroked) { // For filled ellipses we map a unit circle in the vertex attributes rather than // computing an ellipse and modifying that distance, so we normalize to 1 xMaxOffset /= xRadius; yMaxOffset /= yRadius; } // The inner radius in the vertex data must be specified in normalized space. verts.writeQuad(GrVertexWriter::TriStripFromRect(ellipse.fDevBounds), color, origin_centered_tri_strip(xMaxOffset, yMaxOffset), GrVertexWriter::If(fUseScale, std::max(xRadius, yRadius)), invRadii); } fMesh = helper.mesh(); } void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override { if (!fProgramInfo || !fMesh) { return; } flushState->bindPipelineAndScissorClip(*fProgramInfo, chainBounds); flushState->bindTextures(fProgramInfo->primProc(), nullptr, fProgramInfo->pipeline()); flushState->drawMesh(*fMesh); } CombineResult onCombineIfPossible(GrOp* t, GrRecordingContext::Arenas*, const GrCaps& caps) override { EllipseOp* that = t->cast<EllipseOp>(); if (!fHelper.isCompatible(that->fHelper, caps, this->bounds(), that->bounds())) { return CombineResult::kCannotCombine; } if (fStroked != that->fStroked) { return CombineResult::kCannotCombine; } if (fHelper.usesLocalCoords() && !SkMatrixPriv::CheapEqual(fViewMatrixIfUsingLocalCoords, that->fViewMatrixIfUsingLocalCoords)) { return CombineResult::kCannotCombine; } fEllipses.push_back_n(that->fEllipses.count(), that->fEllipses.begin()); fWideColor |= that->fWideColor; return CombineResult::kMerged; } struct Ellipse { SkPMColor4f fColor; SkScalar fXRadius; SkScalar fYRadius; SkScalar fInnerXRadius; SkScalar fInnerYRadius; SkRect fDevBounds; }; SkMatrix fViewMatrixIfUsingLocalCoords; Helper fHelper; bool fStroked; bool fWideColor; bool fUseScale; SkSTArray<1, Ellipse, true> fEllipses; GrSimpleMesh* fMesh = nullptr; GrProgramInfo* fProgramInfo = nullptr; typedef GrMeshDrawOp INHERITED; }; ///////////////////////////////////////////////////////////////////////////////////////////////// class DIEllipseOp : public GrMeshDrawOp { private: using Helper = GrSimpleMeshDrawOpHelper; struct DeviceSpaceParams { SkPoint fCenter; SkScalar fXRadius; SkScalar fYRadius; SkScalar fInnerXRadius; SkScalar fInnerYRadius; DIEllipseStyle fStyle; }; public: DEFINE_OP_CLASS_ID static std::unique_ptr<GrDrawOp> Make(GrRecordingContext* context, GrPaint&& paint, const SkMatrix& viewMatrix, const SkRect& ellipse, const SkStrokeRec& stroke) { DeviceSpaceParams params; params.fCenter = SkPoint::Make(ellipse.centerX(), ellipse.centerY()); params.fXRadius = SkScalarHalf(ellipse.width()); params.fYRadius = SkScalarHalf(ellipse.height()); SkStrokeRec::Style style = stroke.getStyle(); params.fStyle = (SkStrokeRec::kStroke_Style == style) ? DIEllipseStyle::kStroke : (SkStrokeRec::kHairline_Style == style) ? DIEllipseStyle::kHairline : DIEllipseStyle::kFill; params.fInnerXRadius = 0; params.fInnerYRadius = 0; if (SkStrokeRec::kFill_Style != style && SkStrokeRec::kHairline_Style != style) { SkScalar strokeWidth = stroke.getWidth(); if (SkScalarNearlyZero(strokeWidth)) { strokeWidth = SK_ScalarHalf; } else { strokeWidth *= SK_ScalarHalf; } // we only handle thick strokes for near-circular ellipses if (strokeWidth > SK_ScalarHalf && (SK_ScalarHalf * params.fXRadius > params.fYRadius || SK_ScalarHalf * params.fYRadius > params.fXRadius)) { return nullptr; } // we don't handle it if curvature of the stroke is less than curvature of the ellipse if (strokeWidth * (params.fYRadius * params.fYRadius) < (strokeWidth * strokeWidth) * params.fXRadius) { return nullptr; } if (strokeWidth * (params.fXRadius * params.fXRadius) < (strokeWidth * strokeWidth) * params.fYRadius) { return nullptr; } // set inner radius (if needed) if (SkStrokeRec::kStroke_Style == style) { params.fInnerXRadius = params.fXRadius - strokeWidth; params.fInnerYRadius = params.fYRadius - strokeWidth; } params.fXRadius += strokeWidth; params.fYRadius += strokeWidth; } // For large ovals with low precision floats, we fall back to the path renderer. // To compute the AA at the edge we divide by the gradient, which is clamped to a // minimum value to avoid divides by zero. With large ovals and low precision this // leads to blurring at the edge of the oval. const SkScalar kMaxOvalRadius = 16384; if (!context->priv().caps()->shaderCaps()->floatIs32Bits() && (params.fXRadius >= kMaxOvalRadius || params.fYRadius >= kMaxOvalRadius)) { return nullptr; } if (DIEllipseStyle::kStroke == params.fStyle && (params.fInnerXRadius <= 0 || params.fInnerYRadius <= 0)) { params.fStyle = DIEllipseStyle::kFill; } return Helper::FactoryHelper<DIEllipseOp>(context, std::move(paint), params, viewMatrix); } DIEllipseOp(Helper::MakeArgs& helperArgs, const SkPMColor4f& color, const DeviceSpaceParams& params, const SkMatrix& viewMatrix) : INHERITED(ClassID()) , fHelper(helperArgs, GrAAType::kCoverage) , fUseScale(false) { // This expands the outer rect so that after CTM we end up with a half-pixel border SkScalar a = viewMatrix[SkMatrix::kMScaleX]; SkScalar b = viewMatrix[SkMatrix::kMSkewX]; SkScalar c = viewMatrix[SkMatrix::kMSkewY]; SkScalar d = viewMatrix[SkMatrix::kMScaleY]; SkScalar geoDx = SK_ScalarHalf / SkScalarSqrt(a * a + c * c); SkScalar geoDy = SK_ScalarHalf / SkScalarSqrt(b * b + d * d); fEllipses.emplace_back( Ellipse{viewMatrix, color, params.fXRadius, params.fYRadius, params.fInnerXRadius, params.fInnerYRadius, geoDx, geoDy, params.fStyle, SkRect::MakeLTRB(params.fCenter.fX - params.fXRadius - geoDx, params.fCenter.fY - params.fYRadius - geoDy, params.fCenter.fX + params.fXRadius + geoDx, params.fCenter.fY + params.fYRadius + geoDy)}); this->setTransformedBounds(fEllipses[0].fBounds, viewMatrix, HasAABloat::kYes, IsHairline::kNo); } const char* name() const override { return "DIEllipseOp"; } void visitProxies(const VisitProxyFunc& func) const override { if (fProgramInfo) { fProgramInfo->visitFPProxies(func); } else { fHelper.visitProxies(func); } } #ifdef SK_DEBUG SkString dumpInfo() const override { SkString string; for (const auto& geo : fEllipses) { string.appendf( "Color: 0x%08x Rect [L: %.2f, T: %.2f, R: %.2f, B: %.2f], XRad: %.2f, " "YRad: %.2f, InnerXRad: %.2f, InnerYRad: %.2f, GeoDX: %.2f, " "GeoDY: %.2f\n", geo.fColor.toBytes_RGBA(), geo.fBounds.fLeft, geo.fBounds.fTop, geo.fBounds.fRight, geo.fBounds.fBottom, geo.fXRadius, geo.fYRadius, geo.fInnerXRadius, geo.fInnerYRadius, geo.fGeoDx, geo.fGeoDy); } string += fHelper.dumpInfo(); string += INHERITED::dumpInfo(); return string; } #endif GrProcessorSet::Analysis finalize( const GrCaps& caps, const GrAppliedClip* clip, bool hasMixedSampledCoverage, GrClampType clampType) override { fUseScale = !caps.shaderCaps()->floatIs32Bits() && !caps.shaderCaps()->hasLowFragmentPrecision(); SkPMColor4f* color = &fEllipses.front().fColor; return fHelper.finalizeProcessors(caps, clip, hasMixedSampledCoverage, clampType, GrProcessorAnalysisCoverage::kSingleChannel, color, &fWideColor); } FixedFunctionFlags fixedFunctionFlags() const override { return fHelper.fixedFunctionFlags(); } private: GrProgramInfo* programInfo() override { return fProgramInfo; } void onCreateProgramInfo(const GrCaps* caps, SkArenaAlloc* arena, const GrSurfaceProxyView* writeView, GrAppliedClip&& appliedClip, const GrXferProcessor::DstProxyView& dstProxyView) override { GrGeometryProcessor* gp = DIEllipseGeometryProcessor::Make(arena, fWideColor, fUseScale, this->viewMatrix(), this->style()); fProgramInfo = fHelper.createProgramInfo(caps, arena, writeView, std::move(appliedClip), dstProxyView, gp, GrPrimitiveType::kTriangles); } void onPrepareDraws(Target* target) override { if (!fProgramInfo) { this->createProgramInfo(target); } QuadHelper helper(target, fProgramInfo->primProc().vertexStride(), fEllipses.count()); GrVertexWriter verts{helper.vertices()}; if (!verts.fPtr) { return; } for (const auto& ellipse : fEllipses) { GrVertexColor color(ellipse.fColor, fWideColor); SkScalar xRadius = ellipse.fXRadius; SkScalar yRadius = ellipse.fYRadius; // This adjusts the "radius" to include the half-pixel border SkScalar offsetDx = ellipse.fGeoDx / xRadius; SkScalar offsetDy = ellipse.fGeoDy / yRadius; // By default, constructed so that inner offset is (0, 0) for all points SkScalar innerRatioX = -offsetDx; SkScalar innerRatioY = -offsetDy; // ... unless we're stroked if (DIEllipseStyle::kStroke == this->style()) { innerRatioX = xRadius / ellipse.fInnerXRadius; innerRatioY = yRadius / ellipse.fInnerYRadius; } verts.writeQuad(GrVertexWriter::TriStripFromRect(ellipse.fBounds), color, origin_centered_tri_strip(1.0f + offsetDx, 1.0f + offsetDy), GrVertexWriter::If(fUseScale, std::max(xRadius, yRadius)), origin_centered_tri_strip(innerRatioX + offsetDx, innerRatioY + offsetDy)); } fMesh = helper.mesh(); } void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override { if (!fProgramInfo || !fMesh) { return; } flushState->bindPipelineAndScissorClip(*fProgramInfo, chainBounds); flushState->bindTextures(fProgramInfo->primProc(), nullptr, fProgramInfo->pipeline()); flushState->drawMesh(*fMesh); } CombineResult onCombineIfPossible(GrOp* t, GrRecordingContext::Arenas*, const GrCaps& caps) override { DIEllipseOp* that = t->cast<DIEllipseOp>(); if (!fHelper.isCompatible(that->fHelper, caps, this->bounds(), that->bounds())) { return CombineResult::kCannotCombine; } if (this->style() != that->style()) { return CombineResult::kCannotCombine; } // TODO rewrite to allow positioning on CPU if (!SkMatrixPriv::CheapEqual(this->viewMatrix(), that->viewMatrix())) { return CombineResult::kCannotCombine; } fEllipses.push_back_n(that->fEllipses.count(), that->fEllipses.begin()); fWideColor |= that->fWideColor; return CombineResult::kMerged; } const SkMatrix& viewMatrix() const { return fEllipses[0].fViewMatrix; } DIEllipseStyle style() const { return fEllipses[0].fStyle; } struct Ellipse { SkMatrix fViewMatrix; SkPMColor4f fColor; SkScalar fXRadius; SkScalar fYRadius; SkScalar fInnerXRadius; SkScalar fInnerYRadius; SkScalar fGeoDx; SkScalar fGeoDy; DIEllipseStyle fStyle; SkRect fBounds; }; Helper fHelper; bool fWideColor; bool fUseScale; SkSTArray<1, Ellipse, true> fEllipses; GrSimpleMesh* fMesh = nullptr; GrProgramInfo* fProgramInfo = nullptr; typedef GrMeshDrawOp INHERITED; }; /////////////////////////////////////////////////////////////////////////////// // We have three possible cases for geometry for a roundrect. // // In the case of a normal fill or a stroke, we draw the roundrect as a 9-patch: // ____________ // |_|________|_| // | | | | // | | | | // | | | | // |_|________|_| // |_|________|_| // // For strokes, we don't draw the center quad. // // For circular roundrects, in the case where the stroke width is greater than twice // the corner radius (overstroke), we add additional geometry to mark out the rectangle // in the center. The shared vertices are duplicated so we can set a different outer radius // for the fill calculation. // ____________ // |_|________|_| // | |\ ____ /| | // | | | | | | // | | |____| | | // |_|/______\|_| // |_|________|_| // // We don't draw the center quad from the fill rect in this case. // // For filled rrects that need to provide a distance vector we resuse the overstroke // geometry but make the inner rect degenerate (either a point or a horizontal or // vertical line). static const uint16_t gOverstrokeRRectIndices[] = { // clang-format off // overstroke quads // we place this at the beginning so that we can skip these indices when rendering normally 16, 17, 19, 16, 19, 18, 19, 17, 23, 19, 23, 21, 21, 23, 22, 21, 22, 20, 22, 16, 18, 22, 18, 20, // corners 0, 1, 5, 0, 5, 4, 2, 3, 7, 2, 7, 6, 8, 9, 13, 8, 13, 12, 10, 11, 15, 10, 15, 14, // edges 1, 2, 6, 1, 6, 5, 4, 5, 9, 4, 9, 8, 6, 7, 11, 6, 11, 10, 9, 10, 14, 9, 14, 13, // center // we place this at the end so that we can ignore these indices when not rendering as filled 5, 6, 10, 5, 10, 9, // clang-format on }; // fill and standard stroke indices skip the overstroke "ring" static const uint16_t* gStandardRRectIndices = gOverstrokeRRectIndices + 6 * 4; // overstroke count is arraysize minus the center indices static const int kIndicesPerOverstrokeRRect = SK_ARRAY_COUNT(gOverstrokeRRectIndices) - 6; // fill count skips overstroke indices and includes center static const int kIndicesPerFillRRect = kIndicesPerOverstrokeRRect - 6 * 4 + 6; // stroke count is fill count minus center indices static const int kIndicesPerStrokeRRect = kIndicesPerFillRRect - 6; static const int kVertsPerStandardRRect = 16; static const int kVertsPerOverstrokeRRect = 24; enum RRectType { kFill_RRectType, kStroke_RRectType, kOverstroke_RRectType, }; static int rrect_type_to_vert_count(RRectType type) { switch (type) { case kFill_RRectType: case kStroke_RRectType: return kVertsPerStandardRRect; case kOverstroke_RRectType: return kVertsPerOverstrokeRRect; } SK_ABORT("Invalid type"); } static int rrect_type_to_index_count(RRectType type) { switch (type) { case kFill_RRectType: return kIndicesPerFillRRect; case kStroke_RRectType: return kIndicesPerStrokeRRect; case kOverstroke_RRectType: return kIndicesPerOverstrokeRRect; } SK_ABORT("Invalid type"); } static const uint16_t* rrect_type_to_indices(RRectType type) { switch (type) { case kFill_RRectType: case kStroke_RRectType: return gStandardRRectIndices; case kOverstroke_RRectType: return gOverstrokeRRectIndices; } SK_ABORT("Invalid type"); } /////////////////////////////////////////////////////////////////////////////////////////////////// // For distance computations in the interior of filled rrects we: // // add a interior degenerate (point or line) rect // each vertex of that rect gets -outerRad as its radius // this makes the computation of the distance to the outer edge be negative // negative values are caught and then handled differently in the GP's onEmitCode // each vertex is also given the normalized x & y distance from the interior rect's edge // the GP takes the min of those depths +1 to get the normalized distance to the outer edge class CircularRRectOp : public GrMeshDrawOp { private: using Helper = GrSimpleMeshDrawOpHelper; public: DEFINE_OP_CLASS_ID // A devStrokeWidth <= 0 indicates a fill only. If devStrokeWidth > 0 then strokeOnly indicates // whether the rrect is only stroked or stroked and filled. static std::unique_ptr<GrDrawOp> Make(GrRecordingContext* context, GrPaint&& paint, const SkMatrix& viewMatrix, const SkRect& devRect, float devRadius, float devStrokeWidth, bool strokeOnly) { return Helper::FactoryHelper<CircularRRectOp>(context, std::move(paint), viewMatrix, devRect, devRadius, devStrokeWidth, strokeOnly); } CircularRRectOp(Helper::MakeArgs& helperArgs, const SkPMColor4f& color, const SkMatrix& viewMatrix, const SkRect& devRect, float devRadius, float devStrokeWidth, bool strokeOnly) : INHERITED(ClassID()) , fViewMatrixIfUsingLocalCoords(viewMatrix) , fHelper(helperArgs, GrAAType::kCoverage) { SkRect bounds = devRect; SkASSERT(!(devStrokeWidth <= 0 && strokeOnly)); SkScalar innerRadius = 0.0f; SkScalar outerRadius = devRadius; SkScalar halfWidth = 0; RRectType type = kFill_RRectType; if (devStrokeWidth > 0) { if (SkScalarNearlyZero(devStrokeWidth)) { halfWidth = SK_ScalarHalf; } else { halfWidth = SkScalarHalf(devStrokeWidth); } if (strokeOnly) { // Outset stroke by 1/4 pixel devStrokeWidth += 0.25f; // If stroke is greater than width or height, this is still a fill // Otherwise we compute stroke params if (devStrokeWidth <= devRect.width() && devStrokeWidth <= devRect.height()) { innerRadius = devRadius - halfWidth; type = (innerRadius >= 0) ? kStroke_RRectType : kOverstroke_RRectType; } } outerRadius += halfWidth; bounds.outset(halfWidth, halfWidth); } // The radii are outset for two reasons. First, it allows the shader to simply perform // simpler computation because the computed alpha is zero, rather than 50%, at the radius. // Second, the outer radius is used to compute the verts of the bounding box that is // rendered and the outset ensures the box will cover all partially covered by the rrect // corners. outerRadius += SK_ScalarHalf; innerRadius -= SK_ScalarHalf; this->setBounds(bounds, HasAABloat::kYes, IsHairline::kNo); // Expand the rect for aa to generate correct vertices. bounds.outset(SK_ScalarHalf, SK_ScalarHalf); fRRects.emplace_back(RRect{color, innerRadius, outerRadius, bounds, type}); fVertCount = rrect_type_to_vert_count(type); fIndexCount = rrect_type_to_index_count(type); fAllFill = (kFill_RRectType == type); } const char* name() const override { return "CircularRRectOp"; } void visitProxies(const VisitProxyFunc& func) const override { if (fProgramInfo) { fProgramInfo->visitFPProxies(func); } else { fHelper.visitProxies(func); } } #ifdef SK_DEBUG SkString dumpInfo() const override { SkString string; for (int i = 0; i < fRRects.count(); ++i) { string.appendf( "Color: 0x%08x Rect [L: %.2f, T: %.2f, R: %.2f, B: %.2f]," "InnerRad: %.2f, OuterRad: %.2f\n", fRRects[i].fColor.toBytes_RGBA(), fRRects[i].fDevBounds.fLeft, fRRects[i].fDevBounds.fTop, fRRects[i].fDevBounds.fRight, fRRects[i].fDevBounds.fBottom, fRRects[i].fInnerRadius, fRRects[i].fOuterRadius); } string += fHelper.dumpInfo(); string += INHERITED::dumpInfo(); return string; } #endif GrProcessorSet::Analysis finalize( const GrCaps& caps, const GrAppliedClip* clip, bool hasMixedSampledCoverage, GrClampType clampType) override { SkPMColor4f* color = &fRRects.front().fColor; return fHelper.finalizeProcessors(caps, clip, hasMixedSampledCoverage, clampType, GrProcessorAnalysisCoverage::kSingleChannel, color, &fWideColor); } FixedFunctionFlags fixedFunctionFlags() const override { return fHelper.fixedFunctionFlags(); } private: static void FillInOverstrokeVerts(GrVertexWriter& verts, const SkRect& bounds, SkScalar smInset, SkScalar bigInset, SkScalar xOffset, SkScalar outerRadius, SkScalar innerRadius, const GrVertexColor& color) { SkASSERT(smInset < bigInset); // TL verts.write(bounds.fLeft + smInset, bounds.fTop + smInset, color, xOffset, 0.0f, outerRadius, innerRadius); // TR verts.write(bounds.fRight - smInset, bounds.fTop + smInset, color, xOffset, 0.0f, outerRadius, innerRadius); verts.write(bounds.fLeft + bigInset, bounds.fTop + bigInset, color, 0.0f, 0.0f, outerRadius, innerRadius); verts.write(bounds.fRight - bigInset, bounds.fTop + bigInset, color, 0.0f, 0.0f, outerRadius, innerRadius); verts.write(bounds.fLeft + bigInset, bounds.fBottom - bigInset, color, 0.0f, 0.0f, outerRadius, innerRadius); verts.write(bounds.fRight - bigInset, bounds.fBottom - bigInset, color, 0.0f, 0.0f, outerRadius, innerRadius); // BL verts.write(bounds.fLeft + smInset, bounds.fBottom - smInset, color, xOffset, 0.0f, outerRadius, innerRadius); // BR verts.write(bounds.fRight - smInset, bounds.fBottom - smInset, color, xOffset, 0.0f, outerRadius, innerRadius); } GrProgramInfo* programInfo() override { return fProgramInfo; } void onCreateProgramInfo(const GrCaps* caps, SkArenaAlloc* arena, const GrSurfaceProxyView* writeView, GrAppliedClip&& appliedClip, const GrXferProcessor::DstProxyView& dstProxyView) override { // Invert the view matrix as a local matrix (if any other processors require coords). SkMatrix localMatrix; if (!fViewMatrixIfUsingLocalCoords.invert(&localMatrix)) { return; } GrGeometryProcessor* gp = CircleGeometryProcessor::Make(arena, !fAllFill, false, false, false, false, fWideColor, localMatrix); fProgramInfo = fHelper.createProgramInfo(caps, arena, writeView, std::move(appliedClip), dstProxyView, gp, GrPrimitiveType::kTriangles); } void onPrepareDraws(Target* target) override { if (!fProgramInfo) { this->createProgramInfo(target); if (!fProgramInfo) { return; } } sk_sp<const GrBuffer> vertexBuffer; int firstVertex; GrVertexWriter verts{target->makeVertexSpace(fProgramInfo->primProc().vertexStride(), fVertCount, &vertexBuffer, &firstVertex)}; if (!verts.fPtr) { SkDebugf("Could not allocate vertices\n"); return; } sk_sp<const GrBuffer> indexBuffer; int firstIndex = 0; uint16_t* indices = target->makeIndexSpace(fIndexCount, &indexBuffer, &firstIndex); if (!indices) { SkDebugf("Could not allocate indices\n"); return; } int currStartVertex = 0; for (const auto& rrect : fRRects) { GrVertexColor color(rrect.fColor, fWideColor); SkScalar outerRadius = rrect.fOuterRadius; const SkRect& bounds = rrect.fDevBounds; SkScalar yCoords[4] = {bounds.fTop, bounds.fTop + outerRadius, bounds.fBottom - outerRadius, bounds.fBottom}; SkScalar yOuterRadii[4] = {-1, 0, 0, 1}; // The inner radius in the vertex data must be specified in normalized space. // For fills, specifying -1/outerRadius guarantees an alpha of 1.0 at the inner radius. SkScalar innerRadius = rrect.fType != kFill_RRectType ? rrect.fInnerRadius / rrect.fOuterRadius : -1.0f / rrect.fOuterRadius; for (int i = 0; i < 4; ++i) { verts.write(bounds.fLeft, yCoords[i], color, -1.0f, yOuterRadii[i], outerRadius, innerRadius); verts.write(bounds.fLeft + outerRadius, yCoords[i], color, 0.0f, yOuterRadii[i], outerRadius, innerRadius); verts.write(bounds.fRight - outerRadius, yCoords[i], color, 0.0f, yOuterRadii[i], outerRadius, innerRadius); verts.write(bounds.fRight, yCoords[i], color, 1.0f, yOuterRadii[i], outerRadius, innerRadius); } // Add the additional vertices for overstroked rrects. // Effectively this is an additional stroked rrect, with its // outer radius = outerRadius - innerRadius, and inner radius = 0. // This will give us correct AA in the center and the correct // distance to the outer edge. // // Also, the outer offset is a constant vector pointing to the right, which // guarantees that the distance value along the outer rectangle is constant. if (kOverstroke_RRectType == rrect.fType) { SkASSERT(rrect.fInnerRadius <= 0.0f); SkScalar overstrokeOuterRadius = outerRadius - rrect.fInnerRadius; // this is the normalized distance from the outer rectangle of this // geometry to the outer edge SkScalar maxOffset = -rrect.fInnerRadius / overstrokeOuterRadius; FillInOverstrokeVerts(verts, bounds, outerRadius, overstrokeOuterRadius, maxOffset, overstrokeOuterRadius, 0.0f, color); } const uint16_t* primIndices = rrect_type_to_indices(rrect.fType); const int primIndexCount = rrect_type_to_index_count(rrect.fType); for (int i = 0; i < primIndexCount; ++i) { *indices++ = primIndices[i] + currStartVertex; } currStartVertex += rrect_type_to_vert_count(rrect.fType); } fMesh = target->allocMesh(); fMesh->setIndexed(std::move(indexBuffer), fIndexCount, firstIndex, 0, fVertCount - 1, GrPrimitiveRestart::kNo, std::move(vertexBuffer), firstVertex); } void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override { if (!fProgramInfo || !fMesh) { return; } flushState->bindPipelineAndScissorClip(*fProgramInfo, chainBounds); flushState->bindTextures(fProgramInfo->primProc(), nullptr, fProgramInfo->pipeline()); flushState->drawMesh(*fMesh); } CombineResult onCombineIfPossible(GrOp* t, GrRecordingContext::Arenas*, const GrCaps& caps) override { CircularRRectOp* that = t->cast<CircularRRectOp>(); // can only represent 65535 unique vertices with 16-bit indices if (fVertCount + that->fVertCount > 65536) { return CombineResult::kCannotCombine; } if (!fHelper.isCompatible(that->fHelper, caps, this->bounds(), that->bounds())) { return CombineResult::kCannotCombine; } if (fHelper.usesLocalCoords() && !SkMatrixPriv::CheapEqual(fViewMatrixIfUsingLocalCoords, that->fViewMatrixIfUsingLocalCoords)) { return CombineResult::kCannotCombine; } fRRects.push_back_n(that->fRRects.count(), that->fRRects.begin()); fVertCount += that->fVertCount; fIndexCount += that->fIndexCount; fAllFill = fAllFill && that->fAllFill; fWideColor = fWideColor || that->fWideColor; return CombineResult::kMerged; } struct RRect { SkPMColor4f fColor; SkScalar fInnerRadius; SkScalar fOuterRadius; SkRect fDevBounds; RRectType fType; }; SkMatrix fViewMatrixIfUsingLocalCoords; Helper fHelper; int fVertCount; int fIndexCount; bool fAllFill; bool fWideColor; SkSTArray<1, RRect, true> fRRects; GrSimpleMesh* fMesh = nullptr; GrProgramInfo* fProgramInfo = nullptr; typedef GrMeshDrawOp INHERITED; }; static const int kNumRRectsInIndexBuffer = 256; GR_DECLARE_STATIC_UNIQUE_KEY(gStrokeRRectOnlyIndexBufferKey); GR_DECLARE_STATIC_UNIQUE_KEY(gRRectOnlyIndexBufferKey); static sk_sp<const GrBuffer> get_rrect_index_buffer(RRectType type, GrResourceProvider* resourceProvider) { GR_DEFINE_STATIC_UNIQUE_KEY(gStrokeRRectOnlyIndexBufferKey); GR_DEFINE_STATIC_UNIQUE_KEY(gRRectOnlyIndexBufferKey); switch (type) { case kFill_RRectType: return resourceProvider->findOrCreatePatternedIndexBuffer( gStandardRRectIndices, kIndicesPerFillRRect, kNumRRectsInIndexBuffer, kVertsPerStandardRRect, gRRectOnlyIndexBufferKey); case kStroke_RRectType: return resourceProvider->findOrCreatePatternedIndexBuffer( gStandardRRectIndices, kIndicesPerStrokeRRect, kNumRRectsInIndexBuffer, kVertsPerStandardRRect, gStrokeRRectOnlyIndexBufferKey); default: SkASSERT(false); return nullptr; } } class EllipticalRRectOp : public GrMeshDrawOp { private: using Helper = GrSimpleMeshDrawOpHelper; public: DEFINE_OP_CLASS_ID // If devStrokeWidths values are <= 0 indicates then fill only. Otherwise, strokeOnly indicates // whether the rrect is only stroked or stroked and filled. static std::unique_ptr<GrDrawOp> Make(GrRecordingContext* context, GrPaint&& paint, const SkMatrix& viewMatrix, const SkRect& devRect, float devXRadius, float devYRadius, SkVector devStrokeWidths, bool strokeOnly) { SkASSERT(devXRadius >= 0.5); SkASSERT(devYRadius >= 0.5); SkASSERT((devStrokeWidths.fX > 0) == (devStrokeWidths.fY > 0)); SkASSERT(!(strokeOnly && devStrokeWidths.fX <= 0)); if (devStrokeWidths.fX > 0) { if (SkScalarNearlyZero(devStrokeWidths.length())) { devStrokeWidths.set(SK_ScalarHalf, SK_ScalarHalf); } else { devStrokeWidths.scale(SK_ScalarHalf); } // we only handle thick strokes for near-circular ellipses if (devStrokeWidths.length() > SK_ScalarHalf && (SK_ScalarHalf * devXRadius > devYRadius || SK_ScalarHalf * devYRadius > devXRadius)) { return nullptr; } // we don't handle it if curvature of the stroke is less than curvature of the ellipse if (devStrokeWidths.fX * (devYRadius * devYRadius) < (devStrokeWidths.fY * devStrokeWidths.fY) * devXRadius) { return nullptr; } if (devStrokeWidths.fY * (devXRadius * devXRadius) < (devStrokeWidths.fX * devStrokeWidths.fX) * devYRadius) { return nullptr; } } return Helper::FactoryHelper<EllipticalRRectOp>(context, std::move(paint), viewMatrix, devRect, devXRadius, devYRadius, devStrokeWidths, strokeOnly); } EllipticalRRectOp(Helper::MakeArgs helperArgs, const SkPMColor4f& color, const SkMatrix& viewMatrix, const SkRect& devRect, float devXRadius, float devYRadius, SkVector devStrokeHalfWidths, bool strokeOnly) : INHERITED(ClassID()) , fHelper(helperArgs, GrAAType::kCoverage) , fUseScale(false) { SkScalar innerXRadius = 0.0f; SkScalar innerYRadius = 0.0f; SkRect bounds = devRect; bool stroked = false; if (devStrokeHalfWidths.fX > 0) { // this is legit only if scale & translation (which should be the case at the moment) if (strokeOnly) { innerXRadius = devXRadius - devStrokeHalfWidths.fX; innerYRadius = devYRadius - devStrokeHalfWidths.fY; stroked = (innerXRadius >= 0 && innerYRadius >= 0); } devXRadius += devStrokeHalfWidths.fX; devYRadius += devStrokeHalfWidths.fY; bounds.outset(devStrokeHalfWidths.fX, devStrokeHalfWidths.fY); } fStroked = stroked; fViewMatrixIfUsingLocalCoords = viewMatrix; this->setBounds(bounds, HasAABloat::kYes, IsHairline::kNo); // Expand the rect for aa in order to generate the correct vertices. bounds.outset(SK_ScalarHalf, SK_ScalarHalf); fRRects.emplace_back( RRect{color, devXRadius, devYRadius, innerXRadius, innerYRadius, bounds}); } const char* name() const override { return "EllipticalRRectOp"; } void visitProxies(const VisitProxyFunc& func) const override { if (fProgramInfo) { fProgramInfo->visitFPProxies(func); } else { fHelper.visitProxies(func); } } #ifdef SK_DEBUG SkString dumpInfo() const override { SkString string; string.appendf("Stroked: %d\n", fStroked); for (const auto& geo : fRRects) { string.appendf( "Color: 0x%08x Rect [L: %.2f, T: %.2f, R: %.2f, B: %.2f], " "XRad: %.2f, YRad: %.2f, InnerXRad: %.2f, InnerYRad: %.2f\n", geo.fColor.toBytes_RGBA(), geo.fDevBounds.fLeft, geo.fDevBounds.fTop, geo.fDevBounds.fRight, geo.fDevBounds.fBottom, geo.fXRadius, geo.fYRadius, geo.fInnerXRadius, geo.fInnerYRadius); } string += fHelper.dumpInfo(); string += INHERITED::dumpInfo(); return string; } #endif GrProcessorSet::Analysis finalize( const GrCaps& caps, const GrAppliedClip* clip, bool hasMixedSampledCoverage, GrClampType clampType) override { fUseScale = !caps.shaderCaps()->floatIs32Bits(); SkPMColor4f* color = &fRRects.front().fColor; return fHelper.finalizeProcessors(caps, clip, hasMixedSampledCoverage, clampType, GrProcessorAnalysisCoverage::kSingleChannel, color, &fWideColor); } FixedFunctionFlags fixedFunctionFlags() const override { return fHelper.fixedFunctionFlags(); } private: GrProgramInfo* programInfo() override { return fProgramInfo; } void onCreateProgramInfo(const GrCaps* caps, SkArenaAlloc* arena, const GrSurfaceProxyView* writeView, GrAppliedClip&& appliedClip, const GrXferProcessor::DstProxyView& dstProxyView) override { SkMatrix localMatrix; if (!fViewMatrixIfUsingLocalCoords.invert(&localMatrix)) { return; } GrGeometryProcessor* gp = EllipseGeometryProcessor::Make(arena, fStroked, fWideColor, fUseScale, localMatrix); fProgramInfo = fHelper.createProgramInfo(caps, arena, writeView, std::move(appliedClip), dstProxyView, gp, GrPrimitiveType::kTriangles); } void onPrepareDraws(Target* target) override { if (!fProgramInfo) { this->createProgramInfo(target); if (!fProgramInfo) { return; } } // drop out the middle quad if we're stroked int indicesPerInstance = fStroked ? kIndicesPerStrokeRRect : kIndicesPerFillRRect; sk_sp<const GrBuffer> indexBuffer = get_rrect_index_buffer( fStroked ? kStroke_RRectType : kFill_RRectType, target->resourceProvider()); if (!indexBuffer) { SkDebugf("Could not allocate indices\n"); return; } PatternHelper helper(target, GrPrimitiveType::kTriangles, fProgramInfo->primProc().vertexStride(), std::move(indexBuffer), kVertsPerStandardRRect, indicesPerInstance, fRRects.count(), kNumRRectsInIndexBuffer); GrVertexWriter verts{helper.vertices()}; if (!verts.fPtr) { SkDebugf("Could not allocate vertices\n"); return; } for (const auto& rrect : fRRects) { GrVertexColor color(rrect.fColor, fWideColor); // Compute the reciprocals of the radii here to save time in the shader float reciprocalRadii[4] = { SkScalarInvert(rrect.fXRadius), SkScalarInvert(rrect.fYRadius), SkScalarInvert(rrect.fInnerXRadius), SkScalarInvert(rrect.fInnerYRadius) }; // Extend the radii out half a pixel to antialias. SkScalar xOuterRadius = rrect.fXRadius + SK_ScalarHalf; SkScalar yOuterRadius = rrect.fYRadius + SK_ScalarHalf; SkScalar xMaxOffset = xOuterRadius; SkScalar yMaxOffset = yOuterRadius; if (!fStroked) { // For filled rrects we map a unit circle in the vertex attributes rather than // computing an ellipse and modifying that distance, so we normalize to 1. xMaxOffset /= rrect.fXRadius; yMaxOffset /= rrect.fYRadius; } const SkRect& bounds = rrect.fDevBounds; SkScalar yCoords[4] = {bounds.fTop, bounds.fTop + yOuterRadius, bounds.fBottom - yOuterRadius, bounds.fBottom}; SkScalar yOuterOffsets[4] = {yMaxOffset, SK_ScalarNearlyZero, // we're using inversesqrt() in // shader, so can't be exactly 0 SK_ScalarNearlyZero, yMaxOffset}; auto maybeScale = GrVertexWriter::If(fUseScale, std::max(rrect.fXRadius, rrect.fYRadius)); for (int i = 0; i < 4; ++i) { verts.write(bounds.fLeft, yCoords[i], color, xMaxOffset, yOuterOffsets[i], maybeScale, reciprocalRadii); verts.write(bounds.fLeft + xOuterRadius, yCoords[i], color, SK_ScalarNearlyZero, yOuterOffsets[i], maybeScale, reciprocalRadii); verts.write(bounds.fRight - xOuterRadius, yCoords[i], color, SK_ScalarNearlyZero, yOuterOffsets[i], maybeScale, reciprocalRadii); verts.write(bounds.fRight, yCoords[i], color, xMaxOffset, yOuterOffsets[i], maybeScale, reciprocalRadii); } } fMesh = helper.mesh(); } void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override { if (!fProgramInfo || !fMesh) { return; } flushState->bindPipelineAndScissorClip(*fProgramInfo, chainBounds); flushState->bindTextures(fProgramInfo->primProc(), nullptr, fProgramInfo->pipeline()); flushState->drawMesh(*fMesh); } CombineResult onCombineIfPossible(GrOp* t, GrRecordingContext::Arenas*, const GrCaps& caps) override { EllipticalRRectOp* that = t->cast<EllipticalRRectOp>(); if (!fHelper.isCompatible(that->fHelper, caps, this->bounds(), that->bounds())) { return CombineResult::kCannotCombine; } if (fStroked != that->fStroked) { return CombineResult::kCannotCombine; } if (fHelper.usesLocalCoords() && !SkMatrixPriv::CheapEqual(fViewMatrixIfUsingLocalCoords, that->fViewMatrixIfUsingLocalCoords)) { return CombineResult::kCannotCombine; } fRRects.push_back_n(that->fRRects.count(), that->fRRects.begin()); fWideColor = fWideColor || that->fWideColor; return CombineResult::kMerged; } struct RRect { SkPMColor4f fColor; SkScalar fXRadius; SkScalar fYRadius; SkScalar fInnerXRadius; SkScalar fInnerYRadius; SkRect fDevBounds; }; SkMatrix fViewMatrixIfUsingLocalCoords; Helper fHelper; bool fStroked; bool fWideColor; bool fUseScale; SkSTArray<1, RRect, true> fRRects; GrSimpleMesh* fMesh = nullptr; GrProgramInfo* fProgramInfo = nullptr; typedef GrMeshDrawOp INHERITED; }; std::unique_ptr<GrDrawOp> GrOvalOpFactory::MakeCircularRRectOp(GrRecordingContext* context, GrPaint&& paint, const SkMatrix& viewMatrix, const SkRRect& rrect, const SkStrokeRec& stroke, const GrShaderCaps* shaderCaps) { SkASSERT(viewMatrix.rectStaysRect()); SkASSERT(viewMatrix.isSimilarity()); SkASSERT(rrect.isSimple()); SkASSERT(!rrect.isOval()); SkASSERT(SkRRectPriv::GetSimpleRadii(rrect).fX == SkRRectPriv::GetSimpleRadii(rrect).fY); // RRect ops only handle simple, but not too simple, rrects. // Do any matrix crunching before we reset the draw state for device coords. const SkRect& rrectBounds = rrect.getBounds(); SkRect bounds; viewMatrix.mapRect(&bounds, rrectBounds); SkScalar radius = SkRRectPriv::GetSimpleRadii(rrect).fX; SkScalar scaledRadius = SkScalarAbs(radius * (viewMatrix[SkMatrix::kMScaleX] + viewMatrix[SkMatrix::kMSkewY])); // Do mapping of stroke. Use -1 to indicate fill-only draws. SkScalar scaledStroke = -1; SkScalar strokeWidth = stroke.getWidth(); SkStrokeRec::Style style = stroke.getStyle(); bool isStrokeOnly = SkStrokeRec::kStroke_Style == style || SkStrokeRec::kHairline_Style == style; bool hasStroke = isStrokeOnly || SkStrokeRec::kStrokeAndFill_Style == style; if (hasStroke) { if (SkStrokeRec::kHairline_Style == style) { scaledStroke = SK_Scalar1; } else { scaledStroke = SkScalarAbs(strokeWidth * (viewMatrix[SkMatrix::kMScaleX] + viewMatrix[SkMatrix::kMSkewY])); } } // The way the effect interpolates the offset-to-ellipse/circle-center attribute only works on // the interior of the rrect if the radii are >= 0.5. Otherwise, the inner rect of the nine- // patch will have fractional coverage. This only matters when the interior is actually filled. // We could consider falling back to rect rendering here, since a tiny radius is // indistinguishable from a square corner. if (!isStrokeOnly && SK_ScalarHalf > scaledRadius) { return nullptr; } return CircularRRectOp::Make(context, std::move(paint), viewMatrix, bounds, scaledRadius, scaledStroke, isStrokeOnly); } static std::unique_ptr<GrDrawOp> make_rrect_op(GrRecordingContext* context, GrPaint&& paint, const SkMatrix& viewMatrix, const SkRRect& rrect, const SkStrokeRec& stroke) { SkASSERT(viewMatrix.rectStaysRect()); SkASSERT(rrect.isSimple()); SkASSERT(!rrect.isOval()); // RRect ops only handle simple, but not too simple, rrects. // Do any matrix crunching before we reset the draw state for device coords. const SkRect& rrectBounds = rrect.getBounds(); SkRect bounds; viewMatrix.mapRect(&bounds, rrectBounds); SkVector radii = SkRRectPriv::GetSimpleRadii(rrect); SkScalar xRadius = SkScalarAbs(viewMatrix[SkMatrix::kMScaleX] * radii.fX + viewMatrix[SkMatrix::kMSkewY] * radii.fY); SkScalar yRadius = SkScalarAbs(viewMatrix[SkMatrix::kMSkewX] * radii.fX + viewMatrix[SkMatrix::kMScaleY] * radii.fY); SkStrokeRec::Style style = stroke.getStyle(); // Do (potentially) anisotropic mapping of stroke. Use -1s to indicate fill-only draws. SkVector scaledStroke = {-1, -1}; SkScalar strokeWidth = stroke.getWidth(); bool isStrokeOnly = SkStrokeRec::kStroke_Style == style || SkStrokeRec::kHairline_Style == style; bool hasStroke = isStrokeOnly || SkStrokeRec::kStrokeAndFill_Style == style; if (hasStroke) { if (SkStrokeRec::kHairline_Style == style) { scaledStroke.set(1, 1); } else { scaledStroke.fX = SkScalarAbs( strokeWidth * (viewMatrix[SkMatrix::kMScaleX] + viewMatrix[SkMatrix::kMSkewY])); scaledStroke.fY = SkScalarAbs( strokeWidth * (viewMatrix[SkMatrix::kMSkewX] + viewMatrix[SkMatrix::kMScaleY])); } // if half of strokewidth is greater than radius, we don't handle that right now if ((SK_ScalarHalf * scaledStroke.fX > xRadius || SK_ScalarHalf * scaledStroke.fY > yRadius)) { return nullptr; } } // The matrix may have a rotation by an odd multiple of 90 degrees. if (viewMatrix.getScaleX() == 0) { std::swap(xRadius, yRadius); std::swap(scaledStroke.fX, scaledStroke.fY); } // The way the effect interpolates the offset-to-ellipse/circle-center attribute only works on // the interior of the rrect if the radii are >= 0.5. Otherwise, the inner rect of the nine- // patch will have fractional coverage. This only matters when the interior is actually filled. // We could consider falling back to rect rendering here, since a tiny radius is // indistinguishable from a square corner. if (!isStrokeOnly && (SK_ScalarHalf > xRadius || SK_ScalarHalf > yRadius)) { return nullptr; } // if the corners are circles, use the circle renderer return EllipticalRRectOp::Make(context, std::move(paint), viewMatrix, bounds, xRadius, yRadius, scaledStroke, isStrokeOnly); } std::unique_ptr<GrDrawOp> GrOvalOpFactory::MakeRRectOp(GrRecordingContext* context, GrPaint&& paint, const SkMatrix& viewMatrix, const SkRRect& rrect, const SkStrokeRec& stroke, const GrShaderCaps* shaderCaps) { if (rrect.isOval()) { return MakeOvalOp(context, std::move(paint), viewMatrix, rrect.getBounds(), GrStyle(stroke, nullptr), shaderCaps); } if (!viewMatrix.rectStaysRect() || !rrect.isSimple()) { return nullptr; } return make_rrect_op(context, std::move(paint), viewMatrix, rrect, stroke); } /////////////////////////////////////////////////////////////////////////////// std::unique_ptr<GrDrawOp> GrOvalOpFactory::MakeCircleOp(GrRecordingContext* context, GrPaint&& paint, const SkMatrix& viewMatrix, const SkRect& oval, const GrStyle& style, const GrShaderCaps* shaderCaps) { SkScalar width = oval.width(); SkASSERT(width > SK_ScalarNearlyZero && SkScalarNearlyEqual(width, oval.height()) && circle_stays_circle(viewMatrix)); auto r = width / 2.f; SkPoint center = { oval.centerX(), oval.centerY() }; if (style.hasNonDashPathEffect()) { return nullptr; } else if (style.isDashed()) { if (style.strokeRec().getCap() != SkPaint::kButt_Cap || style.dashIntervalCnt() != 2 || style.strokeRec().getWidth() >= width) { return nullptr; } auto onInterval = style.dashIntervals()[0]; auto offInterval = style.dashIntervals()[1]; if (offInterval == 0) { GrStyle strokeStyle(style.strokeRec(), nullptr); return MakeOvalOp(context, std::move(paint), viewMatrix, oval, strokeStyle, shaderCaps); } else if (onInterval == 0) { // There is nothing to draw but we have no way to indicate that here. return nullptr; } auto angularOnInterval = onInterval / r; auto angularOffInterval = offInterval / r; auto phaseAngle = style.dashPhase() / r; // Currently this function doesn't accept ovals with different start angles, though // it could. static const SkScalar kStartAngle = 0.f; return ButtCapDashedCircleOp::Make(context, std::move(paint), viewMatrix, center, r, style.strokeRec().getWidth(), kStartAngle, angularOnInterval, angularOffInterval, phaseAngle); } return CircleOp::Make(context, std::move(paint), viewMatrix, center, r, style); } std::unique_ptr<GrDrawOp> GrOvalOpFactory::MakeOvalOp(GrRecordingContext* context, GrPaint&& paint, const SkMatrix& viewMatrix, const SkRect& oval, const GrStyle& style, const GrShaderCaps* shaderCaps) { // we can draw circles SkScalar width = oval.width(); if (width > SK_ScalarNearlyZero && SkScalarNearlyEqual(width, oval.height()) && circle_stays_circle(viewMatrix)) { return MakeCircleOp(context, std::move(paint), viewMatrix, oval, style, shaderCaps); } if (style.pathEffect()) { return nullptr; } // prefer the device space ellipse op for batchability if (viewMatrix.rectStaysRect()) { return EllipseOp::Make(context, std::move(paint), viewMatrix, oval, style.strokeRec()); } // Otherwise, if we have shader derivative support, render as device-independent if (shaderCaps->shaderDerivativeSupport()) { SkScalar a = viewMatrix[SkMatrix::kMScaleX]; SkScalar b = viewMatrix[SkMatrix::kMSkewX]; SkScalar c = viewMatrix[SkMatrix::kMSkewY]; SkScalar d = viewMatrix[SkMatrix::kMScaleY]; // Check for near-degenerate matrix if (a*a + c*c > SK_ScalarNearlyZero && b*b + d*d > SK_ScalarNearlyZero) { return DIEllipseOp::Make(context, std::move(paint), viewMatrix, oval, style.strokeRec()); } } return nullptr; } /////////////////////////////////////////////////////////////////////////////// std::unique_ptr<GrDrawOp> GrOvalOpFactory::MakeArcOp(GrRecordingContext* context, GrPaint&& paint, const SkMatrix& viewMatrix, const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle, bool useCenter, const GrStyle& style, const GrShaderCaps* shaderCaps) { SkASSERT(!oval.isEmpty()); SkASSERT(sweepAngle); SkScalar width = oval.width(); if (SkScalarAbs(sweepAngle) >= 360.f) { return nullptr; } if (!SkScalarNearlyEqual(width, oval.height()) || !circle_stays_circle(viewMatrix)) { return nullptr; } SkPoint center = {oval.centerX(), oval.centerY()}; CircleOp::ArcParams arcParams = {SkDegreesToRadians(startAngle), SkDegreesToRadians(sweepAngle), useCenter}; return CircleOp::Make(context, std::move(paint), viewMatrix, center, width / 2.f, style, &arcParams); } /////////////////////////////////////////////////////////////////////////////// #if GR_TEST_UTILS GR_DRAW_OP_TEST_DEFINE(CircleOp) { do { SkScalar rotate = random->nextSScalar1() * 360.f; SkScalar translateX = random->nextSScalar1() * 1000.f; SkScalar translateY = random->nextSScalar1() * 1000.f; SkScalar scale; do { scale = random->nextSScalar1() * 100.f; } while (scale == 0); SkMatrix viewMatrix; viewMatrix.setRotate(rotate); viewMatrix.postTranslate(translateX, translateY); viewMatrix.postScale(scale, scale); SkRect circle = GrTest::TestSquare(random); SkPoint center = {circle.centerX(), circle.centerY()}; SkScalar radius = circle.width() / 2.f; SkStrokeRec stroke = GrTest::TestStrokeRec(random); CircleOp::ArcParams arcParamsTmp; const CircleOp::ArcParams* arcParams = nullptr; if (random->nextBool()) { arcParamsTmp.fStartAngleRadians = random->nextSScalar1() * SK_ScalarPI * 2; arcParamsTmp.fSweepAngleRadians = random->nextSScalar1() * SK_ScalarPI * 2 - .01f; arcParamsTmp.fUseCenter = random->nextBool(); arcParams = &arcParamsTmp; } std::unique_ptr<GrDrawOp> op = CircleOp::Make(context, std::move(paint), viewMatrix, center, radius, GrStyle(stroke, nullptr), arcParams); if (op) { return op; } assert_alive(paint); } while (true); } GR_DRAW_OP_TEST_DEFINE(ButtCapDashedCircleOp) { SkScalar rotate = random->nextSScalar1() * 360.f; SkScalar translateX = random->nextSScalar1() * 1000.f; SkScalar translateY = random->nextSScalar1() * 1000.f; SkScalar scale; do { scale = random->nextSScalar1() * 100.f; } while (scale == 0); SkMatrix viewMatrix; viewMatrix.setRotate(rotate); viewMatrix.postTranslate(translateX, translateY); viewMatrix.postScale(scale, scale); SkRect circle = GrTest::TestSquare(random); SkPoint center = {circle.centerX(), circle.centerY()}; SkScalar radius = circle.width() / 2.f; SkScalar strokeWidth = random->nextRangeScalar(0.001f * radius, 1.8f * radius); SkScalar onAngle = random->nextRangeScalar(0.01f, 1000.f); SkScalar offAngle = random->nextRangeScalar(0.01f, 1000.f); SkScalar startAngle = random->nextRangeScalar(-1000.f, 1000.f); SkScalar phase = random->nextRangeScalar(-1000.f, 1000.f); return ButtCapDashedCircleOp::Make(context, std::move(paint), viewMatrix, center, radius, strokeWidth, startAngle, onAngle, offAngle, phase); } GR_DRAW_OP_TEST_DEFINE(EllipseOp) { SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); SkRect ellipse = GrTest::TestSquare(random); return EllipseOp::Make(context, std::move(paint), viewMatrix, ellipse, GrTest::TestStrokeRec(random)); } GR_DRAW_OP_TEST_DEFINE(DIEllipseOp) { SkMatrix viewMatrix = GrTest::TestMatrix(random); SkRect ellipse = GrTest::TestSquare(random); return DIEllipseOp::Make(context, std::move(paint), viewMatrix, ellipse, GrTest::TestStrokeRec(random)); } GR_DRAW_OP_TEST_DEFINE(CircularRRectOp) { do { SkScalar rotate = random->nextSScalar1() * 360.f; SkScalar translateX = random->nextSScalar1() * 1000.f; SkScalar translateY = random->nextSScalar1() * 1000.f; SkScalar scale; do { scale = random->nextSScalar1() * 100.f; } while (scale == 0); SkMatrix viewMatrix; viewMatrix.setRotate(rotate); viewMatrix.postTranslate(translateX, translateY); viewMatrix.postScale(scale, scale); SkRect rect = GrTest::TestRect(random); SkScalar radius = random->nextRangeF(0.1f, 10.f); SkRRect rrect = SkRRect::MakeRectXY(rect, radius, radius); if (rrect.isOval()) { continue; } std::unique_ptr<GrDrawOp> op = GrOvalOpFactory::MakeCircularRRectOp(context, std::move(paint), viewMatrix, rrect, GrTest::TestStrokeRec(random), nullptr); if (op) { return op; } assert_alive(paint); } while (true); } GR_DRAW_OP_TEST_DEFINE(RRectOp) { SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); const SkRRect& rrect = GrTest::TestRRectSimple(random); return make_rrect_op(context, std::move(paint), viewMatrix, rrect, GrTest::TestStrokeRec(random)); } #endif
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "base/sys_info.h" #include <errno.h> #include <stddef.h> #include <stdint.h> #include <string.h> #include <sys/param.h> #include <sys/utsname.h> #include <unistd.h> #include "base/files/file_util.h" #include "base/lazy_instance.h" #include "base/logging.h" #include "base/strings/utf_string_conversions.h" #include "base/sys_info_internal.h" #include "base/threading/scoped_blocking_call.h" #include "build/build_config.h" #if !defined(OS_FUCHSIA) #include <sys/resource.h> #endif #if defined(OS_ANDROID) #include <sys/vfs.h> #define statvfs statfs // Android uses a statvfs-like statfs struct and call. #else #include <sys/statvfs.h> #endif #if defined(OS_LINUX) #include <linux/magic.h> #include <sys/vfs.h> #endif namespace { #if !defined(OS_OPENBSD) && !defined(OS_FUCHSIA) int NumberOfProcessors() { // sysconf returns the number of "logical" (not "physical") processors on both // Mac and Linux. So we get the number of max available "logical" processors. // // Note that the number of "currently online" processors may be fewer than the // returned value of NumberOfProcessors(). On some platforms, the kernel may // make some processors offline intermittently, to save power when system // loading is low. // // One common use case that needs to know the processor count is to create // optimal number of threads for optimization. It should make plan according // to the number of "max available" processors instead of "currently online" // ones. The kernel should be smart enough to make all processors online when // it has sufficient number of threads waiting to run. long res = sysconf(_SC_NPROCESSORS_CONF); if (res == -1) { NOTREACHED(); return 1; } return static_cast<int>(res); } base::LazyInstance< base::internal::LazySysInfoValue<int, NumberOfProcessors> >::Leaky g_lazy_number_of_processors = LAZY_INSTANCE_INITIALIZER; #endif // !defined(OS_OPENBSD) && !defined(OS_FUCHSIA) #if !defined(OS_FUCHSIA) int64_t AmountOfVirtualMemory() { struct rlimit limit; int result = getrlimit(RLIMIT_DATA, &limit); if (result != 0) { NOTREACHED(); return 0; } return limit.rlim_cur == RLIM_INFINITY ? 0 : limit.rlim_cur; } base::LazyInstance< base::internal::LazySysInfoValue<int64_t, AmountOfVirtualMemory>>::Leaky g_lazy_virtual_memory = LAZY_INSTANCE_INITIALIZER; #endif // !defined(OS_FUCHSIA) #if defined(OS_LINUX) bool IsStatsZeroIfUnlimited(const base::FilePath& path) { struct statfs stats; if (HANDLE_EINTR(statfs(path.value().c_str(), &stats)) != 0) return false; switch (stats.f_type) { case TMPFS_MAGIC: case HUGETLBFS_MAGIC: case RAMFS_MAGIC: return true; } return false; } #endif bool GetDiskSpaceInfo(const base::FilePath& path, int64_t* available_bytes, int64_t* total_bytes) { struct statvfs stats; if (HANDLE_EINTR(statvfs(path.value().c_str(), &stats)) != 0) return false; #if defined(OS_LINUX) const bool zero_size_means_unlimited = stats.f_blocks == 0 && IsStatsZeroIfUnlimited(path); #else const bool zero_size_means_unlimited = false; #endif if (available_bytes) { *available_bytes = zero_size_means_unlimited ? std::numeric_limits<int64_t>::max() : static_cast<int64_t>(stats.f_bavail) * stats.f_frsize; } if (total_bytes) { *total_bytes = zero_size_means_unlimited ? std::numeric_limits<int64_t>::max() : static_cast<int64_t>(stats.f_blocks) * stats.f_frsize; } return true; } } // namespace namespace base { #if !defined(OS_OPENBSD) && !defined(OS_FUCHSIA) int SysInfo::NumberOfProcessors() { return g_lazy_number_of_processors.Get().value(); } #endif #if !defined(OS_FUCHSIA) // static int64_t SysInfo::AmountOfVirtualMemory() { return g_lazy_virtual_memory.Get().value(); } #endif // static int64_t SysInfo::AmountOfFreeDiskSpace(const FilePath& path) { base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK); int64_t available; if (!GetDiskSpaceInfo(path, &available, nullptr)) return -1; return available; } // static int64_t SysInfo::AmountOfTotalDiskSpace(const FilePath& path) { base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK); int64_t total; if (!GetDiskSpaceInfo(path, nullptr, &total)) return -1; return total; } #if !defined(OS_MACOSX) && !defined(OS_ANDROID) // static std::string SysInfo::OperatingSystemName() { struct utsname info; if (uname(&info) < 0) { NOTREACHED(); return std::string(); } return std::string(info.sysname); } #endif #if !defined(OS_MACOSX) && !defined(OS_ANDROID) && !defined(OS_CHROMEOS) // static std::string SysInfo::OperatingSystemVersion() { struct utsname info; if (uname(&info) < 0) { NOTREACHED(); return std::string(); } return std::string(info.release); } #endif #if !defined(OS_MACOSX) && !defined(OS_ANDROID) && !defined(OS_CHROMEOS) // static void SysInfo::OperatingSystemVersionNumbers(int32_t* major_version, int32_t* minor_version, int32_t* bugfix_version) { struct utsname info; if (uname(&info) < 0) { NOTREACHED(); *major_version = 0; *minor_version = 0; *bugfix_version = 0; return; } int num_read = sscanf(info.release, "%d.%d.%d", major_version, minor_version, bugfix_version); if (num_read < 1) *major_version = 0; if (num_read < 2) *minor_version = 0; if (num_read < 3) *bugfix_version = 0; } #endif // static std::string SysInfo::OperatingSystemArchitecture() { struct utsname info; if (uname(&info) < 0) { NOTREACHED(); return std::string(); } std::string arch(info.machine); if (arch == "i386" || arch == "i486" || arch == "i586" || arch == "i686") { arch = "x86"; } else if (arch == "amd64") { arch = "x86_64"; } else if (std::string(info.sysname) == "AIX") { arch = "ppc64"; } return arch; } // static size_t SysInfo::VMAllocationGranularity() { return getpagesize(); } } // namespace base
#include "UIPageViewTest.h" #include "cocos2d.h" USING_NS_CC; using namespace cocos2d::ui; UIPageViewTests::UIPageViewTests() { ADD_TEST_CASE(UIPageViewTest); ADD_TEST_CASE(UIPageViewButtonTest); ADD_TEST_CASE(UIPageViewTouchPropagationTest); ADD_TEST_CASE(UIPageViewDynamicAddAndRemoveTest); ADD_TEST_CASE(UIPageViewJumpToPageTest); ADD_TEST_CASE(UIPageViewVerticalTest); ADD_TEST_CASE(UIPageViewDisableTouchTest); ADD_TEST_CASE(UIPageViewChildSizeTest); } // UIPageViewTest UIPageViewTest::UIPageViewTest() : _displayValueLabel(nullptr) { } UIPageViewTest::~UIPageViewTest() { } bool UIPageViewTest::init() { if (UIScene::init()) { Size widgetSize = _widget->getContentSize(); // Add a label in which the dragpanel events will be displayed _displayValueLabel = Text::create("Move by horizontal direction", "fonts/Marker Felt.ttf", 32); _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5)); _uiLayer->addChild(_displayValueLabel); // Add the black background Text* alert = Text::create("PageView", "fonts/Marker Felt.ttf", 30); alert->setColor(Color3B(159, 168, 176)); alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f)); _uiLayer->addChild(alert); Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81)); Layout* background = dynamic_cast<Layout*>(root->getChildByName("background_Panel")); // Create the page view Size size(240, 130); PageView* pageView = PageView::create(); pageView->setDirection(PageView::Direction::HORIZONTAL); pageView->setContentSize(size); Size backgroundSize = background->getContentSize(); pageView->setPosition((widgetSize - pageView->getContentSize()) / 2.0f); pageView->removeAllItems(); pageView->setIndicatorEnabled(true); int pageCount = 4; for (int i = 0; i < pageCount; ++i) { Layout* layout = Layout::create(); layout->setContentSize(size); ImageView* imageView = ImageView::create("cocosui/scrollviewbg.png"); imageView->setScale9Enabled(true); imageView->setContentSize(size); imageView->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f)); layout->addChild(imageView); Text* label = Text::create(StringUtils::format("page %d",(i+1)), "fonts/Marker Felt.ttf", 30); label->setColor(Color3B(192, 192, 192)); label->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f)); layout->addChild(label); pageView->insertCustomItem(layout, i); } pageView->removeItem(0); pageView->scrollToItem(pageCount - 2); pageView->addEventListener((PageView::ccPageViewCallback)CC_CALLBACK_2(UIPageViewTest::pageViewEvent, this)); _uiLayer->addChild(pageView); return true; } return false; } void UIPageViewTest::pageViewEvent(Ref *pSender, PageView::EventType type) { switch (type) { case PageView::EventType::TURNING: { PageView* pageView = dynamic_cast<PageView*>(pSender); _displayValueLabel->setString(StringUtils::format("page = %ld", pageView->getCurrentPageIndex() + 1)); } break; default: break; } } // UIPageViewButtonTest UIPageViewButtonTest::UIPageViewButtonTest() : _displayValueLabel(nullptr) { } UIPageViewButtonTest::~UIPageViewButtonTest() { } bool UIPageViewButtonTest::init() { if (UIScene::init()) { Size widgetSize = _widget->getContentSize(); // Add a label in which the drag panel events will be displayed _displayValueLabel = Text::create("Move by horizontal direction", "fonts/Marker Felt.ttf", 32); _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5)); _uiLayer->addChild(_displayValueLabel); // Add the black background Text* alert = Text::create("PageView with Buttons", "fonts/Marker Felt.ttf", 30); alert->setColor(Color3B(159, 168, 176)); alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f)); _uiLayer->addChild(alert); Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81)); Layout* background = dynamic_cast<Layout*>(root->getChildByName("background_Panel")); // Create the page view PageView* pageView = PageView::create(); pageView->setContentSize(Size(240.0f, 130.0f)); Size backgroundSize = background->getContentSize(); pageView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f + (backgroundSize.width - pageView->getContentSize().width) / 2.0f, (widgetSize.height - backgroundSize.height) / 2.0f + (backgroundSize.height - pageView->getContentSize().height) / 2.0f)); pageView->removeAllItems(); int pageCount = 4; for (int i = 0; i < pageCount; ++i) { HBox* outerBox = HBox::create(); outerBox->setContentSize(Size(240.0f, 130.0f)); for (int k = 0; k < 2; ++k) { VBox* innerBox = VBox::create(); for (int j = 0; j < 3; j++) { Button *btn = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png"); btn->setName(StringUtils::format("button %d", j)); btn->addTouchEventListener( CC_CALLBACK_2(UIPageViewButtonTest::onButtonClicked, this)); innerBox->addChild(btn); } LinearLayoutParameter *parameter = LinearLayoutParameter::create(); parameter->setMargin(Margin(0,0,100,0)); innerBox->setLayoutParameter(parameter); outerBox->addChild(innerBox); } pageView->insertCustomItem(outerBox, i); } pageView->removeItem(0); pageView->addEventListener((PageView::ccPageViewCallback)CC_CALLBACK_2(UIPageViewButtonTest::pageViewEvent, this)); _uiLayer->addChild(pageView); return true; } return false; } void UIPageViewButtonTest::onButtonClicked(Ref* sender, Widget::TouchEventType type) { log("button %s clicked", static_cast<Button*>(sender)->getName().c_str()); } void UIPageViewButtonTest::pageViewEvent(Ref *pSender, PageView::EventType type) { switch (type) { case PageView::EventType::TURNING: { PageView* pageView = dynamic_cast<PageView*>(pSender); _displayValueLabel->setString(StringUtils::format("page = %ld", pageView->getCurrentPageIndex() + 1)); } break; default: break; } } // UIPageViewTouchPropagationTest UIPageViewTouchPropagationTest::UIPageViewTouchPropagationTest() : _displayValueLabel(nullptr) { } UIPageViewTouchPropagationTest::~UIPageViewTouchPropagationTest() { } bool UIPageViewTouchPropagationTest::init() { if (UIScene::init()) { Size widgetSize = _widget->getContentSize(); // Add a label in which the dragpanel events will be displayed _displayValueLabel = Text::create("Move by horizontal direction", "fonts/Marker Felt.ttf", 32); _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5)); _uiLayer->addChild(_displayValueLabel); // Add the black background Text* alert = Text::create("PageView Touch Propagation", "fonts/Marker Felt.ttf", 30); alert->setColor(Color3B(159, 168, 176)); alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f)); _uiLayer->addChild(alert); Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81)); Layout* background = dynamic_cast<Layout*>(root->getChildByName("background_Panel")); // Create the page view PageView* pageView = PageView::create(); pageView->setContentSize(Size(240.0f, 130.0f)); pageView->setAnchorPoint(Vec2(0.5,0.5)); Size backgroundSize = background->getContentSize(); pageView->setPosition(Vec2(widgetSize.width / 2.0f ,widgetSize.height / 2.0f)); pageView->setBackGroundColor(Color3B::GREEN); pageView->setBackGroundColorType(Layout::BackGroundColorType::SOLID); int pageCount = 4; for (int i = 0; i < pageCount; ++i) { HBox* outerBox = HBox::create(); outerBox->setContentSize(Size(240.0f, 130.0f)); for (int k = 0; k < 2; ++k) { VBox* innerBox = VBox::create(); for (int j = 0; j < 3; j++) { Button *btn = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png"); btn->setName(StringUtils::format("button %d", j)); btn->addTouchEventListener( CC_CALLBACK_2(UIPageViewTouchPropagationTest::onButtonClicked, this)); innerBox->addChild(btn); } LinearLayoutParameter *parameter = LinearLayoutParameter::create(); parameter->setMargin(Margin(0,0,100,0)); innerBox->setLayoutParameter(parameter); outerBox->addChild(innerBox); } pageView->insertCustomItem(outerBox, i); } pageView->addEventListener((PageView::ccPageViewCallback)CC_CALLBACK_2(UIPageViewTouchPropagationTest::pageViewEvent, this)); pageView->setName("pageView"); pageView->addTouchEventListener([](Ref* sender, Widget::TouchEventType type){ if (type == Widget::TouchEventType::BEGAN) { CCLOG("page view touch began"); } else if(type == Widget::TouchEventType::MOVED) { CCLOG("page view touch moved"); } else if(type == Widget::TouchEventType::ENDED) { CCLOG("page view touch ended"); } else { CCLOG("page view touch cancelled"); } }); _uiLayer->addChild(pageView); Text *propagationText = Text::create("Allow Propagation", "Arial", 10); propagationText->setAnchorPoint(Vec2(0,0.5)); propagationText->setTextColor(Color4B::RED); propagationText->setPosition(Vec2(0, pageView->getPosition().y + 50)); _uiLayer->addChild(propagationText); Text *swallowTouchText = Text::create("Swallow Touches", "Arial", 10); swallowTouchText->setAnchorPoint(Vec2(0,0.5)); swallowTouchText->setTextColor(Color4B::RED); swallowTouchText->setPosition(Vec2(0, pageView->getPosition().y)); _uiLayer->addChild(swallowTouchText); // Create the checkbox CheckBox* checkBox1 = CheckBox::create("cocosui/check_box_normal.png", "cocosui/check_box_normal_press.png", "cocosui/check_box_active.png", "cocosui/check_box_normal_disable.png", "cocosui/check_box_active_disable.png"); checkBox1->setPosition(propagationText->getPosition() + Vec2(propagationText->getContentSize().width/2, -20)); checkBox1->setName("propagation"); _uiLayer->addChild(checkBox1); // Create the checkbox CheckBox* checkBox2 = CheckBox::create("cocosui/check_box_normal.png", "cocosui/check_box_normal_press.png", "cocosui/check_box_active.png", "cocosui/check_box_normal_disable.png", "cocosui/check_box_active_disable.png"); checkBox2->setPosition(swallowTouchText->getPosition() + Vec2(swallowTouchText->getContentSize().width/2, -20)); checkBox2->setName("swallow"); _uiLayer->addChild(checkBox2); auto eventListener = EventListenerTouchOneByOne::create(); eventListener->onTouchBegan = [](Touch* touch, Event* event) -> bool{ CCLOG("layout recieves touches"); return true; }; _eventDispatcher->addEventListenerWithSceneGraphPriority(eventListener, this); return true; } return false; } void UIPageViewTouchPropagationTest::onButtonClicked(Ref* pSender, Widget::TouchEventType type) { Button *btn = (Button*)pSender; CheckBox *ck1 = (CheckBox*)_uiLayer->getChildByName("propagation"); CheckBox *ck2 = (CheckBox*)_uiLayer->getChildByName("swallow"); auto pageView = (PageView*)_uiLayer->getChildByName("pageView"); if (type == Widget::TouchEventType::BEGAN) { if (ck1->isSelected()) { btn->setPropagateTouchEvents(true); pageView->setPropagateTouchEvents(true); }else { btn->setPropagateTouchEvents(false); pageView->setPropagateTouchEvents(false); } if (ck2->isSelected()) { btn->setSwallowTouches(true); pageView->setSwallowTouches(true); }else { btn->setSwallowTouches(false); pageView->setSwallowTouches(false); } } if (type == Widget::TouchEventType::ENDED) { CCLOG("button clicked"); } } void UIPageViewTouchPropagationTest::pageViewEvent(Ref *pSender, PageView::EventType type) { switch (type) { case PageView::EventType::TURNING: { PageView* pageView = dynamic_cast<PageView*>(pSender); _displayValueLabel->setString(StringUtils::format("page = %ld", pageView->getCurrentPageIndex() + 1)); } break; default: break; } } // UIPageViewDynamicAddAndRemoveTest UIPageViewDynamicAddAndRemoveTest::UIPageViewDynamicAddAndRemoveTest() : _displayValueLabel(nullptr) { } UIPageViewDynamicAddAndRemoveTest::~UIPageViewDynamicAddAndRemoveTest() { } bool UIPageViewDynamicAddAndRemoveTest::init() { if (UIScene::init()) { Size widgetSize = _widget->getContentSize(); // Add a label in which the dragpanel events will be displayed _displayValueLabel = Text::create("Click Buttons on the Left", "fonts/Marker Felt.ttf", 32); _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5)); _uiLayer->addChild(_displayValueLabel); // Add the black background Text* alert = Text::create("PageView Dynamic Modification", "fonts/Marker Felt.ttf", 30); alert->setColor(Color3B(159, 168, 176)); alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f)); _uiLayer->addChild(alert); Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81)); Layout* background = dynamic_cast<Layout*>(root->getChildByName("background_Panel")); // Create the page view PageView* pageView = PageView::create(); pageView->setDirection(ui::PageView::Direction::VERTICAL); pageView->setContentSize(Size(240.0f, 130.0f)); pageView->setAnchorPoint(Vec2(0.5,0.5)); Size backgroundSize = background->getContentSize(); pageView->setPosition(Vec2(widgetSize.width / 2.0f ,widgetSize.height / 2.0f)); pageView->setBackGroundColor(Color3B::GREEN); pageView->setBackGroundColorType(Layout::BackGroundColorType::SOLID); pageView->setIndicatorEnabled(true); pageView->setIndicatorSpaceBetweenIndexNodes(10); int pageCount = 4; for (int i = 0; i < pageCount; ++i) { HBox* outerBox = HBox::create(); outerBox->setContentSize(Size(240.0f, 130.0f)); for (int k = 0; k < 2; ++k) { VBox* innerBox = VBox::create(); for (int j = 0; j < 3; j++) { Button *btn = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png"); btn->setName(StringUtils::format("button %d", j)); innerBox->addChild(btn); } LinearLayoutParameter *parameter = LinearLayoutParameter::create(); parameter->setMargin(Margin(0,0,100,0)); innerBox->setLayoutParameter(parameter); outerBox->addChild(innerBox); } pageView->insertCustomItem(outerBox, i); } pageView->addEventListener((PageView::ccPageViewCallback)CC_CALLBACK_2(UIPageViewDynamicAddAndRemoveTest::pageViewEvent, this)); pageView->setName("pageView"); _uiLayer->addChild(pageView); //add buttons auto button = Button::create(); button->setNormalizedPosition(Vec2(0.12f,0.7f)); button->setTitleText("Add A Page"); button->setZoomScale(0.3f); button->setPressedActionEnabled(true); button->setTitleColor(Color3B::RED); button->addClickEventListener([=](Ref* sender) { HBox* outerBox = HBox::create(); outerBox->setContentSize(Size(240.0f, 130.0f)); for (int k = 0; k < 2; ++k) { VBox* innerBox = VBox::create(); for (int j = 0; j < 3; j++) { Button *btn = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png"); btn->setName(StringUtils::format("button %d", j)); innerBox->addChild(btn); } LinearLayoutParameter *parameter = LinearLayoutParameter::create(); parameter->setMargin(Margin(0,0,100,0)); innerBox->setLayoutParameter(parameter); outerBox->addChild(innerBox); } pageView->pushBackCustomItem(outerBox); _displayValueLabel->setString(StringUtils::format("page count = %ld", pageView->getItems().size())); CCLOG("current page index = %zd", pageView->getCurrentPageIndex()); }); _uiLayer->addChild(button); auto button2 = Button::create(); button2->setNormalizedPosition(Vec2(0.12f,0.5f)); button2->setTitleText("Remove A Page"); button2->setZoomScale(0.3f); button2->setPressedActionEnabled(true); button2->setTitleColor(Color3B::RED); button2->addClickEventListener([=](Ref* sender) { if (pageView->getItems().size() > 0) { pageView->removeItem(pageView->getItems().size()-1); } else { CCLOG("There is no page to remove!"); } _displayValueLabel->setString(StringUtils::format("page count = %ld", pageView->getItems().size())); CCLOG("current page index = %zd", pageView->getCurrentPageIndex()); }); _uiLayer->addChild(button2); auto button3 = Button::create(); button3->setNormalizedPosition(Vec2(0.12f,0.3f)); button3->setTitleText("Remove All Pages"); button3->setZoomScale(0.3f); button3->setPressedActionEnabled(true); button3->setTitleColor(Color3B::RED); button3->addClickEventListener([=](Ref* sender) { pageView->removeAllItems(); _displayValueLabel->setString(StringUtils::format("page count = %ld", pageView->getItems().size())); CCLOG("current page index = %zd", pageView->getCurrentPageIndex()); }); _uiLayer->addChild(button3); auto button4 = (ui::Button*)button3->clone(); button4->setTitleText("Scroll to Page4"); button4->setNormalizedPosition(Vec2(0.85,0.5)); button4->addClickEventListener([=](Ref* sender){ pageView->scrollToItem(3); CCLOG("current page index = %zd", pageView->getCurrentPageIndex()); }); _uiLayer->addChild(button4); return true; } return false; } void UIPageViewDynamicAddAndRemoveTest::pageViewEvent(Ref *pSender, PageView::EventType type) { switch (type) { case PageView::EventType::TURNING: { PageView* pageView = dynamic_cast<PageView*>(pSender); _displayValueLabel->setString(StringUtils::format("page = %ld", pageView->getCurrentPageIndex() + 1)); } break; default: break; } } // UIPageViewJumpToPageTest UIPageViewJumpToPageTest::UIPageViewJumpToPageTest() : _displayValueLabel(nullptr) { } UIPageViewJumpToPageTest::~UIPageViewJumpToPageTest() { } bool UIPageViewJumpToPageTest::init() { if (UIScene::init()) { Size widgetSize = _widget->getContentSize(); // Add a label in which the dragpanel events will be displayed _displayValueLabel = Text::create("setCurrentPageIndex API Test", "fonts/Marker Felt.ttf", 32); _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5)); _uiLayer->addChild(_displayValueLabel); // Add the black background Text* alert = Text::create("PageView", "fonts/Marker Felt.ttf", 30); alert->setColor(Color3B(159, 168, 176)); alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f)); _uiLayer->addChild(alert); Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81)); Layout* background = dynamic_cast<Layout*>(root->getChildByName("background_Panel")); // Create the page view PageView* pageView = PageView::create(); pageView->setContentSize(Size(240.0f, 130.0f)); Size backgroundSize = background->getContentSize(); pageView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f + (backgroundSize.width - pageView->getContentSize().width) / 2.0f, (widgetSize.height - backgroundSize.height) / 2.0f + (backgroundSize.height - pageView->getContentSize().height) / 2.0f)); pageView->setIndicatorEnabled(true); pageView->removeAllItems(); int pageCount = 4; for (int i = 0; i < pageCount; ++i) { Layout* layout = Layout::create(); layout->setContentSize(Size(240.0f, 130.0f)); ImageView* imageView = ImageView::create("cocosui/scrollviewbg.png"); imageView->setScale9Enabled(true); imageView->setContentSize(Size(240, 130)); imageView->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f)); layout->addChild(imageView); Text* label = Text::create(StringUtils::format("page %d",(i+1)), "fonts/Marker Felt.ttf", 30); label->setColor(Color3B(192, 192, 192)); label->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f)); layout->addChild(label); pageView->insertCustomItem(layout, i); } pageView->setCurrentPageIndex(1); //add buttons to jump to specific page auto button1 = ui::Button::create(); button1->setNormalizedPosition(Vec2(0.1, 0.75)); button1->setTitleText("Jump to Page1"); CCLOG("button1 content Size = %f, %f", button1->getContentSize().width, button1->getContentSize().height); button1->addClickEventListener([=](Ref*){ pageView->setCurrentPageIndex(0); }); _uiLayer->addChild(button1); auto button2 = static_cast<ui::Button*>(button1->clone()); button2->setTitleText("Jump to Page2"); button2->setNormalizedPosition(Vec2(0.1, 0.65)); CCLOG("button2 content Size = %f, %f", button2->getContentSize().width, button2->getContentSize().height); button2->addClickEventListener([=](Ref*){ pageView->setCurrentPageIndex(1); }); _uiLayer->addChild(button2); auto button3 = static_cast<ui::Button*>(button2->clone()); button3->setTitleText("Jump to Page3"); button3->setNormalizedPosition(Vec2(0.9, 0.75)); button3->addClickEventListener([=](Ref*){ pageView->setCurrentPageIndex(2); }); _uiLayer->addChild(button3); auto button4 = static_cast<ui::Button*>(button2->clone()); button4->setTitleText("Jump to Page4"); button4->setNormalizedPosition(Vec2(0.9, 0.65)); button4->addClickEventListener([=](Ref*){ pageView->setCurrentPageIndex(3); }); _uiLayer->addChild(button4); _uiLayer->addChild(pageView); return true; } return false; } // UIPageViewVerticalTest UIPageViewVerticalTest::UIPageViewVerticalTest() : _displayValueLabel(nullptr) { } UIPageViewVerticalTest::~UIPageViewVerticalTest() { } bool UIPageViewVerticalTest::init() { if (UIScene::init()) { Size widgetSize = _widget->getContentSize(); // Add a label in which the dragpanel events will be displayed _displayValueLabel = Text::create("Move by Vertical direction", "fonts/Marker Felt.ttf", 32); _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5)); _uiLayer->addChild(_displayValueLabel); // Add the black background Text* alert = Text::create("PageView", "fonts/Marker Felt.ttf", 30); alert->setColor(Color3B(159, 168, 176)); alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f)); _uiLayer->addChild(alert); Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81)); Layout* background = dynamic_cast<Layout*>(root->getChildByName("background_Panel")); // Create the page view PageView* pageView = PageView::create(); pageView->setIndicatorEnabled(true); pageView->setDirection(ui::PageView::Direction::VERTICAL); pageView->setContentSize(Size(240.0f, 130.0f)); Size backgroundSize = background->getContentSize(); pageView->setPosition((widgetSize - pageView->getContentSize()) / 2.0f); pageView->removeAllItems(); int pageCount = 4; for (int i = 0; i < pageCount; ++i) { Layout* layout = Layout::create(); layout->setContentSize(Size(240.0f, 130.0f)); ImageView* imageView = ImageView::create("cocosui/scrollviewbg.png"); imageView->setScale9Enabled(true); imageView->setContentSize(Size(240, 130)); imageView->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f)); layout->addChild(imageView); Text* label = Text::create(StringUtils::format("page %d",(i+1)), "fonts/Marker Felt.ttf", 30); label->setColor(Color3B(192, 192, 192)); label->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f)); layout->addChild(label); pageView->insertCustomItem(layout, i); } pageView->addEventListener((PageView::ccPageViewCallback)CC_CALLBACK_2(UIPageViewVerticalTest::pageViewEvent, this)); _uiLayer->addChild(pageView); return true; } return false; } void UIPageViewVerticalTest::pageViewEvent(Ref *pSender, PageView::EventType type) { switch (type) { case PageView::EventType::TURNING: { PageView* pageView = dynamic_cast<PageView*>(pSender); _displayValueLabel->setString(StringUtils::format("page = %ld", pageView->getCurrentPageIndex() + 1)); } break; default: break; } } // UIPageViewDisableTouchTest UIPageViewDisableTouchTest::UIPageViewDisableTouchTest() : _displayValueLabel(nullptr) { } UIPageViewDisableTouchTest::~UIPageViewDisableTouchTest() { } bool UIPageViewDisableTouchTest::init() { if (UIScene::init()) { Size widgetSize = _widget->getContentSize(); // Add a label in which the dragpanel events will be displayed _displayValueLabel = Text::create("PageView disable touch", "fonts/Marker Felt.ttf", 32); _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5)); _uiLayer->addChild(_displayValueLabel); // Add the black background Text* alert = Text::create("PageView", "fonts/Marker Felt.ttf", 30); alert->setColor(Color3B(159, 168, 176)); alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f)); _uiLayer->addChild(alert); Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81)); Layout* background = dynamic_cast<Layout*>(root->getChildByName("background_Panel")); // Create the page view PageView* pageView = PageView::create(); pageView->setContentSize(Size(240.0f, 130.0f)); Size backgroundSize = background->getContentSize(); pageView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f + (backgroundSize.width - pageView->getContentSize().width) / 2.0f, (widgetSize.height - backgroundSize.height) / 2.0f + (backgroundSize.height - pageView->getContentSize().height) / 2.0f)); pageView->setDirection(ui::PageView::Direction::VERTICAL); pageView->setTouchEnabled(false); pageView->removeAllItems(); int pageCount = 4; for (int i = 0; i < pageCount; ++i) { Layout* layout = Layout::create(); layout->setContentSize(Size(240.0f, 130.0f)); ImageView* imageView = ImageView::create("cocosui/scrollviewbg.png"); imageView->setScale9Enabled(true); imageView->setContentSize(Size(240, 130)); imageView->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f)); layout->addChild(imageView); Text* label = Text::create(StringUtils::format("page %d",(i+1)), "fonts/Marker Felt.ttf", 30); label->setColor(Color3B(192, 192, 192)); label->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f)); layout->addChild(label); pageView->insertCustomItem(layout, i); } _uiLayer->addChild(pageView); return true; } return false; } // UIPageViewTest UIPageViewChildSizeTest::UIPageViewChildSizeTest() : _displayValueLabel(nullptr) { } UIPageViewChildSizeTest::~UIPageViewChildSizeTest() { } bool UIPageViewChildSizeTest::init() { if (UIScene::init()) { Size widgetSize = _widget->getContentSize(); // Add a label in which the dragpanel events will be displayed _displayValueLabel = Text::create("Move by horizontal direction", "fonts/Marker Felt.ttf", 32); _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5)); _uiLayer->addChild(_displayValueLabel); // Add the black background Text* alert = Text::create("PageView", "fonts/Marker Felt.ttf", 30); alert->setColor(Color3B(159, 168, 176)); alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f)); _uiLayer->addChild(alert); Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81)); Layout* background = dynamic_cast<Layout*>(root->getChildByName("background_Panel")); // Create the page view Size size(240, 130); PageView* pageView = PageView::create(); pageView->setDirection(PageView::Direction::HORIZONTAL); pageView->setContentSize(size); Size backgroundSize = background->getContentSize(); pageView->setPosition((widgetSize - pageView->getContentSize()) / 2.0f); pageView->removeAllItems(); pageView->setIndicatorEnabled(true); int pageCount = 4; for (int i = 0; i < pageCount; ++i) { ImageView* imageView = ImageView::create("cocosui/scrollviewbg.png"); imageView->setScale9Enabled(true); Text* label = Text::create(StringUtils::format("page %d", (i + 1)), "fonts/Marker Felt.ttf", 30); label->setColor(Color3B(192, 192, 192)); label->setAnchorPoint(Vec2::ZERO); imageView->addChild(label); pageView->insertCustomItem(imageView, i); } pageView->addEventListener((PageView::ccPageViewCallback)CC_CALLBACK_2(UIPageViewChildSizeTest::pageViewEvent, this)); _uiLayer->addChild(pageView); return true; } return false; } void UIPageViewChildSizeTest::pageViewEvent(Ref *pSender, PageView::EventType type) { switch (type) { case PageView::EventType::TURNING: { PageView* pageView = dynamic_cast<PageView*>(pSender); _displayValueLabel->setString(StringUtils::format("page = %ld", pageView->getCurrentPageIndex() + 1)); } break; default: break; } }
#ifndef INCG_PHI_TESTS_RUNTIME_FAILURE_SETUP_DEBUG_REPORT_MODE_HPP #define INCG_PHI_TESTS_RUNTIME_FAILURE_SETUP_DEBUG_REPORT_MODE_HPP #if defined(_WIN32) # include <crtdbg.h> #endif // This function setups the windows crt debug mode to not open any message boxes static void SetupDebugReportMode() { #if defined(_WIN32) // Crt errors _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR); // Crt asserts _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR); #endif } #endif // INCG_PHI_TESTS_RUNTIME_FAILURE_SETUP_DEBUG_REPORT_MODE_HPP
#include <unity.h> #include "userrequestsrepository.h" #include "..\lib\mocks\mockRequestsender.h" #include "..\lib\mocks\mockIdgenerator.h" const char TableId[33] = "FakeTableIdForTest"; UserRequestsRepository *_repository = nullptr; MockRequestSender _mockRequestSender; MockIdGenerator _mockIdGenerator; void setUp() { // Unit test setup _repository = new UserRequestsRepository(TableId, &_mockRequestSender, &_mockIdGenerator); } void tearDown() { delete _repository; } void test_requestwaiter_called() { _mockRequestSender.ResetTestResults(); _mockIdGenerator.SetNextResult("FakeRequestIdForWaiter"); _repository->SetWaiterIsRequested(); auto stat = _mockRequestSender.EnqueueWaiterRequestStat(); TEST_ASSERT_EQUAL_INT32(1, stat.WasCalled()); TEST_ASSERT_EQUAL_CHAR_ARRAY(TableId, stat.GetParam1(), strlen(TableId)); TEST_ASSERT_EQUAL_CHAR_ARRAY("FakeRequestIdForWaiter", stat.GetParam2(), strlen(stat.GetParam2())); } void test_requestbill_called() { _mockRequestSender.ResetTestResults(); _mockIdGenerator.SetNextResult("FakeRequestIdForBill"); _repository->SetBillIsRequested(); auto stat = _mockRequestSender.EnqueueBillRequestStat(); stat.Print(); TEST_ASSERT_EQUAL_INT32(1, stat.WasCalled()); TEST_ASSERT_EQUAL_CHAR_ARRAY(TableId, stat.GetParam1(), strlen(TableId)); TEST_ASSERT_EQUAL_CHAR_ARRAY("FakeRequestIdForBill", stat.GetParam2(), strlen("FakeRequestIdForBill")); } void test_requestwaiter_canceled() { _mockRequestSender.ResetTestResults(); const char *waiterRequestId = _repository->SetWaiterIsRequested(); _repository->CancelRequest(waiterRequestId); // TEST_ASSERT_EQUAL_INT32(1, _mockCommunicator.CancelAllRequestsCalls); // TEST_ASSERT_EQUAL_CHAR_ARRAY(TableId, _mockCommunicator.TableIdCalled, sizeof(TableId)); } void test_requestbill_is_canceled() { _mockRequestSender.ResetTestResults(); const char *billRequestId = _repository->SetBillIsRequested(); _repository->CancelRequest(billRequestId); // TEST_ASSERT_EQUAL_INT32(1, _mockCommunicator.CancelAllRequestsCalls); // TEST_ASSERT_EQUAL_CHAR_ARRAY(TableId, _mockCommunicator.TableIdCalled, sizeof(TableId)); } void test_repeat_when_requestwaiter_failed() { } int main() { UNITY_BEGIN(); RUN_TEST(test_requestwaiter_called); RUN_TEST(test_requestbill_called); // RUN_TEST(test_requestwaiter_canceled); // RUN_TEST(test_requestbill_is_canceled); UNITY_END(); }
// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved. #include "FBodyStateInputDevice.h" #include "IHeadMountedDisplay.h" #include "Runtime/Slate/Public/Framework/Application/SlateApplication.h" #include "BodyStateInputInterface.h" #include "BodyStateBoneComponent.h" #include "BodyStateHMDSnapshot.h" #include "BodyStateDevice.h" //UE v4.6 IM event wrappers bool FBodyStateInputDevice::EmitKeyUpEventForKey(FKey Key, int32 User, bool Repeat) { FKeyEvent KeyEvent(Key, FSlateApplication::Get().GetModifierKeys(), User, Repeat, 0, 0); return FSlateApplication::Get().ProcessKeyUpEvent(KeyEvent); } bool FBodyStateInputDevice::EmitKeyDownEventForKey(FKey Key, int32 User, bool Repeat) { FKeyEvent KeyEvent(Key, FSlateApplication::Get().GetModifierKeys(), User, Repeat, 0, 0); return FSlateApplication::Get().ProcessKeyDownEvent(KeyEvent); } bool FBodyStateInputDevice::EmitAnalogInputEventForKey(FKey Key, float Value, int32 User, bool Repeat) { FAnalogInputEvent AnalogInputEvent(Key, FSlateApplication::Get().GetModifierKeys(), User, Repeat, 0, 0, Value); return FSlateApplication::Get().ProcessAnalogInputEvent(AnalogInputEvent); } FBodyStateInputDevice::FBodyStateInputDevice(const TSharedRef< FGenericApplicationMessageHandler >& InMessageHandler) : MessageHandler(InMessageHandler) { } FBodyStateInputDevice::~FBodyStateInputDevice() { } void FBodyStateInputDevice::SetMessageHandler(const TSharedRef< FGenericApplicationMessageHandler >& InMessageHandler) { MessageHandler = InMessageHandler; } bool FBodyStateInputDevice::AttachMergeAlgorithm(TFunction< void()> InFunction) { return false; } void FBodyStateInputDevice::AddBoneSceneListener(UBodyStateBoneComponent* Listener) { BoneSceneListeners.Add(Listener); } void FBodyStateInputDevice::RemoveBoneSceneListener(UBodyStateBoneComponent* Listener) { BoneSceneListeners.Remove(Listener); } bool FBodyStateInputDevice::Exec(UWorld* InWorld, const TCHAR* Cmd, FOutputDevice& Ar) { // Nothing necessary to do (boilerplate code to complete the interface) return false; } void FBodyStateInputDevice::SetChannelValue(int32 ControllerId, FForceFeedbackChannelType ChannelType, float Value) { // Nothing necessary to do (boilerplate code to complete the interface) } void FBodyStateInputDevice::SetChannelValues(int32 ControllerId, const FForceFeedbackValues &values) { // Nothing necessary to do (boilerplate code to complete the interface) } /************************************************************************/ /* Key Tick flow functions */ /************************************************************************/ void FBodyStateInputDevice::Tick(float DeltaTime) { //Tick - store delta time for BS refence } //Main loop event emitter void FBodyStateInputDevice::SendControllerEvents() { //HMDSamples->AddCurrentHMDSample(); DispatchInput(); DispatchEstimators(); //DispatchRecognizers(); UpdateSceneListeners(); } //End key tick flow functions /************************************************************************/ /* Key Input functions */ /************************************************************************/ void FBodyStateInputDevice::DispatchInput() { //TODO expand this //Fetch input from all attached devices SkeletonStorage->CallFunctionOnDevices([this](const FBodyStateDevice& Device) { Device.InputCallbackDelegate->UpdateInput(Device.DeviceId, Device.Skeleton); }); } void FBodyStateInputDevice::DispatchEstimators() { //Copy results to merged skeleton and obtain estimator data if any SkeletonStorage->UpdateMergeSkeletonData(); } void FBodyStateInputDevice::DispatchRecognizers() { } void FBodyStateInputDevice::UpdateSceneListeners() { //Early exit optimization if (BoneSceneListeners.Num() == 0) { return; } for (auto Listener : BoneSceneListeners) { //Get relevant skeleton for listener UBodyStateSkeleton* Skeleton = SkeletonStorage->SkeletonForDevice(Listener->SkeletonId); UBodyStateBone* FollowedBone = Skeleton->BoneForEnum(Listener->BoneToFollow); //Update scene transform for that bone from the bone enum Listener->SetRelativeTransform(FollowedBone->Transform()); } }
#include <bits/stdc++.h> #define MAXN 2005 #define mp make_pair #define fi first #define se second using namespace std; const int d[4][2]={ {1,0},{-1,0}, {0,1},{0,-1} }; int n,m,r,c,x,y,ans=1; char g[MAXN][MAXN]; bool vis[MAXN][MAXN]; deque <pair<pair<int,int>,pair<int,int> > > q; void BFS() { q.push_front(mp(mp(r,c),mp(0,0)));vis[r][c]=true; while (!q.empty()) { pair<pair<int,int>,pair<int,int> > now=q.front();q.pop_front(); for (int i=0;i<4;i++) { int tx=now.fi.fi+d[i][0],ty=now.fi.se+d[i][1]; if (vis[tx][ty]) continue; if (tx<1||tx>n||ty<1||ty>m||g[tx][ty]=='*') continue; if (ty==now.fi.se) { vis[tx][ty]=true; q.push_front(mp(mp(tx,ty),now.se)); } else { if (d[i][1]==-1) { if (now.se.fi+1>x) continue; q.push_back(mp(mp(tx,ty),mp(now.se.fi+1,now.se.se))); vis[tx][ty]=true; } else { if (now.se.se+1>y) continue; q.push_back(mp(mp(tx,ty),mp(now.se.fi,now.se.se+1))); vis[tx][ty]=true; } } ++ans; } } return ; } int main() { scanf("%d %d",&n,&m); scanf("%d %d",&r,&c); scanf("%d %d",&x,&y); for (int i=1;i<=n;i++) scanf("%s",g[i]+1); if (g[r][c]=='*') return puts("0"),0; BFS(); printf("%d\n",ans); return 0; }
/* Copyright 2020 The OneFlow Authors. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include "oneflow/core/operator/operator.h" namespace oneflow { class ModelInitOp : public Operator { public: Maybe<void> InitFromOpConf() override; virtual Maybe<void> InferLogicalOutBlobDescs( const std::function<BlobDesc*(const std::string&)>& BlobDesc4BnInOp, const ParallelDesc& parallel_desc) const; Maybe<void> InferOutBlobDescs( const std::function<BlobDesc*(const std::string&)>& GetBlobDesc4BnInOp, const ParallelContext* parallel_ctx) const override; private: Maybe<void> GetSbpSignatures( const std::function<Maybe<const BlobDesc&>(const std::string&)>& LogicalBlobDesc4Ibn, cfg::SbpSignatureList* sbp_sig_list) const override; }; Maybe<void> ModelInitOp::InitFromOpConf() { CHECK(op_conf().has_model_init_conf()); if (op_conf().model_init_conf().has_tick()) { EnrollInputBn("tick", false); } EnrollRepeatedOutputBn("out", false); return Maybe<void>::Ok(); } namespace { Maybe<void> InferBlobDescs(const OperatorConf& conf, const std::function<BlobDesc*(const std::string&)>& BlobDesc4BnInOp) { const int64_t num_out = conf.model_init_conf().out().size(); FOR_RANGE(int64_t, i, 0, num_out) { const VariableOpConf& original_variable_conf = conf.model_init_conf().original_variable_conf(i); BlobDesc* out_i = BlobDesc4BnInOp(GenRepeatedBn("out", i)); out_i->mut_shape() = Shape(original_variable_conf.shape()); out_i->set_data_type(original_variable_conf.data_type()); } return Maybe<void>::Ok(); } } // namespace Maybe<void> ModelInitOp::InferLogicalOutBlobDescs( const std::function<BlobDesc*(const std::string&)>& BlobDesc4BnInOp, const ParallelDesc& parallel_desc) const { return InferBlobDescs(op_conf(), BlobDesc4BnInOp); } Maybe<void> ModelInitOp::InferOutBlobDescs( const std::function<BlobDesc*(const std::string&)>& GetBlobDesc4BnInOp, const ParallelContext* parallel_ctx) const { return InferBlobDescs(op_conf(), GetBlobDesc4BnInOp); } Maybe<void> ModelInitOp::GetSbpSignatures( const std::function<Maybe<const BlobDesc&>(const std::string&)>& LogicalBlobDesc4Ibn, cfg::SbpSignatureList* sbp_sig_list) const { SbpSignatureBuilder() .Broadcast(input_bns()) .Split(output_bns(), 0) .MakeSplitSignatureListBuilder( JUST(LogicalBlobDesc4Ibn(output_bns().Get(0))).shape().NumAxes()) .Build(sbp_sig_list); return Maybe<void>::Ok(); } REGISTER_CPU_OP(OperatorConf::kModelInitConf, ModelInitOp); } // namespace oneflow
// ------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. // ------------------------------------------------------------ #include "stdafx.h" #include <boost/test/unit_test.hpp> #include "Common/boost-taef.h" namespace Common { using namespace std; static string const fprefix = "FileTest-"; class FileTests { }; BOOST_FIXTURE_TEST_SUITE(FileTestsSuite, FileTests) #if defined(PLATFORM_UNIX) BOOST_AUTO_TEST_CASE(CreateHardLink) { string fname = fprefix + Guid::NewGuid().ToString(); File linkFrom; auto err = linkFrom.TryOpen(fname, FileMode::CreateNew); BOOST_REQUIRE_EQUAL(err.ReadValue(), ErrorCodeValue::Success); string linkName = fprefix + Guid::NewGuid().ToString(); auto linked = File::CreateHardLink(linkName, fname); BOOST_REQUIRE(linked); auto linkedAgain = File::CreateHardLink(linkName, fname); BOOST_REQUIRE(!linkedAgain); BOOST_REQUIRE(File::Exists(linkName)); BOOST_REQUIRE_EQUAL(File::Delete2(fname).ReadValue(), ErrorCodeValue::Success); BOOST_REQUIRE(!File::Exists(fname)); BOOST_REQUIRE(File::Exists(linkName)); BOOST_REQUIRE_EQUAL(File::Delete2(linkName).ReadValue(), ErrorCodeValue::Success); BOOST_REQUIRE(!File::Exists(linkName)); } BOOST_AUTO_TEST_CASE(FileAccessDiagnostics) { auto dstr = File::GetFileAccessDiagnostics("/tmp"); RealConsole c; c.WriteLine("file access diagnostistics: {0}", dstr); BOOST_REQUIRE(!dstr.empty()); } #endif // defined(PLATFORM_UNIX) BOOST_AUTO_TEST_CASE(ReplaceFileNoBackup) { string guid = Guid::NewGuid().ToString(); string original = fprefix + "-original-" + guid; { File originalFile; auto err = originalFile.TryOpen(original, FileMode::CreateNew); BOOST_REQUIRE_EQUAL(err.ReadValue(), ErrorCodeValue::Success); BOOST_REQUIRE_EQUAL(originalFile.size(), (int64)0); } string replacement = fprefix + "-replacement-" + guid; char c = 'a'; size_t dataSize = sizeof(c); { File replacementFile; auto err = replacementFile.TryOpen(replacement, FileMode::CreateNew, FileAccess::Write); BOOST_REQUIRE_EQUAL(err.ReadValue(), ErrorCodeValue::Success); replacementFile.Write(&c, (int)dataSize); BOOST_REQUIRE_EQUAL(replacementFile.size(), (int64)dataSize); } auto err = File::Replace(original, replacement, "", true); BOOST_REQUIRE_EQUAL(err.ReadValue(), ErrorCodeValue::Success); BOOST_REQUIRE(!File::Exists(replacement)); int64 newSize = 0; err = File::GetSize(original, newSize); BOOST_REQUIRE_EQUAL(err.ReadValue(), ErrorCodeValue::Success); BOOST_REQUIRE_EQUAL(newSize, (int64)dataSize); BOOST_REQUIRE_EQUAL(File::Delete2(original).ReadValue(), ErrorCodeValue::Success); } BOOST_AUTO_TEST_CASE(ReplaceFileWithBackup) { string guid = Guid::NewGuid().ToString(); string original = fprefix + "-original-" + guid; int64 originalFileSize = 0; { File originalFile; auto err = originalFile.TryOpen(original, FileMode::CreateNew); BOOST_REQUIRE_EQUAL(err.ReadValue(), ErrorCodeValue::Success); BOOST_REQUIRE_EQUAL(originalFile.size(), originalFileSize); } string replacement = fprefix + "-replacement-" + guid; char c = 'a'; size_t dataSize = sizeof(c); { File replacementFile; auto err = replacementFile.TryOpen(replacement, FileMode::CreateNew, FileAccess::Write); BOOST_REQUIRE_EQUAL(err.ReadValue(), ErrorCodeValue::Success); replacementFile.Write(&c, (int)dataSize); BOOST_REQUIRE_EQUAL(replacementFile.size(), (int64)dataSize); } string backup = fprefix + "-backup-" + guid; auto err = File::Replace(original, replacement, backup, true); BOOST_REQUIRE_EQUAL(err.ReadValue(), ErrorCodeValue::Success); BOOST_REQUIRE(!File::Exists(replacement)); int64 newSize = 0; err = File::GetSize(original, newSize); BOOST_REQUIRE_EQUAL(err.ReadValue(), ErrorCodeValue::Success); BOOST_REQUIRE_EQUAL(newSize, (int64)dataSize); BOOST_REQUIRE(File::Exists(backup)); int64 backupFileSize = -1; err = File::GetSize(backup, backupFileSize); BOOST_REQUIRE_EQUAL(backupFileSize, originalFileSize); BOOST_REQUIRE_EQUAL(File::Delete2(original).ReadValue(), ErrorCodeValue::Success); BOOST_REQUIRE_EQUAL(File::Delete2(backup).ReadValue(), ErrorCodeValue::Success); } #if !defined(PLATFORM_UNIX) BOOST_AUTO_TEST_CASE(FlushFileVolume) { // Find valid system drive char drive = NULL; string rootPath(""); for (char testDrive = 'a'; testDrive <= 'z'; testDrive++) { rootPath = testDrive; rootPath.append(":\\"); if (Directory::Exists(rootPath)) { drive = testDrive; break; } } VERIFY_IS_TRUE(drive != NULL); // Flush ErrorCode error(ErrorCodeValue::Success); error = File::FlushVolume(drive); VERIFY_IS_TRUE(error.IsSuccess(), formatString.L("FlushVolume failed against {0} drive with error {1}", drive, error).c_str()); error = File::FlushVolume(NULL); VERIFY_IS_TRUE(error.IsError(ErrorCodeValue::ArgumentNull), formatString.L("FlushVolume did not receive correct errorcode {0} for null drive.", drive, error).c_str()); error = File::FlushVolume('.'); VERIFY_IS_TRUE(error.IsWin32Error(ERROR_FILE_NOT_FOUND), formatString.L("FlushVolume did not receive correct errorcode {0} for incorrect volume.", drive, error).c_str()); } #endif BOOST_AUTO_TEST_SUITE_END() } // end namespace Common
//***************************************************************************** // Copyright 2017-2020 Intel Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. //***************************************************************************** #include "ngraph/itt.hpp" #include "ngraph/op/not.hpp" #include "ngraph/op/op.hpp" #include "ngraph/op/util/elementwise_args.hpp" #include "ngraph/runtime/host_tensor.hpp" #include "ngraph/runtime/reference/not.hpp" using namespace ngraph; using namespace std; constexpr NodeTypeInfo op::v1::LogicalNot::type_info; op::v1::LogicalNot::LogicalNot(const Output<Node>& arg) : Op({arg}) { constructor_validate_and_infer_types(); } bool ngraph::op::v1::LogicalNot::visit_attributes(AttributeVisitor& visitor) { return true; } // TODO(amprocte): Update this to allow only boolean, for consistency with logical binops. void op::v1::LogicalNot::validate_and_infer_types() { auto args_et_pshape = op::util::validate_and_infer_elementwise_args(this); element::Type& args_et = std::get<0>(args_et_pshape); PartialShape& args_pshape = std::get<1>(args_et_pshape); set_output_type(0, args_et, args_pshape); } shared_ptr<Node> op::v1::LogicalNot::clone_with_new_inputs(const OutputVector& new_args) const { check_new_args_count(this, new_args); return make_shared<v1::LogicalNot>(new_args.at(0)); } namespace { template <element::Type_t ET> inline bool evaluate(const HostTensorPtr& arg0, const HostTensorPtr& out, const size_t count) { using T = typename element_type_traits<ET>::value_type; runtime::reference::logical_not<T>( arg0->get_data_ptr<ET>(), out->get_data_ptr<ET>(), count); return true; } bool evaluate_not(const HostTensorPtr& arg0, const HostTensorPtr& out, const size_t count) { bool rc = true; out->set_unary(arg0); switch (arg0->get_element_type()) { TYPE_CASE(boolean)(arg0, out, count); break; TYPE_CASE(i32)(arg0, out, count); break; TYPE_CASE(i64)(arg0, out, count); break; TYPE_CASE(u32)(arg0, out, count); break; TYPE_CASE(u64)(arg0, out, count); break; TYPE_CASE(f16)(arg0, out, count); break; TYPE_CASE(f32)(arg0, out, count); break; default: rc = false; break; } return rc; } } bool op::v1::LogicalNot::evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const { OV_ITT_SCOPED_TASK(itt::domains::nGraphOp, "op::v1::LogicalNot::evaluate"); return evaluate_not(inputs[0], outputs[0], shape_size(get_output_shape(0))); } constexpr NodeTypeInfo op::v0::Not::type_info; op::v0::Not::Not(const Output<Node>& arg) : Op({arg}) { constructor_validate_and_infer_types(); } // TODO(amprocte): Update this to allow only boolean, for consistency with logical binops. void op::v0::Not::validate_and_infer_types() { auto args_et_pshape = ngraph::op::util::validate_and_infer_elementwise_args(this); element::Type& args_et = std::get<0>(args_et_pshape); PartialShape& args_pshape = std::get<1>(args_et_pshape); set_output_type(0, args_et, args_pshape); } shared_ptr<Node> op::v0::Not::clone_with_new_inputs(const OutputVector& new_args) const { check_new_args_count(this, new_args); return make_shared<v0::Not>(new_args.at(0)); } bool op::Not::evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const { OV_ITT_SCOPED_TASK(itt::domains::nGraphOp, "op::Not::evaluate"); return evaluate_not(inputs[0], outputs[0], shape_size(get_output_shape(0))); }
//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // class gamma_spline // //---------------------------------------------------------------------------- #include "ctrl/agg_gamma_spline.h" namespace agg { //------------------------------------------------------------------------ gamma_spline::gamma_spline() : m_x1(0), m_y1(0), m_x2(10), m_y2(10), m_cur_x(0.0) { values(1.0, 1.0, 1.0, 1.0); } //------------------------------------------------------------------------ double gamma_spline::y(double x) const { if(x < 0.0) x = 0.0; if(x > 1.0) x = 1.0; double val = m_spline.get(x); if(val < 0.0) val = 0.0; if(val > 1.0) val = 1.0; return val; } //------------------------------------------------------------------------ void gamma_spline::values(double kx1, double ky1, double kx2, double ky2) { if(kx1 < 0.001) kx1 = 0.001; if(kx1 > 1.999) kx1 = 1.999; if(ky1 < 0.001) ky1 = 0.001; if(ky1 > 1.999) ky1 = 1.999; if(kx2 < 0.001) kx2 = 0.001; if(kx2 > 1.999) kx2 = 1.999; if(ky2 < 0.001) ky2 = 0.001; if(ky2 > 1.999) ky2 = 1.999; m_x[0] = 0.0; m_y[0] = 0.0; m_x[1] = kx1 * 0.25; m_y[1] = ky1 * 0.25; m_x[2] = 1.0 - kx2 * 0.25; m_y[2] = 1.0 - ky2 * 0.25; m_x[3] = 1.0; m_y[3] = 1.0; m_spline.init(4, m_x, m_y); int i; for(i = 0; i < 256; i++) { m_gamma[i] = (unsigned char)(y(double(i) / 255.0) * 255.0); } } //------------------------------------------------------------------------ void gamma_spline::values(double* kx1, double* ky1, double* kx2, double* ky2) const { *kx1 = m_x[1] * 4.0; *ky1 = m_y[1] * 4.0; *kx2 = (1.0 - m_x[2]) * 4.0; *ky2 = (1.0 - m_y[2]) * 4.0; } //------------------------------------------------------------------------ void gamma_spline::box(double x1, double y1, double x2, double y2) { m_x1 = x1; m_y1 = y1; m_x2 = x2; m_y2 = y2; } //------------------------------------------------------------------------ void gamma_spline::rewind(unsigned) { m_cur_x = 0.0; } //------------------------------------------------------------------------ unsigned gamma_spline::vertex(double* vx, double* vy) { if(m_cur_x == 0.0) { *vx = m_x1; *vy = m_y1; m_cur_x += 1.0 / (m_x2 - m_x1); return path_cmd_move_to; } if(m_cur_x > 1.0) { return path_cmd_stop; } *vx = m_x1 + m_cur_x * (m_x2 - m_x1); *vy = m_y1 + y(m_cur_x) * (m_y2 - m_y1); m_cur_x += 1.0 / (m_x2 - m_x1); return path_cmd_line_to; } }
// RUN: %clang_cc1 -fexceptions -fcxx-exceptions %s -triple=i686-windows-msvc -emit-llvm -o - | FileCheck %s // When generating thunks using musttail due to inalloca parameters, don't push // and pop terminate scopes. PR44987 struct NonTrivial { NonTrivial(); NonTrivial(const NonTrivial &o); ~NonTrivial(); int x; }; struct A { virtual void f(NonTrivial o) noexcept; }; struct B { virtual void f(NonTrivial o) noexcept; }; class C : A, B { virtual void f(NonTrivial o) noexcept; }; C c; // CHECK-LABEL: define linkonce_odr dso_local x86_thiscallcc void @"?f@C@@G3AEXUNonTrivial@@@Z"(%class.C* %this, <{ %struct.NonTrivial }>* inalloca %0) // CHECK-NOT: invoke // CHECK: musttail call x86_thiscallcc void @"?f@C@@EAEXUNonTrivial@@@Z"(%class.C* %{{.*}}, <{ %struct.NonTrivial }>* inalloca %0) // CHECK-NEXT ret void
/* this file has been autogenerated by vtkNodeJsWrap */ /* editing this might proof futile */ #define VTK_WRAPPING_CXX #define VTK_STREAMS_FWD_ONLY #include <nan.h> #include "vtkAlgorithmWrap.h" #include "vtkTemporalFractalWrap.h" #include "vtkObjectBaseWrap.h" #include "../../plus/plus.h" using namespace v8; extern Nan::Persistent<v8::Object> vtkNodeJsNoWrap; Nan::Persistent<v8::FunctionTemplate> VtkTemporalFractalWrap::ptpl; VtkTemporalFractalWrap::VtkTemporalFractalWrap() { } VtkTemporalFractalWrap::VtkTemporalFractalWrap(vtkSmartPointer<vtkTemporalFractal> _native) { native = _native; } VtkTemporalFractalWrap::~VtkTemporalFractalWrap() { } void VtkTemporalFractalWrap::Init(v8::Local<v8::Object> exports) { Nan::SetAccessor(exports, Nan::New("vtkTemporalFractal").ToLocalChecked(), ConstructorGetter); Nan::SetAccessor(exports, Nan::New("TemporalFractal").ToLocalChecked(), ConstructorGetter); } void VtkTemporalFractalWrap::ConstructorGetter( v8::Local<v8::String> property, const Nan::PropertyCallbackInfo<v8::Value>& info) { InitPtpl(); info.GetReturnValue().Set(Nan::New(ptpl)->GetFunction()); } void VtkTemporalFractalWrap::InitPtpl() { if (!ptpl.IsEmpty()) return; v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New); VtkAlgorithmWrap::InitPtpl( ); tpl->Inherit(Nan::New<FunctionTemplate>(VtkAlgorithmWrap::ptpl)); tpl->SetClassName(Nan::New("VtkTemporalFractalWrap").ToLocalChecked()); tpl->InstanceTemplate()->SetInternalFieldCount(1); Nan::SetPrototypeMethod(tpl, "AdaptiveSubdivisionOff", AdaptiveSubdivisionOff); Nan::SetPrototypeMethod(tpl, "adaptiveSubdivisionOff", AdaptiveSubdivisionOff); Nan::SetPrototypeMethod(tpl, "AdaptiveSubdivisionOn", AdaptiveSubdivisionOn); Nan::SetPrototypeMethod(tpl, "adaptiveSubdivisionOn", AdaptiveSubdivisionOn); Nan::SetPrototypeMethod(tpl, "DiscreteTimeStepsOff", DiscreteTimeStepsOff); Nan::SetPrototypeMethod(tpl, "discreteTimeStepsOff", DiscreteTimeStepsOff); Nan::SetPrototypeMethod(tpl, "DiscreteTimeStepsOn", DiscreteTimeStepsOn); Nan::SetPrototypeMethod(tpl, "discreteTimeStepsOn", DiscreteTimeStepsOn); Nan::SetPrototypeMethod(tpl, "GenerateRectilinearGridsOff", GenerateRectilinearGridsOff); Nan::SetPrototypeMethod(tpl, "generateRectilinearGridsOff", GenerateRectilinearGridsOff); Nan::SetPrototypeMethod(tpl, "GenerateRectilinearGridsOn", GenerateRectilinearGridsOn); Nan::SetPrototypeMethod(tpl, "generateRectilinearGridsOn", GenerateRectilinearGridsOn); Nan::SetPrototypeMethod(tpl, "GetAdaptiveSubdivision", GetAdaptiveSubdivision); Nan::SetPrototypeMethod(tpl, "getAdaptiveSubdivision", GetAdaptiveSubdivision); Nan::SetPrototypeMethod(tpl, "GetAsymetric", GetAsymetric); Nan::SetPrototypeMethod(tpl, "getAsymetric", GetAsymetric); Nan::SetPrototypeMethod(tpl, "GetDimensions", GetDimensions); Nan::SetPrototypeMethod(tpl, "getDimensions", GetDimensions); Nan::SetPrototypeMethod(tpl, "GetDiscreteTimeSteps", GetDiscreteTimeSteps); Nan::SetPrototypeMethod(tpl, "getDiscreteTimeSteps", GetDiscreteTimeSteps); Nan::SetPrototypeMethod(tpl, "GetFractalValue", GetFractalValue); Nan::SetPrototypeMethod(tpl, "getFractalValue", GetFractalValue); Nan::SetPrototypeMethod(tpl, "GetGenerateRectilinearGrids", GetGenerateRectilinearGrids); Nan::SetPrototypeMethod(tpl, "getGenerateRectilinearGrids", GetGenerateRectilinearGrids); Nan::SetPrototypeMethod(tpl, "GetGhostLevels", GetGhostLevels); Nan::SetPrototypeMethod(tpl, "getGhostLevels", GetGhostLevels); Nan::SetPrototypeMethod(tpl, "GetMaximumLevel", GetMaximumLevel); Nan::SetPrototypeMethod(tpl, "getMaximumLevel", GetMaximumLevel); Nan::SetPrototypeMethod(tpl, "GetTwoDimensional", GetTwoDimensional); Nan::SetPrototypeMethod(tpl, "getTwoDimensional", GetTwoDimensional); Nan::SetPrototypeMethod(tpl, "GhostLevelsOff", GhostLevelsOff); Nan::SetPrototypeMethod(tpl, "ghostLevelsOff", GhostLevelsOff); Nan::SetPrototypeMethod(tpl, "GhostLevelsOn", GhostLevelsOn); Nan::SetPrototypeMethod(tpl, "ghostLevelsOn", GhostLevelsOn); Nan::SetPrototypeMethod(tpl, "NewInstance", NewInstance); Nan::SetPrototypeMethod(tpl, "newInstance", NewInstance); Nan::SetPrototypeMethod(tpl, "SafeDownCast", SafeDownCast); Nan::SetPrototypeMethod(tpl, "safeDownCast", SafeDownCast); Nan::SetPrototypeMethod(tpl, "SetAdaptiveSubdivision", SetAdaptiveSubdivision); Nan::SetPrototypeMethod(tpl, "setAdaptiveSubdivision", SetAdaptiveSubdivision); Nan::SetPrototypeMethod(tpl, "SetAsymetric", SetAsymetric); Nan::SetPrototypeMethod(tpl, "setAsymetric", SetAsymetric); Nan::SetPrototypeMethod(tpl, "SetDimensions", SetDimensions); Nan::SetPrototypeMethod(tpl, "setDimensions", SetDimensions); Nan::SetPrototypeMethod(tpl, "SetDiscreteTimeSteps", SetDiscreteTimeSteps); Nan::SetPrototypeMethod(tpl, "setDiscreteTimeSteps", SetDiscreteTimeSteps); Nan::SetPrototypeMethod(tpl, "SetFractalValue", SetFractalValue); Nan::SetPrototypeMethod(tpl, "setFractalValue", SetFractalValue); Nan::SetPrototypeMethod(tpl, "SetGenerateRectilinearGrids", SetGenerateRectilinearGrids); Nan::SetPrototypeMethod(tpl, "setGenerateRectilinearGrids", SetGenerateRectilinearGrids); Nan::SetPrototypeMethod(tpl, "SetGhostLevels", SetGhostLevels); Nan::SetPrototypeMethod(tpl, "setGhostLevels", SetGhostLevels); Nan::SetPrototypeMethod(tpl, "SetMaximumLevel", SetMaximumLevel); Nan::SetPrototypeMethod(tpl, "setMaximumLevel", SetMaximumLevel); Nan::SetPrototypeMethod(tpl, "SetTwoDimensional", SetTwoDimensional); Nan::SetPrototypeMethod(tpl, "setTwoDimensional", SetTwoDimensional); Nan::SetPrototypeMethod(tpl, "TwoDimensionalOff", TwoDimensionalOff); Nan::SetPrototypeMethod(tpl, "twoDimensionalOff", TwoDimensionalOff); Nan::SetPrototypeMethod(tpl, "TwoDimensionalOn", TwoDimensionalOn); Nan::SetPrototypeMethod(tpl, "twoDimensionalOn", TwoDimensionalOn); #ifdef VTK_NODE_PLUS_VTKTEMPORALFRACTALWRAP_INITPTPL VTK_NODE_PLUS_VTKTEMPORALFRACTALWRAP_INITPTPL #endif ptpl.Reset( tpl ); } void VtkTemporalFractalWrap::New(const Nan::FunctionCallbackInfo<v8::Value>& info) { if(!info.IsConstructCall()) { Nan::ThrowError("Constructor not called in a construct call."); return; } if(info.Length() == 0) { vtkSmartPointer<vtkTemporalFractal> native = vtkSmartPointer<vtkTemporalFractal>::New(); VtkTemporalFractalWrap* obj = new VtkTemporalFractalWrap(native); obj->Wrap(info.This()); } else { if(info[0]->ToObject() != vtkNodeJsNoWrap ) { Nan::ThrowError("Parameter Error"); return; } } info.GetReturnValue().Set(info.This()); } void VtkTemporalFractalWrap::AdaptiveSubdivisionOff(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkTemporalFractalWrap *wrapper = ObjectWrap::Unwrap<VtkTemporalFractalWrap>(info.Holder()); vtkTemporalFractal *native = (vtkTemporalFractal *)wrapper->native.GetPointer(); if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } native->AdaptiveSubdivisionOff(); } void VtkTemporalFractalWrap::AdaptiveSubdivisionOn(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkTemporalFractalWrap *wrapper = ObjectWrap::Unwrap<VtkTemporalFractalWrap>(info.Holder()); vtkTemporalFractal *native = (vtkTemporalFractal *)wrapper->native.GetPointer(); if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } native->AdaptiveSubdivisionOn(); } void VtkTemporalFractalWrap::DiscreteTimeStepsOff(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkTemporalFractalWrap *wrapper = ObjectWrap::Unwrap<VtkTemporalFractalWrap>(info.Holder()); vtkTemporalFractal *native = (vtkTemporalFractal *)wrapper->native.GetPointer(); if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } native->DiscreteTimeStepsOff(); } void VtkTemporalFractalWrap::DiscreteTimeStepsOn(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkTemporalFractalWrap *wrapper = ObjectWrap::Unwrap<VtkTemporalFractalWrap>(info.Holder()); vtkTemporalFractal *native = (vtkTemporalFractal *)wrapper->native.GetPointer(); if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } native->DiscreteTimeStepsOn(); } void VtkTemporalFractalWrap::GenerateRectilinearGridsOff(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkTemporalFractalWrap *wrapper = ObjectWrap::Unwrap<VtkTemporalFractalWrap>(info.Holder()); vtkTemporalFractal *native = (vtkTemporalFractal *)wrapper->native.GetPointer(); if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } native->GenerateRectilinearGridsOff(); } void VtkTemporalFractalWrap::GenerateRectilinearGridsOn(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkTemporalFractalWrap *wrapper = ObjectWrap::Unwrap<VtkTemporalFractalWrap>(info.Holder()); vtkTemporalFractal *native = (vtkTemporalFractal *)wrapper->native.GetPointer(); if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } native->GenerateRectilinearGridsOn(); } void VtkTemporalFractalWrap::GetAdaptiveSubdivision(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkTemporalFractalWrap *wrapper = ObjectWrap::Unwrap<VtkTemporalFractalWrap>(info.Holder()); vtkTemporalFractal *native = (vtkTemporalFractal *)wrapper->native.GetPointer(); int r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->GetAdaptiveSubdivision(); info.GetReturnValue().Set(Nan::New(r)); } void VtkTemporalFractalWrap::GetAsymetric(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkTemporalFractalWrap *wrapper = ObjectWrap::Unwrap<VtkTemporalFractalWrap>(info.Holder()); vtkTemporalFractal *native = (vtkTemporalFractal *)wrapper->native.GetPointer(); int r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->GetAsymetric(); info.GetReturnValue().Set(Nan::New(r)); } void VtkTemporalFractalWrap::GetDimensions(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkTemporalFractalWrap *wrapper = ObjectWrap::Unwrap<VtkTemporalFractalWrap>(info.Holder()); vtkTemporalFractal *native = (vtkTemporalFractal *)wrapper->native.GetPointer(); int r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->GetDimensions(); info.GetReturnValue().Set(Nan::New(r)); } void VtkTemporalFractalWrap::GetDiscreteTimeSteps(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkTemporalFractalWrap *wrapper = ObjectWrap::Unwrap<VtkTemporalFractalWrap>(info.Holder()); vtkTemporalFractal *native = (vtkTemporalFractal *)wrapper->native.GetPointer(); int r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->GetDiscreteTimeSteps(); info.GetReturnValue().Set(Nan::New(r)); } void VtkTemporalFractalWrap::GetFractalValue(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkTemporalFractalWrap *wrapper = ObjectWrap::Unwrap<VtkTemporalFractalWrap>(info.Holder()); vtkTemporalFractal *native = (vtkTemporalFractal *)wrapper->native.GetPointer(); float r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->GetFractalValue(); info.GetReturnValue().Set(Nan::New(r)); } void VtkTemporalFractalWrap::GetGenerateRectilinearGrids(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkTemporalFractalWrap *wrapper = ObjectWrap::Unwrap<VtkTemporalFractalWrap>(info.Holder()); vtkTemporalFractal *native = (vtkTemporalFractal *)wrapper->native.GetPointer(); int r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->GetGenerateRectilinearGrids(); info.GetReturnValue().Set(Nan::New(r)); } void VtkTemporalFractalWrap::GetGhostLevels(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkTemporalFractalWrap *wrapper = ObjectWrap::Unwrap<VtkTemporalFractalWrap>(info.Holder()); vtkTemporalFractal *native = (vtkTemporalFractal *)wrapper->native.GetPointer(); int r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->GetGhostLevels(); info.GetReturnValue().Set(Nan::New(r)); } void VtkTemporalFractalWrap::GetMaximumLevel(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkTemporalFractalWrap *wrapper = ObjectWrap::Unwrap<VtkTemporalFractalWrap>(info.Holder()); vtkTemporalFractal *native = (vtkTemporalFractal *)wrapper->native.GetPointer(); int r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->GetMaximumLevel(); info.GetReturnValue().Set(Nan::New(r)); } void VtkTemporalFractalWrap::GetTwoDimensional(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkTemporalFractalWrap *wrapper = ObjectWrap::Unwrap<VtkTemporalFractalWrap>(info.Holder()); vtkTemporalFractal *native = (vtkTemporalFractal *)wrapper->native.GetPointer(); int r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->GetTwoDimensional(); info.GetReturnValue().Set(Nan::New(r)); } void VtkTemporalFractalWrap::GhostLevelsOff(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkTemporalFractalWrap *wrapper = ObjectWrap::Unwrap<VtkTemporalFractalWrap>(info.Holder()); vtkTemporalFractal *native = (vtkTemporalFractal *)wrapper->native.GetPointer(); if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } native->GhostLevelsOff(); } void VtkTemporalFractalWrap::GhostLevelsOn(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkTemporalFractalWrap *wrapper = ObjectWrap::Unwrap<VtkTemporalFractalWrap>(info.Holder()); vtkTemporalFractal *native = (vtkTemporalFractal *)wrapper->native.GetPointer(); if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } native->GhostLevelsOn(); } void VtkTemporalFractalWrap::NewInstance(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkTemporalFractalWrap *wrapper = ObjectWrap::Unwrap<VtkTemporalFractalWrap>(info.Holder()); vtkTemporalFractal *native = (vtkTemporalFractal *)wrapper->native.GetPointer(); vtkTemporalFractal * r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->NewInstance(); VtkTemporalFractalWrap::InitPtpl(); v8::Local<v8::Value> argv[1] = { Nan::New(vtkNodeJsNoWrap) }; v8::Local<v8::Function> cons = Nan::New<v8::FunctionTemplate>(VtkTemporalFractalWrap::ptpl)->GetFunction(); v8::Local<v8::Object> wo = cons->NewInstance(1, argv); VtkTemporalFractalWrap *w = new VtkTemporalFractalWrap(); w->native = r; w->Wrap(wo); info.GetReturnValue().Set(wo); } void VtkTemporalFractalWrap::SafeDownCast(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkTemporalFractalWrap *wrapper = ObjectWrap::Unwrap<VtkTemporalFractalWrap>(info.Holder()); vtkTemporalFractal *native = (vtkTemporalFractal *)wrapper->native.GetPointer(); if(info.Length() > 0 && info[0]->IsObject() && (Nan::New(VtkObjectBaseWrap::ptpl))->HasInstance(info[0])) { VtkObjectBaseWrap *a0 = ObjectWrap::Unwrap<VtkObjectBaseWrap>(info[0]->ToObject()); vtkTemporalFractal * r; if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } r = native->SafeDownCast( (vtkObjectBase *) a0->native.GetPointer() ); VtkTemporalFractalWrap::InitPtpl(); v8::Local<v8::Value> argv[1] = { Nan::New(vtkNodeJsNoWrap) }; v8::Local<v8::Function> cons = Nan::New<v8::FunctionTemplate>(VtkTemporalFractalWrap::ptpl)->GetFunction(); v8::Local<v8::Object> wo = cons->NewInstance(1, argv); VtkTemporalFractalWrap *w = new VtkTemporalFractalWrap(); w->native = r; w->Wrap(wo); info.GetReturnValue().Set(wo); return; } Nan::ThrowError("Parameter mismatch"); } void VtkTemporalFractalWrap::SetAdaptiveSubdivision(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkTemporalFractalWrap *wrapper = ObjectWrap::Unwrap<VtkTemporalFractalWrap>(info.Holder()); vtkTemporalFractal *native = (vtkTemporalFractal *)wrapper->native.GetPointer(); if(info.Length() > 0 && info[0]->IsInt32()) { if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } native->SetAdaptiveSubdivision( info[0]->Int32Value() ); return; } Nan::ThrowError("Parameter mismatch"); } void VtkTemporalFractalWrap::SetAsymetric(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkTemporalFractalWrap *wrapper = ObjectWrap::Unwrap<VtkTemporalFractalWrap>(info.Holder()); vtkTemporalFractal *native = (vtkTemporalFractal *)wrapper->native.GetPointer(); if(info.Length() > 0 && info[0]->IsInt32()) { if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } native->SetAsymetric( info[0]->Int32Value() ); return; } Nan::ThrowError("Parameter mismatch"); } void VtkTemporalFractalWrap::SetDimensions(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkTemporalFractalWrap *wrapper = ObjectWrap::Unwrap<VtkTemporalFractalWrap>(info.Holder()); vtkTemporalFractal *native = (vtkTemporalFractal *)wrapper->native.GetPointer(); if(info.Length() > 0 && info[0]->IsInt32()) { if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } native->SetDimensions( info[0]->Int32Value() ); return; } Nan::ThrowError("Parameter mismatch"); } void VtkTemporalFractalWrap::SetDiscreteTimeSteps(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkTemporalFractalWrap *wrapper = ObjectWrap::Unwrap<VtkTemporalFractalWrap>(info.Holder()); vtkTemporalFractal *native = (vtkTemporalFractal *)wrapper->native.GetPointer(); if(info.Length() > 0 && info[0]->IsInt32()) { if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } native->SetDiscreteTimeSteps( info[0]->Int32Value() ); return; } Nan::ThrowError("Parameter mismatch"); } void VtkTemporalFractalWrap::SetFractalValue(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkTemporalFractalWrap *wrapper = ObjectWrap::Unwrap<VtkTemporalFractalWrap>(info.Holder()); vtkTemporalFractal *native = (vtkTemporalFractal *)wrapper->native.GetPointer(); if(info.Length() > 0 && info[0]->IsNumber()) { if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } native->SetFractalValue( info[0]->NumberValue() ); return; } Nan::ThrowError("Parameter mismatch"); } void VtkTemporalFractalWrap::SetGenerateRectilinearGrids(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkTemporalFractalWrap *wrapper = ObjectWrap::Unwrap<VtkTemporalFractalWrap>(info.Holder()); vtkTemporalFractal *native = (vtkTemporalFractal *)wrapper->native.GetPointer(); if(info.Length() > 0 && info[0]->IsInt32()) { if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } native->SetGenerateRectilinearGrids( info[0]->Int32Value() ); return; } Nan::ThrowError("Parameter mismatch"); } void VtkTemporalFractalWrap::SetGhostLevels(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkTemporalFractalWrap *wrapper = ObjectWrap::Unwrap<VtkTemporalFractalWrap>(info.Holder()); vtkTemporalFractal *native = (vtkTemporalFractal *)wrapper->native.GetPointer(); if(info.Length() > 0 && info[0]->IsInt32()) { if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } native->SetGhostLevels( info[0]->Int32Value() ); return; } Nan::ThrowError("Parameter mismatch"); } void VtkTemporalFractalWrap::SetMaximumLevel(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkTemporalFractalWrap *wrapper = ObjectWrap::Unwrap<VtkTemporalFractalWrap>(info.Holder()); vtkTemporalFractal *native = (vtkTemporalFractal *)wrapper->native.GetPointer(); if(info.Length() > 0 && info[0]->IsInt32()) { if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } native->SetMaximumLevel( info[0]->Int32Value() ); return; } Nan::ThrowError("Parameter mismatch"); } void VtkTemporalFractalWrap::SetTwoDimensional(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkTemporalFractalWrap *wrapper = ObjectWrap::Unwrap<VtkTemporalFractalWrap>(info.Holder()); vtkTemporalFractal *native = (vtkTemporalFractal *)wrapper->native.GetPointer(); if(info.Length() > 0 && info[0]->IsInt32()) { if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } native->SetTwoDimensional( info[0]->Int32Value() ); return; } Nan::ThrowError("Parameter mismatch"); } void VtkTemporalFractalWrap::TwoDimensionalOff(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkTemporalFractalWrap *wrapper = ObjectWrap::Unwrap<VtkTemporalFractalWrap>(info.Holder()); vtkTemporalFractal *native = (vtkTemporalFractal *)wrapper->native.GetPointer(); if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } native->TwoDimensionalOff(); } void VtkTemporalFractalWrap::TwoDimensionalOn(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkTemporalFractalWrap *wrapper = ObjectWrap::Unwrap<VtkTemporalFractalWrap>(info.Holder()); vtkTemporalFractal *native = (vtkTemporalFractal *)wrapper->native.GetPointer(); if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } native->TwoDimensionalOn(); }
/* ************************************************************************ * Copyright 2016-2020 Advanced Micro Devices, Inc. * * ************************************************************************ */ #include "testing_hemv.hpp" #include "utility.h" #include <gtest/gtest.h> #include <math.h> #include <stdexcept> #include <vector> using ::testing::Combine; using ::testing::TestWithParam; using ::testing::Values; using ::testing::ValuesIn; using namespace std; // only GCC/VS 2010 comes with std::tr1::tuple, but it is unnecessary, std::tuple is good enough; typedef std::tuple<vector<int>, vector<int>, vector<double>, char, bool> hemv_tuple; /* ===================================================================== README: This file contains testers to verify the correctness of BLAS routines with google test It is supposed to be played/used by advance / expert users Normal users only need to get the library routines without testers =================================================================== */ /* ===================================================================== Advance users only: BrainStorm the parameters but do not make artificial one which invalidates the matrix. like lda pairs with M, and "lda must >= M". case "lda < M" will be guarded by argument-checkers inside API of course. Yet, the goal of this file is to verify result correctness not argument-checkers. Representative sampling is sufficient, endless brute-force sampling is not necessary =================================================================== */ // vector of vector, each vector is a {N, lda}; // add/delete as a group const vector<vector<int>> matrix_size_range = { {-1, -1}, // {10, 10, 2}, // {600,500, 500}, {1000, 1000}, // {2000, 2000, 2000}, // {4011, 4011, 4011}, // {8000, 8000, 8000}, }; // vector of vector, each pair is a {incx, incy}; // add/delete this list in pairs, like {1, 1} const vector<vector<int>> incx_incy_range = { {1, 1}, {0, -1}, {2, 1}, // {10, 100}, }; // vector of vector, each pair is a {alpha, beta}; // add/delete this list in pairs, like {2.0, 4.0} const vector<vector<double>> alpha_beta_range = { {1.0, 0.0}, {-1.0, -1.0}, {2.0, 1.0}, {0.0, 1.0}, }; // for single/double precision, 'C'(conjTranspose) will downgraded to 'T' (transpose) internally in // shemv/dhemv, const vector<char> transA_range = { 'N', 'T', 'C', }; const bool is_fortran[] = {false, true}; /* ===============Google Unit Test==================================================== */ /* ===================================================================== BLAS-3 hemv: =================================================================== */ /* ============================Setup Arguments======================================= */ // Please use "class Arguments" (see utility.hpp) to pass parameters to templated testers; // Some routines may not touch/use certain "members" of objects "argus". // like BLAS-1 Scal does not have lda, BLAS-2 HEMV does not have ldb, ldc; // That is fine. These testers & routines will leave untouched members alone. // Do not use std::tuple to directly pass parameters to testers // by std:tuple, you have unpack it with extreme care for each one by like "std::get<0>" which is // not intuitive and error-prone Arguments setup_hemv_arguments(hemv_tuple tup) { vector<int> matrix_size = std::get<0>(tup); vector<int> incx_incy = std::get<1>(tup); vector<double> alpha_beta = std::get<2>(tup); char transA = std::get<3>(tup); bool fortran = std::get<4>(tup); Arguments arg; // see the comments about matrix_size_range above arg.N = matrix_size[0]; arg.lda = matrix_size[1]; // see the comments about matrix_size_range above arg.incx = incx_incy[0]; arg.incy = incx_incy[1]; // the first element of alpha_beta_range is always alpha, and the second is always beta arg.alpha = alpha_beta[0]; arg.beta = alpha_beta[1]; arg.transA_option = transA; arg.fortran = fortran; arg.timing = 0; return arg; } class hemv_gtest : public ::TestWithParam<hemv_tuple> { protected: hemv_gtest() {} virtual ~hemv_gtest() {} virtual void SetUp() {} virtual void TearDown() {} }; TEST_P(hemv_gtest, hemv_gtest_float_complex) { // GetParam return a tuple. Tee setup routine unpack the tuple // and initializes arg(Arguments) which will be passed to testing routine // The Arguments data struture have physical meaning associated. // while the tuple is non-intuitive. Arguments arg = setup_hemv_arguments(GetParam()); hipblasStatus_t status = testing_hemv<hipblasComplex>(arg); // if not success, then the input argument is problematic, so detect the error message if(status != HIPBLAS_STATUS_SUCCESS) { if(arg.N < 0 || arg.lda < arg.N || arg.lda < 1 || arg.incx == 0 || arg.incy == 0) { EXPECT_EQ(HIPBLAS_STATUS_INVALID_VALUE, status); } else { EXPECT_EQ(HIPBLAS_STATUS_SUCCESS, status); // fail } } } // notice we are using vector of vector // so each elment in xxx_range is a avector, // ValuesIn take each element (a vector) and combine them and feed them to test_p // The combinations are { {M, N, lda}, {incx,incy} {alpha, beta}, {transA} } INSTANTIATE_TEST_SUITE_P(hipblasHemv, hemv_gtest, Combine(ValuesIn(matrix_size_range), ValuesIn(incx_incy_range), ValuesIn(alpha_beta_range), ValuesIn(transA_range), ValuesIn(is_fortran)));
#include "offscreen_effect_player.hpp" #include "offscreen_render_target.hpp" #include "glfw_window.hpp" #include "render_thread.hpp" #include <bnb/spal/camera/ocv_based.hpp> #define BNB_CLIENT_TOKEN <#Place your token here#> int main() { int32_t width = 1280; int32_t height = 720; std::optional<std::shared_ptr<bnb::interfaces::offscreen_render_target>> ort; ort = std::make_shared<bnb::offscreen_render_target>(width, height); auto oep = bnb::offscreen_effect_player::create({ BNB_RESOURCES_FOLDER }, BNB_CLIENT_TOKEN, width, height, false, ort); oep->load_effect("effects/test_BG"); //We make glfw_window and render_thread only for show result of OEP std::shared_ptr<glfw_window> window = std::make_shared<glfw_window>(""); std::shared_ptr<render::render_thread> render_t = std::make_shared<render::render_thread>(window->get_window(), width, height); auto ef_cb = [&oep, render_t](bnb::full_image_t image) { auto image_ptr = std::make_shared<bnb::full_image_t>(std::move(image)); auto get_pixel_buffer_callback = [image_ptr, render_t](std::shared_ptr<bnb::interfaces::pixel_buffer> pb) { auto render_callback = [render_t](bnb::full_image_t image) { render_t->update_data(std::move(image)); render_t->schedule([render_t]() mutable { render_t->update_context(); }); }; pb->get_NV12(render_callback); }; oep->process_image_async(image_ptr, get_pixel_buffer_callback); }; std::shared_ptr<bnb::camera_base> m_camera_ptr = bnb::create_camera_device(ef_cb, 0); window->show(width, height); window->run_main_loop(); return 0; }
// Scintilla source code edit control /** @file Indicator.cxx ** Defines the style of indicators which are text decorations such as underlining. **/ // Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org> // The License.txt file describes the conditions under which this software may be distributed. #include <cmath> #include <stdexcept> #include <vector> #include <map> #include <algorithm> #include <memory> #include "Platform.h" #include "Scintilla.h" #include "IntegerRectangle.h" #include "Indicator.h" #include "XPM.h" using namespace Scintilla; static PRectangle PixelGridAlign(const PRectangle &rc) noexcept { // Move left and right side to nearest pixel to avoid blurry visuals return PRectangle(Sci::round(rc.left), std::floor(rc.top), Sci::round(rc.right), std::floor(rc.bottom)); } void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine, const PRectangle &rcCharacter, State state, int value) const { StyleAndColour sacDraw = sacNormal; if (Flags() & SC_INDICFLAG_VALUEFORE) { sacDraw.fore = ColourDesired(value & SC_INDICVALUEMASK); } if (state == State::hover) { sacDraw = sacHover; } const IntegerRectangle irc(rc); surface->PenColour(sacDraw.fore); const int ymid = (irc.bottom + irc.top) / 2; switch (sacDraw.style) { case INDIC_SQUIGGLE: { const IntegerRectangle ircSquiggle(PixelGridAlign(rc)); int x = ircSquiggle.left; const int xLast = ircSquiggle.right; int y = 0; surface->MoveTo(x, irc.top + y); while (x < xLast) { if ((x + 2) > xLast) { y = 1; x = xLast; } else { x += 2; y = 2 - y; } surface->LineTo(x, irc.top + y); } } break; case INDIC_SQUIGGLEPIXMAP: { const PRectangle rcSquiggle = PixelGridAlign(rc); const int width = std::min(4000, static_cast<int>(rcSquiggle.Width())); RGBAImage image(width, 3, 1.0, nullptr); enum { alphaFull = 0xff, alphaSide = 0x2f, alphaSide2=0x5f }; for (int x = 0; x < width; x++) { if (x%2) { // Two halfway columns have a full pixel in middle flanked by light pixels image.SetPixel(x, 0, sacDraw.fore, alphaSide); image.SetPixel(x, 1, sacDraw.fore, alphaFull); image.SetPixel(x, 2, sacDraw.fore, alphaSide); } else { // Extreme columns have a full pixel at bottom or top and a mid-tone pixel in centre image.SetPixel(x, (x % 4) ? 0 : 2, sacDraw.fore, alphaFull); image.SetPixel(x, 1, sacDraw.fore, alphaSide2); } } surface->DrawRGBAImage(rcSquiggle, image.GetWidth(), image.GetHeight(), image.Pixels()); } break; case INDIC_SQUIGGLELOW: { surface->MoveTo(irc.left, irc.top); int x = irc.left + 3; int y = 0; while (x < rc.right) { surface->LineTo(x - 1, irc.top + y); y = 1 - y; surface->LineTo(x, irc.top + y); x += 3; } surface->LineTo(irc.right, irc.top + y); // Finish the line } break; case INDIC_TT: { surface->MoveTo(irc.left, ymid); int x = irc.left + 5; while (x < rc.right) { surface->LineTo(x, ymid); surface->MoveTo(x-3, ymid); surface->LineTo(x-3, ymid+2); x++; surface->MoveTo(x, ymid); x += 5; } surface->LineTo(irc.right, ymid); // Finish the line if (x - 3 <= rc.right) { surface->MoveTo(x-3, ymid); surface->LineTo(x-3, ymid+2); } } break; case INDIC_DIAGONAL: { int x = irc.left; while (x < rc.right) { surface->MoveTo(x, irc.top + 2); int endX = x+3; int endY = irc.top - 1; if (endX > rc.right) { endY += endX - irc.right; endX = irc.right; } surface->LineTo(endX, endY); x += 4; } } break; case INDIC_STRIKE: { surface->MoveTo(irc.left, irc.top - 4); surface->LineTo(irc.right, irc.top - 4); } break; case INDIC_HIDDEN: case INDIC_TEXTFORE: // Draw nothing break; case INDIC_BOX: { surface->MoveTo(irc.left, ymid + 1); surface->LineTo(irc.right, ymid + 1); const int lineTop = static_cast<int>(rcLine.top) + 1; surface->LineTo(irc.right, lineTop); surface->LineTo(irc.left, lineTop); surface->LineTo(irc.left, ymid + 1); } break; case INDIC_ROUNDBOX: case INDIC_STRAIGHTBOX: case INDIC_FULLBOX: { PRectangle rcBox = rcLine; if (sacDraw.style != INDIC_FULLBOX) rcBox.top = rcLine.top + 1; rcBox.left = rc.left; rcBox.right = rc.right; surface->AlphaRectangle(rcBox, (sacDraw.style == INDIC_ROUNDBOX) ? 1 : 0, sacDraw.fore, fillAlpha, sacDraw.fore, outlineAlpha, 0); } break; case INDIC_GRADIENT: case INDIC_GRADIENTCENTRE: { PRectangle rcBox = rc; rcBox.top = rcLine.top + 1; rcBox.bottom = rcLine.bottom; const Surface::GradientOptions options = Surface::GradientOptions::topToBottom; const ColourAlpha start(sacDraw.fore, fillAlpha); const ColourAlpha end(sacDraw.fore, 0); std::vector<ColourStop> stops; switch (sacDraw.style) { case INDIC_GRADIENT: stops.push_back(ColourStop(0.0, start)); stops.push_back(ColourStop(1.0, end)); break; case INDIC_GRADIENTCENTRE: stops.push_back(ColourStop(0.0, end)); stops.push_back(ColourStop(0.5, start)); stops.push_back(ColourStop(1.0, end)); break; } surface->GradientRectangle(rcBox, stops, options); } break; case INDIC_DOTBOX: { PRectangle rcBox = PixelGridAlign(rc); rcBox.top = rcLine.top + 1; rcBox.bottom = rcLine.bottom; const IntegerRectangle ircBox(rcBox); // Cap width at 4000 to avoid large allocations when mistakes made const int width = std::min(ircBox.Width(), 4000); RGBAImage image(width, ircBox.Height(), 1.0, nullptr); // Draw horizontal lines top and bottom for (int x=0; x<width; x++) { for (int y = 0; y<ircBox.Height(); y += ircBox.Height() - 1) { image.SetPixel(x, y, sacDraw.fore, ((x + y) % 2) ? outlineAlpha : fillAlpha); } } // Draw vertical lines left and right for (int y = 1; y<ircBox.Height(); y++) { for (int x=0; x<width; x += width-1) { image.SetPixel(x, y, sacDraw.fore, ((x + y) % 2) ? outlineAlpha : fillAlpha); } } surface->DrawRGBAImage(rcBox, image.GetWidth(), image.GetHeight(), image.Pixels()); } break; case INDIC_DASH: { int x = irc.left; while (x < rc.right) { surface->MoveTo(x, ymid); surface->LineTo(std::min(x + 4, irc.right), ymid); x += 7; } } break; case INDIC_DOTS: { int x = irc.left; while (x < irc.right) { const PRectangle rcDot = PRectangle::FromInts(x, ymid, x + 1, ymid + 1); surface->FillRectangle(rcDot, sacDraw.fore); x += 2; } } break; case INDIC_COMPOSITIONTHICK: { const PRectangle rcComposition(rc.left+1, rcLine.bottom-2, rc.right-1, rcLine.bottom); surface->FillRectangle(rcComposition, sacDraw.fore); } break; case INDIC_COMPOSITIONTHIN: { const PRectangle rcComposition(rc.left+1, rcLine.bottom-2, rc.right-1, rcLine.bottom-1); surface->FillRectangle(rcComposition, sacDraw.fore); } break; case INDIC_POINT: case INDIC_POINTCHARACTER: if (rcCharacter.Width() >= 0.1) { const XYPOSITION pixelHeight = std::floor(rc.Height() - 1.0f); // 1 pixel onto next line if multiphase const XYPOSITION x = (sacDraw.style == INDIC_POINT) ? (rcCharacter.left) : ((rcCharacter.right + rcCharacter.left) / 2); const XYPOSITION ix = Sci::round(x); const XYPOSITION iy = std::floor(rc.top + 1.0f); Point pts[] = { Point(ix - pixelHeight, iy + pixelHeight), // Left Point(ix + pixelHeight, iy + pixelHeight), // Right Point(ix, iy) // Top }; surface->Polygon(pts, Sci::size(pts), sacDraw.fore, sacDraw.fore); } break; default: // Either INDIC_PLAIN or unknown surface->MoveTo(irc.left, ymid); surface->LineTo(irc.right, ymid); } } void Indicator::SetFlags(int attributes_) noexcept { attributes = attributes_; }
#include <iostream> using namespace std; void Stretch(MATRIX3X3& , Pixels& , int ); void Rotate(MATRIX3X3& , Pixels& , int); void Squeeze(MATRIX3X3& , Pixels& , int); void Shearing(MATRIX3X3& , Pixels&); void Flip(MATRIX3X3& , Pixels& , int); void CopyMatrix(Pixels&, PixelsTransformed&, int, int) void MultMatrix(MATRIX3X3& product,MATRIX3X3& matrix1, Pixels& matrix2) int main() { //size for matrix transformation matrix const int m = 2; //matrix for transofrmations typedef double MATRIX3X3[m][m]; //choice for operation int choice; //choose whether x axis stretch or y axis stretch int XorYStretch; cv::Mat img = cv::imread("file.jpg"); int Pixels[10000][10000]; int PixelsTransformed[10000][10000]; //size of image matrix int ImageRow = img.rows; int ImageColumn = img.cols; for(int i=0;i<ImageColumn;i++) { for(int j=0;j<ImageRow;j++) { Pixels[i][j]=img.at<int>(i,j); } } // Call functions to be performed cout << "Please choose a number to perform the operation desired"<< endl; cout << "1 for Stretching. 2 for Rotating. 3 for Squeezing. 4 for Shearing. 5 for flipping" << endl; cin >> choice; switch (choice) { case 1: cout << "Please enter whether it is a Stretch along x axis(Press 1) or y axis (Press 2)" << endl; cin >> XorYStretch; void Stretch(&m, &p, XorYStretch); break; case 2: cout << "Please enter degrees for rotation" << endl; cin >> degrees; void Rotate(&m, &p, degrees); break; case 3: cout << "Please enter Squeeze Factor" << endl; cin >> SqFactor; void Squeeze(&m,&p, SqFactor); break; case 4: cout << "Please enter whether it is a Shear along x axis(Press 1) or y axis (Press 2)" << endl; cin >> XorYShear; void Shearing(&m, &p, XorYShear); break; case 5: cout << "Please enter whether it is a Stretch along x axis(Press 1) or y axis (Press 2) or along y = x (press 3)" << endl; cin >> XorYorLflip; void Flip(&m, &p, XorYorLflip) break; default: // choice is doesn't match any case cout << "Error! Number is not correct"; break; } // OUTPUT FINAL PICTURE return 0; } void CopyMatrix(Pixels& src, PixelsTransformed& dst, int ImageRow, int ImageCol) { for (int i=0; i<ImageRow; ++i) for (int j=0; j<ImageCol; ++j) dst[i][j] = src[i][j]; } //using multiplication from swift library void MultMatrix(MATRIX3X3& product,MATRIX3X3& matrix1, Pixels& matrix2) { for (int x=0; x<3; ++x) for (int y=0; y<3; ++y) { double sum = 0; for (int z=0; z<3; ++z) sum += matrix1[x][z] * matrix2[z][y]; product[x][y] = sum; } } void Stretch(MATRIX3X3& m1, Pixels& p, int XorYStretch) { MATRIX3X3 m1; Pixels p1; int xStretch = 100; int yStretch = 100; if (XorYStretch == 1) { m1[0][0]=xStretch; m1[0][1]=0; m1[1][0]=0; m1[1][1]=1; } else if (XorYStretch == 2) { m1[0][0]=1; m1[0][1]=0; m1[1][0]=0; m1[1][1]=yStretch; } MultMatrix(p1, m1, p); CopyMatrix(p, p1); } void Rotate(MATRIX3X3& m, Pixels& p, int degrees) { MATRIX3X3 m1; Pixels p1; if (degrees == 0) return; double radians = 6.283185308 / (360.0 / degrees); double c = cos(radians); double s = sin(radians); m1[0][0]=c; m1[0][1]=s; m1[1][0]=-s; m1[1][1]=c; MultMatrix(p1, m1, p); CopyMatrix(p, p1); } //leaves area unchanged void Squeeze(MATRIX3X3& m, Pixels& p, int SqFactor) { MATRIX3X3 m1; Pixels p1; m1[0][0]=SqFactor; m1[0][1]=0; m1[1][0]=0; m1[1][1]=(1/SqFactor); MultMatrix(p1, m1, p); CopyMatrix(p, p1); } void Shearing(MATRIX3X3& m, Pixels& p, int XorYShear) { MATRIX3X3 m1; Pixels p1; int ShearFactor = 100; // parallel to x axis if (XorYStretch == 1) { m1[0][0]=1; m1[0][1]=ShearFactor; m1[1][0]=0; m1[1][1]=1; } // parallel to y axis else if (XorYStretch == 2) { m1[0][0]=1; m1[0][1]=0; m1[1][0]=ShearFactor; m1[1][1]=1; } MultMatrix(p1, m1, p); CopyMatrix(p, p1); } void Flip(MATRIX3X3& m, Pixels& p, int XorYorLflip) { MATRIX3X3 m1; Pixels p1; // x axis if (XorYorLflip == 1) { m1[0][0]=1; m1[0][1]= 0; m1[1][0]=0; m1[1][1]= -1; } // y axis else if (XorYorLflip == 2) { m1[0][0]= -1; m1[0][1]=0; m1[1][0]= 0 ; m1[1][1]=1; } // along y = x else if (XorYorLflip == 3) { m1[0][0]=0; m1[0][1]= 1; m1[1][0]= 1; m1[1][1]= 0; } MultMatrix(p1, m1, p); CopyMatrix(p, p1); }
/// @ref gtx_color_encoding /// @file glm/gtx/color_encoding.inl namespace glm { template <typename T, precision P> GLM_FUNC_QUALIFIER tvec3<T, P> convertLinearSRGBToD65XYZ(tvec3<T, P> const& ColorLinearSRGB) { tvec3<T, P> const M(0.490f, 0.17697f, 0.2f); tvec3<T, P> const N(0.31f, 0.8124f, 0.01063f); tvec3<T, P> const O(0.490f, 0.01f, 0.99f); return (M * ColorLinearSRGB + N * ColorLinearSRGB + O * ColorLinearSRGB) * static_cast<T>(5.650675255693055f); } template <typename T, precision P> GLM_FUNC_QUALIFIER tvec3<T, P> convertLinearSRGBToD50XYZ(tvec3<T, P> const& ColorLinearSRGB) { tvec3<T, P> const M(0.436030342570117f, 0.222438466210245f, 0.013897440074263f); tvec3<T, P> const N(0.385101860087134f, 0.716942745571917f, 0.097076381494207f); tvec3<T, P> const O(0.143067806654203f, 0.060618777416563f, 0.713926257896652f); return M * ColorLinearSRGB + N * ColorLinearSRGB + O * ColorLinearSRGB; } template <typename T, precision P> GLM_FUNC_QUALIFIER tvec3<T, P> convertD65XYZToLinearSRGB(tvec3<T, P> const& ColorD65XYZ) { tvec3<T, P> const M(0.41847f, -0.091169f, 0.0009209f); tvec3<T, P> const N(-0.15866f, 0.25243f, 0.015708f); tvec3<T, P> const O(0.0009209f, -0.0025498f, 0.1786f); return M * ColorD65XYZ + N * ColorD65XYZ + O * ColorD65XYZ; } template <typename T, precision P> GLM_FUNC_QUALIFIER tvec3<T, P> convertD65XYZToD50XYZ(tvec3<T, P> const& ColorD65XYZ) { tvec3<T, P> const M(+1.047844353856414f, +0.029549007606644f, -0.009250984365223f); tvec3<T, P> const N(+0.022898981050086f, +0.990508028941971f, +0.015072338237051f); tvec3<T, P> const O(-0.050206647741605f, -0.017074711360960f, +0.751717835079977f); return M * ColorD65XYZ + N * ColorD65XYZ + O * ColorD65XYZ; } }//namespace glm
/* * Copyright (C) 2019-2021 Intel Corporation * * SPDX-License-Identifier: MIT * */ #include "shared/source/utilities/metrics_library.h" namespace NEO { ////////////////////////////////////////////////////// // FUNCTION: MetricsLibrary::oaConfigurationActivate ////////////////////////////////////////////////////// bool MetricsLibrary::oaConfigurationActivate( const ConfigurationHandle_1_0 &handle) { ConfigurationActivateData_1_0 data = {}; data.Type = GpuConfigurationActivationType::EscapeCode; return api->functions.ConfigurationActivate( handle, &data) == StatusCode::Success; } ////////////////////////////////////////////////////// // FUNCTION: MetricsLibrary::oaConfigurationDeactivate ////////////////////////////////////////////////////// bool MetricsLibrary::oaConfigurationDeactivate( const ConfigurationHandle_1_0 &handle) { return api->functions.ConfigurationDeactivate( handle) == StatusCode::Success; } ////////////////////////////////////////////////////// // FUNCTION: MetricsLibrary::userConfigurationCreate ////////////////////////////////////////////////////// bool MetricsLibrary::userConfigurationCreate( const ContextHandle_1_0 &context, ConfigurationHandle_1_0 &handle) { ConfigurationCreateData_1_0 data = {}; data.HandleContext = context; data.Type = ObjectType::ConfigurationHwCountersUser; return api->functions.ConfigurationCreate( &data, &handle) == StatusCode::Success; } ////////////////////////////////////////////////////// // FUNCTION: MetricsLibrary::userConfigurationDelete ////////////////////////////////////////////////////// bool MetricsLibrary::userConfigurationDelete( const ConfigurationHandle_1_0 &handle) { return api->functions.ConfigurationDelete(handle) == StatusCode::Success; } } // namespace NEO
#include "bitboard.hpp" #include "../lib/euler.hpp" #include <vector> #include <cinttypes> using namespace std; typedef unsigned long ul; // Encode each digit on the didital clock as // top middle bottom left right left right const vector<uint8_t> numbers = {0b1011111, 0b0000101, 0b1110110, 0b1110101, 0b0101101, 0b1111001, 0b1111011, 0b1001101, 0b1111111, 0b1111101}; class ClockNumber { public: ClockNumber(string n) { if (n.size() > 8) { cout << "Clock allows only upto 8 digits" << endl; cout << n << " " << n.size() << endl; exit(1); } // save the value of n this->n = n; for (auto i = 0; i < n.size(); ++i) { number |= numbers[n[i]-'0']; if (i < n.size() - 1) number <<= 8; } } uint64_t digital_roots() { // perform digital roots procedure on current number // while keeping account of difference in transitions // between sam and max while (n.size() - 1) { uint64_t n_ = 0; for (auto i = 0; i < n.size(); ++i) n_ += n[i] - '0'; set(to_string(n_)); } return diff; } void set(ClockNumber num) { // Difference between sam's and max's clock transitions diff += 2*popcount(number & num.number); number = num.number; n = num.n; } void reset() { number = diff = 0; } private: /* data */ uint64_t number = 0; string n; ul diff = 0; }; int main(int argc, char *argv[]) { vector<bool> s = sieve(20000000); uint64_t diff = 0; for (auto i = 10000001; i < s.size(); i += 2) { if (s[i]) continue; ClockNumber cn(to_string(i+2)); diff += cn.digital_roots(); } cout << diff << endl; }
#include <iostream> #include <cassert> #include <stddef.h> #include <sys/ioctl.h> #include <sys/stat.h> #include <sys/sys_domain.h> #include <sys/xattr.h> #include <sys/fsgetpath.h> #include <thread> #include <unistd.h> #include <dirent.h> #include <queue> #include <stack> #include <memory> #include <set> #include <map> #include <IOKit/IOKitLib.h> #include <IOKit/IODataQueueClient.h> #include <mach/mach_port.h> #include <CoreFoundation/CFNumber.h> #include <string> #include <sstream> #include "stdlib.h" #include "PrjFSLib.h" #include "../PrjFSKext/public/PrjFSCommon.h" #include "../PrjFSKext/public/PrjFSXattrs.h" #include "../PrjFSKext/public/Message.h" #include "PrjFSUser.hpp" #define STRINGIFY(s) #s using std::cerr; using std::cout; using std::dec; using std::endl; using std::extent; using std::hex; using std::is_pod; using std::lock_guard; using std::make_pair; using std::make_shared; using std::map; using std::move; using std::mutex; using std::oct; using std::ostringstream; using std::pair; using std::queue; using std::set; using std::shared_ptr; using std::stack; using std::string; typedef lock_guard<mutex> mutex_lock; // Structs struct _PrjFS_FileHandle { FILE* file; }; struct FsidInodeCompare { bool operator() (const FsidInode& lhs, const FsidInode& rhs) const { if (lhs.fsid.val[0] != rhs.fsid.val[0]) { return lhs.fsid.val[0] < rhs.fsid.val[0]; } if (lhs.fsid.val[1] != rhs.fsid.val[1]) { return lhs.fsid.val[1] < rhs.fsid.val[1]; } return lhs.inode < rhs.inode; } }; struct MutexAndUseCount { shared_ptr<mutex> mutex; int useCount; }; typedef map<FsidInode, MutexAndUseCount, FsidInodeCompare> FileMutexMap; // Function prototypes static bool SetBitInFileFlags(const char* fullPath, uint32_t bit, bool value); static bool IsBitSetInFileFlags(const char* fullPath, uint32_t bit); static bool InitializeEmptyPlaceholder(const char* fullPath); template<typename TPlaceholder> static bool InitializeEmptyPlaceholder(const char* fullPath, TPlaceholder* data, const char* xattrName); static errno_t AddXAttr(const char* fullPath, const char* name, const void* value, size_t size); static bool TryGetXAttr(const char* fullPath, const char* name, size_t expectedSize, _Out_ void* value); static errno_t RemoveXAttrWithoutFollowingLinks(const char* fullPath, const char* name); static inline PrjFS_NotificationType KUMessageTypeToNotificationType(MessageType kuNotificationType); static bool IsVirtualizationRoot(const char* fullPath); static void CombinePaths(const char* root, const char* relative, char (&combined)[PrjFSMaxPath]); static const char* GetRelativePath(const char* fullPath, const char* root); static errno_t SendKernelMessageResponse(uint64_t messageId, MessageType responseType); static errno_t RegisterVirtualizationRootPath(const char* fullPath); static PrjFS_Result RecursivelyMarkAllChildrenAsInRoot(const char* fullDirectoryPath); static void HandleKernelRequest(void* messageMemory, uint32_t messageSize); static PrjFS_Result HandleEnumerateDirectoryRequest(const MessageHeader* request, const char* absolutePath, const char* relativePath); static PrjFS_Result HandleRecursivelyEnumerateDirectoryRequest(const MessageHeader* request, const char* absolutePath, const char* relativePath); static PrjFS_Result HandleHydrateFileRequest(const MessageHeader* request, const char* absolutePath, const char* relativePath); static PrjFS_Result HandleNewFileInRootNotification( const MessageHeader* request, const char* relativePath, const char* fullPath, bool isDirectory, PrjFS_NotificationType notificationType); static PrjFS_Result HandleFileNotification( const MessageHeader* request, const char* relativePath, const char* fullPath, bool isDirectory, PrjFS_NotificationType notificationType); static void FindNewFoldersInRootAndNotifyProvider(const MessageHeader* request, const char* relativePath); static bool IsDirEntChildDirectory(const dirent* directoryEntry); static Message ParseMessageMemory(const void* messageMemory, uint32_t size); #ifdef DEBUG static const char* NotificationTypeToString(PrjFS_NotificationType notificationType); #endif static FileMutexMap::iterator CheckoutFileMutexIterator(const FsidInode& fsidInode); static void ReturnFileMutexIterator(FileMutexMap::iterator lockIterator); // State static io_connect_t s_kernelServiceConnection = IO_OBJECT_NULL; static string s_virtualizationRootFullPath; static PrjFS_Callbacks s_callbacks; static dispatch_queue_t s_messageQueueDispatchQueue; static dispatch_queue_t s_kernelRequestHandlingConcurrentQueue; // Map of FsidInode -> MutexAndUseCount for that FsidInode, plus mutex to protect the map itself. FileMutexMap s_fileLocks; mutex s_fileLocksMutex; // The full API is defined in the header, but only the minimal set of functions needed // for the initial MirrorProvider implementation are listed here. Calling any other function // will lead to a linker error for now. // Public functions PrjFS_Result PrjFS_StartVirtualizationInstance( _In_ const char* virtualizationRootFullPath, _In_ PrjFS_Callbacks callbacks, _In_ unsigned int poolThreadCount) { #ifdef DEBUG cout << "PrjFS_StartVirtualizationInstance(" << virtualizationRootFullPath << ", " << callbacks.EnumerateDirectory << ", " << callbacks.GetFileStream << ", " << callbacks.NotifyOperation << ", " << callbacks.LogError << "," << poolThreadCount << ")" << endl; #endif if (nullptr == virtualizationRootFullPath || nullptr == callbacks.EnumerateDirectory || nullptr == callbacks.GetFileStream || nullptr == callbacks.NotifyOperation || nullptr == callbacks.LogError) { return PrjFS_Result_EInvalidArgs; } if (!s_virtualizationRootFullPath.empty()) { return PrjFS_Result_EInvalidOperation; } if (!IsVirtualizationRoot(virtualizationRootFullPath)) { return PrjFS_Result_ENotAVirtualizationRoot; } s_kernelServiceConnection = PrjFSService_ConnectToDriver(UserClientType_Provider); if (IO_OBJECT_NULL == s_kernelServiceConnection) { return PrjFS_Result_EDriverNotLoaded; } DataQueueResources dataQueue; s_messageQueueDispatchQueue = dispatch_queue_create("PrjFS Kernel Message Handling", DISPATCH_QUEUE_SERIAL); if (!PrjFSService_DataQueueInit(&dataQueue, s_kernelServiceConnection, ProviderPortType_MessageQueue, ProviderMemoryType_MessageQueue, s_messageQueueDispatchQueue)) { cerr << "Failed to set up shared data queue.\n"; return PrjFS_Result_EInvalidOperation; } s_virtualizationRootFullPath = virtualizationRootFullPath; s_callbacks = callbacks; errno_t error = RegisterVirtualizationRootPath(virtualizationRootFullPath); if (error != 0) { cerr << "Registering virtualization root failed: " << error << ", " << strerror(error) << endl; return PrjFS_Result_EInvalidOperation; } s_kernelRequestHandlingConcurrentQueue = dispatch_queue_create("PrjFS Kernel Request Handling", DISPATCH_QUEUE_CONCURRENT); dispatch_source_set_event_handler(dataQueue.dispatchSource, ^{ DataQueue_ClearMachNotification(dataQueue.notificationPort); while (1) { IODataQueueEntry* entry = DataQueue_Peek(dataQueue.queueMemory); if (nullptr == entry) { // No more items in queue break; } uint32_t messageSize = entry->size; if (messageSize < sizeof(Message)) { cerr << "Bad message size: got " << messageSize << " bytes, expected minimum of " << sizeof(Message) << ", skipping. Kernel/user version mismatch?\n"; DataQueue_Dequeue(dataQueue.queueMemory, nullptr, nullptr); continue; } void* messageMemory = malloc(messageSize); uint32_t dequeuedSize = messageSize; IOReturn result = DataQueue_Dequeue(dataQueue.queueMemory, messageMemory, &dequeuedSize); if (kIOReturnSuccess != result || dequeuedSize != messageSize) { cerr << "Unexpected result dequeueing message - result 0x" << hex << result << " dequeued " << dequeuedSize << "/" << messageSize << " bytes\n"; abort(); } dispatch_async( s_kernelRequestHandlingConcurrentQueue, ^{ HandleKernelRequest(messageMemory, messageSize); }); } }); dispatch_resume(dataQueue.dispatchSource); return PrjFS_Result_Success; } PrjFS_Result PrjFS_ConvertDirectoryToVirtualizationRoot( _In_ const char* virtualizationRootFullPath) { #ifdef DEBUG cout << "PrjFS_ConvertDirectoryToVirtualizationRoot(" << virtualizationRootFullPath << ")" << endl; #endif if (nullptr == virtualizationRootFullPath) { return PrjFS_Result_EInvalidArgs; } // TODO(Mac): walk entire parent chain to root and all child directories to leaf nodes, to make sure we find no other virtualization roots. // It is not allowed to have nested virtualization roots. if (IsBitSetInFileFlags(virtualizationRootFullPath, FileFlags_IsInVirtualizationRoot) || IsVirtualizationRoot(virtualizationRootFullPath)) { return PrjFS_Result_EVirtualizationRootAlreadyExists; } PrjFSVirtualizationRootXAttrData rootXattrData = {}; if (!InitializeEmptyPlaceholder( virtualizationRootFullPath, &rootXattrData, PrjFSVirtualizationRootXAttrName)) { return PrjFS_Result_EIOError; } return RecursivelyMarkAllChildrenAsInRoot(virtualizationRootFullPath); } PrjFS_Result PrjFS_WritePlaceholderDirectory( _In_ const char* relativePath) { #ifdef DEBUG cout << "PrjFS_WritePlaceholderDirectory(" << relativePath << ")" << endl; #endif if (nullptr == relativePath) { return PrjFS_Result_EInvalidArgs; } PrjFS_Result result = PrjFS_Result_Invalid; char fullPath[PrjFSMaxPath]; CombinePaths(s_virtualizationRootFullPath.c_str(), relativePath, fullPath); if (mkdir(fullPath, 0777)) { switch(errno) { // TODO(Mac): Return more specific error codes for other failure scenarios case ENOENT: // A component of the path prefix does not exist or path is an empty string result = PrjFS_Result_EPathNotFound; break; default: result = PrjFS_Result_EIOError; break; } goto CleanupAndFail; } if (!InitializeEmptyPlaceholder(fullPath)) { result = PrjFS_Result_EIOError; goto CleanupAndFail; } return PrjFS_Result_Success; CleanupAndFail: // TODO(Mac): cleanup the directory on disk if needed return result; } PrjFS_Result PrjFS_WritePlaceholderFile( _In_ const char* relativePath, _In_ unsigned char providerId[PrjFS_PlaceholderIdLength], _In_ unsigned char contentId[PrjFS_PlaceholderIdLength], _In_ unsigned long fileSize, _In_ uint16_t fileMode) { #ifdef DEBUG cout << "PrjFS_WritePlaceholderFile(" << relativePath << ", " << (int)providerId[0] << ", " << (int)contentId[0] << ", " << fileSize << ", " << oct << fileMode << dec << ")" << endl; #endif if (nullptr == relativePath) { return PrjFS_Result_EInvalidArgs; } PrjFS_Result result = PrjFS_Result_Invalid; PrjFSFileXAttrData fileXattrData = {}; char fullPath[PrjFSMaxPath]; CombinePaths(s_virtualizationRootFullPath.c_str(), relativePath, fullPath); // Mode "wx" means: // - "w": Open for writing. The stream is positioned at the beginning of the file. Create the file if it does not exist. // - "x": If the file already exists, fopen() fails, and sets errno to EEXIST. FILE* file = fopen(fullPath, "wx"); if (nullptr == file) { switch(errno) { // TODO(Mac): Return more specific error codes for other failure scenarios case ENOENT: // A directory component in fullPath does not exist or is a dangling symbolic link. result = PrjFS_Result_EPathNotFound; break; case EEXIST: // The file already exists default: result = PrjFS_Result_EIOError; break; } goto CleanupAndFail; } // Expand the file to the desired size if (ftruncate(fileno(file), fileSize)) { result = PrjFS_Result_EIOError; goto CleanupAndFail; } fclose(file); file = nullptr; memcpy(fileXattrData.providerId, providerId, PrjFS_PlaceholderIdLength); memcpy(fileXattrData.contentId, contentId, PrjFS_PlaceholderIdLength); if (!InitializeEmptyPlaceholder( fullPath, &fileXattrData, PrjFSFileXAttrName)) { result = PrjFS_Result_EIOError; goto CleanupAndFail; } // TODO(Mac): Only call chmod if fileMode is different than the default file mode if (chmod(fullPath, fileMode)) { result = PrjFS_Result_EIOError; goto CleanupAndFail; } return PrjFS_Result_Success; CleanupAndFail: if (nullptr != file) { // TODO(Mac) #234: we now have a partially created placeholder file. Should we delete it? // A better pattern would likely be to create the file in a tmp location, fully initialize its state, then move it into the requested path fclose(file); file = nullptr; } return result; } PrjFS_Result PrjFS_WriteSymLink( _In_ const char* relativePath, _In_ const char* symLinkTarget) { #ifdef DEBUG cout << "PrjFS_WriteSymLink(" << relativePath << ", " << symLinkTarget << ")" << endl; #endif if (nullptr == relativePath || nullptr == symLinkTarget) { return PrjFS_Result_EInvalidArgs; } char fullPath[PrjFSMaxPath]; CombinePaths(s_virtualizationRootFullPath.c_str(), relativePath, fullPath); if(symlink(symLinkTarget, fullPath)) { goto CleanupAndFail; } // TODO(Mac) #391: Handles failures of SetBitInFileFlags SetBitInFileFlags(fullPath, FileFlags_IsInVirtualizationRoot, true); return PrjFS_Result_Success; CleanupAndFail: return PrjFS_Result_EIOError; } PrjFS_Result PrjFS_UpdatePlaceholderFileIfNeeded( _In_ const char* relativePath, _In_ unsigned char providerId[PrjFS_PlaceholderIdLength], _In_ unsigned char contentId[PrjFS_PlaceholderIdLength], _In_ unsigned long fileSize, _In_ uint16_t fileMode, _In_ PrjFS_UpdateType updateFlags, _Out_ PrjFS_UpdateFailureCause* failureCause) { #ifdef DEBUG cout << "PrjFS_UpdatePlaceholderFileIfNeeded(" << relativePath << ", " << (int)providerId[0] << ", " << (int)contentId[0] << ", " << fileSize << ", " << oct << fileMode << dec << ", " << hex << updateFlags << dec << ")" << endl; #endif // TODO(Mac): Check if the contentId or fileMode have changed before proceeding // with the update PrjFS_Result result = PrjFS_DeleteFile(relativePath, updateFlags, failureCause); if (result != PrjFS_Result_Success) { return result; } // TODO(Mac): Ensure that races with hydration are handled properly return PrjFS_WritePlaceholderFile(relativePath, providerId, contentId, fileSize, fileMode); } PrjFS_Result PrjFS_ReplacePlaceholderFileWithSymLink( _In_ const char* relativePath, _In_ const char* symLinkTarget, _In_ PrjFS_UpdateType updateFlags, _Out_ PrjFS_UpdateFailureCause* failureCause) { #ifdef DEBUG cout << "PrjFS_ReplacePlaceholderFileWithSymLink(" << relativePath << ", " << symLinkTarget << ", " << hex << updateFlags << dec << ")" << endl; #endif PrjFS_Result result = PrjFS_DeleteFile(relativePath, updateFlags, failureCause); if (result != PrjFS_Result_Success) { return result; } return PrjFS_WriteSymLink(relativePath, symLinkTarget); } PrjFS_Result PrjFS_DeleteFile( _In_ const char* relativePath, _In_ PrjFS_UpdateType updateFlags, _Out_ PrjFS_UpdateFailureCause* failureCause) { #ifdef DEBUG cout << "PrjFS_DeleteFile(" << relativePath << ", " << hex << updateFlags << dec << ")" << endl; #endif *failureCause = PrjFS_UpdateFailureCause_Invalid; if (nullptr == relativePath) { return PrjFS_Result_EInvalidArgs; } // TODO(Mac): Ensure that races with hydration are handled properly char fullPath[PrjFSMaxPath]; CombinePaths(s_virtualizationRootFullPath.c_str(), relativePath, fullPath); struct stat path_stat; if (0 != stat(fullPath, &path_stat)) { switch(errno) { case ENOENT: // A component of fullPath does not exist case ENOTDIR: // A component of fullPath is not a directory return PrjFS_Result_Success; default: return PrjFS_Result_EIOError; } } if (!(S_ISREG(path_stat.st_mode) || S_ISDIR(path_stat.st_mode))) { // Only files and directories can be deleted with PrjFS_DeleteFile // Anything else should be treated as a full file *failureCause = PrjFS_UpdateFailureCause_FullFile; return PrjFS_Result_EVirtualizationInvalidOperation; } if (S_ISREG(path_stat.st_mode)) { // TODO(Mac): Determine if we need a similar check for directories as well PrjFSFileXAttrData xattrData = {}; if (!TryGetXAttr(fullPath, PrjFSFileXAttrName, sizeof(PrjFSFileXAttrData), &xattrData)) { *failureCause = PrjFS_UpdateFailureCause_FullFile; return PrjFS_Result_EVirtualizationInvalidOperation; } } if (0 != remove(fullPath)) { switch(errno) { case ENOENT: // A component of fullPath does not exist case ENOTDIR: // A component of fullPath is not a directory return PrjFS_Result_Success; case ENOTEMPTY: return PrjFS_Result_EDirectoryNotEmpty; default: return PrjFS_Result_EIOError; } } return PrjFS_Result_Success; } PrjFS_Result PrjFS_WriteFileContents( _In_ const PrjFS_FileHandle* fileHandle, _In_ const void* bytes, _In_ unsigned int byteCount) { #ifdef DEBUG cout << "PrjFS_WriteFile(" << fileHandle->file << ", " << (int)((char*)bytes)[0] << ", " << (int)((char*)bytes)[1] << ", " << (int)((char*)bytes)[2] << ", " << byteCount << ")" << endl; #endif if (nullptr == fileHandle->file || nullptr == bytes) { return PrjFS_Result_EInvalidArgs; } if (byteCount != fwrite(bytes, 1, byteCount, fileHandle->file)) { return PrjFS_Result_EIOError; } return PrjFS_Result_Success; } // Private functions static Message ParseMessageMemory(const void* messageMemory, uint32_t size) { const MessageHeader* header = static_cast<const MessageHeader*>(messageMemory); if (header->pathSizeBytes + sizeof(*header) != size) { fprintf(stderr, "ParseMessageMemory: invariant failed, bad message? PathSizeBytes = %u, message size = %u, expecting %zu\n", header->pathSizeBytes, size, header->pathSizeBytes + sizeof(*header)); abort(); } const char* path = nullptr; if (header->pathSizeBytes > 0) { path = static_cast<const char*>(messageMemory) + sizeof(*header); // Path string should fit exactly in reserved memory, with nul terminator in end position assert(strnlen(path, header->pathSizeBytes) == header->pathSizeBytes - 1); } return Message { header, path }; } static void HandleKernelRequest(void* messageMemory, uint32_t messageSize) { PrjFS_Result result = PrjFS_Result_EIOError; Message request = ParseMessageMemory(messageMemory, messageSize); const MessageHeader* requestHeader = request.messageHeader; const char* absolutePath = nullptr; const char* relativePath = nullptr; // We expect a non-null request.path for messages sent from the FILEOP handler, // whereas messages originating in the kext's vnode handler will only fill // the fsid/inode, so we need to look up the path below. char pathBuffer[PrjFSMaxPath]; if (request.path == nullptr) { fsid_t fsid = request.messageHeader->fsidInode.fsid; ssize_t pathSize = fsgetpath(pathBuffer, sizeof(pathBuffer), &fsid, request.messageHeader->fsidInode.inode); if (pathSize < 0) { // TODO(Mac): Add this message to PrjFSLib logging once available (#395) ostringstream ss; ss << "MessageType: " << requestHeader->messageType << " " << "PrjFSLib.HandleKernelRequest: fsgetpath failed for fsid 0x" << hex << fsid.val[0] << ":" << hex << fsid.val[1] << ", inode " << dec << request.messageHeader->fsidInode.inode << "; error = " << errno << "(" << strerror(errno) << ")" << endl; string errorMessage = ss.str(); s_callbacks.LogError(errorMessage.c_str()); result = PrjFS_Result_Success; goto CleanupAndReturn; } else { absolutePath = pathBuffer; relativePath = GetRelativePath(pathBuffer, s_virtualizationRootFullPath.c_str()); #if DEBUG cout << "PrjFSLib.HandleKernelRequest: fsgetpath for fsid 0x" << hex << fsid.val[0] << ":" << hex << fsid.val[1] << ", inode " << dec << request.messageHeader->fsidInode.inode << " -> '" << pathBuffer << "' -> relative path '" << (request.path != nullptr ? request.path : "[NULL]") << "'" << endl; #endif } } else { absolutePath = request.path; relativePath = GetRelativePath(absolutePath, s_virtualizationRootFullPath.c_str()); } switch (requestHeader->messageType) { case MessageType_KtoU_EnumerateDirectory: { result = HandleEnumerateDirectoryRequest(requestHeader, absolutePath, relativePath); break; } case MessageType_KtoU_RecursivelyEnumerateDirectory: { result = HandleRecursivelyEnumerateDirectoryRequest(requestHeader, absolutePath, relativePath); break; } case MessageType_KtoU_HydrateFile: { result = HandleHydrateFileRequest(requestHeader, absolutePath, relativePath); break; } case MessageType_KtoU_NotifyFileModified: case MessageType_KtoU_NotifyFilePreDelete: case MessageType_KtoU_NotifyDirectoryPreDelete: case MessageType_KtoU_NotifyFilePreConvertToFull: { result = HandleFileNotification( requestHeader, relativePath, absolutePath, requestHeader->messageType == MessageType_KtoU_NotifyDirectoryPreDelete, // isDirectory KUMessageTypeToNotificationType(static_cast<MessageType>(requestHeader->messageType))); break; } case MessageType_KtoU_NotifyFileCreated: case MessageType_KtoU_NotifyFileRenamed: case MessageType_KtoU_NotifyDirectoryRenamed: case MessageType_KtoU_NotifyFileHardLinkCreated: { bool isDirectory = requestHeader->messageType == MessageType_KtoU_NotifyDirectoryRenamed; result = HandleNewFileInRootNotification( requestHeader, relativePath, absolutePath, isDirectory, KUMessageTypeToNotificationType(static_cast<MessageType>(requestHeader->messageType))); break; } } // async callbacks are not yet implemented assert(PrjFS_Result_Pending != result); CleanupAndReturn: if (PrjFS_Result_Pending != result) { MessageType responseType = PrjFS_Result_Success == result ? MessageType_Response_Success : MessageType_Response_Fail; SendKernelMessageResponse(requestHeader->messageId, responseType); } free(messageMemory); } static PrjFS_Result HandleEnumerateDirectoryRequest(const MessageHeader* request, const char* absolutePath, const char* relativePath) { #ifdef DEBUG cout << "PrjFSLib.HandleEnumerateDirectoryRequest: " << absolutePath << " (root-relative: " << relativePath << ")" << " Process name: " << request->procname << " Pid: " << request->pid << endl; #endif if (!IsBitSetInFileFlags(absolutePath, FileFlags_IsEmpty)) { return PrjFS_Result_Success; } PrjFS_Result result; FileMutexMap::iterator mutexIterator = CheckoutFileMutexIterator(request->fsidInode); { mutex_lock lock(*(mutexIterator->second.mutex)); if (!IsBitSetInFileFlags(absolutePath, FileFlags_IsEmpty)) { result = PrjFS_Result_Success; goto CleanupAndReturn; } result = s_callbacks.EnumerateDirectory( 0 /* commandId */, relativePath, request->pid, request->procname); if (PrjFS_Result_Success == result) { if (!SetBitInFileFlags(absolutePath, FileFlags_IsEmpty, false)) { // TODO(Mac): how should we handle this scenario where the provider thinks it succeeded, but we were unable to // update placeholder metadata? result = PrjFS_Result_EIOError; } } } CleanupAndReturn: ReturnFileMutexIterator(mutexIterator); return result; } static PrjFS_Result HandleRecursivelyEnumerateDirectoryRequest(const MessageHeader* request, const char* absolutePath, const char* relativePath) { #ifdef DEBUG cout << "PrjFSLib.HandleRecursivelyEnumerateDirectoryRequest: " << absolutePath << " (root-relative: " << relativePath << ")" << " Process name: " << request->procname << " Pid: " << request->pid << endl; #endif DIR* directory = nullptr; PrjFS_Result result = PrjFS_Result_Success; queue<string> directoryRelativePaths; directoryRelativePaths.push(relativePath); // Walk each directory, expanding those that are found to be empty char path[PrjFSMaxPath]; while (!directoryRelativePaths.empty()) { string directoryRelativePath(directoryRelativePaths.front()); directoryRelativePaths.pop(); CombinePaths(s_virtualizationRootFullPath.c_str(), directoryRelativePath.c_str(), path); PrjFS_Result result = HandleEnumerateDirectoryRequest(request, path, directoryRelativePath.c_str()); if (result != PrjFS_Result_Success) { goto CleanupAndReturn; } DIR* directory = opendir(path); if (nullptr == directory) { result = PrjFS_Result_EIOError; goto CleanupAndReturn; } dirent* dirEntry = readdir(directory); while (dirEntry != nullptr) { if (IsDirEntChildDirectory(dirEntry)) { CombinePaths(directoryRelativePath.c_str(), dirEntry->d_name, path); directoryRelativePaths.emplace(path); } dirEntry = readdir(directory); } closedir(directory); } CleanupAndReturn: if (directory != nullptr) { closedir(directory); } return result; } static PrjFS_Result HandleHydrateFileRequest(const MessageHeader* request, const char* absolutePath, const char* relativePath) { #ifdef DEBUG cout << "PrjFSLib.HandleHydrateFileRequest: " << absolutePath << " (root-relative: " << relativePath << ")" << " Process name: " << request->procname << " Pid: " << request->pid << endl; #endif PrjFSFileXAttrData xattrData = {}; if (!TryGetXAttr(absolutePath, PrjFSFileXAttrName, sizeof(PrjFSFileXAttrData), &xattrData)) { return PrjFS_Result_EIOError; } if (!IsBitSetInFileFlags(absolutePath, FileFlags_IsEmpty)) { return PrjFS_Result_Success; } PrjFS_Result result; PrjFS_FileHandle fileHandle; FileMutexMap::iterator mutexIterator = CheckoutFileMutexIterator(request->fsidInode); { mutex_lock lock(*(mutexIterator->second.mutex)); if (!IsBitSetInFileFlags(absolutePath, FileFlags_IsEmpty)) { result = PrjFS_Result_Success; goto CleanupAndReturn; } // Mode "rb+" means: // - The file must already exist // - The handle is opened for reading and writing // - We are allowed to seek to somewhere other than end of stream for writing fileHandle.file = fopen(absolutePath, "rb+"); if (nullptr == fileHandle.file) { result = PrjFS_Result_EIOError; goto CleanupAndReturn; } // Seek back to the beginning so the provider can overwrite the empty contents if (fseek(fileHandle.file, 0, 0)) { fclose(fileHandle.file); result = PrjFS_Result_EIOError; goto CleanupAndReturn; } result = s_callbacks.GetFileStream( 0 /* comandId */, relativePath, xattrData.providerId, xattrData.contentId, request->pid, request->procname, &fileHandle); // TODO(Mac): once we support async callbacks, we'll need to save off the fileHandle if the result is Pending fflush(fileHandle.file); // Don't block on closing the file to avoid deadlock with some Antivirus software dispatch_async(s_kernelRequestHandlingConcurrentQueue, ^{ if (fclose(fileHandle.file)) { // TODO(Mac): under what conditions can fclose fail? How do we recover? } }); if (PrjFS_Result_Success == result) { // TODO(Mac): validate that the total bytes written match the size that was reported on the placeholder in the first place // Potential bugs if we don't: // * The provider writes fewer bytes than expected. The hydrated is left with extra padding up to the original reported size. // * The provider writes more bytes than expected. The write succeeds, but whatever tool originally opened the file may have already // allocated the originally reported size, and now the contents appear truncated. if (!SetBitInFileFlags(absolutePath, FileFlags_IsEmpty, false)) { // TODO(Mac): how should we handle this scenario where the provider thinks it succeeded, but we were unable to // update placeholder metadata? result = PrjFS_Result_EIOError; } } } CleanupAndReturn: ReturnFileMutexIterator(mutexIterator); return result; } static PrjFS_Result HandleNewFileInRootNotification( const MessageHeader* request, const char* relativePath, const char* absolutePath, bool isDirectory, PrjFS_NotificationType notificationType) { #ifdef DEBUG cout << "HandleNewFileInRootNotification: " << absolutePath << " (root-relative: " << relativePath << ")" << " Process name: " << request->procname << " Pid: " << request->pid << " notificationType: " << NotificationTypeToString(notificationType) << " isDirectory: " << isDirectory << endl; #endif // Whenever a new file shows up in the root, we need to check if its ancestor // directories are flagged as in root. If they are not, flag them as in root and // notify the provider FindNewFoldersInRootAndNotifyProvider(request, relativePath); PrjFS_Result result = HandleFileNotification( request, relativePath, absolutePath, isDirectory, notificationType); // TODO(Mac) #391: Handle SetBitInFileFlags failures SetBitInFileFlags(absolutePath, FileFlags_IsInVirtualizationRoot, true); return result; } static PrjFS_Result HandleFileNotification( const MessageHeader* request, const char* relativePath, const char* absolutePath, bool isDirectory, PrjFS_NotificationType notificationType) { #ifdef DEBUG cout << "PrjFSLib.HandleFileNotification: " << absolutePath << " (root-relative: " << relativePath << ")" << " Process name: " << request->procname << " Pid: " << request->pid << " notificationType: " << NotificationTypeToString(notificationType) << " isDirectory: " << isDirectory << endl; #endif PrjFSFileXAttrData xattrData = {}; bool placeholderFile = TryGetXAttr(absolutePath, PrjFSFileXAttrName, sizeof(PrjFSFileXAttrData), &xattrData); PrjFS_Result result = s_callbacks.NotifyOperation( 0 /* commandId */, relativePath, xattrData.providerId, xattrData.contentId, request->pid, request->procname, isDirectory, notificationType, nullptr /* destinationRelativePath */); if (result == 0 && placeholderFile && PrjFS_NotificationType_PreConvertToFull == notificationType) { errno_t result = RemoveXAttrWithoutFollowingLinks(absolutePath, PrjFSFileXAttrName); if (0 != result) { // TODO(Mac) #395: Log error // Note that it's expected that RemoveXAttrWithoutFollowingLinks return ENOATTR if // another thread has removed the attribute } } return result; } static void FindNewFoldersInRootAndNotifyProvider(const MessageHeader* request, const char* relativePath) { // Walk up the directory tree and notify the provider about any directories // not flagged as being in the root stack<pair<string /*relative path*/, string /*full path*/>> newFolderPaths; string parentPath(relativePath); size_t lastDirSeparator = parentPath.find_last_of('/'); while (lastDirSeparator != string::npos && lastDirSeparator > 0) { parentPath = parentPath.substr(0, lastDirSeparator); char parentFullPath[PrjFSMaxPath]; CombinePaths(s_virtualizationRootFullPath.c_str(), parentPath.c_str(), parentFullPath); if (IsBitSetInFileFlags(parentFullPath, FileFlags_IsInVirtualizationRoot)) { break; } else { newFolderPaths.emplace(make_pair(parentPath, parentFullPath)); lastDirSeparator = parentPath.find_last_of('/'); } } while (!newFolderPaths.empty()) { const pair<string /*relative path*/, string /*full path*/>& parentFolderPath = newFolderPaths.top(); HandleFileNotification( request, parentFolderPath.first.c_str(), parentFolderPath.second.c_str(), true, // isDirectory PrjFS_NotificationType_NewFileCreated); // TODO(Mac) #391: Handle SetBitInFileFlags failures SetBitInFileFlags(parentFolderPath.second.c_str(), FileFlags_IsInVirtualizationRoot, true); newFolderPaths.pop(); } } static bool IsDirEntChildDirectory(const dirent* directoryEntry) { return directoryEntry->d_type == DT_DIR && 0 != strncmp(".", directoryEntry->d_name, sizeof(directoryEntry->d_name)) && 0 != strncmp("..", directoryEntry->d_name, sizeof(directoryEntry->d_name)); } static bool InitializeEmptyPlaceholder(const char* fullPath) { return SetBitInFileFlags(fullPath, FileFlags_IsInVirtualizationRoot, true) && SetBitInFileFlags(fullPath, FileFlags_IsEmpty, true); } template<typename TPlaceholder> static bool InitializeEmptyPlaceholder(const char* fullPath, TPlaceholder* data, const char* xattrName) { if (InitializeEmptyPlaceholder(fullPath)) { data->header.magicNumber = PlaceholderMagicNumber; data->header.formatVersion = PlaceholderFormatVersion; static_assert(is_pod<TPlaceholder>(), "TPlaceholder must be a POD struct"); errno_t result = AddXAttr(fullPath, xattrName, data, sizeof(TPlaceholder)); if (0 == result) { return true; } else { // TODO(Mac) #395: Log result } } return false; } static bool IsVirtualizationRoot(const char* fullPath) { PrjFSVirtualizationRootXAttrData data = {}; if (TryGetXAttr(fullPath, PrjFSVirtualizationRootXAttrName, sizeof(PrjFSVirtualizationRootXAttrData), &data)) { return true; } return false; } static void CombinePaths(const char* root, const char* relative, char (&combined)[PrjFSMaxPath]) { snprintf(combined, PrjFSMaxPath, "%s/%s", root, relative); } static bool SetBitInFileFlags(const char* fullPath, uint32_t bit, bool value) { struct stat fileAttributes; if (lstat(fullPath, &fileAttributes)) { return false; } uint32_t newValue; if (value) { newValue = fileAttributes.st_flags | bit; } else { newValue = fileAttributes.st_flags & ~bit; } if (lchflags(fullPath, newValue)) { return false; } return true; } static bool IsBitSetInFileFlags(const char* fullPath, uint32_t bit) { struct stat fileAttributes; if (lstat(fullPath, &fileAttributes)) { return false; } return fileAttributes.st_flags & bit; } static errno_t AddXAttr(const char* fullPath, const char* name, const void* value, size_t size) { if (0 != setxattr(fullPath, name, value, size, 0, 0)) { return errno; } return 0; } static bool TryGetXAttr(const char* fullPath, const char* name, size_t expectedSize, _Out_ void* value) { if (expectedSize != getxattr(fullPath, name, value, expectedSize, 0, 0)) { return false; } // TODO(Mac): also validate the magic number and format version. // It's easy to check their expected values, but we will need to decide what to do if they are incorrect. return true; } static errno_t RemoveXAttrWithoutFollowingLinks(const char* fullPath, const char* name) { if (0 != removexattr(fullPath, name, XATTR_NOFOLLOW)) { return errno; } return 0; } static inline PrjFS_NotificationType KUMessageTypeToNotificationType(MessageType kuNotificationType) { switch(kuNotificationType) { case MessageType_KtoU_NotifyFileModified: return PrjFS_NotificationType_FileModified; case MessageType_KtoU_NotifyFilePreDelete: case MessageType_KtoU_NotifyDirectoryPreDelete: return PrjFS_NotificationType_PreDelete; case MessageType_KtoU_NotifyFilePreConvertToFull: return PrjFS_NotificationType_PreConvertToFull; case MessageType_KtoU_NotifyFileCreated: return PrjFS_NotificationType_NewFileCreated; case MessageType_KtoU_NotifyFileRenamed: case MessageType_KtoU_NotifyDirectoryRenamed: return PrjFS_NotificationType_FileRenamed; case MessageType_KtoU_NotifyFileHardLinkCreated: return PrjFS_NotificationType_HardLinkCreated; // Non-notification types case MessageType_Invalid: case MessageType_KtoU_EnumerateDirectory: case MessageType_KtoU_RecursivelyEnumerateDirectory: case MessageType_KtoU_HydrateFile: case MessageType_Response_Success: case MessageType_Response_Fail: case MessageType_Result_Aborted: return PrjFS_NotificationType_Invalid; } } static errno_t SendKernelMessageResponse(uint64_t messageId, MessageType responseType) { const uint64_t inputs[] = { messageId, responseType }; IOReturn callResult = IOConnectCallScalarMethod( s_kernelServiceConnection, ProviderSelector_KernelMessageResponse, inputs, extent<decltype(inputs)>::value, // scalar inputs nullptr, nullptr); // no outputs return callResult == kIOReturnSuccess ? 0 : EBADMSG; } static errno_t RegisterVirtualizationRootPath(const char* fullPath) { uint64_t error = EBADMSG; uint32_t output_count = 1; size_t pathSize = strlen(fullPath) + 1; IOReturn callResult = IOConnectCallMethod( s_kernelServiceConnection, ProviderSelector_RegisterVirtualizationRootPath, nullptr, 0, // no scalar inputs fullPath, pathSize, // struct input &error, &output_count, // scalar output nullptr, nullptr); // no struct output assert(callResult == kIOReturnSuccess); return static_cast<errno_t>(error); } static PrjFS_Result RecursivelyMarkAllChildrenAsInRoot(const char* fullDirectoryPath) { DIR* directory = nullptr; PrjFS_Result result = PrjFS_Result_Success; queue<string> directoryRelativePaths; directoryRelativePaths.push(""); char fullPath[PrjFSMaxPath]; char relativePath[PrjFSMaxPath]; while (!directoryRelativePaths.empty()) { string directoryRelativePath(directoryRelativePaths.front()); directoryRelativePaths.pop(); CombinePaths(fullDirectoryPath, directoryRelativePath.c_str(), fullPath); DIR* directory = opendir(fullPath); if (nullptr == directory) { result = PrjFS_Result_EIOError; goto CleanupAndReturn; } dirent* dirEntry = readdir(directory); while (dirEntry != nullptr) { bool entryIsDirectoryToUpdate = IsDirEntChildDirectory(dirEntry); if (entryIsDirectoryToUpdate || dirEntry->d_type == DT_LNK || dirEntry->d_type == DT_REG) { CombinePaths(directoryRelativePath.c_str(), dirEntry->d_name, relativePath); CombinePaths(fullDirectoryPath, relativePath, fullPath); if (!SetBitInFileFlags(fullPath, FileFlags_IsInVirtualizationRoot, true)) { result = PrjFS_Result_EIOError; goto CleanupAndReturn; } if (entryIsDirectoryToUpdate) { directoryRelativePaths.emplace(relativePath); } } dirEntry = readdir(directory); } closedir(directory); } CleanupAndReturn: if (directory != nullptr) { closedir(directory); } return result; } #ifdef DEBUG static const char* NotificationTypeToString(PrjFS_NotificationType notificationType) { switch(notificationType) { case PrjFS_NotificationType_Invalid: return STRINGIFY(PrjFS_NotificationType_Invalid); case PrjFS_NotificationType_None: return STRINGIFY(PrjFS_NotificationType_None); case PrjFS_NotificationType_NewFileCreated: return STRINGIFY(PrjFS_NotificationType_NewFileCreated); case PrjFS_NotificationType_PreDelete: return STRINGIFY(PrjFS_NotificationType_PreDelete); case PrjFS_NotificationType_FileRenamed: return STRINGIFY(PrjFS_NotificationType_FileRenamed); case PrjFS_NotificationType_HardLinkCreated: return STRINGIFY(PrjFS_NotificationType_HardLinkCreated); case PrjFS_NotificationType_PreConvertToFull: return STRINGIFY(PrjFS_NotificationType_PreConvertToFull); case PrjFS_NotificationType_PreModify: return STRINGIFY(PrjFS_NotificationType_PreModify); case PrjFS_NotificationType_FileModified: return STRINGIFY(PrjFS_NotificationType_FileModified); case PrjFS_NotificationType_FileDeleted: return STRINGIFY(PrjFS_NotificationType_FileDeleted); } } #endif static FileMutexMap::iterator CheckoutFileMutexIterator(const FsidInode& fsidInode) { mutex_lock lock(s_fileLocksMutex); FileMutexMap::iterator iter = s_fileLocks.find(fsidInode); if (iter == s_fileLocks.end()) { pair<FileMutexMap::iterator, bool> newEntry = s_fileLocks.insert( FileMutexMap::value_type(fsidInode, { make_shared<mutex>(), 1 })); assert(newEntry.second); return newEntry.first; } else { iter->second.useCount++; return iter; } } static void ReturnFileMutexIterator(FileMutexMap::iterator lockIterator) { mutex_lock lock(s_fileLocksMutex); lockIterator->second.useCount--; if (lockIterator->second.useCount == 0) { s_fileLocks.erase(lockIterator); } } static const char* GetRelativePath(const char* fullPath, const char* root) { size_t rootLength = strlen(root); size_t pathLength = strlen(fullPath); if (pathLength < rootLength || 0 != memcmp(fullPath, root, rootLength)) { // TODO(Mac): Add this message to PrjFSLib logging once available (#395) fprintf(stderr, "GetRelativePath: root path '%s' is not a prefix of path '%s'\n", root, fullPath); return nullptr; } const char* relativePath = fullPath + rootLength; if (relativePath[0] == '/') { relativePath++; } else if (rootLength > 0 && root[rootLength - 1] != '/' && pathLength > rootLength) { // TODO(Mac): Add this message to PrjFSLib logging once available (#395) fprintf(stderr, "GetRelativePath: root path '%s' is not a parent directory of path '%s' (just a string prefix)\n", root, fullPath); return nullptr; } return relativePath; }
#include <stdio.h> #include <Fw/Cfg/FwConfig.hpp> // The following header will need to be modified when test code is moved // If the component tester is regenerated, this will need to be modified again. // Make the compile fail to make sure it is changed #include <Svc/TlmChan/test/ut/TelemStoreComponentTestAc.hpp> #include <Fw/Types/FwAssert.hpp> namespace Svc { // public methods Fw::InputComPort *TelemStoreComponentTesterBase::get_pktSend_InputPort(NATIVE_INT_TYPE portNum) { FW_ASSERT(portNum < this->getNum_pktSend_InputPorts()); return &this->m_pktSend_InputPort[portNum]; } void TelemStoreComponentTesterBase::set_tlmRecv_OutputPort(NATIVE_INT_TYPE portNum, Fw::InputTlmPort* port) { FW_ASSERT(portNum < this->getNum_tlmRecv_OutputPorts()); this->m_tlmRecv_OutputPort[portNum].addCallPort(port); } void TelemStoreComponentTesterBase::set_tlmGet_OutputPort(NATIVE_INT_TYPE portNum, Fw::InputTlmPort* port) { FW_ASSERT(portNum < this->getNum_tlmGet_OutputPorts()); this->m_tlmGet_OutputPort[portNum].addCallPort(port); } void TelemStoreComponentTesterBase::set_run_OutputPort(NATIVE_INT_TYPE portNum, Svc::InputSchedPort* port) { FW_ASSERT(portNum < this->getNum_run_OutputPorts()); this->m_run_OutputPort[portNum].addCallPort(port); } // protected methods TelemStoreComponentTesterBase::TelemStoreComponentTesterBase(const char* compName) : Fw::PassiveComponentBase(compName) { } TelemStoreComponentTesterBase::~TelemStoreComponentTesterBase(void) { } void TelemStoreComponentTesterBase::init(NATIVE_INT_TYPE instance) { // initialize base class Fw::PassiveComponentBase::init(instance); // Input ports attached to component here with external component interfaces for (NATIVE_INT_TYPE port = 0; port < this->getNum_pktSend_InputPorts(); port++) { this->m_pktSend_InputPort[port].init(); this->m_pktSend_InputPort[port].addCallComp(this, m_p_pktSend_in); this->m_pktSend_InputPort[port].setPortNum(port); #if FW_OBJECT_NAMES == 1 char portName[80]; snprintf(portName, sizeof(portName), "%s_pktSend_InputPort[%d]", this->m_objName, port); this->m_pktSend_InputPort[port].setObjName(portName); #endif } // Set output ports for (NATIVE_INT_TYPE port = 0; port < this->getNum_tlmRecv_OutputPorts(); port++) { this->m_tlmRecv_OutputPort[port].init(); #if FW_OBJECT_NAMES == 1 char portName[80]; snprintf(portName, sizeof(portName), "%s_tlmRecv_OutputPort[%d]", this->m_objName, port); this->m_tlmRecv_OutputPort[port].setObjName(portName); #endif } for (NATIVE_INT_TYPE port = 0; port < this->getNum_tlmGet_OutputPorts(); port++) { this->m_tlmGet_OutputPort[port].init(); #if FW_OBJECT_NAMES == 1 char portName[80]; snprintf(portName, sizeof(portName), "%s_tlmGet_OutputPort[%d]", this->m_objName, port); this->m_tlmGet_OutputPort[port].setObjName(portName); #endif } for (NATIVE_INT_TYPE port = 0; port < this->getNum_run_OutputPorts(); port++) { this->m_run_OutputPort[port].init(); #if FW_OBJECT_NAMES == 1 char portName[80]; snprintf(portName, sizeof(portName), "%s_run_OutputPort[%d]", this->m_objName, port); this->m_run_OutputPort[port].setObjName(portName); #endif } } // Up-calls, calls for output ports void TelemStoreComponentTesterBase::tlmRecv_out(NATIVE_INT_TYPE portNum, U32 id, Fw::Time &timeTag, Fw::TlmBuffer &val) { FW_ASSERT(portNum < this->getNum_tlmRecv_OutputPorts()); m_tlmRecv_OutputPort[portNum].invoke(id, timeTag, val); } void TelemStoreComponentTesterBase::tlmGet_out(NATIVE_INT_TYPE portNum, U32 id, Fw::Time &timeTag, Fw::TlmBuffer &val) { FW_ASSERT(portNum < this->getNum_tlmGet_OutputPorts()); m_tlmGet_OutputPort[portNum].invoke(id, timeTag, val); } void TelemStoreComponentTesterBase::run_out(NATIVE_INT_TYPE portNum, I32 order) { FW_ASSERT(portNum < this->getNum_run_OutputPorts()); m_run_OutputPort[portNum].invoke(order); } NATIVE_INT_TYPE TelemStoreComponentTesterBase::getNum_tlmRecv_OutputPorts(void) { return (NATIVE_INT_TYPE) FW_NUM_ARRAY_ELEMENTS(this->m_tlmRecv_OutputPort); } NATIVE_INT_TYPE TelemStoreComponentTesterBase::getNum_tlmGet_OutputPorts(void) { return (NATIVE_INT_TYPE) FW_NUM_ARRAY_ELEMENTS(this->m_tlmGet_OutputPort); } NATIVE_INT_TYPE TelemStoreComponentTesterBase::getNum_run_OutputPorts(void) { return (NATIVE_INT_TYPE) FW_NUM_ARRAY_ELEMENTS(this->m_run_OutputPort); } NATIVE_INT_TYPE TelemStoreComponentTesterBase::getNum_pktSend_InputPorts(void) { return (NATIVE_INT_TYPE) FW_NUM_ARRAY_ELEMENTS(this->m_pktSend_InputPort); } bool TelemStoreComponentTesterBase::isConnected_tlmRecv_OutputPort(NATIVE_INT_TYPE portNum) { FW_ASSERT(portNum < this->getNum_tlmRecv_OutputPorts(),portNum); return this->m_tlmRecv_OutputPort[portNum].isConnected(); } bool TelemStoreComponentTesterBase::isConnected_tlmGet_OutputPort(NATIVE_INT_TYPE portNum) { FW_ASSERT(portNum < this->getNum_tlmGet_OutputPorts(),portNum); return this->m_tlmGet_OutputPort[portNum].isConnected(); } bool TelemStoreComponentTesterBase::isConnected_run_OutputPort(NATIVE_INT_TYPE portNum) { FW_ASSERT(portNum < this->getNum_run_OutputPorts(),portNum); return this->m_run_OutputPort[portNum].isConnected(); } // private methods // call for incoming port pktSend void TelemStoreComponentTesterBase::m_p_pktSend_in(Fw::PassiveComponentBase* callComp, NATIVE_INT_TYPE portNum, Fw::ComBuffer &data) { FW_ASSERT(callComp); TelemStoreComponentTesterBase* compPtr = (TelemStoreComponentTesterBase*)callComp; compPtr->pktSend_handlerBase(portNum, data); } void TelemStoreComponentTesterBase::pktSend_handlerBase(NATIVE_INT_TYPE portNum, Fw::ComBuffer &data) { // make sure port number is valid FW_ASSERT(portNum < this->getNum_pktSend_InputPorts()); // Down call to pure virtual handler method implemented in Impl class this->pktSend_handler(portNum, data); } }
#ifndef BIGINTEGERALGORITHMS_H #define BIGINTEGERALGORITHMS_H #include "BigInteger.hh" /* Some mathematical algorithms for big integers. * This code is new and, as such, experimental. */ // Returns the greatest common divisor of a and b. BigUnsigned gcd(BigUnsigned a, BigUnsigned b); /* Extended Euclidean algorithm. * Given m and n, finds gcd g and numbers r, s such that r*m + s*n == g. */ void extendedEuclidean(BigInteger m, BigInteger n, BigInteger &g, BigInteger &r, BigInteger &s); /* Returns the multiplicative inverse of x modulo n, or throws an exception if * they have a common factor. */ BigUnsigned modinv(const BigInteger &x, const BigUnsigned &n); // Returns (base ^ exponent) % modulus. BigUnsigned modexp(const BigInteger &base, const BigUnsigned &exponent, const BigUnsigned &modulus); #endif
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See LICENSE in the project root for license information. #include <pch.h> #include <common.h> #include "ItemsRepeater.common.h" #include "FlowLayoutAlgorithm.h" #include "UniformGridLayoutState.h" #include "UniformGridLayout.h" #include "RuntimeProfiler.h" #include "VirtualizingLayoutContext.h" #pragma region IGridLayout UniformGridLayout::UniformGridLayout() { __RP_Marker_ClassById(RuntimeProfiler::ProfId_UniformGridLayout); LayoutId(L"UniformGridLayout"); } #pragma endregion #pragma region IVirtualizingLayoutOverrides void UniformGridLayout::InitializeForContextCore(winrt::VirtualizingLayoutContext const& context) { auto state = context.LayoutState(); winrt::com_ptr<UniformGridLayoutState> gridState = nullptr; if (state) { gridState = GetAsGridState(state); } if (!gridState) { if (state) { throw winrt::hresult_error(E_FAIL, L"LayoutState must derive from UniformGridLayoutState."); } // Custom deriving layouts could potentially be stateful. // If that is the case, we will just create the base state required by UniformGridLayout ourselves. gridState = winrt::make_self<UniformGridLayoutState>(); } gridState->InitializeForContext(context, this); } void UniformGridLayout::UninitializeForContextCore(winrt::VirtualizingLayoutContext const& context) { auto gridState = GetAsGridState(context.LayoutState()); gridState->UninitializeForContext(context); } winrt::Size UniformGridLayout::MeasureOverride( winrt::VirtualizingLayoutContext const& context, winrt::Size const& availableSize) { // Set the width and height on the grid state. If the user already set them then use the preset. // If not, we have to measure the first element and get back a size which we're going to be using for the rest of the items. auto gridState = GetAsGridState(context.LayoutState()); gridState->EnsureElementSize(availableSize, context, m_minItemWidth, m_minItemHeight, m_itemsStretch, Orientation(), MinRowSpacing(), MinColumnSpacing()); auto desiredSize = GetFlowAlgorithm(context).Measure( availableSize, context, true, /* isWrapping*/ MinItemSpacing(), LineSpacing(), OrientationBasedMeasures::GetScrollOrientation(), LayoutId()); // If after Measure the first item is in the realization rect, then we revoke grid state's ownership, // and only use the layout when to clear it when it's done. gridState->EnsureFirstElementOwnership(context); return { desiredSize.Width, desiredSize.Height }; } winrt::Size UniformGridLayout::ArrangeOverride( winrt::VirtualizingLayoutContext const& context, winrt::Size const& finalSize) { auto value = GetFlowAlgorithm(context).Arrange( finalSize, context, static_cast<FlowLayoutAlgorithm::LineAlignment>(m_itemsJustification), LayoutId()); return { value.Width, value.Height }; } void UniformGridLayout::OnItemsChangedCore( winrt::VirtualizingLayoutContext const& context, winrt::IInspectable const& source, winrt::NotifyCollectionChangedEventArgs const& args) { GetFlowAlgorithm(context).OnItemsSourceChanged(source, args, context); // Always invalidate layout to keep the view accurate. InvalidateLayout(); auto gridState = GetAsGridState(context.LayoutState()); gridState->ClearElementOnDataSourceChange(context, args); } #pragma endregion #pragma region IFlowLayoutAlgorithmDelegates winrt::Size UniformGridLayout::Algorithm_GetMeasureSize(int index, const winrt::Size & availableSize, const winrt::VirtualizingLayoutContext& context) { const auto gridState = GetAsGridState(context.LayoutState()); return winrt::Size{ static_cast<float>(gridState->EffectiveItemWidth()),static_cast<float>(gridState->EffectiveItemHeight()) }; } winrt::Size UniformGridLayout::Algorithm_GetProvisionalArrangeSize(int /*index*/, const winrt::Size & /*measureSize*/, winrt::Size const& /*desiredSize*/, const winrt::VirtualizingLayoutContext& context) { const auto gridState = GetAsGridState(context.LayoutState()); return winrt::Size{ static_cast<float>(gridState->EffectiveItemWidth()),static_cast<float>(gridState->EffectiveItemHeight()) }; } bool UniformGridLayout::Algorithm_ShouldBreakLine(int /*index*/, double remainingSpace) { return remainingSpace < 0; } winrt::FlowLayoutAnchorInfo UniformGridLayout::Algorithm_GetAnchorForRealizationRect( const winrt::Size & availableSize, const winrt::VirtualizingLayoutContext & context) { winrt::Rect bounds = winrt::Rect{ NAN, NAN, NAN, NAN }; int anchorIndex = -1; int itemsCount = context.ItemCount(); auto realizationRect = context.RealizationRect(); if (itemsCount > 0 && realizationRect.*MajorSize() > 0) { const auto gridState = GetAsGridState(context.LayoutState()); const auto lastExtent = gridState->FlowAlgorithm().LastExtent(); const int itemsPerLine = std::max(1, static_cast<int>(availableSize.*Minor() / GetMinorSizeWithSpacing(context))); const double majorSize = (itemsCount / itemsPerLine) * GetMajorSizeWithSpacing(context); const double realizationWindowStartWithinExtent = realizationRect.*MajorStart() - lastExtent.*MajorStart(); if ((realizationWindowStartWithinExtent + realizationRect.*MajorSize()) >= 0 && realizationWindowStartWithinExtent <= majorSize) { const double offset = std::max(0.0f, realizationRect.*MajorStart() - lastExtent.*MajorStart()); const int anchorRowIndex = static_cast<int>(offset / GetMajorSizeWithSpacing(context)); anchorIndex = std::max(0, std::min(itemsCount - 1, anchorRowIndex * itemsPerLine)); bounds = GetLayoutRectForDataIndex(availableSize, anchorIndex, lastExtent, context); } } return winrt::FlowLayoutAnchorInfo { anchorIndex, bounds.*MajorStart() }; } winrt::FlowLayoutAnchorInfo UniformGridLayout::Algorithm_GetAnchorForTargetElement( int targetIndex, const winrt::Size & availableSize, const winrt::VirtualizingLayoutContext & context) { int index = -1; double offset = NAN; int count = context.ItemCount(); if (targetIndex >= 0 && targetIndex < count) { int itemsPerLine = std::max(1, static_cast<int>(availableSize.*Minor() / GetMinorSizeWithSpacing(context))); int indexOfFirstInLine = (targetIndex / itemsPerLine) * itemsPerLine; index = indexOfFirstInLine; auto state = GetAsGridState(context.LayoutState()); offset = GetLayoutRectForDataIndex(availableSize, indexOfFirstInLine, state->FlowAlgorithm().LastExtent(), context).*MajorStart(); } return winrt::FlowLayoutAnchorInfo { index, offset }; } winrt::Rect UniformGridLayout::Algorithm_GetExtent( const winrt::Size& availableSize, const winrt::VirtualizingLayoutContext& context, const winrt::UIElement& firstRealized, int firstRealizedItemIndex, const winrt::Rect& firstRealizedLayoutBounds, const winrt::UIElement& lastRealized, int lastRealizedItemIndex, const winrt::Rect& lastRealizedLayoutBounds) { UNREFERENCED_PARAMETER(lastRealized); auto extent = winrt::Rect{}; // Constants const int itemsCount = context.ItemCount(); const float availableSizeMinor = availableSize.*Minor(); const int itemsPerLine = std::max(1, std::isfinite(availableSizeMinor) ? static_cast<int>(availableSizeMinor / GetMinorSizeWithSpacing(context)) : itemsCount); const float lineSize = GetMajorSizeWithSpacing(context); if (itemsCount > 0) { extent.*MinorSize() = std::isfinite(availableSizeMinor) ? availableSizeMinor : std::max(0.0f, itemsCount * GetMinorSizeWithSpacing(context) - static_cast<float>(MinItemSpacing())); extent.*MajorSize() = std::max(0.0f, (itemsCount / itemsPerLine) * lineSize - static_cast<float>(LineSpacing())); if (firstRealized) { MUX_ASSERT(lastRealized); extent.*MajorStart() = firstRealizedLayoutBounds.*MajorStart() - (firstRealizedItemIndex / itemsPerLine) * lineSize; int remainingItems = itemsCount - lastRealizedItemIndex - 1; extent.*MajorSize() = MajorEnd(lastRealizedLayoutBounds) - extent.*MajorStart() + (remainingItems / itemsPerLine) * lineSize; } else { REPEATER_TRACE_INFO(L"%ls: \tEstimating extent with no realized elements. \n", LayoutId().data()); } } else { MUX_ASSERT(firstRealizedItemIndex == -1); MUX_ASSERT(lastRealizedItemIndex == -1); } REPEATER_TRACE_INFO(L"%ls: \tExtent is (%.0f,%.0f). Based on lineSize %.0f and items per line %.0f. \n", LayoutId().data(), extent.Width, extent.Height, lineSize, itemsPerLine); return extent; } #pragma endregion void UniformGridLayout::OnPropertyChanged(const winrt::DependencyPropertyChangedEventArgs& args) { auto property = args.Property(); if (property == s_OrientationProperty) { auto orientation = unbox_value<winrt::Orientation>(args.NewValue()); //Note: For UniformGridLayout Vertical Orientation means we have a Horizontal ScrollOrientation. Horizontal Orientation means we have a Vertical ScrollOrientation. //i.e. the properties are the inverse of each other. ScrollOrientation scrollOrientation = (orientation == winrt::Orientation::Horizontal) ? ScrollOrientation::Vertical : ScrollOrientation::Horizontal; OrientationBasedMeasures::SetScrollOrientation(scrollOrientation); } else if (property == s_MinColumnSpacingProperty) { m_minColumnSpacing = unbox_value<double>(args.NewValue()); } else if (property == s_MinRowSpacingProperty) { m_minRowSpacing = unbox_value<double>(args.NewValue()); } else if (property == s_ItemsJustificationProperty) { m_itemsJustification = unbox_value<winrt::UniformGridLayoutItemsJustification>(args.NewValue()); } else if (property == s_ItemsStretchProperty) { m_itemsStretch = unbox_value<winrt::UniformGridLayoutItemsStretch>(args.NewValue()); } else if (property == s_MinItemWidthProperty) { m_minItemWidth = unbox_value<double>(args.NewValue()); } else if (property == s_MinItemHeightProperty) { m_minItemHeight = unbox_value<double>(args.NewValue()); } InvalidateLayout(); } #pragma region private helpers float UniformGridLayout::GetMinorSizeWithSpacing(winrt::VirtualizingLayoutContext const& context) { auto minItemSpacing = MinItemSpacing(); auto gridState = GetAsGridState(context.LayoutState()); return GetScrollOrientation() == ScrollOrientation::Vertical ? static_cast<float>(gridState->EffectiveItemWidth() + minItemSpacing) : static_cast<float>(gridState->EffectiveItemHeight() + minItemSpacing); } float UniformGridLayout::GetMajorSizeWithSpacing(winrt::VirtualizingLayoutContext const& context) { auto lineSpacing = LineSpacing(); auto gridState = GetAsGridState(context.LayoutState()); return GetScrollOrientation() == ScrollOrientation::Vertical ? static_cast<float>(gridState->EffectiveItemHeight() + lineSpacing) : static_cast<float>(gridState->EffectiveItemWidth() + lineSpacing); } winrt::Rect UniformGridLayout::GetLayoutRectForDataIndex( const winrt::Size& availableSize, int index, const winrt::Rect& lastExtent, const winrt::VirtualizingLayoutContext& context) { int itemsPerLine = std::max(1, static_cast<int>(availableSize.*Minor() / GetMinorSizeWithSpacing(context))); int rowIndex = static_cast<int>(index / itemsPerLine); int indexInRow = index - (rowIndex * itemsPerLine); auto gridState = GetAsGridState(context.LayoutState()); winrt::Rect bounds = MinorMajorRect( indexInRow * GetMinorSizeWithSpacing(context) + lastExtent.*MinorStart(), rowIndex * GetMajorSizeWithSpacing(context) + lastExtent.*MajorStart(), GetScrollOrientation() == ScrollOrientation::Vertical ? static_cast<float>(gridState->EffectiveItemWidth()) : static_cast<float>(gridState->EffectiveItemHeight()), GetScrollOrientation() == ScrollOrientation::Vertical ? static_cast<float>(gridState->EffectiveItemHeight()) : static_cast<float>(gridState->EffectiveItemWidth())); return bounds; } #pragma endregion
#include "../../src/common.h" #include <iostream> using namespace std; int main(int argc, char** argv) { std::string s = "even,evenleo,leo,kobe"; std::vector<std::string> vec = string_split(s, ','); for (auto& i : vec) { std::cout << i << std::endl; } cout << "-------------" << endl; split_file_ascii("input.txt", "lr/input_%d.txt", 3); return 0; }
#include "inventory.hpp" #include "character.hpp" #include "ctrl_file.hpp" #include "random.hpp" #include "save_fs.hpp" namespace elona { namespace { bool is_nonstackable(const ItemRef& item) { return item->quality == Quality::special && is_equipment(the_item_db[item->id]->category); } bool is_stackable_with(const ItemRef& item, const ItemRef& base_item) { const auto ignore_position = !item_get_owner(item).is_map(); if (item->id == "core.small_medal") { return ignore_position || item->position() == base_item->position(); } else { return item->almost_equals(*base_item.get_raw_ptr(), ignore_position); } } } // namespace InventoryRef inv_player() { return cdata.player().inventory(); } InventoryRef inv_map() { return g_inv.ground(); } lua_int inv_weight(const InventoryRef& inv) { lua_int weight{}; for (const auto& item : *inv) { if (item->weight >= 0) { weight += item->weight * item->number(); } } return weight; } lua_int inv_cargo_weight(const InventoryRef& inv) { lua_int weight{}; for (const auto& item : *inv) { if (item->weight < 0) { weight += -item->weight * item->number(); } } return weight; } optional<InventorySlot> inv_get_free_slot(const InventoryRef& inv) { return inv->get_free_slot(); } optional<InventorySlot> inv_make_free_slot(const InventoryRef& inv) { if (inv_get_owner(inv).is_map()) { return inv_make_free_slot_force(inv); } else { return inv_get_free_slot(inv); } } InventorySlot inv_make_free_slot_force(const InventoryRef& inv) { if (const auto slot = inv_get_free_slot(inv)) { return *slot; } auto owner = inv_get_owner(inv); if (owner.is_map()) { txt(i18n::s.get("core.item.items_are_destroyed")); return inv_compress(inv); } while (true) { const auto slot = inv_get_random_slot(inv); const auto item = inv->at(slot).unwrap(); const auto owner_chara = owner.as_character(); assert(owner_chara); if (item->body_part == 0) { if (owner_chara->ai_item == item) { owner_chara->ai_item = nullptr; } item->remove(); return slot; } } } lua_int inv_count(const InventoryRef& inv) { lua_int n{}; for (const auto& _i : *inv) { (void)_i; ++n; } return n; } ItemOwner inv_get_owner(const InventoryRef& inv) { if (inv->inventory_id() == -1) { return ItemOwner::map(); } else if (inv->inventory_id() == 255) { return ItemOwner::temporary(); } else { return ItemOwner::character(cdata[inv->inventory_id()]); } } InventorySlot inv_compress(const InventoryRef& inv) { int number_of_deleted_items{}; for (int i = 0; i < 100; ++i) { int threshold = 200 * (i * i + 1); for (const auto& item : *inv) { if (!item->is_precious && item->value < threshold) { item->remove(); ++number_of_deleted_items; } if (number_of_deleted_items > 10) { break; } } if (number_of_deleted_items > 10) { break; } } if (const auto free_slot = inv->get_free_slot()) { return *free_slot; } // Destroy 1 existing item forcely. const auto slot = inv_get_random_slot(inv); inv->at(slot)->remove(); return slot; } InventorySlot inv_get_random_slot(const InventoryRef& inv) { return static_cast<InventorySlot>(rnd(inv->size())); } InvStackResult inv_stack( const InventoryRef& inv, const ItemRef& base_item, bool show_message, optional<lua_int> number) { if (is_nonstackable(base_item)) { return {false, base_item}; } for (const auto& item : *inv) { if (item == base_item || item->id != base_item->id) continue; if (is_stackable_with(item, base_item)) { const auto num = number.value_or(base_item->number()); item->modify_number(num); base_item->modify_number(-num); if (show_message) { txt(i18n::s.get("core.item.stacked", item, item->number())); } return {true, item}; } } return {false, base_item}; } void inv_open_tmp_inv(const fs::path& file_name) { if (save_fs_exists(file_name)) { ctrl_file_tmp_inv_read(file_name); } else { g_inv.tmp()->clear(); } } void inv_close_tmp_inv(const fs::path& file_name) { ctrl_file_tmp_inv_write(file_name); g_inv.tmp()->clear(); } void inv_open_tmp_inv_no_physical_file() { g_inv.tmp()->clear(); } void inv_close_tmp_inv_no_physical_file() { g_inv.tmp()->clear(); } } // namespace elona
// Copyright (c) 2015-2017, RAPtor Developer Team // License: Simplified BSD, http://opensource.org/licenses/BSD-2-Clause #include "gtest/gtest.h" #include "raptor.hpp" using namespace raptor; int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } // end of main() // TEST(AnisoSpMVTest, TestsInUtil) { double b_val; int grid[2] = {25, 25}; double eps = 0.001; double theta = M_PI/8.0; double* stencil = diffusion_stencil_2d(eps, theta); CSRMatrix* A_sten = stencil_grid(stencil, grid, 2); Vector x(A_sten->n_rows); Vector b(A_sten->n_rows); const char* b_ones = "../../../../test_data/aniso_ones_b.txt"; const char* b_T_ones = "../../../../test_data/aniso_ones_b_T.txt"; const char* b_inc = "../../../../test_data/aniso_inc_b.txt"; const char* b_T_inc = "../../../../test_data/aniso_inc_b_T.txt"; // Test b <- A*ones int n_items_read; x.set_const_value(1.0); A_sten->mult(x, b); FILE* f = fopen(b_ones, "r"); for (int i = 0; i < A_sten->n_rows; i++) { n_items_read = fscanf(f, "%lg\n", &b_val); ASSERT_EQ(n_items_read, 1); ASSERT_NEAR(b[i],b_val,1e-06); } fclose(f); // Test b <- A_T*ones A_sten->mult_T(x, b); f = fopen(b_T_ones, "r"); for (int i = 0; i < A_sten->n_rows; i++) { n_items_read = fscanf(f, "%lg\n", &b_val); ASSERT_EQ(n_items_read, 1); ASSERT_NEAR(b[i], b_val, 1e-06); } fclose(f); // Tests b <- A*incr for (int i = 0; i < A_sten->n_rows; i++) { x[i] = i; } A_sten->mult(x, b); f = fopen(b_inc, "r"); for (int i = 0; i < A_sten->n_rows; i++) { n_items_read = fscanf(f, "%lg\n", &b_val); ASSERT_EQ(n_items_read, 1); ASSERT_NEAR(b[i],b_val, 1e-06); } fclose(f); // Tests b <- A_T*incr A_sten->mult_T(x, b); f = fopen(b_T_inc, "r"); for (int i = 0; i < A_sten->n_rows; i++) { n_items_read = fscanf(f, "%lg\n", &b_val); ASSERT_EQ(n_items_read, 1); ASSERT_NEAR(b[i], b_val, 1e-06); } fclose(f); } // end of TEST(AnisoSpMVTest, TestsInUtil) //
//********************************************************* // Group_Data.cpp - network grid data class //********************************************************* #include "Group_Data.hpp" //--------------------------------------------------------- // Group_Data constructor //--------------------------------------------------------- Group_Data::Group_Data (int group) : Class_Index (group) { Next_Group (0); link.Max_Records (20); } //--------------------------------------------------------- // Group_Array constructor //--------------------------------------------------------- Group_Array::Group_Array (int max_records) : Class_Pointer (max_records, false) { } void Group_Array::Clear (void) { for (Group_Data *ptr = First (); ptr != NULL; ptr = Next ()) { ptr->Clear (); } Class_Pointer::Clear (); } void Group_Array::Reset (void) { for (Group_Data *ptr = First (); ptr != NULL; ptr = Next ()) { ptr->Reset (); } Class_Pointer::Reset (); }
//---------------------------------------------------------------------------// // Copyright (c) 2022 Mikhail Komarov <nemo@nil.foundation> // Copyright (c) 2022 Ilias Khairullin <ilias@nil.foundation> // // MIT License // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. //---------------------------------------------------------------------------// #ifndef CRYPTO3_ZK_PLONK_PLACEHOLDER_PROFILING_HPP #define CRYPTO3_ZK_PLONK_PLACEHOLDER_PROFILING_HPP #include <algorithm> #include <nil/crypto3/math/algorithms/make_evaluation_domain.hpp> #include <nil/crypto3/zk/snark/systems/plonk/placeholder/params.hpp> namespace nil { namespace crypto3 { namespace zk { namespace snark { template<typename PlaceholderParams> struct placeholder_profiling; template<typename FieldType, typename ArithmetizationParams, typename MerkleTreeHashType, typename TranscriptHashType, std::size_t Lambda, std::size_t R, std::size_t M> struct placeholder_profiling<placeholder_params<FieldType, ArithmetizationParams, MerkleTreeHashType, TranscriptHashType, Lambda, R, M>> { typedef placeholder_params<FieldType, ArithmetizationParams, MerkleTreeHashType, TranscriptHashType, Lambda, R, M> placeholder_params_type; template<typename Proof, typename FRIParams, typename CommonData> static void print_params(const Proof &proof, const FRIParams &fri_params, const CommonData &common_data) { std::cout << "modulus = " << FieldType::modulus << std::endl; std::cout << "fri_params.r = " << fri_params.r << std::endl; std::cout << "fri_params.max_degree = " << fri_params.max_degree << std::endl; std::cout << "fri_params.q = "; for (const auto &coeff : fri_params.q) { std::cout << coeff.data << ", "; } std::cout << std::endl; std::cout << "fri_params.D_omegas = "; for (const auto &dom : fri_params.D) { std::cout << static_cast<nil::crypto3::math::basic_radix2_domain<FieldType> &>(*dom).omega.data << ", "; } std::cout << std::endl; std::cout << "lpc_params.lambda = " << placeholder_params_type::batched_commitment_params_type::lambda << std::endl; std::cout << "lpc_params.m = " << placeholder_params_type::batched_commitment_params_type::m << std::endl; std::cout << "common_data.rows_amount = " << common_data.rows_amount << std::endl; std::cout << "common_data.omega = " << static_cast<nil::crypto3::math::basic_radix2_domain<FieldType> &>( *common_data.basic_domain) .omega.data << std::endl; std::cout << "columns_rotations (" << common_data.columns_rotations.size() << " number) = {" << std::endl; for (const auto &column_rotations : common_data.columns_rotations) { std::cout << "["; for (auto rot : column_rotations) { std::cout << int(rot) << ", "; } std::cout << "]," << std::endl; } std::cout << "}" << std::endl; auto max_leaf_size_fri_proof = [](const auto &fri_proof) { std::size_t max_leaf_size = 0; for (const auto &round_proofs_i : fri_proof.round_proofs) { max_leaf_size = std::max(max_leaf_size, round_proofs_i.y.size()); } return max_leaf_size; }; auto max_leaf_size_lpc_proof = [&max_leaf_size_fri_proof](const auto &lpc_proof) { std::size_t max_leaf_size = 0; for (const auto &fri_proofs_i : lpc_proof.fri_proof) { max_leaf_size = std::max(max_leaf_size, max_leaf_size_fri_proof(fri_proofs_i)); } return max_leaf_size; }; std::cout << "max_leaf_size = " << std::max({ max_leaf_size_lpc_proof(proof.eval_proof.witness), max_leaf_size_lpc_proof(proof.eval_proof.quotient), max_leaf_size_lpc_proof(proof.eval_proof.id_permutation), max_leaf_size_lpc_proof(proof.eval_proof.sigma_permutation), max_leaf_size_lpc_proof(proof.eval_proof.public_input), max_leaf_size_lpc_proof(proof.eval_proof.constant), max_leaf_size_lpc_proof(proof.eval_proof.selector), max_leaf_size_lpc_proof(proof.eval_proof.special_selectors), }) << std::endl; } }; } // namespace snark } // namespace zk } // namespace crypto3 } // namespace nil #endif // CRYPTO3_ZK_PLONK_PLACEHOLDER_PROFILING_HPP
#include <iostream> #include <fstream> #include <stdlib.h> #include <time.h> //#include "learner.h" using namespace std; //CLASSES class Voice { public: void say(string phrase); // Used to textually and audibly communicate a phrase }; class Learner { string AIname_; public: Voice voice; Learner(); ~Learner(){} void respond(string phrase); // Used to get, or teach a response void say(string phrase); // Used to textually and audibly communicate a phrase void getName(); void userSearch(string name); // void say(string phrase); // Used to textually and audibly communicate a phrase }; //FUNCTIONS Learner::Learner() { AIname_="MEMORY"; } void Learner::respond(string phrase) { fstream memory; memory.open("Data/Brain.txt", ios::in); // Open the memory file for input // Search through the file until the end is reached while( !memory.eof() ){ // While not at end of file string identifier; getline(memory,identifier); // Get next phrase if(identifier == phrase){ // Is it the phrase we are looking for string response; getline(memory,response); // If so, get the response voice.say(response); // Textually and audibly output the response! return; // Leave the function } } cout<<" It seems that i don't know the answer for this question yet. Please teach me the right answer:"<<endl; memory.close(); // Looks like we couldn't find the phrase in memory. Close the file! memory.open("Data/Brain.txt", ios::out | ios::app); // Now open for output, and append at end of file memory << phrase << endl; // Record initial phrase in memory // if(choice=) // voice.say(phrase); // Repeat the phrase the user entered string userResponse; cout << "ANSWER: "; getline(cin, userResponse); // Get the ideal response memory << userResponse << endl; // Write the ideal response to memory memory.close(); // Close the file! } void Learner::getName() { cout<<AIname_; } void Voice::say(string phrase) { // string command = "espeak \"" + phrase + "\""; // Concat the phrase to the command // const char* charCommand = command.c_str(); // Convert to a const char* cout << phrase << endl; // Textually output phrase // system(charCommand); // Send the command to cmd to execute espeak with the phrase an argument } void Learner::userSearch(string name) { string user; char welcome=0; srand(time(NULL)); fstream USERS; USERS.open("Data/Users.txt", ios::in); // Open the memory file for input // Search through the file until the end is reached while( !USERS.eof() ) { // While not at end of file string identifier; getline(USERS,identifier); // Get next phrase if(identifier == name)// Is user exists? { welcome=rand()%2; cout<<endl; if(welcome==0)cout<<">Welcome back "<<name<<"!"<<endl; else if(welcome==1)cout<<">Heyy "<<name<<"!! "<<"Welcome Back!"<<endl; else cout<<">I missed you "<<name<<". "<< "Welcome back!"<<endl; //voice.say(response); // Textually and audibly output the response!*/ return; // Leave the function } } USERS.close(); // Looks like we couldn't find the phrase in memory. Close the file! USERS.open("Data/Users.txt", ios::out | ios::app); // Now open for output, and append at end of file cout<< ">Hello "<< name<<"! We are talking to each other for first time, so i must introduce myself."<<endl; cout<<">My Name is "; Learner::getName(); cout <<"."<<endl; cout<< ">I am an AI Chatbot. That means that we can chat to each other."<<endl; cout<<">In the future i will be able to speak, and help you with your stuff."<<endl; cout<<">Let's talk to each other!! You can start by saying hi to me!"<<endl; USERS << name << endl; // Write the ideal response to memory USERS.close(); // Close the file! } //MAIN int main (void) { Learner AI; // Create a learner object string user; string phrase; cout<<"Write your name to wake up the chatbot: "; cin>>user; AI.userSearch(user); getline(cin, phrase); for(;;) { cout <<"\n"<<">"<<user<<": "; // User prompt getline(cin, phrase); // Using getline for multi word input, then store in phrase. cout << ">";AI.getName();cout<<": "; AI.respond(phrase); // Pass the user input to the learner and see if he can respond } }
/*********************************************************************************************************************** * OpenStudio(R), Copyright (c) 2008-2018, Alliance for Sustainable Energy, LLC. All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the * following conditions are met: * * (1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following * disclaimer. * * (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the * following disclaimer in the documentation and/or other materials provided with the distribution. * * (3) Neither the name of the copyright holder nor the names of any contributors may be used to endorse or promote * products derived from this software without specific prior written permission from the respective party. * * (4) Other than as required in clauses (1) and (2), distributions in any form of modifications or other derivative * works may not use the "OpenStudio" trademark, "OS", "os", or any other confusingly similar designation without * specific prior written permission from Alliance for Sustainable Energy, LLC. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE UNITED STATES GOVERNMENT, OR ANY CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **********************************************************************************************************************/ #include "../ForwardTranslator.hpp" #include "../../model/CurveRectangularHyperbola1.hpp" #include "../../model/CurveRectangularHyperbola1_Impl.hpp" #include "../../utilities/core/Assert.hpp" #include <utilities/idd/Curve_RectangularHyperbola1_FieldEnums.hxx> #include <utilities/idd/IddEnums.hxx> using namespace openstudio::model; using namespace std; namespace openstudio { namespace energyplus { boost::optional<IdfObject> ForwardTranslator::translateCurveRectangularHyperbola1( CurveRectangularHyperbola1& modelObject) { IdfObject idfObject(IddObjectType::Curve_RectangularHyperbola1); m_idfObjects.push_back(idfObject); OptionalString s; OptionalDouble d; if ((s = modelObject.name())) { idfObject.setName(*s); } idfObject.setDouble(Curve_RectangularHyperbola1Fields::Coefficient1C1,modelObject.coefficient1C1()); idfObject.setDouble(Curve_RectangularHyperbola1Fields::Coefficient2C2,modelObject.coefficient2C2()); idfObject.setDouble(Curve_RectangularHyperbola1Fields::Coefficient3C3,modelObject.coefficient3C3()); idfObject.setDouble(Curve_RectangularHyperbola1Fields::MinimumValueofx,modelObject.minimumValueofx()); idfObject.setDouble(Curve_RectangularHyperbola1Fields::MaximumValueofx,modelObject.maximumValueofx()); if ((d = modelObject.minimumCurveOutput())) { idfObject.setDouble(Curve_RectangularHyperbola1Fields::MinimumCurveOutput,*d); } if ((d = modelObject.maximumCurveOutput())) { idfObject.setDouble(Curve_RectangularHyperbola1Fields::MaximumCurveOutput,*d); } if (!modelObject.isInputUnitTypeforxDefaulted()) { idfObject.setString(Curve_RectangularHyperbola1Fields::InputUnitTypeforx,modelObject.inputUnitTypeforx()); } if (!modelObject.isOutputUnitTypeDefaulted()) { idfObject.setString(Curve_RectangularHyperbola1Fields::OutputUnitType,modelObject.outputUnitType()); } return idfObject; } } // energyplus } // openstudio
//------------------------------------------------- // // Class: L1MuGMTEtaProjectionUnit // // Description: GMT Eta Projection Unit // // // // Author : // H. Sakulin CERN EP // // Migrated to CMSSW: // I. Mikulec // //-------------------------------------------------- //----------------------- // This Class's Header -- //----------------------- #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTEtaProjectionUnit.h" //--------------- // C++ Headers -- //--------------- #include <iostream> #include <vector> #include <cmath> //------------------------------- // Collaborating Class Headers -- //------------------------------- #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTConfig.h" #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTMipIsoAU.h" #include "L1Trigger/GlobalMuonTrigger/interface/L1MuGlobalMuonTrigger.h" #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTDebugBlock.h" #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTMIAUEtaProLUT.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" // -------------------------------- // class L1MuGMTEtaProjectionUnit //--------------------------------- //---------------- // Constructors -- //---------------- L1MuGMTEtaProjectionUnit::L1MuGMTEtaProjectionUnit(const L1MuGMTMipIsoAU& miau, int id) : m_MIAU(miau), m_id(id), m_mu(nullptr) { } //-------------- // Destructor -- //-------------- L1MuGMTEtaProjectionUnit::~L1MuGMTEtaProjectionUnit() { reset(); } //-------------- // Operations -- //-------------- // // run eta projection unit // void L1MuGMTEtaProjectionUnit::run() { load(); if ( m_mu && ( !m_mu->empty() ) ) { int isFwd = m_id / 16; int lut_id = m_id / 4; // obtain inputs as coded in HW unsigned pt = m_mu->pt_packed(); unsigned charge = m_mu->charge_packed(); unsigned eta = m_mu->eta_packed(); // lookup L1MuGMTMIAUEtaProLUT* ep_lut = L1MuGMTConfig::getMIAUEtaProLUT(); unsigned eta_sel_bits = ep_lut->SpecificLookup_eta_sel (lut_id, eta, pt, charge); // convert to bit array // // see comments in L1MuGMTMIAUEtaProLUT.cc // m_eta_select = (unsigned) 0; if (isFwd) { // forward for (int i=0; i<5; i++) if ( (eta_sel_bits & (1 << i)) == (unsigned) (1<<i)) m_eta_select[i] = true; for (int i=5; i<10; i++) if ( (eta_sel_bits & (1 << i)) == (unsigned) (1<<i)) m_eta_select[i+4] = true; } else { // barrel for (int i=0; i<10; i++) if ( (eta_sel_bits & (1 << i)) == (unsigned) (1<<i)) m_eta_select[i+2] = true; } // m_MIAU.GMT().DebugBlockForFill()->SetEtaSelBits( m_id, m_eta_select.read(0,14)) ; m_MIAU.GMT().DebugBlockForFill()->SetEtaSelBits( m_id, m_eta_select.to_ulong()) ; } } // // reset eta projection unit // void L1MuGMTEtaProjectionUnit::reset() { m_mu = nullptr; m_ieta = 0; m_feta = 0.; m_eta_select = (unsigned int) 0; } // // print results of eta projection // void L1MuGMTEtaProjectionUnit::print() const { edm::LogVerbatim("GMT_EtaProjection_info") << "Eta select bits: "; for ( int i=0; i<14; i++ ) { edm::LogVerbatim("GMT_EtaProjection_info") << m_eta_select[i] << " "; } edm::LogVerbatim("GMT_EtaProjection_info"); } // // load 1 muon into eta projection unit // void L1MuGMTEtaProjectionUnit::load() { // retrieve muon from MIP & ISO bit assignment unit m_mu = m_MIAU.muon( m_id % 8 ); }
// 4047. 영준이의 카드 카운팅 // 2019.07.01 #include<iostream> #include<string> using namespace std; int s[14]; int d[14]; int h[14]; int c[14]; int sCnt; int dCnt; int hCnt; int cCnt; void cal() { for (int i = 1; i <= 13; i++) { if (s[i] == 1) { sCnt++; } if (c[i] == 1) { cCnt++; } if (h[i] == 1) { hCnt++; } if (d[i] == 1) { dCnt++; } } } int main() { int test_case; int T; cin >> T; for (test_case = 1; test_case <= T; ++test_case) { fill(s, s + 14, 0); fill(d, d + 14, 0); fill(h, h + 14, 0); fill(c, c + 14, 0); sCnt = 0; dCnt = 0; hCnt = 0; cCnt = 0; string str; cin >> str; bool flag = true; for (int i = 0; i < str.size(); i += 3) { string tmp = str.substr(i, 3); int k = 0; switch (tmp[0]) { case 'S': k = stoi(tmp.substr(1, 2)); if (s[k] == 1) { flag = false; } else { s[k]++; } break; case 'D': k = stoi(tmp.substr(1, 2)); if (d[k] == 1) { flag = false; } else { d[k]++; } break; case 'H': k = stoi(tmp.substr(1, 2)); if (h[k] == 1) { flag = false; } else { h[k]++; } break; case 'C': k = stoi(tmp.substr(1, 2)); if (c[k] == 1) { flag = false; } else { c[k]++; } break; } } cal(); if (flag) { cout << "#" << test_case << " " << 13 - sCnt << " " << 13 - dCnt << " " << 13 - hCnt << " " << 13 - cCnt << endl; } else { cout << "#" << test_case << " " << "ERROR" << endl; } } return 0; }
// Copyright Oliver Kowalke 2009. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_COROUTINES_DETAIL_HOLDER_H #define BOOST_COROUTINES_DETAIL_HOLDER_H #include <boost/assert.hpp> #include <boost/config.hpp> #include <boost/optional.hpp> #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_PREFIX #endif namespace boost { namespace coroutines { namespace detail { template< typename Data > struct holder { context::fcontext_t * ctx; optional< Data > data; bool force_unwind; holder( context::fcontext_t * ctx_) : ctx( ctx_), data(), force_unwind( false) { BOOST_ASSERT( ctx); } holder( context::fcontext_t * ctx_, Data data_) : ctx( ctx_), data( data_), force_unwind( false) { BOOST_ASSERT( ctx); } holder( context::fcontext_t * ctx_, bool force_unwind_) : ctx( ctx_), data(), force_unwind( force_unwind_) { BOOST_ASSERT( ctx); BOOST_ASSERT( force_unwind); } holder( holder const& other) : ctx( other.ctx), data( other.data), force_unwind( other.force_unwind) {} holder & operator=( holder const& other) { if ( this == & other) return * this; ctx = other.ctx; data = other.data; force_unwind = other.force_unwind; return * this; } }; template<> struct holder< void > { context::fcontext_t * ctx; bool force_unwind; holder( context::fcontext_t * ctx_, bool force_unwind_ = false) : ctx( ctx_), force_unwind( force_unwind_) { BOOST_ASSERT( ctx); } holder( holder const& other) : ctx( other.ctx), force_unwind( other.force_unwind) {} holder & operator=( holder const& other) { if ( this == & other) return * this; ctx = other.ctx; force_unwind = other.force_unwind; return * this; } }; }}} #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_SUFFIX #endif #endif // BOOST_COROUTINES_DETAIL_HOLDER_H
#include "stdafx.h" #define SECURITY_WIN32 #include <Security.h> #pragma comment(lib, "Secur32.lib") #include <Lmcons.h> #include <comdef.h> #include <taskschd.h> #pragma comment(lib, "taskschd.lib") #pragma comment(lib, "comsupp.lib") #include <iostream> #include <strutil.h> #include <ProjectTelemetry.h> using namespace std; TRACELOGGING_DEFINE_PROVIDER( g_hProvider, "Microsoft.PowerToysInstaller", // {e1d8165d-5cb6-5c74-3b51-bdfbfe4f7a3b} (0xe1d8165d, 0x5cb6, 0x5c74, 0x3b, 0x51, 0xbd, 0xfb, 0xfe, 0x4f, 0x7a, 0x3b), TraceLoggingOptionProjectTelemetry()); const DWORD USERNAME_DOMAIN_LEN = DNLEN + UNLEN + 2; // Domain Name + '\' + User Name + '\0' const DWORD USERNAME_LEN = UNLEN + 1; // User Name + '\0' // Creates a Scheduled Task to run at logon for the current user. // The path of the executable to run should be passed as the CustomActionData (Value). // Based on the Task Scheduler Logon Trigger Example: // https://docs.microsoft.com/en-us/windows/win32/taskschd/logon-trigger-example--c---/ UINT __stdcall CreateScheduledTaskCA(MSIHANDLE hInstall) { HRESULT hr = S_OK; UINT er = ERROR_SUCCESS; TCHAR username_domain[USERNAME_DOMAIN_LEN]; TCHAR username[USERNAME_LEN]; std::wstring wstrTaskName; ITaskService *pService = NULL; ITaskFolder *pTaskFolder = NULL; ITaskDefinition *pTask = NULL; IRegistrationInfo *pRegInfo = NULL; ITaskSettings *pSettings = NULL; ITriggerCollection *pTriggerCollection = NULL; IRegisteredTask *pRegisteredTask = NULL; hr = WcaInitialize(hInstall, "CreateScheduledTaskCA"); ExitOnFailure(hr, "Failed to initialize"); WcaLog(LOGMSG_STANDARD, "Initialized."); // ------------------------------------------------------ // Get the Domain/Username for the trigger. // // This action needs to run as the system to get elevated privileges from the installation, // so GetUserNameEx can't be used to get the current user details. // The USERNAME and USERDOMAIN environment variables are used instead. if (!GetEnvironmentVariable(L"USERNAME", username, USERNAME_LEN)) { ExitWithLastError(hr, "Getting username failed: %x", hr); } if (!GetEnvironmentVariable(L"USERDOMAIN", username_domain, USERNAME_DOMAIN_LEN)) { ExitWithLastError(hr, "Getting the user's domain failed: %x", hr); } wcscat_s(username_domain, L"\\"); wcscat_s(username_domain, username); WcaLog(LOGMSG_STANDARD, "Current user detected: %ls", username_domain); // Task Name. wstrTaskName = L"Autorun for "; wstrTaskName += username; // Get the executable path passed to the custom action. LPWSTR wszExecutablePath = NULL; hr = WcaGetProperty(L"CustomActionData", &wszExecutablePath); ExitOnFailure(hr, "Failed to get the executable path from CustomActionData."); // COM and Security Initialization is expected to have been done by the MSI. // It couldn't be done in the DLL, anyway. // ------------------------------------------------------ // Create an instance of the Task Service. hr = CoCreateInstance(CLSID_TaskScheduler, NULL, CLSCTX_INPROC_SERVER, IID_ITaskService, (void**)&pService); ExitOnFailure(hr, "Failed to create an instance of ITaskService: %x", hr); // Connect to the task service. hr = pService->Connect(_variant_t(), _variant_t(), _variant_t(), _variant_t()); ExitOnFailure(hr, "ITaskService::Connect failed: %x", hr); // ------------------------------------------------------ // Get the PowerToys task folder. Creates it if it doesn't exist. hr = pService->GetFolder(_bstr_t(L"\\PowerToys"), &pTaskFolder); if (FAILED(hr)) { // Folder doesn't exist. Get the Root folder and create the PowerToys subfolder. ITaskFolder *pRootFolder = NULL; hr = pService->GetFolder(_bstr_t(L"\\"), &pRootFolder); ExitOnFailure(hr, "Cannot get Root Folder pointer: %x", hr); hr = pRootFolder->CreateFolder(_bstr_t(L"\\PowerToys"), _variant_t(L""), &pTaskFolder); if (FAILED(hr)) { pRootFolder->Release(); ExitOnFailure(hr, "Cannot create PowerToys task folder: %x", hr); } WcaLog(LOGMSG_STANDARD, "PowerToys task folder created."); } // If the same task exists, remove it. pTaskFolder->DeleteTask(_bstr_t(wstrTaskName.c_str()), 0); // Create the task builder object to create the task. hr = pService->NewTask(0, &pTask); ExitOnFailure(hr, "Failed to create a task definition: %x", hr); // ------------------------------------------------------ // Get the registration info for setting the identification. hr = pTask->get_RegistrationInfo(&pRegInfo); ExitOnFailure(hr, "Cannot get identification pointer: %x", hr); hr = pRegInfo->put_Author(_bstr_t(username_domain)); ExitOnFailure(hr, "Cannot put identification info: %x", hr); // ------------------------------------------------------ // Create the settings for the task hr = pTask->get_Settings(&pSettings); ExitOnFailure(hr, "Cannot get settings pointer: %x", hr); hr = pSettings->put_StartWhenAvailable(VARIANT_FALSE); ExitOnFailure(hr, "Cannot put_StartWhenAvailable setting info: %x", hr); hr = pSettings->put_StopIfGoingOnBatteries(VARIANT_FALSE); ExitOnFailure(hr, "Cannot put_StopIfGoingOnBatteries setting info: %x", hr); hr = pSettings->put_ExecutionTimeLimit(_bstr_t(L"PT0S")); //Unlimited ExitOnFailure(hr, "Cannot put_ExecutionTimeLimit setting info: %x", hr); hr = pSettings->put_DisallowStartIfOnBatteries(VARIANT_FALSE); ExitOnFailure(hr, "Cannot put_DisallowStartIfOnBatteries setting info: %x", hr); // ------------------------------------------------------ // Get the trigger collection to insert the logon trigger. hr = pTask->get_Triggers(&pTriggerCollection); ExitOnFailure(hr, "Cannot get trigger collection: %x", hr); // Add the logon trigger to the task. ITrigger *pTrigger = NULL; hr = pTriggerCollection->Create(TASK_TRIGGER_LOGON, &pTrigger); ExitOnFailure(hr, "Cannot create the trigger: %x", hr); ILogonTrigger *pLogonTrigger = NULL; hr = pTrigger->QueryInterface( IID_ILogonTrigger, (void**)&pLogonTrigger); pTrigger->Release(); ExitOnFailure(hr, "QueryInterface call failed for ILogonTrigger: %x", hr); hr = pLogonTrigger->put_Id(_bstr_t(L"Trigger1")); if (FAILED(hr)) { WcaLogError(hr, "Cannot put the trigger ID: %x", hr); } // Timing issues may make explorer not be started when the task runs. // Add a little delay to mitigate this. hr = pLogonTrigger->put_Delay(_bstr_t(L"PT03S")); if (FAILED(hr)) { WcaLogError(hr, "Cannot put the trigger delay: %x", hr); } // Define the user. The task will execute when the user logs on. // The specified user must be a user on this computer. hr = pLogonTrigger->put_UserId(_bstr_t(username_domain)); pLogonTrigger->Release(); ExitOnFailure(hr, "Cannot add user ID to logon trigger: %x", hr); // ------------------------------------------------------ // Add an Action to the task. This task will execute the path passed to this custom action. IActionCollection *pActionCollection = NULL; // Get the task action collection pointer. hr = pTask->get_Actions(&pActionCollection); ExitOnFailure(hr, "Cannot get Task collection pointer: %x", hr); // Create the action, specifying that it is an executable action. IAction *pAction = NULL; hr = pActionCollection->Create(TASK_ACTION_EXEC, &pAction); pActionCollection->Release(); ExitOnFailure(hr, "Cannot create the action: %x", hr); IExecAction *pExecAction = NULL; // QI for the executable task pointer. hr = pAction->QueryInterface( IID_IExecAction, (void**)&pExecAction); pAction->Release(); ExitOnFailure(hr, "QueryInterface call failed for IExecAction: %x", hr); // Set the path of the executable to PowerToys (passed as CustomActionData). hr = pExecAction->put_Path(_bstr_t(wszExecutablePath)); pExecAction->Release(); ExitOnFailure(hr, "Cannot set path of executable: %x", hr); // ------------------------------------------------------ // Create the principal for the task IPrincipal *pPrincipal = NULL; hr = pTask->get_Principal(&pPrincipal); ExitOnFailure(hr, "Cannot get principal pointer: %x", hr); // Set up principal information: hr = pPrincipal->put_Id(_bstr_t(L"Principal1")); if (FAILED(hr)) { WcaLogError(hr, "Cannot put the principal ID: %x", hr); } hr = pPrincipal->put_UserId(_bstr_t(username_domain)); if (FAILED(hr)) { WcaLogError(hr, "Cannot put principal user Id: %x", hr); } hr = pPrincipal->put_LogonType(TASK_LOGON_INTERACTIVE_TOKEN); if (FAILED(hr)) { WcaLogError(hr, "Cannot put principal logon type: %x", hr); } // Run the task with the highest available privileges. hr = pPrincipal->put_RunLevel(TASK_RUNLEVEL_HIGHEST); pPrincipal->Release(); ExitOnFailure(hr, "Cannot put principal run level: %x", hr); // ------------------------------------------------------ // Save the task in the PowerToys folder. hr = pTaskFolder->RegisterTaskDefinition( _bstr_t(wstrTaskName.c_str()), pTask, TASK_CREATE_OR_UPDATE, _variant_t(username_domain), _variant_t(), TASK_LOGON_INTERACTIVE_TOKEN, _variant_t(L""), &pRegisteredTask); ExitOnFailure(hr, "Error saving the Task : %x", hr); WcaLog(LOGMSG_STANDARD, "Scheduled task created for the current user."); LExit: ReleaseStr(wszExecutablePath); if (pService) pService->Release(); if (pTaskFolder) pTaskFolder->Release(); if (pTask) pTask->Release(); if (pRegInfo) pRegInfo->Release(); if (pSettings) pSettings->Release(); if (pTriggerCollection) pTriggerCollection->Release(); if (pRegisteredTask) pRegisteredTask->Release(); if (!SUCCEEDED(hr)) { PMSIHANDLE hRecord = MsiCreateRecord(0); MsiRecordSetString(hRecord, 0, TEXT("Failed to create a scheduled task to start PowerToys at user login. You can re-try to create the scheduled task using the PowerToys settings.")); MsiProcessMessage(hInstall, INSTALLMESSAGE(INSTALLMESSAGE_WARNING + MB_OK), hRecord); } er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE; return WcaFinalize(er); } // Removes all Scheduled Tasks in the PowerToys folder and deletes the folder afterwards. // Based on the Task Scheduler Displaying Task Names and State example: // https://docs.microsoft.com/en-us/windows/desktop/TaskSchd/displaying-task-names-and-state--c---/ UINT __stdcall RemoveScheduledTasksCA(MSIHANDLE hInstall) { HRESULT hr = S_OK; UINT er = ERROR_SUCCESS; ITaskService *pService = NULL; ITaskFolder *pTaskFolder = NULL; IRegisteredTaskCollection* pTaskCollection = NULL; hr = WcaInitialize(hInstall, "RemoveScheduledTasksCA"); ExitOnFailure(hr, "Failed to initialize"); WcaLog(LOGMSG_STANDARD, "Initialized."); // COM and Security Initialization is expected to have been done by the MSI. // It couldn't be done in the DLL, anyway. // ------------------------------------------------------ // Create an instance of the Task Service. hr = CoCreateInstance(CLSID_TaskScheduler, NULL, CLSCTX_INPROC_SERVER, IID_ITaskService, (void**)&pService); ExitOnFailure(hr, "Failed to create an instance of ITaskService: %x", hr); // Connect to the task service. hr = pService->Connect(_variant_t(), _variant_t(), _variant_t(), _variant_t()); ExitOnFailure(hr, "ITaskService::Connect failed: %x", hr); // ------------------------------------------------------ // Get the PowerToys task folder. hr = pService->GetFolder(_bstr_t(L"\\PowerToys"), &pTaskFolder); if (FAILED(hr)) { // Folder doesn't exist. No need to delete anything. WcaLog(LOGMSG_STANDARD, "The PowerToys scheduled task folder wasn't found. Nothing to delete."); hr = S_OK; ExitFunction(); } // ------------------------------------------------------- // Get the registered tasks in the folder. hr = pTaskFolder->GetTasks(TASK_ENUM_HIDDEN, &pTaskCollection); ExitOnFailure(hr, "Cannot get the registered tasks: %x", hr); LONG numTasks = 0; hr = pTaskCollection->get_Count(&numTasks); for (LONG i = 0; i < numTasks; i++) { // Delete all the tasks found. // If some tasks can't be deleted, the folder won't be deleted later and the user will still be notified. IRegisteredTask* pRegisteredTask = NULL; hr = pTaskCollection->get_Item(_variant_t(i + 1), &pRegisteredTask); if (SUCCEEDED(hr)) { BSTR taskName = NULL; hr = pRegisteredTask->get_Name(&taskName); if (SUCCEEDED(hr)) { hr = pTaskFolder->DeleteTask(taskName, NULL); if (FAILED(hr)) { WcaLogError(hr, "Cannot delete the '%S' task: %x", taskName, hr); } SysFreeString(taskName); } else { WcaLogError(hr, "Cannot get the registered task name: %x", hr); } pRegisteredTask->Release(); } else { WcaLogError(hr, "Cannot get the registered task item at index=%d: %x", i + 1, hr); } } // ------------------------------------------------------ // Get the pointer to the root task folder and delete the PowerToys subfolder. ITaskFolder *pRootFolder = NULL; hr = pService->GetFolder(_bstr_t(L"\\"), &pRootFolder); ExitOnFailure(hr, "Cannot get Root Folder pointer: %x", hr); hr = pRootFolder->DeleteFolder(_bstr_t(L"PowerToys"), NULL); pRootFolder->Release(); ExitOnFailure(hr, "Cannot delete the PowerToys folder: %x", hr); WcaLog(LOGMSG_STANDARD, "Deleted the PowerToys Task Scheduler folder."); LExit: if (pService) pService->Release(); if (pTaskFolder) pTaskFolder->Release(); if (pTaskCollection) pTaskCollection->Release(); if (!SUCCEEDED(hr)) { PMSIHANDLE hRecord = MsiCreateRecord(0); MsiRecordSetString(hRecord, 0, TEXT("Failed to remove the PowerToys folder from the scheduled task. These can be removed manually later.")); MsiProcessMessage(hInstall, INSTALLMESSAGE(INSTALLMESSAGE_WARNING + MB_OK), hRecord); } er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE; return WcaFinalize(er); } UINT __stdcall TelemetryLogInstallSuccessCA(MSIHANDLE hInstall) { HRESULT hr = S_OK; UINT er = ERROR_SUCCESS; hr = WcaInitialize(hInstall, "TelemetryLogInstallSuccessCA"); ExitOnFailure(hr, "Failed to initialize"); TraceLoggingWrite( g_hProvider, "Install_Success", ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance), TraceLoggingBoolean(TRUE, "UTCReplace_AppSessionGuid"), TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE)); LExit: er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE; return WcaFinalize(er); } UINT __stdcall TelemetryLogInstallCancelCA(MSIHANDLE hInstall) { HRESULT hr = S_OK; UINT er = ERROR_SUCCESS; hr = WcaInitialize(hInstall, "TelemetryLogInstallCancelCA"); ExitOnFailure(hr, "Failed to initialize"); TraceLoggingWrite( g_hProvider, "Install_Cancel", ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance), TraceLoggingBoolean(TRUE, "UTCReplace_AppSessionGuid"), TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE)); LExit: er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE; return WcaFinalize(er); } UINT __stdcall TelemetryLogInstallFailCA(MSIHANDLE hInstall) { HRESULT hr = S_OK; UINT er = ERROR_SUCCESS; hr = WcaInitialize(hInstall, "TelemetryLogInstallFailCA"); ExitOnFailure(hr, "Failed to initialize"); TraceLoggingWrite( g_hProvider, "Install_Fail", ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance), TraceLoggingBoolean(TRUE, "UTCReplace_AppSessionGuid"), TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE)); LExit: er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE; return WcaFinalize(er); } UINT __stdcall TelemetryLogUninstallSuccessCA(MSIHANDLE hInstall) { HRESULT hr = S_OK; UINT er = ERROR_SUCCESS; hr = WcaInitialize(hInstall, "TelemetryLogUninstallSuccessCA"); ExitOnFailure(hr, "Failed to initialize"); TraceLoggingWrite( g_hProvider, "UnInstall_Success", ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance), TraceLoggingBoolean(TRUE, "UTCReplace_AppSessionGuid"), TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE)); LExit: er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE; return WcaFinalize(er); } UINT __stdcall TelemetryLogUninstallCancelCA(MSIHANDLE hInstall) { HRESULT hr = S_OK; UINT er = ERROR_SUCCESS; hr = WcaInitialize(hInstall, "TelemetryLogUninstallCancelCA"); ExitOnFailure(hr, "Failed to initialize"); TraceLoggingWrite( g_hProvider, "UnInstall_Cancel", ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance), TraceLoggingBoolean(TRUE, "UTCReplace_AppSessionGuid"), TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE)); LExit: er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE; return WcaFinalize(er); } UINT __stdcall TelemetryLogUninstallFailCA(MSIHANDLE hInstall) { HRESULT hr = S_OK; UINT er = ERROR_SUCCESS; hr = WcaInitialize(hInstall, "TelemetryLogUninstallFailCA"); ExitOnFailure(hr, "Failed to initialize"); TraceLoggingWrite( g_hProvider, "UnInstall_Fail", ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance), TraceLoggingBoolean(TRUE, "UTCReplace_AppSessionGuid"), TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE)); LExit: er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE; return WcaFinalize(er); } UINT __stdcall TelemetryLogRepairCancelCA(MSIHANDLE hInstall) { HRESULT hr = S_OK; UINT er = ERROR_SUCCESS; hr = WcaInitialize(hInstall, "TelemetryLogRepairCancelCA"); ExitOnFailure(hr, "Failed to initialize"); TraceLoggingWrite( g_hProvider, "Repair_Cancel", ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance), TraceLoggingBoolean(TRUE, "UTCReplace_AppSessionGuid"), TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE)); LExit: er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE; return WcaFinalize(er); } UINT __stdcall TelemetryLogRepairFailCA(MSIHANDLE hInstall) { HRESULT hr = S_OK; UINT er = ERROR_SUCCESS; hr = WcaInitialize(hInstall, "TelemetryLogRepairFailCA"); ExitOnFailure(hr, "Failed to initialize"); TraceLoggingWrite( g_hProvider, "Repair_Fail", ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance), TraceLoggingBoolean(TRUE, "UTCReplace_AppSessionGuid"), TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE)); LExit: er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE; return WcaFinalize(er); } // DllMain - Initialize and cleanup WiX custom action utils. extern "C" BOOL WINAPI DllMain(__in HINSTANCE hInst, __in ULONG ulReason, __in LPVOID) { switch (ulReason) { case DLL_PROCESS_ATTACH: WcaGlobalInitialize(hInst); TraceLoggingRegister(g_hProvider); break; case DLL_PROCESS_DETACH: TraceLoggingUnregister(g_hProvider); WcaGlobalFinalize(); break; } return TRUE; }
#include "Communication.hpp" #include <cmath> #include <cassert> #include <algorithm> #include <strings.h> // Apply the Unbalanced Recursive Bisection (URB) algorithm to establish the boxes // (parts of the computational domain) that are assigned to MPI processes. The result // is stored within dis.ulist data structure void Distrib::createDecomposition(Config *conf) { Domain &dom = conf->dom_; ulist_.resize(nbp_); for(int id=0; id<nbp_; id++) ulist_[id].pid_ = -1; ulist_[0].pid_ = 0; ulist_[0].nbp_ = nbp_; for(int j=0; j<DIMENSION; j++) ulist_[0].xmin_[j] = 0; for(int j=0; j<DIMENSION; j++) { ulist_[0].xmax_[j] = dom.nxmax_[j] - 1; nxmax_[j] = dom.nxmax_[j]; } // Unbalanced Recursive Bisection // to create the domain decomposition among nbp processes for(int count = 1; count < nbp_; count++) { const float64 cutbound = 10000000000.; // Best score to choose a cut worse >= 1. / best = 0. float64 cutbest = cutbound; // Number of processes chosen for the cut int cutpart = -1; // Id of the process to be cut int cutid = -1; // Number of points to put into the newly created process int cutwidth = -1; // Direction of the cut int cutdir = -1; // Consider cutting only in the first NB_DIMS_DECOMPOSITION dimensions. // Valid values are in-between 1 and 4. for(int direction = 0; direction < NB_DIMS_DECOMPOSITION; direction++) { for(int id = 0; id < count; id++) { int nbp = ulist_[id].nbp_; if(nbp > 1) { int center = floor(nbp * 0.5); for(int part = center; part < nbp; part++) { const int width = ulist_[id].xmax_[direction] - ulist_[id].xmin_[direction] + 1; const float64 fract = static_cast<float64>(part) / static_cast<float64>(nbp); const float64 splitscore = 1. - width / static_cast<float64>(dom.nxmax_[direction]); const int tmpwidth = round(fract * width); const float64 ratioscore = fabs(fract * width - tmpwidth); const float64 cutscore = ratioscore + splitscore + cutbound * (tmpwidth < MMAX + 2) + cutbound * ((width - tmpwidth) < (MMAX + 2)); // select the best score to cut the former domain if(cutscore < cutbest) { cutid = id; cutbest = cutscore; cutpart = part; cutwidth = tmpwidth; cutdir = direction; } }//for(int part = center; part < nbp; part++) }//if(nbp > 1) }//for(int id = 0; id < count; id++) }//for(int direction = 0; direction < NB_DIMS_DECOMPOSITION; direction++) if(cutbest == cutbound) { printf("No cut found to create domain decomposition, reduce nb of processes\n"); } for(int j=0; j<DIMENSION; j++) { ulist_[count].xmax_[j] = ulist_[cutid].xmax_[j]; ulist_[count].xmin_[j] = ulist_[cutid].xmin_[j]; } ulist_[cutid].nbp_ -= cutpart; ulist_[cutid].xmin_[cutdir] += cutwidth; ulist_[count].nbp_ = cutpart; ulist_[count].xmax_[cutdir] = ulist_[cutid].xmin_[cutdir] - 1; }//for(int count = 1; count < nbp_; count++) uint64 msum = 0; for(int id = 0; id < nbp_; id++) { const uint64 mcontrib = (ulist_[id].xmax_[3] - ulist_[id].xmin_[3] + 1) * (ulist_[id].xmax_[2] - ulist_[id].xmin_[2] + 1) * (ulist_[id].xmax_[1] - ulist_[id].xmin_[1] + 1) * (ulist_[id].xmax_[0] - ulist_[id].xmin_[0] + 1); if(master()) printf("[%d] local domain [%4u:%4u,%4u:%4u,%4u:%4u,%4u:%4u] cost %lu\n", id, ulist_[id].xmin_[0], ulist_[id].xmax_[0], ulist_[id].xmin_[1], ulist_[id].xmax_[1], ulist_[id].xmin_[2], ulist_[id].xmax_[2], ulist_[id].xmin_[3], ulist_[id].xmax_[3], mcontrib); msum += mcontrib; } uint64 mref = static_cast<uint64>(dom.nxmax_[3]) * static_cast<uint64>(dom.nxmax_[2]) * static_cast<uint64>(dom.nxmax_[1]) * static_cast<uint64>(dom.nxmax_[0]); if(mref != msum) { printf("Problem: sum check mref %lf mcalc %lu \n", mref, msum); MPI_Barrier(MPI_COMM_WORLD); MPI_Finalize(); exit(1); } node_ = &(ulist_[pid_]); // Update local domain size for(int j=0; j<DIMENSION; j++) { dom.local_nx_[j] = node_->xmax_[j] - node_->xmin_[j] + 1; dom.local_nxmin_[j] = node_->xmin_[j]; dom.local_nxmax_[j] = node_->xmax_[j]; } } /* @biref Computes a list 'nlist' of *receiving* halos for the local MPI process. In order to achieve this, it fills the cells of halo_fn with the PID of the MPI. This function works in combination with comm_get_neibourghs, comm_merge_elts_ and comm_book_halo. @param[in] halo_fn[] Identical to fn, used as a buffer to keep pid @param[out] recv_list_ Update the recv_list Used once in init.cpp */ void Distrib::neighboursList(Config *conf, RealView4D &halo_fn) { const Domain& dom = conf->dom_; const int s_nxmax = dom.nxmax_[0]; const int s_nymax = dom.nxmax_[1]; const int s_nvxmax = dom.nxmax_[2]; const int s_nvymax = dom.nxmax_[3]; Urbnode &mynode = ulist_[pid_]; // Process periodic boundary condition to get a complete map for(int ivy = mynode.xmin_[3] - HALO_PTS; ivy < mynode.xmax_[3] + HALO_PTS + 1; ivy++) { for(int ivx = mynode.xmin_[2] - HALO_PTS; ivx < mynode.xmax_[2] + HALO_PTS + 1; ivx++) { const int jvy = (s_nvymax + ivy) % s_nvymax; const int jvx = (s_nvxmax + ivx) % s_nvxmax; for(int iy = mynode.xmin_[1] - HALO_PTS; iy < mynode.xmax_[1] + HALO_PTS + 1; iy++) { for(int ix = mynode.xmin_[0] - HALO_PTS; ix < mynode.xmax_[0] + HALO_PTS + 1; ix++) { const int jy = (s_nymax + iy) % s_nymax; const int jx = (s_nxmax + ix) % s_nxmax; int id = 0; bool notfound = true; while(notfound && (id<nbp_)) { const Urbnode &node = ulist_[id]; if( node.xmin_[0] <= jx && jx <= node.xmax_[0] && node.xmin_[1] <= jy && jy <= node.xmax_[1] && node.xmin_[2] <= jvx && jvx <= node.xmax_[2] && node.xmin_[3] <= jvy && jvy <= node.xmax_[3] ) { halo_fn(ix, iy, ivx, ivy) = static_cast<float64>(id); notfound = 0; } id++; } assert(!notfound); }//for(int ix = mynode.xmin_[0] - HALO_PTS; ix < mynode.xmax_[0] + HALO_PTS + 1; ix++) }//for(int iy = mynode.xmin_[1] - HALO_PTS; iy < mynode.xmax_[1] + HALO_PTS + 1; iy++) }//for(int ivx = mynode.xmin_[2] - HALO_PTS; ivx < mynode.xmax_[2] + HALO_PTS + 1; ivx++) }//for(int ivy = mynode.xmin_[3] - HALO_PTS; ivy < mynode.xmax_[3] + HALO_PTS + 1; ivy++) // Use the map to establish neighbours in the communication // scheme of halo exchange int id = pid_; Urbnode &node = ulist_[id]; std::vector<Halo> hlist; int count = 0; int jv[4]; for(jv[0] = -1; jv[0] < 2; jv[0]++) { for(jv[1] = -1; jv[1] < 2; jv[1]++) { for(jv[2] = -1; jv[2] < 2; jv[2]++) { for(jv[3] = -1; jv[3] < 2; jv[3]++) { int face[8] = { node.xmin_[0], node.xmax_[0] + 1, node.xmin_[1], node.xmax_[1] + 1, node.xmin_[2], node.xmax_[2] + 1, node.xmin_[3], node.xmax_[3] + 1, }; for(int k = 0; k < 4; k++) { if(jv[k] == -1) { face[2 * k + 0] = node.xmin_[k] - HALO_PTS; face[2 * k + 1] = node.xmin_[k] - 1; } if(jv[k] == 1) { face[2 * k + 0] = node.xmax_[k] + 1; face[2 * k + 1] = node.xmax_[k] + HALO_PTS; } } if(jv[0] != 0 || jv[1] != 0 || jv[2] != 0 || jv[3] != 0) getNeighbours(conf, halo_fn, face, hlist, mynode.xmin_, mynode.xmax_, count); count++; } } } } // Compress the neighbours list using sorting + merging of list cells assert(dom.nxmax_[0] < 2010); assert(dom.nxmax_[1] < 2010); assert(dom.nxmax_[2] < 2010); assert(dom.nxmax_[3] < 2010); for(int k = 0; k < 4; k++) { int k0 = k; int k1 = (k + 1) % 4; int k2 = (k + 2) % 4; int k3 = (k + 3) % 4; // [TO DO] Rename this auto larger = [k0, k1, k2, k3](const Halo &a, const Halo &b) { if(a.pid_ == b.pid_) { if(a.xmin_[k0] == b.xmin_[k0]) { if(a.xmin_[k1] == b.xmin_[k1]) { if(a.xmin_[k2] == b.xmin_[k2]) { return (a.xmin_[k3] < b.xmin_[k3]); } else { return (a.xmin_[k2] < b.xmin_[k2]); } } else { return (a.xmin_[k1] < b.xmin_[k1]); } } else { return (a.xmin_[k0] < b.xmin_[k0]); } } else { return (a.pid_ < b.pid_); } }; std::sort(hlist.begin(), hlist.end(), larger); int cursize = hlist.size(); int oldsize = cursize + 1; while(oldsize > cursize) { for(auto it = hlist.begin(); it != hlist.end(); ++it) { auto next = it + 1; if(next != hlist.end()) mergeElts(hlist, it, next); } oldsize = cursize; cursize = hlist.size(); } } // Print the halo list with neighbour id recv_list_.assign(hlist.begin(), hlist.end()); } // Establish and allocate all receving/sending buffers // for halo communication between MPI neighbours. // To this end, it takes as an input 'rlist', the list // of receiving halos. One ouput is 'slist', the halos // to be sent. /* @biref Get a list of the neighbours of the local MPI subdomain. Input is halo_fn that stores PIDs of the cells halo_fn(ivy,ivx,iy,ix). Ouput is hlist that includes a list of halo boxes. The union of all the hlist's boxes represents the actual halo of the local MPI subdomain. called in the initialization phase after neighboursList @param[in] halo Identical to fn @param[in] xrange[8] face[8] = node.xmin[0], node.xmax[0] + 1, node.xmin[1], node.xmax[1] + 1, node.xmin[2], node.xmax[2] + 1, node.xmin[3], node.xmax[3] + 1} where node = ulist_[pid] @param[in] lxmin[4] mynode.xmin, where mynode = ulist_[pid] @param[in] lxmax[4] mynode.xmax, where mynode = ulist_[pid] @param[in] count the total loop count of the 4D loop over halo regions ranging (-1:2) in each direction @param[inout] hlist Indentical to recv_list */ void Distrib::bookHalo(Config *conf) { int size_halo = sizeof(Halo); std::vector<unsigned short> vectp(nbp_, 0); std::vector<unsigned short> redp(nbp_, 0); std::vector<MPI_Request> req; std::vector<MPI_Status> stat; int tag = 111; int nbreq = 0; // Compute the number of local halos that should be received // depending of the PID that should send it. for(auto it = recv_list_.begin(); it != recv_list_.end(); ++it) { vectp[(*it).pid_]++; } // Reduce this 'vectp' array in order that each and ervey process // knows about the number of send/receive halos. MPI_Allreduce(vectp.data(), redp.data(), nbp_, MPI_UNSIGNED_SHORT, MPI_SUM, MPI_COMM_WORLD); // Initialize the vector 'slist' of halos to be sent nbreq = redp[pid_]; send_list_.resize(nbreq); req.resize(nbreq + recv_list_.size()); stat.resize(nbreq + recv_list_.size()); // Receiving halo settings to be received to corresponding MPI processes for(size_t i = 0; i < send_list_.size(); i++) { Halo *sender = &(send_list_[i]); MPI_Irecv(sender, size_halo, MPI_BYTE, MPI_ANY_SOURCE, tag, MPI_COMM_WORLD, &(req[i])); } // Send halo settings to be sent to corresponding MPI processes for(size_t i = 0; i < recv_list_.size(); i++) { Halo *recver = &(recv_list_[i]); int dest = recver->pid_; MPI_Isend(recver, size_halo, MPI_BYTE, dest, tag, MPI_COMM_WORLD, &(req[nbreq])); nbreq++; } // One should wait the end of the exchange before allocating the halo MPI_Waitall(nbreq, req.data(), stat.data()); // All local halos dimensions are now well known. // Let's allocate them. for(size_t i = 0; i < send_list_.size(); i++) { Halo *halo = &(send_list_[i]); int32 size = (halo->xmax_[0] - halo->xmin_[0] + 1) * (halo->xmax_[1] - halo->xmin_[1] + 1) * (halo->xmax_[2] - halo->xmin_[2] + 1) * (halo->xmax_[3] - halo->xmin_[3] + 1); halo->size_ = size; } for(size_t i = 0; i < recv_list_.size(); i++) { Halo *halo = &(recv_list_[i]); int32 size = (halo->xmax_[0] - halo->xmin_[0] + 1) * (halo->xmax_[1] - halo->xmin_[1] + 1) * (halo->xmax_[2] - halo->xmin_[2] + 1) * (halo->xmax_[3] - halo->xmin_[3] + 1); halo->size_ = size; } // Set the PID of each halo's sender in 'slist''s components for(size_t i = 0; i < send_list_.size(); i++) { Halo *sender = &(send_list_[i]); sender->pid_ = stat[i].MPI_SOURCE; } // Copy into Kokkos suited structure // Halo size large enough to store send_buffers_ = new Halos(); recv_buffers_ = new Halos(); send_buffers_->set(conf, send_list_, "send", nbp_, pid_); recv_buffers_->set(conf, recv_list_, "recv", nbp_, pid_); fprintf(stderr, "[%d] Number of halo blocs = %lu\n", pid_, send_list_.size()); } /* @biref Get a list of the neighbours of the local MPI subdomain. Input is halo_fn that stores PIDs of the cells halo_fn(ivy,ivx,iy,ix). Ouput is hlist that includes a list of halo boxes. The union of all the hlist's boxes represents the actual halo of the local MPI subdomain. called inside the neighboursList function @param[in] halo_fn[] Identical to fn @param[in] xrange[8] face[8] = node.xmin[0], node.xmax[0] + 1, node.xmin[1], node.xmax[1] + 1, node.xmin[2], node.xmax[2] + 1, node.xmin[3], node.xmax[3] + 1} where node = ulist_[pid] @param[in] lxmin[4] mynode.xmin, where mynode = ulist_[pid] @param[in] lxmax[4] mynode.xmax, where mynode = ulist_[pid] @param[in] count the total loop count of the 4D loop over halo regions ranging (-1:2) in each direction @param[inout] hlist Indentical to recv_list */ void Distrib::getNeighbours(const Config *conf, const RealView4D &halo_fn, int xrange[8], std::vector<Halo> &hlist, int lxmin[4], int lxmax[4], int count) { std::vector<Halo> vhalo; uint8 neighbours[nbp_]; uint32 nb_neib = 0; for(uint32 j=0; j<nbp_; j++) neighbours[j] = 255; vhalo.clear(); for(int ivy = xrange[6]; ivy <= xrange[7]; ivy++) { for(int ivx = xrange[4]; ivx <= xrange[5]; ivx++) { for(int iy = xrange[2]; iy <= xrange[3]; iy++) { for(int ix = xrange[0]; ix <= xrange[1]; ix++) { const uint32 neibid = round(halo_fn(ix, iy, ivx, ivy)); if(neighbours[neibid] == 255) { Halo myneib; neighbours[neibid] = nb_neib; myneib.pid_ = neibid; myneib.xmin_[0] = ix; myneib.xmin_[1] = iy; myneib.xmin_[2] = ivx; myneib.xmin_[3] = ivy; myneib.xmax_[0] = ix; myneib.xmax_[1] = iy; myneib.xmax_[2] = ivx; myneib.xmax_[3] = ivy; myneib.tag_ = count; for(int k = 0; k < 4; k++) { myneib.lxmin_[k] = lxmin[k]; myneib.lxmax_[k] = lxmax[k]; } vhalo.push_back(myneib); nb_neib++; }//if(neighbours[neibid] == 255) uint8 neighbour = neighbours[neibid]; vhalo[neighbour].xmax_[0] = ix; vhalo[neighbour].xmax_[1] = iy; vhalo[neighbour].xmax_[2] = ivx; vhalo[neighbour].xmax_[3] = ivy; }//for(int32 ix = xrange[0]; ix <= xrange[1]; ix++) }//for(int32 iy = xrange[2]; iy <= xrange[3]; iy++) }//for(int32 ivx = xrange[4]; ivx <= xrange[5]; ivx++) }//for(int32 ivy = xrange[6]; ivy <= xrange[7]; ivy++) // [Y. A] Comment, can it be a very large array? hlist.insert(hlist.end(), vhalo.begin(), vhalo.end()); } /* @biref Possibly merge two halos 'f' and 'g' into a single one if ever it is possible. The vector 'v' contains 'f' and 'g' initially and 'g' can possibly be erased by this function. called in neighboursList function @param[in] v hlist @param[in] g The iterator of hlist pointing it + 1 (next) @param[out] f The iterator of hlist pointing it */ int Distrib::mergeElts(std::vector<Halo> &v, std::vector<Halo>::iterator &f, std::vector<Halo>::iterator &g) { if((*f).pid_ == (*g).pid_) { // Owned by the same MPI process for(uint32 i = 0; i < DIMENSION; i++) { bool equal = true; int retcode = 0; for(uint32 j = 0; j < DIMENSION; j++) { if(j != i) { equal = equal && ((*f).xmin_[j] == (*g).xmin_[j]) && ((*f).xmax_[j] == (*g).xmax_[j]); } } if(equal && ((*f).xmin_[i] == (*g).xmax_[i] + 1)) { (*f).xmin_[i] = (*g).xmin_[i]; retcode = 1; } if(equal && ((*f).xmax_[i] + 1 == (*g).xmin_[i])) { (*f).xmax_[i] = (*g).xmax_[i]; retcode = 2; } if(retcode != 0) { v.erase(g); return retcode; } } } return 0; } void Distrib::Isend(int &creq, std::vector<MPI_Request> &req) { int nb_halos = send_buffers_->nb_merged_halos_; int size_local_copy = send_buffers_->merged_size(pid_); for(int i = 0; i < nb_halos; i++) { if(i == pid_) { // Then local copy local_copy(send_buffers_, recv_buffers_); } else { // Then MPI communication float64 *head = send_buffers_->head(i); const int size = send_buffers_->merged_size(i); const int pid = send_buffers_->merged_pid(i); const int tag = send_buffers_->merged_tag(i); if(size != 0 ) { #if defined( ENABLE_OPENMP_OFFLOAD ) #pragma omp target data use_device_ptr(head) #endif MPI_Isend(head, size, MPI_DOUBLE, pid, tag, MPI_COMM_WORLD, &(req[creq++])); } } } } void Distrib::Irecv(int &creq, std::vector<MPI_Request> &req) { int nb_halos = recv_buffers_->nb_merged_halos_; int size_local_copy = recv_buffers_->merged_size(pid_); for(int i = 0; i < nb_halos; i++) { if(i != pid_) { // Then MPI communication float64 *head = recv_buffers_->head(i); const int size = recv_buffers_->merged_size(i); const int pid = recv_buffers_->merged_pid(i); const int tag = recv_buffers_->merged_tag(i); if(size != 0 ) { #if defined( ENABLE_OPENMP_OFFLOAD ) #pragma omp target data use_device_ptr(head) #endif MPI_Irecv(head, size, MPI_DOUBLE, pid, tag, MPI_COMM_WORLD, &(req[creq++])); } } } } /* @biref Copy values of distribution function in to the halo regions (within slist) that will be sent. called in exchangeHalo function @param[in] send_list @param[in] recv_list @param[inout] halo_fn */ void Distrib::packAndBoundary(Config *conf, RealView4D &halo_fn, Halos *send_buffers) { if(spline_) { pack(halo_fn, send_buffers); boundary_condition(halo_fn, send_buffers); } } /* @biref Perform actually the exchange of halo with neighbouring MPI processes. 'halo_fn' is the input/output distrib. function. 'recv_list' and 'send_list' are the list of receive/send halos. @param[in] recv_list @param[in] send_list @param[inout] halo_fn [TO DO] names halo_fill_A and halo_fill_B should be renamed as halo_pack, halo_unpack This function is called inside the main loop */ void Distrib::exchangeHalo(Config *conf, RealView4D &halo_fn, std::vector<Timer*> &timers) { std::vector<MPI_Request> req; std::vector<MPI_Status> stat; int nbreq = 0, creq = 0; nbreq = recv_buffers_->nb_reqs() + send_buffers_->nb_reqs(); creq = 0; req.resize(nbreq); stat.resize(nbreq); // CUDA Aware MPI timers[TimerEnum::pack]->begin(); Irecv(creq, req); packAndBoundary(conf, halo_fn, send_buffers_); timers[TimerEnum::pack]->end(); timers[TimerEnum::comm]->begin(); Isend(creq, req); // local copy done inside Waitall(creq, req, stat); // clear vectors std::vector<MPI_Request>().swap(req); std::vector<MPI_Status>().swap(stat); timers[TimerEnum::comm]->end(); timers[TimerEnum::unpack]->begin(); // copy halo regions back into distribution function unpack(halo_fn, recv_buffers_); timers[TimerEnum::unpack]->end(); }
// // C_Relation.cpp // galgas-developer // // Created by Pierre Molinaro on 22/05/14. //---------------------------------------------------------------------------------------------------------------------- #include "bdd/C_Relation.h" #include "utilities/C_SharedObject.h" //---------------------------------------------------------------------------------------------------------------------- C_Relation::C_Relation (void) : mConfiguration (), mBDD () { } //---------------------------------------------------------------------------------------------------------------------- C_Relation::C_Relation (const C_RelationConfiguration & inConfiguration, const C_BDD inBDD) : mConfiguration (inConfiguration), mBDD (inBDD) { } //---------------------------------------------------------------------------------------------------------------------- C_Relation::C_Relation (const C_RelationConfiguration & inConfiguration, const bool inIsFull) : mConfiguration (inConfiguration), mBDD () { if (inIsFull) { mBDD.setToTrue () ; } } //---------------------------------------------------------------------------------------------------------------------- C_Relation::C_Relation (const C_String & inVariableName, const C_RelationSingleType & inVariableType, const bool inIsFull) : mConfiguration (), mBDD () { if (inIsFull) { mBDD.setToTrue () ; } mConfiguration.addVariable (inVariableName, inVariableType) ; } //---------------------------------------------------------------------------------------------------------------------- C_Relation::~C_Relation (void) { } //---------------------------------------------------------------------------------------------------------------------- C_Relation::C_Relation (const C_Relation & inSource) : mConfiguration (inSource.mConfiguration), mBDD (inSource.mBDD) { } //---------------------------------------------------------------------------------------------------------------------- C_Relation & C_Relation::operator = (const C_Relation & inSource) { if (this != & inSource) { mConfiguration = inSource.mConfiguration ; mBDD = inSource.mBDD ; } return *this ; } //---------------------------------------------------------------------------------------------------------------------- void C_Relation::addVariable (const C_String & inVariableName, const C_RelationSingleType & inType) { mConfiguration.addVariable (inVariableName, inType) ; } //---------------------------------------------------------------------------------------------------------------------- void C_Relation::appendConfiguration (const C_RelationConfiguration & inConfiguration) { mConfiguration.appendConfiguration (inConfiguration) ; } //---------------------------------------------------------------------------------------------------------------------- C_RelationConfiguration C_Relation::configuration (void) const { return mConfiguration ; } //---------------------------------------------------------------------------------------------------------------------- C_BDD C_Relation::bdd (void) const { return mBDD ; } //---------------------------------------------------------------------------------------------------------------------- void C_Relation::setToEmpty (void) { mBDD.setToFalse () ; } //---------------------------------------------------------------------------------------------------------------------- void C_Relation::setToFull (void) { mBDD.setToTrue () ; } //---------------------------------------------------------------------------------------------------------------------- C_Relation::C_Relation (const C_RelationConfiguration & inConfiguration, const int32_t inVariableIndex, const C_BDD::compareEnum inComparaison, const uint64_t inConstant COMMA_LOCATION_ARGS) : mConfiguration (inConfiguration), mBDD () { mBDD = C_BDD::varCompareConst (inConfiguration.bddStartBitIndexForVariable (inVariableIndex COMMA_THERE), inConfiguration.bddBitCountForVariable (inVariableIndex COMMA_THERE), inComparaison, inConstant) ; } //---------------------------------------------------------------------------------------------------------------------- void C_Relation::andWith (const C_Relation & inRelation COMMA_LOCATION_ARGS) { mConfiguration.checkIdenticalTo (inRelation.mConfiguration COMMA_THERE) ; mBDD &= inRelation.mBDD ; } //---------------------------------------------------------------------------------------------------------------------- void C_Relation::orWith (const C_Relation & inRelation COMMA_LOCATION_ARGS) { mConfiguration.checkIdenticalTo (inRelation.mConfiguration COMMA_THERE) ; mBDD |= inRelation.mBDD ; } //---------------------------------------------------------------------------------------------------------------------- C_Relation C_Relation::andOp (const C_Relation & inRelation COMMA_LOCATION_ARGS) const { C_Relation result = *this ; result.andWith (inRelation COMMA_THERE) ; return result ; } //---------------------------------------------------------------------------------------------------------------------- C_Relation C_Relation::orOp (const C_Relation & inRelation COMMA_LOCATION_ARGS) const { C_Relation result = *this ; result.orWith (inRelation COMMA_THERE) ; return result ; } //---------------------------------------------------------------------------------------------------------------------- C_Relation C_Relation::operator ~ (void) const { C_Relation result = *this ; result.mBDD.negate () ; return result ; } //---------------------------------------------------------------------------------------------------------------------- C_Relation C_Relation::accessibleStatesFrom (const C_Relation & inStartStates, int32_t * outIterationCount COMMA_LOCATION_ARGS) const { #ifndef DO_NOT_GENERATE_CHECKINGS const int32_t startRelationVariableCount = inStartStates.variableCount () ; const int32_t accessibilityVariableCount = variableCount () ; #endif MF_AssertThere ((startRelationVariableCount + startRelationVariableCount) == accessibilityVariableCount, "C_Relation::accessibleStatesFrom error: start state has %lld variables, accessibility relation has %lld variables", (int64_t) startRelationVariableCount, (int64_t) accessibilityVariableCount) ; return C_Relation ( inStartStates.configuration(), mBDD.accessibleStates (inStartStates.mBDD, inStartStates.bitCount (), outIterationCount) ) ; } //---------------------------------------------------------------------------------------------------------------------- C_Relation C_Relation::transitiveClosure (int32_t * outIterationCount) const { return C_Relation ( mConfiguration, mBDD.transitiveClosure (bitCount () / 2, outIterationCount) ) ; } //---------------------------------------------------------------------------------------------------------------------- bool C_Relation::containsValue (const int32_t inVariableIndex, const uint64_t inValue COMMA_LOCATION_ARGS) const { return mBDD.containsValue64 (inValue, mConfiguration.bddStartBitIndexForVariable (inVariableIndex COMMA_THERE), mConfiguration.bddBitCountForVariable (inVariableIndex COMMA_THERE)) ; } //---------------------------------------------------------------------------------------------------------------------- void C_Relation::getValueArray (TC_UniqueArray <uint64_t> & outArray) const { mBDD.buildValue64Array (outArray, mConfiguration.bitCount ()) ; } //---------------------------------------------------------------------------------------------------------------------- uint64_t C_Relation::value64Count (void) const { return mBDD.valueCount64 (mConfiguration.bitCount ()) ; } //---------------------------------------------------------------------------------------------------------------------- // getArray //---------------------------------------------------------------------------------------------------------------------- void C_Relation::getArray (TC_UniqueArray <TC_UniqueArray <uint64_t> > & outArray COMMA_LOCATION_ARGS) const { MF_AssertThere (variableCount () == 2, "C_Relation::getArray error: variableCount () == %lld != 2", (int64_t) variableCount (), 0) ; const uint32_t bitCount0 = mConfiguration.bddBitCountForVariable (0 COMMA_THERE) ; const uint32_t bitCount1 = mConfiguration.bddBitCountForVariable (1 COMMA_THERE) ; const uint32_t size0 = mConfiguration.constantCountForVariable (0 COMMA_THERE) ; mBDD.getArray2 (outArray, size0, bitCount0, bitCount1) ; } //---------------------------------------------------------------------------------------------------------------------- C_Relation C_Relation::relationByDeletingLastVariable (LOCATION_ARGS) const { C_Relation result = *this ; const int32_t lastVariableIndex = variableCount () - 1 ; result.mBDD = result.mBDD.existsOnBitRange (mConfiguration.bddStartBitIndexForVariable (lastVariableIndex COMMA_THERE), mConfiguration.bddBitCountForVariable (lastVariableIndex COMMA_THERE)) ; result.mConfiguration.deleteLastVariable (THERE) ; return result ; } //---------------------------------------------------------------------------------------------------------------------- C_Relation C_Relation::swap021 (LOCATION_ARGS) const { MF_AssertThere (variableCount () == 3, "C_Relation::swap021 error: variableCount () == %lld != 3", (int64_t) variableCount (), 0) ; const uint32_t bitCount0 = mConfiguration.bddBitCountForVariable (0 COMMA_THERE) ; const uint32_t bitCount1 = mConfiguration.bddBitCountForVariable (1 COMMA_THERE) ; const uint32_t bitCount2 = mConfiguration.bddBitCountForVariable (2 COMMA_THERE) ; const C_BDD result = mBDD.swap021 (bitCount0, bitCount1, bitCount2) ; const C_RelationConfiguration config = mConfiguration.swap021 (THERE) ; return C_Relation (config, result) ; } //---------------------------------------------------------------------------------------------------------------------- C_Relation C_Relation::swap102 (LOCATION_ARGS) const { MF_AssertThere (variableCount () == 3, "C_Relation::swap102 error: variableCount () == %lld != 3", (int64_t) variableCount (), 0) ; const uint32_t bitCount0 = mConfiguration.bddBitCountForVariable (0 COMMA_THERE) ; const uint32_t bitCount1 = mConfiguration.bddBitCountForVariable (1 COMMA_THERE) ; const uint32_t bitCount2 = mConfiguration.bddBitCountForVariable (2 COMMA_THERE) ; const C_BDD result = mBDD.swap102 (bitCount0, bitCount1, bitCount2) ; const C_RelationConfiguration config = mConfiguration.swap102 (THERE) ; return C_Relation (config, result) ; } //---------------------------------------------------------------------------------------------------------------------- C_Relation C_Relation::swap120 (LOCATION_ARGS) const { MF_AssertThere (variableCount () == 3, "C_Relation::swap120 error: variableCount () == %lld != 3", (int64_t) variableCount (), 0) ; const uint32_t bitCount0 = mConfiguration.bddBitCountForVariable (0 COMMA_THERE) ; const uint32_t bitCount1 = mConfiguration.bddBitCountForVariable (1 COMMA_THERE) ; const uint32_t bitCount2 = mConfiguration.bddBitCountForVariable (2 COMMA_THERE) ; const C_BDD result = mBDD.swap120 (bitCount0, bitCount1, bitCount2) ; const C_RelationConfiguration config = mConfiguration.swap120 (THERE) ; return C_Relation (config, result) ; } //---------------------------------------------------------------------------------------------------------------------- C_Relation C_Relation::swap201 (LOCATION_ARGS) const { MF_AssertThere (variableCount () == 3, "C_Relation::swap201 error: variableCount () == %lld != 3", (int64_t) variableCount (), 0) ; const uint32_t bitCount0 = mConfiguration.bddBitCountForVariable (0 COMMA_THERE) ; const uint32_t bitCount1 = mConfiguration.bddBitCountForVariable (1 COMMA_THERE) ; const uint32_t bitCount2 = mConfiguration.bddBitCountForVariable (2 COMMA_THERE) ; const C_BDD result = mBDD.swap201 (bitCount0, bitCount1, bitCount2) ; const C_RelationConfiguration config = mConfiguration.swap201 (THERE) ; return C_Relation (config, result) ; } //---------------------------------------------------------------------------------------------------------------------- C_Relation C_Relation::swap210 (LOCATION_ARGS) const { MF_AssertThere (variableCount () == 3, "C_Relation::swap210 error: variableCount () == %lld != 3", (int64_t) variableCount (), 0) ; const uint32_t bitCount0 = mConfiguration.bddBitCountForVariable (0 COMMA_THERE) ; const uint32_t bitCount1 = mConfiguration.bddBitCountForVariable (1 COMMA_THERE) ; const uint32_t bitCount2 = mConfiguration.bddBitCountForVariable (2 COMMA_THERE) ; const C_BDD result = mBDD.swap210 (bitCount0, bitCount1, bitCount2) ; const C_RelationConfiguration config = mConfiguration.swap210 (THERE) ; return C_Relation (config, result) ; } //---------------------------------------------------------------------------------------------------------------------- C_Relation C_Relation::exitsOnVariable (const int32_t inVariableIndex COMMA_LOCATION_ARGS) const { C_Relation result = *this ; const uint32_t bitIndex = mConfiguration.bddStartBitIndexForVariable (inVariableIndex COMMA_THERE) ; const uint32_t bit_count = mConfiguration.bddBitCountForVariable (inVariableIndex COMMA_THERE) ; result.mBDD = result.mBDD.existsOnBitRange (bitIndex, bit_count) ; return result ; } //---------------------------------------------------------------------------------------------------------------------- bool C_Relation::operator == (const C_Relation & inRelation) const { mConfiguration.checkIdenticalTo (inRelation.mConfiguration COMMA_HERE) ; return mBDD == inRelation.mBDD ; } //---------------------------------------------------------------------------------------------------------------------- bool C_Relation::operator != (const C_Relation & inRelation) const { mConfiguration.checkIdenticalTo (inRelation.mConfiguration COMMA_HERE) ; return mBDD != inRelation.mBDD ; } //---------------------------------------------------------------------------------------------------------------------- C_Relation C_Relation::transposedRelation (LOCATION_ARGS) const { MF_AssertThere (variableCount () == 2, "C_Relation::transposedRelation error: variableCount () == %lld != 2", (int64_t) variableCount (), 0) ; const uint32_t bitSize0 = mConfiguration.bddBitCountForVariable (0 COMMA_THERE) ; const uint32_t bitSize1 = mConfiguration.bddBitCountForVariable (1 COMMA_THERE) ; const uint32_t totalSize = (uint32_t) (bitSize0 + bitSize1) ; uint32_t * tab = NULL ; macroMyNewArray (tab, uint32_t, totalSize) ; for (uint32_t i=0 ; i<bitSize0 ; i++) { tab [i] = (uint32_t) (i + bitSize1) ; } for (uint32_t j=0 ; j<bitSize1 ; j++) { tab [j + bitSize0] = j ; } const C_BDD r = mBDD.substitution (tab, totalSize COMMA_HERE) ; macroMyDeleteArray (tab) ; //--- const C_String name0 = mConfiguration.nameForVariable (0 COMMA_HERE) ; const C_RelationSingleType type0 = mConfiguration.typeForVariable (0 COMMA_HERE) ; const C_String name1 = mConfiguration.nameForVariable (1 COMMA_HERE) ; const C_RelationSingleType type1 = mConfiguration.typeForVariable (1 COMMA_HERE) ; C_RelationConfiguration config ; config.addVariable (name1, type1) ; config.addVariable (name0, type0) ; return C_Relation (config, r) ; } //----------------------------------------------------------------------------------------------------------------------
/* Copyright (c) 2007-2017 by Jakob Schröter <js@camaya.net> This file is part of the gloox library. http://camaya.net/gloox This software is distributed under a license. The full license agreement can be found in the file LICENSE in this distribution. This software may not be copied, modified, sold or distributed other than expressed in the named license agreement. This software is distributed without any warranty. */ #include "featureneg.h" #include "dataform.h" #include "tag.h" namespace gloox { FeatureNeg::FeatureNeg( DataForm* form ) : StanzaExtension( ExtFeatureNeg ), m_form( form ) { } FeatureNeg::FeatureNeg( const Tag* tag ) : StanzaExtension( ExtFeatureNeg ), m_form( 0 ) { if( !tag || tag->name() != "feature" || tag->xmlns() != XMLNS_FEATURE_NEG ) return; const Tag* f = tag->findTag( "feature/x[@xmlns='" + XMLNS_X_DATA + "']" ); if( f ) m_form = new DataForm( f ); } FeatureNeg::~FeatureNeg() { delete m_form; } const std::string& FeatureNeg::filterString() const { static const std::string filter = "/message/feature[@xmlns='" + XMLNS_FEATURE_NEG + "']" "|/iq/feature[@xmlns='" + XMLNS_FEATURE_NEG + "']" ; return filter; } Tag* FeatureNeg::tag() const { if( !m_form ) return 0; Tag* t = new Tag( "feature" ); t->setXmlns( XMLNS_FEATURE_NEG ); t->addChild( m_form->tag() ); return t; } }
/* ******************************************************************************* * Copyright (c) 2020-2021, STMicroelectronics * All rights reserved. * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ******************************************************************************* */ #if defined(ARDUINO_GENERIC_L071KBTX) || defined(ARDUINO_GENERIC_L071KZTX) ||\ defined(ARDUINO_GENERIC_L081KZTX) #include "pins_arduino.h" // Digital PinName array const PinName digitalPin[] = { PA_0, // D0/A0 PA_1, // D1/A1 PA_2, // D2/A2 PA_3, // D3/A3 PA_4, // D4/A4 PA_5, // D5/A5 PA_6, // D6/A6 PA_7, // D7/A7 PA_8, // D8 PA_9, // D9 PA_10, // D10 PA_11, // D11 PA_12, // D12 PA_13, // D13 PA_14, // D14 PA_15, // D15 PB_0, // D16/A8 PB_1, // D17/A9 PB_3, // D18 PB_4, // D19 PB_5, // D20 PB_6, // D21 PB_7, // D22 PC_14, // D23 PC_15 // D24 }; // Analog (Ax) pin number array const uint32_t analogInputPin[] = { 0, // A0, PA0 1, // A1, PA1 2, // A2, PA2 3, // A3, PA3 4, // A4, PA4 5, // A5, PA5 6, // A6, PA6 7, // A7, PA7 16, // A8, PB0 17 // A9, PB1 }; #endif /* ARDUINO_GENERIC_* */
// // The MIT License(MIT) // // Copyright(c) 2014 Demonsaw LLC // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. #include "server_util.h" #include "component/function_component.h" #include "component/session_component.h" #include "component/error/error_component.h" #include "component/server/server_component.h" #include "component/server/server_machine_component.h" #include "component/server/server_option_component.h" #include "component/server/server_security_component.h" namespace eja { // Static mutex server_util::m_mutex; // Utility entity::ptr server_util::create() { const auto entity = eja::entity::create(); entity->add<server_component>(); entity->add<server_option_component>(); entity->add<server_security_component>(); entity->add<server_machine_component>(); entity->add<session_component>(); // Error entity->add<error_entity_vector_component>(); return entity; } entity::ptr server_util::create(const entity::ptr parent) { const auto entity = create(); entity->set_entity(parent); return entity; } }
// Example program #include <iostream> using namespace std; int main() { int n, m; cin >> n >> m; int *a = new int[m]; long long time = 0; int currentPos = 1; for(int i = 0; i < m; i++){ cin >> a[i]; } for(int i = 0; i < m; i++){ if( a[i] < currentPos){ time += n - currentPos + a[i]; currentPos = a[i]; } else{ time += a[i] - currentPos; currentPos = a[i]; } } cout << fixed <<time << endl; return 0; }
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #include <aws/s3-crt/model/LambdaFunctionConfiguration.h> #include <aws/core/utils/xml/XmlSerializer.h> #include <aws/core/utils/StringUtils.h> #include <aws/core/utils/memory/stl/AWSStringStream.h> #include <utility> using namespace Aws::Utils::Xml; using namespace Aws::Utils; namespace Aws { namespace S3Crt { namespace Model { LambdaFunctionConfiguration::LambdaFunctionConfiguration() : m_idHasBeenSet(false), m_lambdaFunctionArnHasBeenSet(false), m_eventsHasBeenSet(false), m_filterHasBeenSet(false) { } LambdaFunctionConfiguration::LambdaFunctionConfiguration(const XmlNode& xmlNode) : m_idHasBeenSet(false), m_lambdaFunctionArnHasBeenSet(false), m_eventsHasBeenSet(false), m_filterHasBeenSet(false) { *this = xmlNode; } LambdaFunctionConfiguration& LambdaFunctionConfiguration::operator =(const XmlNode& xmlNode) { XmlNode resultNode = xmlNode; if(!resultNode.IsNull()) { XmlNode idNode = resultNode.FirstChild("Id"); if(!idNode.IsNull()) { m_id = Aws::Utils::Xml::DecodeEscapedXmlText(idNode.GetText()); m_idHasBeenSet = true; } XmlNode lambdaFunctionArnNode = resultNode.FirstChild("CloudFunction"); if(!lambdaFunctionArnNode.IsNull()) { m_lambdaFunctionArn = Aws::Utils::Xml::DecodeEscapedXmlText(lambdaFunctionArnNode.GetText()); m_lambdaFunctionArnHasBeenSet = true; } XmlNode eventsNode = resultNode.FirstChild("Event"); if(!eventsNode.IsNull()) { XmlNode eventMember = eventsNode; while(!eventMember.IsNull()) { m_events.push_back(EventMapper::GetEventForName(StringUtils::Trim(eventMember.GetText().c_str()))); eventMember = eventMember.NextNode("Event"); } m_eventsHasBeenSet = true; } XmlNode filterNode = resultNode.FirstChild("Filter"); if(!filterNode.IsNull()) { m_filter = filterNode; m_filterHasBeenSet = true; } } return *this; } void LambdaFunctionConfiguration::AddToNode(XmlNode& parentNode) const { Aws::StringStream ss; if(m_idHasBeenSet) { XmlNode idNode = parentNode.CreateChildElement("Id"); idNode.SetText(m_id); } if(m_lambdaFunctionArnHasBeenSet) { XmlNode lambdaFunctionArnNode = parentNode.CreateChildElement("CloudFunction"); lambdaFunctionArnNode.SetText(m_lambdaFunctionArn); } if(m_eventsHasBeenSet) { for(const auto& item : m_events) { XmlNode eventsNode = parentNode.CreateChildElement("Event"); eventsNode.SetText(EventMapper::GetNameForEvent(item)); } } if(m_filterHasBeenSet) { XmlNode filterNode = parentNode.CreateChildElement("Filter"); m_filter.AddToNode(filterNode); } } } // namespace Model } // namespace S3Crt } // namespace Aws
#ifndef MYAWESOMEGAME_STATE_MANAGER_TRANSITION_HORIZONTAL_BARS_HPP #define MYAWESOMEGAME_STATE_MANAGER_TRANSITION_HORIZONTAL_BARS_HPP #include "shape.hpp" #include "state_manager_transition_impl.hpp" #include "vector.hpp" namespace jt { class StateManagerTransitionHorizontalBars : public StateManagerTransitionImpl { public: StateManagerTransitionHorizontalBars(Vector2f const& shapeSize, int numberOfShapes, float totalTime, TextureManagerInterface& tm); private: void doUpdate(float elapsed) override; void doStart() override; void doDraw(std::shared_ptr<jt::RenderTarget> rt) override; std::shared_ptr<jt::Shape> m_shape { nullptr }; int m_numberOfShapes { 0 }; }; } // namespace jt #endif // MYAWESOMEGAME_STATE_MANAGER_TRANSITION_HORIZONTAL_BARS_HPP
#include "randNumListGen.h" randNumListGen::randNumListGen() { } randNumListGen::~randNumListGen() { } std::vector<int> randNumListGen::getNumList() { return vInt; } std::vector<int> randomizedList(int numValues, int low, int high) { srand(time(NULL)); std::vector<int> vInt; int x; for (int i = 0; i < numValues; i++) { x = rand() % high + low; vInt.push_back(x); } std::cout << numValues << " of random numbers generated." << std::endl; return vInt; } template <typename _t> void writeVectToFile(std::vector<_t> vInt, std::string filename) { std::ofstream numFile; numFile.open(filename); for (std::vector<_t>::iterator vIt = vInt.begin(); vIt != vInt.end(); vIt++) { numFile << *vIt << "\n"; } numFile.close(); }
// Fill out your copyright notice in the Description page of Project Settings. // Parent #include "NT_PlayerController.h" // Unreal #include "GameFramework/PlayerState.h" #include "Interfaces/NetworkPredictionInterface.h" #include "GameFramework/PawnMovementComponent.h" // NT #include "NT_GameInstance.h" #include "Actors/Pawns/NT_Pawn.h" #include "Actors/Pawns/Characters/NT_Character.h" // Public ANT_PlayerController::ANT_PlayerController() { PrimaryActorTick.bCanEverTick = true; } // Protected void ANT_PlayerController::Local_FrameworkInitialized() { NetLog(TEXT("Received framework initialization.")); if (IsOwningClient()) { if (ServerSide()) { Server_SetOwningClient_FrameworkInitialized(); } else { ServerRPC_Reliable_NotifyFrameworkInit_OnOwningClient(); } } K2_Local_FrameworkInitialized(); } void ANT_PlayerController::PawnReady() { NetLog(TEXT("Player is ready.")); // Originally: Super::OnPossess(PawnToPossess); ChangeState(NAME_Playing); if (bAutoManageActiveCameraTarget) { AutoManageActiveCameraTarget(GetPawn()); ResetCameraMode(); } // End of Originally: Super::OnPossess(PawnToPossess); // Override this and add your own conditions... K2_PawnReady(); if (ServerSide() && IsOwningClient()) { // The server host doesn't have to wait for the player state to replicate. OwningClient_Ready(); } } void ANT_PlayerController::Client_ProcessPlayerState() { if (PlayerState != NULL) { OwningClient_Ready(); } } // This should ONLY occur if EVERYTHING is set to go brrrrr on the owning client side. NO IFS OR BUTS. void ANT_PlayerController::OwningClient_Ready() { NetLog(TEXT("Owning Client of controller is ready to play.")); if (IsOwningClient()) { // Do what you gotta do and go brrrrrrr (BP Side). K2_OwningClient_Ready(); // Not sure if I should do it client side.. //On_OwningClient_Ready.Broadcast(); ServerRPC_Reliable_NotifyOwningClient_Ready_Implementation(); } } void ANT_PlayerController::ServerRPC_Reliable_NotifyOwningClient_Ready_Implementation() { if (! ServerSide()) return; NetLog(TEXT("Owning Client Ready: Notified via RPC.")); On_OwningClient_Ready.Broadcast(); } void ANT_PlayerController::Server_SetOwningClient_FrameworkInitialized() { bOwningClient_FrameworkInitialized = true; On_OwningClient_PostLogin.Broadcast(this); } void ANT_PlayerController::ServerRPC_Reliable_NotifyFrameworkInit_OnOwningClient_Implementation() { if (! ServerSide()) return; Server_SetOwningClient_FrameworkInitialized(); } // APlayerController // Public bool ANT_PlayerController::CanRestartPlayer() { bool baseCheck = PlayerState && !PlayerState->IsOnlyASpectator() && HasClientLoadedCurrentWorld() && PendingSwapConnection == NULL ; return baseCheck && bOwningClient_FrameworkInitialized; } // AController void ANT_PlayerController::OnPossess(APawn* _pawnToPossess) { //Super::OnPossess(PawnToPossess); if ( _pawnToPossess != NULL && (PlayerState == NULL || !PlayerState->IsOnlyASpectator()) ) { // ====================================================================Originally: Super::OnPossess(PawnToPossess); const bool bNewPawn = (GetPawn() != _pawnToPossess); if (GetPawn() && bNewPawn) { UnPossess(); } if (_pawnToPossess->Controller != NULL) { _pawnToPossess->Controller->UnPossess(); } _pawnToPossess->PossessedBy(this); // update rotation to match possessed pawn's rotation SetControlRotation( _pawnToPossess->GetActorRotation() ); SetPawn(_pawnToPossess); check(GetPawn() != NULL); if (GetPawn() && GetPawn()->PrimaryActorTick.bStartWithTickEnabled) { GetPawn()->SetActorTickEnabled(true); } INetworkPredictionInterface* NetworkPredictionInterface = GetPawn() ? Cast<INetworkPredictionInterface>(GetPawn()->GetMovementComponent()) : NULL; if (NetworkPredictionInterface) { NetworkPredictionInterface->ResetPredictionData_Server(); } AcknowledgedPawn = NULL; // Local PCs will have the Restart() triggered right away in ClientRestart (via PawnClientRestart()), but the server should call Restart() locally for remote PCs. // We're really just trying to avoid calling Restart() multiple times. if (!IsLocalPlayerController()) { GetPawn()->Restart(); } ClientRestart(GetPawn()); //==========================================================End of=================== Originally: Super::OnPossess(PawnToPossess); NetLog(TEXT("OnPossess")); if (ServerSide()) { if (_pawnToPossess->IsA(ANT_Pawn::StaticClass())) { Cast<ANT_Pawn>(_pawnToPossess)->On_PawnReady.AddDynamic(this, &ANT_PlayerController::PawnReady); } else if (_pawnToPossess->IsA(ANT_Character::StaticClass())) { Cast<ANT_Character>(_pawnToPossess)->On_PawnReady.AddDynamic(this, &ANT_PlayerController::PawnReady); } On_PawnPossessed.Broadcast(); } } } // AActor // Public void ANT_PlayerController::BeginPlay() { Super::BeginPlay(); NetLog(TEXT("BeginPlay")); UNT_GameInstance* gInst = GetGameInstance<UNT_GameInstance>(); gInst->On_Framework_Initialized.AddDynamic(this, &ANT_PlayerController::Local_FrameworkInitialized); gInst->Local_NotifyComponentReady(EFramework_ComponentFlag::PlayerController); } void ANT_PlayerController::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const { Super::GetLifetimeReplicatedProps(OutLifetimeProps); DOREPLIFETIME(ANT_PlayerController, bOwningClient_FrameworkInitialized); }
/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2020 Aerll - aerlldev@gmail.com // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this softwareand associated documentation files(the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and /or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright noticeand this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. // #ifndef RPP_ERRORQUEUE_HPP #define RPP_ERRORQUEUE_HPP #include <memory> #include <queue> #include <utility.hpp> #include <error.hpp> class ErrorQueue { protected: ErrorQueue() = default; ErrorQueue(const ErrorQueue&) = delete; ErrorQueue& operator=(const ErrorQueue&) = delete; public: virtual ~ErrorQueue() = default; protected: void pushError(std::unique_ptr<Error>&& err) { m_errors.push(std::move(err)); ++m_count; } bool hasErrors() const { return !m_errors.empty(); } void resetCount() noexcept { m_count = 0; } uint32_t totalCount() const noexcept { return m_count; } void printErrors(uint32_t lineWidth); protected: std::queue<std::unique_ptr<Error>> m_errors; uint32_t m_count; }; #endif // RPP_ERRORQUEUE_HPP
#include "FileSplitter.h" #include "FileMerger.h" #include <iostream> using namespace external_sort; int main(int argc, const char* argv[]) { if (argc < 3) { std::cout << "Not enough parameters. Example usage: external_sort file_for_sort.txt sorted.txt\n"; return -1; } try { FileSplitter splitter(argv[1]); FileWrapper outFile(argv[2], false); static_assert(MAX_SORTED_SIZE > 0, "Limit size of part of file can't be zero"); static_assert(MAX_SORTED_SIZE <= 1024, "Limit size of part of file too big"); #ifdef DEBUG_MERGE const auto partSize = 300; #else const auto partSize = MAX_SORTED_SIZE * 1024L * 1024L; #endif std::cout << "Start file " << argv[1] << " splitting...\n"; splitter.Split(partSize, [&outFile, &argv](FileSplitter::SplitIterator begin, FileSplitter::SplitIterator end) { std::cout << "Start merge files to destination " << argv[2] << std::endl; MergeSortedTo(begin, end, outFile); }); std::cout << "Finished\n"; return 0; } catch(const std::exception& error) { std::cout << "Error: " << error.what() << std::flush; return -1; } }
#include "color.h" Color::Color() { this->_color = 0; this->s_color = "none"; } Color::Color(Uint32 color) { this->_color = color; this->s_color = "none"; } Color::Color(string color) { this->_color = 0; this->s_color = color; calc(color); } void Color::calc(string color) { const int size = color.size(); if (color[0] != '#' || (size != 7 && size != 9)) { std::cout << "Error parse '" << color << "' as hex color" << std::endl; return; } this->_color = parseColorHexString(color); } Uint32 Color::parseColorHexString(string color) { Uint32 result = 0; for (size_t i = 1; i < color.size(); i++) { char symbol = tolower(color[i]); int value = 0; if (symbol >= '0' && symbol <= '9') { value = symbol - '0'; } else if (symbol >= 'a' && symbol <= 'f') { value = symbol - 'a' + 10; } result += value * (Uint32)(pow(16, (7 - (i-1)))); } if (color.size() == 7) { result |= 0x000000ff; } return result; } bool Color::operator==(const Color& obj) { return _color == obj._color && s_color == obj.s_color; } Uint32 Color::color() { return _color; } SDL_Color Color::colorSDL() const { Uint8* c = (Uint8*)&_color; const SDL_Color sdl_color = { c[3], c[2], c[1], c[0] }; return sdl_color; } Uint8 Color::r() { Uint8* c = (Uint8*)& _color; return c[3]; } Uint8 Color::g() { Uint8* c = (Uint8*)& _color; return c[2]; } Uint8 Color::b() { Uint8* c = (Uint8*)& _color; return c[1]; } Uint8 Color::a() { Uint8* c = (Uint8*)& _color; return c[0]; }
#include "io.hpp" #include "boost/filesystem.hpp" #include "google/protobuf/text_format.h" #include "google/protobuf/util/json_util.h" #include "fmt/format.h" namespace is { namespace fs = boost::filesystem; namespace gio = google::protobuf::io; void load(std::string const& filename, google::protobuf::Message* message) { auto path = fs::path{filename}; auto file = std::ifstream{filename}; if (!file.is_open()) { throw std::runtime_error{fmt::format("Failed to open file {}", filename)}; } std::string buffer((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>()); auto extension = path.extension().string(); if (extension == ".json") { auto status = google::protobuf::util::JsonStringToMessage(buffer, message); if (!status.ok()) { throw std::runtime_error{status.ToString()}; } return; } if (extension == ".prototxt") { auto ok = google::protobuf::TextFormat::ParseFromString(buffer, message); if (!ok) { throw std::runtime_error{"Failed to parse prototxt"}; } return; } throw std::runtime_error{fmt::format("Invalid file format '{}'", extension)}; } void save(std::string const& filename, google::protobuf::Message const& message) { std::string data; auto path = fs::path{filename}; auto extension = path.extension().string(); if (extension == ".json") { google::protobuf::util::JsonPrintOptions options; options.add_whitespace = true; options.always_print_primitive_fields = true; google::protobuf::util::MessageToJsonString(message, &data, options); } else if (extension == ".prototxt") { google::protobuf::TextFormat::PrintToString(message, &data); } else { throw std::runtime_error{fmt::format("Invalid file format '{}'", extension)}; } auto parent_path = path.parent_path(); boost::system::error_code error; if (!parent_path.string().empty()) { fs::create_directories(path.parent_path(), error); } if (error) { throw std::runtime_error{fmt::format("Failed to create directories '{}': {}", parent_path.string(), error.message())}; } auto file = std::ofstream{filename}; if (!file.is_open()) { throw std::runtime_error{fmt::format("Failed to open file {}", filename)}; } file << data; file.close(); } ProtobufWriter::ProtobufWriter(std::string const& filename) : raw_output(nullptr) { file.open(filename, std::ios::out | std::ios::binary); if (file.fail()) { throw std::runtime_error{fmt::format("Failed to open file \'{}\'", filename)}; } raw_output = new gio::OstreamOutputStream(&file); } ProtobufWriter::~ProtobufWriter() { close(); } void ProtobufWriter::insert(google::protobuf::Message const& message) { auto size = message.ByteSize(); // We create a new coded stream for each message. Don't worry, this is fast. google::protobuf::io::CodedOutputStream coded_output(raw_output); coded_output.WriteVarint32(size); uint8_t* buffer = coded_output.GetDirectBufferForNBytesAndAdvance(size); if (buffer != nullptr) { // Optimization: The message fits in one buffer, so use the faster // direct-to-array serialization path. message.SerializeWithCachedSizesToArray(buffer); } else { // Slightly-slower path when the message is multiple buffers. message.SerializeWithCachedSizes(&coded_output); if (coded_output.HadError()) { throw std::runtime_error{"Can not write serialized message on buffer."}; } } } void ProtobufWriter::close() { if (raw_output != nullptr) { delete raw_output; raw_output = nullptr; } if (file.is_open()) { file.close(); } } ProtobufReader::ProtobufReader(std::string const& filename) : raw_input(nullptr) { file.open(filename, std::ios::in | std::ios::binary); if (file.fail()) { throw std::runtime_error{fmt::format("Failed to open file \'{}\'", filename)}; } raw_input = new gio::IstreamInputStream(&file); } ProtobufReader::~ProtobufReader() { close(); } bool ProtobufReader::next(google::protobuf::Message* message) { // We create a new coded stream for each message. Don't worry, this is fast, // and it makes sure the 64MB total size limit is imposed per-message rather // than on the whole stream. (See the CodedInputStream interface for more // info on this limit.) google::protobuf::io::CodedInputStream coded_input(raw_input); uint32_t size; if (!coded_input.ReadVarint32(&size)) { return false; } // Tell the stream not to read beyond that size. google::protobuf::io::CodedInputStream::Limit msg_limit = coded_input.PushLimit(size); if (!message->MergeFromCodedStream(&coded_input)) { throw std::runtime_error("Can't deserialize message"); } else if (!coded_input.ConsumedEntireMessage()) { throw std::runtime_error("Failed to consume message"); } // Release the limit coded_input.PopLimit(msg_limit); return true; } void ProtobufReader::close() { if (raw_input != nullptr) { delete raw_input; raw_input = nullptr; } if (file.is_open()) { file.close(); } } } // namespace is
/* * This file is open source software, licensed to you under the terms * of the Apache License, Version 2.0 (the "License"). See the NOTICE file * distributed with this work for additional information regarding copyright * ownership. You may not use this file except in compliance with the License. * * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /* * Copyright (C) 2015 Cloudius Systems, Ltd. */ #include <algorithm> #include <iostream> #include "core/reactor.hh" #include "core/fstream.hh" #include "core/shared_ptr.hh" #include "core/app-template.hh" #include "core/do_with.hh" #include "core/seastar.hh" #include "test-utils.hh" struct writer { output_stream<char> out; writer(file f) : out(make_file_output_stream(std::move(f))) {} }; struct reader { input_stream<char> in; reader(file f) : in(make_file_input_stream(std::move(f))) {} }; SEASTAR_TEST_CASE(test_fstream) { auto sem = make_lw_shared<semaphore>(0); engine().open_file_dma("testfile.tmp", open_flags::rw | open_flags::create | open_flags::truncate).then([sem] (file f) { auto w = make_shared<writer>(std::move(f)); auto buf = static_cast<char*>(::malloc(4096)); memset(buf, 0, 4096); buf[0] = '['; buf[1] = 'A'; buf[4095] = ']'; w->out.write(buf, 4096).then([buf, w] { ::free(buf); return make_ready_future<>(); }).then([w] { auto buf = static_cast<char*>(::malloc(8192)); memset(buf, 0, 8192); buf[0] = '['; buf[1] = 'B'; buf[8191] = ']'; return w->out.write(buf, 8192).then([buf, w] { ::free(buf); return w->out.close().then([w] {}); }); }).then([] { return engine().open_file_dma("testfile.tmp", open_flags::ro); }).then([] (file f) { /* file content after running the above: * 00000000 5b 41 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |[A..............| * 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * * * 00000ff0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5d |...............]| * 00001000 5b 42 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |[B..............| * 00001010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * * * 00002ff0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5d |...............]| * 00003000 */ auto r = make_shared<reader>(std::move(f)); return r->in.read_exactly(4096 + 8192).then([r] (temporary_buffer<char> buf) { auto p = buf.get(); BOOST_REQUIRE(p[0] == '[' && p[1] == 'A' && p[4095] == ']'); BOOST_REQUIRE(p[4096] == '[' && p[4096 + 1] == 'B' && p[4096 + 8191] == ']'); return make_ready_future<>(); }).then([r] { return r->in.close(); }).finally([r] {}); }).finally([sem] () { sem->signal(); }); }); return sem->wait(); } SEASTAR_TEST_CASE(test_fstream_unaligned) { auto sem = make_lw_shared<semaphore>(0); engine().open_file_dma("testfile.tmp", open_flags::rw | open_flags::create | open_flags::truncate).then([sem] (file f) { auto w = make_shared<writer>(std::move(f)); auto buf = static_cast<char*>(::malloc(40)); memset(buf, 0, 40); buf[0] = '['; buf[1] = 'A'; buf[39] = ']'; w->out.write(buf, 40).then([buf, w] { ::free(buf); return w->out.close().then([w] {}); }).then([] { return engine().open_file_dma("testfile.tmp", open_flags::ro); }).then([] (file f) { return do_with(std::move(f), [] (file& f) { return f.size().then([] (size_t size) { // assert that file was indeed truncated to the amount of bytes written. BOOST_REQUIRE(size == 40); return make_ready_future<>(); }); }); }).then([] { return engine().open_file_dma("testfile.tmp", open_flags::ro); }).then([] (file f) { auto r = make_shared<reader>(std::move(f)); return r->in.read_exactly(40).then([r] (temporary_buffer<char> buf) { auto p = buf.get(); BOOST_REQUIRE(p[0] == '[' && p[1] == 'A' && p[39] == ']'); return make_ready_future<>(); }).then([r] { return r->in.close(); }).finally([r] {}); }).finally([sem] () { sem->signal(); }); }); return sem->wait(); } future<> test_consume_until_end(uint64_t size) { return open_file_dma("testfile.tmp", open_flags::rw | open_flags::create | open_flags::truncate).then([size] (file f) { return do_with(make_file_output_stream(f), [size] (output_stream<char>& out) { std::vector<char> buf(size); std::iota(buf.begin(), buf.end(), 0); return out.write(buf.data(), buf.size()).then([&out] { return out.flush(); }); }).then([f] { return f.size(); }).then([size, f] (size_t real_size) { BOOST_REQUIRE_EQUAL(size, real_size); }).then([size, f] { auto consumer = [offset = uint64_t(0), size] (temporary_buffer<char> buf) mutable -> future<input_stream<char>::unconsumed_remainder> { if (!buf) { return make_ready_future<input_stream<char>::unconsumed_remainder>(temporary_buffer<char>()); } BOOST_REQUIRE(offset + buf.size() <= size); std::vector<char> expected(buf.size()); std::iota(expected.begin(), expected.end(), offset); offset += buf.size(); BOOST_REQUIRE(std::equal(buf.begin(), buf.end(), expected.begin())); return make_ready_future<input_stream<char>::unconsumed_remainder>(std::experimental::nullopt); }; return do_with(make_file_input_stream(f), std::move(consumer), [size] (input_stream<char>& in, auto& consumer) { return in.consume(consumer).then([&in] { return in.close(); }); }); }); }); } SEASTAR_TEST_CASE(test_consume_aligned_file) { return test_consume_until_end(4096); } SEASTAR_TEST_CASE(test_consume_empty_file) { return test_consume_until_end(0); } SEASTAR_TEST_CASE(test_consume_unaligned_file) { return test_consume_until_end(1); } SEASTAR_TEST_CASE(test_consume_unaligned_file_large) { return test_consume_until_end((1 << 20) + 1); }
// // DetectorExample_XENON10.hh // // Added by Quentin Riffard, September 10, 2021 // // This header file is a preliminary attempt to add a G3 detector // to be used for sensitivity and projection studies. // // Note: Parameters here are subject to change based on future // performance studies // #ifndef NEST_DETECTOR_G3_HH #define NEST_DETECTOR_G3_HH #include "VDetector.hh" using namespace std; class Detector_G3 : public VDetector { public: Detector_G3() { cerr << "You are currently using the projected G3 detector." << endl << endl; // Call the initialisation of all the parameters Initialization(); } ~Detector_G3() override = default; void Initialization() override { // Primary Scintillation (S1) parameters g1 = 0.118735; // phd per S1 phot at dtCntr (not phe). Divide out 2-PE // effect sPEres = 0.38; // single phe resolution (Gaussian assumed) sPEthr = 0.375; // POD threshold in phe, usually used IN PLACE of sPEeff sPEeff = 1.0; // actual efficiency, can be used in lieu of POD threshold noiseBaseline[0] = 0.0; // baseline noise mean and width in PE (Gaussian) noiseBaseline[1] = 0.0; // baseline noise mean and width in PE (Gaussian) noiseBaseline[2] = 0.0; noiseBaseline[3] = 0.0; P_dphe = 0.2; // chance 1 photon makes 2 phe instead of 1 in Hamamatsu PMT coinWind = 150; // S1 coincidence window in ns coinLevel = 3; // how many PMTs have to fire for an S1 to count numPMTs = 494; // For coincidence calculation // Ionization and Secondary Scintillation (S2) parameters g1_gas = 0.1018; // phd per S2 photon in gas, used to get SE size s2Fano = 2.0; // Fano-like fudge factor for SE width s2_thr = 470. * (1.0 + P_dphe); // the S2 threshold in phe or PE, *not* phd. Affects NR most E_gas = 10.821; // field in kV/cm between liquid/gas border and anode eLife_us = 850.; // the drift electron mean lifetime in micro-seconds // Thermodynamic Properties inGas = false; T_Kelvin = 177.; // for liquid drift speed calculation p_bar = 2.14; // gas pressure in units of bars, it controls S2 size // if you are getting warnings about being in gas, lower T and/or raise p // Data Analysis Parameters and Geometry dtCntr = 505.123; // center of detector for S1 corrections, in usec. dt_min = 0.01; // minimum. Top of detector fiducial volume dt_max = 894.74; // maximum. Bottom of detector fiducial volume radius = 728.; // millimeters (fiducial rad) radmax = 728.; // actual physical geo. limit TopDrift = 1461.; // mm not cm or us (but, this *is* where dt=0) // a z-axis value of 0 means the bottom of the detector (cathode OR bottom // PMTs) // In 2-phase, TopDrift=liquid/gas border. In gas detector it's GATE, not // anode! anode = 1469. - 0.2568; // the level of the anode grid-wire plane in mm // In a gas TPC, this is not TopDrift (top of drift region), but a few mm // above it gate = 1456.; // mm. This is where the E-field changes (higher) // in gas detectors, the gate is still the gate, but it's where S2 starts cathode = 0.; // mm. Defines point below which events are gamma-X // 2-D (X & Y) Position Reconstruction PosResExp = 0.015; // exp increase in pos recon res at hi r, 1/mm PosResBase = 70.8364; // baseline unc in mm, see NEST.cpp for usage OldW13eV = true; noiseLinear[0] = 0; noiseLinear[1] = 0; } // S1 PDE custom fit for function of z // s1polA + s1polB*z[mm] + s1polC*z^2+... (QE included, for binom dist) e.g. double FitS1(double xPos_mm, double yPos_mm, double zPos_mm, LCE map) override { return 1.; // No S1 corrections } // Drift electric field as function of Z in mm // For example, use a high-order poly spline double FitEF(double xPos_mm, double yPos_mm, double zPos_mm) override { // in V/cm return 180.; // Simple uniform field } // S2 PDE custom fit for function of r // s2polA + s2polB*r[mm] + s2polC*r^2+... (QE included, for binom dist) e.g. double FitS2(double xPos_mm, double yPos_mm, LCE map) override { return 1.; // No S2 corrections } vector<double> FitTBA(double xPos_mm, double yPos_mm, double zPos_mm) override { vector<double> BotTotRat(2); BotTotRat[0] = 0.6; // S1 bottom-to-total ratio BotTotRat[1] = 0.4; // S2 bottom-to-total ratio, typically only used for // position recon (1-this) return BotTotRat; } double OptTrans(double xPos_mm, double yPos_mm, double zPos_mm) override { double phoTravT, approxCenter = (TopDrift + cathode) / 2., relativeZ = zPos_mm - approxCenter; double A = 0.048467 - 7.6386e-6 * relativeZ + 1.2016e-6 * pow(relativeZ, 2.) - 6.0833e-9 * pow(relativeZ, 3.); if (A < 0.) A = 0.; // cannot have negative probability double B_a = 0.99373 + 0.0010309 * relativeZ - 2.5788e-6 * pow(relativeZ, 2.) - 1.2000e-8 * pow(relativeZ, 3.); double B_b = 1. - B_a; double tau_a = 11.15; // all times in nanoseconds double tau_b = 4.5093 + 0.03437 * relativeZ - 0.00018406 * pow(relativeZ, 2.) - 1.6383e-6 * pow(relativeZ, 3.); if (tau_b < 0.) tau_b = 0.; // cannot have negative time // A = 0.0574; B_a = 1.062; tau_a = 11.1; tau_b = 2.70; B_b = 1.0 - B_a; // //LUX D-D conditions if (RandomGen::rndm()->rand_uniform() < A) phoTravT = 0.; // direct travel time to PMTs (low) else { // using P0(t) = // A*delta(t)+(1-A)*[(B_a/tau_a)e^(-t/tau_a)+(B_b/tau_b)e^(-t/tau_b)] // LUX PSD paper, but should apply to all detectors w/ diff #'s if (RandomGen::rndm()->rand_uniform() < B_a) phoTravT = -tau_a * log(RandomGen::rndm()->rand_uniform()); else phoTravT = -tau_b * log(RandomGen::rndm()->rand_uniform()); } double sig = RandomGen::rndm()->rand_gauss( 3.84, .09); // includes stat unc but not syst phoTravT += RandomGen::rndm()->rand_gauss( 0.00, sig); // the overall width added to photon time spectra by the // effects in the electronics and the data reduction // pipeline if (phoTravT > DBL_MAX) phoTravT = tau_a; if (phoTravT < -DBL_MAX) phoTravT = 0.000; return phoTravT; // this function follows LUX (arXiv:1802.06162) not Xe10 // technically but tried to make general } vector<double> SinglePEWaveForm(double area, double t0) override { vector<double> PEperBin; double threshold = PULSEHEIGHT; // photo-electrons double sigma = PULSE_WIDTH; // ns area *= 10. * (1. + threshold); double amplitude = area / (sigma * sqrt(2. * M_PI)), signal; // assumes perfect Gaussian double tStep1 = SAMPLE_SIZE / 1e2; // ns, make sure much smaller than // sample size; used to generate MC-true // pulses essentially double tStep2 = SAMPLE_SIZE; // ns; 1 over digitization rate, 100 MHz assumed here double time = -5. * sigma; bool digitizeMe = false; while (true) { signal = amplitude * exp(-pow(time, 2.) / (2. * sigma * sigma)); if (signal < threshold) { if (digitizeMe) break; else ; // do nothing - goes down to advancing time block } else { if (digitizeMe) PEperBin.push_back(signal); else { if (RandomGen::rndm()->rand_uniform() < 2. * (tStep1 / tStep2)) { PEperBin.push_back(time + t0); PEperBin.push_back(signal); digitizeMe = true; } else { } } } if (digitizeMe) time += tStep2; else time += tStep1; if (time > 5. * sigma) break; } return PEperBin; } }; #endif // NEST_DETECTOR_G3_HH
/* * Xml.cpp * * Created on: Feb 5, 2013 * Author: leo */ #include <fruitpunch/Resources/Xml.h> #include <fruitpunch/Common/Node.h> #include <pugixml.hpp> using namespace fp_core::common; namespace fp_core { namespace resources { Xml::Xml() : NodeResource() { // TODO Auto-generated constructor stub } Xml::~Xml() { // TODO Auto-generated destructor stub } void Xml::load(std::string fullPath) { pugi::xml_document doc; pugi::xml_parse_result result = doc.load_file(fullPath.c_str()); mRoot = this->makeNode(doc.root().first_child()); } boost::shared_ptr<fp_core::common::Node> Xml::getRoot() { return mRoot; } boost::shared_ptr<fp_core::common::Node> Xml::makeNode(const pugi::xml_node& node) { boost::shared_ptr<Node> result(new Node()); // ------------------------------------------------------------------------ // Set Node name based on its type // ------------------------------------------------------------------------ switch (node.type()) { case pugi::node_cdata: result->setName("@cdata"); break; case pugi::node_comment: result->setName("@comment"); break; default: result->setName(node.name()); break; } result->setValue(node.value()); // ------------------------------------------------------------------------ // Attributes // ------------------------------------------------------------------------ pugi::xml_attribute_iterator it = node.attributes_begin(); boost::shared_ptr<Node> attributes(new Node()); attributes->setName("@attributes"); for (; it != node.attributes_end(); it++) { boost::shared_ptr<Node> attrNode(new Node()); attrNode->setName(it->name()); attrNode->setValue(it->value()); attributes->add(attrNode); } result->add(attributes); // ------------------------------------------------------------------------ // Children // ------------------------------------------------------------------------ pugi::xml_node_iterator nit = node.children().begin(); for (; nit != node.children().end(); nit++) { result->add(makeNode(*nit)); } return result; } } /* namespace common */ } /* namespace fp_core */
#include "quad.h" #include "texture2d.h" #include <glm/gtc/type_ptr.hpp> namespace { constexpr GLubyte *bufferOffset(size_t bytes) { return static_cast<GLubyte *>(0) + bytes; } } Quad::Quad() : vertexArrayObject(0) , vertexBufferObject(0) { } Quad::~Quad() { destruct(); } void Quad::construct(int size) { construct(size, size); } void Quad::construct(int width, int height) { construct(width, height, glm::vec3{1.0f, 1.0f, 1.0f}); } void Quad::construct(int width, int height, const glm::vec3 &color) { construct(width, height, color, color, color, color); } void Quad::construct(int width, int height, Texture2D *texture) { construct(width, height, glm::vec3{1.0f, 1.0f, 1.0f}); if (vertexBufferObject) { textureObject = texture; } } struct vertex { GLfloat x, y, z; GLfloat r, g, b; GLfloat u, v; }; void Quad::construct(int width, int height, const glm::vec3 &topLeftColor, const glm::vec3 &topRightColor, const glm::vec3 &bottomLeftColor, const glm::vec3 &bottomRightColor) { destruct(); glGenVertexArrays(1, &vertexArrayObject); glBindVertexArray(vertexArrayObject); vertex vertices[] = { { width * -0.5f, height * -0.5f, 0.0f, bottomLeftColor.r, bottomLeftColor.g, bottomLeftColor.b, 0.0f, 0.0f }, { width * 0.5f, height * -0.5f, 0.0f, bottomRightColor.r, bottomRightColor.g, bottomRightColor.b, 1.0f, 0.0f }, { width * -0.5f, height * 0.5f, 0.0f, topLeftColor.r, topLeftColor.g, topLeftColor.b, 0.0f, 1.0f }, { width * -0.5f, height * 0.5f, 0.0f, topLeftColor.r, topLeftColor.g, topLeftColor.b, 0.0f, 1.0f }, { width * 0.5f, height * -0.5f, 0.0f, bottomRightColor.r, bottomRightColor.g, bottomRightColor.b, 1.0f, 0.0f }, { width * 0.5f, height * 0.5f, 0.0f, topRightColor.r, topRightColor.g, topRightColor.b, 1.0f, 1.0f } }; glGenBuffers(1, &vertexBufferObject); glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObject); glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); } void Quad::destruct() { if (vertexBufferObject) { glDeleteBuffers(1, &vertexBufferObject); } if (vertexArrayObject) { glDeleteVertexArrays(1, &vertexArrayObject); } textureObject = nullptr; } void Quad::draw(const ProgramIndices &indices, const glm::mat4 &modelViewProjection) { glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObject); if (indices.vertexIndex >= 0) { glVertexAttribPointer(indices.vertexIndex, 3, GL_FLOAT, GL_FALSE, sizeof(vertex), bufferOffset(0)); glEnableVertexAttribArray(indices.vertexIndex); } if (indices.colorIndex >= 0) { glVertexAttribPointer(indices.colorIndex, 3, GL_FLOAT, GL_FALSE, sizeof(vertex), bufferOffset(sizeof(GLfloat) * 3)); glEnableVertexAttribArray(indices.colorIndex); } if (indices.uvIndex >= 0) { glVertexAttribPointer(indices.uvIndex, 2, GL_FLOAT, GL_FALSE, sizeof(vertex), bufferOffset(sizeof(GLfloat) * 6)); glEnableVertexAttribArray(indices.uvIndex); } const int textureSamplerIndex = 0; if (textureObject && indices.textureIndex >= 0) { glActiveTexture(GL_TEXTURE0 + textureSamplerIndex); textureObject->bind(); glUniform1i(indices.textureIndex, textureSamplerIndex); } glUniformMatrix4fv(indices.modelViewProjectionIndex, 1, GL_FALSE, glm::value_ptr(modelViewProjection)); glDrawArrays(GL_TRIANGLES, 0, Quad::NumVertices); if (textureObject && indices.textureIndex >= 0) { glActiveTexture(GL_TEXTURE0 + textureSamplerIndex); textureObject->unbind(); glActiveTexture(GL_TEXTURE0); } glBindBuffer(GL_ARRAY_BUFFER, 0); }
//================================================================================================= /*! // \file src/mathtest/dmatdmatadd/MHaMUb.cpp // \brief Source file for the MHaMUb dense matrix/dense matrix addition math test // // Copyright (C) 2012-2019 Klaus Iglberger - All Rights Reserved // // This file is part of the Blaze library. You can redistribute it and/or modify it under // the terms of the New (Revised) BSD License. Redistribution and use in source and binary // forms, with or without modification, are permitted provided that the following conditions // are met: // // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright notice, this list // of conditions and the following disclaimer in the documentation and/or other materials // provided with the distribution. // 3. Neither the names of the Blaze development group nor the names of its contributors // may be used to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT // SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR // BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. */ //================================================================================================= //************************************************************************************************* // Includes //************************************************************************************************* #include <cstdlib> #include <iostream> #include <blaze/math/HybridMatrix.h> #include <blaze/math/UniformMatrix.h> #include <blazetest/mathtest/Creator.h> #include <blazetest/mathtest/dmatdmatadd/OperationTest.h> #include <blazetest/system/MathTest.h> #ifdef BLAZE_USE_HPX_THREADS # include <hpx/hpx_main.hpp> #endif //================================================================================================= // // MAIN FUNCTION // //================================================================================================= //************************************************************************************************* int main() { std::cout << " Running 'MHaMUb'..." << std::endl; using blazetest::mathtest::TypeA; using blazetest::mathtest::TypeB; try { // Matrix type definitions using MHa = blaze::HybridMatrix<TypeA,128UL,128UL>; using MUb = blaze::UniformMatrix<TypeB>; // Creator type definitions using CMHa = blazetest::Creator<MHa>; using CMUb = blazetest::Creator<MUb>; // Running tests with small matrices for( size_t i=0UL; i<=9UL; ++i ) { for( size_t j=0UL; j<=9UL; ++j ) { RUN_DMATDMATADD_OPERATION_TEST( CMHa( i, j ), CMUb( i, j ) ); } } // Running tests with large matrices RUN_DMATDMATADD_OPERATION_TEST( CMHa( 67UL, 67UL ), CMUb( 67UL, 67UL ) ); RUN_DMATDMATADD_OPERATION_TEST( CMHa( 67UL, 127UL ), CMUb( 67UL, 127UL ) ); RUN_DMATDMATADD_OPERATION_TEST( CMHa( 128UL, 64UL ), CMUb( 128UL, 64UL ) ); RUN_DMATDMATADD_OPERATION_TEST( CMHa( 128UL, 128UL ), CMUb( 128UL, 128UL ) ); } catch( std::exception& ex ) { std::cerr << "\n\n ERROR DETECTED during dense matrix/dense matrix addition:\n" << ex.what() << "\n"; return EXIT_FAILURE; } return EXIT_SUCCESS; } //*************************************************************************************************
#include "TestTrackHits.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h" #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h" #include "TrackingTools/MaterialEffects/interface/PropagatorWithMaterial.h" #include "TrackingTools/TrackFitters/interface/TrajectoryStateCombiner.h" #include <TDirectory.h> #include "DataFormats/TrackerCommon/interface/TrackerTopology.h" #include "Geometry/Records/interface/TrackerTopologyRcd.h" #include "DataFormats/BeamSpot/interface/BeamSpot.h" typedef TrajectoryStateOnSurface TSOS; typedef TransientTrackingRecHit::ConstRecHitPointer CTTRHp; using namespace std; using namespace edm; TestTrackHits::TestTrackHits(const edm::ParameterSet& iConfig) : trackerHitAssociatorConfig_(consumesCollector()) { LogTrace("TestTrackHits") << iConfig; propagatorName = iConfig.getParameter<std::string>("Propagator"); builderName = iConfig.getParameter<std::string>("TTRHBuilder"); srcName = iConfig.getParameter<std::string>("src"); tpName = iConfig.getParameter<std::string>("tpname"); updatorName = iConfig.getParameter<std::string>("updator"); out = iConfig.getParameter<std::string>("out"); theGToken = esConsumes<edm::Transition::BeginRun>(); theMFToken = esConsumes<edm::Transition::BeginRun>(); thePropagatorToken = esConsumes<edm::Transition::BeginRun>(edm::ESInputTag("", propagatorName)); theBuilderToken = esConsumes<edm::Transition::BeginRun>(edm::ESInputTag("", builderName)); theUpdatorToken = esConsumes<edm::Transition::BeginRun>(edm::ESInputTag("", updatorName)); theTopoToken = esConsumes(); // ParameterSet cuts = iConfig.getParameter<ParameterSet>("RecoTracksCuts"); // selectRecoTracks = RecoTrackSelector(cuts.getParameter<double>("ptMin"), // cuts.getParameter<double>("minRapidity"), // cuts.getParameter<double>("maxRapidity"), // cuts.getParameter<double>("tip"), // cuts.getParameter<double>("lip"), // cuts.getParameter<int>("minHit"), // cuts.getParameter<double>("maxChi2")); } TestTrackHits::~TestTrackHits() {} void TestTrackHits::beginRun(edm::Run const& run, const edm::EventSetup& iSetup) { theG = iSetup.getHandle(theGToken); theMF = iSetup.getHandle(theMFToken); thePropagator = iSetup.getHandle(thePropagatorToken); theBuilder = iSetup.getHandle(theBuilderToken); theUpdator = iSetup.getHandle(theUpdatorToken); file = new TFile(out.c_str(), "recreate"); for (int i = 0; i != 6; i++) for (int j = 0; j != 9; j++) { if (i == 0 && j > 2) break; if (i == 1 && j > 1) break; if (i == 2 && j > 3) break; if (i == 3 && j > 2) break; if (i == 4 && j > 5) break; if (i == 5 && j > 8) break; title.str(""); title << "Chi2Increment_" << i + 1 << "-" << j + 1; hChi2Increment[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, 0, 100); title.str(""); title << "Chi2IncrementVsEta_" << i + 1 << "-" << j + 1; hChi2IncrementVsEta[title.str()] = new TH2F(title.str().c_str(), title.str().c_str(), 50, -2.5, 2.5, 1000, 0, 100); title.str(""); title << "Chi2GoodHit_" << i + 1 << "-" << j + 1; hChi2GoodHit[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, 0, 100); title.str(""); title << "Chi2BadHit_" << i + 1 << "-" << j + 1; hChi2BadHit[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, 0, 100); title.str(""); title << "Chi2DeltaHit_" << i + 1 << "-" << j + 1; hChi2DeltaHit[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, 0, 100); title.str(""); title << "Chi2NSharedHit_" << i + 1 << "-" << j + 1; hChi2NSharedHit[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, 0, 100); title.str(""); title << "Chi2SharedHit_" << i + 1 << "-" << j + 1; hChi2SharedHit[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, 0, 100); title.str(""); title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_ts"; hPullGP_X_ts[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50); title.str(""); title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_ts"; hPullGP_Y_ts[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50); title.str(""); title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_ts"; hPullGP_Z_ts[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50); title.str(""); title << "PullGM_X_" << i + 1 << "-" << j + 1 << "_ts"; hPullGM_X_ts[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50); title.str(""); title << "PullGM_Y_" << i + 1 << "-" << j + 1 << "_ts"; hPullGM_Y_ts[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50); title.str(""); title << "PullGM_Z_" << i + 1 << "-" << j + 1 << "_ts"; hPullGM_Z_ts[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50); title.str(""); title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_tr"; hPullGP_X_tr[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50); title.str(""); title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_tr"; hPullGP_Y_tr[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50); title.str(""); title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_tr"; hPullGP_Z_tr[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50); title.str(""); title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_rs"; hPullGP_X_rs[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50); title.str(""); title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_rs"; hPullGP_Y_rs[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50); title.str(""); title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_rs"; hPullGP_Z_rs[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50); if (((i == 2 || i == 4) && (j == 0 || j == 1)) || (i == 3 || i == 5)) { //mono title.str(""); title << "Chi2Increment_mono_" << i + 1 << "-" << j + 1; hChi2Increment_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, 0, 100); title.str(""); title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_ts_mono"; hPullGP_X_ts_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50); title.str(""); title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_ts_mono"; hPullGP_Y_ts_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50); title.str(""); title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_ts_mono"; hPullGP_Z_ts_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50); title.str(""); title << "PullGM_X_" << i + 1 << "-" << j + 1 << "_ts_mono"; hPullGM_X_ts_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50); title.str(""); title << "PullGM_Y_" << i + 1 << "-" << j + 1 << "_ts_mono"; hPullGM_Y_ts_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50); title.str(""); title << "PullGM_Z_" << i + 1 << "-" << j + 1 << "_ts_mono"; hPullGM_Z_ts_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50); title.str(""); title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_tr_mono"; hPullGP_X_tr_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50); title.str(""); title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_tr_mono"; hPullGP_Y_tr_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50); title.str(""); title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_tr_mono"; hPullGP_Z_tr_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50); title.str(""); title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_rs_mono"; hPullGP_X_rs_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50); title.str(""); title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_rs_mono"; hPullGP_Y_rs_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50); title.str(""); title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_rs_mono"; hPullGP_Z_rs_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50); //stereo title.str(""); title << "Chi2Increment_stereo_" << i + 1 << "-" << j + 1; hChi2Increment_stereo[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, 0, 100); title.str(""); title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_ts_stereo"; hPullGP_X_ts_stereo[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50); title.str(""); title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_ts_stereo"; hPullGP_Y_ts_stereo[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50); title.str(""); title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_ts_stereo"; hPullGP_Z_ts_stereo[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50); title.str(""); title << "PullGM_X_" << i + 1 << "-" << j + 1 << "_ts_stereo"; hPullGM_X_ts_stereo[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50); title.str(""); title << "PullGM_Y_" << i + 1 << "-" << j + 1 << "_ts_stereo"; hPullGM_Y_ts_stereo[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50); title.str(""); title << "PullGM_Z_" << i + 1 << "-" << j + 1 << "_ts_stereo"; hPullGM_Z_ts_stereo[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50); title.str(""); title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_tr_stereo"; hPullGP_X_tr_stereo[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50); title.str(""); title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_tr_stereo"; hPullGP_Y_tr_stereo[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50); title.str(""); title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_tr_stereo"; hPullGP_Z_tr_stereo[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50); title.str(""); title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_rs_stereo"; hPullGP_X_rs_stereo[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50); title.str(""); title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_rs_stereo"; hPullGP_Y_rs_stereo[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50); title.str(""); title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_rs_stereo"; hPullGP_Z_rs_stereo[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50); } } hTotChi2Increment = new TH1F("TotChi2Increment", "TotChi2Increment", 1000, 0, 100); hTotChi2GoodHit = new TH1F("TotChi2GoodHit", "TotChi2GoodHit", 1000, 0, 100); hTotChi2BadHit = new TH1F("TotChi2BadHit", "TotChi2BadHit", 1000, 0, 100); hTotChi2DeltaHit = new TH1F("TotChi2DeltaHit", "TotChi2DeltaHit", 1000, 0, 100); hTotChi2NSharedHit = new TH1F("TotChi2NSharedHit", "TotChi2NSharedHit", 1000, 0, 100); hTotChi2SharedHit = new TH1F("TotChi2SharedHit", "TotChi2SharedHit", 1000, 0, 100); hProcess_vs_Chi2 = new TH2F("Process_vs_Chi2", "Process_vs_Chi2", 1000, 0, 100, 17, -0.5, 16.5); hClsize_vs_Chi2 = new TH2F("Clsize_vs_Chi2", "Clsize_vs_Chi2", 1000, 0, 100, 17, -0.5, 16.5); hPixClsize_vs_Chi2 = new TH2F("PixClsize_vs_Chi2", "PixClsize_vs_Chi2", 1000, 0, 100, 17, -0.5, 16.5); hPrjClsize_vs_Chi2 = new TH2F("PrjClsize_vs_Chi2", "PrjClsize_vs_Chi2", 1000, 0, 100, 17, -0.5, 16.5); hSt1Clsize_vs_Chi2 = new TH2F("St1Clsize_vs_Chi2", "St1Clsize_vs_Chi2", 1000, 0, 100, 17, -0.5, 16.5); hSt2Clsize_vs_Chi2 = new TH2F("St2Clsize_vs_Chi2", "St2Clsize_vs_Chi2", 1000, 0, 100, 17, -0.5, 16.5); hGoodHit_vs_Chi2 = new TH2F("GoodHit_vs_Chi2", "GoodHit_vs_Chi2", 10000, 0, 1000, 2, -0.5, 1.5); hClusterSize = new TH1F("ClusterSize", "ClusterSize", 40, -0.5, 39.5); hPixClusterSize = new TH1F("PixClusterSize", "PixClusterSize", 40, -0.5, 39.5); hPrjClusterSize = new TH1F("PrjClusterSize", "PrjClusterSize", 40, -0.5, 39.5); hSt1ClusterSize = new TH1F("St1ClusterSize", "St1ClusterSize", 40, -0.5, 39.5); hSt2ClusterSize = new TH1F("St2ClusterSize", "St2ClusterSize", 40, -0.5, 39.5); hSimHitVecSize = new TH1F("hSimHitVecSize", "hSimHitVecSize", 40, -0.5, 39.5); hPixSimHitVecSize = new TH1F("PixSimHitVecSize", "PixSimHitVecSize", 40, -0.5, 39.5); hPrjSimHitVecSize = new TH1F("PrjSimHitVecSize", "PrjSimHitVecSize", 40, -0.5, 39.5); hSt1SimHitVecSize = new TH1F("St1SimHitVecSize", "St1SimHitVecSize", 40, -0.5, 39.5); hSt2SimHitVecSize = new TH1F("St2SimHitVecSize", "St2SimHitVecSize", 40, -0.5, 39.5); goodbadmerged = new TH1F("goodbadmerged", "goodbadmerged", 5, 0.5, 5.5); energyLossRatio = new TH1F("energyLossRatio", "energyLossRatio", 100, 0, 1); mergedPull = new TH1F("mergedPull", "mergedPull", 200, 0, 20); probXgood = new TH1F("probXgood", "probXgood", 110, 0, 1.1); probXbad = new TH1F("probXbad", "probXbad", 110, 0, 1.1); probXdelta = new TH1F("probXdelta", "probXdelta", 110, 0, 1.1); probXshared = new TH1F("probXshared", "probXshared", 110, 0, 1.1); probXnoshare = new TH1F("probXnoshare", "probXnoshare", 110, 0, 1.1); probYgood = new TH1F("probYgood", "probYgood", 110, 0, 1.1); probYbad = new TH1F("probYbad", "probYbad", 110, 0, 1.1); probYdelta = new TH1F("probYdelta", "probYdelta", 110, 0, 1.1); probYshared = new TH1F("probYshared", "probYshared", 110, 0, 1.1); probYnoshare = new TH1F("probYnoshare", "probYnoshare", 110, 0, 1.1); } void TestTrackHits::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { //Retrieve tracker topology from geometry edm::ESHandle<TrackerTopology> tTopo = iSetup.getHandle(theTopoToken); LogDebug("TestTrackHits") << "new event"; iEvent.getByLabel(srcName, trajCollectionHandle); iEvent.getByLabel(srcName, trackCollectionHandle); iEvent.getByLabel(srcName, trajTrackAssociationCollectionHandle); iEvent.getByLabel(tpName, trackingParticleCollectionHandle); edm::Handle<reco::BeamSpot> beamSpot; iEvent.getByLabel("offlineBeamSpot", beamSpot); LogTrace("TestTrackHits") << "Tr collection size=" << trackCollectionHandle->size(); LogTrace("TestTrackHits") << "TP collection size=" << trackingParticleCollectionHandle->size(); iEvent.getByLabel("trackAssociatorByHits", trackAssociator); TrackerHitAssociator hitAssociator(iEvent, trackerHitAssociatorConfig_); reco::RecoToSimCollection recSimColl = trackAssociator->associateRecoToSim(trackCollectionHandle, trackingParticleCollectionHandle); TrajectoryStateCombiner combiner; int evtHits = 0; int i = 0; int yy = 0; int yyy = 0; for (std::vector<Trajectory>::const_iterator it = trajCollectionHandle->begin(); it != trajCollectionHandle->end(); it++) { LogTrace("TestTrackHits") << "\n*****************new trajectory********************"; double tchi2 = 0; std::vector<TrajectoryMeasurement> tmColl = it->measurements(); edm::Ref<std::vector<Trajectory> > traj(trajCollectionHandle, i); reco::TrackRef tmptrack = (*trajTrackAssociationCollectionHandle.product())[traj]; edm::RefToBase<reco::Track> track(tmptrack); // if ( !selectRecoTracks( *track,beamSpot.product() ) ) { // LogTrace("TestTrackHits") << "track does not pass quality cuts: skippingtrack #" << ++yyy; // i++; // continue; // } std::vector<std::pair<TrackingParticleRef, double> > tP; if (recSimColl.find(track) != recSimColl.end()) { tP = recSimColl[track]; if (!tP.empty()) { edm::LogVerbatim("TestTrackHits") << "reco::Track #" << ++yyy << " with pt=" << track->pt() << " associated with quality:" << tP.begin()->second << " good track #" << ++yy << " has hits:" << track->numberOfValidHits() << "\n"; } } else { edm::LogVerbatim("TestTrackHits") << "reco::Track #" << ++yyy << " with pt=" << track->pt() << " NOT associated to any TrackingParticle" << "\n"; i++; continue; } // if(recSimColl.find(track) != recSimColl.end()) { // tP = recSimColl[track]; // } else { // LogTrace("TestTrackHits") << "fake track: skipping track " << ++yyy; // continue;//skip fake tracks // } // if (tP.size()==0) { // LogTrace("TestTrackHits") << "fake track: skipping track " << ++yyy; // continue; // } TrackingParticleRef tp = tP.begin()->first; LogTrace("TestTrackHits") << "a tp is associated with fraction=" << tP.begin()->second; //LogTrace("TestTrackHits") << "last tp is associated with fraction=" << (tP.end()-1)->second; std::vector<unsigned int> tpids; for (TrackingParticle::g4t_iterator g4T = tp->g4Track_begin(); g4T != tp->g4Track_end(); ++g4T) { LogTrace("TestTrackHits") << "tp id=" << g4T->trackId(); tpids.push_back(g4T->trackId()); } //LogTrace("TestTrackHits") << "Analyzing hits of track number " << ++yyy << " good track number " << ++yy; int pp = 0; for (std::vector<TrajectoryMeasurement>::iterator tm = tmColl.begin(); tm != tmColl.end(); ++tm) { tchi2 += tm->estimate(); LogTrace("TestTrackHits") << "+++++++++++++++++new hit+++++++++++++++++"; CTTRHp rhit = tm->recHit(); //TSOS state = tm->backwardPredictedState(); //TSOS state = tm->forwardPredictedState(); TSOS state = combiner(tm->backwardPredictedState(), tm->forwardPredictedState()); if (rhit->isValid() == 0 && rhit->det() != nullptr) continue; evtHits++; LogTrace("TestTrackHits") << "valid hit #" << ++pp << "of hits=" << track->numberOfValidHits(); int subdetId = rhit->det()->geographicalId().subdetId(); DetId id = rhit->det()->geographicalId(); int layerId = tTopo->layer(id); LogTrace("TestTrackHits") << "subdetId=" << subdetId << " layerId=" << layerId; const Surface* surf = rhit->surface(); if (surf == nullptr) continue; double energyLoss_ = 0.; unsigned int monoId = 0; std::vector<double> energyLossM; std::vector<double> energyLossS; std::vector<PSimHit> assSimHits = hitAssociator.associateHit(*(rhit)->hit()); unsigned int simhitvecsize = assSimHits.size(); if (simhitvecsize == 0) continue; PSimHit shit; std::vector<unsigned int> trackIds; energyLossS.clear(); energyLossM.clear(); for (std::vector<PSimHit>::const_iterator m = assSimHits.begin(); m < assSimHits.end(); m++) { unsigned int tId = m->trackId(); if (find(trackIds.begin(), trackIds.end(), tId) == trackIds.end()) trackIds.push_back(tId); if (m->energyLoss() > energyLoss_) { shit = *m; energyLoss_ = m->energyLoss(); } if (dynamic_cast<const SiStripMatchedRecHit2D*>(rhit->hit())) { if (monoId == 0) monoId = m->detUnitId(); if (monoId == m->detUnitId()) { energyLossM.push_back(m->energyLoss()); } else { energyLossS.push_back(m->energyLoss()); } //std::cout << "detUnitId=" << m->detUnitId() << " trackId=" << m->trackId() << " energyLoss=" << m->energyLoss() << std::endl; } else { energyLossM.push_back(m->energyLoss()); } } //double delta = 99999; //LocalPoint rhitLPv = rhit->localPosition(); //vector<PSimHit> assSimHits = hitAssociator.associateHit(*(rhit)->hit()); //unsigned int simhitvecsize = assSimHits.size(); //if (simhitvecsize==0) continue; //PSimHit shit; //for(std::vector<PSimHit>::const_iterator m=assSimHits.begin(); m<assSimHits.end(); m++){ // if ((m->localPosition()-rhitLPv).mag()<delta) { // shit=*m; // delta = (m->localPosition()-rhitLPv).mag(); // } //} //plot chi2 increment double chi2increment = tm->estimate(); LogTrace("TestTrackHits") << "tm->estimate()=" << tm->estimate(); title.str(""); title << "Chi2Increment_" << subdetId << "-" << layerId; hChi2Increment[title.str()]->Fill(chi2increment); title.str(""); title << "Chi2IncrementVsEta_" << subdetId << "-" << layerId; hChi2IncrementVsEta[title.str()]->Fill(track->eta(), chi2increment); hTotChi2Increment->Fill(chi2increment); hProcess_vs_Chi2->Fill(chi2increment, shit.processType()); int clustersize = 0; bool mergedhit = false; if (dynamic_cast<const SiPixelRecHit*>(rhit->hit())) { clustersize = ((const SiPixelRecHit*)(rhit->hit()))->cluster()->size(); hPixClsize_vs_Chi2->Fill(chi2increment, clustersize); hPixClusterSize->Fill(clustersize); hPixSimHitVecSize->Fill(simhitvecsize); if (simhitvecsize > 1) mergedhit = true; } else if (dynamic_cast<const SiStripRecHit2D*>(rhit->hit())) { clustersize = ((const SiStripRecHit2D*)(rhit->hit()))->cluster()->amplitudes().size(); hSt1Clsize_vs_Chi2->Fill(chi2increment, clustersize); hSt1ClusterSize->Fill(clustersize); hSt1SimHitVecSize->Fill(simhitvecsize); if (simhitvecsize > 1) mergedhit = true; } else if (dynamic_cast<const SiStripMatchedRecHit2D*>(rhit->hit())) { int clsize1 = ((const SiStripMatchedRecHit2D*)(rhit->hit()))->monoCluster().amplitudes().size(); int clsize2 = ((const SiStripMatchedRecHit2D*)(rhit->hit()))->stereoCluster().amplitudes().size(); if (clsize1 > clsize2) clustersize = clsize1; else clustersize = clsize2; hSt2Clsize_vs_Chi2->Fill(chi2increment, clustersize); hSt2ClusterSize->Fill(clustersize); hSt2SimHitVecSize->Fill(simhitvecsize); if (simhitvecsize > 2) mergedhit = true; } else if (dynamic_cast<const ProjectedSiStripRecHit2D*>(rhit->hit())) { clustersize = ((const ProjectedSiStripRecHit2D*)(rhit->hit()))->originalHit().cluster()->amplitudes().size(); hPrjClsize_vs_Chi2->Fill(chi2increment, clustersize); hPrjClusterSize->Fill(clustersize); hPrjSimHitVecSize->Fill(simhitvecsize); if (simhitvecsize > 1) mergedhit = true; } hClsize_vs_Chi2->Fill(chi2increment, clustersize); hClusterSize->Fill(clustersize); hSimHitVecSize->Fill(simhitvecsize); // if (dynamic_cast<const SiPixelRecHit*>(rhit->hit())) // hClsize_vs_Chi2->Fill( chi2increment, ((const SiPixelRecHit*)(rhit->hit()))->cluster()->size() ); // if (dynamic_cast<const SiStripRecHit2D*>(rhit->hit())) // hClsize_vs_Chi2->Fill( chi2increment, ((const SiStripRecHit2D*)(rhit->hit()))->cluster()->amplitudes().size() ); std::vector<SimHitIdpr> simTrackIds = hitAssociator.associateHitId(*(rhit)->hit()); bool goodhit = false; for (size_t j = 0; j < simTrackIds.size(); j++) { LogTrace("TestTrackHits") << "hit id=" << simTrackIds[j].first; for (size_t jj = 0; jj < tpids.size(); jj++) { if (simTrackIds[j].first == tpids[jj]) goodhit = true; break; } } bool shared = true; bool ioniOnly = true; const SiPixelRecHit* pix = dynamic_cast<const SiPixelRecHit*>(rhit->hit()); if (goodhit) { if (energyLossM.size() > 1 && energyLossS.size() <= 1) { sort(energyLossM.begin(), energyLossM.end(), greater<double>()); energyLossRatio->Fill(energyLossM[1] / energyLossM[0]); } else if (energyLossS.size() > 1 && energyLossM.size() <= 1) { sort(energyLossS.begin(), energyLossS.end(), greater<double>()); energyLossRatio->Fill(energyLossS[1] / energyLossS[0]); } else if (energyLossS.size() > 1 && energyLossM.size() > 1) { sort(energyLossM.begin(), energyLossM.end(), greater<double>()); sort(energyLossS.begin(), energyLossS.end(), greater<double>()); energyLossM[1] / energyLossM[0] > energyLossS[1] / energyLossS[0] ? energyLossRatio->Fill(energyLossM[1] / energyLossM[0]) : energyLossRatio->Fill(energyLossS[1] / energyLossS[0]); } if (mergedhit) { //not optimized for matched hits LogVerbatim("TestTrackHits") << "MERGED HIT" << std::endl; unsigned int idc = 0; for (size_t jj = 0; jj < tpids.size(); jj++) { idc += std::count(trackIds.begin(), trackIds.end(), tpids[jj]); } if (idc == trackIds.size()) { shared = false; } for (std::vector<PSimHit>::const_iterator m = assSimHits.begin() + 1; m < assSimHits.end(); m++) { if ((m->processType() != 7 && m->processType() != 8 && m->processType() != 9) && abs(m->particleType()) != 11) { ioniOnly = false; break; } } if (ioniOnly && !shared) { title.str(""); title << "Chi2DeltaHit_" << subdetId << "-" << layerId; hChi2DeltaHit[title.str()]->Fill(chi2increment); hTotChi2DeltaHit->Fill(chi2increment); if (pix) { probXdelta->Fill(pix->probabilityX()); probYdelta->Fill(pix->probabilityY()); } } else if (!ioniOnly && !shared) { title.str(""); title << "Chi2NSharedHit_" << subdetId << "-" << layerId; hChi2NSharedHit[title.str()]->Fill(chi2increment); hTotChi2NSharedHit->Fill(chi2increment); if (pix) { probXnoshare->Fill(pix->probabilityX()); probYnoshare->Fill(pix->probabilityY()); } } else { title.str(""); title << "Chi2SharedHit_" << subdetId << "-" << layerId; hChi2SharedHit[title.str()]->Fill(chi2increment); hTotChi2SharedHit->Fill(chi2increment); if (pix) { probXshared->Fill(pix->probabilityX()); probYshared->Fill(pix->probabilityY()); } } for (std::vector<PSimHit>::const_iterator m = assSimHits.begin(); m < assSimHits.end(); m++) { unsigned int tId = m->trackId(); LogVerbatim("TestTrackHits") << "component with id=" << tId << " eLoss=" << m->energyLoss() << " pType=" << m->processType(); if (find(tpids.begin(), tpids.end(), tId) == tpids.end()) continue; if (m->processType() == 2) { GlobalPoint gpr = rhit->globalPosition(); AlgebraicSymMatrix33 ger = rhit->globalPositionError().matrix(); GlobalPoint gps = surf->toGlobal(m->localPosition()); LogVerbatim("TestTrackHits") << gpr << " " << gps << " " << ger; ROOT::Math::SVector<double, 3> delta; delta[0] = gpr.x() - gps.x(); delta[1] = gpr.y() - gps.y(); delta[2] = gpr.z() - gps.z(); LogVerbatim("TestTrackHits") << delta << " " << ger; double mpull = sqrt(delta[0] * delta[0] / ger[0][0] + delta[1] * delta[1] / ger[1][1] + delta[2] * delta[2] / ger[2][2]); LogVerbatim("TestTrackHits") << "hit pull=" << mpull; //ger.similarity(delta); mergedPull->Fill(mpull); break; } } } else { LogVerbatim("TestTrackHits") << "good hit"; title.str(""); title << "Chi2GoodHit_" << subdetId << "-" << layerId; hChi2GoodHit[title.str()]->Fill(chi2increment); hTotChi2GoodHit->Fill(chi2increment); if (pix) { probXgood->Fill(pix->probabilityX()); probYgood->Fill(pix->probabilityY()); } } } else { LogVerbatim("TestTrackHits") << "bad hit"; title.str(""); title << "Chi2BadHit_" << subdetId << "-" << layerId; hChi2BadHit[title.str()]->Fill(chi2increment); hTotChi2BadHit->Fill(chi2increment); goodbadmerged->Fill(2); if (pix) { probXbad->Fill(pix->probabilityX()); probYbad->Fill(pix->probabilityY()); } } hGoodHit_vs_Chi2->Fill(chi2increment, goodhit); LocalVector shitLMom; LocalPoint shitLPos; if (dynamic_cast<const SiStripMatchedRecHit2D*>(rhit->hit())) { if (simhitvecsize > 2 && goodhit) { if (ioniOnly && !shared) goodbadmerged->Fill(3); else if (!ioniOnly && !shared) goodbadmerged->Fill(4); else goodbadmerged->Fill(5); } else if (goodhit) goodbadmerged->Fill(1); double rechitmatchedx = rhit->localPosition().x(); double rechitmatchedy = rhit->localPosition().y(); double mindist = 999999; float distx, disty; std::pair<LocalPoint, LocalVector> closestPair; const StripGeomDetUnit* stripDet = (StripGeomDetUnit*)((const GluedGeomDet*)(rhit)->det())->stereoDet(); const BoundPlane& plane = (rhit)->det()->surface(); for (std::vector<PSimHit>::const_iterator m = assSimHits.begin(); m < assSimHits.end(); m++) { //project simhit; std::pair<LocalPoint, LocalVector> hitPair = projectHit((*m), stripDet, plane); distx = fabs(rechitmatchedx - hitPair.first.x()); disty = fabs(rechitmatchedy - hitPair.first.y()); double dist = distx * distx + disty * disty; if (sqrt(dist) < mindist) { mindist = dist; closestPair = hitPair; } } shitLPos = closestPair.first; shitLMom = closestPair.second; } else { if (simhitvecsize > 1 && goodhit) { if (ioniOnly && !shared) goodbadmerged->Fill(3); else if (!ioniOnly && !shared) goodbadmerged->Fill(4); else goodbadmerged->Fill(5); } else if (goodhit) goodbadmerged->Fill(1); shitLPos = shit.localPosition(); shitLMom = shit.momentumAtEntry(); } GlobalVector shitGMom = surf->toGlobal(shitLMom); GlobalPoint shitGPos = surf->toGlobal(shitLPos); GlobalVector tsosGMom = state.globalMomentum(); GlobalError tsosGMEr(state.cartesianError().matrix().Sub<AlgebraicSymMatrix33>(3, 3)); GlobalPoint tsosGPos = state.globalPosition(); GlobalError tsosGPEr = state.cartesianError().position(); GlobalPoint rhitGPos = (rhit)->globalPosition(); GlobalError rhitGPEr = (rhit)->globalPositionError(); LogVerbatim("TestTrackHits") << "assSimHits.size()=" << assSimHits.size(); LogVerbatim("TestTrackHits") << "tsos globalPos =" << tsosGPos; LogVerbatim("TestTrackHits") << "sim hit globalPos=" << shitGPos; LogVerbatim("TestTrackHits") << "rec hit globalPos=" << rhitGPos; LogVerbatim("TestTrackHits") << "geographicalId =" << rhit->det()->geographicalId().rawId(); LogVerbatim("TestTrackHits") << "surface position =" << surf->position(); #if 0 if (rhit->detUnit()) LogTrace("TestTrackHits") << "rhit->detUnit()->geographicalId()=" << rhit->detUnit()->geographicalId().rawId() ; LogTrace("TestTrackHits") << "rhit->det()->surface().position()=" << rhit->det()->surface().position() ; if (rhit->detUnit()) LogTrace("TestTrackHits") << "rhit->detUnit()->surface().position()=" << rhit->detUnit()->surface().position() ; LogTrace("TestTrackHits") << "rhit->det()->position()=" << rhit->det()->position() ; if (rhit->detUnit()) LogTrace("TestTrackHits") << "rhit->detUnit()->position()=" << rhit->detUnit()->position() ; LogTrace("TestTrackHits") << "rhit->det()->surface().bounds().length()=" << rhit->det()->surface().bounds().length() ; if (rhit->detUnit()) LogTrace("TestTrackHits") << "rhit->detUnit()->surface().bounds().length()=" << rhit->detUnit()->surface().bounds().length() ; LogTrace("TestTrackHits") << "rhit->det()->surface().bounds().width()=" << rhit->det()->surface().bounds().width() ; if (rhit->detUnit()) LogTrace("TestTrackHits") << "rhit->detUnit()->surface().bounds().width()=" << rhit->detUnit()->surface().bounds().width() ; LogTrace("TestTrackHits") << "rhit->det()->surface().bounds().thickness()=" << rhit->det()->surface().bounds().thickness() ; if (rhit->detUnit()) LogTrace("TestTrackHits") << "rhit->detUnit()->surface().bounds().thickness()=" << rhit->detUnit()->surface().bounds().thickness() ; #endif double pullGPX_rs = (rhitGPos.x() - shitGPos.x()) / sqrt(rhitGPEr.cxx()); double pullGPY_rs = (rhitGPos.y() - shitGPos.y()) / sqrt(rhitGPEr.cyy()); double pullGPZ_rs = (rhitGPos.z() - shitGPos.z()) / sqrt(rhitGPEr.czz()); //double pullGPX_rs = (rhitGPos.x()-shitGPos.x()); //double pullGPY_rs = (rhitGPos.y()-shitGPos.y()); //double pullGPZ_rs = (rhitGPos.z()-shitGPos.z()); LogTrace("TestTrackHits") << "rs"; title.str(""); title << "PullGP_X_" << subdetId << "-" << layerId << "_rs"; hPullGP_X_rs[title.str()]->Fill(pullGPX_rs); title.str(""); title << "PullGP_Y_" << subdetId << "-" << layerId << "_rs"; hPullGP_Y_rs[title.str()]->Fill(pullGPY_rs); title.str(""); title << "PullGP_Z_" << subdetId << "-" << layerId << "_rs"; hPullGP_Z_rs[title.str()]->Fill(pullGPZ_rs); double pullGPX_tr = (tsosGPos.x() - rhitGPos.x()) / sqrt(tsosGPEr.cxx() + rhitGPEr.cxx()); double pullGPY_tr = (tsosGPos.y() - rhitGPos.y()) / sqrt(tsosGPEr.cyy() + rhitGPEr.cyy()); double pullGPZ_tr = (tsosGPos.z() - rhitGPos.z()) / sqrt(tsosGPEr.czz() + rhitGPEr.czz()); //double pullGPX_tr = (tsosGPos.x()-rhitGPos.x()); //double pullGPY_tr = (tsosGPos.y()-rhitGPos.y()); //double pullGPZ_tr = (tsosGPos.z()-rhitGPos.z()); LogTrace("TestTrackHits") << "tr"; title.str(""); title << "PullGP_X_" << subdetId << "-" << layerId << "_tr"; hPullGP_X_tr[title.str()]->Fill(pullGPX_tr); title.str(""); title << "PullGP_Y_" << subdetId << "-" << layerId << "_tr"; hPullGP_Y_tr[title.str()]->Fill(pullGPY_tr); title.str(""); title << "PullGP_Z_" << subdetId << "-" << layerId << "_tr"; hPullGP_Z_tr[title.str()]->Fill(pullGPZ_tr); double pullGPX_ts = (tsosGPos.x() - shitGPos.x()) / sqrt(tsosGPEr.cxx()); double pullGPY_ts = (tsosGPos.y() - shitGPos.y()) / sqrt(tsosGPEr.cyy()); double pullGPZ_ts = (tsosGPos.z() - shitGPos.z()) / sqrt(tsosGPEr.czz()); //double pullGPX_ts = (tsosGPos.x()-shitGPos.x()); //double pullGPY_ts = (tsosGPos.y()-shitGPos.y()); //double pullGPZ_ts = (tsosGPos.z()-shitGPos.z()); LogTrace("TestTrackHits") << "ts1"; title.str(""); title << "PullGP_X_" << subdetId << "-" << layerId << "_ts"; hPullGP_X_ts[title.str()]->Fill(pullGPX_ts); title.str(""); title << "PullGP_Y_" << subdetId << "-" << layerId << "_ts"; hPullGP_Y_ts[title.str()]->Fill(pullGPY_ts); title.str(""); title << "PullGP_Z_" << subdetId << "-" << layerId << "_ts"; hPullGP_Z_ts[title.str()]->Fill(pullGPZ_ts); double pullGMX_ts = (tsosGMom.x() - shitGMom.x()) / sqrt(tsosGMEr.cxx()); double pullGMY_ts = (tsosGMom.y() - shitGMom.y()) / sqrt(tsosGMEr.cyy()); double pullGMZ_ts = (tsosGMom.z() - shitGMom.z()) / sqrt(tsosGMEr.czz()); //double pullGMX_ts = (tsosGMom.x()-shitGMom.x()); //double pullGMY_ts = (tsosGMom.y()-shitGMom.y()); //double pullGMZ_ts = (tsosGMom.z()-shitGMom.z()); LogTrace("TestTrackHits") << "ts2"; title.str(""); title << "PullGM_X_" << subdetId << "-" << layerId << "_ts"; hPullGM_X_ts[title.str()]->Fill(pullGMX_ts); title.str(""); title << "PullGM_Y_" << subdetId << "-" << layerId << "_ts"; hPullGM_Y_ts[title.str()]->Fill(pullGMY_ts); title.str(""); title << "PullGM_Z_" << subdetId << "-" << layerId << "_ts"; hPullGM_Z_ts[title.str()]->Fill(pullGMZ_ts); if (dynamic_cast<const SiStripMatchedRecHit2D*>(rhit->hit())) { Propagator* thePropagatorAnyDir = new PropagatorWithMaterial(anyDirection, 0.105, theMF.product(), 1.6); //mono LogTrace("TestTrackHits") << "MONO HIT"; auto m = dynamic_cast<const SiStripMatchedRecHit2D*>(rhit->hit())->monoHit(); CTTRHp tMonoHit = theBuilder->build(&m); if (tMonoHit == nullptr) continue; vector<PSimHit> assMonoSimHits = hitAssociator.associateHit(*tMonoHit->hit()); if (assMonoSimHits.empty()) continue; const PSimHit sMonoHit = *(assMonoSimHits.begin()); const Surface* monoSurf = &(tMonoHit->det()->surface()); if (monoSurf == nullptr) continue; TSOS monoState = thePropagatorAnyDir->propagate(state, *monoSurf); if (monoState.isValid() == 0) continue; LocalVector monoShitLMom = sMonoHit.momentumAtEntry(); GlobalVector monoShitGMom = monoSurf->toGlobal(monoShitLMom); LocalPoint monoShitLPos = sMonoHit.localPosition(); GlobalPoint monoShitGPos = monoSurf->toGlobal(monoShitLPos); //LogTrace("TestTrackHits") << "assMonoSimHits.size()=" << assMonoSimHits.size() ; //LogTrace("TestTrackHits") << "mono shit=" << monoShitGPos ; GlobalVector monoTsosGMom = monoState.globalMomentum(); GlobalError monoTsosGMEr(monoState.cartesianError().matrix().Sub<AlgebraicSymMatrix33>(3, 3)); GlobalPoint monoTsosGPos = monoState.globalPosition(); GlobalError monoTsosGPEr = monoState.cartesianError().position(); GlobalPoint monoRhitGPos = tMonoHit->globalPosition(); GlobalError monoRhitGPEr = tMonoHit->globalPositionError(); double pullGPX_rs_mono = (monoRhitGPos.x() - monoShitGPos.x()) / sqrt(monoRhitGPEr.cxx()); double pullGPY_rs_mono = (monoRhitGPos.y() - monoShitGPos.y()) / sqrt(monoRhitGPEr.cyy()); double pullGPZ_rs_mono = (monoRhitGPos.z() - monoShitGPos.z()) / sqrt(monoRhitGPEr.czz()); //double pullGPX_rs_mono = (monoRhitGPos.x()-monoShitGPos.x()); //double pullGPY_rs_mono = (monoRhitGPos.y()-monoShitGPos.y()); //double pullGPZ_rs_mono = (monoRhitGPos.z()-monoShitGPos.z()); MeasurementExtractor meMo(monoState); double chi2mono = computeChi2Increment(meMo, tMonoHit); title.str(""); title << "Chi2Increment_mono_" << subdetId << "-" << layerId; hChi2Increment_mono[title.str()]->Fill(chi2mono); title.str(""); title << "PullGP_X_" << subdetId << "-" << layerId << "_rs_mono"; hPullGP_X_rs_mono[title.str()]->Fill(pullGPX_rs_mono); title.str(""); title << "PullGP_Y_" << subdetId << "-" << layerId << "_rs_mono"; hPullGP_Y_rs_mono[title.str()]->Fill(pullGPY_rs_mono); title.str(""); title << "PullGP_Z_" << subdetId << "-" << layerId << "_rs_mono"; hPullGP_Z_rs_mono[title.str()]->Fill(pullGPZ_rs_mono); double pullGPX_tr_mono = (monoTsosGPos.x() - monoRhitGPos.x()) / sqrt(monoTsosGPEr.cxx() + monoRhitGPEr.cxx()); double pullGPY_tr_mono = (monoTsosGPos.y() - monoRhitGPos.y()) / sqrt(monoTsosGPEr.cyy() + monoRhitGPEr.cyy()); double pullGPZ_tr_mono = (monoTsosGPos.z() - monoRhitGPos.z()) / sqrt(monoTsosGPEr.czz() + monoRhitGPEr.czz()); //double pullGPX_tr_mono = (monoTsosGPos.x()-monoRhitGPos.x()); //double pullGPY_tr_mono = (monoTsosGPos.y()-monoRhitGPos.y()); //double pullGPZ_tr_mono = (monoTsosGPos.z()-monoRhitGPos.z()); title.str(""); title << "PullGP_X_" << subdetId << "-" << layerId << "_tr_mono"; hPullGP_X_tr_mono[title.str()]->Fill(pullGPX_tr_mono); title.str(""); title << "PullGP_Y_" << subdetId << "-" << layerId << "_tr_mono"; hPullGP_Y_tr_mono[title.str()]->Fill(pullGPY_tr_mono); title.str(""); title << "PullGP_Z_" << subdetId << "-" << layerId << "_tr_mono"; hPullGP_Z_tr_mono[title.str()]->Fill(pullGPZ_tr_mono); double pullGPX_ts_mono = (monoTsosGPos.x() - monoShitGPos.x()) / sqrt(monoTsosGPEr.cxx()); double pullGPY_ts_mono = (monoTsosGPos.y() - monoShitGPos.y()) / sqrt(monoTsosGPEr.cyy()); double pullGPZ_ts_mono = (monoTsosGPos.z() - monoShitGPos.z()) / sqrt(monoTsosGPEr.czz()); //double pullGPX_ts_mono = (monoTsosGPos.x()-monoShitGPos.x()); //double pullGPY_ts_mono = (monoTsosGPos.y()-monoShitGPos.y()); //double pullGPZ_ts_mono = (monoTsosGPos.z()-monoShitGPos.z()); title.str(""); title << "PullGP_X_" << subdetId << "-" << layerId << "_ts_mono"; hPullGP_X_ts_mono[title.str()]->Fill(pullGPX_ts_mono); title.str(""); title << "PullGP_Y_" << subdetId << "-" << layerId << "_ts_mono"; hPullGP_Y_ts_mono[title.str()]->Fill(pullGPY_ts_mono); title.str(""); title << "PullGP_Z_" << subdetId << "-" << layerId << "_ts_mono"; hPullGP_Z_ts_mono[title.str()]->Fill(pullGPZ_ts_mono); double pullGMX_ts_mono = (monoTsosGMom.x() - monoShitGMom.x()) / sqrt(monoTsosGMEr.cxx()); double pullGMY_ts_mono = (monoTsosGMom.y() - monoShitGMom.y()) / sqrt(monoTsosGMEr.cyy()); double pullGMZ_ts_mono = (monoTsosGMom.z() - monoShitGMom.z()) / sqrt(monoTsosGMEr.czz()); //double pullGMX_ts_mono = (monoTsosGMom.x()-monoShitGMom.x()); //double pullGMY_ts_mono = (monoTsosGMom.y()-monoShitGMom.y()); //double pullGMZ_ts_mono = (monoTsosGMom.z()-monoShitGMom.z()); title.str(""); title << "PullGM_X_" << subdetId << "-" << layerId << "_ts_mono"; hPullGM_X_ts_mono[title.str()]->Fill(pullGMX_ts_mono); title.str(""); title << "PullGM_Y_" << subdetId << "-" << layerId << "_ts_mono"; hPullGM_Y_ts_mono[title.str()]->Fill(pullGMY_ts_mono); title.str(""); title << "PullGM_Z_" << subdetId << "-" << layerId << "_ts_mono"; hPullGM_Z_ts_mono[title.str()]->Fill(pullGMZ_ts_mono); //stereo LogTrace("TestTrackHits") << "STEREO HIT"; auto s = dynamic_cast<const SiStripMatchedRecHit2D*>(rhit->hit())->stereoHit(); CTTRHp tStereoHit = theBuilder->build(&s); if (tStereoHit == nullptr) continue; vector<PSimHit> assStereoSimHits = hitAssociator.associateHit(*tStereoHit->hit()); if (assStereoSimHits.empty()) continue; const PSimHit sStereoHit = *(assStereoSimHits.begin()); const Surface* stereoSurf = &(tStereoHit->det()->surface()); if (stereoSurf == nullptr) continue; TSOS stereoState = thePropagatorAnyDir->propagate(state, *stereoSurf); if (stereoState.isValid() == 0) continue; LocalVector stereoShitLMom = sStereoHit.momentumAtEntry(); GlobalVector stereoShitGMom = stereoSurf->toGlobal(stereoShitLMom); LocalPoint stereoShitLPos = sStereoHit.localPosition(); GlobalPoint stereoShitGPos = stereoSurf->toGlobal(stereoShitLPos); //LogTrace("TestTrackHits") << "assStereoSimHits.size()=" << assStereoSimHits.size() ; //LogTrace("TestTrackHits") << "stereo shit=" << stereoShitGPos ; GlobalVector stereoTsosGMom = stereoState.globalMomentum(); GlobalError stereoTsosGMEr(stereoState.cartesianError().matrix().Sub<AlgebraicSymMatrix33>(3, 3)); GlobalPoint stereoTsosGPos = stereoState.globalPosition(); GlobalError stereoTsosGPEr = stereoState.cartesianError().position(); GlobalPoint stereoRhitGPos = tStereoHit->globalPosition(); GlobalError stereoRhitGPEr = tStereoHit->globalPositionError(); MeasurementExtractor meSt(stereoState); double chi2stereo = computeChi2Increment(meSt, tStereoHit); title.str(""); title << "Chi2Increment_stereo_" << subdetId << "-" << layerId; hChi2Increment_stereo[title.str()]->Fill(chi2stereo); double pullGPX_rs_stereo = (stereoRhitGPos.x() - stereoShitGPos.x()) / sqrt(stereoRhitGPEr.cxx()); double pullGPY_rs_stereo = (stereoRhitGPos.y() - stereoShitGPos.y()) / sqrt(stereoRhitGPEr.cyy()); double pullGPZ_rs_stereo = (stereoRhitGPos.z() - stereoShitGPos.z()) / sqrt(stereoRhitGPEr.czz()); // double pullGPX_rs_stereo = (stereoRhitGPos.x()-stereoShitGPos.x())/*/sqrt(stereoRhitGPEr.cxx())*/; // double pullGPY_rs_stereo = (stereoRhitGPos.y()-stereoShitGPos.y())/*/sqrt(stereoRhitGPEr.cyy())*/; // double pullGPZ_rs_stereo = (stereoRhitGPos.z()-stereoShitGPos.z())/*/sqrt(stereoRhitGPEr.czz())*/; title.str(""); title << "PullGP_X_" << subdetId << "-" << layerId << "_rs_stereo"; hPullGP_X_rs_stereo[title.str()]->Fill(pullGPX_rs_stereo); title.str(""); title << "PullGP_Y_" << subdetId << "-" << layerId << "_rs_stereo"; hPullGP_Y_rs_stereo[title.str()]->Fill(pullGPY_rs_stereo); title.str(""); title << "PullGP_Z_" << subdetId << "-" << layerId << "_rs_stereo"; hPullGP_Z_rs_stereo[title.str()]->Fill(pullGPZ_rs_stereo); double pullGPX_tr_stereo = (stereoTsosGPos.x() - stereoRhitGPos.x()) / sqrt(stereoTsosGPEr.cxx() + stereoRhitGPEr.cxx()); double pullGPY_tr_stereo = (stereoTsosGPos.y() - stereoRhitGPos.y()) / sqrt(stereoTsosGPEr.cyy() + stereoRhitGPEr.cyy()); double pullGPZ_tr_stereo = (stereoTsosGPos.z() - stereoRhitGPos.z()) / sqrt(stereoTsosGPEr.czz() + stereoRhitGPEr.czz()); //double pullGPX_tr_stereo = (stereoTsosGPos.x()-stereoRhitGPos.x()); //double pullGPY_tr_stereo = (stereoTsosGPos.y()-stereoRhitGPos.y()); //double pullGPZ_tr_stereo = (stereoTsosGPos.z()-stereoRhitGPos.z()); title.str(""); title << "PullGP_X_" << subdetId << "-" << layerId << "_tr_stereo"; hPullGP_X_tr_stereo[title.str()]->Fill(pullGPX_tr_stereo); title.str(""); title << "PullGP_Y_" << subdetId << "-" << layerId << "_tr_stereo"; hPullGP_Y_tr_stereo[title.str()]->Fill(pullGPY_tr_stereo); title.str(""); title << "PullGP_Z_" << subdetId << "-" << layerId << "_tr_stereo"; hPullGP_Z_tr_stereo[title.str()]->Fill(pullGPZ_tr_stereo); double pullGPX_ts_stereo = (stereoTsosGPos.x() - stereoShitGPos.x()) / sqrt(stereoTsosGPEr.cxx()); double pullGPY_ts_stereo = (stereoTsosGPos.y() - stereoShitGPos.y()) / sqrt(stereoTsosGPEr.cyy()); double pullGPZ_ts_stereo = (stereoTsosGPos.z() - stereoShitGPos.z()) / sqrt(stereoTsosGPEr.czz()); //double pullGPX_ts_stereo = (stereoTsosGPos.x()-stereoShitGPos.x()); //double pullGPY_ts_stereo = (stereoTsosGPos.y()-stereoShitGPos.y()); //double pullGPZ_ts_stereo = (stereoTsosGPos.z()-stereoShitGPos.z()); title.str(""); title << "PullGP_X_" << subdetId << "-" << layerId << "_ts_stereo"; hPullGP_X_ts_stereo[title.str()]->Fill(pullGPX_ts_stereo); title.str(""); title << "PullGP_Y_" << subdetId << "-" << layerId << "_ts_stereo"; hPullGP_Y_ts_stereo[title.str()]->Fill(pullGPY_ts_stereo); title.str(""); title << "PullGP_Z_" << subdetId << "-" << layerId << "_ts_stereo"; hPullGP_Z_ts_stereo[title.str()]->Fill(pullGPZ_ts_stereo); double pullGMX_ts_stereo = (stereoTsosGMom.x() - stereoShitGMom.x()) / sqrt(stereoTsosGMEr.cxx()); double pullGMY_ts_stereo = (stereoTsosGMom.y() - stereoShitGMom.y()) / sqrt(stereoTsosGMEr.cyy()); double pullGMZ_ts_stereo = (stereoTsosGMom.z() - stereoShitGMom.z()) / sqrt(stereoTsosGMEr.czz()); //double pullGMX_ts_stereo = (stereoTsosGMom.x()-stereoShitGMom.x()); //double pullGMY_ts_stereo = (stereoTsosGMom.y()-stereoShitGMom.y()); //double pullGMZ_ts_stereo = (stereoTsosGMom.z()-stereoShitGMom.z()); title.str(""); title << "PullGM_X_" << subdetId << "-" << layerId << "_ts_stereo"; hPullGM_X_ts_stereo[title.str()]->Fill(pullGMX_ts_stereo); title.str(""); title << "PullGM_Y_" << subdetId << "-" << layerId << "_ts_stereo"; hPullGM_Y_ts_stereo[title.str()]->Fill(pullGMY_ts_stereo); title.str(""); title << "PullGM_Z_" << subdetId << "-" << layerId << "_ts_stereo"; hPullGM_Z_ts_stereo[title.str()]->Fill(pullGMZ_ts_stereo); } } LogTrace("TestTrackHits") << "traj chi2=" << tchi2; LogTrace("TestTrackHits") << "track chi2=" << track->chi2(); i++; } LogTrace("TestTrackHits") << "end of event: processd hits=" << evtHits; } void TestTrackHits::endJob() { //file->Write(); TDirectory* chi2d = file->mkdir("Chi2Increment"); TDirectory* gp_ts = file->mkdir("GP_TSOS-SimHit"); TDirectory* gm_ts = file->mkdir("GM_TSOS-SimHit"); TDirectory* gp_tr = file->mkdir("GP_TSOS-RecHit"); TDirectory* gp_rs = file->mkdir("GP_RecHit-SimHit"); TDirectory* gp_tsx = gp_ts->mkdir("X"); TDirectory* gp_tsy = gp_ts->mkdir("Y"); TDirectory* gp_tsz = gp_ts->mkdir("Z"); TDirectory* gm_tsx = gm_ts->mkdir("X"); TDirectory* gm_tsy = gm_ts->mkdir("Y"); TDirectory* gm_tsz = gm_ts->mkdir("Z"); TDirectory* gp_trx = gp_tr->mkdir("X"); TDirectory* gp_try = gp_tr->mkdir("Y"); TDirectory* gp_trz = gp_tr->mkdir("Z"); TDirectory* gp_rsx = gp_rs->mkdir("X"); TDirectory* gp_rsy = gp_rs->mkdir("Y"); TDirectory* gp_rsz = gp_rs->mkdir("Z"); TDirectory* gp_tsx_mono = gp_ts->mkdir("MONOX"); TDirectory* gp_tsy_mono = gp_ts->mkdir("MONOY"); TDirectory* gp_tsz_mono = gp_ts->mkdir("MONOZ"); TDirectory* gm_tsx_mono = gm_ts->mkdir("MONOX"); TDirectory* gm_tsy_mono = gm_ts->mkdir("MONOY"); TDirectory* gm_tsz_mono = gm_ts->mkdir("MONOZ"); TDirectory* gp_trx_mono = gp_tr->mkdir("MONOX"); TDirectory* gp_try_mono = gp_tr->mkdir("MONOY"); TDirectory* gp_trz_mono = gp_tr->mkdir("MONOZ"); TDirectory* gp_rsx_mono = gp_rs->mkdir("MONOX"); TDirectory* gp_rsy_mono = gp_rs->mkdir("MONOY"); TDirectory* gp_rsz_mono = gp_rs->mkdir("MONOZ"); TDirectory* gp_tsx_stereo = gp_ts->mkdir("STEREOX"); TDirectory* gp_tsy_stereo = gp_ts->mkdir("STEREOY"); TDirectory* gp_tsz_stereo = gp_ts->mkdir("STEREOZ"); TDirectory* gm_tsx_stereo = gm_ts->mkdir("STEREOX"); TDirectory* gm_tsy_stereo = gm_ts->mkdir("STEREOY"); TDirectory* gm_tsz_stereo = gm_ts->mkdir("STEREOZ"); TDirectory* gp_trx_stereo = gp_tr->mkdir("STEREOX"); TDirectory* gp_try_stereo = gp_tr->mkdir("STEREOY"); TDirectory* gp_trz_stereo = gp_tr->mkdir("STEREOZ"); TDirectory* gp_rsx_stereo = gp_rs->mkdir("STEREOX"); TDirectory* gp_rsy_stereo = gp_rs->mkdir("STEREOY"); TDirectory* gp_rsz_stereo = gp_rs->mkdir("STEREOZ"); chi2d->cd(); hTotChi2Increment->Write(); hTotChi2GoodHit->Write(); hTotChi2BadHit->Write(); hTotChi2DeltaHit->Write(); hTotChi2NSharedHit->Write(); hTotChi2SharedHit->Write(); hProcess_vs_Chi2->Write(); hClsize_vs_Chi2->Write(); hPixClsize_vs_Chi2->Write(); hPrjClsize_vs_Chi2->Write(); hSt1Clsize_vs_Chi2->Write(); hSt2Clsize_vs_Chi2->Write(); hGoodHit_vs_Chi2->Write(); hClusterSize->Write(); hPixClusterSize->Write(); hPrjClusterSize->Write(); hSt1ClusterSize->Write(); hSt2ClusterSize->Write(); hSimHitVecSize->Write(); hPixSimHitVecSize->Write(); hPrjSimHitVecSize->Write(); hSt1SimHitVecSize->Write(); hSt2SimHitVecSize->Write(); goodbadmerged->Write(); energyLossRatio->Write(); mergedPull->Write(); probXgood->Write(); probXbad->Write(); probXdelta->Write(); probXshared->Write(); probXnoshare->Write(); probYgood->Write(); probYbad->Write(); probYdelta->Write(); probYshared->Write(); probYnoshare->Write(); for (int i = 0; i != 6; i++) for (int j = 0; j != 9; j++) { if (i == 0 && j > 2) break; if (i == 1 && j > 1) break; if (i == 2 && j > 3) break; if (i == 3 && j > 2) break; if (i == 4 && j > 5) break; if (i == 5 && j > 8) break; chi2d->cd(); title.str(""); title << "Chi2Increment_" << i + 1 << "-" << j + 1; hChi2Increment[title.str()]->Write(); title.str(""); title << "Chi2IncrementVsEta_" << i + 1 << "-" << j + 1; hChi2IncrementVsEta[title.str()]->Write(); title.str(""); title << "Chi2GoodHit_" << i + 1 << "-" << j + 1; hChi2GoodHit[title.str()]->Write(); title.str(""); title << "Chi2BadHit_" << i + 1 << "-" << j + 1; hChi2BadHit[title.str()]->Write(); title.str(""); title << "Chi2DeltaHit_" << i + 1 << "-" << j + 1; hChi2DeltaHit[title.str()]->Write(); title.str(""); title << "Chi2NSharedHit_" << i + 1 << "-" << j + 1; hChi2NSharedHit[title.str()]->Write(); title.str(""); title << "Chi2SharedHit_" << i + 1 << "-" << j + 1; hChi2SharedHit[title.str()]->Write(); gp_ts->cd(); gp_tsx->cd(); title.str(""); title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_ts"; hPullGP_X_ts[title.str()]->Write(); gp_tsy->cd(); title.str(""); title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_ts"; hPullGP_Y_ts[title.str()]->Write(); gp_tsz->cd(); title.str(""); title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_ts"; hPullGP_Z_ts[title.str()]->Write(); gm_ts->cd(); gm_tsx->cd(); title.str(""); title << "PullGM_X_" << i + 1 << "-" << j + 1 << "_ts"; hPullGM_X_ts[title.str()]->Write(); gm_tsy->cd(); title.str(""); title << "PullGM_Y_" << i + 1 << "-" << j + 1 << "_ts"; hPullGM_Y_ts[title.str()]->Write(); gm_tsz->cd(); title.str(""); title << "PullGM_Z_" << i + 1 << "-" << j + 1 << "_ts"; hPullGM_Z_ts[title.str()]->Write(); gp_tr->cd(); gp_trx->cd(); title.str(""); title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_tr"; hPullGP_X_tr[title.str()]->Write(); gp_try->cd(); title.str(""); title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_tr"; hPullGP_Y_tr[title.str()]->Write(); gp_trz->cd(); title.str(""); title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_tr"; hPullGP_Z_tr[title.str()]->Write(); gp_rs->cd(); gp_rsx->cd(); title.str(""); title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_rs"; hPullGP_X_rs[title.str()]->Write(); gp_rsy->cd(); title.str(""); title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_rs"; hPullGP_Y_rs[title.str()]->Write(); gp_rsz->cd(); title.str(""); title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_rs"; hPullGP_Z_rs[title.str()]->Write(); if (((i == 2 || i == 4) && (j == 0 || j == 1)) || (i == 3 || i == 5)) { chi2d->cd(); title.str(""); title << "Chi2Increment_mono_" << i + 1 << "-" << j + 1; hChi2Increment_mono[title.str()]->Write(); title.str(""); title << "Chi2Increment_stereo_" << i + 1 << "-" << j + 1; hChi2Increment_stereo[title.str()]->Write(); //mono gp_ts->cd(); gp_tsx_mono->cd(); title.str(""); title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_ts_mono"; hPullGP_X_ts_mono[title.str()]->Write(); gp_tsy_mono->cd(); title.str(""); title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_ts_mono"; hPullGP_Y_ts_mono[title.str()]->Write(); gp_tsz_mono->cd(); title.str(""); title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_ts_mono"; hPullGP_Z_ts_mono[title.str()]->Write(); gm_ts->cd(); gm_tsx_mono->cd(); title.str(""); title << "PullGM_X_" << i + 1 << "-" << j + 1 << "_ts_mono"; hPullGM_X_ts_mono[title.str()]->Write(); gm_tsy_mono->cd(); title.str(""); title << "PullGM_Y_" << i + 1 << "-" << j + 1 << "_ts_mono"; hPullGM_Y_ts_mono[title.str()]->Write(); gm_tsz_mono->cd(); title.str(""); title << "PullGM_Z_" << i + 1 << "-" << j + 1 << "_ts_mono"; hPullGM_Z_ts_mono[title.str()]->Write(); gp_tr->cd(); gp_trx_mono->cd(); title.str(""); title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_tr_mono"; hPullGP_X_tr_mono[title.str()]->Write(); gp_try_mono->cd(); title.str(""); title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_tr_mono"; hPullGP_Y_tr_mono[title.str()]->Write(); gp_trz_mono->cd(); title.str(""); title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_tr_mono"; hPullGP_Z_tr_mono[title.str()]->Write(); gp_rs->cd(); gp_rsx_mono->cd(); title.str(""); title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_rs_mono"; hPullGP_X_rs_mono[title.str()]->Write(); gp_rsy_mono->cd(); title.str(""); title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_rs_mono"; hPullGP_Y_rs_mono[title.str()]->Write(); gp_rsz_mono->cd(); title.str(""); title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_rs_mono"; hPullGP_Z_rs_mono[title.str()]->Write(); //stereo gp_ts->cd(); gp_tsx_stereo->cd(); title.str(""); title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_ts_stereo"; hPullGP_X_ts_stereo[title.str()]->Write(); gp_tsy_stereo->cd(); title.str(""); title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_ts_stereo"; hPullGP_Y_ts_stereo[title.str()]->Write(); gp_tsz_stereo->cd(); title.str(""); title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_ts_stereo"; hPullGP_Z_ts_stereo[title.str()]->Write(); gm_ts->cd(); gm_tsx_stereo->cd(); title.str(""); title << "PullGM_X_" << i + 1 << "-" << j + 1 << "_ts_stereo"; hPullGM_X_ts_stereo[title.str()]->Write(); gm_tsy_stereo->cd(); title.str(""); title << "PullGM_Y_" << i + 1 << "-" << j + 1 << "_ts_stereo"; hPullGM_Y_ts_stereo[title.str()]->Write(); gm_tsz_stereo->cd(); title.str(""); title << "PullGM_Z_" << i + 1 << "-" << j + 1 << "_ts_stereo"; hPullGM_Z_ts_stereo[title.str()]->Write(); gp_tr->cd(); gp_trx_stereo->cd(); title.str(""); title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_tr_stereo"; hPullGP_X_tr_stereo[title.str()]->Write(); gp_try_stereo->cd(); title.str(""); title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_tr_stereo"; hPullGP_Y_tr_stereo[title.str()]->Write(); gp_trz_stereo->cd(); title.str(""); title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_tr_stereo"; hPullGP_Z_tr_stereo[title.str()]->Write(); gp_rs->cd(); gp_rsx_stereo->cd(); title.str(""); title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_rs_stereo"; hPullGP_X_rs_stereo[title.str()]->Write(); gp_rsy_stereo->cd(); title.str(""); title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_rs_stereo"; hPullGP_Y_rs_stereo[title.str()]->Write(); gp_rsz_stereo->cd(); title.str(""); title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_rs_stereo"; hPullGP_Z_rs_stereo[title.str()]->Write(); } } file->Close(); } //needed by to do the residual for matched hits //taken from SiStripTrackingRecHitsValid.cc std::pair<LocalPoint, LocalVector> TestTrackHits::projectHit(const PSimHit& hit, const StripGeomDetUnit* stripDet, const BoundPlane& plane) { const StripTopology& topol = stripDet->specificTopology(); GlobalPoint globalpos = stripDet->surface().toGlobal(hit.localPosition()); LocalPoint localHit = plane.toLocal(globalpos); //track direction LocalVector locdir = hit.localDirection(); //rotate track in new frame GlobalVector globaldir = stripDet->surface().toGlobal(locdir); LocalVector dir = plane.toLocal(globaldir); float scale = -localHit.z() / dir.z(); LocalPoint projectedPos = localHit + scale * dir; float selfAngle = topol.stripAngle(topol.strip(hit.localPosition())); LocalVector stripDir(sin(selfAngle), cos(selfAngle), 0); // vector along strip in hit frame LocalVector localStripDir(plane.toLocal(stripDet->surface().toGlobal(stripDir))); return std::pair<LocalPoint, LocalVector>(projectedPos, localStripDir); } template <unsigned int D> double TestTrackHits::computeChi2Increment(MeasurementExtractor me, TransientTrackingRecHit::ConstRecHitPointer rhit) { typedef typename AlgebraicROOTObject<D>::Vector VecD; typedef typename AlgebraicROOTObject<D, D>::SymMatrix SMatDD; VecD r = asSVector<D>(rhit->parameters()) - me.measuredParameters<D>(*rhit); SMatDD R = asSMatrix<D>(rhit->parametersError()) + me.measuredError<D>(*rhit); R.Invert(); return ROOT::Math::Similarity(r, R); } #include "FWCore/Framework/interface/ModuleFactory.h" #include "FWCore/Framework/interface/MakerMacros.h" DEFINE_FWK_MODULE(TestTrackHits);
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved. #include "Engine/PlayerStartPIE.h" APlayerStartPIE::APlayerStartPIE(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) { }
/*========================================================================= Program: Visualization Toolkit Module: vtkLineWidget.cxx Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ #include "vtkLineWidget.h" #include "vtkActor.h" #include "vtkAssemblyNode.h" #include "vtkAssemblyPath.h" #include "vtkCallbackCommand.h" #include "vtkCamera.h" #include "vtkCellPicker.h" #include "vtkCommand.h" #include "vtkDoubleArray.h" #include "vtkFloatArray.h" #include "vtkMath.h" #include "vtkObjectFactory.h" #include "vtkPickingManager.h" #include "vtkPlanes.h" #include "vtkPointWidget.h" #include "vtkPolyData.h" #include "vtkPolyDataMapper.h" #include "vtkProperty.h" #include "vtkRenderWindow.h" #include "vtkRenderWindowInteractor.h" #include "vtkRenderer.h" #include "vtkSphereSource.h" vtkStandardNewMacro(vtkLineWidget); //------------------------------------------------------------------------------ // This class is used to coordinate the interaction between the point widget // at the center of the line and the line widget. When the line is selected // (as compared to the handles), a point widget appears at the selection // point, which can be manipulated in the usual way. class vtkPWCallback : public vtkCommand { public: static vtkPWCallback* New() { return new vtkPWCallback; } void Execute(vtkObject* vtkNotUsed(caller), unsigned long, void*) override { double x[3]; this->PointWidget->GetPosition(x); this->LineWidget->SetLinePosition(x); } vtkPWCallback() : LineWidget(nullptr) , PointWidget(nullptr) { } vtkLineWidget* LineWidget; vtkPointWidget* PointWidget; }; //------------------------------------------------------------------------------ // This class is used to coordinate the interaction between the point widget // (point 1) and the line widget. class vtkPW1Callback : public vtkCommand { public: static vtkPW1Callback* New() { return new vtkPW1Callback; } void Execute(vtkObject* vtkNotUsed(caller), unsigned long, void*) override { double x[3]; this->PointWidget->GetPosition(x); this->LineWidget->SetPoint1(x); } vtkPW1Callback() : LineWidget(nullptr) , PointWidget(nullptr) { } vtkLineWidget* LineWidget; vtkPointWidget* PointWidget; }; //------------------------------------------------------------------------------ // This class is used to coordinate the interaction between the point widget // (point 2) and the line widget. class vtkPW2Callback : public vtkCommand { public: static vtkPW2Callback* New() { return new vtkPW2Callback; } void Execute(vtkObject* vtkNotUsed(caller), unsigned long, void*) override { double x[3]; this->PointWidget->GetPosition(x); this->LineWidget->SetPoint2(x); } vtkPW2Callback() : LineWidget(nullptr) , PointWidget(nullptr) { } vtkLineWidget* LineWidget; vtkPointWidget* PointWidget; }; //------------------------------------------------------------------------------ // Begin the definition of the vtkLineWidget methods // vtkLineWidget::vtkLineWidget() { this->State = vtkLineWidget::Start; this->EventCallbackCommand->SetCallback(vtkLineWidget::ProcessEvents); this->Align = vtkLineWidget::XAxis; // Build the representation of the widget int i; // Represent the line this->LineSource = vtkLineSource::New(); this->LineSource->SetResolution(5); this->LineMapper = vtkPolyDataMapper::New(); this->LineMapper->SetInputConnection(this->LineSource->GetOutputPort()); this->LineActor = vtkActor::New(); this->LineActor->SetMapper(this->LineMapper); // Create the handles this->Handle = new vtkActor*[2]; this->HandleMapper = new vtkPolyDataMapper*[2]; this->HandleGeometry = new vtkSphereSource*[2]; for (i = 0; i < 2; i++) { this->HandleGeometry[i] = vtkSphereSource::New(); this->HandleGeometry[i]->SetThetaResolution(16); this->HandleGeometry[i]->SetPhiResolution(8); this->HandleMapper[i] = vtkPolyDataMapper::New(); this->HandleMapper[i]->SetInputConnection(this->HandleGeometry[i]->GetOutputPort()); this->Handle[i] = vtkActor::New(); this->Handle[i]->SetMapper(this->HandleMapper[i]); } // Define the point coordinates double bounds[6]; bounds[0] = -0.5; bounds[1] = 0.5; bounds[2] = -0.5; bounds[3] = 0.5; bounds[4] = -0.5; bounds[5] = 0.5; this->PlaceFactor = 1.0; // overload parent's value // Initial creation of the widget, serves to initialize it this->PlaceWidget(bounds); this->ClampToBounds = 0; // Manage the picking stuff this->HandlePicker = vtkCellPicker::New(); this->HandlePicker->SetTolerance(0.001); for (i = 0; i < 2; i++) { this->HandlePicker->AddPickList(this->Handle[i]); } this->HandlePicker->PickFromListOn(); this->LinePicker = vtkCellPicker::New(); this->LinePicker->SetTolerance(0.005); // need some fluff this->LinePicker->AddPickList(this->LineActor); this->LinePicker->PickFromListOn(); this->CurrentHandle = nullptr; // Set up the initial properties this->CreateDefaultProperties(); // Create the point widgets and associated callbacks this->PointWidget = vtkPointWidget::New(); this->PointWidget->AllOff(); this->PointWidget->SetHotSpotSize(0.5); this->PointWidget1 = vtkPointWidget::New(); this->PointWidget1->AllOff(); this->PointWidget1->SetHotSpotSize(0.5); this->PointWidget2 = vtkPointWidget::New(); this->PointWidget2->AllOff(); this->PointWidget2->SetHotSpotSize(0.5); this->PWCallback = vtkPWCallback::New(); this->PWCallback->LineWidget = this; this->PWCallback->PointWidget = this->PointWidget; this->PW1Callback = vtkPW1Callback::New(); this->PW1Callback->LineWidget = this; this->PW1Callback->PointWidget = this->PointWidget1; this->PW2Callback = vtkPW2Callback::New(); this->PW2Callback->LineWidget = this; this->PW2Callback->PointWidget = this->PointWidget2; // Very tricky, the point widgets watch for their own // interaction events. this->PointWidget->AddObserver(vtkCommand::InteractionEvent, this->PWCallback, 0.0); this->PointWidget1->AddObserver(vtkCommand::InteractionEvent, this->PW1Callback, 0.0); this->PointWidget2->AddObserver(vtkCommand::InteractionEvent, this->PW2Callback, 0.0); this->CurrentPointWidget = nullptr; } //------------------------------------------------------------------------------ vtkLineWidget::~vtkLineWidget() { this->LineActor->Delete(); this->LineMapper->Delete(); this->LineSource->Delete(); for (int i = 0; i < 2; i++) { this->HandleGeometry[i]->Delete(); this->HandleMapper[i]->Delete(); this->Handle[i]->Delete(); } delete[] this->Handle; delete[] this->HandleMapper; delete[] this->HandleGeometry; this->HandlePicker->Delete(); this->LinePicker->Delete(); this->HandleProperty->Delete(); this->SelectedHandleProperty->Delete(); this->LineProperty->Delete(); this->SelectedLineProperty->Delete(); this->PointWidget->RemoveObserver(this->PWCallback); this->PointWidget1->RemoveObserver(this->PW1Callback); this->PointWidget2->RemoveObserver(this->PW2Callback); this->PointWidget->Delete(); this->PointWidget1->Delete(); this->PointWidget2->Delete(); this->PWCallback->Delete(); this->PW1Callback->Delete(); this->PW2Callback->Delete(); } //------------------------------------------------------------------------------ void vtkLineWidget::SetEnabled(int enabling) { if (!this->Interactor) { vtkErrorMacro(<< "The interactor must be set prior to enabling/disabling widget"); return; } if (enabling) //----------------------------------------------------------- { vtkDebugMacro(<< "Enabling line widget"); if (this->Enabled) // already enabled, just return { return; } if (!this->CurrentRenderer) { this->SetCurrentRenderer(this->Interactor->FindPokedRenderer( this->Interactor->GetLastEventPosition()[0], this->Interactor->GetLastEventPosition()[1])); if (this->CurrentRenderer == nullptr) { return; } } this->PointWidget->SetCurrentRenderer(this->CurrentRenderer); this->PointWidget1->SetCurrentRenderer(this->CurrentRenderer); this->PointWidget2->SetCurrentRenderer(this->CurrentRenderer); this->Enabled = 1; // listen for the following events vtkRenderWindowInteractor* i = this->Interactor; i->AddObserver(vtkCommand::MouseMoveEvent, this->EventCallbackCommand, this->Priority); i->AddObserver(vtkCommand::LeftButtonPressEvent, this->EventCallbackCommand, this->Priority); i->AddObserver(vtkCommand::LeftButtonReleaseEvent, this->EventCallbackCommand, this->Priority); i->AddObserver(vtkCommand::MiddleButtonPressEvent, this->EventCallbackCommand, this->Priority); i->AddObserver( vtkCommand::MiddleButtonReleaseEvent, this->EventCallbackCommand, this->Priority); i->AddObserver(vtkCommand::RightButtonPressEvent, this->EventCallbackCommand, this->Priority); i->AddObserver(vtkCommand::RightButtonReleaseEvent, this->EventCallbackCommand, this->Priority); // Add the line this->CurrentRenderer->AddActor(this->LineActor); this->LineActor->SetProperty(this->LineProperty); // turn on the handles for (int j = 0; j < 2; j++) { this->CurrentRenderer->AddActor(this->Handle[j]); this->Handle[j]->SetProperty(this->HandleProperty); } this->BuildRepresentation(); this->SizeHandles(); this->RegisterPickers(); this->InvokeEvent(vtkCommand::EnableEvent, nullptr); } else // disabling---------------------------------------------------------- { vtkDebugMacro(<< "Disabling line widget"); if (!this->Enabled) // already disabled, just return { return; } this->Enabled = 0; // don't listen for events any more this->Interactor->RemoveObserver(this->EventCallbackCommand); // turn off the line this->CurrentRenderer->RemoveActor(this->LineActor); // turn off the handles for (int i = 0; i < 2; i++) { this->CurrentRenderer->RemoveActor(this->Handle[i]); } if (this->CurrentPointWidget) { this->CurrentPointWidget->EnabledOff(); } this->CurrentHandle = nullptr; this->InvokeEvent(vtkCommand::DisableEvent, nullptr); this->SetCurrentRenderer(nullptr); this->UnRegisterPickers(); } this->Interactor->Render(); } //------------------------------------------------------------------------------ void vtkLineWidget::RegisterPickers() { vtkPickingManager* pm = this->GetPickingManager(); if (!pm) { return; } pm->AddPicker(this->HandlePicker, this); pm->AddPicker(this->LinePicker, this); } //------------------------------------------------------------------------------ void vtkLineWidget::ProcessEvents( vtkObject* vtkNotUsed(object), unsigned long event, void* clientdata, void* vtkNotUsed(calldata)) { vtkLineWidget* self = reinterpret_cast<vtkLineWidget*>(clientdata); // okay, let's do the right thing switch (event) { case vtkCommand::LeftButtonPressEvent: self->OnLeftButtonDown(); break; case vtkCommand::LeftButtonReleaseEvent: self->OnLeftButtonUp(); break; case vtkCommand::MiddleButtonPressEvent: self->OnMiddleButtonDown(); break; case vtkCommand::MiddleButtonReleaseEvent: self->OnMiddleButtonUp(); break; case vtkCommand::RightButtonPressEvent: self->OnRightButtonDown(); break; case vtkCommand::RightButtonReleaseEvent: self->OnRightButtonUp(); break; case vtkCommand::MouseMoveEvent: self->OnMouseMove(); break; } } //------------------------------------------------------------------------------ void vtkLineWidget::PrintSelf(ostream& os, vtkIndent indent) { this->Superclass::PrintSelf(os, indent); if (this->HandleProperty) { os << indent << "Handle Property: " << this->HandleProperty << "\n"; } else { os << indent << "Handle Property: (none)\n"; } if (this->SelectedHandleProperty) { os << indent << "Selected Handle Property: " << this->SelectedHandleProperty << "\n"; } else { os << indent << "Selected Handle Property: (none)\n"; } if (this->LineProperty) { os << indent << "Line Property: " << this->LineProperty << "\n"; } else { os << indent << "Line Property: (none)\n"; } if (this->SelectedLineProperty) { os << indent << "Selected Line Property: " << this->SelectedLineProperty << "\n"; } else { os << indent << "Selected Line Property: (none)\n"; } os << indent << "Constrain To Bounds: " << (this->ClampToBounds ? "On\n" : "Off\n"); os << indent << "Align with: "; switch (this->Align) { case XAxis: os << "X Axis"; break; case YAxis: os << "Y Axis"; break; case ZAxis: os << "Z Axis"; break; default: os << "None"; } int res = this->LineSource->GetResolution(); double* pt1 = this->LineSource->GetPoint1(); double* pt2 = this->LineSource->GetPoint2(); os << indent << "Resolution: " << res << "\n"; os << indent << "Point 1: (" << pt1[0] << ", " << pt1[1] << ", " << pt1[2] << ")\n"; os << indent << "Point 2: (" << pt2[0] << ", " << pt2[1] << ", " << pt2[2] << ")\n"; } //------------------------------------------------------------------------------ void vtkLineWidget::BuildRepresentation() { // int res = this->LineSource->GetResolution(); double* pt1 = this->LineSource->GetPoint1(); double* pt2 = this->LineSource->GetPoint2(); this->HandleGeometry[0]->SetCenter(pt1); this->HandleGeometry[1]->SetCenter(pt2); } //------------------------------------------------------------------------------ void vtkLineWidget::SizeHandles() { double radius = this->vtk3DWidget::SizeHandles(1.0); this->HandleGeometry[0]->SetRadius(radius); this->HandleGeometry[1]->SetRadius(radius); } //------------------------------------------------------------------------------ int vtkLineWidget::HighlightHandle(vtkProp* prop) { // first unhighlight anything picked if (this->CurrentHandle) { this->CurrentHandle->SetProperty(this->HandleProperty); } // set the current handle this->CurrentHandle = static_cast<vtkActor*>(prop); // find the current handle if (this->CurrentHandle) { this->ValidPick = 1; this->HandlePicker->GetPickPosition(this->LastPickPosition); this->CurrentHandle->SetProperty(this->SelectedHandleProperty); return (this->CurrentHandle == this->Handle[0] ? 0 : 1); } return -1; } //------------------------------------------------------------------------------ int vtkLineWidget::ForwardEvent(unsigned long event) { if (!this->CurrentPointWidget) { return 0; } vtkPointWidget::ProcessEvents(this, event, this->CurrentPointWidget, nullptr); return 1; } //------------------------------------------------------------------------------ // assumed current handle is set void vtkLineWidget::EnablePointWidget() { // Set up the point widgets double x[3]; if (this->CurrentHandle) // picking the handles { if (this->CurrentHandle == this->Handle[0]) { this->CurrentPointWidget = this->PointWidget1; this->LineSource->GetPoint1(x); } else { this->CurrentPointWidget = this->PointWidget2; this->LineSource->GetPoint2(x); } } else // picking the line { this->CurrentPointWidget = this->PointWidget; this->LinePicker->GetPickPosition(x); this->LastPosition[0] = x[0]; this->LastPosition[1] = x[1]; this->LastPosition[2] = x[2]; } double bounds[6]; for (int i = 0; i < 3; i++) { bounds[2 * i] = x[i] - 0.1 * this->InitialLength; bounds[2 * i + 1] = x[i] + 0.1 * this->InitialLength; } // Note: translation mode is disabled and enabled to control // the proper positioning of the bounding box. this->CurrentPointWidget->SetInteractor(this->Interactor); this->CurrentPointWidget->TranslationModeOff(); this->CurrentPointWidget->SetPlaceFactor(1.0); this->CurrentPointWidget->PlaceWidget(bounds); this->CurrentPointWidget->TranslationModeOn(); this->CurrentPointWidget->SetPosition(x); this->CurrentPointWidget->SetCurrentRenderer(this->CurrentRenderer); this->CurrentPointWidget->On(); } //------------------------------------------------------------------------------ // assumed current handle is set void vtkLineWidget::DisablePointWidget() { if (this->CurrentPointWidget) { this->CurrentPointWidget->Off(); } this->CurrentPointWidget = nullptr; } //------------------------------------------------------------------------------ void vtkLineWidget::HighlightHandles(int highlight) { if (highlight) { this->ValidPick = 1; this->HandlePicker->GetPickPosition(this->LastPickPosition); this->Handle[0]->SetProperty(this->SelectedHandleProperty); this->Handle[1]->SetProperty(this->SelectedHandleProperty); } else { this->Handle[0]->SetProperty(this->HandleProperty); this->Handle[1]->SetProperty(this->HandleProperty); } } //------------------------------------------------------------------------------ void vtkLineWidget::HighlightLine(int highlight) { if (highlight) { this->ValidPick = 1; this->LinePicker->GetPickPosition(this->LastPickPosition); this->LineActor->SetProperty(this->SelectedLineProperty); } else { this->LineActor->SetProperty(this->LineProperty); } } //------------------------------------------------------------------------------ void vtkLineWidget::OnLeftButtonDown() { int forward = 0; int X = this->Interactor->GetEventPosition()[0]; int Y = this->Interactor->GetEventPosition()[1]; // Okay, make sure that the pick is in the current renderer if (!this->CurrentRenderer || !this->CurrentRenderer->IsInViewport(X, Y)) { this->State = vtkLineWidget::Outside; return; } // Okay, we can process this. Try to pick handles first; // if no handles picked, then try to pick the line. vtkAssemblyPath* path = this->GetAssemblyPath(X, Y, 0., this->HandlePicker); if (path != nullptr) { this->EventCallbackCommand->SetAbortFlag(1); this->StartInteraction(); this->InvokeEvent(vtkCommand::StartInteractionEvent, nullptr); this->State = vtkLineWidget::MovingHandle; this->HighlightHandle(path->GetFirstNode()->GetViewProp()); this->EnablePointWidget(); forward = this->ForwardEvent(vtkCommand::LeftButtonPressEvent); } else { path = this->GetAssemblyPath(X, Y, 0., this->LinePicker); if (path != nullptr) { this->EventCallbackCommand->SetAbortFlag(1); this->StartInteraction(); this->InvokeEvent(vtkCommand::StartInteractionEvent, nullptr); this->State = vtkLineWidget::MovingLine; this->HighlightLine(1); this->EnablePointWidget(); forward = this->ForwardEvent(vtkCommand::LeftButtonPressEvent); } else { this->State = vtkLineWidget::Outside; this->HighlightHandle(nullptr); return; } } if (!forward) { this->Interactor->Render(); } } //------------------------------------------------------------------------------ void vtkLineWidget::OnLeftButtonUp() { if (this->State == vtkLineWidget::Outside || this->State == vtkLineWidget::Start) { return; } this->State = vtkLineWidget::Start; this->HighlightHandle(nullptr); this->HighlightLine(0); this->SizeHandles(); int forward = this->ForwardEvent(vtkCommand::LeftButtonReleaseEvent); this->DisablePointWidget(); this->EventCallbackCommand->SetAbortFlag(1); this->EndInteraction(); this->InvokeEvent(vtkCommand::EndInteractionEvent, nullptr); if (!forward) { this->Interactor->Render(); } } //------------------------------------------------------------------------------ void vtkLineWidget::OnMiddleButtonDown() { int forward = 0; int X = this->Interactor->GetEventPosition()[0]; int Y = this->Interactor->GetEventPosition()[1]; // Okay, make sure that the pick is in the current renderer if (!this->CurrentRenderer || !this->CurrentRenderer->IsInViewport(X, Y)) { this->State = vtkLineWidget::Outside; return; } // Okay, we can process this. Try to pick handles first; // if no handles picked, then pick the bounding box. vtkAssemblyPath* path = this->GetAssemblyPath(X, Y, 0., this->HandlePicker); if (path != nullptr) { this->EventCallbackCommand->SetAbortFlag(1); this->StartInteraction(); this->InvokeEvent(vtkCommand::StartInteractionEvent, nullptr); this->State = vtkLineWidget::MovingLine; this->HighlightHandles(1); this->HighlightLine(1); this->EnablePointWidget(); forward = this->ForwardEvent(vtkCommand::LeftButtonPressEvent); } else { path = this->GetAssemblyPath(X, Y, 0., this->LinePicker); if (path != nullptr) { this->EventCallbackCommand->SetAbortFlag(1); this->StartInteraction(); this->InvokeEvent(vtkCommand::StartInteractionEvent, nullptr); // The highlight methods set the LastPickPosition, so they are ordered this->HighlightHandles(1); this->HighlightLine(1); this->State = vtkLineWidget::MovingLine; this->EnablePointWidget(); forward = this->ForwardEvent(vtkCommand::LeftButtonPressEvent); } else { this->State = vtkLineWidget::Outside; return; } } if (!forward) { this->Interactor->Render(); } } //------------------------------------------------------------------------------ void vtkLineWidget::OnMiddleButtonUp() { if (this->State == vtkLineWidget::Outside || this->State == vtkLineWidget::Start) { return; } this->State = vtkLineWidget::Start; this->HighlightLine(0); this->HighlightHandles(0); this->SizeHandles(); int forward = this->ForwardEvent(vtkCommand::LeftButtonReleaseEvent); this->DisablePointWidget(); this->EventCallbackCommand->SetAbortFlag(1); this->EndInteraction(); this->InvokeEvent(vtkCommand::EndInteractionEvent, nullptr); if (!forward) { this->Interactor->Render(); } } //------------------------------------------------------------------------------ void vtkLineWidget::OnRightButtonDown() { int X = this->Interactor->GetEventPosition()[0]; int Y = this->Interactor->GetEventPosition()[1]; // Okay, make sure that the pick is in the current renderer if (!this->CurrentRenderer || !this->CurrentRenderer->IsInViewport(X, Y)) { this->State = vtkLineWidget::Outside; return; } // Okay, we can process this. Try to pick handles first; // if no handles picked, then pick the bounding box. vtkAssemblyPath* path = this->GetAssemblyPath(X, Y, 0., this->HandlePicker); if (path != nullptr) { this->HighlightLine(1); this->HighlightHandles(1); this->State = vtkLineWidget::Scaling; } else { path = this->GetAssemblyPath(X, Y, 0., this->LinePicker); if (path != nullptr) { this->HighlightHandles(1); this->HighlightLine(1); this->State = vtkLineWidget::Scaling; } else { this->State = vtkLineWidget::Outside; this->HighlightLine(0); return; } } this->EventCallbackCommand->SetAbortFlag(1); this->StartInteraction(); this->InvokeEvent(vtkCommand::StartInteractionEvent, nullptr); this->Interactor->Render(); } //------------------------------------------------------------------------------ void vtkLineWidget::OnRightButtonUp() { if (this->State == vtkLineWidget::Outside || this->State == vtkLineWidget::Start) { return; } this->State = vtkLineWidget::Start; this->HighlightLine(0); this->HighlightHandles(0); this->SizeHandles(); this->EventCallbackCommand->SetAbortFlag(1); this->EndInteraction(); this->InvokeEvent(vtkCommand::EndInteractionEvent, nullptr); this->Interactor->Render(); } //------------------------------------------------------------------------------ void vtkLineWidget::OnMouseMove() { // See whether we're active if (this->State == vtkLineWidget::Outside || this->State == vtkLineWidget::Start) { return; } int X = this->Interactor->GetEventPosition()[0]; int Y = this->Interactor->GetEventPosition()[1]; // Do different things depending on state // Calculations everybody does double focalPoint[4], pickPoint[4], prevPickPoint[4]; double z; vtkCamera* camera = this->CurrentRenderer->GetActiveCamera(); if (!camera) { return; } // Compute the two points defining the motion vector this->ComputeWorldToDisplay( this->LastPickPosition[0], this->LastPickPosition[1], this->LastPickPosition[2], focalPoint); z = focalPoint[2]; this->ComputeDisplayToWorld(double(this->Interactor->GetLastEventPosition()[0]), double(this->Interactor->GetLastEventPosition()[1]), z, prevPickPoint); this->ComputeDisplayToWorld(double(X), double(Y), z, pickPoint); // Process the motion int forward = 0; if (this->State == vtkLineWidget::MovingHandle) { forward = this->ForwardEvent(vtkCommand::MouseMoveEvent); } else if (this->State == vtkLineWidget::MovingLine) { forward = this->ForwardEvent(vtkCommand::MouseMoveEvent); } else if (this->State == vtkLineWidget::Scaling) { this->Scale(prevPickPoint, pickPoint, X, Y); } // Interact, if desired this->EventCallbackCommand->SetAbortFlag(1); this->InvokeEvent(vtkCommand::InteractionEvent, nullptr); if (!forward) { this->Interactor->Render(); } } //------------------------------------------------------------------------------ void vtkLineWidget::Scale(double* p1, double* p2, int vtkNotUsed(X), int Y) { // Get the motion vector double v[3]; v[0] = p2[0] - p1[0]; v[1] = p2[1] - p1[1]; v[2] = p2[2] - p1[2]; // int res = this->LineSource->GetResolution(); double* pt1 = this->LineSource->GetPoint1(); double* pt2 = this->LineSource->GetPoint2(); double center[3]; center[0] = (pt1[0] + pt2[0]) / 2.0; center[1] = (pt1[1] + pt2[1]) / 2.0; center[2] = (pt1[2] + pt2[2]) / 2.0; // Compute the scale factor double sf = vtkMath::Norm(v) / sqrt(vtkMath::Distance2BetweenPoints(pt1, pt2)); if (Y > this->Interactor->GetLastEventPosition()[1]) { sf = 1.0 + sf; } else { sf = 1.0 - sf; } // Move the end points double point1[3], point2[3]; for (int i = 0; i < 3; i++) { point1[i] = sf * (pt1[i] - center[i]) + center[i]; point2[i] = sf * (pt2[i] - center[i]) + center[i]; } this->LineSource->SetPoint1(point1); this->LineSource->SetPoint2(point2); this->LineSource->Update(); this->BuildRepresentation(); } //------------------------------------------------------------------------------ void vtkLineWidget::CreateDefaultProperties() { // Handle properties this->HandleProperty = vtkProperty::New(); this->HandleProperty->SetColor(1, 1, 1); this->SelectedHandleProperty = vtkProperty::New(); this->SelectedHandleProperty->SetColor(1, 0, 0); // Line properties this->LineProperty = vtkProperty::New(); this->LineProperty->SetRepresentationToWireframe(); this->LineProperty->SetAmbient(1.0); this->LineProperty->SetAmbientColor(1.0, 1.0, 1.0); this->LineProperty->SetLineWidth(2.0); this->SelectedLineProperty = vtkProperty::New(); this->SelectedLineProperty->SetRepresentationToWireframe(); this->SelectedLineProperty->SetAmbient(1.0); this->SelectedLineProperty->SetAmbientColor(0.0, 1.0, 0.0); this->SelectedLineProperty->SetLineWidth(2.0); } //------------------------------------------------------------------------------ void vtkLineWidget::PlaceWidget(double bds[6]) { int i; double bounds[6], center[3]; this->AdjustBounds(bds, bounds, center); if (this->Align == vtkLineWidget::YAxis) { this->LineSource->SetPoint1(center[0], bounds[2], center[2]); this->LineSource->SetPoint2(center[0], bounds[3], center[2]); } else if (this->Align == vtkLineWidget::ZAxis) { this->LineSource->SetPoint1(center[0], center[1], bounds[4]); this->LineSource->SetPoint2(center[0], center[1], bounds[5]); } else if (this->Align == vtkLineWidget::XAxis) // default or x-aligned { this->LineSource->SetPoint1(bounds[0], center[1], center[2]); this->LineSource->SetPoint2(bounds[1], center[1], center[2]); } this->LineSource->Update(); for (i = 0; i < 6; i++) { this->InitialBounds[i] = bounds[i]; } this->InitialLength = sqrt((bounds[1] - bounds[0]) * (bounds[1] - bounds[0]) + (bounds[3] - bounds[2]) * (bounds[3] - bounds[2]) + (bounds[5] - bounds[4]) * (bounds[5] - bounds[4])); // Position the handles at the end of the lines this->BuildRepresentation(); this->SizeHandles(); } //------------------------------------------------------------------------------ void vtkLineWidget::SetPoint1(double x, double y, double z) { double xyz[3]; xyz[0] = x; xyz[1] = y; xyz[2] = z; if (this->ClampToBounds) { this->ClampPosition(xyz); this->PointWidget1->SetPosition(xyz); } this->LineSource->SetPoint1(xyz); this->BuildRepresentation(); } //------------------------------------------------------------------------------ void vtkLineWidget::SetPoint2(double x, double y, double z) { double xyz[3]; xyz[0] = x; xyz[1] = y; xyz[2] = z; if (this->ClampToBounds) { this->ClampPosition(xyz); this->PointWidget2->SetPosition(xyz); } this->LineSource->SetPoint2(xyz); this->BuildRepresentation(); } //------------------------------------------------------------------------------ void vtkLineWidget::SetLinePosition(double x[3]) { double p1[3], p2[3], v[3]; // vector of motion v[0] = x[0] - this->LastPosition[0]; v[1] = x[1] - this->LastPosition[1]; v[2] = x[2] - this->LastPosition[2]; // update position this->GetPoint1(p1); this->GetPoint2(p2); for (int i = 0; i < 3; i++) { p1[i] += v[i]; p2[i] += v[i]; } // See whether we can move if (this->ClampToBounds && (!this->InBounds(p1) || !this->InBounds(p2))) { this->PointWidget->SetPosition(this->LastPosition); return; } this->SetPoint1(p1); this->SetPoint2(p2); // remember last position this->LastPosition[0] = x[0]; this->LastPosition[1] = x[1]; this->LastPosition[2] = x[2]; } //------------------------------------------------------------------------------ void vtkLineWidget::ClampPosition(double x[3]) { for (int i = 0; i < 3; i++) { if (x[i] < this->InitialBounds[2 * i]) { x[i] = this->InitialBounds[2 * i]; } if (x[i] > this->InitialBounds[2 * i + 1]) { x[i] = this->InitialBounds[2 * i + 1]; } } } //------------------------------------------------------------------------------ int vtkLineWidget::InBounds(double x[3]) { for (int i = 0; i < 3; i++) { if (x[i] < this->InitialBounds[2 * i] || x[i] > this->InitialBounds[2 * i + 1]) { return 0; } } return 1; } //------------------------------------------------------------------------------ void vtkLineWidget::GetPolyData(vtkPolyData* pd) { pd->ShallowCopy(this->LineSource->GetOutput()); }
#include "Common.hpp" #include "Config.hpp" #include "String.hpp" #pragma warning(push) #pragma warning(disable: 4127) // if constexpr #include <yaml-cpp/yaml.h> #pragma warning(pop) #include <fstream> void Config::Load() { unordered_map::clear(); try { auto vYaml = YAML::LoadFile(AsUtf8String(x_sPath)); for (const auto &p : vYaml) { auto sKey = AsWideString(p.first.as<std::string>()); auto sVal = AsWideString(p.second.as<std::string>()); unordered_map::emplace(std::move(sKey), std::move(sVal)); } } catch (YAML::BadFile &) { } catch (YAML::ParserException &) { } for (auto &p : x_mapDefaults) { auto it = unordered_map::find(p.first); if (it == unordered_map::end()) unordered_map::emplace(p.first, p.second); } } void Config::Save() { YAML::Node vYaml; for (auto &p : *static_cast<unordered_map *>(this)) vYaml[AsUtf8String(p.first)] = AsUtf8String(p.second); std::ofstream vStream(AsUtf8String(x_sPath)); vStream << vYaml; }
/* Copyright (c) 2010-2019, AOYAMA Kazuharu * All rights reserved. * * This software may be used and distributed according to the terms of * the New BSD License, which is incorporated herein by reference. */ #include "tsystemglobal.h" #include "taccesslogstream.h" #include "tfileaiowriter.h" #include <TWebApplication> #include <TAppSettings> #include <TLogger> #include <TLog> #include <TAccessLog> #include <QString> #include <QByteArray> #include <QDateTime> #include <QFile> #include <QDir> #include <QFileInfo> #include <QSqlError> constexpr auto DEFAULT_SYSTEMLOG_LAYOUT = "%d %5P %m%n"; constexpr auto DEFAULT_SYSTEMLOG_DATETIME_FORMAT = "yyyy-MM-ddThh:mm:ss"; constexpr auto DEFAULT_ACCESSLOG_LAYOUT = "%h %d \"%r\" %s %O%n"; constexpr auto DEFAULT_ACCESSLOG_DATETIME_FORMAT = "yyyy-MM-ddThh:mm:ss"; static TAccessLogStream *accesslogstrm = nullptr; static TAccessLogStream *sqllogstrm = nullptr; static TFileAioWriter systemLog; static QByteArray syslogLayout = DEFAULT_SYSTEMLOG_LAYOUT; static QByteArray syslogDateTimeFormat = DEFAULT_SYSTEMLOG_DATETIME_FORMAT; static QByteArray accessLogLayout = DEFAULT_ACCESSLOG_LAYOUT; static QByteArray accessLogDateTimeFormat; void Tf::writeAccessLog(const TAccessLog &log) { if (accesslogstrm) { accesslogstrm->writeLog(log.toByteArray(accessLogLayout, accessLogDateTimeFormat)); } } void Tf::setupSystemLogger() { // Log directory QDir logdir(Tf::app()->logPath()); if (!logdir.exists()) { logdir.mkpath("."); } // system log systemLog.setFileName(Tf::app()->systemLogFilePath()); systemLog.open(); syslogLayout = Tf::appSettings()->value(Tf::SystemLogLayout, DEFAULT_SYSTEMLOG_LAYOUT).toByteArray(); syslogDateTimeFormat = Tf::appSettings()->value(Tf::SystemLogDateTimeFormat, DEFAULT_SYSTEMLOG_DATETIME_FORMAT).toByteArray(); } void Tf::releaseSystemLogger() { systemLog.close(); } void Tf::setupAccessLogger() { // access log QString accesslogpath = Tf::app()->accessLogFilePath(); if (!accesslogstrm && !accesslogpath.isEmpty()) { accesslogstrm = new TAccessLogStream(accesslogpath); } accessLogLayout = Tf::appSettings()->value(Tf::AccessLogLayout, DEFAULT_ACCESSLOG_LAYOUT).toByteArray(); accessLogDateTimeFormat = Tf::appSettings()->value(Tf::AccessLogDateTimeFormat, DEFAULT_ACCESSLOG_DATETIME_FORMAT).toByteArray(); } void Tf::releaseAccessLogger() { delete accesslogstrm; accesslogstrm = nullptr; } void Tf::setupQueryLogger() { // sql query log QString querylogpath = Tf::app()->sqlQueryLogFilePath(); if (!sqllogstrm && !querylogpath.isEmpty()) { sqllogstrm = new TAccessLogStream(querylogpath); } } void Tf::releaseQueryLogger() { delete sqllogstrm; sqllogstrm = nullptr; } static void tSystemMessage(int priority, const char *msg, va_list ap) { TLog log(priority, QString().vsprintf(msg, ap).toLocal8Bit()); QByteArray buf = TLogger::logToByteArray(log, syslogLayout, syslogDateTimeFormat); systemLog.write(buf.data(), buf.length()); } void tSystemError(const char *msg, ...) { va_list ap; va_start(ap, msg); tSystemMessage(Tf::ErrorLevel, msg, ap); va_end(ap); } void tSystemWarn(const char *msg, ...) { va_list ap; va_start(ap, msg); tSystemMessage(Tf::WarnLevel, msg, ap); va_end(ap); } void tSystemInfo(const char *msg, ...) { va_list ap; va_start(ap, msg); tSystemMessage(Tf::InfoLevel, msg, ap); va_end(ap); } #ifndef TF_NO_DEBUG void tSystemDebug(const char *msg, ...) { va_list ap; va_start(ap, msg); tSystemMessage(Tf::DebugLevel, msg, ap); va_end(ap); } void tSystemTrace(const char *msg, ...) { va_list ap; va_start(ap, msg); tSystemMessage(Tf::TraceLevel, msg, ap); va_end(ap); } #else void tSystemDebug(const char *, ...) { } void tSystemTrace(const char *, ...) { } #endif void Tf::traceQueryLog(const char *msg, ...) { if (sqllogstrm) { va_list ap; va_start(ap, msg); TLog log(-1, QString().vsprintf(msg, ap).toLocal8Bit()); QByteArray buf = TLogger::logToByteArray(log, syslogLayout, syslogDateTimeFormat); sqllogstrm->writeLog(buf); va_end(ap); } } void Tf::writeQueryLog(const QString &query, bool success, const QSqlError &error) { QString q = query; if (!success) { QString err = (!error.databaseText().isEmpty()) ? error.databaseText() : error.text().trimmed(); if (!err.isEmpty()) { err = QLatin1Char('[') + err + QLatin1String("] "); } q = QLatin1String("(Query failed) ") + err + query; } Tf::traceQueryLog("%s", qPrintable(q)); } QMap<QString, QVariant> Tf::settingsToMap(QSettings &settings, const QString &env) { // QSettings not thread-safe // May crash in endGroup() if used on multi-threading. #215 QMap<QString, QVariant> map; if (! env.isEmpty()) { settings.beginGroup(env); } for (auto &k : settings.allKeys()) { map.insert(k, settings.value(k)); } if (! env.isEmpty()) { settings.endGroup(); } return map; }
#include <string> #include <ios> #include <iomanip> #include <sstream> #ifndef BRA_NO_MPI # include <yampi/rank.hpp> #endif #include <bra/gate/gate.hpp> #include <bra/gate/generate_events.hpp> #include <bra/state.hpp> namespace bra { namespace gate { std::string const generate_events::name_ = "GENERATE EVENTS"; #ifndef BRA_NO_MPI generate_events::generate_events(yampi::rank const root, int num_events, int seed) : ::bra::gate::gate{}, root_{root}, num_events_{num_events}, seed_{seed} { } ::bra::state& generate_events::do_apply(::bra::state& state) const { return state.generate_events(root_, num_events_, seed_); } #else // BRA_NO_MPI generate_events::generate_events(int num_events, int seed) : ::bra::gate::gate{}, num_events_{num_events}, seed_{seed} { } ::bra::state& generate_events::do_apply(::bra::state& state) const { return state.generate_events(num_events_, seed_); } #endif // BRA_NO_MPI std::string const& generate_events::do_name() const { return name_; } std::string generate_events::do_representation( std::ostringstream& repr_stream, int const) const { return repr_stream.str(); } } // namespace gate } // namespace bra
#include <bits/stdc++.h> using namespace std; long long number(int x, int p) { if (p > 0) { x=x*pow(10,p); } else{ return x; } } int main(int argc, char const *argv[]) { int t; cin >> t; int labib; int x1, x2, p1, p2; long long a,b; for (int i = 1; i <= t; i++) { cin >> x1 >> p1; cin >> x2 >> p2; // cout <<">>>>"<< x1 << x2 << p1 << p2 << endl; a = number(x1,p1); b = number(x2,p2); // cout << "=="<< a <<" "<< b << endl; if(a>b) { printf(">\n"); } else if (a<b) { printf("<\n"); } else { printf("=\n"); } } return 0; }
/* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef SETVARREQ_H #define SETVARREQ_H #include "SignalData.hpp" #include "ConfigParamId.hpp" #define JAM_FILE_ID 183 class SetVarReq { public: static UintR size(); void mgmtSrvrBlockRef(UintR mgmtSrvrBlockRef); UintR mgmtSrvrBlockRef(void) const; void variable(ConfigParamId variable); ConfigParamId variable(void) const; void value(UintR value); UintR value(void) const; private: UintR _mgmtSrvrBlockRef; UintR _variable; UintR _value; }; inline UintR SetVarReq::size(void) { return 3; } inline void SetVarReq::mgmtSrvrBlockRef(UintR mgmtSrvrBlockRef) { _mgmtSrvrBlockRef = mgmtSrvrBlockRef; } inline UintR SetVarReq::mgmtSrvrBlockRef(void) const { return _mgmtSrvrBlockRef; } inline void SetVarReq::variable(ConfigParamId variable) { _variable = variable; } inline ConfigParamId SetVarReq::variable(void) const { return static_cast<ConfigParamId>(_variable); } inline void SetVarReq::value(UintR value) { _value = value; } inline UintR SetVarReq::value(void) const { return _value; } #undef JAM_FILE_ID #endif // SETVARREQ_H
// Copyright (c) 2015 Anton Bikineev // Copyright (c) 2015 Thomas Heller // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef HPX_SERIALIZATION_POLYMORPHIC_NONINTRUSIVE_FACTORY_IMPL_HPP #define HPX_SERIALIZATION_POLYMORPHIC_NONINTRUSIVE_FACTORY_IMPL_HPP #include <hpx/serialization/detail/polymorphic_nonintrusive_factory.hpp> #include <hpx/serialization/input_archive.hpp> #include <hpx/serialization/output_archive.hpp> #include <hpx/serialization/string.hpp> #include <string> namespace hpx { namespace serialization { namespace detail { template <typename T> void polymorphic_nonintrusive_factory::save(output_archive& ar, const T& t) { // It's safe to call typeid here. The typeid(t) return value is // only used for local lookup to the portable string that goes over the // wire std::string const class_name = typeinfo_map_.at(typeid(t).name()); ar << class_name; map_.at(class_name).save_function(ar, &t); } template <typename T> void polymorphic_nonintrusive_factory::load(input_archive& ar, T& t) { std::string class_name; ar >> class_name; map_.at(class_name).load_function(ar, &t); } template <typename T> T* polymorphic_nonintrusive_factory::load(input_archive& ar) { std::string class_name; ar >> class_name; const function_bunch_type& bunch = map_.at(class_name); T* t = static_cast<T*>(bunch.create_function(ar)); return t; } }}} // namespace hpx::serialization::detail #endif
// Copyright 2020 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/chromeos/child_accounts/family_user_chrome_activity_metrics.h" #include <memory> #include <vector> #include "base/command_line.h" #include "base/files/file_path.h" #include "base/logging.h" #include "base/test/metrics/histogram_tester.h" #include "base/time/time.h" #include "chrome/browser/apps/app_service/app_service_proxy.h" #include "chrome/browser/apps/app_service/app_service_proxy_factory.h" #include "chrome/browser/chromeos/child_accounts/time_limits/app_time_limit_utils.h" #include "chrome/browser/chromeos/child_accounts/time_limits/app_time_test_utils.h" #include "chrome/browser/chromeos/child_accounts/time_limits/app_types.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/test_extension_system.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/common/pref_names.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/test_browser_window_aura.h" #include "components/services/app_service/public/cpp/app_registry_cache.h" #include "components/services/app_service/public/mojom/types.mojom.h" namespace chromeos { namespace { constexpr char kExtensionNameChrome[] = "Chrome"; constexpr char kExtensionAppUrl[] = "https://example.com/"; constexpr base::TimeDelta kHalfHour = base::TimeDelta::FromMinutes(30); constexpr apps::InstanceState kActiveInstanceState = static_cast<apps::InstanceState>( apps::InstanceState::kStarted | apps::InstanceState::kRunning | apps::InstanceState::kActive | apps::InstanceState::kVisible); constexpr apps::InstanceState kInactiveInstanceState = static_cast<apps::InstanceState>(apps::InstanceState::kStarted | apps::InstanceState::kRunning); } // namespace class FamilyUserChromeActivityMetricsTest : public ChromeRenderViewHostTestHarness { public: FamilyUserChromeActivityMetricsTest() : ChromeRenderViewHostTestHarness( base::test::TaskEnvironment::TimeSource::MOCK_TIME) {} ~FamilyUserChromeActivityMetricsTest() override = default; void SetUp() override { ChromeRenderViewHostTestHarness::SetUp(); InitiateFamilyUserChromeActivityMetrics(); extensions::TestExtensionSystem* extension_system( static_cast<extensions::TestExtensionSystem*>( extensions::ExtensionSystem::Get(profile()))); extension_service_ = extension_system->CreateExtensionService( /*command_line=*/base::CommandLine::ForCurrentProcess(), /*install_directory=*/base::FilePath(), /*autoupdate_enabled=*/false); extension_service_->Init(); // Install Chrome. scoped_refptr<extensions::Extension> chrome = app_time::CreateExtension( extension_misc::kChromeAppId, kExtensionNameChrome, kExtensionAppUrl); extension_service_->AddComponentExtension(chrome.get()); PushChromeApp(); } void TearDown() override { DestroyFamilyUserChromeActivityMetrics(); ChromeRenderViewHostTestHarness::TearDown(); } protected: void DestroyFamilyUserChromeActivityMetrics() { family_user_chrome_activity_metrics_.reset(); } void InitiateFamilyUserChromeActivityMetrics() { family_user_chrome_activity_metrics_ = std::make_unique<FamilyUserChromeActivityMetrics>(profile()); } void PushChromeApp() { std::vector<apps::mojom::AppPtr> deltas; auto app = apps::mojom::App::New(); app->app_id = app_time::GetChromeAppId().app_id(); app->app_type = app_time::GetChromeAppId().app_type(); deltas.push_back(std::move(app)); apps::AppServiceProxyFactory::GetForProfile(profile()) ->AppRegistryCache() .OnApps(std::move(deltas), app_time::GetChromeAppId().app_type(), false /* should_notify_initialized */); } void SetActiveSessionStartTime(base::Time time) { family_user_chrome_activity_metrics_->SetActiveSessionStartForTesting(time); } void OnNewDay() { family_user_chrome_activity_metrics_->OnNewDay(); } void PushChromeAppInstance(aura::Window* window, apps::InstanceState state) { std::unique_ptr<apps::Instance> instance = std::make_unique<apps::Instance>( app_time::GetChromeAppId().app_id(), window); instance->UpdateState(state, base::Time::Now()); std::vector<std::unique_ptr<apps::Instance>> deltas; deltas.push_back(std::move(instance)); apps::AppServiceProxyFactory::GetForProfile(profile()) ->InstanceRegistry() .OnInstances(deltas); } std::unique_ptr<Browser> CreateBrowserWithAuraWindow() { std::unique_ptr<aura::Window> window = std::make_unique<aura::Window>( nullptr, aura::client::WINDOW_TYPE_NORMAL); window->set_id(0); window->Init(ui::LAYER_TEXTURED); Browser::CreateParams params(profile(), true); params.type = Browser::TYPE_NORMAL; browser_window_ = std::make_unique<TestBrowserWindowAura>(std::move(window)); params.window = browser_window_.get(); return std::unique_ptr<Browser>(Browser::Create(params)); } PrefService* pref_service() { return profile()->GetPrefs(); } private: std::unique_ptr<FamilyUserChromeActivityMetrics> family_user_chrome_activity_metrics_; std::unique_ptr<TestBrowserWindowAura> browser_window_; extensions::ExtensionService* extension_service_ = nullptr; }; TEST_F(FamilyUserChromeActivityMetricsTest, Basic) { base::HistogramTester histogram_tester; BrowserList* active_browser_list = BrowserList::GetInstance(); // Expect BrowserList is empty at the beginning. EXPECT_EQ(0U, active_browser_list->size()); std::unique_ptr<Browser> browser1 = CreateBrowserWithAuraWindow(); EXPECT_EQ(1U, active_browser_list->size()); // Set the app active. If the app is active, it should be started, running, // and visible. PushChromeAppInstance(browser1->window()->GetNativeWindow(), kActiveInstanceState); task_environment()->FastForwardBy(kHalfHour); // Set the app running in the background. PushChromeAppInstance(browser1->window()->GetNativeWindow(), kInactiveInstanceState); EXPECT_EQ(kHalfHour, pref_service()->GetTimeDelta( prefs::kFamilyUserMetricsChromeBrowserEngagementDuration)); // Test multiple browsers. std::unique_ptr<Browser> browser2 = CreateBrowserWithAuraWindow(); EXPECT_EQ(2U, active_browser_list->size()); PushChromeAppInstance(browser2->window()->GetNativeWindow(), apps::InstanceState::kActive); task_environment()->FastForwardBy(kHalfHour); PushChromeAppInstance(browser2->window()->GetNativeWindow(), apps::InstanceState::kDestroyed); EXPECT_EQ(base::TimeDelta::FromHours(1), pref_service()->GetTimeDelta( prefs::kFamilyUserMetricsChromeBrowserEngagementDuration)); // Test date change. task_environment()->FastForwardBy(base::TimeDelta::FromDays(1)); OnNewDay(); EXPECT_EQ(base::TimeDelta(), pref_service()->GetTimeDelta( prefs::kFamilyUserMetricsChromeBrowserEngagementDuration)); histogram_tester.ExpectTimeBucketCount( FamilyUserChromeActivityMetrics:: kChromeBrowserEngagementDurationHistogramName, base::TimeDelta::FromHours(1), 1); } TEST_F(FamilyUserChromeActivityMetricsTest, ClockBackward) { base::HistogramTester histogram_tester; BrowserList* active_browser_list = BrowserList::GetInstance(); EXPECT_EQ(0U, active_browser_list->size()); std::unique_ptr<Browser> browser = CreateBrowserWithAuraWindow(); // Expect that |browser| is added to browser list. EXPECT_EQ(1U, active_browser_list->size()); PushChromeAppInstance(browser->window()->GetNativeWindow(), kActiveInstanceState); base::Time mock_session_start = base::Time::Now() + kHalfHour; // Mock a state that start time > end time. SetActiveSessionStartTime(mock_session_start); PushChromeAppInstance(browser->window()->GetNativeWindow(), kInactiveInstanceState); histogram_tester.ExpectTotalCount( FamilyUserChromeActivityMetrics:: kChromeBrowserEngagementDurationHistogramName, 0); EXPECT_EQ(base::TimeDelta(), pref_service()->GetTimeDelta( prefs::kFamilyUserMetricsChromeBrowserEngagementDuration)); } // Tests destroying FamilyUserChromeActivityMetrics. OnAppInactive() will be // invoked while Chrome browser state changed to kDestroyed. TEST_F(FamilyUserChromeActivityMetricsTest, DestructionAndCreationOfFamilyUserChromeActivityMetrics) { base::HistogramTester histogram_tester; BrowserList* active_browser_list = BrowserList::GetInstance(); EXPECT_EQ(0U, active_browser_list->size()); std::unique_ptr<Browser> browser = CreateBrowserWithAuraWindow(); // Expect that |browser| is added to browser list. EXPECT_EQ(1U, active_browser_list->size()); PushChromeAppInstance(browser->window()->GetNativeWindow(), kActiveInstanceState); task_environment()->FastForwardBy(kHalfHour); PushChromeAppInstance(browser->window()->GetNativeWindow(), apps::InstanceState::kDestroyed); browser.reset(); EXPECT_EQ(0U, active_browser_list->size()); DestroyFamilyUserChromeActivityMetrics(); histogram_tester.ExpectTotalCount( FamilyUserChromeActivityMetrics:: kChromeBrowserEngagementDurationHistogramName, 0); EXPECT_EQ(kHalfHour, pref_service()->GetTimeDelta( prefs::kFamilyUserMetricsChromeBrowserEngagementDuration)); // Test restart. InitiateFamilyUserChromeActivityMetrics(); browser = CreateBrowserWithAuraWindow(); PushChromeAppInstance(browser->window()->GetNativeWindow(), kActiveInstanceState); task_environment()->FastForwardBy(kHalfHour); // Set the app running background. PushChromeAppInstance(browser->window()->GetNativeWindow(), kInactiveInstanceState); histogram_tester.ExpectTotalCount( FamilyUserChromeActivityMetrics:: kChromeBrowserEngagementDurationHistogramName, 0); EXPECT_EQ(base::TimeDelta::FromHours(1), pref_service()->GetTimeDelta( prefs::kFamilyUserMetricsChromeBrowserEngagementDuration)); } } // namespace chromeos
// Copyright 2005, Google Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Tests for Google Test itself. This verifies that the basic constructs of // Google Test work. #include "gtest/gtest.h" // Verifies that the command line flag variables can be accessed in // code once "gtest.h" has been #included. // Do not move it after other gtest #includes. TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) { bool dummy = testing::GTEST_FLAG(also_run_disabled_tests) || testing::GTEST_FLAG(break_on_failure) || testing::GTEST_FLAG(catch_exceptions) || testing::GTEST_FLAG(color) != "unknown" || testing::GTEST_FLAG(filter) != "unknown" || testing::GTEST_FLAG(list_tests) || testing::GTEST_FLAG(output) != "unknown" || testing::GTEST_FLAG(print_time) || testing::GTEST_FLAG(random_seed) || testing::GTEST_FLAG(repeat) > 0 || testing::GTEST_FLAG(show_internal_stack_frames) || testing::GTEST_FLAG(shuffle) || testing::GTEST_FLAG(stack_trace_depth) > 0 || testing::GTEST_FLAG(stream_result_to) != "unknown" || testing::GTEST_FLAG(throw_on_failure); EXPECT_TRUE(dummy || !dummy); // Suppresses warning that dummy is unused. } #include <limits.h> // For INT_MAX. #include <stdlib.h> #include <string.h> #include <time.h> #include <map> #include <vector> #include <ostream> #if GTEST_LANG_CXX11 #include <unordered_set> #endif // GTEST_LANG_CXX11 #include "gtest/gtest-spi.h" #include "src/gtest-internal-inl.h" namespace testing { namespace internal { #if GTEST_CAN_STREAM_RESULTS_ class StreamingListenerTest : public Test { public: class FakeSocketWriter : public StreamingListener::AbstractSocketWriter { public: // Sends a string to the socket. virtual void Send(const std::string& message) { output_ += message; } std::string output_; }; StreamingListenerTest() : fake_sock_writer_(new FakeSocketWriter), streamer_(fake_sock_writer_), test_info_obj_("FooTest", "Bar", NULL, NULL, CodeLocation(__FILE__, __LINE__), 0, NULL) {} protected: std::string* output() { return &(fake_sock_writer_->output_); } FakeSocketWriter* const fake_sock_writer_; StreamingListener streamer_; UnitTest unit_test_; TestInfo test_info_obj_; // The name test_info_ was taken by testing::Test. }; TEST_F(StreamingListenerTest, OnTestProgramEnd) { *output() = ""; streamer_.OnTestProgramEnd(unit_test_); EXPECT_EQ("event=TestProgramEnd&passed=1\n", *output()); } TEST_F(StreamingListenerTest, OnTestIterationEnd) { *output() = ""; streamer_.OnTestIterationEnd(unit_test_, 42); EXPECT_EQ("event=TestIterationEnd&passed=1&elapsed_time=0ms\n", *output()); } TEST_F(StreamingListenerTest, OnTestCaseStart) { *output() = ""; streamer_.OnTestCaseStart(TestCase("FooTest", "Bar", NULL, NULL)); EXPECT_EQ("event=TestCaseStart&name=FooTest\n", *output()); } TEST_F(StreamingListenerTest, OnTestCaseEnd) { *output() = ""; streamer_.OnTestCaseEnd(TestCase("FooTest", "Bar", NULL, NULL)); EXPECT_EQ("event=TestCaseEnd&passed=1&elapsed_time=0ms\n", *output()); } TEST_F(StreamingListenerTest, OnTestStart) { *output() = ""; streamer_.OnTestStart(test_info_obj_); EXPECT_EQ("event=TestStart&name=Bar\n", *output()); } TEST_F(StreamingListenerTest, OnTestEnd) { *output() = ""; streamer_.OnTestEnd(test_info_obj_); EXPECT_EQ("event=TestEnd&passed=1&elapsed_time=0ms\n", *output()); } TEST_F(StreamingListenerTest, OnTestPartResult) { *output() = ""; streamer_.OnTestPartResult(TestPartResult( TestPartResult::kFatalFailure, "foo.cc", 42, "failed=\n&%")); // Meta characters in the failure message should be properly escaped. EXPECT_EQ( "event=TestPartResult&file=foo.cc&line=42&message=failed%3D%0A%26%25\n", *output()); } #endif // GTEST_CAN_STREAM_RESULTS_ // Provides access to otherwise private parts of the TestEventListeners class // that are needed to test it. class TestEventListenersAccessor { public: static TestEventListener* GetRepeater(TestEventListeners* listeners) { return listeners->repeater(); } static void SetDefaultResultPrinter(TestEventListeners* listeners, TestEventListener* listener) { listeners->SetDefaultResultPrinter(listener); } static void SetDefaultXmlGenerator(TestEventListeners* listeners, TestEventListener* listener) { listeners->SetDefaultXmlGenerator(listener); } static bool EventForwardingEnabled(const TestEventListeners& listeners) { return listeners.EventForwardingEnabled(); } static void SuppressEventForwarding(TestEventListeners* listeners) { listeners->SuppressEventForwarding(); } }; class UnitTestRecordPropertyTestHelper : public Test { protected: UnitTestRecordPropertyTestHelper() {} // Forwards to UnitTest::RecordProperty() to bypass access controls. void UnitTestRecordProperty(const char* key, const std::string& value) { unit_test_.RecordProperty(key, value); } UnitTest unit_test_; }; } // namespace internal } // namespace testing using testing::AssertionFailure; using testing::AssertionResult; using testing::AssertionSuccess; using testing::DoubleLE; using testing::EmptyTestEventListener; using testing::Environment; using testing::FloatLE; using testing::GTEST_FLAG(also_run_disabled_tests); using testing::GTEST_FLAG(break_on_failure); using testing::GTEST_FLAG(catch_exceptions); using testing::GTEST_FLAG(color); using testing::GTEST_FLAG(death_test_use_fork); using testing::GTEST_FLAG(filter); using testing::GTEST_FLAG(list_tests); using testing::GTEST_FLAG(output); using testing::GTEST_FLAG(print_time); using testing::GTEST_FLAG(random_seed); using testing::GTEST_FLAG(repeat); using testing::GTEST_FLAG(show_internal_stack_frames); using testing::GTEST_FLAG(shuffle); using testing::GTEST_FLAG(stack_trace_depth); using testing::GTEST_FLAG(stream_result_to); using testing::GTEST_FLAG(throw_on_failure); using testing::IsNotSubstring; using testing::IsSubstring; using testing::Message; using testing::ScopedFakeTestPartResultReporter; using testing::StaticAssertTypeEq; using testing::Test; using testing::TestCase; using testing::TestEventListeners; using testing::TestInfo; using testing::TestPartResult; using testing::TestPartResultArray; using testing::TestProperty; using testing::TestResult; using testing::TimeInMillis; using testing::UnitTest; using testing::internal::AddReference; using testing::internal::AlwaysFalse; using testing::internal::AlwaysTrue; using testing::internal::AppendUserMessage; using testing::internal::ArrayAwareFind; using testing::internal::ArrayEq; using testing::internal::CodePointToUtf8; using testing::internal::CompileAssertTypesEqual; using testing::internal::CopyArray; using testing::internal::CountIf; using testing::internal::EqFailure; using testing::internal::FloatingPoint; using testing::internal::ForEach; using testing::internal::FormatEpochTimeInMillisAsIso8601; using testing::internal::FormatTimeInMillisAsSeconds; using testing::internal::GTestFlagSaver; using testing::internal::GetCurrentOsStackTraceExceptTop; using testing::internal::GetElementOr; using testing::internal::GetNextRandomSeed; using testing::internal::GetRandomSeedFromFlag; using testing::internal::GetTestTypeId; using testing::internal::GetTimeInMillis; using testing::internal::GetTypeId; using testing::internal::GetUnitTestImpl; using testing::internal::ImplicitlyConvertible; using testing::internal::Int32; using testing::internal::Int32FromEnvOrDie; using testing::internal::IsAProtocolMessage; using testing::internal::IsContainer; using testing::internal::IsContainerTest; using testing::internal::IsNotContainer; using testing::internal::NativeArray; using testing::internal::OsStackTraceGetter; using testing::internal::OsStackTraceGetterInterface; using testing::internal::ParseInt32Flag; using testing::internal::RelationToSourceCopy; using testing::internal::RelationToSourceReference; using testing::internal::RemoveConst; using testing::internal::RemoveReference; using testing::internal::ShouldRunTestOnShard; using testing::internal::ShouldShard; using testing::internal::ShouldUseColor; using testing::internal::Shuffle; using testing::internal::ShuffleRange; using testing::internal::SkipPrefix; using testing::internal::StreamableToString; using testing::internal::String; using testing::internal::TestEventListenersAccessor; using testing::internal::TestResultAccessor; using testing::internal::UInt32; using testing::internal::UnitTestImpl; using testing::internal::WideStringToUtf8; using testing::internal::edit_distance::CalculateOptimalEdits; using testing::internal::edit_distance::CreateUnifiedDiff; using testing::internal::edit_distance::EditType; using testing::internal::kMaxRandomSeed; using testing::internal::kTestTypeIdInGoogleTest; using testing::kMaxStackTraceDepth; #if GTEST_HAS_STREAM_REDIRECTION using testing::internal::CaptureStdout; using testing::internal::GetCapturedStdout; #endif #if GTEST_IS_THREADSAFE using testing::internal::ThreadWithParam; #endif class TestingVector : public std::vector<int> { }; ::std::ostream& operator<<(::std::ostream& os, const TestingVector& vector) { os << "{ "; for (size_t i = 0; i < vector.size(); i++) { os << vector[i] << " "; } os << "}"; return os; } // This line tests that we can define tests in an unnamed namespace. namespace { TEST(GetRandomSeedFromFlagTest, HandlesZero) { const int seed = GetRandomSeedFromFlag(0); EXPECT_LE(1, seed); EXPECT_LE(seed, static_cast<int>(kMaxRandomSeed)); } TEST(GetRandomSeedFromFlagTest, PreservesValidSeed) { EXPECT_EQ(1, GetRandomSeedFromFlag(1)); EXPECT_EQ(2, GetRandomSeedFromFlag(2)); EXPECT_EQ(kMaxRandomSeed - 1, GetRandomSeedFromFlag(kMaxRandomSeed - 1)); EXPECT_EQ(static_cast<int>(kMaxRandomSeed), GetRandomSeedFromFlag(kMaxRandomSeed)); } TEST(GetRandomSeedFromFlagTest, NormalizesInvalidSeed) { const int seed1 = GetRandomSeedFromFlag(-1); EXPECT_LE(1, seed1); EXPECT_LE(seed1, static_cast<int>(kMaxRandomSeed)); const int seed2 = GetRandomSeedFromFlag(kMaxRandomSeed + 1); EXPECT_LE(1, seed2); EXPECT_LE(seed2, static_cast<int>(kMaxRandomSeed)); } TEST(GetNextRandomSeedTest, WorksForValidInput) { EXPECT_EQ(2, GetNextRandomSeed(1)); EXPECT_EQ(3, GetNextRandomSeed(2)); EXPECT_EQ(static_cast<int>(kMaxRandomSeed), GetNextRandomSeed(kMaxRandomSeed - 1)); EXPECT_EQ(1, GetNextRandomSeed(kMaxRandomSeed)); // We deliberately don't test GetNextRandomSeed() with invalid // inputs, as that requires death tests, which are expensive. This // is fine as GetNextRandomSeed() is internal and has a // straightforward definition. } static void ClearCurrentTestPartResults() { TestResultAccessor::ClearTestPartResults( GetUnitTestImpl()->current_test_result()); } // Tests GetTypeId. TEST(GetTypeIdTest, ReturnsSameValueForSameType) { EXPECT_EQ(GetTypeId<int>(), GetTypeId<int>()); EXPECT_EQ(GetTypeId<Test>(), GetTypeId<Test>()); } class SubClassOfTest : public Test {}; class AnotherSubClassOfTest : public Test {}; TEST(GetTypeIdTest, ReturnsDifferentValuesForDifferentTypes) { EXPECT_NE(GetTypeId<int>(), GetTypeId<const int>()); EXPECT_NE(GetTypeId<int>(), GetTypeId<char>()); EXPECT_NE(GetTypeId<int>(), GetTestTypeId()); EXPECT_NE(GetTypeId<SubClassOfTest>(), GetTestTypeId()); EXPECT_NE(GetTypeId<AnotherSubClassOfTest>(), GetTestTypeId()); EXPECT_NE(GetTypeId<AnotherSubClassOfTest>(), GetTypeId<SubClassOfTest>()); } // Verifies that GetTestTypeId() returns the same value, no matter it // is called from inside Google Test or outside of it. TEST(GetTestTypeIdTest, ReturnsTheSameValueInsideOrOutsideOfGoogleTest) { EXPECT_EQ(kTestTypeIdInGoogleTest, GetTestTypeId()); } // Tests CanonicalizeForStdLibVersioning. using ::testing::internal::CanonicalizeForStdLibVersioning; TEST(CanonicalizeForStdLibVersioning, LeavesUnversionedNamesUnchanged) { EXPECT_EQ("std::bind", CanonicalizeForStdLibVersioning("std::bind")); EXPECT_EQ("std::_", CanonicalizeForStdLibVersioning("std::_")); EXPECT_EQ("std::__foo", CanonicalizeForStdLibVersioning("std::__foo")); EXPECT_EQ("gtl::__1::x", CanonicalizeForStdLibVersioning("gtl::__1::x")); EXPECT_EQ("__1::x", CanonicalizeForStdLibVersioning("__1::x")); EXPECT_EQ("::__1::x", CanonicalizeForStdLibVersioning("::__1::x")); } TEST(CanonicalizeForStdLibVersioning, ElidesDoubleUnderNames) { EXPECT_EQ("std::bind", CanonicalizeForStdLibVersioning("std::__1::bind")); EXPECT_EQ("std::_", CanonicalizeForStdLibVersioning("std::__1::_")); EXPECT_EQ("std::bind", CanonicalizeForStdLibVersioning("std::__g::bind")); EXPECT_EQ("std::_", CanonicalizeForStdLibVersioning("std::__g::_")); EXPECT_EQ("std::bind", CanonicalizeForStdLibVersioning("std::__google::bind")); EXPECT_EQ("std::_", CanonicalizeForStdLibVersioning("std::__google::_")); } // Tests FormatTimeInMillisAsSeconds(). TEST(FormatTimeInMillisAsSecondsTest, FormatsZero) { EXPECT_EQ("0", FormatTimeInMillisAsSeconds(0)); } TEST(FormatTimeInMillisAsSecondsTest, FormatsPositiveNumber) { EXPECT_EQ("0.003", FormatTimeInMillisAsSeconds(3)); EXPECT_EQ("0.01", FormatTimeInMillisAsSeconds(10)); EXPECT_EQ("0.2", FormatTimeInMillisAsSeconds(200)); EXPECT_EQ("1.2", FormatTimeInMillisAsSeconds(1200)); EXPECT_EQ("3", FormatTimeInMillisAsSeconds(3000)); } TEST(FormatTimeInMillisAsSecondsTest, FormatsNegativeNumber) { EXPECT_EQ("-0.003", FormatTimeInMillisAsSeconds(-3)); EXPECT_EQ("-0.01", FormatTimeInMillisAsSeconds(-10)); EXPECT_EQ("-0.2", FormatTimeInMillisAsSeconds(-200)); EXPECT_EQ("-1.2", FormatTimeInMillisAsSeconds(-1200)); EXPECT_EQ("-3", FormatTimeInMillisAsSeconds(-3000)); } // Tests FormatEpochTimeInMillisAsIso8601(). The correctness of conversion // for particular dates below was verified in Python using // datetime.datetime.fromutctimestamp(<timetamp>/1000). // FormatEpochTimeInMillisAsIso8601 depends on the current timezone, so we // have to set up a particular timezone to obtain predictable results. class FormatEpochTimeInMillisAsIso8601Test : public Test { public: // On Cygwin, GCC doesn't allow unqualified integer literals to exceed // 32 bits, even when 64-bit integer types are available. We have to // force the constants to have a 64-bit type here. static const TimeInMillis kMillisPerSec = 1000; private: virtual void SetUp() { saved_tz_ = NULL; GTEST_DISABLE_MSC_DEPRECATED_PUSH_(/* getenv, strdup: deprecated */) if (getenv("TZ")) saved_tz_ = strdup(getenv("TZ")); GTEST_DISABLE_MSC_DEPRECATED_POP_() // Set up the time zone for FormatEpochTimeInMillisAsIso8601 to use. We // cannot use the local time zone because the function's output depends // on the time zone. SetTimeZone("UTC+00"); } virtual void TearDown() { SetTimeZone(saved_tz_); free(const_cast<char*>(saved_tz_)); saved_tz_ = NULL; } static void SetTimeZone(const char* time_zone) { // tzset() distinguishes between the TZ variable being present and empty // and not being present, so we have to consider the case of time_zone // being NULL. #if _MSC_VER || GTEST_OS_WINDOWS_MINGW // ...Unless it's MSVC, whose standard library's _putenv doesn't // distinguish between an empty and a missing variable. const std::string env_var = std::string("TZ=") + (time_zone ? time_zone : ""); _putenv(env_var.c_str()); GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996 /* deprecated function */) tzset(); GTEST_DISABLE_MSC_WARNINGS_POP_() #else if (time_zone) { setenv(("TZ"), time_zone, 1); } else { unsetenv("TZ"); } tzset(); #endif } const char* saved_tz_; }; const TimeInMillis FormatEpochTimeInMillisAsIso8601Test::kMillisPerSec; TEST_F(FormatEpochTimeInMillisAsIso8601Test, PrintsTwoDigitSegments) { EXPECT_EQ("2011-10-31T18:52:42", FormatEpochTimeInMillisAsIso8601(1320087162 * kMillisPerSec)); } TEST_F(FormatEpochTimeInMillisAsIso8601Test, MillisecondsDoNotAffectResult) { EXPECT_EQ( "2011-10-31T18:52:42", FormatEpochTimeInMillisAsIso8601(1320087162 * kMillisPerSec + 234)); } TEST_F(FormatEpochTimeInMillisAsIso8601Test, PrintsLeadingZeroes) { EXPECT_EQ("2011-09-03T05:07:02", FormatEpochTimeInMillisAsIso8601(1315026422 * kMillisPerSec)); } TEST_F(FormatEpochTimeInMillisAsIso8601Test, Prints24HourTime) { EXPECT_EQ("2011-09-28T17:08:22", FormatEpochTimeInMillisAsIso8601(1317229702 * kMillisPerSec)); } TEST_F(FormatEpochTimeInMillisAsIso8601Test, PrintsEpochStart) { EXPECT_EQ("1970-01-01T00:00:00", FormatEpochTimeInMillisAsIso8601(0)); } #if GTEST_CAN_COMPARE_NULL # ifdef __BORLANDC__ // Silences warnings: "Condition is always true", "Unreachable code" # pragma option push -w-ccc -w-rch # endif // Tests that GTEST_IS_NULL_LITERAL_(x) is true when x is a null // pointer literal. TEST(NullLiteralTest, IsTrueForNullLiterals) { EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(NULL)); EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(0)); EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(0U)); EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(0L)); } // Tests that GTEST_IS_NULL_LITERAL_(x) is false when x is not a null // pointer literal. TEST(NullLiteralTest, IsFalseForNonNullLiterals) { EXPECT_FALSE(GTEST_IS_NULL_LITERAL_(1)); EXPECT_FALSE(GTEST_IS_NULL_LITERAL_(0.0)); EXPECT_FALSE(GTEST_IS_NULL_LITERAL_('a')); EXPECT_FALSE(GTEST_IS_NULL_LITERAL_(static_cast<void*>(NULL))); } # ifdef __BORLANDC__ // Restores warnings after previous "#pragma option push" suppressed them. # pragma option pop # endif #endif // GTEST_CAN_COMPARE_NULL // // Tests CodePointToUtf8(). // Tests that the NUL character L'\0' is encoded correctly. TEST(CodePointToUtf8Test, CanEncodeNul) { EXPECT_EQ("", CodePointToUtf8(L'\0')); } // Tests that ASCII characters are encoded correctly. TEST(CodePointToUtf8Test, CanEncodeAscii) { EXPECT_EQ("a", CodePointToUtf8(L'a')); EXPECT_EQ("Z", CodePointToUtf8(L'Z')); EXPECT_EQ("&", CodePointToUtf8(L'&')); EXPECT_EQ("\x7F", CodePointToUtf8(L'\x7F')); } // Tests that Unicode code-points that have 8 to 11 bits are encoded // as 110xxxxx 10xxxxxx. TEST(CodePointToUtf8Test, CanEncode8To11Bits) { // 000 1101 0011 => 110-00011 10-010011 EXPECT_EQ("\xC3\x93", CodePointToUtf8(L'\xD3')); // 101 0111 0110 => 110-10101 10-110110 // Some compilers (e.g., GCC on MinGW) cannot handle non-ASCII codepoints // in wide strings and wide chars. In order to accommodate them, we have to // introduce such character constants as integers. EXPECT_EQ("\xD5\xB6", CodePointToUtf8(static_cast<wchar_t>(0x576))); } // Tests that Unicode code-points that have 12 to 16 bits are encoded // as 1110xxxx 10xxxxxx 10xxxxxx. TEST(CodePointToUtf8Test, CanEncode12To16Bits) { // 0000 1000 1101 0011 => 1110-0000 10-100011 10-010011 EXPECT_EQ("\xE0\xA3\x93", CodePointToUtf8(static_cast<wchar_t>(0x8D3))); // 1100 0111 0100 1101 => 1110-1100 10-011101 10-001101 EXPECT_EQ("\xEC\x9D\x8D", CodePointToUtf8(static_cast<wchar_t>(0xC74D))); } #if !GTEST_WIDE_STRING_USES_UTF16_ // Tests in this group require a wchar_t to hold > 16 bits, and thus // are skipped on Windows, Cygwin, and Symbian, where a wchar_t is // 16-bit wide. This code may not compile on those systems. // Tests that Unicode code-points that have 17 to 21 bits are encoded // as 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx. TEST(CodePointToUtf8Test, CanEncode17To21Bits) { // 0 0001 0000 1000 1101 0011 => 11110-000 10-010000 10-100011 10-010011 EXPECT_EQ("\xF0\x90\xA3\x93", CodePointToUtf8(L'\x108D3')); // 0 0001 0000 0100 0000 0000 => 11110-000 10-010000 10-010000 10-000000 EXPECT_EQ("\xF0\x90\x90\x80", CodePointToUtf8(L'\x10400')); // 1 0000 1000 0110 0011 0100 => 11110-100 10-001000 10-011000 10-110100 EXPECT_EQ("\xF4\x88\x98\xB4", CodePointToUtf8(L'\x108634')); } // Tests that encoding an invalid code-point generates the expected result. TEST(CodePointToUtf8Test, CanEncodeInvalidCodePoint) { EXPECT_EQ("(Invalid Unicode 0x1234ABCD)", CodePointToUtf8(L'\x1234ABCD')); } #endif // !GTEST_WIDE_STRING_USES_UTF16_ // Tests WideStringToUtf8(). // Tests that the NUL character L'\0' is encoded correctly. TEST(WideStringToUtf8Test, CanEncodeNul) { EXPECT_STREQ("", WideStringToUtf8(L"", 0).c_str()); EXPECT_STREQ("", WideStringToUtf8(L"", -1).c_str()); } // Tests that ASCII strings are encoded correctly. TEST(WideStringToUtf8Test, CanEncodeAscii) { EXPECT_STREQ("a", WideStringToUtf8(L"a", 1).c_str()); EXPECT_STREQ("ab", WideStringToUtf8(L"ab", 2).c_str()); EXPECT_STREQ("a", WideStringToUtf8(L"a", -1).c_str()); EXPECT_STREQ("ab", WideStringToUtf8(L"ab", -1).c_str()); } // Tests that Unicode code-points that have 8 to 11 bits are encoded // as 110xxxxx 10xxxxxx. TEST(WideStringToUtf8Test, CanEncode8To11Bits) { // 000 1101 0011 => 110-00011 10-010011 EXPECT_STREQ("\xC3\x93", WideStringToUtf8(L"\xD3", 1).c_str()); EXPECT_STREQ("\xC3\x93", WideStringToUtf8(L"\xD3", -1).c_str()); // 101 0111 0110 => 110-10101 10-110110 const wchar_t s[] = { 0x576, '\0' }; EXPECT_STREQ("\xD5\xB6", WideStringToUtf8(s, 1).c_str()); EXPECT_STREQ("\xD5\xB6", WideStringToUtf8(s, -1).c_str()); } // Tests that Unicode code-points that have 12 to 16 bits are encoded // as 1110xxxx 10xxxxxx 10xxxxxx. TEST(WideStringToUtf8Test, CanEncode12To16Bits) { // 0000 1000 1101 0011 => 1110-0000 10-100011 10-010011 const wchar_t s1[] = { 0x8D3, '\0' }; EXPECT_STREQ("\xE0\xA3\x93", WideStringToUtf8(s1, 1).c_str()); EXPECT_STREQ("\xE0\xA3\x93", WideStringToUtf8(s1, -1).c_str()); // 1100 0111 0100 1101 => 1110-1100 10-011101 10-001101 const wchar_t s2[] = { 0xC74D, '\0' }; EXPECT_STREQ("\xEC\x9D\x8D", WideStringToUtf8(s2, 1).c_str()); EXPECT_STREQ("\xEC\x9D\x8D", WideStringToUtf8(s2, -1).c_str()); } // Tests that the conversion stops when the function encounters \0 character. TEST(WideStringToUtf8Test, StopsOnNulCharacter) { EXPECT_STREQ("ABC", WideStringToUtf8(L"ABC\0XYZ", 100).c_str()); } // Tests that the conversion stops when the function reaches the limit // specified by the 'length' parameter. TEST(WideStringToUtf8Test, StopsWhenLengthLimitReached) { EXPECT_STREQ("ABC", WideStringToUtf8(L"ABCDEF", 3).c_str()); } #if !GTEST_WIDE_STRING_USES_UTF16_ // Tests that Unicode code-points that have 17 to 21 bits are encoded // as 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx. This code may not compile // on the systems using UTF-16 encoding. TEST(WideStringToUtf8Test, CanEncode17To21Bits) { // 0 0001 0000 1000 1101 0011 => 11110-000 10-010000 10-100011 10-010011 EXPECT_STREQ("\xF0\x90\xA3\x93", WideStringToUtf8(L"\x108D3", 1).c_str()); EXPECT_STREQ("\xF0\x90\xA3\x93", WideStringToUtf8(L"\x108D3", -1).c_str()); // 1 0000 1000 0110 0011 0100 => 11110-100 10-001000 10-011000 10-110100 EXPECT_STREQ("\xF4\x88\x98\xB4", WideStringToUtf8(L"\x108634", 1).c_str()); EXPECT_STREQ("\xF4\x88\x98\xB4", WideStringToUtf8(L"\x108634", -1).c_str()); } // Tests that encoding an invalid code-point generates the expected result. TEST(WideStringToUtf8Test, CanEncodeInvalidCodePoint) { EXPECT_STREQ("(Invalid Unicode 0xABCDFF)", WideStringToUtf8(L"\xABCDFF", -1).c_str()); } #else // !GTEST_WIDE_STRING_USES_UTF16_ // Tests that surrogate pairs are encoded correctly on the systems using // UTF-16 encoding in the wide strings. TEST(WideStringToUtf8Test, CanEncodeValidUtf16SUrrogatePairs) { const wchar_t s[] = { 0xD801, 0xDC00, '\0' }; EXPECT_STREQ("\xF0\x90\x90\x80", WideStringToUtf8(s, -1).c_str()); } // Tests that encoding an invalid UTF-16 surrogate pair // generates the expected result. TEST(WideStringToUtf8Test, CanEncodeInvalidUtf16SurrogatePair) { // Leading surrogate is at the end of the string. const wchar_t s1[] = { 0xD800, '\0' }; EXPECT_STREQ("\xED\xA0\x80", WideStringToUtf8(s1, -1).c_str()); // Leading surrogate is not followed by the trailing surrogate. const wchar_t s2[] = { 0xD800, 'M', '\0' }; EXPECT_STREQ("\xED\xA0\x80M", WideStringToUtf8(s2, -1).c_str()); // Trailing surrogate appearas without a leading surrogate. const wchar_t s3[] = { 0xDC00, 'P', 'Q', 'R', '\0' }; EXPECT_STREQ("\xED\xB0\x80PQR", WideStringToUtf8(s3, -1).c_str()); } #endif // !GTEST_WIDE_STRING_USES_UTF16_ // Tests that codepoint concatenation works correctly. #if !GTEST_WIDE_STRING_USES_UTF16_ TEST(WideStringToUtf8Test, ConcatenatesCodepointsCorrectly) { const wchar_t s[] = { 0x108634, 0xC74D, '\n', 0x576, 0x8D3, 0x108634, '\0'}; EXPECT_STREQ( "\xF4\x88\x98\xB4" "\xEC\x9D\x8D" "\n" "\xD5\xB6" "\xE0\xA3\x93" "\xF4\x88\x98\xB4", WideStringToUtf8(s, -1).c_str()); } #else TEST(WideStringToUtf8Test, ConcatenatesCodepointsCorrectly) { const wchar_t s[] = { 0xC74D, '\n', 0x576, 0x8D3, '\0'}; EXPECT_STREQ( "\xEC\x9D\x8D" "\n" "\xD5\xB6" "\xE0\xA3\x93", WideStringToUtf8(s, -1).c_str()); } #endif // !GTEST_WIDE_STRING_USES_UTF16_ // Tests the Random class. TEST(RandomDeathTest, GeneratesCrashesOnInvalidRange) { testing::internal::Random random(42); EXPECT_DEATH_IF_SUPPORTED( random.Generate(0), "Cannot generate a number in the range \\[0, 0\\)"); EXPECT_DEATH_IF_SUPPORTED( random.Generate(testing::internal::Random::kMaxRange + 1), "Generation of a number in \\[0, 2147483649\\) was requested, " "but this can only generate numbers in \\[0, 2147483648\\)"); } TEST(RandomTest, GeneratesNumbersWithinRange) { const UInt32 kRange = 10000; testing::internal::Random random(12345); for (int i = 0; i < 10; i++) { EXPECT_LT(random.Generate(kRange), kRange) << " for iteration " << i; } testing::internal::Random random2(testing::internal::Random::kMaxRange); for (int i = 0; i < 10; i++) { EXPECT_LT(random2.Generate(kRange), kRange) << " for iteration " << i; } } TEST(RandomTest, RepeatsWhenReseeded) { const int kSeed = 123; const int kArraySize = 10; const UInt32 kRange = 10000; UInt32 values[kArraySize]; testing::internal::Random random(kSeed); for (int i = 0; i < kArraySize; i++) { values[i] = random.Generate(kRange); } random.Reseed(kSeed); for (int i = 0; i < kArraySize; i++) { EXPECT_EQ(values[i], random.Generate(kRange)) << " for iteration " << i; } } // Tests STL container utilities. // Tests CountIf(). static bool IsPositive(int n) { return n > 0; } TEST(ContainerUtilityTest, CountIf) { std::vector<int> v; EXPECT_EQ(0, CountIf(v, IsPositive)); // Works for an empty container. v.push_back(-1); v.push_back(0); EXPECT_EQ(0, CountIf(v, IsPositive)); // Works when no value satisfies. v.push_back(2); v.push_back(-10); v.push_back(10); EXPECT_EQ(2, CountIf(v, IsPositive)); } // Tests ForEach(). static int g_sum = 0; static void Accumulate(int n) { g_sum += n; } TEST(ContainerUtilityTest, ForEach) { std::vector<int> v; g_sum = 0; ForEach(v, Accumulate); EXPECT_EQ(0, g_sum); // Works for an empty container; g_sum = 0; v.push_back(1); ForEach(v, Accumulate); EXPECT_EQ(1, g_sum); // Works for a container with one element. g_sum = 0; v.push_back(20); v.push_back(300); ForEach(v, Accumulate); EXPECT_EQ(321, g_sum); } // Tests GetElementOr(). TEST(ContainerUtilityTest, GetElementOr) { std::vector<char> a; EXPECT_EQ('x', GetElementOr(a, 0, 'x')); a.push_back('a'); a.push_back('b'); EXPECT_EQ('a', GetElementOr(a, 0, 'x')); EXPECT_EQ('b', GetElementOr(a, 1, 'x')); EXPECT_EQ('x', GetElementOr(a, -2, 'x')); EXPECT_EQ('x', GetElementOr(a, 2, 'x')); } TEST(ContainerUtilityDeathTest, ShuffleRange) { std::vector<int> a; a.push_back(0); a.push_back(1); a.push_back(2); testing::internal::Random random(1); EXPECT_DEATH_IF_SUPPORTED( ShuffleRange(&random, -1, 1, &a), "Invalid shuffle range start -1: must be in range \\[0, 3\\]"); EXPECT_DEATH_IF_SUPPORTED( ShuffleRange(&random, 4, 4, &a), "Invalid shuffle range start 4: must be in range \\[0, 3\\]"); EXPECT_DEATH_IF_SUPPORTED( ShuffleRange(&random, 3, 2, &a), "Invalid shuffle range finish 2: must be in range \\[3, 3\\]"); EXPECT_DEATH_IF_SUPPORTED( ShuffleRange(&random, 3, 4, &a), "Invalid shuffle range finish 4: must be in range \\[3, 3\\]"); } class VectorShuffleTest : public Test { protected: static const int kVectorSize = 20; VectorShuffleTest() : random_(1) { for (int i = 0; i < kVectorSize; i++) { vector_.push_back(i); } } static bool VectorIsCorrupt(const TestingVector& vector) { if (kVectorSize != static_cast<int>(vector.size())) { return true; } bool found_in_vector[kVectorSize] = { false }; for (size_t i = 0; i < vector.size(); i++) { const int e = vector[i]; if (e < 0 || e >= kVectorSize || found_in_vector[e]) { return true; } found_in_vector[e] = true; } // Vector size is correct, elements' range is correct, no // duplicate elements. Therefore no corruption has occurred. return false; } static bool VectorIsNotCorrupt(const TestingVector& vector) { return !VectorIsCorrupt(vector); } static bool RangeIsShuffled(const TestingVector& vector, int begin, int end) { for (int i = begin; i < end; i++) { if (i != vector[i]) { return true; } } return false; } static bool RangeIsUnshuffled( const TestingVector& vector, int begin, int end) { return !RangeIsShuffled(vector, begin, end); } static bool VectorIsShuffled(const TestingVector& vector) { return RangeIsShuffled(vector, 0, static_cast<int>(vector.size())); } static bool VectorIsUnshuffled(const TestingVector& vector) { return !VectorIsShuffled(vector); } testing::internal::Random random_; TestingVector vector_; }; // class VectorShuffleTest const int VectorShuffleTest::kVectorSize; TEST_F(VectorShuffleTest, HandlesEmptyRange) { // Tests an empty range at the beginning... ShuffleRange(&random_, 0, 0, &vector_); ASSERT_PRED1(VectorIsNotCorrupt, vector_); ASSERT_PRED1(VectorIsUnshuffled, vector_); // ...in the middle... ShuffleRange(&random_, kVectorSize/2, kVectorSize/2, &vector_); ASSERT_PRED1(VectorIsNotCorrupt, vector_); ASSERT_PRED1(VectorIsUnshuffled, vector_); // ...at the end... ShuffleRange(&random_, kVectorSize - 1, kVectorSize - 1, &vector_); ASSERT_PRED1(VectorIsNotCorrupt, vector_); ASSERT_PRED1(VectorIsUnshuffled, vector_); // ...and past the end. ShuffleRange(&random_, kVectorSize, kVectorSize, &vector_); ASSERT_PRED1(VectorIsNotCorrupt, vector_); ASSERT_PRED1(VectorIsUnshuffled, vector_); } TEST_F(VectorShuffleTest, HandlesRangeOfSizeOne) { // Tests a size one range at the beginning... ShuffleRange(&random_, 0, 1, &vector_); ASSERT_PRED1(VectorIsNotCorrupt, vector_); ASSERT_PRED1(VectorIsUnshuffled, vector_); // ...in the middle... ShuffleRange(&random_, kVectorSize/2, kVectorSize/2 + 1, &vector_); ASSERT_PRED1(VectorIsNotCorrupt, vector_); ASSERT_PRED1(VectorIsUnshuffled, vector_); // ...and at the end. ShuffleRange(&random_, kVectorSize - 1, kVectorSize, &vector_); ASSERT_PRED1(VectorIsNotCorrupt, vector_); ASSERT_PRED1(VectorIsUnshuffled, vector_); } // Because we use our own random number generator and a fixed seed, // we can guarantee that the following "random" tests will succeed. TEST_F(VectorShuffleTest, ShufflesEntireVector) { Shuffle(&random_, &vector_); ASSERT_PRED1(VectorIsNotCorrupt, vector_); EXPECT_FALSE(VectorIsUnshuffled(vector_)) << vector_; // Tests the first and last elements in particular to ensure that // there are no off-by-one problems in our shuffle algorithm. EXPECT_NE(0, vector_[0]); EXPECT_NE(kVectorSize - 1, vector_[kVectorSize - 1]); } TEST_F(VectorShuffleTest, ShufflesStartOfVector) { const int kRangeSize = kVectorSize/2; ShuffleRange(&random_, 0, kRangeSize, &vector_); ASSERT_PRED1(VectorIsNotCorrupt, vector_); EXPECT_PRED3(RangeIsShuffled, vector_, 0, kRangeSize); EXPECT_PRED3(RangeIsUnshuffled, vector_, kRangeSize, kVectorSize); } TEST_F(VectorShuffleTest, ShufflesEndOfVector) { const int kRangeSize = kVectorSize / 2; ShuffleRange(&random_, kRangeSize, kVectorSize, &vector_); ASSERT_PRED1(VectorIsNotCorrupt, vector_); EXPECT_PRED3(RangeIsUnshuffled, vector_, 0, kRangeSize); EXPECT_PRED3(RangeIsShuffled, vector_, kRangeSize, kVectorSize); } TEST_F(VectorShuffleTest, ShufflesMiddleOfVector) { int kRangeSize = kVectorSize/3; ShuffleRange(&random_, kRangeSize, 2*kRangeSize, &vector_); ASSERT_PRED1(VectorIsNotCorrupt, vector_); EXPECT_PRED3(RangeIsUnshuffled, vector_, 0, kRangeSize); EXPECT_PRED3(RangeIsShuffled, vector_, kRangeSize, 2*kRangeSize); EXPECT_PRED3(RangeIsUnshuffled, vector_, 2*kRangeSize, kVectorSize); } TEST_F(VectorShuffleTest, ShufflesRepeatably) { TestingVector vector2; for (int i = 0; i < kVectorSize; i++) { vector2.push_back(i); } random_.Reseed(1234); Shuffle(&random_, &vector_); random_.Reseed(1234); Shuffle(&random_, &vector2); ASSERT_PRED1(VectorIsNotCorrupt, vector_); ASSERT_PRED1(VectorIsNotCorrupt, vector2); for (int i = 0; i < kVectorSize; i++) { EXPECT_EQ(vector_[i], vector2[i]) << " where i is " << i; } } // Tests the size of the AssertHelper class. TEST(AssertHelperTest, AssertHelperIsSmall) { // To avoid breaking clients that use lots of assertions in one // function, we cannot grow the size of AssertHelper. EXPECT_LE(sizeof(testing::internal::AssertHelper), sizeof(void*)); } // Tests String::EndsWithCaseInsensitive(). TEST(StringTest, EndsWithCaseInsensitive) { EXPECT_TRUE(String::EndsWithCaseInsensitive("foobar", "BAR")); EXPECT_TRUE(String::EndsWithCaseInsensitive("foobaR", "bar")); EXPECT_TRUE(String::EndsWithCaseInsensitive("foobar", "")); EXPECT_TRUE(String::EndsWithCaseInsensitive("", "")); EXPECT_FALSE(String::EndsWithCaseInsensitive("Foobar", "foo")); EXPECT_FALSE(String::EndsWithCaseInsensitive("foobar", "Foo")); EXPECT_FALSE(String::EndsWithCaseInsensitive("", "foo")); } // C++Builder's preprocessor is buggy; it fails to expand macros that // appear in macro parameters after wide char literals. Provide an alias // for NULL as a workaround. static const wchar_t* const kNull = NULL; // Tests String::CaseInsensitiveWideCStringEquals TEST(StringTest, CaseInsensitiveWideCStringEquals) { EXPECT_TRUE(String::CaseInsensitiveWideCStringEquals(NULL, NULL)); EXPECT_FALSE(String::CaseInsensitiveWideCStringEquals(kNull, L"")); EXPECT_FALSE(String::CaseInsensitiveWideCStringEquals(L"", kNull)); EXPECT_FALSE(String::CaseInsensitiveWideCStringEquals(kNull, L"foobar")); EXPECT_FALSE(String::CaseInsensitiveWideCStringEquals(L"foobar", kNull)); EXPECT_TRUE(String::CaseInsensitiveWideCStringEquals(L"foobar", L"foobar")); EXPECT_TRUE(String::CaseInsensitiveWideCStringEquals(L"foobar", L"FOOBAR")); EXPECT_TRUE(String::CaseInsensitiveWideCStringEquals(L"FOOBAR", L"foobar")); } #if GTEST_OS_WINDOWS // Tests String::ShowWideCString(). TEST(StringTest, ShowWideCString) { EXPECT_STREQ("(null)", String::ShowWideCString(NULL).c_str()); EXPECT_STREQ("", String::ShowWideCString(L"").c_str()); EXPECT_STREQ("foo", String::ShowWideCString(L"foo").c_str()); } # if GTEST_OS_WINDOWS_MOBILE TEST(StringTest, AnsiAndUtf16Null) { EXPECT_EQ(NULL, String::AnsiToUtf16(NULL)); EXPECT_EQ(NULL, String::Utf16ToAnsi(NULL)); } TEST(StringTest, AnsiAndUtf16ConvertBasic) { const char* ansi = String::Utf16ToAnsi(L"str"); EXPECT_STREQ("str", ansi); delete [] ansi; const WCHAR* utf16 = String::AnsiToUtf16("str"); EXPECT_EQ(0, wcsncmp(L"str", utf16, 3)); delete [] utf16; } TEST(StringTest, AnsiAndUtf16ConvertPathChars) { const char* ansi = String::Utf16ToAnsi(L".:\\ \"*?"); EXPECT_STREQ(".:\\ \"*?", ansi); delete [] ansi; const WCHAR* utf16 = String::AnsiToUtf16(".:\\ \"*?"); EXPECT_EQ(0, wcsncmp(L".:\\ \"*?", utf16, 3)); delete [] utf16; } # endif // GTEST_OS_WINDOWS_MOBILE #endif // GTEST_OS_WINDOWS // Tests TestProperty construction. TEST(TestPropertyTest, StringValue) { TestProperty property("key", "1"); EXPECT_STREQ("key", property.key()); EXPECT_STREQ("1", property.value()); } // Tests TestProperty replacing a value. TEST(TestPropertyTest, ReplaceStringValue) { TestProperty property("key", "1"); EXPECT_STREQ("1", property.value()); property.SetValue("2"); EXPECT_STREQ("2", property.value()); } // AddFatalFailure() and AddNonfatalFailure() must be stand-alone // functions (i.e. their definitions cannot be inlined at the call // sites), or C++Builder won't compile the code. static void AddFatalFailure() { FAIL() << "Expected fatal failure."; } static void AddNonfatalFailure() { ADD_FAILURE() << "Expected non-fatal failure."; } class ScopedFakeTestPartResultReporterTest : public Test { public: // Must be public and not protected due to a bug in g++ 3.4.2. enum FailureMode { FATAL_FAILURE, NONFATAL_FAILURE }; static void AddFailure(FailureMode failure) { if (failure == FATAL_FAILURE) { AddFatalFailure(); } else { AddNonfatalFailure(); } } }; // Tests that ScopedFakeTestPartResultReporter intercepts test // failures. TEST_F(ScopedFakeTestPartResultReporterTest, InterceptsTestFailures) { TestPartResultArray results; { ScopedFakeTestPartResultReporter reporter( ScopedFakeTestPartResultReporter::INTERCEPT_ONLY_CURRENT_THREAD, &results); AddFailure(NONFATAL_FAILURE); AddFailure(FATAL_FAILURE); } EXPECT_EQ(2, results.size()); EXPECT_TRUE(results.GetTestPartResult(0).nonfatally_failed()); EXPECT_TRUE(results.GetTestPartResult(1).fatally_failed()); } TEST_F(ScopedFakeTestPartResultReporterTest, DeprecatedConstructor) { TestPartResultArray results; { // Tests, that the deprecated constructor still works. ScopedFakeTestPartResultReporter reporter(&results); AddFailure(NONFATAL_FAILURE); } EXPECT_EQ(1, results.size()); } #if GTEST_IS_THREADSAFE class ScopedFakeTestPartResultReporterWithThreadsTest : public ScopedFakeTestPartResultReporterTest { protected: static void AddFailureInOtherThread(FailureMode failure) { ThreadWithParam<FailureMode> thread(&AddFailure, failure, NULL); thread.Join(); } }; TEST_F(ScopedFakeTestPartResultReporterWithThreadsTest, InterceptsTestFailuresInAllThreads) { TestPartResultArray results; { ScopedFakeTestPartResultReporter reporter( ScopedFakeTestPartResultReporter::INTERCEPT_ALL_THREADS, &results); AddFailure(NONFATAL_FAILURE); AddFailure(FATAL_FAILURE); AddFailureInOtherThread(NONFATAL_FAILURE); AddFailureInOtherThread(FATAL_FAILURE); } EXPECT_EQ(4, results.size()); EXPECT_TRUE(results.GetTestPartResult(0).nonfatally_failed()); EXPECT_TRUE(results.GetTestPartResult(1).fatally_failed()); EXPECT_TRUE(results.GetTestPartResult(2).nonfatally_failed()); EXPECT_TRUE(results.GetTestPartResult(3).fatally_failed()); } #endif // GTEST_IS_THREADSAFE // Tests EXPECT_FATAL_FAILURE{,ON_ALL_THREADS}. Makes sure that they // work even if the failure is generated in a called function rather than // the current context. typedef ScopedFakeTestPartResultReporterTest ExpectFatalFailureTest; TEST_F(ExpectFatalFailureTest, CatchesFatalFaliure) { EXPECT_FATAL_FAILURE(AddFatalFailure(), "Expected fatal failure."); } #if GTEST_HAS_GLOBAL_STRING TEST_F(ExpectFatalFailureTest, AcceptsStringObject) { EXPECT_FATAL_FAILURE(AddFatalFailure(), ::string("Expected fatal failure.")); } #endif TEST_F(ExpectFatalFailureTest, AcceptsStdStringObject) { EXPECT_FATAL_FAILURE(AddFatalFailure(), ::std::string("Expected fatal failure.")); } TEST_F(ExpectFatalFailureTest, CatchesFatalFailureOnAllThreads) { // We have another test below to verify that the macro catches fatal // failures generated on another thread. EXPECT_FATAL_FAILURE_ON_ALL_THREADS(AddFatalFailure(), "Expected fatal failure."); } #ifdef __BORLANDC__ // Silences warnings: "Condition is always true" # pragma option push -w-ccc #endif // Tests that EXPECT_FATAL_FAILURE() can be used in a non-void // function even when the statement in it contains ASSERT_*. int NonVoidFunction() { EXPECT_FATAL_FAILURE(ASSERT_TRUE(false), ""); EXPECT_FATAL_FAILURE_ON_ALL_THREADS(FAIL(), ""); return 0; } TEST_F(ExpectFatalFailureTest, CanBeUsedInNonVoidFunction) { NonVoidFunction(); } // Tests that EXPECT_FATAL_FAILURE(statement, ...) doesn't abort the // current function even though 'statement' generates a fatal failure. void DoesNotAbortHelper(bool* aborted) { EXPECT_FATAL_FAILURE(ASSERT_TRUE(false), ""); EXPECT_FATAL_FAILURE_ON_ALL_THREADS(FAIL(), ""); *aborted = false; } #ifdef __BORLANDC__ // Restores warnings after previous "#pragma option push" suppressed them. # pragma option pop #endif TEST_F(ExpectFatalFailureTest, DoesNotAbort) { bool aborted = true; DoesNotAbortHelper(&aborted); EXPECT_FALSE(aborted); } // Tests that the EXPECT_FATAL_FAILURE{,_ON_ALL_THREADS} accepts a // statement that contains a macro which expands to code containing an // unprotected comma. static int global_var = 0; #define GTEST_USE_UNPROTECTED_COMMA_ global_var++, global_var++ TEST_F(ExpectFatalFailureTest, AcceptsMacroThatExpandsToUnprotectedComma) { #ifndef __BORLANDC__ // ICE's in C++Builder. EXPECT_FATAL_FAILURE({ GTEST_USE_UNPROTECTED_COMMA_; AddFatalFailure(); }, ""); #endif EXPECT_FATAL_FAILURE_ON_ALL_THREADS({ GTEST_USE_UNPROTECTED_COMMA_; AddFatalFailure(); }, ""); } // Tests EXPECT_NONFATAL_FAILURE{,ON_ALL_THREADS}. typedef ScopedFakeTestPartResultReporterTest ExpectNonfatalFailureTest; TEST_F(ExpectNonfatalFailureTest, CatchesNonfatalFailure) { EXPECT_NONFATAL_FAILURE(AddNonfatalFailure(), "Expected non-fatal failure."); } #if GTEST_HAS_GLOBAL_STRING TEST_F(ExpectNonfatalFailureTest, AcceptsStringObject) { EXPECT_NONFATAL_FAILURE(AddNonfatalFailure(), ::string("Expected non-fatal failure.")); } #endif TEST_F(ExpectNonfatalFailureTest, AcceptsStdStringObject) { EXPECT_NONFATAL_FAILURE(AddNonfatalFailure(), ::std::string("Expected non-fatal failure.")); } TEST_F(ExpectNonfatalFailureTest, CatchesNonfatalFailureOnAllThreads) { // We have another test below to verify that the macro catches // non-fatal failures generated on another thread. EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(AddNonfatalFailure(), "Expected non-fatal failure."); } // Tests that the EXPECT_NONFATAL_FAILURE{,_ON_ALL_THREADS} accepts a // statement that contains a macro which expands to code containing an // unprotected comma. TEST_F(ExpectNonfatalFailureTest, AcceptsMacroThatExpandsToUnprotectedComma) { EXPECT_NONFATAL_FAILURE({ GTEST_USE_UNPROTECTED_COMMA_; AddNonfatalFailure(); }, ""); EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS({ GTEST_USE_UNPROTECTED_COMMA_; AddNonfatalFailure(); }, ""); } #if GTEST_IS_THREADSAFE typedef ScopedFakeTestPartResultReporterWithThreadsTest ExpectFailureWithThreadsTest; TEST_F(ExpectFailureWithThreadsTest, ExpectFatalFailureOnAllThreads) { EXPECT_FATAL_FAILURE_ON_ALL_THREADS(AddFailureInOtherThread(FATAL_FAILURE), "Expected fatal failure."); } TEST_F(ExpectFailureWithThreadsTest, ExpectNonFatalFailureOnAllThreads) { EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS( AddFailureInOtherThread(NONFATAL_FAILURE), "Expected non-fatal failure."); } #endif // GTEST_IS_THREADSAFE // Tests the TestProperty class. TEST(TestPropertyTest, ConstructorWorks) { const TestProperty property("key", "value"); EXPECT_STREQ("key", property.key()); EXPECT_STREQ("value", property.value()); } TEST(TestPropertyTest, SetValue) { TestProperty property("key", "value_1"); EXPECT_STREQ("key", property.key()); property.SetValue("value_2"); EXPECT_STREQ("key", property.key()); EXPECT_STREQ("value_2", property.value()); } // Tests the TestResult class // The test fixture for testing TestResult. class TestResultTest : public Test { protected: typedef std::vector<TestPartResult> TPRVector; // We make use of 2 TestPartResult objects, TestPartResult * pr1, * pr2; // ... and 3 TestResult objects. TestResult * r0, * r1, * r2; virtual void SetUp() { // pr1 is for success. pr1 = new TestPartResult(TestPartResult::kSuccess, "foo/bar.cc", 10, "Success!"); // pr2 is for fatal failure. pr2 = new TestPartResult(TestPartResult::kFatalFailure, "foo/bar.cc", -1, // This line number means "unknown" "Failure!"); // Creates the TestResult objects. r0 = new TestResult(); r1 = new TestResult(); r2 = new TestResult(); // In order to test TestResult, we need to modify its internal // state, in particular the TestPartResult vector it holds. // test_part_results() returns a const reference to this vector. // We cast it to a non-const object s.t. it can be modified TPRVector* results1 = const_cast<TPRVector*>( &TestResultAccessor::test_part_results(*r1)); TPRVector* results2 = const_cast<TPRVector*>( &TestResultAccessor::test_part_results(*r2)); // r0 is an empty TestResult. // r1 contains a single SUCCESS TestPartResult. results1->push_back(*pr1); // r2 contains a SUCCESS, and a FAILURE. results2->push_back(*pr1); results2->push_back(*pr2); } virtual void TearDown() { delete pr1; delete pr2; delete r0; delete r1; delete r2; } // Helper that compares two TestPartResults. static void CompareTestPartResult(const TestPartResult& expected, const TestPartResult& actual) { EXPECT_EQ(expected.type(), actual.type()); EXPECT_STREQ(expected.file_name(), actual.file_name()); EXPECT_EQ(expected.line_number(), actual.line_number()); EXPECT_STREQ(expected.summary(), actual.summary()); EXPECT_STREQ(expected.message(), actual.message()); EXPECT_EQ(expected.passed(), actual.passed()); EXPECT_EQ(expected.failed(), actual.failed()); EXPECT_EQ(expected.nonfatally_failed(), actual.nonfatally_failed()); EXPECT_EQ(expected.fatally_failed(), actual.fatally_failed()); } }; // Tests TestResult::total_part_count(). TEST_F(TestResultTest, total_part_count) { ASSERT_EQ(0, r0->total_part_count()); ASSERT_EQ(1, r1->total_part_count()); ASSERT_EQ(2, r2->total_part_count()); } // Tests TestResult::Passed(). TEST_F(TestResultTest, Passed) { ASSERT_TRUE(r0->Passed()); ASSERT_TRUE(r1->Passed()); ASSERT_FALSE(r2->Passed()); } // Tests TestResult::Failed(). TEST_F(TestResultTest, Failed) { ASSERT_FALSE(r0->Failed()); ASSERT_FALSE(r1->Failed()); ASSERT_TRUE(r2->Failed()); } // Tests TestResult::GetTestPartResult(). typedef TestResultTest TestResultDeathTest; TEST_F(TestResultDeathTest, GetTestPartResult) { CompareTestPartResult(*pr1, r2->GetTestPartResult(0)); CompareTestPartResult(*pr2, r2->GetTestPartResult(1)); EXPECT_DEATH_IF_SUPPORTED(r2->GetTestPartResult(2), ""); EXPECT_DEATH_IF_SUPPORTED(r2->GetTestPartResult(-1), ""); } // Tests TestResult has no properties when none are added. TEST(TestResultPropertyTest, NoPropertiesFoundWhenNoneAreAdded) { TestResult test_result; ASSERT_EQ(0, test_result.test_property_count()); } // Tests TestResult has the expected property when added. TEST(TestResultPropertyTest, OnePropertyFoundWhenAdded) { TestResult test_result; TestProperty property("key_1", "1"); TestResultAccessor::RecordProperty(&test_result, "testcase", property); ASSERT_EQ(1, test_result.test_property_count()); const TestProperty& actual_property = test_result.GetTestProperty(0); EXPECT_STREQ("key_1", actual_property.key()); EXPECT_STREQ("1", actual_property.value()); } // Tests TestResult has multiple properties when added. TEST(TestResultPropertyTest, MultiplePropertiesFoundWhenAdded) { TestResult test_result; TestProperty property_1("key_1", "1"); TestProperty property_2("key_2", "2"); TestResultAccessor::RecordProperty(&test_result, "testcase", property_1); TestResultAccessor::RecordProperty(&test_result, "testcase", property_2); ASSERT_EQ(2, test_result.test_property_count()); const TestProperty& actual_property_1 = test_result.GetTestProperty(0); EXPECT_STREQ("key_1", actual_property_1.key()); EXPECT_STREQ("1", actual_property_1.value()); const TestProperty& actual_property_2 = test_result.GetTestProperty(1); EXPECT_STREQ("key_2", actual_property_2.key()); EXPECT_STREQ("2", actual_property_2.value()); } // Tests TestResult::RecordProperty() overrides values for duplicate keys. TEST(TestResultPropertyTest, OverridesValuesForDuplicateKeys) { TestResult test_result; TestProperty property_1_1("key_1", "1"); TestProperty property_2_1("key_2", "2"); TestProperty property_1_2("key_1", "12"); TestProperty property_2_2("key_2", "22"); TestResultAccessor::RecordProperty(&test_result, "testcase", property_1_1); TestResultAccessor::RecordProperty(&test_result, "testcase", property_2_1); TestResultAccessor::RecordProperty(&test_result, "testcase", property_1_2); TestResultAccessor::RecordProperty(&test_result, "testcase", property_2_2); ASSERT_EQ(2, test_result.test_property_count()); const TestProperty& actual_property_1 = test_result.GetTestProperty(0); EXPECT_STREQ("key_1", actual_property_1.key()); EXPECT_STREQ("12", actual_property_1.value()); const TestProperty& actual_property_2 = test_result.GetTestProperty(1); EXPECT_STREQ("key_2", actual_property_2.key()); EXPECT_STREQ("22", actual_property_2.value()); } // Tests TestResult::GetTestProperty(). TEST(TestResultPropertyTest, GetTestProperty) { TestResult test_result; TestProperty property_1("key_1", "1"); TestProperty property_2("key_2", "2"); TestProperty property_3("key_3", "3"); TestResultAccessor::RecordProperty(&test_result, "testcase", property_1); TestResultAccessor::RecordProperty(&test_result, "testcase", property_2); TestResultAccessor::RecordProperty(&test_result, "testcase", property_3); const TestProperty& fetched_property_1 = test_result.GetTestProperty(0); const TestProperty& fetched_property_2 = test_result.GetTestProperty(1); const TestProperty& fetched_property_3 = test_result.GetTestProperty(2); EXPECT_STREQ("key_1", fetched_property_1.key()); EXPECT_STREQ("1", fetched_property_1.value()); EXPECT_STREQ("key_2", fetched_property_2.key()); EXPECT_STREQ("2", fetched_property_2.value()); EXPECT_STREQ("key_3", fetched_property_3.key()); EXPECT_STREQ("3", fetched_property_3.value()); EXPECT_DEATH_IF_SUPPORTED(test_result.GetTestProperty(3), ""); EXPECT_DEATH_IF_SUPPORTED(test_result.GetTestProperty(-1), ""); } // Tests the Test class. // // It's difficult to test every public method of this class (we are // already stretching the limit of Google Test by using it to test itself!). // Fortunately, we don't have to do that, as we are already testing // the functionalities of the Test class extensively by using Google Test // alone. // // Therefore, this section only contains one test. // Tests that GTestFlagSaver works on Windows and Mac. class GTestFlagSaverTest : public Test { protected: // Saves the Google Test flags such that we can restore them later, and // then sets them to their default values. This will be called // before the first test in this test case is run. static void SetUpTestCase() { saver_ = new GTestFlagSaver; GTEST_FLAG(also_run_disabled_tests) = false; GTEST_FLAG(break_on_failure) = false; GTEST_FLAG(catch_exceptions) = false; GTEST_FLAG(death_test_use_fork) = false; GTEST_FLAG(color) = "auto"; GTEST_FLAG(filter) = ""; GTEST_FLAG(list_tests) = false; GTEST_FLAG(output) = ""; GTEST_FLAG(print_time) = true; GTEST_FLAG(random_seed) = 0; GTEST_FLAG(repeat) = 1; GTEST_FLAG(shuffle) = false; GTEST_FLAG(stack_trace_depth) = kMaxStackTraceDepth; GTEST_FLAG(stream_result_to) = ""; GTEST_FLAG(throw_on_failure) = false; } // Restores the Google Test flags that the tests have modified. This will // be called after the last test in this test case is run. static void TearDownTestCase() { delete saver_; saver_ = NULL; } // Verifies that the Google Test flags have their default values, and then // modifies each of them. void VerifyAndModifyFlags() { EXPECT_FALSE(GTEST_FLAG(also_run_disabled_tests)); EXPECT_FALSE(GTEST_FLAG(break_on_failure)); EXPECT_FALSE(GTEST_FLAG(catch_exceptions)); EXPECT_STREQ("auto", GTEST_FLAG(color).c_str()); EXPECT_FALSE(GTEST_FLAG(death_test_use_fork)); EXPECT_STREQ("", GTEST_FLAG(filter).c_str()); EXPECT_FALSE(GTEST_FLAG(list_tests)); EXPECT_STREQ("", GTEST_FLAG(output).c_str()); EXPECT_TRUE(GTEST_FLAG(print_time)); EXPECT_EQ(0, GTEST_FLAG(random_seed)); EXPECT_EQ(1, GTEST_FLAG(repeat)); EXPECT_FALSE(GTEST_FLAG(shuffle)); EXPECT_EQ(kMaxStackTraceDepth, GTEST_FLAG(stack_trace_depth)); EXPECT_STREQ("", GTEST_FLAG(stream_result_to).c_str()); EXPECT_FALSE(GTEST_FLAG(throw_on_failure)); GTEST_FLAG(also_run_disabled_tests) = true; GTEST_FLAG(break_on_failure) = true; GTEST_FLAG(catch_exceptions) = true; GTEST_FLAG(color) = "no"; GTEST_FLAG(death_test_use_fork) = true; GTEST_FLAG(filter) = "abc"; GTEST_FLAG(list_tests) = true; GTEST_FLAG(output) = "xml:foo.xml"; GTEST_FLAG(print_time) = false; GTEST_FLAG(random_seed) = 1; GTEST_FLAG(repeat) = 100; GTEST_FLAG(shuffle) = true; GTEST_FLAG(stack_trace_depth) = 1; GTEST_FLAG(stream_result_to) = "localhost:1234"; GTEST_FLAG(throw_on_failure) = true; } private: // For saving Google Test flags during this test case. static GTestFlagSaver* saver_; }; GTestFlagSaver* GTestFlagSaverTest::saver_ = NULL; // Google Test doesn't guarantee the order of tests. The following two // tests are designed to work regardless of their order. // Modifies the Google Test flags in the test body. TEST_F(GTestFlagSaverTest, ModifyGTestFlags) { VerifyAndModifyFlags(); } // Verifies that the Google Test flags in the body of the previous test were // restored to their original values. TEST_F(GTestFlagSaverTest, VerifyGTestFlags) { VerifyAndModifyFlags(); } // Sets an environment variable with the given name to the given // value. If the value argument is "", unsets the environment // variable. The caller must ensure that both arguments are not NULL. static void SetEnv(const char* name, const char* value) { #if GTEST_OS_WINDOWS_MOBILE // Environment variables are not supported on Windows CE. return; #elif defined(__BORLANDC__) || defined(__SunOS_5_8) || defined(__SunOS_5_9) // C++Builder's putenv only stores a pointer to its parameter; we have to // ensure that the string remains valid as long as it might be needed. // We use an std::map to do so. static std::map<std::string, std::string*> added_env; // Because putenv stores a pointer to the string buffer, we can't delete the // previous string (if present) until after it's replaced. std::string *prev_env = NULL; if (added_env.find(name) != added_env.end()) { prev_env = added_env[name]; } added_env[name] = new std::string( (Message() << name << "=" << value).GetString()); // The standard signature of putenv accepts a 'char*' argument. Other // implementations, like C++Builder's, accept a 'const char*'. // We cast away the 'const' since that would work for both variants. putenv(const_cast<char*>(added_env[name]->c_str())); delete prev_env; #elif GTEST_OS_WINDOWS // If we are on Windows proper. _putenv((Message() << name << "=" << value).GetString().c_str()); #else if (*value == '\0') { unsetenv(name); } else { setenv(name, value, 1); } #endif // GTEST_OS_WINDOWS_MOBILE } #if !GTEST_OS_WINDOWS_MOBILE // Environment variables are not supported on Windows CE. using testing::internal::Int32FromGTestEnv; // Tests Int32FromGTestEnv(). // Tests that Int32FromGTestEnv() returns the default value when the // environment variable is not set. TEST(Int32FromGTestEnvTest, ReturnsDefaultWhenVariableIsNotSet) { SetEnv(GTEST_FLAG_PREFIX_UPPER_ "TEMP", ""); EXPECT_EQ(10, Int32FromGTestEnv("temp", 10)); } # if !defined(GTEST_GET_INT32_FROM_ENV_) // Tests that Int32FromGTestEnv() returns the default value when the // environment variable overflows as an Int32. TEST(Int32FromGTestEnvTest, ReturnsDefaultWhenValueOverflows) { printf("(expecting 2 warnings)\n"); SetEnv(GTEST_FLAG_PREFIX_UPPER_ "TEMP", "12345678987654321"); EXPECT_EQ(20, Int32FromGTestEnv("temp", 20)); SetEnv(GTEST_FLAG_PREFIX_UPPER_ "TEMP", "-12345678987654321"); EXPECT_EQ(30, Int32FromGTestEnv("temp", 30)); } // Tests that Int32FromGTestEnv() returns the default value when the // environment variable does not represent a valid decimal integer. TEST(Int32FromGTestEnvTest, ReturnsDefaultWhenValueIsInvalid) { printf("(expecting 2 warnings)\n"); SetEnv(GTEST_FLAG_PREFIX_UPPER_ "TEMP", "A1"); EXPECT_EQ(40, Int32FromGTestEnv("temp", 40)); SetEnv(GTEST_FLAG_PREFIX_UPPER_ "TEMP", "12X"); EXPECT_EQ(50, Int32FromGTestEnv("temp", 50)); } # endif // !defined(GTEST_GET_INT32_FROM_ENV_) // Tests that Int32FromGTestEnv() parses and returns the value of the // environment variable when it represents a valid decimal integer in // the range of an Int32. TEST(Int32FromGTestEnvTest, ParsesAndReturnsValidValue) { SetEnv(GTEST_FLAG_PREFIX_UPPER_ "TEMP", "123"); EXPECT_EQ(123, Int32FromGTestEnv("temp", 0)); SetEnv(GTEST_FLAG_PREFIX_UPPER_ "TEMP", "-321"); EXPECT_EQ(-321, Int32FromGTestEnv("temp", 0)); } #endif // !GTEST_OS_WINDOWS_MOBILE // Tests ParseInt32Flag(). // Tests that ParseInt32Flag() returns false and doesn't change the // output value when the flag has wrong format TEST(ParseInt32FlagTest, ReturnsFalseForInvalidFlag) { Int32 value = 123; EXPECT_FALSE(ParseInt32Flag("--a=100", "b", &value)); EXPECT_EQ(123, value); EXPECT_FALSE(ParseInt32Flag("a=100", "a", &value)); EXPECT_EQ(123, value); } // Tests that ParseInt32Flag() returns false and doesn't change the // output value when the flag overflows as an Int32. TEST(ParseInt32FlagTest, ReturnsDefaultWhenValueOverflows) { printf("(expecting 2 warnings)\n"); Int32 value = 123; EXPECT_FALSE(ParseInt32Flag("--abc=12345678987654321", "abc", &value)); EXPECT_EQ(123, value); EXPECT_FALSE(ParseInt32Flag("--abc=-12345678987654321", "abc", &value)); EXPECT_EQ(123, value); } // Tests that ParseInt32Flag() returns false and doesn't change the // output value when the flag does not represent a valid decimal // integer. TEST(ParseInt32FlagTest, ReturnsDefaultWhenValueIsInvalid) { printf("(expecting 2 warnings)\n"); Int32 value = 123; EXPECT_FALSE(ParseInt32Flag("--abc=A1", "abc", &value)); EXPECT_EQ(123, value); EXPECT_FALSE(ParseInt32Flag("--abc=12X", "abc", &value)); EXPECT_EQ(123, value); } // Tests that ParseInt32Flag() parses the value of the flag and // returns true when the flag represents a valid decimal integer in // the range of an Int32. TEST(ParseInt32FlagTest, ParsesAndReturnsValidValue) { Int32 value = 123; EXPECT_TRUE(ParseInt32Flag("--" GTEST_FLAG_PREFIX_ "abc=456", "abc", &value)); EXPECT_EQ(456, value); EXPECT_TRUE(ParseInt32Flag("--" GTEST_FLAG_PREFIX_ "abc=-789", "abc", &value)); EXPECT_EQ(-789, value); } // Tests that Int32FromEnvOrDie() parses the value of the var or // returns the correct default. // Environment variables are not supported on Windows CE. #if !GTEST_OS_WINDOWS_MOBILE TEST(Int32FromEnvOrDieTest, ParsesAndReturnsValidValue) { EXPECT_EQ(333, Int32FromEnvOrDie(GTEST_FLAG_PREFIX_UPPER_ "UnsetVar", 333)); SetEnv(GTEST_FLAG_PREFIX_UPPER_ "UnsetVar", "123"); EXPECT_EQ(123, Int32FromEnvOrDie(GTEST_FLAG_PREFIX_UPPER_ "UnsetVar", 333)); SetEnv(GTEST_FLAG_PREFIX_UPPER_ "UnsetVar", "-123"); EXPECT_EQ(-123, Int32FromEnvOrDie(GTEST_FLAG_PREFIX_UPPER_ "UnsetVar", 333)); } #endif // !GTEST_OS_WINDOWS_MOBILE // Tests that Int32FromEnvOrDie() aborts with an error message // if the variable is not an Int32. TEST(Int32FromEnvOrDieDeathTest, AbortsOnFailure) { SetEnv(GTEST_FLAG_PREFIX_UPPER_ "VAR", "xxx"); EXPECT_DEATH_IF_SUPPORTED( Int32FromEnvOrDie(GTEST_FLAG_PREFIX_UPPER_ "VAR", 123), ".*"); } // Tests that Int32FromEnvOrDie() aborts with an error message // if the variable cannot be represented by an Int32. TEST(Int32FromEnvOrDieDeathTest, AbortsOnInt32Overflow) { SetEnv(GTEST_FLAG_PREFIX_UPPER_ "VAR", "1234567891234567891234"); EXPECT_DEATH_IF_SUPPORTED( Int32FromEnvOrDie(GTEST_FLAG_PREFIX_UPPER_ "VAR", 123), ".*"); } // Tests that ShouldRunTestOnShard() selects all tests // where there is 1 shard. TEST(ShouldRunTestOnShardTest, IsPartitionWhenThereIsOneShard) { EXPECT_TRUE(ShouldRunTestOnShard(1, 0, 0)); EXPECT_TRUE(ShouldRunTestOnShard(1, 0, 1)); EXPECT_TRUE(ShouldRunTestOnShard(1, 0, 2)); EXPECT_TRUE(ShouldRunTestOnShard(1, 0, 3)); EXPECT_TRUE(ShouldRunTestOnShard(1, 0, 4)); } class ShouldShardTest : public testing::Test { protected: virtual void SetUp() { index_var_ = GTEST_FLAG_PREFIX_UPPER_ "INDEX"; total_var_ = GTEST_FLAG_PREFIX_UPPER_ "TOTAL"; } virtual void TearDown() { SetEnv(index_var_, ""); SetEnv(total_var_, ""); } const char* index_var_; const char* total_var_; }; // Tests that sharding is disabled if neither of the environment variables // are set. TEST_F(ShouldShardTest, ReturnsFalseWhenNeitherEnvVarIsSet) { SetEnv(index_var_, ""); SetEnv(total_var_, ""); EXPECT_FALSE(ShouldShard(total_var_, index_var_, false)); EXPECT_FALSE(ShouldShard(total_var_, index_var_, true)); } // Tests that sharding is not enabled if total_shards == 1. TEST_F(ShouldShardTest, ReturnsFalseWhenTotalShardIsOne) { SetEnv(index_var_, "0"); SetEnv(total_var_, "1"); EXPECT_FALSE(ShouldShard(total_var_, index_var_, false)); EXPECT_FALSE(ShouldShard(total_var_, index_var_, true)); } // Tests that sharding is enabled if total_shards > 1 and // we are not in a death test subprocess. // Environment variables are not supported on Windows CE. #if !GTEST_OS_WINDOWS_MOBILE TEST_F(ShouldShardTest, WorksWhenShardEnvVarsAreValid) { SetEnv(index_var_, "4"); SetEnv(total_var_, "22"); EXPECT_TRUE(ShouldShard(total_var_, index_var_, false)); EXPECT_FALSE(ShouldShard(total_var_, index_var_, true)); SetEnv(index_var_, "8"); SetEnv(total_var_, "9"); EXPECT_TRUE(ShouldShard(total_var_, index_var_, false)); EXPECT_FALSE(ShouldShard(total_var_, index_var_, true)); SetEnv(index_var_, "0"); SetEnv(total_var_, "9"); EXPECT_TRUE(ShouldShard(total_var_, index_var_, false)); EXPECT_FALSE(ShouldShard(total_var_, index_var_, true)); } #endif // !GTEST_OS_WINDOWS_MOBILE // Tests that we exit in error if the sharding values are not valid. typedef ShouldShardTest ShouldShardDeathTest; TEST_F(ShouldShardDeathTest, AbortsWhenShardingEnvVarsAreInvalid) { SetEnv(index_var_, "4"); SetEnv(total_var_, "4"); EXPECT_DEATH_IF_SUPPORTED(ShouldShard(total_var_, index_var_, false), ".*"); SetEnv(index_var_, "4"); SetEnv(total_var_, "-2"); EXPECT_DEATH_IF_SUPPORTED(ShouldShard(total_var_, index_var_, false), ".*"); SetEnv(index_var_, "5"); SetEnv(total_var_, ""); EXPECT_DEATH_IF_SUPPORTED(ShouldShard(total_var_, index_var_, false), ".*"); SetEnv(index_var_, ""); SetEnv(total_var_, "5"); EXPECT_DEATH_IF_SUPPORTED(ShouldShard(total_var_, index_var_, false), ".*"); } // Tests that ShouldRunTestOnShard is a partition when 5 // shards are used. TEST(ShouldRunTestOnShardTest, IsPartitionWhenThereAreFiveShards) { // Choose an arbitrary number of tests and shards. const int num_tests = 17; const int num_shards = 5; // Check partitioning: each test should be on exactly 1 shard. for (int test_id = 0; test_id < num_tests; test_id++) { int prev_selected_shard_index = -1; for (int shard_index = 0; shard_index < num_shards; shard_index++) { if (ShouldRunTestOnShard(num_shards, shard_index, test_id)) { if (prev_selected_shard_index < 0) { prev_selected_shard_index = shard_index; } else { ADD_FAILURE() << "Shard " << prev_selected_shard_index << " and " << shard_index << " are both selected to run test " << test_id; } } } } // Check balance: This is not required by the sharding protocol, but is a // desirable property for performance. for (int shard_index = 0; shard_index < num_shards; shard_index++) { int num_tests_on_shard = 0; for (int test_id = 0; test_id < num_tests; test_id++) { num_tests_on_shard += ShouldRunTestOnShard(num_shards, shard_index, test_id); } EXPECT_GE(num_tests_on_shard, num_tests / num_shards); } } // For the same reason we are not explicitly testing everything in the // Test class, there are no separate tests for the following classes // (except for some trivial cases): // // TestCase, UnitTest, UnitTestResultPrinter. // // Similarly, there are no separate tests for the following macros: // // TEST, TEST_F, RUN_ALL_TESTS TEST(UnitTestTest, CanGetOriginalWorkingDir) { ASSERT_TRUE(UnitTest::GetInstance()->original_working_dir() != NULL); EXPECT_STRNE(UnitTest::GetInstance()->original_working_dir(), ""); } TEST(UnitTestTest, ReturnsPlausibleTimestamp) { EXPECT_LT(0, UnitTest::GetInstance()->start_timestamp()); EXPECT_LE(UnitTest::GetInstance()->start_timestamp(), GetTimeInMillis()); } // When a property using a reserved key is supplied to this function, it // tests that a non-fatal failure is added, a fatal failure is not added, // and that the property is not recorded. void ExpectNonFatalFailureRecordingPropertyWithReservedKey( const TestResult& test_result, const char* key) { EXPECT_NONFATAL_FAILURE(Test::RecordProperty(key, "1"), "Reserved key"); ASSERT_EQ(0, test_result.test_property_count()) << "Property for key '" << key << "' recorded unexpectedly."; } void ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest( const char* key) { const TestInfo* test_info = UnitTest::GetInstance()->current_test_info(); ASSERT_TRUE(test_info != NULL); ExpectNonFatalFailureRecordingPropertyWithReservedKey(*test_info->result(), key); } void ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase( const char* key) { const TestCase* test_case = UnitTest::GetInstance()->current_test_case(); ASSERT_TRUE(test_case != NULL); ExpectNonFatalFailureRecordingPropertyWithReservedKey( test_case->ad_hoc_test_result(), key); } void ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase( const char* key) { ExpectNonFatalFailureRecordingPropertyWithReservedKey( UnitTest::GetInstance()->ad_hoc_test_result(), key); } // Tests that property recording functions in UnitTest outside of tests // functions correcly. Creating a separate instance of UnitTest ensures it // is in a state similar to the UnitTest's singleton's between tests. class UnitTestRecordPropertyTest : public testing::internal::UnitTestRecordPropertyTestHelper { public: static void SetUpTestCase() { ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase( "disabled"); ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase( "errors"); ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase( "failures"); ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase( "name"); ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase( "tests"); ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase( "time"); Test::RecordProperty("test_case_key_1", "1"); const TestCase* test_case = UnitTest::GetInstance()->current_test_case(); ASSERT_TRUE(test_case != NULL); ASSERT_EQ(1, test_case->ad_hoc_test_result().test_property_count()); EXPECT_STREQ("test_case_key_1", test_case->ad_hoc_test_result().GetTestProperty(0).key()); EXPECT_STREQ("1", test_case->ad_hoc_test_result().GetTestProperty(0).value()); } }; // Tests TestResult has the expected property when added. TEST_F(UnitTestRecordPropertyTest, OnePropertyFoundWhenAdded) { UnitTestRecordProperty("key_1", "1"); ASSERT_EQ(1, unit_test_.ad_hoc_test_result().test_property_count()); EXPECT_STREQ("key_1", unit_test_.ad_hoc_test_result().GetTestProperty(0).key()); EXPECT_STREQ("1", unit_test_.ad_hoc_test_result().GetTestProperty(0).value()); } // Tests TestResult has multiple properties when added. TEST_F(UnitTestRecordPropertyTest, MultiplePropertiesFoundWhenAdded) { UnitTestRecordProperty("key_1", "1"); UnitTestRecordProperty("key_2", "2"); ASSERT_EQ(2, unit_test_.ad_hoc_test_result().test_property_count()); EXPECT_STREQ("key_1", unit_test_.ad_hoc_test_result().GetTestProperty(0).key()); EXPECT_STREQ("1", unit_test_.ad_hoc_test_result().GetTestProperty(0).value()); EXPECT_STREQ("key_2", unit_test_.ad_hoc_test_result().GetTestProperty(1).key()); EXPECT_STREQ("2", unit_test_.ad_hoc_test_result().GetTestProperty(1).value()); } // Tests TestResult::RecordProperty() overrides values for duplicate keys. TEST_F(UnitTestRecordPropertyTest, OverridesValuesForDuplicateKeys) { UnitTestRecordProperty("key_1", "1"); UnitTestRecordProperty("key_2", "2"); UnitTestRecordProperty("key_1", "12"); UnitTestRecordProperty("key_2", "22"); ASSERT_EQ(2, unit_test_.ad_hoc_test_result().test_property_count()); EXPECT_STREQ("key_1", unit_test_.ad_hoc_test_result().GetTestProperty(0).key()); EXPECT_STREQ("12", unit_test_.ad_hoc_test_result().GetTestProperty(0).value()); EXPECT_STREQ("key_2", unit_test_.ad_hoc_test_result().GetTestProperty(1).key()); EXPECT_STREQ("22", unit_test_.ad_hoc_test_result().GetTestProperty(1).value()); } TEST_F(UnitTestRecordPropertyTest, AddFailureInsideTestsWhenUsingTestCaseReservedKeys) { ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest( "name"); ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest( "value_param"); ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest( "type_param"); ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest( "status"); ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest( "time"); ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest( "classname"); } TEST_F(UnitTestRecordPropertyTest, AddRecordWithReservedKeysGeneratesCorrectPropertyList) { EXPECT_NONFATAL_FAILURE( Test::RecordProperty("name", "1"), "'classname', 'name', 'status', 'time', 'type_param', 'value_param'," " 'file', and 'line' are reserved"); } class UnitTestRecordPropertyTestEnvironment : public Environment { public: virtual void TearDown() { ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase( "tests"); ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase( "failures"); ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase( "disabled"); ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase( "errors"); ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase( "name"); ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase( "timestamp"); ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase( "time"); ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase( "random_seed"); } }; // This will test property recording outside of any test or test case. static Environment* record_property_env = AddGlobalTestEnvironment(new UnitTestRecordPropertyTestEnvironment); // This group of tests is for predicate assertions (ASSERT_PRED*, etc) // of various arities. They do not attempt to be exhaustive. Rather, // view them as smoke tests that can be easily reviewed and verified. // A more complete set of tests for predicate assertions can be found // in gtest_pred_impl_unittest.cc. // First, some predicates and predicate-formatters needed by the tests. // Returns true iff the argument is an even number. bool IsEven(int n) { return (n % 2) == 0; } // A functor that returns true iff the argument is an even number. struct IsEvenFunctor { bool operator()(int n) { return IsEven(n); } }; // A predicate-formatter function that asserts the argument is an even // number. AssertionResult AssertIsEven(const char* expr, int n) { if (IsEven(n)) { return AssertionSuccess(); } Message msg; msg << expr << " evaluates to " << n << ", which is not even."; return AssertionFailure(msg); } // A predicate function that returns AssertionResult for use in // EXPECT/ASSERT_TRUE/FALSE. AssertionResult ResultIsEven(int n) { if (IsEven(n)) return AssertionSuccess() << n << " is even"; else return AssertionFailure() << n << " is odd"; } // A predicate function that returns AssertionResult but gives no // explanation why it succeeds. Needed for testing that // EXPECT/ASSERT_FALSE handles such functions correctly. AssertionResult ResultIsEvenNoExplanation(int n) { if (IsEven(n)) return AssertionSuccess(); else return AssertionFailure() << n << " is odd"; } // A predicate-formatter functor that asserts the argument is an even // number. struct AssertIsEvenFunctor { AssertionResult operator()(const char* expr, int n) { return AssertIsEven(expr, n); } }; // Returns true iff the sum of the arguments is an even number. bool SumIsEven2(int n1, int n2) { return IsEven(n1 + n2); } // A functor that returns true iff the sum of the arguments is an even // number. struct SumIsEven3Functor { bool operator()(int n1, int n2, int n3) { return IsEven(n1 + n2 + n3); } }; // A predicate-formatter function that asserts the sum of the // arguments is an even number. AssertionResult AssertSumIsEven4( const char* e1, const char* e2, const char* e3, const char* e4, int n1, int n2, int n3, int n4) { const int sum = n1 + n2 + n3 + n4; if (IsEven(sum)) { return AssertionSuccess(); } Message msg; msg << e1 << " + " << e2 << " + " << e3 << " + " << e4 << " (" << n1 << " + " << n2 << " + " << n3 << " + " << n4 << ") evaluates to " << sum << ", which is not even."; return AssertionFailure(msg); } // A predicate-formatter functor that asserts the sum of the arguments // is an even number. struct AssertSumIsEven5Functor { AssertionResult operator()( const char* e1, const char* e2, const char* e3, const char* e4, const char* e5, int n1, int n2, int n3, int n4, int n5) { const int sum = n1 + n2 + n3 + n4 + n5; if (IsEven(sum)) { return AssertionSuccess(); } Message msg; msg << e1 << " + " << e2 << " + " << e3 << " + " << e4 << " + " << e5 << " (" << n1 << " + " << n2 << " + " << n3 << " + " << n4 << " + " << n5 << ") evaluates to " << sum << ", which is not even."; return AssertionFailure(msg); } }; // Tests unary predicate assertions. // Tests unary predicate assertions that don't use a custom formatter. TEST(Pred1Test, WithoutFormat) { // Success cases. EXPECT_PRED1(IsEvenFunctor(), 2) << "This failure is UNEXPECTED!"; ASSERT_PRED1(IsEven, 4); // Failure cases. EXPECT_NONFATAL_FAILURE({ // NOLINT EXPECT_PRED1(IsEven, 5) << "This failure is expected."; }, "This failure is expected."); EXPECT_FATAL_FAILURE(ASSERT_PRED1(IsEvenFunctor(), 5), "evaluates to false"); } // Tests unary predicate assertions that use a custom formatter. TEST(Pred1Test, WithFormat) { // Success cases. EXPECT_PRED_FORMAT1(AssertIsEven, 2); ASSERT_PRED_FORMAT1(AssertIsEvenFunctor(), 4) << "This failure is UNEXPECTED!"; // Failure cases. const int n = 5; EXPECT_NONFATAL_FAILURE(EXPECT_PRED_FORMAT1(AssertIsEvenFunctor(), n), "n evaluates to 5, which is not even."); EXPECT_FATAL_FAILURE({ // NOLINT ASSERT_PRED_FORMAT1(AssertIsEven, 5) << "This failure is expected."; }, "This failure is expected."); } // Tests that unary predicate assertions evaluates their arguments // exactly once. TEST(Pred1Test, SingleEvaluationOnFailure) { // A success case. static int n = 0; EXPECT_PRED1(IsEven, n++); EXPECT_EQ(1, n) << "The argument is not evaluated exactly once."; // A failure case. EXPECT_FATAL_FAILURE({ // NOLINT ASSERT_PRED_FORMAT1(AssertIsEvenFunctor(), n++) << "This failure is expected."; }, "This failure is expected."); EXPECT_EQ(2, n) << "The argument is not evaluated exactly once."; } // Tests predicate assertions whose arity is >= 2. // Tests predicate assertions that don't use a custom formatter. TEST(PredTest, WithoutFormat) { // Success cases. ASSERT_PRED2(SumIsEven2, 2, 4) << "This failure is UNEXPECTED!"; EXPECT_PRED3(SumIsEven3Functor(), 4, 6, 8); // Failure cases. const int n1 = 1; const int n2 = 2; EXPECT_NONFATAL_FAILURE({ // NOLINT EXPECT_PRED2(SumIsEven2, n1, n2) << "This failure is expected."; }, "This failure is expected."); EXPECT_FATAL_FAILURE({ // NOLINT ASSERT_PRED3(SumIsEven3Functor(), 1, 2, 4); }, "evaluates to false"); } // Tests predicate assertions that use a custom formatter. TEST(PredTest, WithFormat) { // Success cases. ASSERT_PRED_FORMAT4(AssertSumIsEven4, 4, 6, 8, 10) << "This failure is UNEXPECTED!"; EXPECT_PRED_FORMAT5(AssertSumIsEven5Functor(), 2, 4, 6, 8, 10); // Failure cases. const int n1 = 1; const int n2 = 2; const int n3 = 4; const int n4 = 6; EXPECT_NONFATAL_FAILURE({ // NOLINT EXPECT_PRED_FORMAT4(AssertSumIsEven4, n1, n2, n3, n4); }, "evaluates to 13, which is not even."); EXPECT_FATAL_FAILURE({ // NOLINT ASSERT_PRED_FORMAT5(AssertSumIsEven5Functor(), 1, 2, 4, 6, 8) << "This failure is expected."; }, "This failure is expected."); } // Tests that predicate assertions evaluates their arguments // exactly once. TEST(PredTest, SingleEvaluationOnFailure) { // A success case. int n1 = 0; int n2 = 0; EXPECT_PRED2(SumIsEven2, n1++, n2++); EXPECT_EQ(1, n1) << "Argument 1 is not evaluated exactly once."; EXPECT_EQ(1, n2) << "Argument 2 is not evaluated exactly once."; // Another success case. n1 = n2 = 0; int n3 = 0; int n4 = 0; int n5 = 0; ASSERT_PRED_FORMAT5(AssertSumIsEven5Functor(), n1++, n2++, n3++, n4++, n5++) << "This failure is UNEXPECTED!"; EXPECT_EQ(1, n1) << "Argument 1 is not evaluated exactly once."; EXPECT_EQ(1, n2) << "Argument 2 is not evaluated exactly once."; EXPECT_EQ(1, n3) << "Argument 3 is not evaluated exactly once."; EXPECT_EQ(1, n4) << "Argument 4 is not evaluated exactly once."; EXPECT_EQ(1, n5) << "Argument 5 is not evaluated exactly once."; // A failure case. n1 = n2 = n3 = 0; EXPECT_NONFATAL_FAILURE({ // NOLINT EXPECT_PRED3(SumIsEven3Functor(), ++n1, n2++, n3++) << "This failure is expected."; }, "This failure is expected."); EXPECT_EQ(1, n1) << "Argument 1 is not evaluated exactly once."; EXPECT_EQ(1, n2) << "Argument 2 is not evaluated exactly once."; EXPECT_EQ(1, n3) << "Argument 3 is not evaluated exactly once."; // Another failure case. n1 = n2 = n3 = n4 = 0; EXPECT_NONFATAL_FAILURE({ // NOLINT EXPECT_PRED_FORMAT4(AssertSumIsEven4, ++n1, n2++, n3++, n4++); }, "evaluates to 1, which is not even."); EXPECT_EQ(1, n1) << "Argument 1 is not evaluated exactly once."; EXPECT_EQ(1, n2) << "Argument 2 is not evaluated exactly once."; EXPECT_EQ(1, n3) << "Argument 3 is not evaluated exactly once."; EXPECT_EQ(1, n4) << "Argument 4 is not evaluated exactly once."; } // Some helper functions for testing using overloaded/template // functions with ASSERT_PREDn and EXPECT_PREDn. bool IsPositive(double x) { return x > 0; } template <typename T> bool IsNegative(T x) { return x < 0; } template <typename T1, typename T2> bool GreaterThan(T1 x1, T2 x2) { return x1 > x2; } // Tests that overloaded functions can be used in *_PRED* as long as // their types are explicitly specified. TEST(PredicateAssertionTest, AcceptsOverloadedFunction) { // C++Builder requires C-style casts rather than static_cast. EXPECT_PRED1((bool (*)(int))(IsPositive), 5); // NOLINT ASSERT_PRED1((bool (*)(double))(IsPositive), 6.0); // NOLINT } // Tests that template functions can be used in *_PRED* as long as // their types are explicitly specified. TEST(PredicateAssertionTest, AcceptsTemplateFunction) { EXPECT_PRED1(IsNegative<int>, -5); // Makes sure that we can handle templates with more than one // parameter. ASSERT_PRED2((GreaterThan<int, int>), 5, 0); } // Some helper functions for testing using overloaded/template // functions with ASSERT_PRED_FORMATn and EXPECT_PRED_FORMATn. AssertionResult IsPositiveFormat(const char* /* expr */, int n) { return n > 0 ? AssertionSuccess() : AssertionFailure(Message() << "Failure"); } AssertionResult IsPositiveFormat(const char* /* expr */, double x) { return x > 0 ? AssertionSuccess() : AssertionFailure(Message() << "Failure"); } template <typename T> AssertionResult IsNegativeFormat(const char* /* expr */, T x) { return x < 0 ? AssertionSuccess() : AssertionFailure(Message() << "Failure"); } template <typename T1, typename T2> AssertionResult EqualsFormat(const char* /* expr1 */, const char* /* expr2 */, const T1& x1, const T2& x2) { return x1 == x2 ? AssertionSuccess() : AssertionFailure(Message() << "Failure"); } // Tests that overloaded functions can be used in *_PRED_FORMAT* // without explicitly specifying their types. TEST(PredicateFormatAssertionTest, AcceptsOverloadedFunction) { EXPECT_PRED_FORMAT1(IsPositiveFormat, 5); ASSERT_PRED_FORMAT1(IsPositiveFormat, 6.0); } // Tests that template functions can be used in *_PRED_FORMAT* without // explicitly specifying their types. TEST(PredicateFormatAssertionTest, AcceptsTemplateFunction) { EXPECT_PRED_FORMAT1(IsNegativeFormat, -5); ASSERT_PRED_FORMAT2(EqualsFormat, 3, 3); } // Tests string assertions. // Tests ASSERT_STREQ with non-NULL arguments. TEST(StringAssertionTest, ASSERT_STREQ) { const char * const p1 = "good"; ASSERT_STREQ(p1, p1); // Let p2 have the same content as p1, but be at a different address. const char p2[] = "good"; ASSERT_STREQ(p1, p2); EXPECT_FATAL_FAILURE(ASSERT_STREQ("bad", "good"), " \"bad\"\n \"good\""); } // Tests ASSERT_STREQ with NULL arguments. TEST(StringAssertionTest, ASSERT_STREQ_Null) { ASSERT_STREQ(static_cast<const char *>(NULL), NULL); EXPECT_FATAL_FAILURE(ASSERT_STREQ(NULL, "non-null"), "non-null"); } // Tests ASSERT_STREQ with NULL arguments. TEST(StringAssertionTest, ASSERT_STREQ_Null2) { EXPECT_FATAL_FAILURE(ASSERT_STREQ("non-null", NULL), "non-null"); } // Tests ASSERT_STRNE. TEST(StringAssertionTest, ASSERT_STRNE) { ASSERT_STRNE("hi", "Hi"); ASSERT_STRNE("Hi", NULL); ASSERT_STRNE(NULL, "Hi"); ASSERT_STRNE("", NULL); ASSERT_STRNE(NULL, ""); ASSERT_STRNE("", "Hi"); ASSERT_STRNE("Hi", ""); EXPECT_FATAL_FAILURE(ASSERT_STRNE("Hi", "Hi"), "\"Hi\" vs \"Hi\""); } // Tests ASSERT_STRCASEEQ. TEST(StringAssertionTest, ASSERT_STRCASEEQ) { ASSERT_STRCASEEQ("hi", "Hi"); ASSERT_STRCASEEQ(static_cast<const char *>(NULL), NULL); ASSERT_STRCASEEQ("", ""); EXPECT_FATAL_FAILURE(ASSERT_STRCASEEQ("Hi", "hi2"), "Ignoring case"); } // Tests ASSERT_STRCASENE. TEST(StringAssertionTest, ASSERT_STRCASENE) { ASSERT_STRCASENE("hi1", "Hi2"); ASSERT_STRCASENE("Hi", NULL); ASSERT_STRCASENE(NULL, "Hi"); ASSERT_STRCASENE("", NULL); ASSERT_STRCASENE(NULL, ""); ASSERT_STRCASENE("", "Hi"); ASSERT_STRCASENE("Hi", ""); EXPECT_FATAL_FAILURE(ASSERT_STRCASENE("Hi", "hi"), "(ignoring case)"); } // Tests *_STREQ on wide strings. TEST(StringAssertionTest, STREQ_Wide) { // NULL strings. ASSERT_STREQ(static_cast<const wchar_t *>(NULL), NULL); // Empty strings. ASSERT_STREQ(L"", L""); // Non-null vs NULL. EXPECT_NONFATAL_FAILURE(EXPECT_STREQ(L"non-null", NULL), "non-null"); // Equal strings. EXPECT_STREQ(L"Hi", L"Hi"); // Unequal strings. EXPECT_NONFATAL_FAILURE(EXPECT_STREQ(L"abc", L"Abc"), "Abc"); // Strings containing wide characters. EXPECT_NONFATAL_FAILURE(EXPECT_STREQ(L"abc\x8119", L"abc\x8120"), "abc"); // The streaming variation. EXPECT_NONFATAL_FAILURE({ // NOLINT EXPECT_STREQ(L"abc\x8119", L"abc\x8121") << "Expected failure"; }, "Expected failure"); } // Tests *_STRNE on wide strings. TEST(StringAssertionTest, STRNE_Wide) { // NULL strings. EXPECT_NONFATAL_FAILURE({ // NOLINT EXPECT_STRNE(static_cast<const wchar_t *>(NULL), NULL); }, ""); // Empty strings. EXPECT_NONFATAL_FAILURE(EXPECT_STRNE(L"", L""), "L\"\""); // Non-null vs NULL. ASSERT_STRNE(L"non-null", NULL); // Equal strings. EXPECT_NONFATAL_FAILURE(EXPECT_STRNE(L"Hi", L"Hi"), "L\"Hi\""); // Unequal strings. EXPECT_STRNE(L"abc", L"Abc"); // Strings containing wide characters. EXPECT_NONFATAL_FAILURE(EXPECT_STRNE(L"abc\x8119", L"abc\x8119"), "abc"); // The streaming variation. ASSERT_STRNE(L"abc\x8119", L"abc\x8120") << "This shouldn't happen"; } // Tests for ::testing::IsSubstring(). // Tests that IsSubstring() returns the correct result when the input // argument type is const char*. TEST(IsSubstringTest, ReturnsCorrectResultForCString) { EXPECT_FALSE(IsSubstring("", "", NULL, "a")); EXPECT_FALSE(IsSubstring("", "", "b", NULL)); EXPECT_FALSE(IsSubstring("", "", "needle", "haystack")); EXPECT_TRUE(IsSubstring("", "", static_cast<const char*>(NULL), NULL)); EXPECT_TRUE(IsSubstring("", "", "needle", "two needles")); } // Tests that IsSubstring() returns the correct result when the input // argument type is const wchar_t*. TEST(IsSubstringTest, ReturnsCorrectResultForWideCString) { EXPECT_FALSE(IsSubstring("", "", kNull, L"a")); EXPECT_FALSE(IsSubstring("", "", L"b", kNull)); EXPECT_FALSE(IsSubstring("", "", L"needle", L"haystack")); EXPECT_TRUE(IsSubstring("", "", static_cast<const wchar_t*>(NULL), NULL)); EXPECT_TRUE(IsSubstring("", "", L"needle", L"two needles")); } // Tests that IsSubstring() generates the correct message when the input // argument type is const char*. TEST(IsSubstringTest, GeneratesCorrectMessageForCString) { EXPECT_STREQ("Value of: needle_expr\n" " Actual: \"needle\"\n" "Expected: a substring of haystack_expr\n" "Which is: \"haystack\"", IsSubstring("needle_expr", "haystack_expr", "needle", "haystack").failure_message()); } // Tests that IsSubstring returns the correct result when the input // argument type is ::std::string. TEST(IsSubstringTest, ReturnsCorrectResultsForStdString) { EXPECT_TRUE(IsSubstring("", "", std::string("hello"), "ahellob")); EXPECT_FALSE(IsSubstring("", "", "hello", std::string("world"))); } #if GTEST_HAS_STD_WSTRING // Tests that IsSubstring returns the correct result when the input // argument type is ::std::wstring. TEST(IsSubstringTest, ReturnsCorrectResultForStdWstring) { EXPECT_TRUE(IsSubstring("", "", ::std::wstring(L"needle"), L"two needles")); EXPECT_FALSE(IsSubstring("", "", L"needle", ::std::wstring(L"haystack"))); } // Tests that IsSubstring() generates the correct message when the input // argument type is ::std::wstring. TEST(IsSubstringTest, GeneratesCorrectMessageForWstring) { EXPECT_STREQ("Value of: needle_expr\n" " Actual: L\"needle\"\n" "Expected: a substring of haystack_expr\n" "Which is: L\"haystack\"", IsSubstring( "needle_expr", "haystack_expr", ::std::wstring(L"needle"), L"haystack").failure_message()); } #endif // GTEST_HAS_STD_WSTRING // Tests for ::testing::IsNotSubstring(). // Tests that IsNotSubstring() returns the correct result when the input // argument type is const char*. TEST(IsNotSubstringTest, ReturnsCorrectResultForCString) { EXPECT_TRUE(IsNotSubstring("", "", "needle", "haystack")); EXPECT_FALSE(IsNotSubstring("", "", "needle", "two needles")); } // Tests that IsNotSubstring() returns the correct result when the input // argument type is const wchar_t*. TEST(IsNotSubstringTest, ReturnsCorrectResultForWideCString) { EXPECT_TRUE(IsNotSubstring("", "", L"needle", L"haystack")); EXPECT_FALSE(IsNotSubstring("", "", L"needle", L"two needles")); } // Tests that IsNotSubstring() generates the correct message when the input // argument type is const wchar_t*. TEST(IsNotSubstringTest, GeneratesCorrectMessageForWideCString) { EXPECT_STREQ("Value of: needle_expr\n" " Actual: L\"needle\"\n" "Expected: not a substring of haystack_expr\n" "Which is: L\"two needles\"", IsNotSubstring( "needle_expr", "haystack_expr", L"needle", L"two needles").failure_message()); } // Tests that IsNotSubstring returns the correct result when the input // argument type is ::std::string. TEST(IsNotSubstringTest, ReturnsCorrectResultsForStdString) { EXPECT_FALSE(IsNotSubstring("", "", std::string("hello"), "ahellob")); EXPECT_TRUE(IsNotSubstring("", "", "hello", std::string("world"))); } // Tests that IsNotSubstring() generates the correct message when the input // argument type is ::std::string. TEST(IsNotSubstringTest, GeneratesCorrectMessageForStdString) { EXPECT_STREQ("Value of: needle_expr\n" " Actual: \"needle\"\n" "Expected: not a substring of haystack_expr\n" "Which is: \"two needles\"", IsNotSubstring( "needle_expr", "haystack_expr", ::std::string("needle"), "two needles").failure_message()); } #if GTEST_HAS_STD_WSTRING // Tests that IsNotSubstring returns the correct result when the input // argument type is ::std::wstring. TEST(IsNotSubstringTest, ReturnsCorrectResultForStdWstring) { EXPECT_FALSE( IsNotSubstring("", "", ::std::wstring(L"needle"), L"two needles")); EXPECT_TRUE(IsNotSubstring("", "", L"needle", ::std::wstring(L"haystack"))); } #endif // GTEST_HAS_STD_WSTRING // Tests floating-point assertions. template <typename RawType> class FloatingPointTest : public Test { protected: // Pre-calculated numbers to be used by the tests. struct TestValues { RawType close_to_positive_zero; RawType close_to_negative_zero; RawType further_from_negative_zero; RawType close_to_one; RawType further_from_one; RawType infinity; RawType close_to_infinity; RawType further_from_infinity; RawType nan1; RawType nan2; }; typedef typename testing::internal::FloatingPoint<RawType> Floating; typedef typename Floating::Bits Bits; virtual void SetUp() { const size_t max_ulps = Floating::kMaxUlps; // The bits that represent 0.0. const Bits zero_bits = Floating(0).bits(); // Makes some numbers close to 0.0. values_.close_to_positive_zero = Floating::ReinterpretBits( zero_bits + max_ulps/2); values_.close_to_negative_zero = -Floating::ReinterpretBits( zero_bits + max_ulps - max_ulps/2); values_.further_from_negative_zero = -Floating::ReinterpretBits( zero_bits + max_ulps + 1 - max_ulps/2); // The bits that represent 1.0. const Bits one_bits = Floating(1).bits(); // Makes some numbers close to 1.0. values_.close_to_one = Floating::ReinterpretBits(one_bits + max_ulps); values_.further_from_one = Floating::ReinterpretBits( one_bits + max_ulps + 1); // +infinity. values_.infinity = Floating::Infinity(); // The bits that represent +infinity. const Bits infinity_bits = Floating(values_.infinity).bits(); // Makes some numbers close to infinity. values_.close_to_infinity = Floating::ReinterpretBits( infinity_bits - max_ulps); values_.further_from_infinity = Floating::ReinterpretBits( infinity_bits - max_ulps - 1); // Makes some NAN's. Sets the most significant bit of the fraction so that // our NaN's are quiet; trying to process a signaling NaN would raise an // exception if our environment enables floating point exceptions. values_.nan1 = Floating::ReinterpretBits(Floating::kExponentBitMask | (static_cast<Bits>(1) << (Floating::kFractionBitCount - 1)) | 1); values_.nan2 = Floating::ReinterpretBits(Floating::kExponentBitMask | (static_cast<Bits>(1) << (Floating::kFractionBitCount - 1)) | 200); } void TestSize() { EXPECT_EQ(sizeof(RawType), sizeof(Bits)); } static TestValues values_; }; template <typename RawType> typename FloatingPointTest<RawType>::TestValues FloatingPointTest<RawType>::values_; // Instantiates FloatingPointTest for testing *_FLOAT_EQ. typedef FloatingPointTest<float> FloatTest; // Tests that the size of Float::Bits matches the size of float. TEST_F(FloatTest, Size) { TestSize(); } // Tests comparing with +0 and -0. TEST_F(FloatTest, Zeros) { EXPECT_FLOAT_EQ(0.0, -0.0); EXPECT_NONFATAL_FAILURE(EXPECT_FLOAT_EQ(-0.0, 1.0), "1.0"); EXPECT_FATAL_FAILURE(ASSERT_FLOAT_EQ(0.0, 1.5), "1.5"); } // Tests comparing numbers close to 0. // // This ensures that *_FLOAT_EQ handles the sign correctly and no // overflow occurs when comparing numbers whose absolute value is very // small. TEST_F(FloatTest, AlmostZeros) { // In C++Builder, names within local classes (such as used by // EXPECT_FATAL_FAILURE) cannot be resolved against static members of the // scoping class. Use a static local alias as a workaround. // We use the assignment syntax since some compilers, like Sun Studio, // don't allow initializing references using construction syntax // (parentheses). static const FloatTest::TestValues& v = this->values_; EXPECT_FLOAT_EQ(0.0, v.close_to_positive_zero); EXPECT_FLOAT_EQ(-0.0, v.close_to_negative_zero); EXPECT_FLOAT_EQ(v.close_to_positive_zero, v.close_to_negative_zero); EXPECT_FATAL_FAILURE({ // NOLINT ASSERT_FLOAT_EQ(v.close_to_positive_zero, v.further_from_negative_zero); }, "v.further_from_negative_zero"); } // Tests comparing numbers close to each other. TEST_F(FloatTest, SmallDiff) { EXPECT_FLOAT_EQ(1.0, values_.close_to_one); EXPECT_NONFATAL_FAILURE(EXPECT_FLOAT_EQ(1.0, values_.further_from_one), "values_.further_from_one"); } // Tests comparing numbers far apart. TEST_F(FloatTest, LargeDiff) { EXPECT_NONFATAL_FAILURE(EXPECT_FLOAT_EQ(2.5, 3.0), "3.0"); } // Tests comparing with infinity. // // This ensures that no overflow occurs when comparing numbers whose // absolute value is very large. TEST_F(FloatTest, Infinity) { EXPECT_FLOAT_EQ(values_.infinity, values_.close_to_infinity); EXPECT_FLOAT_EQ(-values_.infinity, -values_.close_to_infinity); #if !GTEST_OS_SYMBIAN // Nokia's STLport crashes if we try to output infinity or NaN. EXPECT_NONFATAL_FAILURE(EXPECT_FLOAT_EQ(values_.infinity, -values_.infinity), "-values_.infinity"); // This is interesting as the representations of infinity and nan1 // are only 1 DLP apart. EXPECT_NONFATAL_FAILURE(EXPECT_FLOAT_EQ(values_.infinity, values_.nan1), "values_.nan1"); #endif // !GTEST_OS_SYMBIAN } // Tests that comparing with NAN always returns false. TEST_F(FloatTest, NaN) { #if !GTEST_OS_SYMBIAN // Nokia's STLport crashes if we try to output infinity or NaN. // In C++Builder, names within local classes (such as used by // EXPECT_FATAL_FAILURE) cannot be resolved against static members of the // scoping class. Use a static local alias as a workaround. // We use the assignment syntax since some compilers, like Sun Studio, // don't allow initializing references using construction syntax // (parentheses). static const FloatTest::TestValues& v = this->values_; EXPECT_NONFATAL_FAILURE(EXPECT_FLOAT_EQ(v.nan1, v.nan1), "v.nan1"); EXPECT_NONFATAL_FAILURE(EXPECT_FLOAT_EQ(v.nan1, v.nan2), "v.nan2"); EXPECT_NONFATAL_FAILURE(EXPECT_FLOAT_EQ(1.0, v.nan1), "v.nan1"); EXPECT_FATAL_FAILURE(ASSERT_FLOAT_EQ(v.nan1, v.infinity), "v.infinity"); #endif // !GTEST_OS_SYMBIAN } // Tests that *_FLOAT_EQ are reflexive. TEST_F(FloatTest, Reflexive) { EXPECT_FLOAT_EQ(0.0, 0.0); EXPECT_FLOAT_EQ(1.0, 1.0); ASSERT_FLOAT_EQ(values_.infinity, values_.infinity); } // Tests that *_FLOAT_EQ are commutative. TEST_F(FloatTest, Commutative) { // We already tested EXPECT_FLOAT_EQ(1.0, values_.close_to_one). EXPECT_FLOAT_EQ(values_.close_to_one, 1.0); // We already tested EXPECT_FLOAT_EQ(1.0, values_.further_from_one). EXPECT_NONFATAL_FAILURE(EXPECT_FLOAT_EQ(values_.further_from_one, 1.0), "1.0"); } // Tests EXPECT_NEAR. TEST_F(FloatTest, EXPECT_NEAR) { EXPECT_NEAR(-1.0f, -1.1f, 0.2f); EXPECT_NEAR(2.0f, 3.0f, 1.0f); EXPECT_NONFATAL_FAILURE(EXPECT_NEAR(1.0f,1.5f, 0.25f), // NOLINT "The difference between 1.0f and 1.5f is 0.5, " "which exceeds 0.25f"); // To work around a bug in gcc 2.95.0, there is intentionally no // space after the first comma in the previous line. } // Tests ASSERT_NEAR. TEST_F(FloatTest, ASSERT_NEAR) { ASSERT_NEAR(-1.0f, -1.1f, 0.2f); ASSERT_NEAR(2.0f, 3.0f, 1.0f); EXPECT_FATAL_FAILURE(ASSERT_NEAR(1.0f,1.5f, 0.25f), // NOLINT "The difference between 1.0f and 1.5f is 0.5, " "which exceeds 0.25f"); // To work around a bug in gcc 2.95.0, there is intentionally no // space after the first comma in the previous line. } // Tests the cases where FloatLE() should succeed. TEST_F(FloatTest, FloatLESucceeds) { EXPECT_PRED_FORMAT2(FloatLE, 1.0f, 2.0f); // When val1 < val2, ASSERT_PRED_FORMAT2(FloatLE, 1.0f, 1.0f); // val1 == val2, // or when val1 is greater than, but almost equals to, val2. EXPECT_PRED_FORMAT2(FloatLE, values_.close_to_positive_zero, 0.0f); } // Tests the cases where FloatLE() should fail. TEST_F(FloatTest, FloatLEFails) { // When val1 is greater than val2 by a large margin, EXPECT_NONFATAL_FAILURE(EXPECT_PRED_FORMAT2(FloatLE, 2.0f, 1.0f), "(2.0f) <= (1.0f)"); // or by a small yet non-negligible margin, EXPECT_NONFATAL_FAILURE({ // NOLINT EXPECT_PRED_FORMAT2(FloatLE, values_.further_from_one, 1.0f); }, "(values_.further_from_one) <= (1.0f)"); #if !GTEST_OS_SYMBIAN && !defined(__BORLANDC__) // Nokia's STLport crashes if we try to output infinity or NaN. // C++Builder gives bad results for ordered comparisons involving NaNs // due to compiler bugs. EXPECT_NONFATAL_FAILURE({ // NOLINT EXPECT_PRED_FORMAT2(FloatLE, values_.nan1, values_.infinity); }, "(values_.nan1) <= (values_.infinity)"); EXPECT_NONFATAL_FAILURE({ // NOLINT EXPECT_PRED_FORMAT2(FloatLE, -values_.infinity, values_.nan1); }, "(-values_.infinity) <= (values_.nan1)"); EXPECT_FATAL_FAILURE({ // NOLINT ASSERT_PRED_FORMAT2(FloatLE, values_.nan1, values_.nan1); }, "(values_.nan1) <= (values_.nan1)"); #endif // !GTEST_OS_SYMBIAN && !defined(__BORLANDC__) } // Instantiates FloatingPointTest for testing *_DOUBLE_EQ. typedef FloatingPointTest<double> DoubleTest; // Tests that the size of Double::Bits matches the size of double. TEST_F(DoubleTest, Size) { TestSize(); } // Tests comparing with +0 and -0. TEST_F(DoubleTest, Zeros) { EXPECT_DOUBLE_EQ(0.0, -0.0); EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(-0.0, 1.0), "1.0"); EXPECT_FATAL_FAILURE(ASSERT_DOUBLE_EQ(0.0, 1.0), "1.0"); } // Tests comparing numbers close to 0. // // This ensures that *_DOUBLE_EQ handles the sign correctly and no // overflow occurs when comparing numbers whose absolute value is very // small. TEST_F(DoubleTest, AlmostZeros) { // In C++Builder, names within local classes (such as used by // EXPECT_FATAL_FAILURE) cannot be resolved against static members of the // scoping class. Use a static local alias as a workaround. // We use the assignment syntax since some compilers, like Sun Studio, // don't allow initializing references using construction syntax // (parentheses). static const DoubleTest::TestValues& v = this->values_; EXPECT_DOUBLE_EQ(0.0, v.close_to_positive_zero); EXPECT_DOUBLE_EQ(-0.0, v.close_to_negative_zero); EXPECT_DOUBLE_EQ(v.close_to_positive_zero, v.close_to_negative_zero); EXPECT_FATAL_FAILURE({ // NOLINT ASSERT_DOUBLE_EQ(v.close_to_positive_zero, v.further_from_negative_zero); }, "v.further_from_negative_zero"); } // Tests comparing numbers close to each other. TEST_F(DoubleTest, SmallDiff) { EXPECT_DOUBLE_EQ(1.0, values_.close_to_one); EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(1.0, values_.further_from_one), "values_.further_from_one"); } // Tests comparing numbers far apart. TEST_F(DoubleTest, LargeDiff) { EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(2.0, 3.0), "3.0"); } // Tests comparing with infinity. // // This ensures that no overflow occurs when comparing numbers whose // absolute value is very large. TEST_F(DoubleTest, Infinity) { EXPECT_DOUBLE_EQ(values_.infinity, values_.close_to_infinity); EXPECT_DOUBLE_EQ(-values_.infinity, -values_.close_to_infinity); #if !GTEST_OS_SYMBIAN // Nokia's STLport crashes if we try to output infinity or NaN. EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(values_.infinity, -values_.infinity), "-values_.infinity"); // This is interesting as the representations of infinity_ and nan1_ // are only 1 DLP apart. EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(values_.infinity, values_.nan1), "values_.nan1"); #endif // !GTEST_OS_SYMBIAN } // Tests that comparing with NAN always returns false. TEST_F(DoubleTest, NaN) { #if !GTEST_OS_SYMBIAN // In C++Builder, names within local classes (such as used by // EXPECT_FATAL_FAILURE) cannot be resolved against static members of the // scoping class. Use a static local alias as a workaround. // We use the assignment syntax since some compilers, like Sun Studio, // don't allow initializing references using construction syntax // (parentheses). static const DoubleTest::TestValues& v = this->values_; // Nokia's STLport crashes if we try to output infinity or NaN. EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(v.nan1, v.nan1), "v.nan1"); EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(v.nan1, v.nan2), "v.nan2"); EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(1.0, v.nan1), "v.nan1"); EXPECT_FATAL_FAILURE(ASSERT_DOUBLE_EQ(v.nan1, v.infinity), "v.infinity"); #endif // !GTEST_OS_SYMBIAN } // Tests that *_DOUBLE_EQ are reflexive. TEST_F(DoubleTest, Reflexive) { EXPECT_DOUBLE_EQ(0.0, 0.0); EXPECT_DOUBLE_EQ(1.0, 1.0); #if !GTEST_OS_SYMBIAN // Nokia's STLport crashes if we try to output infinity or NaN. ASSERT_DOUBLE_EQ(values_.infinity, values_.infinity); #endif // !GTEST_OS_SYMBIAN } // Tests that *_DOUBLE_EQ are commutative. TEST_F(DoubleTest, Commutative) { // We already tested EXPECT_DOUBLE_EQ(1.0, values_.close_to_one). EXPECT_DOUBLE_EQ(values_.close_to_one, 1.0); // We already tested EXPECT_DOUBLE_EQ(1.0, values_.further_from_one). EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(values_.further_from_one, 1.0), "1.0"); } // Tests EXPECT_NEAR. TEST_F(DoubleTest, EXPECT_NEAR) { EXPECT_NEAR(-1.0, -1.1, 0.2); EXPECT_NEAR(2.0, 3.0, 1.0); EXPECT_NONFATAL_FAILURE(EXPECT_NEAR(1.0, 1.5, 0.25), // NOLINT "The difference between 1.0 and 1.5 is 0.5, " "which exceeds 0.25"); // To work around a bug in gcc 2.95.0, there is intentionally no // space after the first comma in the previous statement. } // Tests ASSERT_NEAR. TEST_F(DoubleTest, ASSERT_NEAR) { ASSERT_NEAR(-1.0, -1.1, 0.2); ASSERT_NEAR(2.0, 3.0, 1.0); EXPECT_FATAL_FAILURE(ASSERT_NEAR(1.0, 1.5, 0.25), // NOLINT "The difference between 1.0 and 1.5 is 0.5, " "which exceeds 0.25"); // To work around a bug in gcc 2.95.0, there is intentionally no // space after the first comma in the previous statement. } // Tests the cases where DoubleLE() should succeed. TEST_F(DoubleTest, DoubleLESucceeds) { EXPECT_PRED_FORMAT2(DoubleLE, 1.0, 2.0); // When val1 < val2, ASSERT_PRED_FORMAT2(DoubleLE, 1.0, 1.0); // val1 == val2, // or when val1 is greater than, but almost equals to, val2. EXPECT_PRED_FORMAT2(DoubleLE, values_.close_to_positive_zero, 0.0); } // Tests the cases where DoubleLE() should fail. TEST_F(DoubleTest, DoubleLEFails) { // When val1 is greater than val2 by a large margin, EXPECT_NONFATAL_FAILURE(EXPECT_PRED_FORMAT2(DoubleLE, 2.0, 1.0), "(2.0) <= (1.0)"); // or by a small yet non-negligible margin, EXPECT_NONFATAL_FAILURE({ // NOLINT EXPECT_PRED_FORMAT2(DoubleLE, values_.further_from_one, 1.0); }, "(values_.further_from_one) <= (1.0)"); #if !GTEST_OS_SYMBIAN && !defined(__BORLANDC__) // Nokia's STLport crashes if we try to output infinity or NaN. // C++Builder gives bad results for ordered comparisons involving NaNs // due to compiler bugs. EXPECT_NONFATAL_FAILURE({ // NOLINT EXPECT_PRED_FORMAT2(DoubleLE, values_.nan1, values_.infinity); }, "(values_.nan1) <= (values_.infinity)"); EXPECT_NONFATAL_FAILURE({ // NOLINT EXPECT_PRED_FORMAT2(DoubleLE, -values_.infinity, values_.nan1); }, " (-values_.infinity) <= (values_.nan1)"); EXPECT_FATAL_FAILURE({ // NOLINT ASSERT_PRED_FORMAT2(DoubleLE, values_.nan1, values_.nan1); }, "(values_.nan1) <= (values_.nan1)"); #endif // !GTEST_OS_SYMBIAN && !defined(__BORLANDC__) } // Verifies that a test or test case whose name starts with DISABLED_ is // not run. // A test whose name starts with DISABLED_. // Should not run. TEST(DisabledTest, DISABLED_TestShouldNotRun) { FAIL() << "Unexpected failure: Disabled test should not be run."; } // A test whose name does not start with DISABLED_. // Should run. TEST(DisabledTest, NotDISABLED_TestShouldRun) { EXPECT_EQ(1, 1); } // A test case whose name starts with DISABLED_. // Should not run. TEST(DISABLED_TestCase, TestShouldNotRun) { FAIL() << "Unexpected failure: Test in disabled test case should not be run."; } // A test case and test whose names start with DISABLED_. // Should not run. TEST(DISABLED_TestCase, DISABLED_TestShouldNotRun) { FAIL() << "Unexpected failure: Test in disabled test case should not be run."; } // Check that when all tests in a test case are disabled, SetUpTestCase() and // TearDownTestCase() are not called. class DisabledTestsTest : public Test { protected: static void SetUpTestCase() { FAIL() << "Unexpected failure: All tests disabled in test case. " "SetUpTestCase() should not be called."; } static void TearDownTestCase() { FAIL() << "Unexpected failure: All tests disabled in test case. " "TearDownTestCase() should not be called."; } }; TEST_F(DisabledTestsTest, DISABLED_TestShouldNotRun_1) { FAIL() << "Unexpected failure: Disabled test should not be run."; } TEST_F(DisabledTestsTest, DISABLED_TestShouldNotRun_2) { FAIL() << "Unexpected failure: Disabled test should not be run."; } // Tests that disabled typed tests aren't run. #if GTEST_HAS_TYPED_TEST template <typename T> class TypedTest : public Test { }; typedef testing::Types<int, double> NumericTypes; TYPED_TEST_CASE(TypedTest, NumericTypes); TYPED_TEST(TypedTest, DISABLED_ShouldNotRun) { FAIL() << "Unexpected failure: Disabled typed test should not run."; } template <typename T> class DISABLED_TypedTest : public Test { }; TYPED_TEST_CASE(DISABLED_TypedTest, NumericTypes); TYPED_TEST(DISABLED_TypedTest, ShouldNotRun) { FAIL() << "Unexpected failure: Disabled typed test should not run."; } #endif // GTEST_HAS_TYPED_TEST // Tests that disabled type-parameterized tests aren't run. #if GTEST_HAS_TYPED_TEST_P template <typename T> class TypedTestP : public Test { }; TYPED_TEST_CASE_P(TypedTestP); TYPED_TEST_P(TypedTestP, DISABLED_ShouldNotRun) { FAIL() << "Unexpected failure: " << "Disabled type-parameterized test should not run."; } REGISTER_TYPED_TEST_CASE_P(TypedTestP, DISABLED_ShouldNotRun); INSTANTIATE_TYPED_TEST_CASE_P(My, TypedTestP, NumericTypes); template <typename T> class DISABLED_TypedTestP : public Test { }; TYPED_TEST_CASE_P(DISABLED_TypedTestP); TYPED_TEST_P(DISABLED_TypedTestP, ShouldNotRun) { FAIL() << "Unexpected failure: " << "Disabled type-parameterized test should not run."; } REGISTER_TYPED_TEST_CASE_P(DISABLED_TypedTestP, ShouldNotRun); INSTANTIATE_TYPED_TEST_CASE_P(My, DISABLED_TypedTestP, NumericTypes); #endif // GTEST_HAS_TYPED_TEST_P // Tests that assertion macros evaluate their arguments exactly once. class SingleEvaluationTest : public Test { public: // Must be public and not protected due to a bug in g++ 3.4.2. // This helper function is needed by the FailedASSERT_STREQ test // below. It's public to work around C++Builder's bug with scoping local // classes. static void CompareAndIncrementCharPtrs() { ASSERT_STREQ(p1_++, p2_++); } // This helper function is needed by the FailedASSERT_NE test below. It's // public to work around C++Builder's bug with scoping local classes. static void CompareAndIncrementInts() { ASSERT_NE(a_++, b_++); } protected: SingleEvaluationTest() { p1_ = s1_; p2_ = s2_; a_ = 0; b_ = 0; } static const char* const s1_; static const char* const s2_; static const char* p1_; static const char* p2_; static int a_; static int b_; }; const char* const SingleEvaluationTest::s1_ = "01234"; const char* const SingleEvaluationTest::s2_ = "abcde"; const char* SingleEvaluationTest::p1_; const char* SingleEvaluationTest::p2_; int SingleEvaluationTest::a_; int SingleEvaluationTest::b_; // Tests that when ASSERT_STREQ fails, it evaluates its arguments // exactly once. TEST_F(SingleEvaluationTest, FailedASSERT_STREQ) { EXPECT_FATAL_FAILURE(SingleEvaluationTest::CompareAndIncrementCharPtrs(), "p2_++"); EXPECT_EQ(s1_ + 1, p1_); EXPECT_EQ(s2_ + 1, p2_); } // Tests that string assertion arguments are evaluated exactly once. TEST_F(SingleEvaluationTest, ASSERT_STR) { // successful EXPECT_STRNE EXPECT_STRNE(p1_++, p2_++); EXPECT_EQ(s1_ + 1, p1_); EXPECT_EQ(s2_ + 1, p2_); // failed EXPECT_STRCASEEQ EXPECT_NONFATAL_FAILURE(EXPECT_STRCASEEQ(p1_++, p2_++), "Ignoring case"); EXPECT_EQ(s1_ + 2, p1_); EXPECT_EQ(s2_ + 2, p2_); } // Tests that when ASSERT_NE fails, it evaluates its arguments exactly // once. TEST_F(SingleEvaluationTest, FailedASSERT_NE) { EXPECT_FATAL_FAILURE(SingleEvaluationTest::CompareAndIncrementInts(), "(a_++) != (b_++)"); EXPECT_EQ(1, a_); EXPECT_EQ(1, b_); } // Tests that assertion arguments are evaluated exactly once. TEST_F(SingleEvaluationTest, OtherCases) { // successful EXPECT_TRUE EXPECT_TRUE(0 == a_++); // NOLINT EXPECT_EQ(1, a_); // failed EXPECT_TRUE EXPECT_NONFATAL_FAILURE(EXPECT_TRUE(-1 == a_++), "-1 == a_++"); EXPECT_EQ(2, a_); // successful EXPECT_GT EXPECT_GT(a_++, b_++); EXPECT_EQ(3, a_); EXPECT_EQ(1, b_); // failed EXPECT_LT EXPECT_NONFATAL_FAILURE(EXPECT_LT(a_++, b_++), "(a_++) < (b_++)"); EXPECT_EQ(4, a_); EXPECT_EQ(2, b_); // successful ASSERT_TRUE ASSERT_TRUE(0 < a_++); // NOLINT EXPECT_EQ(5, a_); // successful ASSERT_GT ASSERT_GT(a_++, b_++); EXPECT_EQ(6, a_); EXPECT_EQ(3, b_); } #if GTEST_HAS_EXCEPTIONS void ThrowAnInteger() { throw 1; } // Tests that assertion arguments are evaluated exactly once. TEST_F(SingleEvaluationTest, ExceptionTests) { // successful EXPECT_THROW EXPECT_THROW({ // NOLINT a_++; ThrowAnInteger(); }, int); EXPECT_EQ(1, a_); // failed EXPECT_THROW, throws different EXPECT_NONFATAL_FAILURE(EXPECT_THROW({ // NOLINT a_++; ThrowAnInteger(); }, bool), "throws a different type"); EXPECT_EQ(2, a_); // failed EXPECT_THROW, throws nothing EXPECT_NONFATAL_FAILURE(EXPECT_THROW(a_++, bool), "throws nothing"); EXPECT_EQ(3, a_); // successful EXPECT_NO_THROW EXPECT_NO_THROW(a_++); EXPECT_EQ(4, a_); // failed EXPECT_NO_THROW EXPECT_NONFATAL_FAILURE(EXPECT_NO_THROW({ // NOLINT a_++; ThrowAnInteger(); }), "it throws"); EXPECT_EQ(5, a_); // successful EXPECT_ANY_THROW EXPECT_ANY_THROW({ // NOLINT a_++; ThrowAnInteger(); }); EXPECT_EQ(6, a_); // failed EXPECT_ANY_THROW EXPECT_NONFATAL_FAILURE(EXPECT_ANY_THROW(a_++), "it doesn't"); EXPECT_EQ(7, a_); } #endif // GTEST_HAS_EXCEPTIONS // Tests {ASSERT|EXPECT}_NO_FATAL_FAILURE. class NoFatalFailureTest : public Test { protected: void Succeeds() {} void FailsNonFatal() { ADD_FAILURE() << "some non-fatal failure"; } void Fails() { FAIL() << "some fatal failure"; } void DoAssertNoFatalFailureOnFails() { ASSERT_NO_FATAL_FAILURE(Fails()); ADD_FAILURE() << "should not reach here."; } void DoExpectNoFatalFailureOnFails() { EXPECT_NO_FATAL_FAILURE(Fails()); ADD_FAILURE() << "other failure"; } }; TEST_F(NoFatalFailureTest, NoFailure) { EXPECT_NO_FATAL_FAILURE(Succeeds()); ASSERT_NO_FATAL_FAILURE(Succeeds()); } TEST_F(NoFatalFailureTest, NonFatalIsNoFailure) { EXPECT_NONFATAL_FAILURE( EXPECT_NO_FATAL_FAILURE(FailsNonFatal()), "some non-fatal failure"); EXPECT_NONFATAL_FAILURE( ASSERT_NO_FATAL_FAILURE(FailsNonFatal()), "some non-fatal failure"); } TEST_F(NoFatalFailureTest, AssertNoFatalFailureOnFatalFailure) { TestPartResultArray gtest_failures; { ScopedFakeTestPartResultReporter gtest_reporter(&gtest_failures); DoAssertNoFatalFailureOnFails(); } ASSERT_EQ(2, gtest_failures.size()); EXPECT_EQ(TestPartResult::kFatalFailure, gtest_failures.GetTestPartResult(0).type()); EXPECT_EQ(TestPartResult::kFatalFailure, gtest_failures.GetTestPartResult(1).type()); EXPECT_PRED_FORMAT2(testing::IsSubstring, "some fatal failure", gtest_failures.GetTestPartResult(0).message()); EXPECT_PRED_FORMAT2(testing::IsSubstring, "it does", gtest_failures.GetTestPartResult(1).message()); } TEST_F(NoFatalFailureTest, ExpectNoFatalFailureOnFatalFailure) { TestPartResultArray gtest_failures; { ScopedFakeTestPartResultReporter gtest_reporter(&gtest_failures); DoExpectNoFatalFailureOnFails(); } ASSERT_EQ(3, gtest_failures.size()); EXPECT_EQ(TestPartResult::kFatalFailure, gtest_failures.GetTestPartResult(0).type()); EXPECT_EQ(TestPartResult::kNonFatalFailure, gtest_failures.GetTestPartResult(1).type()); EXPECT_EQ(TestPartResult::kNonFatalFailure, gtest_failures.GetTestPartResult(2).type()); EXPECT_PRED_FORMAT2(testing::IsSubstring, "some fatal failure", gtest_failures.GetTestPartResult(0).message()); EXPECT_PRED_FORMAT2(testing::IsSubstring, "it does", gtest_failures.GetTestPartResult(1).message()); EXPECT_PRED_FORMAT2(testing::IsSubstring, "other failure", gtest_failures.GetTestPartResult(2).message()); } TEST_F(NoFatalFailureTest, MessageIsStreamable) { TestPartResultArray gtest_failures; { ScopedFakeTestPartResultReporter gtest_reporter(&gtest_failures); EXPECT_NO_FATAL_FAILURE(FAIL() << "foo") << "my message"; } ASSERT_EQ(2, gtest_failures.size()); EXPECT_EQ(TestPartResult::kNonFatalFailure, gtest_failures.GetTestPartResult(0).type()); EXPECT_EQ(TestPartResult::kNonFatalFailure, gtest_failures.GetTestPartResult(1).type()); EXPECT_PRED_FORMAT2(testing::IsSubstring, "foo", gtest_failures.GetTestPartResult(0).message()); EXPECT_PRED_FORMAT2(testing::IsSubstring, "my message", gtest_failures.GetTestPartResult(1).message()); } // Tests non-string assertions. std::string EditsToString(const std::vector<EditType>& edits) { std::string out; for (size_t i = 0; i < edits.size(); ++i) { static const char kEdits[] = " +-/"; out.append(1, kEdits[edits[i]]); } return out; } std::vector<size_t> CharsToIndices(const std::string& str) { std::vector<size_t> out; for (size_t i = 0; i < str.size(); ++i) { out.push_back(str[i]); } return out; } std::vector<std::string> CharsToLines(const std::string& str) { std::vector<std::string> out; for (size_t i = 0; i < str.size(); ++i) { out.push_back(str.substr(i, 1)); } return out; } TEST(EditDistance, TestCases) { struct Case { int line; const char* left; const char* right; const char* expected_edits; const char* expected_diff; }; static const Case kCases[] = { // No change. {__LINE__, "A", "A", " ", ""}, {__LINE__, "ABCDE", "ABCDE", " ", ""}, // Simple adds. {__LINE__, "X", "XA", " +", "@@ +1,2 @@\n X\n+A\n"}, {__LINE__, "X", "XABCD", " ++++", "@@ +1,5 @@\n X\n+A\n+B\n+C\n+D\n"}, // Simple removes. {__LINE__, "XA", "X", " -", "@@ -1,2 @@\n X\n-A\n"}, {__LINE__, "XABCD", "X", " ----", "@@ -1,5 @@\n X\n-A\n-B\n-C\n-D\n"}, // Simple replaces. {__LINE__, "A", "a", "/", "@@ -1,1 +1,1 @@\n-A\n+a\n"}, {__LINE__, "ABCD", "abcd", "////", "@@ -1,4 +1,4 @@\n-A\n-B\n-C\n-D\n+a\n+b\n+c\n+d\n"}, // Path finding. {__LINE__, "ABCDEFGH", "ABXEGH1", " -/ - +", "@@ -1,8 +1,7 @@\n A\n B\n-C\n-D\n+X\n E\n-F\n G\n H\n+1\n"}, {__LINE__, "AAAABCCCC", "ABABCDCDC", "- / + / ", "@@ -1,9 +1,9 @@\n-A\n A\n-A\n+B\n A\n B\n C\n+D\n C\n-C\n+D\n C\n"}, {__LINE__, "ABCDE", "BCDCD", "- +/", "@@ -1,5 +1,5 @@\n-A\n B\n C\n D\n-E\n+C\n+D\n"}, {__LINE__, "ABCDEFGHIJKL", "BCDCDEFGJKLJK", "- ++ -- ++", "@@ -1,4 +1,5 @@\n-A\n B\n+C\n+D\n C\n D\n" "@@ -6,7 +7,7 @@\n F\n G\n-H\n-I\n J\n K\n L\n+J\n+K\n"}, {}}; for (const Case* c = kCases; c->left; ++c) { EXPECT_TRUE(c->expected_edits == EditsToString(CalculateOptimalEdits(CharsToIndices(c->left), CharsToIndices(c->right)))) << "Left <" << c->left << "> Right <" << c->right << "> Edits <" << EditsToString(CalculateOptimalEdits( CharsToIndices(c->left), CharsToIndices(c->right))) << ">"; EXPECT_TRUE(c->expected_diff == CreateUnifiedDiff(CharsToLines(c->left), CharsToLines(c->right))) << "Left <" << c->left << "> Right <" << c->right << "> Diff <" << CreateUnifiedDiff(CharsToLines(c->left), CharsToLines(c->right)) << ">"; } } // Tests EqFailure(), used for implementing *EQ* assertions. TEST(AssertionTest, EqFailure) { const std::string foo_val("5"), bar_val("6"); const std::string msg1( EqFailure("foo", "bar", foo_val, bar_val, false) .failure_message()); EXPECT_STREQ( "Expected equality of these values:\n" " foo\n" " Which is: 5\n" " bar\n" " Which is: 6", msg1.c_str()); const std::string msg2( EqFailure("foo", "6", foo_val, bar_val, false) .failure_message()); EXPECT_STREQ( "Expected equality of these values:\n" " foo\n" " Which is: 5\n" " 6", msg2.c_str()); const std::string msg3( EqFailure("5", "bar", foo_val, bar_val, false) .failure_message()); EXPECT_STREQ( "Expected equality of these values:\n" " 5\n" " bar\n" " Which is: 6", msg3.c_str()); const std::string msg4( EqFailure("5", "6", foo_val, bar_val, false).failure_message()); EXPECT_STREQ( "Expected equality of these values:\n" " 5\n" " 6", msg4.c_str()); const std::string msg5( EqFailure("foo", "bar", std::string("\"x\""), std::string("\"y\""), true).failure_message()); EXPECT_STREQ( "Expected equality of these values:\n" " foo\n" " Which is: \"x\"\n" " bar\n" " Which is: \"y\"\n" "Ignoring case", msg5.c_str()); } TEST(AssertionTest, EqFailureWithDiff) { const std::string left( "1\\n2XXX\\n3\\n5\\n6\\n7\\n8\\n9\\n10\\n11\\n12XXX\\n13\\n14\\n15"); const std::string right( "1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n11\\n12\\n13\\n14"); const std::string msg1( EqFailure("left", "right", left, right, false).failure_message()); EXPECT_STREQ( "Expected equality of these values:\n" " left\n" " Which is: " "1\\n2XXX\\n3\\n5\\n6\\n7\\n8\\n9\\n10\\n11\\n12XXX\\n13\\n14\\n15\n" " right\n" " Which is: 1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n11\\n12\\n13\\n14\n" "With diff:\n@@ -1,5 +1,6 @@\n 1\n-2XXX\n+2\n 3\n+4\n 5\n 6\n" "@@ -7,8 +8,6 @@\n 8\n 9\n-10\n 11\n-12XXX\n+12\n 13\n 14\n-15\n", msg1.c_str()); } // Tests AppendUserMessage(), used for implementing the *EQ* macros. TEST(AssertionTest, AppendUserMessage) { const std::string foo("foo"); Message msg; EXPECT_STREQ("foo", AppendUserMessage(foo, msg).c_str()); msg << "bar"; EXPECT_STREQ("foo\nbar", AppendUserMessage(foo, msg).c_str()); } #ifdef __BORLANDC__ // Silences warnings: "Condition is always true", "Unreachable code" # pragma option push -w-ccc -w-rch #endif // Tests ASSERT_TRUE. TEST(AssertionTest, ASSERT_TRUE) { ASSERT_TRUE(2 > 1); // NOLINT EXPECT_FATAL_FAILURE(ASSERT_TRUE(2 < 1), "2 < 1"); } // Tests ASSERT_TRUE(predicate) for predicates returning AssertionResult. TEST(AssertionTest, AssertTrueWithAssertionResult) { ASSERT_TRUE(ResultIsEven(2)); #ifndef __BORLANDC__ // ICE's in C++Builder. EXPECT_FATAL_FAILURE(ASSERT_TRUE(ResultIsEven(3)), "Value of: ResultIsEven(3)\n" " Actual: false (3 is odd)\n" "Expected: true"); #endif ASSERT_TRUE(ResultIsEvenNoExplanation(2)); EXPECT_FATAL_FAILURE(ASSERT_TRUE(ResultIsEvenNoExplanation(3)), "Value of: ResultIsEvenNoExplanation(3)\n" " Actual: false (3 is odd)\n" "Expected: true"); } // Tests ASSERT_FALSE. TEST(AssertionTest, ASSERT_FALSE) { ASSERT_FALSE(2 < 1); // NOLINT EXPECT_FATAL_FAILURE(ASSERT_FALSE(2 > 1), "Value of: 2 > 1\n" " Actual: true\n" "Expected: false"); } // Tests ASSERT_FALSE(predicate) for predicates returning AssertionResult. TEST(AssertionTest, AssertFalseWithAssertionResult) { ASSERT_FALSE(ResultIsEven(3)); #ifndef __BORLANDC__ // ICE's in C++Builder. EXPECT_FATAL_FAILURE(ASSERT_FALSE(ResultIsEven(2)), "Value of: ResultIsEven(2)\n" " Actual: true (2 is even)\n" "Expected: false"); #endif ASSERT_FALSE(ResultIsEvenNoExplanation(3)); EXPECT_FATAL_FAILURE(ASSERT_FALSE(ResultIsEvenNoExplanation(2)), "Value of: ResultIsEvenNoExplanation(2)\n" " Actual: true\n" "Expected: false"); } #ifdef __BORLANDC__ // Restores warnings after previous "#pragma option push" suppressed them # pragma option pop #endif // Tests using ASSERT_EQ on double values. The purpose is to make // sure that the specialization we did for integer and anonymous enums // isn't used for double arguments. TEST(ExpectTest, ASSERT_EQ_Double) { // A success. ASSERT_EQ(5.6, 5.6); // A failure. EXPECT_FATAL_FAILURE(ASSERT_EQ(5.1, 5.2), "5.1"); } // Tests ASSERT_EQ. TEST(AssertionTest, ASSERT_EQ) { ASSERT_EQ(5, 2 + 3); EXPECT_FATAL_FAILURE(ASSERT_EQ(5, 2*3), "Expected equality of these values:\n" " 5\n" " 2*3\n" " Which is: 6"); } // Tests ASSERT_EQ(NULL, pointer). #if GTEST_CAN_COMPARE_NULL TEST(AssertionTest, ASSERT_EQ_NULL) { // A success. const char* p = NULL; // Some older GCC versions may issue a spurious warning in this or the next // assertion statement. This warning should not be suppressed with // static_cast since the test verifies the ability to use bare NULL as the // expected parameter to the macro. ASSERT_EQ(NULL, p); // A failure. static int n = 0; EXPECT_FATAL_FAILURE(ASSERT_EQ(NULL, &n), " &n\n Which is:"); } #endif // GTEST_CAN_COMPARE_NULL // Tests ASSERT_EQ(0, non_pointer). Since the literal 0 can be // treated as a null pointer by the compiler, we need to make sure // that ASSERT_EQ(0, non_pointer) isn't interpreted by Google Test as // ASSERT_EQ(static_cast<void*>(NULL), non_pointer). TEST(ExpectTest, ASSERT_EQ_0) { int n = 0; // A success. ASSERT_EQ(0, n); // A failure. EXPECT_FATAL_FAILURE(ASSERT_EQ(0, 5.6), " 0\n 5.6"); } // Tests ASSERT_NE. TEST(AssertionTest, ASSERT_NE) { ASSERT_NE(6, 7); EXPECT_FATAL_FAILURE(ASSERT_NE('a', 'a'), "Expected: ('a') != ('a'), " "actual: 'a' (97, 0x61) vs 'a' (97, 0x61)"); } // Tests ASSERT_LE. TEST(AssertionTest, ASSERT_LE) { ASSERT_LE(2, 3); ASSERT_LE(2, 2); EXPECT_FATAL_FAILURE(ASSERT_LE(2, 0), "Expected: (2) <= (0), actual: 2 vs 0"); } // Tests ASSERT_LT. TEST(AssertionTest, ASSERT_LT) { ASSERT_LT(2, 3); EXPECT_FATAL_FAILURE(ASSERT_LT(2, 2), "Expected: (2) < (2), actual: 2 vs 2"); } // Tests ASSERT_GE. TEST(AssertionTest, ASSERT_GE) { ASSERT_GE(2, 1); ASSERT_GE(2, 2); EXPECT_FATAL_FAILURE(ASSERT_GE(2, 3), "Expected: (2) >= (3), actual: 2 vs 3"); } // Tests ASSERT_GT. TEST(AssertionTest, ASSERT_GT) { ASSERT_GT(2, 1); EXPECT_FATAL_FAILURE(ASSERT_GT(2, 2), "Expected: (2) > (2), actual: 2 vs 2"); } #if GTEST_HAS_EXCEPTIONS void ThrowNothing() {} // Tests ASSERT_THROW. TEST(AssertionTest, ASSERT_THROW) { ASSERT_THROW(ThrowAnInteger(), int); # ifndef __BORLANDC__ // ICE's in C++Builder 2007 and 2009. EXPECT_FATAL_FAILURE( ASSERT_THROW(ThrowAnInteger(), bool), "Expected: ThrowAnInteger() throws an exception of type bool.\n" " Actual: it throws a different type."); # endif EXPECT_FATAL_FAILURE( ASSERT_THROW(ThrowNothing(), bool), "Expected: ThrowNothing() throws an exception of type bool.\n" " Actual: it throws nothing."); } // Tests ASSERT_NO_THROW. TEST(AssertionTest, ASSERT_NO_THROW) { ASSERT_NO_THROW(ThrowNothing()); EXPECT_FATAL_FAILURE(ASSERT_NO_THROW(ThrowAnInteger()), "Expected: ThrowAnInteger() doesn't throw an exception." "\n Actual: it throws."); } // Tests ASSERT_ANY_THROW. TEST(AssertionTest, ASSERT_ANY_THROW) { ASSERT_ANY_THROW(ThrowAnInteger()); EXPECT_FATAL_FAILURE( ASSERT_ANY_THROW(ThrowNothing()), "Expected: ThrowNothing() throws an exception.\n" " Actual: it doesn't."); } #endif // GTEST_HAS_EXCEPTIONS // Makes sure we deal with the precedence of <<. This test should // compile. TEST(AssertionTest, AssertPrecedence) { ASSERT_EQ(1 < 2, true); bool false_value = false; ASSERT_EQ(true && false_value, false); } // A subroutine used by the following test. void TestEq1(int x) { ASSERT_EQ(1, x); } // Tests calling a test subroutine that's not part of a fixture. TEST(AssertionTest, NonFixtureSubroutine) { EXPECT_FATAL_FAILURE(TestEq1(2), " x\n Which is: 2"); } // An uncopyable class. class Uncopyable { public: explicit Uncopyable(int a_value) : value_(a_value) {} int value() const { return value_; } bool operator==(const Uncopyable& rhs) const { return value() == rhs.value(); } private: // This constructor deliberately has no implementation, as we don't // want this class to be copyable. Uncopyable(const Uncopyable&); // NOLINT int value_; }; ::std::ostream& operator<<(::std::ostream& os, const Uncopyable& value) { return os << value.value(); } bool IsPositiveUncopyable(const Uncopyable& x) { return x.value() > 0; } // A subroutine used by the following test. void TestAssertNonPositive() { Uncopyable y(-1); ASSERT_PRED1(IsPositiveUncopyable, y); } // A subroutine used by the following test. void TestAssertEqualsUncopyable() { Uncopyable x(5); Uncopyable y(-1); ASSERT_EQ(x, y); } // Tests that uncopyable objects can be used in assertions. TEST(AssertionTest, AssertWorksWithUncopyableObject) { Uncopyable x(5); ASSERT_PRED1(IsPositiveUncopyable, x); ASSERT_EQ(x, x); EXPECT_FATAL_FAILURE(TestAssertNonPositive(), "IsPositiveUncopyable(y) evaluates to false, where\ny evaluates to -1"); EXPECT_FATAL_FAILURE(TestAssertEqualsUncopyable(), "Expected equality of these values:\n" " x\n Which is: 5\n y\n Which is: -1"); } // Tests that uncopyable objects can be used in expects. TEST(AssertionTest, ExpectWorksWithUncopyableObject) { Uncopyable x(5); EXPECT_PRED1(IsPositiveUncopyable, x); Uncopyable y(-1); EXPECT_NONFATAL_FAILURE(EXPECT_PRED1(IsPositiveUncopyable, y), "IsPositiveUncopyable(y) evaluates to false, where\ny evaluates to -1"); EXPECT_EQ(x, x); EXPECT_NONFATAL_FAILURE(EXPECT_EQ(x, y), "Expected equality of these values:\n" " x\n Which is: 5\n y\n Which is: -1"); } enum NamedEnum { kE1 = 0, kE2 = 1 }; TEST(AssertionTest, NamedEnum) { EXPECT_EQ(kE1, kE1); EXPECT_LT(kE1, kE2); EXPECT_NONFATAL_FAILURE(EXPECT_EQ(kE1, kE2), "Which is: 0"); EXPECT_NONFATAL_FAILURE(EXPECT_EQ(kE1, kE2), "Which is: 1"); } // The version of gcc used in XCode 2.2 has a bug and doesn't allow // anonymous enums in assertions. Therefore the following test is not // done on Mac. // Sun Studio and HP aCC also reject this code. #if !GTEST_OS_MAC && !defined(__SUNPRO_CC) && !defined(__HP_aCC) // Tests using assertions with anonymous enums. enum { kCaseA = -1, # if GTEST_OS_LINUX // We want to test the case where the size of the anonymous enum is // larger than sizeof(int), to make sure our implementation of the // assertions doesn't truncate the enums. However, MSVC // (incorrectly) doesn't allow an enum value to exceed the range of // an int, so this has to be conditionally compiled. // // On Linux, kCaseB and kCaseA have the same value when truncated to // int size. We want to test whether this will confuse the // assertions. kCaseB = testing::internal::kMaxBiggestInt, # else kCaseB = INT_MAX, # endif // GTEST_OS_LINUX kCaseC = 42 }; TEST(AssertionTest, AnonymousEnum) { # if GTEST_OS_LINUX EXPECT_EQ(static_cast<int>(kCaseA), static_cast<int>(kCaseB)); # endif // GTEST_OS_LINUX EXPECT_EQ(kCaseA, kCaseA); EXPECT_NE(kCaseA, kCaseB); EXPECT_LT(kCaseA, kCaseB); EXPECT_LE(kCaseA, kCaseB); EXPECT_GT(kCaseB, kCaseA); EXPECT_GE(kCaseA, kCaseA); EXPECT_NONFATAL_FAILURE(EXPECT_GE(kCaseA, kCaseB), "(kCaseA) >= (kCaseB)"); EXPECT_NONFATAL_FAILURE(EXPECT_GE(kCaseA, kCaseC), "-1 vs 42"); ASSERT_EQ(kCaseA, kCaseA); ASSERT_NE(kCaseA, kCaseB); ASSERT_LT(kCaseA, kCaseB); ASSERT_LE(kCaseA, kCaseB); ASSERT_GT(kCaseB, kCaseA); ASSERT_GE(kCaseA, kCaseA); # ifndef __BORLANDC__ // ICE's in C++Builder. EXPECT_FATAL_FAILURE(ASSERT_EQ(kCaseA, kCaseB), " kCaseB\n Which is: "); EXPECT_FATAL_FAILURE(ASSERT_EQ(kCaseA, kCaseC), "\n Which is: 42"); # endif EXPECT_FATAL_FAILURE(ASSERT_EQ(kCaseA, kCaseC), "\n Which is: -1"); } #endif // !GTEST_OS_MAC && !defined(__SUNPRO_CC) #if GTEST_OS_WINDOWS static HRESULT UnexpectedHRESULTFailure() { return E_UNEXPECTED; } static HRESULT OkHRESULTSuccess() { return S_OK; } static HRESULT FalseHRESULTSuccess() { return S_FALSE; } // HRESULT assertion tests test both zero and non-zero // success codes as well as failure message for each. // // Windows CE doesn't support message texts. TEST(HRESULTAssertionTest, EXPECT_HRESULT_SUCCEEDED) { EXPECT_HRESULT_SUCCEEDED(S_OK); EXPECT_HRESULT_SUCCEEDED(S_FALSE); EXPECT_NONFATAL_FAILURE(EXPECT_HRESULT_SUCCEEDED(UnexpectedHRESULTFailure()), "Expected: (UnexpectedHRESULTFailure()) succeeds.\n" " Actual: 0x8000FFFF"); } TEST(HRESULTAssertionTest, ASSERT_HRESULT_SUCCEEDED) { ASSERT_HRESULT_SUCCEEDED(S_OK); ASSERT_HRESULT_SUCCEEDED(S_FALSE); EXPECT_FATAL_FAILURE(ASSERT_HRESULT_SUCCEEDED(UnexpectedHRESULTFailure()), "Expected: (UnexpectedHRESULTFailure()) succeeds.\n" " Actual: 0x8000FFFF"); } TEST(HRESULTAssertionTest, EXPECT_HRESULT_FAILED) { EXPECT_HRESULT_FAILED(E_UNEXPECTED); EXPECT_NONFATAL_FAILURE(EXPECT_HRESULT_FAILED(OkHRESULTSuccess()), "Expected: (OkHRESULTSuccess()) fails.\n" " Actual: 0x0"); EXPECT_NONFATAL_FAILURE(EXPECT_HRESULT_FAILED(FalseHRESULTSuccess()), "Expected: (FalseHRESULTSuccess()) fails.\n" " Actual: 0x1"); } TEST(HRESULTAssertionTest, ASSERT_HRESULT_FAILED) { ASSERT_HRESULT_FAILED(E_UNEXPECTED); # ifndef __BORLANDC__ // ICE's in C++Builder 2007 and 2009. EXPECT_FATAL_FAILURE(ASSERT_HRESULT_FAILED(OkHRESULTSuccess()), "Expected: (OkHRESULTSuccess()) fails.\n" " Actual: 0x0"); # endif EXPECT_FATAL_FAILURE(ASSERT_HRESULT_FAILED(FalseHRESULTSuccess()), "Expected: (FalseHRESULTSuccess()) fails.\n" " Actual: 0x1"); } // Tests that streaming to the HRESULT macros works. TEST(HRESULTAssertionTest, Streaming) { EXPECT_HRESULT_SUCCEEDED(S_OK) << "unexpected failure"; ASSERT_HRESULT_SUCCEEDED(S_OK) << "unexpected failure"; EXPECT_HRESULT_FAILED(E_UNEXPECTED) << "unexpected failure"; ASSERT_HRESULT_FAILED(E_UNEXPECTED) << "unexpected failure"; EXPECT_NONFATAL_FAILURE( EXPECT_HRESULT_SUCCEEDED(E_UNEXPECTED) << "expected failure", "expected failure"); # ifndef __BORLANDC__ // ICE's in C++Builder 2007 and 2009. EXPECT_FATAL_FAILURE( ASSERT_HRESULT_SUCCEEDED(E_UNEXPECTED) << "expected failure", "expected failure"); # endif EXPECT_NONFATAL_FAILURE( EXPECT_HRESULT_FAILED(S_OK) << "expected failure", "expected failure"); EXPECT_FATAL_FAILURE( ASSERT_HRESULT_FAILED(S_OK) << "expected failure", "expected failure"); } #endif // GTEST_OS_WINDOWS #ifdef __BORLANDC__ // Silences warnings: "Condition is always true", "Unreachable code" # pragma option push -w-ccc -w-rch #endif // Tests that the assertion macros behave like single statements. TEST(AssertionSyntaxTest, BasicAssertionsBehavesLikeSingleStatement) { if (AlwaysFalse()) ASSERT_TRUE(false) << "This should never be executed; " "It's a compilation test only."; if (AlwaysTrue()) EXPECT_FALSE(false); else ; // NOLINT if (AlwaysFalse()) ASSERT_LT(1, 3); if (AlwaysFalse()) ; // NOLINT else EXPECT_GT(3, 2) << ""; } #if GTEST_HAS_EXCEPTIONS // Tests that the compiler will not complain about unreachable code in the // EXPECT_THROW/EXPECT_ANY_THROW/EXPECT_NO_THROW macros. TEST(ExpectThrowTest, DoesNotGenerateUnreachableCodeWarning) { int n = 0; EXPECT_THROW(throw 1, int); EXPECT_NONFATAL_FAILURE(EXPECT_THROW(n++, int), ""); EXPECT_NONFATAL_FAILURE(EXPECT_THROW(throw 1, const char*), ""); EXPECT_NO_THROW(n++); EXPECT_NONFATAL_FAILURE(EXPECT_NO_THROW(throw 1), ""); EXPECT_ANY_THROW(throw 1); EXPECT_NONFATAL_FAILURE(EXPECT_ANY_THROW(n++), ""); } TEST(AssertionSyntaxTest, ExceptionAssertionsBehavesLikeSingleStatement) { if (AlwaysFalse()) EXPECT_THROW(ThrowNothing(), bool); if (AlwaysTrue()) EXPECT_THROW(ThrowAnInteger(), int); else ; // NOLINT if (AlwaysFalse()) EXPECT_NO_THROW(ThrowAnInteger()); if (AlwaysTrue()) EXPECT_NO_THROW(ThrowNothing()); else ; // NOLINT if (AlwaysFalse()) EXPECT_ANY_THROW(ThrowNothing()); if (AlwaysTrue()) EXPECT_ANY_THROW(ThrowAnInteger()); else ; // NOLINT } #endif // GTEST_HAS_EXCEPTIONS TEST(AssertionSyntaxTest, NoFatalFailureAssertionsBehavesLikeSingleStatement) { if (AlwaysFalse()) EXPECT_NO_FATAL_FAILURE(FAIL()) << "This should never be executed. " << "It's a compilation test only."; else ; // NOLINT if (AlwaysFalse()) ASSERT_NO_FATAL_FAILURE(FAIL()) << ""; else ; // NOLINT if (AlwaysTrue()) EXPECT_NO_FATAL_FAILURE(SUCCEED()); else ; // NOLINT if (AlwaysFalse()) ; // NOLINT else ASSERT_NO_FATAL_FAILURE(SUCCEED()); } // Tests that the assertion macros work well with switch statements. TEST(AssertionSyntaxTest, WorksWithSwitch) { switch (0) { case 1: break; default: ASSERT_TRUE(true); } switch (0) case 0: EXPECT_FALSE(false) << "EXPECT_FALSE failed in switch case"; // Binary assertions are implemented using a different code path // than the Boolean assertions. Hence we test them separately. switch (0) { case 1: default: ASSERT_EQ(1, 1) << "ASSERT_EQ failed in default switch handler"; } switch (0) case 0: EXPECT_NE(1, 2); } #if GTEST_HAS_EXCEPTIONS void ThrowAString() { throw "std::string"; } // Test that the exception assertion macros compile and work with const // type qualifier. TEST(AssertionSyntaxTest, WorksWithConst) { ASSERT_THROW(ThrowAString(), const char*); EXPECT_THROW(ThrowAString(), const char*); } #endif // GTEST_HAS_EXCEPTIONS } // namespace namespace testing { // Tests that Google Test tracks SUCCEED*. TEST(SuccessfulAssertionTest, SUCCEED) { SUCCEED(); SUCCEED() << "OK"; EXPECT_EQ(2, GetUnitTestImpl()->current_test_result()->total_part_count()); } // Tests that Google Test doesn't track successful EXPECT_*. TEST(SuccessfulAssertionTest, EXPECT) { EXPECT_TRUE(true); EXPECT_EQ(0, GetUnitTestImpl()->current_test_result()->total_part_count()); } // Tests that Google Test doesn't track successful EXPECT_STR*. TEST(SuccessfulAssertionTest, EXPECT_STR) { EXPECT_STREQ("", ""); EXPECT_EQ(0, GetUnitTestImpl()->current_test_result()->total_part_count()); } // Tests that Google Test doesn't track successful ASSERT_*. TEST(SuccessfulAssertionTest, ASSERT) { ASSERT_TRUE(true); EXPECT_EQ(0, GetUnitTestImpl()->current_test_result()->total_part_count()); } // Tests that Google Test doesn't track successful ASSERT_STR*. TEST(SuccessfulAssertionTest, ASSERT_STR) { ASSERT_STREQ("", ""); EXPECT_EQ(0, GetUnitTestImpl()->current_test_result()->total_part_count()); } } // namespace testing namespace { // Tests the message streaming variation of assertions. TEST(AssertionWithMessageTest, EXPECT) { EXPECT_EQ(1, 1) << "This should succeed."; EXPECT_NONFATAL_FAILURE(EXPECT_NE(1, 1) << "Expected failure #1.", "Expected failure #1"); EXPECT_LE(1, 2) << "This should succeed."; EXPECT_NONFATAL_FAILURE(EXPECT_LT(1, 0) << "Expected failure #2.", "Expected failure #2."); EXPECT_GE(1, 0) << "This should succeed."; EXPECT_NONFATAL_FAILURE(EXPECT_GT(1, 2) << "Expected failure #3.", "Expected failure #3."); EXPECT_STREQ("1", "1") << "This should succeed."; EXPECT_NONFATAL_FAILURE(EXPECT_STRNE("1", "1") << "Expected failure #4.", "Expected failure #4."); EXPECT_STRCASEEQ("a", "A") << "This should succeed."; EXPECT_NONFATAL_FAILURE(EXPECT_STRCASENE("a", "A") << "Expected failure #5.", "Expected failure #5."); EXPECT_FLOAT_EQ(1, 1) << "This should succeed."; EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(1, 1.2) << "Expected failure #6.", "Expected failure #6."); EXPECT_NEAR(1, 1.1, 0.2) << "This should succeed."; } TEST(AssertionWithMessageTest, ASSERT) { ASSERT_EQ(1, 1) << "This should succeed."; ASSERT_NE(1, 2) << "This should succeed."; ASSERT_LE(1, 2) << "This should succeed."; ASSERT_LT(1, 2) << "This should succeed."; ASSERT_GE(1, 0) << "This should succeed."; EXPECT_FATAL_FAILURE(ASSERT_GT(1, 2) << "Expected failure.", "Expected failure."); } TEST(AssertionWithMessageTest, ASSERT_STR) { ASSERT_STREQ("1", "1") << "This should succeed."; ASSERT_STRNE("1", "2") << "This should succeed."; ASSERT_STRCASEEQ("a", "A") << "This should succeed."; EXPECT_FATAL_FAILURE(ASSERT_STRCASENE("a", "A") << "Expected failure.", "Expected failure."); } TEST(AssertionWithMessageTest, ASSERT_FLOATING) { ASSERT_FLOAT_EQ(1, 1) << "This should succeed."; ASSERT_DOUBLE_EQ(1, 1) << "This should succeed."; EXPECT_FATAL_FAILURE(ASSERT_NEAR(1,1.2, 0.1) << "Expect failure.", // NOLINT "Expect failure."); // To work around a bug in gcc 2.95.0, there is intentionally no // space after the first comma in the previous statement. } // Tests using ASSERT_FALSE with a streamed message. TEST(AssertionWithMessageTest, ASSERT_FALSE) { ASSERT_FALSE(false) << "This shouldn't fail."; EXPECT_FATAL_FAILURE({ // NOLINT ASSERT_FALSE(true) << "Expected failure: " << 2 << " > " << 1 << " evaluates to " << true; }, "Expected failure"); } // Tests using FAIL with a streamed message. TEST(AssertionWithMessageTest, FAIL) { EXPECT_FATAL_FAILURE(FAIL() << 0, "0"); } // Tests using SUCCEED with a streamed message. TEST(AssertionWithMessageTest, SUCCEED) { SUCCEED() << "Success == " << 1; } // Tests using ASSERT_TRUE with a streamed message. TEST(AssertionWithMessageTest, ASSERT_TRUE) { ASSERT_TRUE(true) << "This should succeed."; ASSERT_TRUE(true) << true; EXPECT_FATAL_FAILURE({ // NOLINT ASSERT_TRUE(false) << static_cast<const char *>(NULL) << static_cast<char *>(NULL); }, "(null)(null)"); } #if GTEST_OS_WINDOWS // Tests using wide strings in assertion messages. TEST(AssertionWithMessageTest, WideStringMessage) { EXPECT_NONFATAL_FAILURE({ // NOLINT EXPECT_TRUE(false) << L"This failure is expected.\x8119"; }, "This failure is expected."); EXPECT_FATAL_FAILURE({ // NOLINT ASSERT_EQ(1, 2) << "This failure is " << L"expected too.\x8120"; }, "This failure is expected too."); } #endif // GTEST_OS_WINDOWS // Tests EXPECT_TRUE. TEST(ExpectTest, EXPECT_TRUE) { EXPECT_TRUE(true) << "Intentional success"; EXPECT_NONFATAL_FAILURE(EXPECT_TRUE(false) << "Intentional failure #1.", "Intentional failure #1."); EXPECT_NONFATAL_FAILURE(EXPECT_TRUE(false) << "Intentional failure #2.", "Intentional failure #2."); EXPECT_TRUE(2 > 1); // NOLINT EXPECT_NONFATAL_FAILURE(EXPECT_TRUE(2 < 1), "Value of: 2 < 1\n" " Actual: false\n" "Expected: true"); EXPECT_NONFATAL_FAILURE(EXPECT_TRUE(2 > 3), "2 > 3"); } // Tests EXPECT_TRUE(predicate) for predicates returning AssertionResult. TEST(ExpectTest, ExpectTrueWithAssertionResult) { EXPECT_TRUE(ResultIsEven(2)); EXPECT_NONFATAL_FAILURE(EXPECT_TRUE(ResultIsEven(3)), "Value of: ResultIsEven(3)\n" " Actual: false (3 is odd)\n" "Expected: true"); EXPECT_TRUE(ResultIsEvenNoExplanation(2)); EXPECT_NONFATAL_FAILURE(EXPECT_TRUE(ResultIsEvenNoExplanation(3)), "Value of: ResultIsEvenNoExplanation(3)\n" " Actual: false (3 is odd)\n" "Expected: true"); } // Tests EXPECT_FALSE with a streamed message. TEST(ExpectTest, EXPECT_FALSE) { EXPECT_FALSE(2 < 1); // NOLINT EXPECT_FALSE(false) << "Intentional success"; EXPECT_NONFATAL_FAILURE(EXPECT_FALSE(true) << "Intentional failure #1.", "Intentional failure #1."); EXPECT_NONFATAL_FAILURE(EXPECT_FALSE(true) << "Intentional failure #2.", "Intentional failure #2."); EXPECT_NONFATAL_FAILURE(EXPECT_FALSE(2 > 1), "Value of: 2 > 1\n" " Actual: true\n" "Expected: false"); EXPECT_NONFATAL_FAILURE(EXPECT_FALSE(2 < 3), "2 < 3"); } // Tests EXPECT_FALSE(predicate) for predicates returning AssertionResult. TEST(ExpectTest, ExpectFalseWithAssertionResult) { EXPECT_FALSE(ResultIsEven(3)); EXPECT_NONFATAL_FAILURE(EXPECT_FALSE(ResultIsEven(2)), "Value of: ResultIsEven(2)\n" " Actual: true (2 is even)\n" "Expected: false"); EXPECT_FALSE(ResultIsEvenNoExplanation(3)); EXPECT_NONFATAL_FAILURE(EXPECT_FALSE(ResultIsEvenNoExplanation(2)), "Value of: ResultIsEvenNoExplanation(2)\n" " Actual: true\n" "Expected: false"); } #ifdef __BORLANDC__ // Restores warnings after previous "#pragma option push" suppressed them # pragma option pop #endif // Tests EXPECT_EQ. TEST(ExpectTest, EXPECT_EQ) { EXPECT_EQ(5, 2 + 3); EXPECT_NONFATAL_FAILURE(EXPECT_EQ(5, 2*3), "Expected equality of these values:\n" " 5\n" " 2*3\n" " Which is: 6"); EXPECT_NONFATAL_FAILURE(EXPECT_EQ(5, 2 - 3), "2 - 3"); } // Tests using EXPECT_EQ on double values. The purpose is to make // sure that the specialization we did for integer and anonymous enums // isn't used for double arguments. TEST(ExpectTest, EXPECT_EQ_Double) { // A success. EXPECT_EQ(5.6, 5.6); // A failure. EXPECT_NONFATAL_FAILURE(EXPECT_EQ(5.1, 5.2), "5.1"); } #if GTEST_CAN_COMPARE_NULL // Tests EXPECT_EQ(NULL, pointer). TEST(ExpectTest, EXPECT_EQ_NULL) { // A success. const char* p = NULL; // Some older GCC versions may issue a spurious warning in this or the next // assertion statement. This warning should not be suppressed with // static_cast since the test verifies the ability to use bare NULL as the // expected parameter to the macro. EXPECT_EQ(NULL, p); // A failure. int n = 0; EXPECT_NONFATAL_FAILURE(EXPECT_EQ(NULL, &n), " &n\n Which is:"); } #endif // GTEST_CAN_COMPARE_NULL // Tests EXPECT_EQ(0, non_pointer). Since the literal 0 can be // treated as a null pointer by the compiler, we need to make sure // that EXPECT_EQ(0, non_pointer) isn't interpreted by Google Test as // EXPECT_EQ(static_cast<void*>(NULL), non_pointer). TEST(ExpectTest, EXPECT_EQ_0) { int n = 0; // A success. EXPECT_EQ(0, n); // A failure. EXPECT_NONFATAL_FAILURE(EXPECT_EQ(0, 5.6), " 0\n 5.6"); } // Tests EXPECT_NE. TEST(ExpectTest, EXPECT_NE) { EXPECT_NE(6, 7); EXPECT_NONFATAL_FAILURE(EXPECT_NE('a', 'a'), "Expected: ('a') != ('a'), " "actual: 'a' (97, 0x61) vs 'a' (97, 0x61)"); EXPECT_NONFATAL_FAILURE(EXPECT_NE(2, 2), "2"); char* const p0 = NULL; EXPECT_NONFATAL_FAILURE(EXPECT_NE(p0, p0), "p0"); // Only way to get the Nokia compiler to compile the cast // is to have a separate void* variable first. Putting // the two casts on the same line doesn't work, neither does // a direct C-style to char*. void* pv1 = (void*)0x1234; // NOLINT char* const p1 = reinterpret_cast<char*>(pv1); EXPECT_NONFATAL_FAILURE(EXPECT_NE(p1, p1), "p1"); } // Tests EXPECT_LE. TEST(ExpectTest, EXPECT_LE) { EXPECT_LE(2, 3); EXPECT_LE(2, 2); EXPECT_NONFATAL_FAILURE(EXPECT_LE(2, 0), "Expected: (2) <= (0), actual: 2 vs 0"); EXPECT_NONFATAL_FAILURE(EXPECT_LE(1.1, 0.9), "(1.1) <= (0.9)"); } // Tests EXPECT_LT. TEST(ExpectTest, EXPECT_LT) { EXPECT_LT(2, 3); EXPECT_NONFATAL_FAILURE(EXPECT_LT(2, 2), "Expected: (2) < (2), actual: 2 vs 2"); EXPECT_NONFATAL_FAILURE(EXPECT_LT(2, 1), "(2) < (1)"); } // Tests EXPECT_GE. TEST(ExpectTest, EXPECT_GE) { EXPECT_GE(2, 1); EXPECT_GE(2, 2); EXPECT_NONFATAL_FAILURE(EXPECT_GE(2, 3), "Expected: (2) >= (3), actual: 2 vs 3"); EXPECT_NONFATAL_FAILURE(EXPECT_GE(0.9, 1.1), "(0.9) >= (1.1)"); } // Tests EXPECT_GT. TEST(ExpectTest, EXPECT_GT) { EXPECT_GT(2, 1); EXPECT_NONFATAL_FAILURE(EXPECT_GT(2, 2), "Expected: (2) > (2), actual: 2 vs 2"); EXPECT_NONFATAL_FAILURE(EXPECT_GT(2, 3), "(2) > (3)"); } #if GTEST_HAS_EXCEPTIONS // Tests EXPECT_THROW. TEST(ExpectTest, EXPECT_THROW) { EXPECT_THROW(ThrowAnInteger(), int); EXPECT_NONFATAL_FAILURE(EXPECT_THROW(ThrowAnInteger(), bool), "Expected: ThrowAnInteger() throws an exception of " "type bool.\n Actual: it throws a different type."); EXPECT_NONFATAL_FAILURE( EXPECT_THROW(ThrowNothing(), bool), "Expected: ThrowNothing() throws an exception of type bool.\n" " Actual: it throws nothing."); } // Tests EXPECT_NO_THROW. TEST(ExpectTest, EXPECT_NO_THROW) { EXPECT_NO_THROW(ThrowNothing()); EXPECT_NONFATAL_FAILURE(EXPECT_NO_THROW(ThrowAnInteger()), "Expected: ThrowAnInteger() doesn't throw an " "exception.\n Actual: it throws."); } // Tests EXPECT_ANY_THROW. TEST(ExpectTest, EXPECT_ANY_THROW) { EXPECT_ANY_THROW(ThrowAnInteger()); EXPECT_NONFATAL_FAILURE( EXPECT_ANY_THROW(ThrowNothing()), "Expected: ThrowNothing() throws an exception.\n" " Actual: it doesn't."); } #endif // GTEST_HAS_EXCEPTIONS // Make sure we deal with the precedence of <<. TEST(ExpectTest, ExpectPrecedence) { EXPECT_EQ(1 < 2, true); EXPECT_NONFATAL_FAILURE(EXPECT_EQ(true, true && false), " true && false\n Which is: false"); } // Tests the StreamableToString() function. // Tests using StreamableToString() on a scalar. TEST(StreamableToStringTest, Scalar) { EXPECT_STREQ("5", StreamableToString(5).c_str()); } // Tests using StreamableToString() on a non-char pointer. TEST(StreamableToStringTest, Pointer) { int n = 0; int* p = &n; EXPECT_STRNE("(null)", StreamableToString(p).c_str()); } // Tests using StreamableToString() on a NULL non-char pointer. TEST(StreamableToStringTest, NullPointer) { int* p = NULL; EXPECT_STREQ("(null)", StreamableToString(p).c_str()); } // Tests using StreamableToString() on a C string. TEST(StreamableToStringTest, CString) { EXPECT_STREQ("Foo", StreamableToString("Foo").c_str()); } // Tests using StreamableToString() on a NULL C string. TEST(StreamableToStringTest, NullCString) { char* p = NULL; EXPECT_STREQ("(null)", StreamableToString(p).c_str()); } // Tests using streamable values as assertion messages. // Tests using std::string as an assertion message. TEST(StreamableTest, string) { static const std::string str( "This failure message is a std::string, and is expected."); EXPECT_FATAL_FAILURE(FAIL() << str, str.c_str()); } // Tests that we can output strings containing embedded NULs. // Limited to Linux because we can only do this with std::string's. TEST(StreamableTest, stringWithEmbeddedNUL) { static const char char_array_with_nul[] = "Here's a NUL\0 and some more string"; static const std::string string_with_nul(char_array_with_nul, sizeof(char_array_with_nul) - 1); // drops the trailing NUL EXPECT_FATAL_FAILURE(FAIL() << string_with_nul, "Here's a NUL\\0 and some more string"); } // Tests that we can output a NUL char. TEST(StreamableTest, NULChar) { EXPECT_FATAL_FAILURE({ // NOLINT FAIL() << "A NUL" << '\0' << " and some more string"; }, "A NUL\\0 and some more string"); } // Tests using int as an assertion message. TEST(StreamableTest, int) { EXPECT_FATAL_FAILURE(FAIL() << 900913, "900913"); } // Tests using NULL char pointer as an assertion message. // // In MSVC, streaming a NULL char * causes access violation. Google Test // implemented a workaround (substituting "(null)" for NULL). This // tests whether the workaround works. TEST(StreamableTest, NullCharPtr) { EXPECT_FATAL_FAILURE(FAIL() << static_cast<const char*>(NULL), "(null)"); } // Tests that basic IO manipulators (endl, ends, and flush) can be // streamed to testing::Message. TEST(StreamableTest, BasicIoManip) { EXPECT_FATAL_FAILURE({ // NOLINT FAIL() << "Line 1." << std::endl << "A NUL char " << std::ends << std::flush << " in line 2."; }, "Line 1.\nA NUL char \\0 in line 2."); } // Tests the macros that haven't been covered so far. void AddFailureHelper(bool* aborted) { *aborted = true; ADD_FAILURE() << "Intentional failure."; *aborted = false; } // Tests ADD_FAILURE. TEST(MacroTest, ADD_FAILURE) { bool aborted = true; EXPECT_NONFATAL_FAILURE(AddFailureHelper(&aborted), "Intentional failure."); EXPECT_FALSE(aborted); } // Tests ADD_FAILURE_AT. TEST(MacroTest, ADD_FAILURE_AT) { // Verifies that ADD_FAILURE_AT does generate a nonfatal failure and // the failure message contains the user-streamed part. EXPECT_NONFATAL_FAILURE(ADD_FAILURE_AT("foo.cc", 42) << "Wrong!", "Wrong!"); // Verifies that the user-streamed part is optional. EXPECT_NONFATAL_FAILURE(ADD_FAILURE_AT("foo.cc", 42), "Failed"); // Unfortunately, we cannot verify that the failure message contains // the right file path and line number the same way, as // EXPECT_NONFATAL_FAILURE() doesn't get to see the file path and // line number. Instead, we do that in googletest-output-test_.cc. } // Tests FAIL. TEST(MacroTest, FAIL) { EXPECT_FATAL_FAILURE(FAIL(), "Failed"); EXPECT_FATAL_FAILURE(FAIL() << "Intentional failure.", "Intentional failure."); } // Tests SUCCEED TEST(MacroTest, SUCCEED) { SUCCEED(); SUCCEED() << "Explicit success."; } // Tests for EXPECT_EQ() and ASSERT_EQ(). // // These tests fail *intentionally*, s.t. the failure messages can be // generated and tested. // // We have different tests for different argument types. // Tests using bool values in {EXPECT|ASSERT}_EQ. TEST(EqAssertionTest, Bool) { EXPECT_EQ(true, true); EXPECT_FATAL_FAILURE({ bool false_value = false; ASSERT_EQ(false_value, true); }, " false_value\n Which is: false\n true"); } // Tests using int values in {EXPECT|ASSERT}_EQ. TEST(EqAssertionTest, Int) { ASSERT_EQ(32, 32); EXPECT_NONFATAL_FAILURE(EXPECT_EQ(32, 33), " 32\n 33"); } // Tests using time_t values in {EXPECT|ASSERT}_EQ. TEST(EqAssertionTest, Time_T) { EXPECT_EQ(static_cast<time_t>(0), static_cast<time_t>(0)); EXPECT_FATAL_FAILURE(ASSERT_EQ(static_cast<time_t>(0), static_cast<time_t>(1234)), "1234"); } // Tests using char values in {EXPECT|ASSERT}_EQ. TEST(EqAssertionTest, Char) { ASSERT_EQ('z', 'z'); const char ch = 'b'; EXPECT_NONFATAL_FAILURE(EXPECT_EQ('\0', ch), " ch\n Which is: 'b'"); EXPECT_NONFATAL_FAILURE(EXPECT_EQ('a', ch), " ch\n Which is: 'b'"); } // Tests using wchar_t values in {EXPECT|ASSERT}_EQ. TEST(EqAssertionTest, WideChar) { EXPECT_EQ(L'b', L'b'); EXPECT_NONFATAL_FAILURE(EXPECT_EQ(L'\0', L'x'), "Expected equality of these values:\n" " L'\0'\n" " Which is: L'\0' (0, 0x0)\n" " L'x'\n" " Which is: L'x' (120, 0x78)"); static wchar_t wchar; wchar = L'b'; EXPECT_NONFATAL_FAILURE(EXPECT_EQ(L'a', wchar), "wchar"); wchar = 0x8119; EXPECT_FATAL_FAILURE(ASSERT_EQ(static_cast<wchar_t>(0x8120), wchar), " wchar\n Which is: L'"); } // Tests using ::std::string values in {EXPECT|ASSERT}_EQ. TEST(EqAssertionTest, StdString) { // Compares a const char* to an std::string that has identical // content. ASSERT_EQ("Test", ::std::string("Test")); // Compares two identical std::strings. static const ::std::string str1("A * in the middle"); static const ::std::string str2(str1); EXPECT_EQ(str1, str2); // Compares a const char* to an std::string that has different // content EXPECT_NONFATAL_FAILURE(EXPECT_EQ("Test", ::std::string("test")), "\"test\""); // Compares an std::string to a char* that has different content. char* const p1 = const_cast<char*>("foo"); EXPECT_NONFATAL_FAILURE(EXPECT_EQ(::std::string("bar"), p1), "p1"); // Compares two std::strings that have different contents, one of // which having a NUL character in the middle. This should fail. static ::std::string str3(str1); str3.at(2) = '\0'; EXPECT_FATAL_FAILURE(ASSERT_EQ(str1, str3), " str3\n Which is: \"A \\0 in the middle\""); } #if GTEST_HAS_STD_WSTRING // Tests using ::std::wstring values in {EXPECT|ASSERT}_EQ. TEST(EqAssertionTest, StdWideString) { // Compares two identical std::wstrings. const ::std::wstring wstr1(L"A * in the middle"); const ::std::wstring wstr2(wstr1); ASSERT_EQ(wstr1, wstr2); // Compares an std::wstring to a const wchar_t* that has identical // content. const wchar_t kTestX8119[] = { 'T', 'e', 's', 't', 0x8119, '\0' }; EXPECT_EQ(::std::wstring(kTestX8119), kTestX8119); // Compares an std::wstring to a const wchar_t* that has different // content. const wchar_t kTestX8120[] = { 'T', 'e', 's', 't', 0x8120, '\0' }; EXPECT_NONFATAL_FAILURE({ // NOLINT EXPECT_EQ(::std::wstring(kTestX8119), kTestX8120); }, "kTestX8120"); // Compares two std::wstrings that have different contents, one of // which having a NUL character in the middle. ::std::wstring wstr3(wstr1); wstr3.at(2) = L'\0'; EXPECT_NONFATAL_FAILURE(EXPECT_EQ(wstr1, wstr3), "wstr3"); // Compares a wchar_t* to an std::wstring that has different // content. EXPECT_FATAL_FAILURE({ // NOLINT ASSERT_EQ(const_cast<wchar_t*>(L"foo"), ::std::wstring(L"bar")); }, ""); } #endif // GTEST_HAS_STD_WSTRING #if GTEST_HAS_GLOBAL_STRING // Tests using ::string values in {EXPECT|ASSERT}_EQ. TEST(EqAssertionTest, GlobalString) { // Compares a const char* to a ::string that has identical content. EXPECT_EQ("Test", ::string("Test")); // Compares two identical ::strings. const ::string str1("A * in the middle"); const ::string str2(str1); ASSERT_EQ(str1, str2); // Compares a ::string to a const char* that has different content. EXPECT_NONFATAL_FAILURE(EXPECT_EQ(::string("Test"), "test"), "test"); // Compares two ::strings that have different contents, one of which // having a NUL character in the middle. ::string str3(str1); str3.at(2) = '\0'; EXPECT_NONFATAL_FAILURE(EXPECT_EQ(str1, str3), "str3"); // Compares a ::string to a char* that has different content. EXPECT_FATAL_FAILURE({ // NOLINT ASSERT_EQ(::string("bar"), const_cast<char*>("foo")); }, ""); } #endif // GTEST_HAS_GLOBAL_STRING #if GTEST_HAS_GLOBAL_WSTRING // Tests using ::wstring values in {EXPECT|ASSERT}_EQ. TEST(EqAssertionTest, GlobalWideString) { // Compares two identical ::wstrings. static const ::wstring wstr1(L"A * in the middle"); static const ::wstring wstr2(wstr1); EXPECT_EQ(wstr1, wstr2); // Compares a const wchar_t* to a ::wstring that has identical content. const wchar_t kTestX8119[] = { 'T', 'e', 's', 't', 0x8119, '\0' }; ASSERT_EQ(kTestX8119, ::wstring(kTestX8119)); // Compares a const wchar_t* to a ::wstring that has different // content. const wchar_t kTestX8120[] = { 'T', 'e', 's', 't', 0x8120, '\0' }; EXPECT_NONFATAL_FAILURE({ // NOLINT EXPECT_EQ(kTestX8120, ::wstring(kTestX8119)); }, "Test\\x8119"); // Compares a wchar_t* to a ::wstring that has different content. wchar_t* const p1 = const_cast<wchar_t*>(L"foo"); EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p1, ::wstring(L"bar")), "bar"); // Compares two ::wstrings that have different contents, one of which // having a NUL character in the middle. static ::wstring wstr3; wstr3 = wstr1; wstr3.at(2) = L'\0'; EXPECT_FATAL_FAILURE(ASSERT_EQ(wstr1, wstr3), "wstr3"); } #endif // GTEST_HAS_GLOBAL_WSTRING // Tests using char pointers in {EXPECT|ASSERT}_EQ. TEST(EqAssertionTest, CharPointer) { char* const p0 = NULL; // Only way to get the Nokia compiler to compile the cast // is to have a separate void* variable first. Putting // the two casts on the same line doesn't work, neither does // a direct C-style to char*. void* pv1 = (void*)0x1234; // NOLINT void* pv2 = (void*)0xABC0; // NOLINT char* const p1 = reinterpret_cast<char*>(pv1); char* const p2 = reinterpret_cast<char*>(pv2); ASSERT_EQ(p1, p1); EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p0, p2), " p2\n Which is:"); EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p1, p2), " p2\n Which is:"); EXPECT_FATAL_FAILURE(ASSERT_EQ(reinterpret_cast<char*>(0x1234), reinterpret_cast<char*>(0xABC0)), "ABC0"); } // Tests using wchar_t pointers in {EXPECT|ASSERT}_EQ. TEST(EqAssertionTest, WideCharPointer) { wchar_t* const p0 = NULL; // Only way to get the Nokia compiler to compile the cast // is to have a separate void* variable first. Putting // the two casts on the same line doesn't work, neither does // a direct C-style to char*. void* pv1 = (void*)0x1234; // NOLINT void* pv2 = (void*)0xABC0; // NOLINT wchar_t* const p1 = reinterpret_cast<wchar_t*>(pv1); wchar_t* const p2 = reinterpret_cast<wchar_t*>(pv2); EXPECT_EQ(p0, p0); EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p0, p2), " p2\n Which is:"); EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p1, p2), " p2\n Which is:"); void* pv3 = (void*)0x1234; // NOLINT void* pv4 = (void*)0xABC0; // NOLINT const wchar_t* p3 = reinterpret_cast<const wchar_t*>(pv3); const wchar_t* p4 = reinterpret_cast<const wchar_t*>(pv4); EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p3, p4), "p4"); } // Tests using other types of pointers in {EXPECT|ASSERT}_EQ. TEST(EqAssertionTest, OtherPointer) { ASSERT_EQ(static_cast<const int*>(NULL), static_cast<const int*>(NULL)); EXPECT_FATAL_FAILURE(ASSERT_EQ(static_cast<const int*>(NULL), reinterpret_cast<const int*>(0x1234)), "0x1234"); } // A class that supports binary comparison operators but not streaming. class UnprintableChar { public: explicit UnprintableChar(char ch) : char_(ch) {} bool operator==(const UnprintableChar& rhs) const { return char_ == rhs.char_; } bool operator!=(const UnprintableChar& rhs) const { return char_ != rhs.char_; } bool operator<(const UnprintableChar& rhs) const { return char_ < rhs.char_; } bool operator<=(const UnprintableChar& rhs) const { return char_ <= rhs.char_; } bool operator>(const UnprintableChar& rhs) const { return char_ > rhs.char_; } bool operator>=(const UnprintableChar& rhs) const { return char_ >= rhs.char_; } private: char char_; }; // Tests that ASSERT_EQ() and friends don't require the arguments to // be printable. TEST(ComparisonAssertionTest, AcceptsUnprintableArgs) { const UnprintableChar x('x'), y('y'); ASSERT_EQ(x, x); EXPECT_NE(x, y); ASSERT_LT(x, y); EXPECT_LE(x, y); ASSERT_GT(y, x); EXPECT_GE(x, x); EXPECT_NONFATAL_FAILURE(EXPECT_EQ(x, y), "1-byte object <78>"); EXPECT_NONFATAL_FAILURE(EXPECT_EQ(x, y), "1-byte object <79>"); EXPECT_NONFATAL_FAILURE(EXPECT_LT(y, y), "1-byte object <79>"); EXPECT_NONFATAL_FAILURE(EXPECT_GT(x, y), "1-byte object <78>"); EXPECT_NONFATAL_FAILURE(EXPECT_GT(x, y), "1-byte object <79>"); // Code tested by EXPECT_FATAL_FAILURE cannot reference local // variables, so we have to write UnprintableChar('x') instead of x. #ifndef __BORLANDC__ // ICE's in C++Builder. EXPECT_FATAL_FAILURE(ASSERT_NE(UnprintableChar('x'), UnprintableChar('x')), "1-byte object <78>"); EXPECT_FATAL_FAILURE(ASSERT_LE(UnprintableChar('y'), UnprintableChar('x')), "1-byte object <78>"); #endif EXPECT_FATAL_FAILURE(ASSERT_LE(UnprintableChar('y'), UnprintableChar('x')), "1-byte object <79>"); EXPECT_FATAL_FAILURE(ASSERT_GE(UnprintableChar('x'), UnprintableChar('y')), "1-byte object <78>"); EXPECT_FATAL_FAILURE(ASSERT_GE(UnprintableChar('x'), UnprintableChar('y')), "1-byte object <79>"); } // Tests the FRIEND_TEST macro. // This class has a private member we want to test. We will test it // both in a TEST and in a TEST_F. class Foo { public: Foo() {} private: int Bar() const { return 1; } // Declares the friend tests that can access the private member // Bar(). FRIEND_TEST(FRIEND_TEST_Test, TEST); FRIEND_TEST(FRIEND_TEST_Test2, TEST_F); }; // Tests that the FRIEND_TEST declaration allows a TEST to access a // class's private members. This should compile. TEST(FRIEND_TEST_Test, TEST) { ASSERT_EQ(1, Foo().Bar()); } // The fixture needed to test using FRIEND_TEST with TEST_F. class FRIEND_TEST_Test2 : public Test { protected: Foo foo; }; // Tests that the FRIEND_TEST declaration allows a TEST_F to access a // class's private members. This should compile. TEST_F(FRIEND_TEST_Test2, TEST_F) { ASSERT_EQ(1, foo.Bar()); } // Tests the life cycle of Test objects. // The test fixture for testing the life cycle of Test objects. // // This class counts the number of live test objects that uses this // fixture. class TestLifeCycleTest : public Test { protected: // Constructor. Increments the number of test objects that uses // this fixture. TestLifeCycleTest() { count_++; } // Destructor. Decrements the number of test objects that uses this // fixture. ~TestLifeCycleTest() { count_--; } // Returns the number of live test objects that uses this fixture. int count() const { return count_; } private: static int count_; }; int TestLifeCycleTest::count_ = 0; // Tests the life cycle of test objects. TEST_F(TestLifeCycleTest, Test1) { // There should be only one test object in this test case that's // currently alive. ASSERT_EQ(1, count()); } // Tests the life cycle of test objects. TEST_F(TestLifeCycleTest, Test2) { // After Test1 is done and Test2 is started, there should still be // only one live test object, as the object for Test1 should've been // deleted. ASSERT_EQ(1, count()); } } // namespace // Tests that the copy constructor works when it is NOT optimized away by // the compiler. TEST(AssertionResultTest, CopyConstructorWorksWhenNotOptimied) { // Checks that the copy constructor doesn't try to dereference NULL pointers // in the source object. AssertionResult r1 = AssertionSuccess(); AssertionResult r2 = r1; // The following line is added to prevent the compiler from optimizing // away the constructor call. r1 << "abc"; AssertionResult r3 = r1; EXPECT_EQ(static_cast<bool>(r3), static_cast<bool>(r1)); EXPECT_STREQ("abc", r1.message()); } // Tests that AssertionSuccess and AssertionFailure construct // AssertionResult objects as expected. TEST(AssertionResultTest, ConstructionWorks) { AssertionResult r1 = AssertionSuccess(); EXPECT_TRUE(r1); EXPECT_STREQ("", r1.message()); AssertionResult r2 = AssertionSuccess() << "abc"; EXPECT_TRUE(r2); EXPECT_STREQ("abc", r2.message()); AssertionResult r3 = AssertionFailure(); EXPECT_FALSE(r3); EXPECT_STREQ("", r3.message()); AssertionResult r4 = AssertionFailure() << "def"; EXPECT_FALSE(r4); EXPECT_STREQ("def", r4.message()); AssertionResult r5 = AssertionFailure(Message() << "ghi"); EXPECT_FALSE(r5); EXPECT_STREQ("ghi", r5.message()); } // Tests that the negation flips the predicate result but keeps the message. TEST(AssertionResultTest, NegationWorks) { AssertionResult r1 = AssertionSuccess() << "abc"; EXPECT_FALSE(!r1); EXPECT_STREQ("abc", (!r1).message()); AssertionResult r2 = AssertionFailure() << "def"; EXPECT_TRUE(!r2); EXPECT_STREQ("def", (!r2).message()); } TEST(AssertionResultTest, StreamingWorks) { AssertionResult r = AssertionSuccess(); r << "abc" << 'd' << 0 << true; EXPECT_STREQ("abcd0true", r.message()); } TEST(AssertionResultTest, CanStreamOstreamManipulators) { AssertionResult r = AssertionSuccess(); r << "Data" << std::endl << std::flush << std::ends << "Will be visible"; EXPECT_STREQ("Data\n\\0Will be visible", r.message()); } // The next test uses explicit conversion operators -- a C++11 feature. #if GTEST_LANG_CXX11 TEST(AssertionResultTest, ConstructibleFromContextuallyConvertibleToBool) { struct ExplicitlyConvertibleToBool { explicit operator bool() const { return value; } bool value; }; ExplicitlyConvertibleToBool v1 = {false}; ExplicitlyConvertibleToBool v2 = {true}; EXPECT_FALSE(v1); EXPECT_TRUE(v2); } #endif // GTEST_LANG_CXX11 struct ConvertibleToAssertionResult { operator AssertionResult() const { return AssertionResult(true); } }; TEST(AssertionResultTest, ConstructibleFromImplicitlyConvertible) { ConvertibleToAssertionResult obj; EXPECT_TRUE(obj); } // Tests streaming a user type whose definition and operator << are // both in the global namespace. class Base { public: explicit Base(int an_x) : x_(an_x) {} int x() const { return x_; } private: int x_; }; std::ostream& operator<<(std::ostream& os, const Base& val) { return os << val.x(); } std::ostream& operator<<(std::ostream& os, const Base* pointer) { return os << "(" << pointer->x() << ")"; } TEST(MessageTest, CanStreamUserTypeInGlobalNameSpace) { Message msg; Base a(1); msg << a << &a; // Uses ::operator<<. EXPECT_STREQ("1(1)", msg.GetString().c_str()); } // Tests streaming a user type whose definition and operator<< are // both in an unnamed namespace. namespace { class MyTypeInUnnamedNameSpace : public Base { public: explicit MyTypeInUnnamedNameSpace(int an_x): Base(an_x) {} }; std::ostream& operator<<(std::ostream& os, const MyTypeInUnnamedNameSpace& val) { return os << val.x(); } std::ostream& operator<<(std::ostream& os, const MyTypeInUnnamedNameSpace* pointer) { return os << "(" << pointer->x() << ")"; } } // namespace TEST(MessageTest, CanStreamUserTypeInUnnamedNameSpace) { Message msg; MyTypeInUnnamedNameSpace a(1); msg << a << &a; // Uses <unnamed_namespace>::operator<<. EXPECT_STREQ("1(1)", msg.GetString().c_str()); } // Tests streaming a user type whose definition and operator<< are // both in a user namespace. namespace namespace1 { class MyTypeInNameSpace1 : public Base { public: explicit MyTypeInNameSpace1(int an_x): Base(an_x) {} }; std::ostream& operator<<(std::ostream& os, const MyTypeInNameSpace1& val) { return os << val.x(); } std::ostream& operator<<(std::ostream& os, const MyTypeInNameSpace1* pointer) { return os << "(" << pointer->x() << ")"; } } // namespace namespace1 TEST(MessageTest, CanStreamUserTypeInUserNameSpace) { Message msg; namespace1::MyTypeInNameSpace1 a(1); msg << a << &a; // Uses namespace1::operator<<. EXPECT_STREQ("1(1)", msg.GetString().c_str()); } // Tests streaming a user type whose definition is in a user namespace // but whose operator<< is in the global namespace. namespace namespace2 { class MyTypeInNameSpace2 : public ::Base { public: explicit MyTypeInNameSpace2(int an_x): Base(an_x) {} }; } // namespace namespace2 std::ostream& operator<<(std::ostream& os, const namespace2::MyTypeInNameSpace2& val) { return os << val.x(); } std::ostream& operator<<(std::ostream& os, const namespace2::MyTypeInNameSpace2* pointer) { return os << "(" << pointer->x() << ")"; } TEST(MessageTest, CanStreamUserTypeInUserNameSpaceWithStreamOperatorInGlobal) { Message msg; namespace2::MyTypeInNameSpace2 a(1); msg << a << &a; // Uses ::operator<<. EXPECT_STREQ("1(1)", msg.GetString().c_str()); } // Tests streaming NULL pointers to testing::Message. TEST(MessageTest, NullPointers) { Message msg; char* const p1 = NULL; unsigned char* const p2 = NULL; int* p3 = NULL; double* p4 = NULL; bool* p5 = NULL; Message* p6 = NULL; msg << p1 << p2 << p3 << p4 << p5 << p6; ASSERT_STREQ("(null)(null)(null)(null)(null)(null)", msg.GetString().c_str()); } // Tests streaming wide strings to testing::Message. TEST(MessageTest, WideStrings) { // Streams a NULL of type const wchar_t*. const wchar_t* const_wstr = NULL; EXPECT_STREQ("(null)", (Message() << const_wstr).GetString().c_str()); // Streams a NULL of type wchar_t*. wchar_t* wstr = NULL; EXPECT_STREQ("(null)", (Message() << wstr).GetString().c_str()); // Streams a non-NULL of type const wchar_t*. const_wstr = L"abc\x8119"; EXPECT_STREQ("abc\xe8\x84\x99", (Message() << const_wstr).GetString().c_str()); // Streams a non-NULL of type wchar_t*. wstr = const_cast<wchar_t*>(const_wstr); EXPECT_STREQ("abc\xe8\x84\x99", (Message() << wstr).GetString().c_str()); } // This line tests that we can define tests in the testing namespace. namespace testing { // Tests the TestInfo class. class TestInfoTest : public Test { protected: static const TestInfo* GetTestInfo(const char* test_name) { const TestCase* const test_case = GetUnitTestImpl()-> GetTestCase("TestInfoTest", "", NULL, NULL); for (int i = 0; i < test_case->total_test_count(); ++i) { const TestInfo* const test_info = test_case->GetTestInfo(i); if (strcmp(test_name, test_info->name()) == 0) return test_info; } return NULL; } static const TestResult* GetTestResult( const TestInfo* test_info) { return test_info->result(); } }; // Tests TestInfo::test_case_name() and TestInfo::name(). TEST_F(TestInfoTest, Names) { const TestInfo* const test_info = GetTestInfo("Names"); ASSERT_STREQ("TestInfoTest", test_info->test_case_name()); ASSERT_STREQ("Names", test_info->name()); } // Tests TestInfo::result(). TEST_F(TestInfoTest, result) { const TestInfo* const test_info = GetTestInfo("result"); // Initially, there is no TestPartResult for this test. ASSERT_EQ(0, GetTestResult(test_info)->total_part_count()); // After the previous assertion, there is still none. ASSERT_EQ(0, GetTestResult(test_info)->total_part_count()); } #define VERIFY_CODE_LOCATION \ const int expected_line = __LINE__ - 1; \ const TestInfo* const test_info = GetUnitTestImpl()->current_test_info(); \ ASSERT_TRUE(test_info); \ EXPECT_STREQ(__FILE__, test_info->file()); \ EXPECT_EQ(expected_line, test_info->line()) TEST(CodeLocationForTEST, Verify) { VERIFY_CODE_LOCATION; } class CodeLocationForTESTF : public Test { }; TEST_F(CodeLocationForTESTF, Verify) { VERIFY_CODE_LOCATION; } class CodeLocationForTESTP : public TestWithParam<int> { }; TEST_P(CodeLocationForTESTP, Verify) { VERIFY_CODE_LOCATION; } INSTANTIATE_TEST_CASE_P(, CodeLocationForTESTP, Values(0)); template <typename T> class CodeLocationForTYPEDTEST : public Test { }; TYPED_TEST_CASE(CodeLocationForTYPEDTEST, int); TYPED_TEST(CodeLocationForTYPEDTEST, Verify) { VERIFY_CODE_LOCATION; } template <typename T> class CodeLocationForTYPEDTESTP : public Test { }; TYPED_TEST_CASE_P(CodeLocationForTYPEDTESTP); TYPED_TEST_P(CodeLocationForTYPEDTESTP, Verify) { VERIFY_CODE_LOCATION; } REGISTER_TYPED_TEST_CASE_P(CodeLocationForTYPEDTESTP, Verify); INSTANTIATE_TYPED_TEST_CASE_P(My, CodeLocationForTYPEDTESTP, int); #undef VERIFY_CODE_LOCATION // Tests setting up and tearing down a test case. class SetUpTestCaseTest : public Test { protected: // This will be called once before the first test in this test case // is run. static void SetUpTestCase() { printf("Setting up the test case . . .\n"); // Initializes some shared resource. In this simple example, we // just create a C string. More complex stuff can be done if // desired. shared_resource_ = "123"; // Increments the number of test cases that have been set up. counter_++; // SetUpTestCase() should be called only once. EXPECT_EQ(1, counter_); } // This will be called once after the last test in this test case is // run. static void TearDownTestCase() { printf("Tearing down the test case . . .\n"); // Decrements the number of test cases that have been set up. counter_--; // TearDownTestCase() should be called only once. EXPECT_EQ(0, counter_); // Cleans up the shared resource. shared_resource_ = NULL; } // This will be called before each test in this test case. virtual void SetUp() { // SetUpTestCase() should be called only once, so counter_ should // always be 1. EXPECT_EQ(1, counter_); } // Number of test cases that have been set up. static int counter_; // Some resource to be shared by all tests in this test case. static const char* shared_resource_; }; int SetUpTestCaseTest::counter_ = 0; const char* SetUpTestCaseTest::shared_resource_ = NULL; // A test that uses the shared resource. TEST_F(SetUpTestCaseTest, Test1) { EXPECT_STRNE(NULL, shared_resource_); } // Another test that uses the shared resource. TEST_F(SetUpTestCaseTest, Test2) { EXPECT_STREQ("123", shared_resource_); } // The ParseFlagsTest test case tests ParseGoogleTestFlagsOnly. // The Flags struct stores a copy of all Google Test flags. struct Flags { // Constructs a Flags struct where each flag has its default value. Flags() : also_run_disabled_tests(false), break_on_failure(false), catch_exceptions(false), death_test_use_fork(false), filter(""), list_tests(false), output(""), print_time(true), random_seed(0), repeat(1), shuffle(false), stack_trace_depth(kMaxStackTraceDepth), stream_result_to(""), throw_on_failure(false) {} // Factory methods. // Creates a Flags struct where the gtest_also_run_disabled_tests flag has // the given value. static Flags AlsoRunDisabledTests(bool also_run_disabled_tests) { Flags flags; flags.also_run_disabled_tests = also_run_disabled_tests; return flags; } // Creates a Flags struct where the gtest_break_on_failure flag has // the given value. static Flags BreakOnFailure(bool break_on_failure) { Flags flags; flags.break_on_failure = break_on_failure; return flags; } // Creates a Flags struct where the gtest_catch_exceptions flag has // the given value. static Flags CatchExceptions(bool catch_exceptions) { Flags flags; flags.catch_exceptions = catch_exceptions; return flags; } // Creates a Flags struct where the gtest_death_test_use_fork flag has // the given value. static Flags DeathTestUseFork(bool death_test_use_fork) { Flags flags; flags.death_test_use_fork = death_test_use_fork; return flags; } // Creates a Flags struct where the gtest_filter flag has the given // value. static Flags Filter(const char* filter) { Flags flags; flags.filter = filter; return flags; } // Creates a Flags struct where the gtest_list_tests flag has the // given value. static Flags ListTests(bool list_tests) { Flags flags; flags.list_tests = list_tests; return flags; } // Creates a Flags struct where the gtest_output flag has the given // value. static Flags Output(const char* output) { Flags flags; flags.output = output; return flags; } // Creates a Flags struct where the gtest_print_time flag has the given // value. static Flags PrintTime(bool print_time) { Flags flags; flags.print_time = print_time; return flags; } // Creates a Flags struct where the gtest_random_seed flag has the given // value. static Flags RandomSeed(Int32 random_seed) { Flags flags; flags.random_seed = random_seed; return flags; } // Creates a Flags struct where the gtest_repeat flag has the given // value. static Flags Repeat(Int32 repeat) { Flags flags; flags.repeat = repeat; return flags; } // Creates a Flags struct where the gtest_shuffle flag has the given // value. static Flags Shuffle(bool shuffle) { Flags flags; flags.shuffle = shuffle; return flags; } // Creates a Flags struct where the GTEST_FLAG(stack_trace_depth) flag has // the given value. static Flags StackTraceDepth(Int32 stack_trace_depth) { Flags flags; flags.stack_trace_depth = stack_trace_depth; return flags; } // Creates a Flags struct where the GTEST_FLAG(stream_result_to) flag has // the given value. static Flags StreamResultTo(const char* stream_result_to) { Flags flags; flags.stream_result_to = stream_result_to; return flags; } // Creates a Flags struct where the gtest_throw_on_failure flag has // the given value. static Flags ThrowOnFailure(bool throw_on_failure) { Flags flags; flags.throw_on_failure = throw_on_failure; return flags; } // These fields store the flag values. bool also_run_disabled_tests; bool break_on_failure; bool catch_exceptions; bool death_test_use_fork; const char* filter; bool list_tests; const char* output; bool print_time; Int32 random_seed; Int32 repeat; bool shuffle; Int32 stack_trace_depth; const char* stream_result_to; bool throw_on_failure; }; // Fixture for testing ParseGoogleTestFlagsOnly(). class ParseFlagsTest : public Test { protected: // Clears the flags before each test. virtual void SetUp() { GTEST_FLAG(also_run_disabled_tests) = false; GTEST_FLAG(break_on_failure) = false; GTEST_FLAG(catch_exceptions) = false; GTEST_FLAG(death_test_use_fork) = false; GTEST_FLAG(filter) = ""; GTEST_FLAG(list_tests) = false; GTEST_FLAG(output) = ""; GTEST_FLAG(print_time) = true; GTEST_FLAG(random_seed) = 0; GTEST_FLAG(repeat) = 1; GTEST_FLAG(shuffle) = false; GTEST_FLAG(stack_trace_depth) = kMaxStackTraceDepth; GTEST_FLAG(stream_result_to) = ""; GTEST_FLAG(throw_on_failure) = false; } // Asserts that two narrow or wide string arrays are equal. template <typename CharType> static void AssertStringArrayEq(size_t size1, CharType** array1, size_t size2, CharType** array2) { ASSERT_EQ(size1, size2) << " Array sizes different."; for (size_t i = 0; i != size1; i++) { ASSERT_STREQ(array1[i], array2[i]) << " where i == " << i; } } // Verifies that the flag values match the expected values. static void CheckFlags(const Flags& expected) { EXPECT_EQ(expected.also_run_disabled_tests, GTEST_FLAG(also_run_disabled_tests)); EXPECT_EQ(expected.break_on_failure, GTEST_FLAG(break_on_failure)); EXPECT_EQ(expected.catch_exceptions, GTEST_FLAG(catch_exceptions)); EXPECT_EQ(expected.death_test_use_fork, GTEST_FLAG(death_test_use_fork)); EXPECT_STREQ(expected.filter, GTEST_FLAG(filter).c_str()); EXPECT_EQ(expected.list_tests, GTEST_FLAG(list_tests)); EXPECT_STREQ(expected.output, GTEST_FLAG(output).c_str()); EXPECT_EQ(expected.print_time, GTEST_FLAG(print_time)); EXPECT_EQ(expected.random_seed, GTEST_FLAG(random_seed)); EXPECT_EQ(expected.repeat, GTEST_FLAG(repeat)); EXPECT_EQ(expected.shuffle, GTEST_FLAG(shuffle)); EXPECT_EQ(expected.stack_trace_depth, GTEST_FLAG(stack_trace_depth)); EXPECT_STREQ(expected.stream_result_to, GTEST_FLAG(stream_result_to).c_str()); EXPECT_EQ(expected.throw_on_failure, GTEST_FLAG(throw_on_failure)); } // Parses a command line (specified by argc1 and argv1), then // verifies that the flag values are expected and that the // recognized flags are removed from the command line. template <typename CharType> static void TestParsingFlags(int argc1, const CharType** argv1, int argc2, const CharType** argv2, const Flags& expected, bool should_print_help) { const bool saved_help_flag = ::testing::internal::g_help_flag; ::testing::internal::g_help_flag = false; # if GTEST_HAS_STREAM_REDIRECTION CaptureStdout(); # endif // Parses the command line. internal::ParseGoogleTestFlagsOnly(&argc1, const_cast<CharType**>(argv1)); # if GTEST_HAS_STREAM_REDIRECTION const std::string captured_stdout = GetCapturedStdout(); # endif // Verifies the flag values. CheckFlags(expected); // Verifies that the recognized flags are removed from the command // line. AssertStringArrayEq(argc1 + 1, argv1, argc2 + 1, argv2); // ParseGoogleTestFlagsOnly should neither set g_help_flag nor print the // help message for the flags it recognizes. EXPECT_EQ(should_print_help, ::testing::internal::g_help_flag); # if GTEST_HAS_STREAM_REDIRECTION const char* const expected_help_fragment = "This program contains tests written using"; if (should_print_help) { EXPECT_PRED_FORMAT2(IsSubstring, expected_help_fragment, captured_stdout); } else { EXPECT_PRED_FORMAT2(IsNotSubstring, expected_help_fragment, captured_stdout); } # endif // GTEST_HAS_STREAM_REDIRECTION ::testing::internal::g_help_flag = saved_help_flag; } // This macro wraps TestParsingFlags s.t. the user doesn't need // to specify the array sizes. # define GTEST_TEST_PARSING_FLAGS_(argv1, argv2, expected, should_print_help) \ TestParsingFlags(sizeof(argv1)/sizeof(*argv1) - 1, argv1, \ sizeof(argv2)/sizeof(*argv2) - 1, argv2, \ expected, should_print_help) }; // Tests parsing an empty command line. TEST_F(ParseFlagsTest, Empty) { const char* argv[] = { NULL }; const char* argv2[] = { NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags(), false); } // Tests parsing a command line that has no flag. TEST_F(ParseFlagsTest, NoFlag) { const char* argv[] = { "foo.exe", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags(), false); } // Tests parsing a bad --gtest_filter flag. TEST_F(ParseFlagsTest, FilterBad) { const char* argv[] = { "foo.exe", "--gtest_filter", NULL }; const char* argv2[] = { "foo.exe", "--gtest_filter", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter(""), true); } // Tests parsing an empty --gtest_filter flag. TEST_F(ParseFlagsTest, FilterEmpty) { const char* argv[] = { "foo.exe", "--gtest_filter=", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter(""), false); } // Tests parsing a non-empty --gtest_filter flag. TEST_F(ParseFlagsTest, FilterNonEmpty) { const char* argv[] = { "foo.exe", "--gtest_filter=abc", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter("abc"), false); } // Tests parsing --gtest_break_on_failure. TEST_F(ParseFlagsTest, BreakOnFailureWithoutValue) { const char* argv[] = { "foo.exe", "--gtest_break_on_failure", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::BreakOnFailure(true), false); } // Tests parsing --gtest_break_on_failure=0. TEST_F(ParseFlagsTest, BreakOnFailureFalse_0) { const char* argv[] = { "foo.exe", "--gtest_break_on_failure=0", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::BreakOnFailure(false), false); } // Tests parsing --gtest_break_on_failure=f. TEST_F(ParseFlagsTest, BreakOnFailureFalse_f) { const char* argv[] = { "foo.exe", "--gtest_break_on_failure=f", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::BreakOnFailure(false), false); } // Tests parsing --gtest_break_on_failure=F. TEST_F(ParseFlagsTest, BreakOnFailureFalse_F) { const char* argv[] = { "foo.exe", "--gtest_break_on_failure=F", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::BreakOnFailure(false), false); } // Tests parsing a --gtest_break_on_failure flag that has a "true" // definition. TEST_F(ParseFlagsTest, BreakOnFailureTrue) { const char* argv[] = { "foo.exe", "--gtest_break_on_failure=1", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::BreakOnFailure(true), false); } // Tests parsing --gtest_catch_exceptions. TEST_F(ParseFlagsTest, CatchExceptions) { const char* argv[] = { "foo.exe", "--gtest_catch_exceptions", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::CatchExceptions(true), false); } // Tests parsing --gtest_death_test_use_fork. TEST_F(ParseFlagsTest, DeathTestUseFork) { const char* argv[] = { "foo.exe", "--gtest_death_test_use_fork", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::DeathTestUseFork(true), false); } // Tests having the same flag twice with different values. The // expected behavior is that the one coming last takes precedence. TEST_F(ParseFlagsTest, DuplicatedFlags) { const char* argv[] = { "foo.exe", "--gtest_filter=a", "--gtest_filter=b", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter("b"), false); } // Tests having an unrecognized flag on the command line. TEST_F(ParseFlagsTest, UnrecognizedFlag) { const char* argv[] = { "foo.exe", "--gtest_break_on_failure", "bar", // Unrecognized by Google Test. "--gtest_filter=b", NULL }; const char* argv2[] = { "foo.exe", "bar", NULL }; Flags flags; flags.break_on_failure = true; flags.filter = "b"; GTEST_TEST_PARSING_FLAGS_(argv, argv2, flags, false); } // Tests having a --gtest_list_tests flag TEST_F(ParseFlagsTest, ListTestsFlag) { const char* argv[] = { "foo.exe", "--gtest_list_tests", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ListTests(true), false); } // Tests having a --gtest_list_tests flag with a "true" value TEST_F(ParseFlagsTest, ListTestsTrue) { const char* argv[] = { "foo.exe", "--gtest_list_tests=1", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ListTests(true), false); } // Tests having a --gtest_list_tests flag with a "false" value TEST_F(ParseFlagsTest, ListTestsFalse) { const char* argv[] = { "foo.exe", "--gtest_list_tests=0", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ListTests(false), false); } // Tests parsing --gtest_list_tests=f. TEST_F(ParseFlagsTest, ListTestsFalse_f) { const char* argv[] = { "foo.exe", "--gtest_list_tests=f", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ListTests(false), false); } // Tests parsing --gtest_list_tests=F. TEST_F(ParseFlagsTest, ListTestsFalse_F) { const char* argv[] = { "foo.exe", "--gtest_list_tests=F", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ListTests(false), false); } // Tests parsing --gtest_output (invalid). TEST_F(ParseFlagsTest, OutputEmpty) { const char* argv[] = { "foo.exe", "--gtest_output", NULL }; const char* argv2[] = { "foo.exe", "--gtest_output", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags(), true); } // Tests parsing --gtest_output=xml TEST_F(ParseFlagsTest, OutputXml) { const char* argv[] = { "foo.exe", "--gtest_output=xml", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Output("xml"), false); } // Tests parsing --gtest_output=xml:file TEST_F(ParseFlagsTest, OutputXmlFile) { const char* argv[] = { "foo.exe", "--gtest_output=xml:file", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Output("xml:file"), false); } // Tests parsing --gtest_output=xml:directory/path/ TEST_F(ParseFlagsTest, OutputXmlDirectory) { const char* argv[] = { "foo.exe", "--gtest_output=xml:directory/path/", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Output("xml:directory/path/"), false); } // Tests having a --gtest_print_time flag TEST_F(ParseFlagsTest, PrintTimeFlag) { const char* argv[] = { "foo.exe", "--gtest_print_time", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::PrintTime(true), false); } // Tests having a --gtest_print_time flag with a "true" value TEST_F(ParseFlagsTest, PrintTimeTrue) { const char* argv[] = { "foo.exe", "--gtest_print_time=1", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::PrintTime(true), false); } // Tests having a --gtest_print_time flag with a "false" value TEST_F(ParseFlagsTest, PrintTimeFalse) { const char* argv[] = { "foo.exe", "--gtest_print_time=0", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::PrintTime(false), false); } // Tests parsing --gtest_print_time=f. TEST_F(ParseFlagsTest, PrintTimeFalse_f) { const char* argv[] = { "foo.exe", "--gtest_print_time=f", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::PrintTime(false), false); } // Tests parsing --gtest_print_time=F. TEST_F(ParseFlagsTest, PrintTimeFalse_F) { const char* argv[] = { "foo.exe", "--gtest_print_time=F", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::PrintTime(false), false); } // Tests parsing --gtest_random_seed=number TEST_F(ParseFlagsTest, RandomSeed) { const char* argv[] = { "foo.exe", "--gtest_random_seed=1000", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::RandomSeed(1000), false); } // Tests parsing --gtest_repeat=number TEST_F(ParseFlagsTest, Repeat) { const char* argv[] = { "foo.exe", "--gtest_repeat=1000", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Repeat(1000), false); } // Tests having a --gtest_also_run_disabled_tests flag TEST_F(ParseFlagsTest, AlsoRunDisabledTestsFlag) { const char* argv[] = { "foo.exe", "--gtest_also_run_disabled_tests", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::AlsoRunDisabledTests(true), false); } // Tests having a --gtest_also_run_disabled_tests flag with a "true" value TEST_F(ParseFlagsTest, AlsoRunDisabledTestsTrue) { const char* argv[] = { "foo.exe", "--gtest_also_run_disabled_tests=1", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::AlsoRunDisabledTests(true), false); } // Tests having a --gtest_also_run_disabled_tests flag with a "false" value TEST_F(ParseFlagsTest, AlsoRunDisabledTestsFalse) { const char* argv[] = { "foo.exe", "--gtest_also_run_disabled_tests=0", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::AlsoRunDisabledTests(false), false); } // Tests parsing --gtest_shuffle. TEST_F(ParseFlagsTest, ShuffleWithoutValue) { const char* argv[] = { "foo.exe", "--gtest_shuffle", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Shuffle(true), false); } // Tests parsing --gtest_shuffle=0. TEST_F(ParseFlagsTest, ShuffleFalse_0) { const char* argv[] = { "foo.exe", "--gtest_shuffle=0", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Shuffle(false), false); } // Tests parsing a --gtest_shuffle flag that has a "true" definition. TEST_F(ParseFlagsTest, ShuffleTrue) { const char* argv[] = { "foo.exe", "--gtest_shuffle=1", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Shuffle(true), false); } // Tests parsing --gtest_stack_trace_depth=number. TEST_F(ParseFlagsTest, StackTraceDepth) { const char* argv[] = { "foo.exe", "--gtest_stack_trace_depth=5", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::StackTraceDepth(5), false); } TEST_F(ParseFlagsTest, StreamResultTo) { const char* argv[] = { "foo.exe", "--gtest_stream_result_to=localhost:1234", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_( argv, argv2, Flags::StreamResultTo("localhost:1234"), false); } // Tests parsing --gtest_throw_on_failure. TEST_F(ParseFlagsTest, ThrowOnFailureWithoutValue) { const char* argv[] = { "foo.exe", "--gtest_throw_on_failure", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ThrowOnFailure(true), false); } // Tests parsing --gtest_throw_on_failure=0. TEST_F(ParseFlagsTest, ThrowOnFailureFalse_0) { const char* argv[] = { "foo.exe", "--gtest_throw_on_failure=0", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ThrowOnFailure(false), false); } // Tests parsing a --gtest_throw_on_failure flag that has a "true" // definition. TEST_F(ParseFlagsTest, ThrowOnFailureTrue) { const char* argv[] = { "foo.exe", "--gtest_throw_on_failure=1", NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ThrowOnFailure(true), false); } # if GTEST_OS_WINDOWS // Tests parsing wide strings. TEST_F(ParseFlagsTest, WideStrings) { const wchar_t* argv[] = { L"foo.exe", L"--gtest_filter=Foo*", L"--gtest_list_tests=1", L"--gtest_break_on_failure", L"--non_gtest_flag", NULL }; const wchar_t* argv2[] = { L"foo.exe", L"--non_gtest_flag", NULL }; Flags expected_flags; expected_flags.break_on_failure = true; expected_flags.filter = "Foo*"; expected_flags.list_tests = true; GTEST_TEST_PARSING_FLAGS_(argv, argv2, expected_flags, false); } # endif // GTEST_OS_WINDOWS #if GTEST_USE_OWN_FLAGFILE_FLAG_ class FlagfileTest : public ParseFlagsTest { public: virtual void SetUp() { ParseFlagsTest::SetUp(); testdata_path_.Set(internal::FilePath( testing::TempDir() + internal::GetCurrentExecutableName().string() + "_flagfile_test")); testing::internal::posix::RmDir(testdata_path_.c_str()); EXPECT_TRUE(testdata_path_.CreateFolder()); } virtual void TearDown() { testing::internal::posix::RmDir(testdata_path_.c_str()); ParseFlagsTest::TearDown(); } internal::FilePath CreateFlagfile(const char* contents) { internal::FilePath file_path(internal::FilePath::GenerateUniqueFileName( testdata_path_, internal::FilePath("unique"), "txt")); FILE* f = testing::internal::posix::FOpen(file_path.c_str(), "w"); fprintf(f, "%s", contents); fclose(f); return file_path; } private: internal::FilePath testdata_path_; }; // Tests an empty flagfile. TEST_F(FlagfileTest, Empty) { internal::FilePath flagfile_path(CreateFlagfile("")); std::string flagfile_flag = std::string("--" GTEST_FLAG_PREFIX_ "flagfile=") + flagfile_path.c_str(); const char* argv[] = { "foo.exe", flagfile_flag.c_str(), NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags(), false); } // Tests passing a non-empty --gtest_filter flag via --gtest_flagfile. TEST_F(FlagfileTest, FilterNonEmpty) { internal::FilePath flagfile_path(CreateFlagfile( "--" GTEST_FLAG_PREFIX_ "filter=abc")); std::string flagfile_flag = std::string("--" GTEST_FLAG_PREFIX_ "flagfile=") + flagfile_path.c_str(); const char* argv[] = { "foo.exe", flagfile_flag.c_str(), NULL }; const char* argv2[] = { "foo.exe", NULL }; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter("abc"), false); } // Tests passing several flags via --gtest_flagfile. TEST_F(FlagfileTest, SeveralFlags) { internal::FilePath flagfile_path(CreateFlagfile( "--" GTEST_FLAG_PREFIX_ "filter=abc\n" "--" GTEST_FLAG_PREFIX_ "break_on_failure\n" "--" GTEST_FLAG_PREFIX_ "list_tests")); std::string flagfile_flag = std::string("--" GTEST_FLAG_PREFIX_ "flagfile=") + flagfile_path.c_str(); const char* argv[] = { "foo.exe", flagfile_flag.c_str(), NULL }; const char* argv2[] = { "foo.exe", NULL }; Flags expected_flags; expected_flags.break_on_failure = true; expected_flags.filter = "abc"; expected_flags.list_tests = true; GTEST_TEST_PARSING_FLAGS_(argv, argv2, expected_flags, false); } #endif // GTEST_USE_OWN_FLAGFILE_FLAG_ // Tests current_test_info() in UnitTest. class CurrentTestInfoTest : public Test { protected: // Tests that current_test_info() returns NULL before the first test in // the test case is run. static void SetUpTestCase() { // There should be no tests running at this point. const TestInfo* test_info = UnitTest::GetInstance()->current_test_info(); EXPECT_TRUE(test_info == NULL) << "There should be no tests running at this point."; } // Tests that current_test_info() returns NULL after the last test in // the test case has run. static void TearDownTestCase() { const TestInfo* test_info = UnitTest::GetInstance()->current_test_info(); EXPECT_TRUE(test_info == NULL) << "There should be no tests running at this point."; } }; // Tests that current_test_info() returns TestInfo for currently running // test by checking the expected test name against the actual one. TEST_F(CurrentTestInfoTest, WorksForFirstTestInATestCase) { const TestInfo* test_info = UnitTest::GetInstance()->current_test_info(); ASSERT_TRUE(NULL != test_info) << "There is a test running so we should have a valid TestInfo."; EXPECT_STREQ("CurrentTestInfoTest", test_info->test_case_name()) << "Expected the name of the currently running test case."; EXPECT_STREQ("WorksForFirstTestInATestCase", test_info->name()) << "Expected the name of the currently running test."; } // Tests that current_test_info() returns TestInfo for currently running // test by checking the expected test name against the actual one. We // use this test to see that the TestInfo object actually changed from // the previous invocation. TEST_F(CurrentTestInfoTest, WorksForSecondTestInATestCase) { const TestInfo* test_info = UnitTest::GetInstance()->current_test_info(); ASSERT_TRUE(NULL != test_info) << "There is a test running so we should have a valid TestInfo."; EXPECT_STREQ("CurrentTestInfoTest", test_info->test_case_name()) << "Expected the name of the currently running test case."; EXPECT_STREQ("WorksForSecondTestInATestCase", test_info->name()) << "Expected the name of the currently running test."; } } // namespace testing // These two lines test that we can define tests in a namespace that // has the name "testing" and is nested in another namespace. namespace my_namespace { namespace testing { // Makes sure that TEST knows to use ::testing::Test instead of // ::my_namespace::testing::Test. class Test {}; // Makes sure that an assertion knows to use ::testing::Message instead of // ::my_namespace::testing::Message. class Message {}; // Makes sure that an assertion knows to use // ::testing::AssertionResult instead of // ::my_namespace::testing::AssertionResult. class AssertionResult {}; // Tests that an assertion that should succeed works as expected. TEST(NestedTestingNamespaceTest, Success) { EXPECT_EQ(1, 1) << "This shouldn't fail."; } // Tests that an assertion that should fail works as expected. TEST(NestedTestingNamespaceTest, Failure) { EXPECT_FATAL_FAILURE(FAIL() << "This failure is expected.", "This failure is expected."); } } // namespace testing } // namespace my_namespace // Tests that one can call superclass SetUp and TearDown methods-- // that is, that they are not private. // No tests are based on this fixture; the test "passes" if it compiles // successfully. class ProtectedFixtureMethodsTest : public Test { protected: virtual void SetUp() { Test::SetUp(); } virtual void TearDown() { Test::TearDown(); } }; // StreamingAssertionsTest tests the streaming versions of a representative // sample of assertions. TEST(StreamingAssertionsTest, Unconditional) { SUCCEED() << "expected success"; EXPECT_NONFATAL_FAILURE(ADD_FAILURE() << "expected failure", "expected failure"); EXPECT_FATAL_FAILURE(FAIL() << "expected failure", "expected failure"); } #ifdef __BORLANDC__ // Silences warnings: "Condition is always true", "Unreachable code" # pragma option push -w-ccc -w-rch #endif TEST(StreamingAssertionsTest, Truth) { EXPECT_TRUE(true) << "unexpected failure"; ASSERT_TRUE(true) << "unexpected failure"; EXPECT_NONFATAL_FAILURE(EXPECT_TRUE(false) << "expected failure", "expected failure"); EXPECT_FATAL_FAILURE(ASSERT_TRUE(false) << "expected failure", "expected failure"); } TEST(StreamingAssertionsTest, Truth2) { EXPECT_FALSE(false) << "unexpected failure"; ASSERT_FALSE(false) << "unexpected failure"; EXPECT_NONFATAL_FAILURE(EXPECT_FALSE(true) << "expected failure", "expected failure"); EXPECT_FATAL_FAILURE(ASSERT_FALSE(true) << "expected failure", "expected failure"); } #ifdef __BORLANDC__ // Restores warnings after previous "#pragma option push" suppressed them # pragma option pop #endif TEST(StreamingAssertionsTest, IntegerEquals) { EXPECT_EQ(1, 1) << "unexpected failure"; ASSERT_EQ(1, 1) << "unexpected failure"; EXPECT_NONFATAL_FAILURE(EXPECT_EQ(1, 2) << "expected failure", "expected failure"); EXPECT_FATAL_FAILURE(ASSERT_EQ(1, 2) << "expected failure", "expected failure"); } TEST(StreamingAssertionsTest, IntegerLessThan) { EXPECT_LT(1, 2) << "unexpected failure"; ASSERT_LT(1, 2) << "unexpected failure"; EXPECT_NONFATAL_FAILURE(EXPECT_LT(2, 1) << "expected failure", "expected failure"); EXPECT_FATAL_FAILURE(ASSERT_LT(2, 1) << "expected failure", "expected failure"); } TEST(StreamingAssertionsTest, StringsEqual) { EXPECT_STREQ("foo", "foo") << "unexpected failure"; ASSERT_STREQ("foo", "foo") << "unexpected failure"; EXPECT_NONFATAL_FAILURE(EXPECT_STREQ("foo", "bar") << "expected failure", "expected failure"); EXPECT_FATAL_FAILURE(ASSERT_STREQ("foo", "bar") << "expected failure", "expected failure"); } TEST(StreamingAssertionsTest, StringsNotEqual) { EXPECT_STRNE("foo", "bar") << "unexpected failure"; ASSERT_STRNE("foo", "bar") << "unexpected failure"; EXPECT_NONFATAL_FAILURE(EXPECT_STRNE("foo", "foo") << "expected failure", "expected failure"); EXPECT_FATAL_FAILURE(ASSERT_STRNE("foo", "foo") << "expected failure", "expected failure"); } TEST(StreamingAssertionsTest, StringsEqualIgnoringCase) { EXPECT_STRCASEEQ("foo", "FOO") << "unexpected failure"; ASSERT_STRCASEEQ("foo", "FOO") << "unexpected failure"; EXPECT_NONFATAL_FAILURE(EXPECT_STRCASEEQ("foo", "bar") << "expected failure", "expected failure"); EXPECT_FATAL_FAILURE(ASSERT_STRCASEEQ("foo", "bar") << "expected failure", "expected failure"); } TEST(StreamingAssertionsTest, StringNotEqualIgnoringCase) { EXPECT_STRCASENE("foo", "bar") << "unexpected failure"; ASSERT_STRCASENE("foo", "bar") << "unexpected failure"; EXPECT_NONFATAL_FAILURE(EXPECT_STRCASENE("foo", "FOO") << "expected failure", "expected failure"); EXPECT_FATAL_FAILURE(ASSERT_STRCASENE("bar", "BAR") << "expected failure", "expected failure"); } TEST(StreamingAssertionsTest, FloatingPointEquals) { EXPECT_FLOAT_EQ(1.0, 1.0) << "unexpected failure"; ASSERT_FLOAT_EQ(1.0, 1.0) << "unexpected failure"; EXPECT_NONFATAL_FAILURE(EXPECT_FLOAT_EQ(0.0, 1.0) << "expected failure", "expected failure"); EXPECT_FATAL_FAILURE(ASSERT_FLOAT_EQ(0.0, 1.0) << "expected failure", "expected failure"); } #if GTEST_HAS_EXCEPTIONS TEST(StreamingAssertionsTest, Throw) { EXPECT_THROW(ThrowAnInteger(), int) << "unexpected failure"; ASSERT_THROW(ThrowAnInteger(), int) << "unexpected failure"; EXPECT_NONFATAL_FAILURE(EXPECT_THROW(ThrowAnInteger(), bool) << "expected failure", "expected failure"); EXPECT_FATAL_FAILURE(ASSERT_THROW(ThrowAnInteger(), bool) << "expected failure", "expected failure"); } TEST(StreamingAssertionsTest, NoThrow) { EXPECT_NO_THROW(ThrowNothing()) << "unexpected failure"; ASSERT_NO_THROW(ThrowNothing()) << "unexpected failure"; EXPECT_NONFATAL_FAILURE(EXPECT_NO_THROW(ThrowAnInteger()) << "expected failure", "expected failure"); EXPECT_FATAL_FAILURE(ASSERT_NO_THROW(ThrowAnInteger()) << "expected failure", "expected failure"); } TEST(StreamingAssertionsTest, AnyThrow) { EXPECT_ANY_THROW(ThrowAnInteger()) << "unexpected failure"; ASSERT_ANY_THROW(ThrowAnInteger()) << "unexpected failure"; EXPECT_NONFATAL_FAILURE(EXPECT_ANY_THROW(ThrowNothing()) << "expected failure", "expected failure"); EXPECT_FATAL_FAILURE(ASSERT_ANY_THROW(ThrowNothing()) << "expected failure", "expected failure"); } #endif // GTEST_HAS_EXCEPTIONS // Tests that Google Test correctly decides whether to use colors in the output. TEST(ColoredOutputTest, UsesColorsWhenGTestColorFlagIsYes) { GTEST_FLAG(color) = "yes"; SetEnv("TERM", "xterm"); // TERM supports colors. EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY. EXPECT_TRUE(ShouldUseColor(false)); // Stdout is not a TTY. SetEnv("TERM", "dumb"); // TERM doesn't support colors. EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY. EXPECT_TRUE(ShouldUseColor(false)); // Stdout is not a TTY. } TEST(ColoredOutputTest, UsesColorsWhenGTestColorFlagIsAliasOfYes) { SetEnv("TERM", "dumb"); // TERM doesn't support colors. GTEST_FLAG(color) = "True"; EXPECT_TRUE(ShouldUseColor(false)); // Stdout is not a TTY. GTEST_FLAG(color) = "t"; EXPECT_TRUE(ShouldUseColor(false)); // Stdout is not a TTY. GTEST_FLAG(color) = "1"; EXPECT_TRUE(ShouldUseColor(false)); // Stdout is not a TTY. } TEST(ColoredOutputTest, UsesNoColorWhenGTestColorFlagIsNo) { GTEST_FLAG(color) = "no"; SetEnv("TERM", "xterm"); // TERM supports colors. EXPECT_FALSE(ShouldUseColor(true)); // Stdout is a TTY. EXPECT_FALSE(ShouldUseColor(false)); // Stdout is not a TTY. SetEnv("TERM", "dumb"); // TERM doesn't support colors. EXPECT_FALSE(ShouldUseColor(true)); // Stdout is a TTY. EXPECT_FALSE(ShouldUseColor(false)); // Stdout is not a TTY. } TEST(ColoredOutputTest, UsesNoColorWhenGTestColorFlagIsInvalid) { SetEnv("TERM", "xterm"); // TERM supports colors. GTEST_FLAG(color) = "F"; EXPECT_FALSE(ShouldUseColor(true)); // Stdout is a TTY. GTEST_FLAG(color) = "0"; EXPECT_FALSE(ShouldUseColor(true)); // Stdout is a TTY. GTEST_FLAG(color) = "unknown"; EXPECT_FALSE(ShouldUseColor(true)); // Stdout is a TTY. } TEST(ColoredOutputTest, UsesColorsWhenStdoutIsTty) { GTEST_FLAG(color) = "auto"; SetEnv("TERM", "xterm"); // TERM supports colors. EXPECT_FALSE(ShouldUseColor(false)); // Stdout is not a TTY. EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY. } TEST(ColoredOutputTest, UsesColorsWhenTermSupportsColors) { GTEST_FLAG(color) = "auto"; #if GTEST_OS_WINDOWS // On Windows, we ignore the TERM variable as it's usually not set. SetEnv("TERM", "dumb"); EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY. SetEnv("TERM", ""); EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY. SetEnv("TERM", "xterm"); EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY. #else // On non-Windows platforms, we rely on TERM to determine if the // terminal supports colors. SetEnv("TERM", "dumb"); // TERM doesn't support colors. EXPECT_FALSE(ShouldUseColor(true)); // Stdout is a TTY. SetEnv("TERM", "emacs"); // TERM doesn't support colors. EXPECT_FALSE(ShouldUseColor(true)); // Stdout is a TTY. SetEnv("TERM", "vt100"); // TERM doesn't support colors. EXPECT_FALSE(ShouldUseColor(true)); // Stdout is a TTY. SetEnv("TERM", "xterm-mono"); // TERM doesn't support colors. EXPECT_FALSE(ShouldUseColor(true)); // Stdout is a TTY. SetEnv("TERM", "xterm"); // TERM supports colors. EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY. SetEnv("TERM", "xterm-color"); // TERM supports colors. EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY. SetEnv("TERM", "xterm-256color"); // TERM supports colors. EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY. SetEnv("TERM", "screen"); // TERM supports colors. EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY. SetEnv("TERM", "screen-256color"); // TERM supports colors. EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY. SetEnv("TERM", "tmux"); // TERM supports colors. EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY. SetEnv("TERM", "tmux-256color"); // TERM supports colors. EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY. SetEnv("TERM", "rxvt-unicode"); // TERM supports colors. EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY. SetEnv("TERM", "rxvt-unicode-256color"); // TERM supports colors. EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY. SetEnv("TERM", "linux"); // TERM supports colors. EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY. SetEnv("TERM", "cygwin"); // TERM supports colors. EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY. #endif // GTEST_OS_WINDOWS } // Verifies that StaticAssertTypeEq works in a namespace scope. static bool dummy1 GTEST_ATTRIBUTE_UNUSED_ = StaticAssertTypeEq<bool, bool>(); static bool dummy2 GTEST_ATTRIBUTE_UNUSED_ = StaticAssertTypeEq<const int, const int>(); // Verifies that StaticAssertTypeEq works in a class. template <typename T> class StaticAssertTypeEqTestHelper { public: StaticAssertTypeEqTestHelper() { StaticAssertTypeEq<bool, T>(); } }; TEST(StaticAssertTypeEqTest, WorksInClass) { StaticAssertTypeEqTestHelper<bool>(); } // Verifies that StaticAssertTypeEq works inside a function. typedef int IntAlias; TEST(StaticAssertTypeEqTest, CompilesForEqualTypes) { StaticAssertTypeEq<int, IntAlias>(); StaticAssertTypeEq<int*, IntAlias*>(); } TEST(HasNonfatalFailureTest, ReturnsFalseWhenThereIsNoFailure) { EXPECT_FALSE(HasNonfatalFailure()); } static void FailFatally() { FAIL(); } TEST(HasNonfatalFailureTest, ReturnsFalseWhenThereIsOnlyFatalFailure) { FailFatally(); const bool has_nonfatal_failure = HasNonfatalFailure(); ClearCurrentTestPartResults(); EXPECT_FALSE(has_nonfatal_failure); } TEST(HasNonfatalFailureTest, ReturnsTrueWhenThereIsNonfatalFailure) { ADD_FAILURE(); const bool has_nonfatal_failure = HasNonfatalFailure(); ClearCurrentTestPartResults(); EXPECT_TRUE(has_nonfatal_failure); } TEST(HasNonfatalFailureTest, ReturnsTrueWhenThereAreFatalAndNonfatalFailures) { FailFatally(); ADD_FAILURE(); const bool has_nonfatal_failure = HasNonfatalFailure(); ClearCurrentTestPartResults(); EXPECT_TRUE(has_nonfatal_failure); } // A wrapper for calling HasNonfatalFailure outside of a test body. static bool HasNonfatalFailureHelper() { return testing::Test::HasNonfatalFailure(); } TEST(HasNonfatalFailureTest, WorksOutsideOfTestBody) { EXPECT_FALSE(HasNonfatalFailureHelper()); } TEST(HasNonfatalFailureTest, WorksOutsideOfTestBody2) { ADD_FAILURE(); const bool has_nonfatal_failure = HasNonfatalFailureHelper(); ClearCurrentTestPartResults(); EXPECT_TRUE(has_nonfatal_failure); } TEST(HasFailureTest, ReturnsFalseWhenThereIsNoFailure) { EXPECT_FALSE(HasFailure()); } TEST(HasFailureTest, ReturnsTrueWhenThereIsFatalFailure) { FailFatally(); const bool has_failure = HasFailure(); ClearCurrentTestPartResults(); EXPECT_TRUE(has_failure); } TEST(HasFailureTest, ReturnsTrueWhenThereIsNonfatalFailure) { ADD_FAILURE(); const bool has_failure = HasFailure(); ClearCurrentTestPartResults(); EXPECT_TRUE(has_failure); } TEST(HasFailureTest, ReturnsTrueWhenThereAreFatalAndNonfatalFailures) { FailFatally(); ADD_FAILURE(); const bool has_failure = HasFailure(); ClearCurrentTestPartResults(); EXPECT_TRUE(has_failure); } // A wrapper for calling HasFailure outside of a test body. static bool HasFailureHelper() { return testing::Test::HasFailure(); } TEST(HasFailureTest, WorksOutsideOfTestBody) { EXPECT_FALSE(HasFailureHelper()); } TEST(HasFailureTest, WorksOutsideOfTestBody2) { ADD_FAILURE(); const bool has_failure = HasFailureHelper(); ClearCurrentTestPartResults(); EXPECT_TRUE(has_failure); } class TestListener : public EmptyTestEventListener { public: TestListener() : on_start_counter_(NULL), is_destroyed_(NULL) {} TestListener(int* on_start_counter, bool* is_destroyed) : on_start_counter_(on_start_counter), is_destroyed_(is_destroyed) {} virtual ~TestListener() { if (is_destroyed_) *is_destroyed_ = true; } protected: virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) { if (on_start_counter_ != NULL) (*on_start_counter_)++; } private: int* on_start_counter_; bool* is_destroyed_; }; // Tests the constructor. TEST(TestEventListenersTest, ConstructionWorks) { TestEventListeners listeners; EXPECT_TRUE(TestEventListenersAccessor::GetRepeater(&listeners) != NULL); EXPECT_TRUE(listeners.default_result_printer() == NULL); EXPECT_TRUE(listeners.default_xml_generator() == NULL); } // Tests that the TestEventListeners destructor deletes all the listeners it // owns. TEST(TestEventListenersTest, DestructionWorks) { bool default_result_printer_is_destroyed = false; bool default_xml_printer_is_destroyed = false; bool extra_listener_is_destroyed = false; TestListener* default_result_printer = new TestListener( NULL, &default_result_printer_is_destroyed); TestListener* default_xml_printer = new TestListener( NULL, &default_xml_printer_is_destroyed); TestListener* extra_listener = new TestListener( NULL, &extra_listener_is_destroyed); { TestEventListeners listeners; TestEventListenersAccessor::SetDefaultResultPrinter(&listeners, default_result_printer); TestEventListenersAccessor::SetDefaultXmlGenerator(&listeners, default_xml_printer); listeners.Append(extra_listener); } EXPECT_TRUE(default_result_printer_is_destroyed); EXPECT_TRUE(default_xml_printer_is_destroyed); EXPECT_TRUE(extra_listener_is_destroyed); } // Tests that a listener Append'ed to a TestEventListeners list starts // receiving events. TEST(TestEventListenersTest, Append) { int on_start_counter = 0; bool is_destroyed = false; TestListener* listener = new TestListener(&on_start_counter, &is_destroyed); { TestEventListeners listeners; listeners.Append(listener); TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart( *UnitTest::GetInstance()); EXPECT_EQ(1, on_start_counter); } EXPECT_TRUE(is_destroyed); } // Tests that listeners receive events in the order they were appended to // the list, except for *End requests, which must be received in the reverse // order. class SequenceTestingListener : public EmptyTestEventListener { public: SequenceTestingListener(std::vector<std::string>* vector, const char* id) : vector_(vector), id_(id) {} protected: virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) { vector_->push_back(GetEventDescription("OnTestProgramStart")); } virtual void OnTestProgramEnd(const UnitTest& /*unit_test*/) { vector_->push_back(GetEventDescription("OnTestProgramEnd")); } virtual void OnTestIterationStart(const UnitTest& /*unit_test*/, int /*iteration*/) { vector_->push_back(GetEventDescription("OnTestIterationStart")); } virtual void OnTestIterationEnd(const UnitTest& /*unit_test*/, int /*iteration*/) { vector_->push_back(GetEventDescription("OnTestIterationEnd")); } private: std::string GetEventDescription(const char* method) { Message message; message << id_ << "." << method; return message.GetString(); } std::vector<std::string>* vector_; const char* const id_; GTEST_DISALLOW_COPY_AND_ASSIGN_(SequenceTestingListener); }; TEST(EventListenerTest, AppendKeepsOrder) { std::vector<std::string> vec; TestEventListeners listeners; listeners.Append(new SequenceTestingListener(&vec, "1st")); listeners.Append(new SequenceTestingListener(&vec, "2nd")); listeners.Append(new SequenceTestingListener(&vec, "3rd")); TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart( *UnitTest::GetInstance()); ASSERT_EQ(3U, vec.size()); EXPECT_STREQ("1st.OnTestProgramStart", vec[0].c_str()); EXPECT_STREQ("2nd.OnTestProgramStart", vec[1].c_str()); EXPECT_STREQ("3rd.OnTestProgramStart", vec[2].c_str()); vec.clear(); TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramEnd( *UnitTest::GetInstance()); ASSERT_EQ(3U, vec.size()); EXPECT_STREQ("3rd.OnTestProgramEnd", vec[0].c_str()); EXPECT_STREQ("2nd.OnTestProgramEnd", vec[1].c_str()); EXPECT_STREQ("1st.OnTestProgramEnd", vec[2].c_str()); vec.clear(); TestEventListenersAccessor::GetRepeater(&listeners)->OnTestIterationStart( *UnitTest::GetInstance(), 0); ASSERT_EQ(3U, vec.size()); EXPECT_STREQ("1st.OnTestIterationStart", vec[0].c_str()); EXPECT_STREQ("2nd.OnTestIterationStart", vec[1].c_str()); EXPECT_STREQ("3rd.OnTestIterationStart", vec[2].c_str()); vec.clear(); TestEventListenersAccessor::GetRepeater(&listeners)->OnTestIterationEnd( *UnitTest::GetInstance(), 0); ASSERT_EQ(3U, vec.size()); EXPECT_STREQ("3rd.OnTestIterationEnd", vec[0].c_str()); EXPECT_STREQ("2nd.OnTestIterationEnd", vec[1].c_str()); EXPECT_STREQ("1st.OnTestIterationEnd", vec[2].c_str()); } // Tests that a listener removed from a TestEventListeners list stops receiving // events and is not deleted when the list is destroyed. TEST(TestEventListenersTest, Release) { int on_start_counter = 0; bool is_destroyed = false; // Although Append passes the ownership of this object to the list, // the following calls release it, and we need to delete it before the // test ends. TestListener* listener = new TestListener(&on_start_counter, &is_destroyed); { TestEventListeners listeners; listeners.Append(listener); EXPECT_EQ(listener, listeners.Release(listener)); TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart( *UnitTest::GetInstance()); EXPECT_TRUE(listeners.Release(listener) == NULL); } EXPECT_EQ(0, on_start_counter); EXPECT_FALSE(is_destroyed); delete listener; } // Tests that no events are forwarded when event forwarding is disabled. TEST(EventListenerTest, SuppressEventForwarding) { int on_start_counter = 0; TestListener* listener = new TestListener(&on_start_counter, NULL); TestEventListeners listeners; listeners.Append(listener); ASSERT_TRUE(TestEventListenersAccessor::EventForwardingEnabled(listeners)); TestEventListenersAccessor::SuppressEventForwarding(&listeners); ASSERT_FALSE(TestEventListenersAccessor::EventForwardingEnabled(listeners)); TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart( *UnitTest::GetInstance()); EXPECT_EQ(0, on_start_counter); } // Tests that events generated by Google Test are not forwarded in // death test subprocesses. TEST(EventListenerDeathTest, EventsNotForwardedInDeathTestSubprecesses) { EXPECT_DEATH_IF_SUPPORTED({ GTEST_CHECK_(TestEventListenersAccessor::EventForwardingEnabled( *GetUnitTestImpl()->listeners())) << "expected failure";}, "expected failure"); } // Tests that a listener installed via SetDefaultResultPrinter() starts // receiving events and is returned via default_result_printer() and that // the previous default_result_printer is removed from the list and deleted. TEST(EventListenerTest, default_result_printer) { int on_start_counter = 0; bool is_destroyed = false; TestListener* listener = new TestListener(&on_start_counter, &is_destroyed); TestEventListeners listeners; TestEventListenersAccessor::SetDefaultResultPrinter(&listeners, listener); EXPECT_EQ(listener, listeners.default_result_printer()); TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart( *UnitTest::GetInstance()); EXPECT_EQ(1, on_start_counter); // Replacing default_result_printer with something else should remove it // from the list and destroy it. TestEventListenersAccessor::SetDefaultResultPrinter(&listeners, NULL); EXPECT_TRUE(listeners.default_result_printer() == NULL); EXPECT_TRUE(is_destroyed); // After broadcasting an event the counter is still the same, indicating // the listener is not in the list anymore. TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart( *UnitTest::GetInstance()); EXPECT_EQ(1, on_start_counter); } // Tests that the default_result_printer listener stops receiving events // when removed via Release and that is not owned by the list anymore. TEST(EventListenerTest, RemovingDefaultResultPrinterWorks) { int on_start_counter = 0; bool is_destroyed = false; // Although Append passes the ownership of this object to the list, // the following calls release it, and we need to delete it before the // test ends. TestListener* listener = new TestListener(&on_start_counter, &is_destroyed); { TestEventListeners listeners; TestEventListenersAccessor::SetDefaultResultPrinter(&listeners, listener); EXPECT_EQ(listener, listeners.Release(listener)); EXPECT_TRUE(listeners.default_result_printer() == NULL); EXPECT_FALSE(is_destroyed); // Broadcasting events now should not affect default_result_printer. TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart( *UnitTest::GetInstance()); EXPECT_EQ(0, on_start_counter); } // Destroying the list should not affect the listener now, too. EXPECT_FALSE(is_destroyed); delete listener; } // Tests that a listener installed via SetDefaultXmlGenerator() starts // receiving events and is returned via default_xml_generator() and that // the previous default_xml_generator is removed from the list and deleted. TEST(EventListenerTest, default_xml_generator) { int on_start_counter = 0; bool is_destroyed = false; TestListener* listener = new TestListener(&on_start_counter, &is_destroyed); TestEventListeners listeners; TestEventListenersAccessor::SetDefaultXmlGenerator(&listeners, listener); EXPECT_EQ(listener, listeners.default_xml_generator()); TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart( *UnitTest::GetInstance()); EXPECT_EQ(1, on_start_counter); // Replacing default_xml_generator with something else should remove it // from the list and destroy it. TestEventListenersAccessor::SetDefaultXmlGenerator(&listeners, NULL); EXPECT_TRUE(listeners.default_xml_generator() == NULL); EXPECT_TRUE(is_destroyed); // After broadcasting an event the counter is still the same, indicating // the listener is not in the list anymore. TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart( *UnitTest::GetInstance()); EXPECT_EQ(1, on_start_counter); } // Tests that the default_xml_generator listener stops receiving events // when removed via Release and that is not owned by the list anymore. TEST(EventListenerTest, RemovingDefaultXmlGeneratorWorks) { int on_start_counter = 0; bool is_destroyed = false; // Although Append passes the ownership of this object to the list, // the following calls release it, and we need to delete it before the // test ends. TestListener* listener = new TestListener(&on_start_counter, &is_destroyed); { TestEventListeners listeners; TestEventListenersAccessor::SetDefaultXmlGenerator(&listeners, listener); EXPECT_EQ(listener, listeners.Release(listener)); EXPECT_TRUE(listeners.default_xml_generator() == NULL); EXPECT_FALSE(is_destroyed); // Broadcasting events now should not affect default_xml_generator. TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart( *UnitTest::GetInstance()); EXPECT_EQ(0, on_start_counter); } // Destroying the list should not affect the listener now, too. EXPECT_FALSE(is_destroyed); delete listener; } // Sanity tests to ensure that the alternative, verbose spellings of // some of the macros work. We don't test them thoroughly as that // would be quite involved. Since their implementations are // straightforward, and they are rarely used, we'll just rely on the // users to tell us when they are broken. GTEST_TEST(AlternativeNameTest, Works) { // GTEST_TEST is the same as TEST. GTEST_SUCCEED() << "OK"; // GTEST_SUCCEED is the same as SUCCEED. // GTEST_FAIL is the same as FAIL. EXPECT_FATAL_FAILURE(GTEST_FAIL() << "An expected failure", "An expected failure"); // GTEST_ASSERT_XY is the same as ASSERT_XY. GTEST_ASSERT_EQ(0, 0); EXPECT_FATAL_FAILURE(GTEST_ASSERT_EQ(0, 1) << "An expected failure", "An expected failure"); EXPECT_FATAL_FAILURE(GTEST_ASSERT_EQ(1, 0) << "An expected failure", "An expected failure"); GTEST_ASSERT_NE(0, 1); GTEST_ASSERT_NE(1, 0); EXPECT_FATAL_FAILURE(GTEST_ASSERT_NE(0, 0) << "An expected failure", "An expected failure"); GTEST_ASSERT_LE(0, 0); GTEST_ASSERT_LE(0, 1); EXPECT_FATAL_FAILURE(GTEST_ASSERT_LE(1, 0) << "An expected failure", "An expected failure"); GTEST_ASSERT_LT(0, 1); EXPECT_FATAL_FAILURE(GTEST_ASSERT_LT(0, 0) << "An expected failure", "An expected failure"); EXPECT_FATAL_FAILURE(GTEST_ASSERT_LT(1, 0) << "An expected failure", "An expected failure"); GTEST_ASSERT_GE(0, 0); GTEST_ASSERT_GE(1, 0); EXPECT_FATAL_FAILURE(GTEST_ASSERT_GE(0, 1) << "An expected failure", "An expected failure"); GTEST_ASSERT_GT(1, 0); EXPECT_FATAL_FAILURE(GTEST_ASSERT_GT(0, 1) << "An expected failure", "An expected failure"); EXPECT_FATAL_FAILURE(GTEST_ASSERT_GT(1, 1) << "An expected failure", "An expected failure"); } // Tests for internal utilities necessary for implementation of the universal // printing. // FIXME: Find a better home for them. class ConversionHelperBase {}; class ConversionHelperDerived : public ConversionHelperBase {}; // Tests that IsAProtocolMessage<T>::value is a compile-time constant. TEST(IsAProtocolMessageTest, ValueIsCompileTimeConstant) { GTEST_COMPILE_ASSERT_(IsAProtocolMessage<ProtocolMessage>::value, const_true); GTEST_COMPILE_ASSERT_(!IsAProtocolMessage<int>::value, const_false); } // Tests that IsAProtocolMessage<T>::value is true when T is // proto2::Message or a sub-class of it. TEST(IsAProtocolMessageTest, ValueIsTrueWhenTypeIsAProtocolMessage) { EXPECT_TRUE(IsAProtocolMessage< ::proto2::Message>::value); EXPECT_TRUE(IsAProtocolMessage<ProtocolMessage>::value); } // Tests that IsAProtocolMessage<T>::value is false when T is neither // ProtocolMessage nor a sub-class of it. TEST(IsAProtocolMessageTest, ValueIsFalseWhenTypeIsNotAProtocolMessage) { EXPECT_FALSE(IsAProtocolMessage<int>::value); EXPECT_FALSE(IsAProtocolMessage<const ConversionHelperBase>::value); } // Tests that CompileAssertTypesEqual compiles when the type arguments are // equal. TEST(CompileAssertTypesEqual, CompilesWhenTypesAreEqual) { CompileAssertTypesEqual<void, void>(); CompileAssertTypesEqual<int*, int*>(); } // Tests that RemoveReference does not affect non-reference types. TEST(RemoveReferenceTest, DoesNotAffectNonReferenceType) { CompileAssertTypesEqual<int, RemoveReference<int>::type>(); CompileAssertTypesEqual<const char, RemoveReference<const char>::type>(); } // Tests that RemoveReference removes reference from reference types. TEST(RemoveReferenceTest, RemovesReference) { CompileAssertTypesEqual<int, RemoveReference<int&>::type>(); CompileAssertTypesEqual<const char, RemoveReference<const char&>::type>(); } // Tests GTEST_REMOVE_REFERENCE_. template <typename T1, typename T2> void TestGTestRemoveReference() { CompileAssertTypesEqual<T1, GTEST_REMOVE_REFERENCE_(T2)>(); } TEST(RemoveReferenceTest, MacroVersion) { TestGTestRemoveReference<int, int>(); TestGTestRemoveReference<const char, const char&>(); } // Tests that RemoveConst does not affect non-const types. TEST(RemoveConstTest, DoesNotAffectNonConstType) { CompileAssertTypesEqual<int, RemoveConst<int>::type>(); CompileAssertTypesEqual<char&, RemoveConst<char&>::type>(); } // Tests that RemoveConst removes const from const types. TEST(RemoveConstTest, RemovesConst) { CompileAssertTypesEqual<int, RemoveConst<const int>::type>(); CompileAssertTypesEqual<char[2], RemoveConst<const char[2]>::type>(); CompileAssertTypesEqual<char[2][3], RemoveConst<const char[2][3]>::type>(); } // Tests GTEST_REMOVE_CONST_. template <typename T1, typename T2> void TestGTestRemoveConst() { CompileAssertTypesEqual<T1, GTEST_REMOVE_CONST_(T2)>(); } TEST(RemoveConstTest, MacroVersion) { TestGTestRemoveConst<int, int>(); TestGTestRemoveConst<double&, double&>(); TestGTestRemoveConst<char, const char>(); } // Tests GTEST_REMOVE_REFERENCE_AND_CONST_. template <typename T1, typename T2> void TestGTestRemoveReferenceAndConst() { CompileAssertTypesEqual<T1, GTEST_REMOVE_REFERENCE_AND_CONST_(T2)>(); } TEST(RemoveReferenceToConstTest, Works) { TestGTestRemoveReferenceAndConst<int, int>(); TestGTestRemoveReferenceAndConst<double, double&>(); TestGTestRemoveReferenceAndConst<char, const char>(); TestGTestRemoveReferenceAndConst<char, const char&>(); TestGTestRemoveReferenceAndConst<const char*, const char*>(); } // Tests that AddReference does not affect reference types. TEST(AddReferenceTest, DoesNotAffectReferenceType) { CompileAssertTypesEqual<int&, AddReference<int&>::type>(); CompileAssertTypesEqual<const char&, AddReference<const char&>::type>(); } // Tests that AddReference adds reference to non-reference types. TEST(AddReferenceTest, AddsReference) { CompileAssertTypesEqual<int&, AddReference<int>::type>(); CompileAssertTypesEqual<const char&, AddReference<const char>::type>(); } // Tests GTEST_ADD_REFERENCE_. template <typename T1, typename T2> void TestGTestAddReference() { CompileAssertTypesEqual<T1, GTEST_ADD_REFERENCE_(T2)>(); } TEST(AddReferenceTest, MacroVersion) { TestGTestAddReference<int&, int>(); TestGTestAddReference<const char&, const char&>(); } // Tests GTEST_REFERENCE_TO_CONST_. template <typename T1, typename T2> void TestGTestReferenceToConst() { CompileAssertTypesEqual<T1, GTEST_REFERENCE_TO_CONST_(T2)>(); } TEST(GTestReferenceToConstTest, Works) { TestGTestReferenceToConst<const char&, char>(); TestGTestReferenceToConst<const int&, const int>(); TestGTestReferenceToConst<const double&, double>(); TestGTestReferenceToConst<const std::string&, const std::string&>(); } // Tests that ImplicitlyConvertible<T1, T2>::value is a compile-time constant. TEST(ImplicitlyConvertibleTest, ValueIsCompileTimeConstant) { GTEST_COMPILE_ASSERT_((ImplicitlyConvertible<int, int>::value), const_true); GTEST_COMPILE_ASSERT_((!ImplicitlyConvertible<void*, int*>::value), const_false); } // Tests that ImplicitlyConvertible<T1, T2>::value is true when T1 can // be implicitly converted to T2. TEST(ImplicitlyConvertibleTest, ValueIsTrueWhenConvertible) { EXPECT_TRUE((ImplicitlyConvertible<int, double>::value)); EXPECT_TRUE((ImplicitlyConvertible<double, int>::value)); EXPECT_TRUE((ImplicitlyConvertible<int*, void*>::value)); EXPECT_TRUE((ImplicitlyConvertible<int*, const int*>::value)); EXPECT_TRUE((ImplicitlyConvertible<ConversionHelperDerived&, const ConversionHelperBase&>::value)); EXPECT_TRUE((ImplicitlyConvertible<const ConversionHelperBase, ConversionHelperBase>::value)); } // Tests that ImplicitlyConvertible<T1, T2>::value is false when T1 // cannot be implicitly converted to T2. TEST(ImplicitlyConvertibleTest, ValueIsFalseWhenNotConvertible) { EXPECT_FALSE((ImplicitlyConvertible<double, int*>::value)); EXPECT_FALSE((ImplicitlyConvertible<void*, int*>::value)); EXPECT_FALSE((ImplicitlyConvertible<const int*, int*>::value)); EXPECT_FALSE((ImplicitlyConvertible<ConversionHelperBase&, ConversionHelperDerived&>::value)); } // Tests IsContainerTest. class NonContainer {}; TEST(IsContainerTestTest, WorksForNonContainer) { EXPECT_EQ(sizeof(IsNotContainer), sizeof(IsContainerTest<int>(0))); EXPECT_EQ(sizeof(IsNotContainer), sizeof(IsContainerTest<char[5]>(0))); EXPECT_EQ(sizeof(IsNotContainer), sizeof(IsContainerTest<NonContainer>(0))); } TEST(IsContainerTestTest, WorksForContainer) { EXPECT_EQ(sizeof(IsContainer), sizeof(IsContainerTest<std::vector<bool> >(0))); EXPECT_EQ(sizeof(IsContainer), sizeof(IsContainerTest<std::map<int, double> >(0))); } #if GTEST_LANG_CXX11 struct ConstOnlyContainerWithPointerIterator { using const_iterator = int*; const_iterator begin() const; const_iterator end() const; }; struct ConstOnlyContainerWithClassIterator { struct const_iterator { const int& operator*() const; const_iterator& operator++(/* pre-increment */); }; const_iterator begin() const; const_iterator end() const; }; TEST(IsContainerTestTest, ConstOnlyContainer) { EXPECT_EQ(sizeof(IsContainer), sizeof(IsContainerTest<ConstOnlyContainerWithPointerIterator>(0))); EXPECT_EQ(sizeof(IsContainer), sizeof(IsContainerTest<ConstOnlyContainerWithClassIterator>(0))); } #endif // GTEST_LANG_CXX11 // Tests IsHashTable. struct AHashTable { typedef void hasher; }; struct NotReallyAHashTable { typedef void hasher; typedef void reverse_iterator; }; TEST(IsHashTable, Basic) { EXPECT_TRUE(testing::internal::IsHashTable<AHashTable>::value); EXPECT_FALSE(testing::internal::IsHashTable<NotReallyAHashTable>::value); #if GTEST_LANG_CXX11 EXPECT_FALSE(testing::internal::IsHashTable<std::vector<int>>::value); EXPECT_TRUE(testing::internal::IsHashTable<std::unordered_set<int>>::value); #endif // GTEST_LANG_CXX11 #if GTEST_HAS_HASH_SET_ EXPECT_TRUE(testing::internal::IsHashTable<__gnu_cxx::hash_set<int>>::value); #endif // GTEST_HAS_HASH_SET_ } // Tests ArrayEq(). TEST(ArrayEqTest, WorksForDegeneratedArrays) { EXPECT_TRUE(ArrayEq(5, 5L)); EXPECT_FALSE(ArrayEq('a', 0)); } TEST(ArrayEqTest, WorksForOneDimensionalArrays) { // Note that a and b are distinct but compatible types. const int a[] = { 0, 1 }; long b[] = { 0, 1 }; EXPECT_TRUE(ArrayEq(a, b)); EXPECT_TRUE(ArrayEq(a, 2, b)); b[0] = 2; EXPECT_FALSE(ArrayEq(a, b)); EXPECT_FALSE(ArrayEq(a, 1, b)); } TEST(ArrayEqTest, WorksForTwoDimensionalArrays) { const char a[][3] = { "hi", "lo" }; const char b[][3] = { "hi", "lo" }; const char c[][3] = { "hi", "li" }; EXPECT_TRUE(ArrayEq(a, b)); EXPECT_TRUE(ArrayEq(a, 2, b)); EXPECT_FALSE(ArrayEq(a, c)); EXPECT_FALSE(ArrayEq(a, 2, c)); } // Tests ArrayAwareFind(). TEST(ArrayAwareFindTest, WorksForOneDimensionalArray) { const char a[] = "hello"; EXPECT_EQ(a + 4, ArrayAwareFind(a, a + 5, 'o')); EXPECT_EQ(a + 5, ArrayAwareFind(a, a + 5, 'x')); } TEST(ArrayAwareFindTest, WorksForTwoDimensionalArray) { int a[][2] = { { 0, 1 }, { 2, 3 }, { 4, 5 } }; const int b[2] = { 2, 3 }; EXPECT_EQ(a + 1, ArrayAwareFind(a, a + 3, b)); const int c[2] = { 6, 7 }; EXPECT_EQ(a + 3, ArrayAwareFind(a, a + 3, c)); } // Tests CopyArray(). TEST(CopyArrayTest, WorksForDegeneratedArrays) { int n = 0; CopyArray('a', &n); EXPECT_EQ('a', n); } TEST(CopyArrayTest, WorksForOneDimensionalArrays) { const char a[3] = "hi"; int b[3]; #ifndef __BORLANDC__ // C++Builder cannot compile some array size deductions. CopyArray(a, &b); EXPECT_TRUE(ArrayEq(a, b)); #endif int c[3]; CopyArray(a, 3, c); EXPECT_TRUE(ArrayEq(a, c)); } TEST(CopyArrayTest, WorksForTwoDimensionalArrays) { const int a[2][3] = { { 0, 1, 2 }, { 3, 4, 5 } }; int b[2][3]; #ifndef __BORLANDC__ // C++Builder cannot compile some array size deductions. CopyArray(a, &b); EXPECT_TRUE(ArrayEq(a, b)); #endif int c[2][3]; CopyArray(a, 2, c); EXPECT_TRUE(ArrayEq(a, c)); } // Tests NativeArray. TEST(NativeArrayTest, ConstructorFromArrayWorks) { const int a[3] = { 0, 1, 2 }; NativeArray<int> na(a, 3, RelationToSourceReference()); EXPECT_EQ(3U, na.size()); EXPECT_EQ(a, na.begin()); } TEST(NativeArrayTest, CreatesAndDeletesCopyOfArrayWhenAskedTo) { typedef int Array[2]; Array* a = new Array[1]; (*a)[0] = 0; (*a)[1] = 1; NativeArray<int> na(*a, 2, RelationToSourceCopy()); EXPECT_NE(*a, na.begin()); delete[] a; EXPECT_EQ(0, na.begin()[0]); EXPECT_EQ(1, na.begin()[1]); // We rely on the heap checker to verify that na deletes the copy of // array. } TEST(NativeArrayTest, TypeMembersAreCorrect) { StaticAssertTypeEq<char, NativeArray<char>::value_type>(); StaticAssertTypeEq<int[2], NativeArray<int[2]>::value_type>(); StaticAssertTypeEq<const char*, NativeArray<char>::const_iterator>(); StaticAssertTypeEq<const bool(*)[2], NativeArray<bool[2]>::const_iterator>(); } TEST(NativeArrayTest, MethodsWork) { const int a[3] = { 0, 1, 2 }; NativeArray<int> na(a, 3, RelationToSourceCopy()); ASSERT_EQ(3U, na.size()); EXPECT_EQ(3, na.end() - na.begin()); NativeArray<int>::const_iterator it = na.begin(); EXPECT_EQ(0, *it); ++it; EXPECT_EQ(1, *it); it++; EXPECT_EQ(2, *it); ++it; EXPECT_EQ(na.end(), it); EXPECT_TRUE(na == na); NativeArray<int> na2(a, 3, RelationToSourceReference()); EXPECT_TRUE(na == na2); const int b1[3] = { 0, 1, 1 }; const int b2[4] = { 0, 1, 2, 3 }; EXPECT_FALSE(na == NativeArray<int>(b1, 3, RelationToSourceReference())); EXPECT_FALSE(na == NativeArray<int>(b2, 4, RelationToSourceCopy())); } TEST(NativeArrayTest, WorksForTwoDimensionalArray) { const char a[2][3] = { "hi", "lo" }; NativeArray<char[3]> na(a, 2, RelationToSourceReference()); ASSERT_EQ(2U, na.size()); EXPECT_EQ(a, na.begin()); } // Tests SkipPrefix(). TEST(SkipPrefixTest, SkipsWhenPrefixMatches) { const char* const str = "hello"; const char* p = str; EXPECT_TRUE(SkipPrefix("", &p)); EXPECT_EQ(str, p); p = str; EXPECT_TRUE(SkipPrefix("hell", &p)); EXPECT_EQ(str + 4, p); } TEST(SkipPrefixTest, DoesNotSkipWhenPrefixDoesNotMatch) { const char* const str = "world"; const char* p = str; EXPECT_FALSE(SkipPrefix("W", &p)); EXPECT_EQ(str, p); p = str; EXPECT_FALSE(SkipPrefix("world!", &p)); EXPECT_EQ(str, p); } // Tests ad_hoc_test_result(). class AdHocTestResultTest : public testing::Test { protected: static void SetUpTestCase() { FAIL() << "A failure happened inside SetUpTestCase()."; } }; TEST_F(AdHocTestResultTest, AdHocTestResultForTestCaseShowsFailure) { const testing::TestResult& test_result = testing::UnitTest::GetInstance() ->current_test_case() ->ad_hoc_test_result(); EXPECT_TRUE(test_result.Failed()); } TEST_F(AdHocTestResultTest, AdHocTestResultTestForUnitTestDoesNotShowFailure) { const testing::TestResult& test_result = testing::UnitTest::GetInstance()->ad_hoc_test_result(); EXPECT_FALSE(test_result.Failed()); }
// @generated /* A Bison parser, made by GNU Bison 2.4.1. */ /* Skeleton implementation for Bison's Yacc-like parsers in C Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work under terms of your choice, so long as that work isn't itself a parser generator using the skeleton or a modified version thereof as a parser skeleton. Alternatively, if you modify or redistribute the parser skeleton itself, you may (at your option) remove this special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ /* C LALR(1) parser skeleton written by Richard Stallman, by simplifying the original so-called "semantic" parser. */ /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local variables, as they might otherwise be expanded by user macros. There are some unavoidable exceptions within include files to define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ /* Identify Bison output. */ #define YYBISON 1 /* Bison version. */ #define YYBISON_VERSION "2.4.1" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" /* Pure parsers. */ #define YYPURE 1 /* Push parsers. */ #define YYPUSH 0 /* Pull parsers. */ #define YYPULL 1 /* Using locations. */ #define YYLSP_NEEDED 1 /* Substitute the variable and function names. */ #define yyparse Compilerparse #define yylex Compilerlex #define yyerror Compilererror #define yylval Compilerlval #define yychar Compilerchar #define yydebug Compilerdebug #define yynerrs Compilernerrs #define yylloc Compilerlloc /* Copy the first part of user declarations. */ /* Line 189 of yacc.c */ #line 1 "hphp.y" // macros for bison #define YYSTYPE HPHP::HPHP_PARSER_NS::Token #define YYSTYPE_IS_TRIVIAL false #define YYLTYPE HPHP::Location #define YYLTYPE_IS_TRIVIAL true #define YYERROR_VERBOSE #define YYINITDEPTH 500 #define YYLEX_PARAM _p #include "hphp/compiler/parser/parser.h" #include <boost/lexical_cast.hpp> #include "hphp/util/text-util.h" #include "hphp/util/logger.h" #ifdef yyerror #undef yyerror #endif #define yyerror(loc,p,msg) p->parseFatal(loc,msg) #ifdef YYLLOC_DEFAULT # undef YYLLOC_DEFAULT #endif #define YYRHSLOC(Rhs, K) ((Rhs)[K]) #define YYLLOC_DEFAULT(Current, Rhs, N) \ do \ if (N) { \ (Current).first(YYRHSLOC (Rhs, 1)); \ (Current).last (YYRHSLOC (Rhs, N)); \ } else { \ (Current).line0 = (Current).line1 = YYRHSLOC (Rhs, 0).line1; \ (Current).char0 = (Current).char1 = YYRHSLOC (Rhs, 0).char1; \ } \ while (0); \ _p->setRuleLocation(&Current); #define YYCOPY(To, From, Count) \ do { \ YYSIZE_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) { \ (To)[yyi] = (From)[yyi]; \ } \ if (From != From ## a) { \ YYSTACK_FREE (From); \ } \ } \ while (0) #define YYCOPY_RESET(To, From, Count) \ do \ { \ YYSIZE_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) { \ (To)[yyi] = (From)[yyi]; \ (From)[yyi].reset(); \ } \ if (From != From ## a) { \ YYSTACK_FREE (From); \ } \ } \ while (0) #define YYTOKEN_RESET(From, Count) \ do \ { \ YYSIZE_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) { \ (From)[yyi].reset(); \ } \ if (From != From ## a) { \ YYSTACK_FREE (From); \ } \ } \ while (0) # define YYSTACK_RELOCATE_RESET(Stack_alloc, Stack) \ do \ { \ YYSIZE_T yynewbytes; \ YYCOPY_RESET (&yyptr->Stack_alloc, Stack, yysize); \ Stack = &yyptr->Stack_alloc; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ while (0) #define YYSTACK_CLEANUP \ YYTOKEN_RESET (yyvs, yystacksize); \ if (yyvs != yyvsa) { \ YYSTACK_FREE (yyvs); \ } \ if (yyls != yylsa) { \ YYSTACK_FREE (yyls); \ } \ // macros for rules #define BEXP(e...) _p->onBinaryOpExp(e); #define UEXP(e...) _p->onUnaryOpExp(e); using namespace HPHP::HPHP_PARSER_NS; typedef HPHP::ClosureType ClosureType; /////////////////////////////////////////////////////////////////////////////// // helpers static void scalar_num(Parser *_p, Token &out, const char *num) { Token t; t.setText(num); _p->onScalar(out, T_LNUMBER, t); } static void scalar_num(Parser *_p, Token &out, int num) { Token t; t.setText(boost::lexical_cast<std::string>(num)); _p->onScalar(out, T_LNUMBER, t); } static void scalar_null(Parser *_p, Token &out) { Token tnull; tnull.setText("null"); _p->onConstantValue(out, tnull); } static void scalar_file(Parser *_p, Token &out) { Token file; file.setText("__FILE__"); _p->onScalar(out, T_FILE, file); } static void scalar_line(Parser *_p, Token &out) { Token line; line.setText("__LINE__"); _p->onScalar(out, T_LINE, line); } /////////////////////////////////////////////////////////////////////////////// static void constant_ae(Parser *_p, Token &out, Token &value) { const std::string& valueStr = value.text(); if (valueStr.size() < 3 || valueStr.size() > 5 || (strcasecmp("true", valueStr.c_str()) != 0 && strcasecmp("false", valueStr.c_str()) != 0 && strcasecmp("null", valueStr.c_str()) != 0 && strcasecmp("inf", valueStr.c_str()) != 0 && strcasecmp("nan", valueStr.c_str()) != 0)) { HPHP_PARSER_ERROR("User-defined constants are not allowed in user " "attribute expressions", _p); } _p->onConstantValue(out, value); } /////////////////////////////////////////////////////////////////////////////// /** * XHP functions: They are defined here, so different parsers don't have to * handle XHP rules at all. */ static void xhp_tag(Parser *_p, Token &out, Token &label, Token &body) { if (!body.text().empty() && body.text() != label.text()) { HPHP_PARSER_ERROR("XHP: mismatched tag: '%s' not the same as '%s'", _p, body.text().c_str(), label.text().c_str()); } label.xhpLabel(); Token name; _p->onName(name, label, Parser::StringName); _p->onNewObject(out, name, body); } static void xhp_attribute(Parser *_p, Token &out, Token &type, Token &label, Token &def, Token &req) { /** * The bool, int, float, and string typenames are not given any special * treatment by the parser and are treated the same as regular class names * (which initially gets marked as type code 5). However, XHP wants to use * different type codes for bool, int, float, and string, so we need to fix * up the type code here to make XHP happy. */ if (type.num() == 5) { auto* str = type.text().c_str(); if (_p->scanner().isHHSyntaxEnabled()) { switch (type.text().size()) { case 6: if (!strcasecmp(str, "HH\\int")) { type.reset(); type.setNum(3); } break; case 7: if (!strcasecmp(str, "HH\\bool")) { type.reset(); type.setNum(2); } break; case 8: if (!strcasecmp(str, "HH\\float")) { type.reset(); type.setNum(8); } else if (!strcasecmp(str, "HH\\mixed")) { type.reset(); type.setNum(6); } break; case 9: if (!strcasecmp(str, "HH\\string")) { type.reset(); type.setNum(1); } break; default: break; } } else { switch (type.text().size()) { case 3: if (!strcasecmp(str, "int")) { type.reset(); type.setNum(3); } break; case 4: if (!strcasecmp(str, "bool")) { type.reset(); type.setNum(2); } else if (!strcasecmp(str, "real")) { type.reset(); type.setNum(8); } break; case 5: if (!strcasecmp(str, "float")) { type.reset(); type.setNum(8); } else if (!strcasecmp(str, "mixed")) { type.reset(); type.setNum(6); } break; case 6: if (!strcasecmp(str, "string")) { type.reset(); type.setNum(1); } else if (!strcasecmp(str, "double")) { type.reset(); type.setNum(8); } break; case 7: if (!strcasecmp(str, "integer")) { type.reset(); type.setNum(3); } else if (!strcasecmp(str, "boolean")) { type.reset(); type.setNum(2); } break; default: break; } } } Token num; scalar_num(_p, num, type.num()); Token arr1; _p->onArrayPair(arr1, 0, 0, num, 0); Token arr2; switch (type.num()) { case 5: /* class */ { Token cls; _p->onScalar(cls, T_CONSTANT_ENCAPSED_STRING, type); _p->onArrayPair(arr2, &arr1, 0, cls, 0); break; } case 7: /* enum */ { Token arr; _p->onArray(arr, type); _p->onArrayPair(arr2, &arr1, 0, arr, 0); break; } default: { Token tnull; scalar_null(_p, tnull); _p->onArrayPair(arr2, &arr1, 0, tnull, 0); break; } } Token arr3; _p->onArrayPair(arr3, &arr2, 0, def, 0); Token arr4; _p->onArrayPair(arr4, &arr3, 0, req, 0); _p->onArray(out, arr4); out.setText(label); } static void xhp_attribute_list(Parser *_p, Token &out, Token *list, Token &decl) { if (decl.num() == 0) { decl.xhpLabel(); if (list) { out = *list; out.setText(list->text() + ":" + decl.text()); // avoiding vector<string> } else { out.setText(decl); } } else { Token name; _p->onScalar(name, T_CONSTANT_ENCAPSED_STRING, decl); _p->onArrayPair(out, list, &name, decl, 0); if (list) { out.setText(list->text()); } else { out.setText(""); } } } static void xhp_attribute_stmt(Parser *_p, Token &out, Token &attributes) { Token modifiers; Token fname; fname.setText("__xhpAttributeDeclaration"); { Token m; Token m1; m1.setNum(T_PROTECTED); _p->onMemberModifier(m, NULL, m1); Token m2; m2.setNum(T_STATIC); _p->onMemberModifier(modifiers, &m, m2); } _p->pushFuncLocation(); _p->onMethodStart(fname, modifiers); std::vector<std::string> classes; HPHP::split(':', attributes.text().c_str(), classes, true); Token arrAttributes; _p->onArray(arrAttributes, attributes); Token dummy; Token stmts0; { _p->onStatementListStart(stmts0); } Token stmts1; { // static $_ = -1; Token one; scalar_num(_p, one, "1"); Token mone; UEXP(mone, one, '-', 1); Token var; var.set(T_VARIABLE, "_"); Token decl; _p->onStaticVariable(decl, 0, var, &mone); Token sdecl; _p->onStatic(sdecl, decl); _p->addStatement(stmts1, stmts0, sdecl); } Token stmts2; { // if ($_ === -1) { // $_ = array_merge(parent::__xhpAttributeDeclaration(), // attributes); // } Token parent; parent.set(T_STRING, "parent"); Token cls; _p->onName(cls, parent, Parser::StringName); Token fname; fname.setText("__xhpAttributeDeclaration"); Token param1; _p->onCall(param1, 0, fname, dummy, &cls); Token params1; _p->onCallParam(params1, NULL, param1, false, false); for (unsigned int i = 0; i < classes.size(); i++) { Token parent; parent.set(T_STRING, classes[i]); Token cls; _p->onName(cls, parent, Parser::StringName); Token fname; fname.setText("__xhpAttributeDeclaration"); Token param; _p->onCall(param, 0, fname, dummy, &cls); Token params; _p->onCallParam(params, &params1, param, false, false); params1 = params; } Token params2; _p->onCallParam(params2, &params1, arrAttributes, false, false); Token name; name.set(T_STRING, "array_merge"); Token call; _p->onCall(call, 0, name, params2, NULL); Token tvar; tvar.set(T_VARIABLE, "_"); Token var; _p->onSimpleVariable(var, tvar); Token assign; _p->onAssign(assign, var, call, 0); Token exp; _p->onExpStatement(exp, assign); Token block; _p->onBlock(block, exp); Token tvar2; tvar2.set(T_VARIABLE, "_"); Token var2; _p->onSimpleVariable(var2, tvar2); Token one; scalar_num(_p, one, "1"); Token mone; UEXP(mone, one, '-', 1); Token cond; BEXP(cond, var2, mone, T_IS_IDENTICAL); Token dummy1, dummy2; Token sif; _p->onIf(sif, cond, block, dummy1, dummy2); _p->addStatement(stmts2, stmts1, sif); } Token stmts3; { // return $_; Token tvar; tvar.set(T_VARIABLE, "_"); Token var; _p->onSimpleVariable(var, tvar); Token ret; _p->onReturn(ret, &var); _p->addStatement(stmts3, stmts2, ret); } Token stmt; { _p->finishStatement(stmt, stmts3); stmt = 1; } { Token params, ret, ref; ref = 1; _p->onMethod(out, modifiers, ret, ref, fname, params, stmt, nullptr, false); } } static void xhp_collect_attributes(Parser *_p, Token &out, Token &stmts) { Token *attr = _p->xhpGetAttributes(); if (attr) { Token stmt; xhp_attribute_stmt(_p, stmt, *attr); _p->onClassStatement(out, stmts, stmt); } else { out = stmts; } } static void xhp_category_stmt(Parser *_p, Token &out, Token &categories) { Token fname; fname.setText("__xhpCategoryDeclaration"); Token m1; m1.setNum(T_PROTECTED); Token modifiers; _p->onMemberModifier(modifiers, 0, m1); _p->pushFuncLocation(); _p->onMethodStart(fname, modifiers); Token stmts0; { _p->onStatementListStart(stmts0); } Token stmts1; { // static $_ = categories; Token arr; _p->onArray(arr, categories); Token var; var.set(T_VARIABLE, "_"); Token decl; _p->onStaticVariable(decl, 0, var, &arr); Token sdecl; _p->onStatic(sdecl, decl); _p->addStatement(stmts1, stmts0, sdecl); } Token stmts2; { // return $_; Token tvar; tvar.set(T_VARIABLE, "_"); Token var; _p->onSimpleVariable(var, tvar); Token ret; _p->onReturn(ret, &var); _p->addStatement(stmts2, stmts1, ret); } Token stmt; { _p->finishStatement(stmt, stmts2); stmt = 1; } { Token params, ret, ref; ref = 1; _p->onMethod(out, modifiers, ret, ref, fname, params, stmt, nullptr, false); } } static void xhp_children_decl_tag(Parser *_p, Token &arr, Token &tag) { Token num; scalar_num(_p, num, tag.num()); Token arr1; _p->onArrayPair(arr1, &arr, 0, num, 0); Token name; if (tag.num() == 3 || tag.num() == 4) { _p->onScalar(name, T_CONSTANT_ENCAPSED_STRING, tag); } else if (tag.num() >= 0) { scalar_null(_p, name); } else { HPHP_PARSER_ERROR("XHP: unknown children declaration", _p); } Token arr2; _p->onArrayPair(arr2, &arr1, 0, name, 0); arr = arr2; } static void xhp_children_decl(Parser *_p, Token &out, Token &op1, int op, Token *op2) { Token num; scalar_num(_p, num, op); Token arr; _p->onArrayPair(arr, 0, 0, num, 0); if (op2) { Token arr1; _p->onArrayPair(arr1, &arr, 0, op1, 0); Token arr2; _p->onArrayPair(arr2, &arr1, 0, *op2, 0); _p->onArray(out, arr2); } else { xhp_children_decl_tag(_p, arr, op1); _p->onArray(out, arr); } } static void xhp_children_paren(Parser *_p, Token &out, Token exp, int op) { Token num; scalar_num(_p, num, op); Token arr1; _p->onArrayPair(arr1, 0, 0, num, 0); Token num5; scalar_num(_p, num5, 5); Token arr2; _p->onArrayPair(arr2, &arr1, 0, num5, 0); Token arr3; _p->onArrayPair(arr3, &arr2, 0, exp, 0); _p->onArray(out, arr3); } static void xhp_children_stmt(Parser *_p, Token &out, Token &children) { Token fname; fname.setText("__xhpChildrenDeclaration"); Token m1; m1.setNum(T_PROTECTED); Token modifiers; _p->onMemberModifier(modifiers, 0, m1); _p->pushFuncLocation(); _p->onMethodStart(fname, modifiers); Token stmts0; { _p->onStatementListStart(stmts0); } Token stmts1; { // static $_ = children; Token arr; if (children.num() == 2) { arr = children; } else if (children.num() >= 0) { scalar_num(_p, arr, children.num()); } else { HPHP_PARSER_ERROR("XHP: XHP unknown children declaration", _p); } Token var; var.set(T_VARIABLE, "_"); Token decl; _p->onStaticVariable(decl, 0, var, &arr); Token sdecl; _p->onStatic(sdecl, decl); _p->addStatement(stmts1, stmts0, sdecl); } Token stmts2; { // return $_; Token tvar; tvar.set(T_VARIABLE, "_"); Token var; _p->onSimpleVariable(var, tvar); Token ret; _p->onReturn(ret, &var); _p->addStatement(stmts2, stmts1, ret); } Token stmt; { _p->finishStatement(stmt, stmts2); stmt = 1; } { Token params, ret, ref; ref = 1; _p->onMethod(out, modifiers, ret, ref, fname, params, stmt, nullptr, false); } } static void only_in_hh_syntax(Parser *_p) { if (!_p->scanner().isHHSyntaxEnabled()) { HPHP_PARSER_ERROR( "Syntax only allowed with -v Eval.EnableHipHopSyntax=true", _p); } } static void validate_hh_variadic_variant(Parser* _p, Token& userAttrs, Token& typehint, Token* mod) { if (!userAttrs.text().empty() || !typehint.text().empty() || (mod && !mod->text().empty())) { HPHP_PARSER_ERROR("Variadic '...' should be followed by a '$variable'", _p); } only_in_hh_syntax(_p); } // Shapes may not have leading integers in key names, considered as a // parse time error. This is because at runtime they are currently // hphp arrays, which will treat leading integer keys as numbers. static void validate_shape_keyname(Token& tok, Parser* _p) { if (tok.text().empty()) { HPHP_PARSER_ERROR("Shape key names may not be empty", _p); } if (isdigit(tok.text()[0])) { HPHP_PARSER_ERROR("Shape key names may not start with integers", _p); } } /////////////////////////////////////////////////////////////////////////////// static int yylex(YYSTYPE *token, HPHP::Location *loc, Parser *_p) { return _p->scan(token, loc); } /* Line 189 of yacc.c */ #line 644 "hphp.tab.cpp" /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 0 #endif /* Enabling verbose error messages. */ #ifdef YYERROR_VERBOSE # undef YYERROR_VERBOSE # define YYERROR_VERBOSE 1 #else # define YYERROR_VERBOSE 0 #endif /* Enabling the token table. */ #ifndef YYTOKEN_TABLE # define YYTOKEN_TABLE 0 #endif /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE /* Put the tokens into the symbol table, so that GDB and other debuggers know about them. */ enum yytokentype { T_REQUIRE_ONCE = 258, T_REQUIRE = 259, T_EVAL = 260, T_INCLUDE_ONCE = 261, T_INCLUDE = 262, T_LAMBDA_ARROW = 263, T_LOGICAL_OR = 264, T_LOGICAL_XOR = 265, T_LOGICAL_AND = 266, T_PRINT = 267, T_POW_EQUAL = 268, T_SR_EQUAL = 269, T_SL_EQUAL = 270, T_XOR_EQUAL = 271, T_OR_EQUAL = 272, T_AND_EQUAL = 273, T_MOD_EQUAL = 274, T_CONCAT_EQUAL = 275, T_DIV_EQUAL = 276, T_MUL_EQUAL = 277, T_MINUS_EQUAL = 278, T_PLUS_EQUAL = 279, T_YIELD = 280, T_AWAIT = 281, T_BOOLEAN_OR = 282, T_BOOLEAN_AND = 283, T_IS_NOT_IDENTICAL = 284, T_IS_IDENTICAL = 285, T_IS_NOT_EQUAL = 286, T_IS_EQUAL = 287, T_IS_GREATER_OR_EQUAL = 288, T_IS_SMALLER_OR_EQUAL = 289, T_SR = 290, T_SL = 291, T_INSTANCEOF = 292, T_UNSET_CAST = 293, T_BOOL_CAST = 294, T_OBJECT_CAST = 295, T_ARRAY_CAST = 296, T_STRING_CAST = 297, T_DOUBLE_CAST = 298, T_INT_CAST = 299, T_DEC = 300, T_INC = 301, T_POW = 302, T_CLONE = 303, T_NEW = 304, T_EXIT = 305, T_IF = 306, T_ELSEIF = 307, T_ELSE = 308, T_ENDIF = 309, T_LNUMBER = 310, T_DNUMBER = 311, T_ONUMBER = 312, T_STRING = 313, T_STRING_VARNAME = 314, T_VARIABLE = 315, T_NUM_STRING = 316, T_INLINE_HTML = 317, T_CHARACTER = 318, T_BAD_CHARACTER = 319, T_ENCAPSED_AND_WHITESPACE = 320, T_CONSTANT_ENCAPSED_STRING = 321, T_ECHO = 322, T_DO = 323, T_WHILE = 324, T_ENDWHILE = 325, T_FOR = 326, T_ENDFOR = 327, T_FOREACH = 328, T_ENDFOREACH = 329, T_DECLARE = 330, T_ENDDECLARE = 331, T_AS = 332, T_SWITCH = 333, T_ENDSWITCH = 334, T_CASE = 335, T_DEFAULT = 336, T_BREAK = 337, T_GOTO = 338, T_CONTINUE = 339, T_FUNCTION = 340, T_CONST = 341, T_RETURN = 342, T_TRY = 343, T_CATCH = 344, T_THROW = 345, T_USE = 346, T_GLOBAL = 347, T_PUBLIC = 348, T_PROTECTED = 349, T_PRIVATE = 350, T_FINAL = 351, T_ABSTRACT = 352, T_STATIC = 353, T_VAR = 354, T_UNSET = 355, T_ISSET = 356, T_EMPTY = 357, T_HALT_COMPILER = 358, T_CLASS = 359, T_INTERFACE = 360, T_EXTENDS = 361, T_IMPLEMENTS = 362, T_OBJECT_OPERATOR = 363, T_DOUBLE_ARROW = 364, T_LIST = 365, T_ARRAY = 366, T_CALLABLE = 367, T_CLASS_C = 368, T_METHOD_C = 369, T_FUNC_C = 370, T_LINE = 371, T_FILE = 372, T_COMMENT = 373, T_DOC_COMMENT = 374, T_OPEN_TAG = 375, T_OPEN_TAG_WITH_ECHO = 376, T_CLOSE_TAG = 377, T_WHITESPACE = 378, T_START_HEREDOC = 379, T_END_HEREDOC = 380, T_DOLLAR_OPEN_CURLY_BRACES = 381, T_CURLY_OPEN = 382, T_DOUBLE_COLON = 383, T_NAMESPACE = 384, T_NS_C = 385, T_DIR = 386, T_NS_SEPARATOR = 387, T_XHP_LABEL = 388, T_XHP_TEXT = 389, T_XHP_ATTRIBUTE = 390, T_XHP_CATEGORY = 391, T_XHP_CATEGORY_LABEL = 392, T_XHP_CHILDREN = 393, T_ENUM = 394, T_XHP_REQUIRED = 395, T_TRAIT = 396, T_ELLIPSIS = 397, T_INSTEADOF = 398, T_TRAIT_C = 399, T_HH_ERROR = 400, T_FINALLY = 401, T_XHP_TAG_LT = 402, T_XHP_TAG_GT = 403, T_TYPELIST_LT = 404, T_TYPELIST_GT = 405, T_UNRESOLVED_LT = 406, T_COLLECTION = 407, T_SHAPE = 408, T_VARRAY = 409, T_MIARRAY = 410, T_MSARRAY = 411, T_TYPE = 412, T_UNRESOLVED_TYPE = 413, T_NEWTYPE = 414, T_UNRESOLVED_NEWTYPE = 415, T_COMPILER_HALT_OFFSET = 416, T_ASYNC = 417, T_FROM = 418, T_WHERE = 419, T_JOIN = 420, T_IN = 421, T_ON = 422, T_EQUALS = 423, T_INTO = 424, T_LET = 425, T_ORDERBY = 426, T_ASCENDING = 427, T_DESCENDING = 428, T_SELECT = 429, T_GROUP = 430, T_BY = 431, T_LAMBDA_OP = 432, T_LAMBDA_CP = 433, T_UNRESOLVED_OP = 434 }; #endif #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef int YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 #endif #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED typedef struct YYLTYPE { int line0; int char0; int line1; int char1; } YYLTYPE; # define yyltype YYLTYPE /* obsolescent; will be withdrawn */ # define YYLTYPE_IS_DECLARED 1 # define YYLTYPE_IS_TRIVIAL 1 #endif /* Copy the second part of user declarations. */ /* Line 264 of yacc.c */ #line 878 "hphp.tab.cpp" #ifdef short # undef short #endif #ifdef YYTYPE_UINT8 typedef YYTYPE_UINT8 yytype_uint8; #else typedef unsigned char yytype_uint8; #endif #ifdef YYTYPE_INT8 typedef YYTYPE_INT8 yytype_int8; #elif (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) typedef signed char yytype_int8; #else typedef short int yytype_int8; #endif #ifdef YYTYPE_UINT16 typedef YYTYPE_UINT16 yytype_uint16; #else typedef unsigned short int yytype_uint16; #endif #ifdef YYTYPE_INT16 typedef YYTYPE_INT16 yytype_int16; #else typedef short int yytype_int16; #endif #ifndef YYSIZE_T # ifdef __SIZE_TYPE__ # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else # define YYSIZE_T unsigned int # endif #endif #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ # if YYENABLE_NLS # if ENABLE_NLS # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ # define YY_(msgid) dgettext ("bison-runtime", msgid) # endif # endif # ifndef YY_ # define YY_(msgid) msgid # endif #endif /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ # define YYUSE(e) ((void) (e)) #else # define YYUSE(e) /* empty */ #endif /* Identity function, used to suppress warnings about constant conditions. */ #ifndef lint # define YYID(n) (n) #else #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static int YYID (int yyi) #else static int YYID (yyi) int yyi; #endif { return yyi; } #endif #if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ # ifdef YYSTACK_USE_ALLOCA # if YYSTACK_USE_ALLOCA # ifdef __GNUC__ # define YYSTACK_ALLOC __builtin_alloca # elif defined __BUILTIN_VA_ARG_INCR # include <alloca.h> /* INFRINGES ON USER NAME SPACE */ # elif defined _AIX # define YYSTACK_ALLOC __alloca # elif defined _MSC_VER # include <malloc.h> /* INFRINGES ON USER NAME SPACE */ # define alloca _alloca # else # define YYSTACK_ALLOC alloca # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ # ifndef _STDLIB_H # define _STDLIB_H 1 # endif # endif # endif # endif # endif # ifdef YYSTACK_ALLOC /* Pacify GCC's `empty if-body' warning. */ # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) # ifndef YYSTACK_ALLOC_MAXIMUM /* The OS might guarantee only one guard page at the bottom of the stack, and a page size can be as small as 4096 bytes. So we cannot safely invoke alloca (N) if N exceeds 4096. Use a slightly smaller number to allow for a few compiler-allocated temporary stack slots. */ # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ # endif # else # define YYSTACK_ALLOC YYMALLOC # define YYSTACK_FREE YYFREE # ifndef YYSTACK_ALLOC_MAXIMUM # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM # endif # if (defined __cplusplus && ! defined _STDLIB_H \ && ! ((defined YYMALLOC || defined malloc) \ && (defined YYFREE || defined free))) # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ # ifndef _STDLIB_H # define _STDLIB_H 1 # endif # endif # ifndef YYMALLOC # define YYMALLOC malloc # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif # endif #endif /* ! defined yyoverflow || YYERROR_VERBOSE */ #if (! defined yyoverflow \ && (! defined __cplusplus \ || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \ && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ struct yyalloc { yytype_int16 yyss_alloc; YYSTYPE yyvs_alloc; YYLTYPE yyls_alloc; }; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (struct yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ + 2 * YYSTACK_GAP_MAXIMUM) /* Copy COUNT objects from FROM to TO. The source and destination do not overlap. */ # ifndef YYCOPY # if defined __GNUC__ && 1 < __GNUC__ # define YYCOPY(To, From, Count) \ __builtin_memcpy (To, From, (Count) * sizeof (*(From))) # else # define YYCOPY(To, From, Count) \ do \ { \ YYSIZE_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (To)[yyi] = (From)[yyi]; \ } \ while (YYID (0)) # endif # endif /* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ YYSIZE_T yynewbytes; \ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ Stack = &yyptr->Stack_alloc; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ while (YYID (0)) #endif /* YYFINAL -- State number of the termination state. */ #define YYFINAL 3 /* YYLAST -- Last index in YYTABLE. */ #define YYLAST 16601 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 209 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 273 /* YYNRULES -- Number of rules. */ #define YYNRULES 922 /* YYNRULES -- Number of states. */ #define YYNSTATES 1746 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 434 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 52, 207, 2, 204, 51, 35, 208, 199, 200, 49, 46, 9, 47, 48, 50, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 30, 201, 40, 14, 41, 29, 55, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 66, 2, 206, 34, 2, 205, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 202, 33, 203, 54, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 31, 32, 36, 37, 38, 39, 42, 43, 44, 45, 53, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198 }; #if YYDEBUG /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in YYRHS. */ static const yytype_uint16 yyprhs[] = { 0, 0, 3, 4, 7, 10, 11, 13, 15, 17, 19, 21, 23, 28, 32, 33, 40, 41, 47, 51, 56, 61, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 106, 108, 112, 114, 118, 120, 122, 125, 129, 134, 136, 139, 143, 148, 150, 153, 157, 162, 164, 168, 170, 174, 177, 179, 182, 185, 191, 196, 199, 200, 202, 204, 206, 208, 212, 218, 227, 228, 233, 234, 241, 242, 253, 254, 259, 262, 266, 269, 273, 276, 280, 284, 288, 292, 296, 302, 304, 306, 307, 317, 318, 329, 335, 336, 350, 351, 357, 361, 365, 368, 371, 374, 377, 380, 383, 387, 390, 393, 397, 400, 401, 406, 416, 417, 418, 423, 426, 427, 429, 430, 432, 433, 443, 444, 455, 456, 468, 469, 479, 480, 491, 492, 501, 502, 512, 513, 521, 522, 531, 532, 540, 541, 550, 552, 554, 556, 558, 560, 563, 566, 569, 570, 573, 574, 577, 578, 580, 584, 586, 590, 593, 594, 596, 599, 604, 606, 611, 613, 618, 620, 625, 627, 632, 636, 642, 646, 651, 656, 662, 668, 673, 674, 676, 678, 683, 684, 690, 691, 694, 695, 699, 700, 708, 715, 718, 724, 729, 730, 735, 741, 749, 756, 763, 771, 781, 790, 797, 803, 806, 811, 815, 816, 820, 825, 832, 838, 844, 851, 860, 868, 871, 872, 874, 877, 880, 884, 889, 894, 898, 900, 902, 905, 910, 914, 920, 922, 926, 929, 930, 933, 937, 940, 941, 942, 947, 948, 954, 957, 958, 969, 970, 982, 986, 990, 994, 999, 1004, 1008, 1014, 1017, 1020, 1021, 1028, 1034, 1039, 1043, 1045, 1047, 1051, 1056, 1058, 1060, 1062, 1064, 1069, 1071, 1073, 1077, 1080, 1081, 1084, 1085, 1087, 1091, 1093, 1095, 1097, 1099, 1103, 1108, 1113, 1118, 1120, 1122, 1125, 1128, 1131, 1135, 1139, 1141, 1143, 1145, 1147, 1151, 1153, 1157, 1159, 1161, 1163, 1164, 1166, 1169, 1171, 1173, 1175, 1177, 1179, 1181, 1183, 1185, 1186, 1188, 1190, 1192, 1196, 1202, 1204, 1208, 1214, 1219, 1223, 1227, 1230, 1232, 1234, 1238, 1242, 1244, 1246, 1247, 1250, 1255, 1259, 1266, 1269, 1273, 1280, 1282, 1284, 1286, 1293, 1297, 1302, 1309, 1313, 1317, 1321, 1325, 1329, 1333, 1337, 1341, 1345, 1349, 1353, 1357, 1360, 1363, 1366, 1369, 1373, 1377, 1381, 1385, 1389, 1393, 1397, 1401, 1405, 1409, 1413, 1417, 1421, 1425, 1429, 1433, 1437, 1440, 1443, 1446, 1449, 1453, 1457, 1461, 1465, 1469, 1473, 1477, 1481, 1485, 1489, 1495, 1500, 1502, 1505, 1508, 1511, 1514, 1517, 1520, 1523, 1526, 1529, 1531, 1533, 1535, 1537, 1539, 1543, 1546, 1548, 1550, 1552, 1558, 1559, 1560, 1572, 1573, 1586, 1587, 1591, 1592, 1597, 1598, 1605, 1606, 1614, 1617, 1620, 1625, 1627, 1629, 1635, 1639, 1645, 1649, 1652, 1653, 1656, 1657, 1662, 1667, 1671, 1676, 1681, 1686, 1691, 1696, 1701, 1706, 1711, 1716, 1721, 1723, 1725, 1727, 1731, 1734, 1738, 1743, 1746, 1750, 1752, 1755, 1757, 1760, 1762, 1764, 1766, 1768, 1770, 1772, 1777, 1782, 1785, 1794, 1805, 1808, 1810, 1814, 1816, 1819, 1821, 1823, 1825, 1827, 1830, 1835, 1839, 1843, 1848, 1850, 1853, 1858, 1861, 1868, 1869, 1871, 1876, 1877, 1880, 1881, 1883, 1885, 1889, 1891, 1895, 1897, 1899, 1903, 1907, 1909, 1911, 1913, 1915, 1917, 1919, 1921, 1923, 1925, 1927, 1929, 1931, 1933, 1935, 1937, 1939, 1941, 1943, 1945, 1947, 1949, 1951, 1953, 1955, 1957, 1959, 1961, 1963, 1965, 1967, 1969, 1971, 1973, 1975, 1977, 1979, 1981, 1983, 1985, 1987, 1989, 1991, 1993, 1995, 1997, 1999, 2001, 2003, 2005, 2007, 2009, 2011, 2013, 2015, 2017, 2019, 2021, 2023, 2025, 2027, 2029, 2031, 2033, 2035, 2037, 2039, 2041, 2043, 2045, 2047, 2049, 2051, 2053, 2055, 2057, 2059, 2061, 2063, 2065, 2067, 2072, 2074, 2076, 2078, 2080, 2082, 2084, 2086, 2088, 2091, 2093, 2094, 2095, 2097, 2099, 2103, 2104, 2106, 2108, 2110, 2112, 2114, 2116, 2118, 2120, 2122, 2124, 2126, 2128, 2130, 2134, 2137, 2139, 2141, 2146, 2150, 2155, 2157, 2159, 2161, 2163, 2167, 2171, 2175, 2179, 2183, 2187, 2191, 2195, 2199, 2203, 2207, 2211, 2215, 2219, 2223, 2227, 2231, 2235, 2238, 2241, 2244, 2247, 2251, 2255, 2259, 2263, 2267, 2271, 2275, 2279, 2285, 2290, 2294, 2298, 2302, 2304, 2306, 2308, 2310, 2314, 2318, 2322, 2325, 2326, 2328, 2329, 2331, 2332, 2338, 2342, 2346, 2348, 2350, 2352, 2354, 2356, 2360, 2363, 2365, 2367, 2369, 2371, 2373, 2375, 2378, 2381, 2386, 2390, 2395, 2398, 2399, 2405, 2409, 2413, 2415, 2419, 2421, 2424, 2425, 2431, 2435, 2438, 2439, 2443, 2444, 2449, 2452, 2453, 2457, 2461, 2463, 2464, 2466, 2469, 2472, 2477, 2481, 2485, 2488, 2493, 2496, 2501, 2503, 2505, 2507, 2509, 2511, 2514, 2519, 2523, 2528, 2532, 2534, 2536, 2538, 2540, 2543, 2548, 2553, 2557, 2559, 2561, 2565, 2573, 2580, 2589, 2599, 2608, 2619, 2627, 2634, 2643, 2645, 2648, 2653, 2658, 2660, 2662, 2667, 2669, 2670, 2672, 2675, 2677, 2679, 2682, 2687, 2691, 2695, 2696, 2698, 2701, 2706, 2710, 2713, 2717, 2724, 2725, 2727, 2732, 2735, 2736, 2742, 2746, 2750, 2752, 2759, 2764, 2769, 2772, 2775, 2776, 2782, 2786, 2790, 2792, 2795, 2796, 2802, 2806, 2810, 2812, 2815, 2816, 2819, 2820, 2826, 2830, 2834, 2836, 2839, 2840, 2843, 2844, 2850, 2854, 2858, 2860, 2863, 2866, 2868, 2871, 2873, 2878, 2882, 2886, 2893, 2897, 2899, 2901, 2903, 2908, 2913, 2918, 2923, 2926, 2929, 2934, 2937, 2940, 2942, 2946, 2950, 2954, 2955, 2958, 2964, 2971, 2973, 2976, 2978, 2983, 2987, 2988, 2990, 2994, 2997, 3001, 3003, 3005, 3006, 3007, 3010, 3015, 3018, 3025, 3030, 3032, 3034, 3035, 3039, 3045, 3049, 3051, 3054, 3055, 3060, 3063, 3066, 3068, 3070, 3072, 3074, 3079, 3086, 3088, 3097, 3104, 3106 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int16 yyrhs[] = { 210, 0, -1, -1, 211, 212, -1, 212, 213, -1, -1, 231, -1, 248, -1, 255, -1, 252, -1, 260, -1, 466, -1, 122, 199, 200, 201, -1, 148, 223, 201, -1, -1, 148, 223, 202, 214, 212, 203, -1, -1, 148, 202, 215, 212, 203, -1, 110, 217, 201, -1, 110, 104, 218, 201, -1, 110, 105, 219, 201, -1, 228, 201, -1, 77, -1, 154, -1, 155, -1, 157, -1, 159, -1, 158, -1, 183, -1, 184, -1, 186, -1, 185, -1, 187, -1, 188, -1, 189, -1, 190, -1, 191, -1, 192, -1, 193, -1, 194, -1, 195, -1, 217, 9, 220, -1, 220, -1, 221, 9, 221, -1, 221, -1, 222, 9, 222, -1, 222, -1, 223, -1, 151, 223, -1, 223, 96, 216, -1, 151, 223, 96, 216, -1, 223, -1, 151, 223, -1, 223, 96, 216, -1, 151, 223, 96, 216, -1, 223, -1, 151, 223, -1, 223, 96, 216, -1, 151, 223, 96, 216, -1, 216, -1, 223, 151, 216, -1, 223, -1, 148, 151, 223, -1, 151, 223, -1, 224, -1, 224, 469, -1, 224, 469, -1, 228, 9, 467, 14, 405, -1, 105, 467, 14, 405, -1, 229, 230, -1, -1, 231, -1, 248, -1, 255, -1, 260, -1, 202, 229, 203, -1, 70, 331, 231, 282, 284, -1, 70, 331, 30, 229, 283, 285, 73, 201, -1, -1, 88, 331, 232, 276, -1, -1, 87, 233, 231, 88, 331, 201, -1, -1, 90, 199, 333, 201, 333, 201, 333, 200, 234, 274, -1, -1, 97, 331, 235, 279, -1, 101, 201, -1, 101, 340, 201, -1, 103, 201, -1, 103, 340, 201, -1, 106, 201, -1, 106, 340, 201, -1, 27, 101, 201, -1, 111, 292, 201, -1, 117, 294, 201, -1, 86, 332, 201, -1, 119, 199, 463, 200, 201, -1, 201, -1, 81, -1, -1, 92, 199, 340, 96, 273, 272, 200, 236, 275, -1, -1, 92, 199, 340, 28, 96, 273, 272, 200, 237, 275, -1, 94, 199, 278, 200, 277, -1, -1, 107, 240, 108, 199, 398, 79, 200, 202, 229, 203, 242, 238, 245, -1, -1, 107, 240, 165, 239, 243, -1, 109, 340, 201, -1, 102, 216, 201, -1, 340, 201, -1, 334, 201, -1, 335, 201, -1, 336, 201, -1, 337, 201, -1, 338, 201, -1, 106, 337, 201, -1, 339, 201, -1, 368, 201, -1, 106, 367, 201, -1, 216, 30, -1, -1, 202, 241, 229, 203, -1, 242, 108, 199, 398, 79, 200, 202, 229, 203, -1, -1, -1, 202, 244, 229, 203, -1, 165, 243, -1, -1, 35, -1, -1, 104, -1, -1, 247, 246, 468, 249, 199, 288, 200, 473, 320, -1, -1, 324, 247, 246, 468, 250, 199, 288, 200, 473, 320, -1, -1, 425, 323, 247, 246, 468, 251, 199, 288, 200, 473, 320, -1, -1, 158, 216, 253, 30, 480, 465, 202, 295, 203, -1, -1, 425, 158, 216, 254, 30, 480, 465, 202, 295, 203, -1, -1, 266, 263, 256, 267, 268, 202, 298, 203, -1, -1, 425, 266, 263, 257, 267, 268, 202, 298, 203, -1, -1, 124, 264, 258, 269, 202, 298, 203, -1, -1, 425, 124, 264, 259, 269, 202, 298, 203, -1, -1, 160, 265, 261, 268, 202, 298, 203, -1, -1, 425, 160, 265, 262, 268, 202, 298, 203, -1, 468, -1, 152, -1, 468, -1, 468, -1, 123, -1, 116, 123, -1, 115, 123, -1, 125, 398, -1, -1, 126, 270, -1, -1, 125, 270, -1, -1, 398, -1, 270, 9, 398, -1, 398, -1, 271, 9, 398, -1, 128, 273, -1, -1, 432, -1, 35, 432, -1, 129, 199, 444, 200, -1, 231, -1, 30, 229, 91, 201, -1, 231, -1, 30, 229, 93, 201, -1, 231, -1, 30, 229, 89, 201, -1, 231, -1, 30, 229, 95, 201, -1, 216, 14, 405, -1, 278, 9, 216, 14, 405, -1, 202, 280, 203, -1, 202, 201, 280, 203, -1, 30, 280, 98, 201, -1, 30, 201, 280, 98, 201, -1, 280, 99, 340, 281, 229, -1, 280, 100, 281, 229, -1, -1, 30, -1, 201, -1, 282, 71, 331, 231, -1, -1, 283, 71, 331, 30, 229, -1, -1, 72, 231, -1, -1, 72, 30, 229, -1, -1, 287, 9, 426, 326, 481, 161, 79, -1, 287, 9, 426, 326, 481, 161, -1, 287, 410, -1, 426, 326, 481, 161, 79, -1, 426, 326, 481, 161, -1, -1, 426, 326, 481, 79, -1, 426, 326, 481, 35, 79, -1, 426, 326, 481, 35, 79, 14, 405, -1, 426, 326, 481, 79, 14, 405, -1, 287, 9, 426, 326, 481, 79, -1, 287, 9, 426, 326, 481, 35, 79, -1, 287, 9, 426, 326, 481, 35, 79, 14, 405, -1, 287, 9, 426, 326, 481, 79, 14, 405, -1, 289, 9, 426, 481, 161, 79, -1, 289, 9, 426, 481, 161, -1, 289, 410, -1, 426, 481, 161, 79, -1, 426, 481, 161, -1, -1, 426, 481, 79, -1, 426, 481, 35, 79, -1, 426, 481, 35, 79, 14, 405, -1, 426, 481, 79, 14, 405, -1, 289, 9, 426, 481, 79, -1, 289, 9, 426, 481, 35, 79, -1, 289, 9, 426, 481, 35, 79, 14, 405, -1, 289, 9, 426, 481, 79, 14, 405, -1, 291, 410, -1, -1, 340, -1, 35, 432, -1, 161, 340, -1, 291, 9, 340, -1, 291, 9, 161, 340, -1, 291, 9, 35, 432, -1, 292, 9, 293, -1, 293, -1, 79, -1, 204, 432, -1, 204, 202, 340, 203, -1, 294, 9, 79, -1, 294, 9, 79, 14, 405, -1, 79, -1, 79, 14, 405, -1, 295, 296, -1, -1, 297, 201, -1, 467, 14, 405, -1, 298, 299, -1, -1, -1, 322, 300, 328, 201, -1, -1, 324, 480, 301, 328, 201, -1, 329, 201, -1, -1, 323, 247, 246, 468, 199, 302, 286, 200, 473, 321, -1, -1, 425, 323, 247, 246, 468, 199, 303, 286, 200, 473, 321, -1, 154, 308, 201, -1, 155, 314, 201, -1, 157, 316, 201, -1, 4, 125, 398, 201, -1, 4, 126, 398, 201, -1, 110, 271, 201, -1, 110, 271, 202, 304, 203, -1, 304, 305, -1, 304, 306, -1, -1, 227, 147, 216, 162, 271, 201, -1, 307, 96, 323, 216, 201, -1, 307, 96, 324, 201, -1, 227, 147, 216, -1, 216, -1, 309, -1, 308, 9, 309, -1, 310, 395, 312, 313, -1, 152, -1, 130, -1, 398, -1, 118, -1, 158, 202, 311, 203, -1, 131, -1, 404, -1, 311, 9, 404, -1, 14, 405, -1, -1, 55, 159, -1, -1, 315, -1, 314, 9, 315, -1, 156, -1, 317, -1, 216, -1, 121, -1, 199, 318, 200, -1, 199, 318, 200, 49, -1, 199, 318, 200, 29, -1, 199, 318, 200, 46, -1, 317, -1, 319, -1, 319, 49, -1, 319, 29, -1, 319, 46, -1, 318, 9, 318, -1, 318, 33, 318, -1, 216, -1, 152, -1, 156, -1, 201, -1, 202, 229, 203, -1, 201, -1, 202, 229, 203, -1, 324, -1, 118, -1, 324, -1, -1, 325, -1, 324, 325, -1, 112, -1, 113, -1, 114, -1, 117, -1, 116, -1, 115, -1, 181, -1, 327, -1, -1, 112, -1, 113, -1, 114, -1, 328, 9, 79, -1, 328, 9, 79, 14, 405, -1, 79, -1, 79, 14, 405, -1, 329, 9, 467, 14, 405, -1, 105, 467, 14, 405, -1, 199, 330, 200, -1, 68, 400, 403, -1, 67, 340, -1, 387, -1, 359, -1, 199, 340, 200, -1, 332, 9, 340, -1, 340, -1, 332, -1, -1, 27, 340, -1, 27, 340, 128, 340, -1, 432, 14, 334, -1, 129, 199, 444, 200, 14, 334, -1, 28, 340, -1, 432, 14, 337, -1, 129, 199, 444, 200, 14, 337, -1, 341, -1, 432, -1, 330, -1, 129, 199, 444, 200, 14, 340, -1, 432, 14, 340, -1, 432, 14, 35, 432, -1, 432, 14, 35, 68, 400, 403, -1, 432, 26, 340, -1, 432, 25, 340, -1, 432, 24, 340, -1, 432, 23, 340, -1, 432, 22, 340, -1, 432, 21, 340, -1, 432, 20, 340, -1, 432, 19, 340, -1, 432, 18, 340, -1, 432, 17, 340, -1, 432, 16, 340, -1, 432, 15, 340, -1, 432, 64, -1, 64, 432, -1, 432, 63, -1, 63, 432, -1, 340, 31, 340, -1, 340, 32, 340, -1, 340, 10, 340, -1, 340, 12, 340, -1, 340, 11, 340, -1, 340, 33, 340, -1, 340, 35, 340, -1, 340, 34, 340, -1, 340, 48, 340, -1, 340, 46, 340, -1, 340, 47, 340, -1, 340, 49, 340, -1, 340, 50, 340, -1, 340, 65, 340, -1, 340, 51, 340, -1, 340, 45, 340, -1, 340, 44, 340, -1, 46, 340, -1, 47, 340, -1, 52, 340, -1, 54, 340, -1, 340, 37, 340, -1, 340, 36, 340, -1, 340, 39, 340, -1, 340, 38, 340, -1, 340, 40, 340, -1, 340, 43, 340, -1, 340, 41, 340, -1, 340, 42, 340, -1, 340, 53, 400, -1, 199, 341, 200, -1, 340, 29, 340, 30, 340, -1, 340, 29, 30, 340, -1, 462, -1, 62, 340, -1, 61, 340, -1, 60, 340, -1, 59, 340, -1, 58, 340, -1, 57, 340, -1, 56, 340, -1, 69, 401, -1, 55, 340, -1, 407, -1, 358, -1, 357, -1, 360, -1, 361, -1, 205, 402, 205, -1, 13, 340, -1, 343, -1, 346, -1, 365, -1, 110, 199, 386, 410, 200, -1, -1, -1, 247, 246, 199, 344, 288, 200, 473, 342, 202, 229, 203, -1, -1, 324, 247, 246, 199, 345, 288, 200, 473, 342, 202, 229, 203, -1, -1, 79, 347, 351, -1, -1, 181, 79, 348, 351, -1, -1, 196, 349, 288, 197, 473, 351, -1, -1, 181, 196, 350, 288, 197, 473, 351, -1, 8, 340, -1, 8, 337, -1, 8, 202, 229, 203, -1, 85, -1, 464, -1, 353, 9, 352, 128, 340, -1, 352, 128, 340, -1, 354, 9, 352, 128, 405, -1, 352, 128, 405, -1, 353, 409, -1, -1, 354, 409, -1, -1, 172, 199, 355, 200, -1, 130, 199, 445, 200, -1, 66, 445, 206, -1, 398, 202, 447, 203, -1, 174, 199, 451, 200, -1, 175, 199, 451, 200, -1, 173, 199, 452, 200, -1, 174, 199, 455, 200, -1, 175, 199, 455, 200, -1, 173, 199, 456, 200, -1, 398, 202, 449, 203, -1, 365, 66, 440, 206, -1, 366, 66, 440, 206, -1, 358, -1, 464, -1, 85, -1, 199, 341, 200, -1, 369, 370, -1, 432, 14, 367, -1, 182, 79, 185, 340, -1, 371, 382, -1, 371, 382, 385, -1, 382, -1, 382, 385, -1, 372, -1, 371, 372, -1, 373, -1, 374, -1, 375, -1, 376, -1, 377, -1, 378, -1, 182, 79, 185, 340, -1, 189, 79, 14, 340, -1, 183, 340, -1, 184, 79, 185, 340, 186, 340, 187, 340, -1, 184, 79, 185, 340, 186, 340, 187, 340, 188, 79, -1, 190, 379, -1, 380, -1, 379, 9, 380, -1, 340, -1, 340, 381, -1, 191, -1, 192, -1, 383, -1, 384, -1, 193, 340, -1, 194, 340, 195, 340, -1, 188, 79, 370, -1, 386, 9, 79, -1, 386, 9, 35, 79, -1, 79, -1, 35, 79, -1, 166, 152, 388, 167, -1, 390, 50, -1, 390, 167, 391, 166, 50, 389, -1, -1, 152, -1, 390, 392, 14, 393, -1, -1, 391, 394, -1, -1, 152, -1, 153, -1, 202, 340, 203, -1, 153, -1, 202, 340, 203, -1, 387, -1, 396, -1, 395, 30, 396, -1, 395, 47, 396, -1, 216, -1, 69, -1, 104, -1, 105, -1, 106, -1, 27, -1, 28, -1, 107, -1, 108, -1, 165, -1, 109, -1, 70, -1, 71, -1, 73, -1, 72, -1, 88, -1, 89, -1, 87, -1, 90, -1, 91, -1, 92, -1, 93, -1, 94, -1, 95, -1, 53, -1, 96, -1, 97, -1, 98, -1, 99, -1, 100, -1, 101, -1, 103, -1, 102, -1, 86, -1, 13, -1, 123, -1, 124, -1, 125, -1, 126, -1, 68, -1, 67, -1, 118, -1, 5, -1, 7, -1, 6, -1, 4, -1, 3, -1, 148, -1, 110, -1, 111, -1, 120, -1, 121, -1, 122, -1, 117, -1, 116, -1, 115, -1, 114, -1, 113, -1, 112, -1, 181, -1, 119, -1, 129, -1, 130, -1, 10, -1, 12, -1, 11, -1, 132, -1, 134, -1, 133, -1, 135, -1, 136, -1, 150, -1, 149, -1, 180, -1, 160, -1, 163, -1, 162, -1, 176, -1, 178, -1, 172, -1, 226, 199, 290, 200, -1, 227, -1, 152, -1, 398, -1, 117, -1, 438, -1, 398, -1, 117, -1, 442, -1, 199, 200, -1, 331, -1, -1, -1, 84, -1, 459, -1, 199, 290, 200, -1, -1, 74, -1, 75, -1, 76, -1, 85, -1, 135, -1, 136, -1, 150, -1, 132, -1, 163, -1, 133, -1, 134, -1, 149, -1, 180, -1, 143, 84, 144, -1, 143, 144, -1, 404, -1, 225, -1, 130, 199, 408, 200, -1, 66, 408, 206, -1, 172, 199, 356, 200, -1, 406, -1, 364, -1, 362, -1, 363, -1, 199, 405, 200, -1, 405, 31, 405, -1, 405, 32, 405, -1, 405, 10, 405, -1, 405, 12, 405, -1, 405, 11, 405, -1, 405, 33, 405, -1, 405, 35, 405, -1, 405, 34, 405, -1, 405, 48, 405, -1, 405, 46, 405, -1, 405, 47, 405, -1, 405, 49, 405, -1, 405, 50, 405, -1, 405, 51, 405, -1, 405, 45, 405, -1, 405, 44, 405, -1, 405, 65, 405, -1, 52, 405, -1, 54, 405, -1, 46, 405, -1, 47, 405, -1, 405, 37, 405, -1, 405, 36, 405, -1, 405, 39, 405, -1, 405, 38, 405, -1, 405, 40, 405, -1, 405, 43, 405, -1, 405, 41, 405, -1, 405, 42, 405, -1, 405, 29, 405, 30, 405, -1, 405, 29, 30, 405, -1, 227, 147, 216, -1, 152, 147, 216, -1, 227, 147, 123, -1, 225, -1, 78, -1, 464, -1, 404, -1, 207, 459, 207, -1, 208, 459, 208, -1, 143, 459, 144, -1, 411, 409, -1, -1, 9, -1, -1, 9, -1, -1, 411, 9, 405, 128, 405, -1, 411, 9, 405, -1, 405, 128, 405, -1, 405, -1, 74, -1, 75, -1, 76, -1, 85, -1, 143, 84, 144, -1, 143, 144, -1, 74, -1, 75, -1, 76, -1, 216, -1, 412, -1, 216, -1, 46, 413, -1, 47, 413, -1, 130, 199, 415, 200, -1, 66, 415, 206, -1, 172, 199, 418, 200, -1, 416, 409, -1, -1, 416, 9, 414, 128, 414, -1, 416, 9, 414, -1, 414, 128, 414, -1, 414, -1, 417, 9, 414, -1, 414, -1, 419, 409, -1, -1, 419, 9, 352, 128, 414, -1, 352, 128, 414, -1, 417, 409, -1, -1, 199, 420, 200, -1, -1, 422, 9, 216, 421, -1, 216, 421, -1, -1, 424, 422, 409, -1, 45, 423, 44, -1, 425, -1, -1, 428, -1, 127, 437, -1, 127, 216, -1, 127, 202, 340, 203, -1, 66, 440, 206, -1, 202, 340, 203, -1, 433, 429, -1, 199, 330, 200, 429, -1, 443, 429, -1, 199, 330, 200, 429, -1, 437, -1, 397, -1, 435, -1, 436, -1, 430, -1, 432, 427, -1, 199, 330, 200, 427, -1, 399, 147, 437, -1, 434, 199, 290, 200, -1, 199, 432, 200, -1, 397, -1, 435, -1, 436, -1, 430, -1, 432, 428, -1, 199, 330, 200, 428, -1, 434, 199, 290, 200, -1, 199, 432, 200, -1, 437, -1, 430, -1, 199, 432, 200, -1, 432, 127, 216, 469, 199, 290, 200, -1, 432, 127, 437, 199, 290, 200, -1, 432, 127, 202, 340, 203, 199, 290, 200, -1, 199, 330, 200, 127, 216, 469, 199, 290, 200, -1, 199, 330, 200, 127, 437, 199, 290, 200, -1, 199, 330, 200, 127, 202, 340, 203, 199, 290, 200, -1, 399, 147, 216, 469, 199, 290, 200, -1, 399, 147, 437, 199, 290, 200, -1, 399, 147, 202, 340, 203, 199, 290, 200, -1, 438, -1, 441, 438, -1, 438, 66, 440, 206, -1, 438, 202, 340, 203, -1, 439, -1, 79, -1, 204, 202, 340, 203, -1, 340, -1, -1, 204, -1, 441, 204, -1, 437, -1, 431, -1, 442, 427, -1, 199, 330, 200, 427, -1, 399, 147, 437, -1, 199, 432, 200, -1, -1, 431, -1, 442, 428, -1, 199, 330, 200, 428, -1, 199, 432, 200, -1, 444, 9, -1, 444, 9, 432, -1, 444, 9, 129, 199, 444, 200, -1, -1, 432, -1, 129, 199, 444, 200, -1, 446, 409, -1, -1, 446, 9, 340, 128, 340, -1, 446, 9, 340, -1, 340, 128, 340, -1, 340, -1, 446, 9, 340, 128, 35, 432, -1, 446, 9, 35, 432, -1, 340, 128, 35, 432, -1, 35, 432, -1, 448, 409, -1, -1, 448, 9, 340, 128, 340, -1, 448, 9, 340, -1, 340, 128, 340, -1, 340, -1, 450, 409, -1, -1, 450, 9, 405, 128, 405, -1, 450, 9, 405, -1, 405, 128, 405, -1, 405, -1, 453, 409, -1, -1, 454, 409, -1, -1, 453, 9, 340, 128, 340, -1, 340, 128, 340, -1, 454, 9, 340, -1, 340, -1, 457, 409, -1, -1, 458, 409, -1, -1, 457, 9, 405, 128, 405, -1, 405, 128, 405, -1, 458, 9, 405, -1, 405, -1, 459, 460, -1, 459, 84, -1, 460, -1, 84, 460, -1, 79, -1, 79, 66, 461, 206, -1, 79, 127, 216, -1, 145, 340, 203, -1, 145, 78, 66, 340, 206, 203, -1, 146, 432, 203, -1, 216, -1, 80, -1, 79, -1, 120, 199, 463, 200, -1, 121, 199, 432, 200, -1, 121, 199, 341, 200, -1, 121, 199, 330, 200, -1, 7, 340, -1, 6, 340, -1, 5, 199, 340, 200, -1, 4, 340, -1, 3, 340, -1, 432, -1, 463, 9, 432, -1, 399, 147, 216, -1, 399, 147, 123, -1, -1, 96, 480, -1, 176, 468, 14, 480, 201, -1, 178, 468, 465, 14, 480, 201, -1, 216, -1, 480, 216, -1, 216, -1, 216, 168, 474, 169, -1, 168, 471, 169, -1, -1, 480, -1, 470, 9, 480, -1, 470, 409, -1, 470, 9, 161, -1, 471, -1, 161, -1, -1, -1, 30, 480, -1, 474, 9, 475, 216, -1, 475, 216, -1, 474, 9, 475, 216, 96, 480, -1, 475, 216, 96, 480, -1, 46, -1, 47, -1, -1, 85, 128, 480, -1, 227, 147, 216, 128, 480, -1, 477, 9, 476, -1, 476, -1, 477, 409, -1, -1, 172, 199, 478, 200, -1, 29, 480, -1, 55, 480, -1, 227, -1, 130, -1, 131, -1, 479, -1, 130, 168, 480, 169, -1, 130, 168, 480, 9, 480, 169, -1, 152, -1, 199, 104, 199, 472, 200, 30, 480, 200, -1, 199, 480, 9, 470, 409, 200, -1, 480, -1, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { 0, 733, 733, 733, 742, 744, 747, 748, 749, 750, 751, 752, 753, 756, 758, 758, 760, 760, 762, 763, 765, 767, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 794, 796, 800, 802, 806, 808, 812, 813, 814, 815, 820, 821, 822, 823, 828, 829, 830, 831, 836, 837, 841, 842, 844, 847, 853, 860, 867, 871, 877, 879, 882, 883, 884, 885, 888, 889, 893, 898, 898, 904, 904, 911, 910, 916, 916, 921, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 933, 936, 934, 943, 941, 948, 956, 950, 960, 958, 962, 963, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 985, 985, 990, 996, 1000, 1000, 1008, 1009, 1013, 1014, 1018, 1023, 1022, 1035, 1033, 1047, 1045, 1061, 1060, 1069, 1067, 1079, 1078, 1097, 1095, 1114, 1113, 1122, 1120, 1132, 1131, 1143, 1141, 1154, 1155, 1159, 1162, 1165, 1166, 1167, 1170, 1172, 1175, 1176, 1179, 1180, 1183, 1184, 1188, 1189, 1194, 1195, 1198, 1199, 1200, 1204, 1205, 1209, 1210, 1214, 1215, 1219, 1220, 1225, 1226, 1231, 1232, 1233, 1234, 1237, 1240, 1242, 1245, 1246, 1250, 1252, 1255, 1258, 1261, 1262, 1265, 1266, 1270, 1276, 1283, 1285, 1290, 1296, 1300, 1304, 1308, 1313, 1318, 1323, 1328, 1334, 1343, 1348, 1354, 1356, 1360, 1365, 1369, 1372, 1375, 1379, 1383, 1387, 1391, 1396, 1404, 1406, 1409, 1410, 1411, 1412, 1414, 1416, 1421, 1422, 1425, 1426, 1427, 1431, 1432, 1434, 1435, 1439, 1441, 1444, 1448, 1454, 1456, 1459, 1459, 1463, 1462, 1466, 1470, 1468, 1483, 1480, 1493, 1495, 1497, 1499, 1501, 1503, 1505, 1509, 1510, 1511, 1514, 1520, 1523, 1529, 1532, 1537, 1539, 1544, 1549, 1553, 1554, 1560, 1561, 1563, 1567, 1568, 1573, 1574, 1578, 1579, 1583, 1585, 1591, 1596, 1597, 1599, 1603, 1604, 1605, 1606, 1610, 1611, 1612, 1613, 1614, 1615, 1617, 1622, 1625, 1626, 1630, 1631, 1635, 1636, 1639, 1640, 1643, 1644, 1647, 1648, 1652, 1653, 1654, 1655, 1656, 1657, 1658, 1662, 1663, 1666, 1667, 1668, 1671, 1673, 1675, 1676, 1679, 1681, 1686, 1687, 1689, 1690, 1691, 1694, 1698, 1699, 1703, 1704, 1708, 1709, 1713, 1717, 1722, 1726, 1730, 1735, 1736, 1737, 1740, 1742, 1743, 1744, 1747, 1748, 1749, 1750, 1751, 1752, 1753, 1754, 1755, 1756, 1757, 1758, 1759, 1760, 1761, 1762, 1763, 1764, 1765, 1766, 1767, 1768, 1769, 1770, 1771, 1772, 1773, 1774, 1775, 1776, 1777, 1778, 1779, 1780, 1781, 1782, 1783, 1784, 1785, 1786, 1787, 1788, 1789, 1791, 1792, 1794, 1796, 1797, 1798, 1799, 1800, 1801, 1802, 1803, 1804, 1805, 1806, 1807, 1808, 1809, 1810, 1811, 1812, 1813, 1814, 1815, 1816, 1817, 1818, 1822, 1826, 1831, 1830, 1845, 1843, 1860, 1860, 1876, 1875, 1893, 1893, 1909, 1908, 1929, 1930, 1931, 1936, 1938, 1942, 1946, 1952, 1956, 1962, 1964, 1968, 1970, 1974, 1978, 1979, 1983, 1990, 1991, 1995, 1999, 2001, 2006, 2011, 2018, 2020, 2025, 2026, 2027, 2029, 2033, 2037, 2041, 2045, 2047, 2049, 2051, 2056, 2057, 2062, 2063, 2064, 2065, 2066, 2067, 2071, 2075, 2079, 2083, 2088, 2093, 2097, 2098, 2102, 2103, 2107, 2108, 2112, 2113, 2117, 2121, 2125, 2129, 2130, 2131, 2132, 2136, 2142, 2151, 2164, 2165, 2168, 2171, 2174, 2175, 2178, 2182, 2185, 2188, 2195, 2196, 2200, 2201, 2203, 2207, 2208, 2209, 2210, 2211, 2212, 2213, 2214, 2215, 2216, 2217, 2218, 2219, 2220, 2221, 2222, 2223, 2224, 2225, 2226, 2227, 2228, 2229, 2230, 2231, 2232, 2233, 2234, 2235, 2236, 2237, 2238, 2239, 2240, 2241, 2242, 2243, 2244, 2245, 2246, 2247, 2248, 2249, 2250, 2251, 2252, 2253, 2254, 2255, 2256, 2257, 2258, 2259, 2260, 2261, 2262, 2263, 2264, 2265, 2266, 2267, 2268, 2269, 2270, 2271, 2272, 2273, 2274, 2275, 2276, 2277, 2278, 2279, 2280, 2281, 2282, 2283, 2284, 2285, 2286, 2290, 2295, 2296, 2299, 2300, 2301, 2305, 2306, 2307, 2311, 2312, 2313, 2317, 2318, 2319, 2322, 2324, 2328, 2329, 2330, 2331, 2333, 2334, 2335, 2336, 2337, 2338, 2339, 2340, 2341, 2342, 2345, 2350, 2351, 2352, 2354, 2355, 2357, 2358, 2359, 2360, 2361, 2362, 2364, 2366, 2368, 2370, 2372, 2373, 2374, 2375, 2376, 2377, 2378, 2379, 2380, 2381, 2382, 2383, 2384, 2385, 2386, 2387, 2388, 2390, 2392, 2394, 2396, 2397, 2400, 2401, 2405, 2407, 2411, 2414, 2417, 2423, 2424, 2425, 2426, 2427, 2428, 2429, 2434, 2436, 2440, 2441, 2444, 2445, 2449, 2452, 2454, 2456, 2460, 2461, 2462, 2463, 2465, 2468, 2472, 2473, 2474, 2475, 2478, 2479, 2480, 2481, 2482, 2484, 2485, 2490, 2492, 2495, 2498, 2500, 2502, 2505, 2507, 2511, 2513, 2516, 2519, 2525, 2527, 2530, 2531, 2536, 2539, 2543, 2543, 2548, 2551, 2552, 2556, 2557, 2562, 2563, 2567, 2568, 2572, 2573, 2578, 2580, 2585, 2586, 2587, 2588, 2589, 2590, 2591, 2593, 2596, 2598, 2602, 2603, 2604, 2605, 2606, 2608, 2610, 2612, 2616, 2617, 2618, 2622, 2625, 2628, 2631, 2635, 2639, 2646, 2650, 2654, 2661, 2662, 2667, 2669, 2670, 2673, 2674, 2677, 2678, 2682, 2683, 2687, 2688, 2689, 2690, 2692, 2695, 2698, 2699, 2700, 2702, 2704, 2708, 2709, 2710, 2712, 2713, 2714, 2718, 2720, 2723, 2725, 2726, 2727, 2728, 2731, 2733, 2734, 2738, 2740, 2743, 2745, 2746, 2747, 2751, 2753, 2756, 2759, 2761, 2763, 2767, 2769, 2772, 2774, 2777, 2779, 2782, 2783, 2787, 2789, 2792, 2794, 2797, 2800, 2804, 2806, 2810, 2811, 2813, 2814, 2820, 2821, 2823, 2825, 2827, 2829, 2832, 2833, 2834, 2838, 2839, 2840, 2841, 2842, 2843, 2844, 2845, 2846, 2850, 2851, 2855, 2857, 2865, 2867, 2871, 2875, 2882, 2883, 2889, 2890, 2897, 2900, 2904, 2907, 2912, 2917, 2919, 2920, 2921, 2925, 2926, 2930, 2932, 2933, 2936, 2941, 2942, 2943, 2947, 2950, 2959, 2961, 2965, 2968, 2971, 2979, 2982, 2985, 2986, 2989, 2992, 2993, 2996, 3000, 3004, 3010, 3020, 3021 }; #endif #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { "$end", "error", "$undefined", "T_REQUIRE_ONCE", "T_REQUIRE", "T_EVAL", "T_INCLUDE_ONCE", "T_INCLUDE", "T_LAMBDA_ARROW", "','", "T_LOGICAL_OR", "T_LOGICAL_XOR", "T_LOGICAL_AND", "T_PRINT", "'='", "T_POW_EQUAL", "T_SR_EQUAL", "T_SL_EQUAL", "T_XOR_EQUAL", "T_OR_EQUAL", "T_AND_EQUAL", "T_MOD_EQUAL", "T_CONCAT_EQUAL", "T_DIV_EQUAL", "T_MUL_EQUAL", "T_MINUS_EQUAL", "T_PLUS_EQUAL", "T_YIELD", "T_AWAIT", "'?'", "':'", "T_BOOLEAN_OR", "T_BOOLEAN_AND", "'|'", "'^'", "'&'", "T_IS_NOT_IDENTICAL", "T_IS_IDENTICAL", "T_IS_NOT_EQUAL", "T_IS_EQUAL", "'<'", "'>'", "T_IS_GREATER_OR_EQUAL", "T_IS_SMALLER_OR_EQUAL", "T_SR", "T_SL", "'+'", "'-'", "'.'", "'*'", "'/'", "'%'", "'!'", "T_INSTANCEOF", "'~'", "'@'", "T_UNSET_CAST", "T_BOOL_CAST", "T_OBJECT_CAST", "T_ARRAY_CAST", "T_STRING_CAST", "T_DOUBLE_CAST", "T_INT_CAST", "T_DEC", "T_INC", "T_POW", "'['", "T_CLONE", "T_NEW", "T_EXIT", "T_IF", "T_ELSEIF", "T_ELSE", "T_ENDIF", "T_LNUMBER", "T_DNUMBER", "T_ONUMBER", "T_STRING", "T_STRING_VARNAME", "T_VARIABLE", "T_NUM_STRING", "T_INLINE_HTML", "T_CHARACTER", "T_BAD_CHARACTER", "T_ENCAPSED_AND_WHITESPACE", "T_CONSTANT_ENCAPSED_STRING", "T_ECHO", "T_DO", "T_WHILE", "T_ENDWHILE", "T_FOR", "T_ENDFOR", "T_FOREACH", "T_ENDFOREACH", "T_DECLARE", "T_ENDDECLARE", "T_AS", "T_SWITCH", "T_ENDSWITCH", "T_CASE", "T_DEFAULT", "T_BREAK", "T_GOTO", "T_CONTINUE", "T_FUNCTION", "T_CONST", "T_RETURN", "T_TRY", "T_CATCH", "T_THROW", "T_USE", "T_GLOBAL", "T_PUBLIC", "T_PROTECTED", "T_PRIVATE", "T_FINAL", "T_ABSTRACT", "T_STATIC", "T_VAR", "T_UNSET", "T_ISSET", "T_EMPTY", "T_HALT_COMPILER", "T_CLASS", "T_INTERFACE", "T_EXTENDS", "T_IMPLEMENTS", "T_OBJECT_OPERATOR", "T_DOUBLE_ARROW", "T_LIST", "T_ARRAY", "T_CALLABLE", "T_CLASS_C", "T_METHOD_C", "T_FUNC_C", "T_LINE", "T_FILE", "T_COMMENT", "T_DOC_COMMENT", "T_OPEN_TAG", "T_OPEN_TAG_WITH_ECHO", "T_CLOSE_TAG", "T_WHITESPACE", "T_START_HEREDOC", "T_END_HEREDOC", "T_DOLLAR_OPEN_CURLY_BRACES", "T_CURLY_OPEN", "T_DOUBLE_COLON", "T_NAMESPACE", "T_NS_C", "T_DIR", "T_NS_SEPARATOR", "T_XHP_LABEL", "T_XHP_TEXT", "T_XHP_ATTRIBUTE", "T_XHP_CATEGORY", "T_XHP_CATEGORY_LABEL", "T_XHP_CHILDREN", "T_ENUM", "T_XHP_REQUIRED", "T_TRAIT", "\"...\"", "T_INSTEADOF", "T_TRAIT_C", "T_HH_ERROR", "T_FINALLY", "T_XHP_TAG_LT", "T_XHP_TAG_GT", "T_TYPELIST_LT", "T_TYPELIST_GT", "T_UNRESOLVED_LT", "T_COLLECTION", "T_SHAPE", "T_VARRAY", "T_MIARRAY", "T_MSARRAY", "T_TYPE", "T_UNRESOLVED_TYPE", "T_NEWTYPE", "T_UNRESOLVED_NEWTYPE", "T_COMPILER_HALT_OFFSET", "T_ASYNC", "T_FROM", "T_WHERE", "T_JOIN", "T_IN", "T_ON", "T_EQUALS", "T_INTO", "T_LET", "T_ORDERBY", "T_ASCENDING", "T_DESCENDING", "T_SELECT", "T_GROUP", "T_BY", "T_LAMBDA_OP", "T_LAMBDA_CP", "T_UNRESOLVED_OP", "'('", "')'", "';'", "'{'", "'}'", "'$'", "'`'", "']'", "'\"'", "'\\''", "$accept", "start", "$@1", "top_statement_list", "top_statement", "$@2", "$@3", "ident", "use_declarations", "use_fn_declarations", "use_const_declarations", "use_declaration", "use_fn_declaration", "use_const_declaration", "namespace_name", "namespace_string_base", "namespace_string", "namespace_string_typeargs", "class_namespace_string_typeargs", "constant_declaration", "inner_statement_list", "inner_statement", "statement", "$@4", "$@5", "$@6", "$@7", "$@8", "$@9", "$@10", "$@11", "try_statement_list", "$@12", "additional_catches", "finally_statement_list", "$@13", "optional_finally", "is_reference", "function_loc", "function_declaration_statement", "$@14", "$@15", "$@16", "enum_declaration_statement", "$@17", "$@18", "class_declaration_statement", "$@19", "$@20", "$@21", "$@22", "trait_declaration_statement", "$@23", "$@24", "class_decl_name", "interface_decl_name", "trait_decl_name", "class_entry_type", "extends_from", "implements_list", "interface_extends_list", "interface_list", "trait_list", "foreach_optional_arg", "foreach_variable", "for_statement", "foreach_statement", "while_statement", "declare_statement", "declare_list", "switch_case_list", "case_list", "case_separator", "elseif_list", "new_elseif_list", "else_single", "new_else_single", "method_parameter_list", "non_empty_method_parameter_list", "parameter_list", "non_empty_parameter_list", "function_call_parameter_list", "non_empty_fcall_parameter_list", "global_var_list", "global_var", "static_var_list", "enum_statement_list", "enum_statement", "enum_constant_declaration", "class_statement_list", "class_statement", "$@25", "$@26", "$@27", "$@28", "trait_rules", "trait_precedence_rule", "trait_alias_rule", "trait_alias_rule_method", "xhp_attribute_stmt", "xhp_attribute_decl", "xhp_attribute_decl_type", "xhp_attribute_enum", "xhp_attribute_default", "xhp_attribute_is_required", "xhp_category_stmt", "xhp_category_decl", "xhp_children_stmt", "xhp_children_paren_expr", "xhp_children_decl_expr", "xhp_children_decl_tag", "function_body", "method_body", "variable_modifiers", "method_modifiers", "non_empty_member_modifiers", "member_modifier", "parameter_modifiers", "parameter_modifier", "class_variable_declaration", "class_constant_declaration", "expr_with_parens", "parenthesis_expr", "expr_list", "for_expr", "yield_expr", "yield_assign_expr", "yield_list_assign_expr", "await_expr", "await_assign_expr", "await_list_assign_expr", "expr", "expr_no_variable", "lambda_use_vars", "closure_expression", "$@29", "$@30", "lambda_expression", "$@31", "$@32", "$@33", "$@34", "lambda_body", "shape_keyname", "non_empty_shape_pair_list", "non_empty_static_shape_pair_list", "shape_pair_list", "static_shape_pair_list", "shape_literal", "array_literal", "collection_literal", "map_array_literal", "varray_literal", "static_map_array_literal", "static_varray_literal", "static_collection_literal", "dim_expr", "dim_expr_base", "query_expr", "query_assign_expr", "query_head", "query_body", "query_body_clauses", "query_body_clause", "from_clause", "let_clause", "where_clause", "join_clause", "join_into_clause", "orderby_clause", "orderings", "ordering", "ordering_direction", "select_or_group_clause", "select_clause", "group_clause", "query_continuation", "lexical_var_list", "xhp_tag", "xhp_tag_body", "xhp_opt_end_label", "xhp_attributes", "xhp_children", "xhp_attribute_name", "xhp_attribute_value", "xhp_child", "xhp_label_ws", "xhp_bareword", "simple_function_call", "fully_qualified_class_name", "static_class_name", "class_name_reference", "exit_expr", "backticks_expr", "ctor_arguments", "common_scalar", "static_expr", "static_class_constant", "scalar", "static_array_pair_list", "possible_comma", "hh_possible_comma", "non_empty_static_array_pair_list", "common_scalar_ae", "static_numeric_scalar_ae", "static_scalar_ae", "static_array_pair_list_ae", "non_empty_static_array_pair_list_ae", "non_empty_static_scalar_list_ae", "static_shape_pair_list_ae", "non_empty_static_shape_pair_list_ae", "static_scalar_list_ae", "attribute_static_scalar_list", "non_empty_user_attribute_list", "user_attribute_list", "$@35", "non_empty_user_attributes", "optional_user_attributes", "property_access", "property_access_without_variables", "array_access", "dimmable_variable_access", "dimmable_variable_no_calls_access", "variable", "dimmable_variable", "callable_variable", "object_method_call", "class_method_call", "variable_without_objects", "reference_variable", "compound_variable", "dim_offset", "simple_indirect_reference", "variable_no_calls", "dimmable_variable_no_calls", "assignment_list", "array_pair_list", "non_empty_array_pair_list", "collection_init", "non_empty_collection_init", "static_collection_init", "non_empty_static_collection_init", "map_array_init", "varray_init", "non_empty_map_array_init", "non_empty_varray_init", "static_map_array_init", "static_varray_init", "non_empty_static_map_array_init", "non_empty_static_varray_init", "encaps_list", "encaps_var", "encaps_var_offset", "internal_functions", "variable_list", "class_constant", "hh_opt_constraint", "hh_type_alias_statement", "hh_name_with_type", "hh_name_with_typevar", "hh_typeargs_opt", "hh_non_empty_type_list", "hh_type_list", "hh_func_type_list", "hh_opt_return_type", "hh_typevar_list", "hh_typevar_variance", "hh_shape_member_type", "hh_non_empty_shape_member_list", "hh_shape_member_list", "hh_shape_type", "hh_type", "hh_type_opt", 0 }; #endif # ifdef YYPRINT /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to token YYLEX-NUM. */ static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 44, 264, 265, 266, 267, 61, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 63, 58, 282, 283, 124, 94, 38, 284, 285, 286, 287, 60, 62, 288, 289, 290, 291, 43, 45, 46, 42, 47, 37, 33, 292, 126, 64, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 91, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 40, 41, 59, 123, 125, 36, 96, 93, 34, 39 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint16 yyr1[] = { 0, 209, 211, 210, 212, 212, 213, 213, 213, 213, 213, 213, 213, 213, 214, 213, 215, 213, 213, 213, 213, 213, 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, 217, 217, 218, 218, 219, 219, 220, 220, 220, 220, 221, 221, 221, 221, 222, 222, 222, 222, 223, 223, 224, 224, 224, 225, 226, 227, 228, 228, 229, 229, 230, 230, 230, 230, 231, 231, 231, 232, 231, 233, 231, 234, 231, 235, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 236, 231, 237, 231, 231, 238, 231, 239, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 241, 240, 242, 242, 244, 243, 245, 245, 246, 246, 247, 249, 248, 250, 248, 251, 248, 253, 252, 254, 252, 256, 255, 257, 255, 258, 255, 259, 255, 261, 260, 262, 260, 263, 263, 264, 265, 266, 266, 266, 267, 267, 268, 268, 269, 269, 270, 270, 271, 271, 272, 272, 273, 273, 273, 274, 274, 275, 275, 276, 276, 277, 277, 278, 278, 279, 279, 279, 279, 280, 280, 280, 281, 281, 282, 282, 283, 283, 284, 284, 285, 285, 286, 286, 286, 286, 286, 286, 287, 287, 287, 287, 287, 287, 287, 287, 288, 288, 288, 288, 288, 288, 289, 289, 289, 289, 289, 289, 289, 289, 290, 290, 291, 291, 291, 291, 291, 291, 292, 292, 293, 293, 293, 294, 294, 294, 294, 295, 295, 296, 297, 298, 298, 300, 299, 301, 299, 299, 302, 299, 303, 299, 299, 299, 299, 299, 299, 299, 299, 304, 304, 304, 305, 306, 306, 307, 307, 308, 308, 309, 309, 310, 310, 310, 310, 310, 311, 311, 312, 312, 313, 313, 314, 314, 315, 316, 316, 316, 317, 317, 317, 317, 318, 318, 318, 318, 318, 318, 318, 319, 319, 319, 320, 320, 321, 321, 322, 322, 323, 323, 324, 324, 325, 325, 325, 325, 325, 325, 325, 326, 326, 327, 327, 327, 328, 328, 328, 328, 329, 329, 330, 330, 330, 330, 330, 331, 332, 332, 333, 333, 334, 334, 335, 336, 337, 338, 339, 340, 340, 340, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 342, 342, 344, 343, 345, 343, 347, 346, 348, 346, 349, 346, 350, 346, 351, 351, 351, 352, 352, 353, 353, 354, 354, 355, 355, 356, 356, 357, 358, 358, 359, 360, 360, 361, 362, 362, 363, 364, 365, 365, 366, 366, 366, 366, 367, 368, 369, 370, 370, 370, 370, 371, 371, 372, 372, 372, 372, 372, 372, 373, 374, 375, 376, 377, 378, 379, 379, 380, 380, 381, 381, 382, 382, 383, 384, 385, 386, 386, 386, 386, 387, 388, 388, 389, 389, 390, 390, 391, 391, 392, 393, 393, 394, 394, 394, 395, 395, 395, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 396, 397, 398, 398, 399, 399, 399, 400, 400, 400, 401, 401, 401, 402, 402, 402, 403, 403, 404, 404, 404, 404, 404, 404, 404, 404, 404, 404, 404, 404, 404, 404, 404, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 406, 406, 406, 407, 407, 407, 407, 407, 407, 407, 408, 408, 409, 409, 410, 410, 411, 411, 411, 411, 412, 412, 412, 412, 412, 412, 413, 413, 413, 413, 414, 414, 414, 414, 414, 414, 414, 415, 415, 416, 416, 416, 416, 417, 417, 418, 418, 419, 419, 420, 420, 421, 421, 422, 422, 424, 423, 425, 426, 426, 427, 427, 428, 428, 429, 429, 430, 430, 431, 431, 432, 432, 432, 432, 432, 432, 432, 432, 432, 432, 433, 433, 433, 433, 433, 433, 433, 433, 434, 434, 434, 435, 435, 435, 435, 435, 435, 436, 436, 436, 437, 437, 438, 438, 438, 439, 439, 440, 440, 441, 441, 442, 442, 442, 442, 442, 442, 443, 443, 443, 443, 443, 444, 444, 444, 444, 444, 444, 445, 445, 446, 446, 446, 446, 446, 446, 446, 446, 447, 447, 448, 448, 448, 448, 449, 449, 450, 450, 450, 450, 451, 451, 452, 452, 453, 453, 454, 454, 455, 455, 456, 456, 457, 457, 458, 458, 459, 459, 459, 459, 460, 460, 460, 460, 460, 460, 461, 461, 461, 462, 462, 462, 462, 462, 462, 462, 462, 462, 463, 463, 464, 464, 465, 465, 466, 466, 467, 467, 468, 468, 469, 469, 470, 470, 471, 472, 472, 472, 472, 473, 473, 474, 474, 474, 474, 475, 475, 475, 476, 476, 477, 477, 478, 478, 479, 480, 480, 480, 480, 480, 480, 480, 480, 480, 480, 480, 481, 481 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { 0, 2, 0, 2, 2, 0, 1, 1, 1, 1, 1, 1, 4, 3, 0, 6, 0, 5, 3, 4, 4, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 1, 3, 1, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 3, 1, 3, 2, 1, 2, 2, 5, 4, 2, 0, 1, 1, 1, 1, 3, 5, 8, 0, 4, 0, 6, 0, 10, 0, 4, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 5, 1, 1, 0, 9, 0, 10, 5, 0, 13, 0, 5, 3, 3, 2, 2, 2, 2, 2, 2, 3, 2, 2, 3, 2, 0, 4, 9, 0, 0, 4, 2, 0, 1, 0, 1, 0, 9, 0, 10, 0, 11, 0, 9, 0, 10, 0, 8, 0, 9, 0, 7, 0, 8, 0, 7, 0, 8, 1, 1, 1, 1, 1, 2, 2, 2, 0, 2, 0, 2, 0, 1, 3, 1, 3, 2, 0, 1, 2, 4, 1, 4, 1, 4, 1, 4, 1, 4, 3, 5, 3, 4, 4, 5, 5, 4, 0, 1, 1, 4, 0, 5, 0, 2, 0, 3, 0, 7, 6, 2, 5, 4, 0, 4, 5, 7, 6, 6, 7, 9, 8, 6, 5, 2, 4, 3, 0, 3, 4, 6, 5, 5, 6, 8, 7, 2, 0, 1, 2, 2, 3, 4, 4, 3, 1, 1, 2, 4, 3, 5, 1, 3, 2, 0, 2, 3, 2, 0, 0, 4, 0, 5, 2, 0, 10, 0, 11, 3, 3, 3, 4, 4, 3, 5, 2, 2, 0, 6, 5, 4, 3, 1, 1, 3, 4, 1, 1, 1, 1, 4, 1, 1, 3, 2, 0, 2, 0, 1, 3, 1, 1, 1, 1, 3, 4, 4, 4, 1, 1, 2, 2, 2, 3, 3, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 0, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 3, 5, 1, 3, 5, 4, 3, 3, 2, 1, 1, 3, 3, 1, 1, 0, 2, 4, 3, 6, 2, 3, 6, 1, 1, 1, 6, 3, 4, 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 4, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 3, 2, 1, 1, 1, 5, 0, 0, 11, 0, 12, 0, 3, 0, 4, 0, 6, 0, 7, 2, 2, 4, 1, 1, 5, 3, 5, 3, 2, 0, 2, 0, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 3, 2, 3, 4, 2, 3, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 4, 4, 2, 8, 10, 2, 1, 3, 1, 2, 1, 1, 1, 1, 2, 4, 3, 3, 4, 1, 2, 4, 2, 6, 0, 1, 4, 0, 2, 0, 1, 1, 3, 1, 3, 1, 1, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 0, 0, 1, 1, 3, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 2, 1, 1, 4, 3, 4, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 5, 4, 3, 3, 3, 1, 1, 1, 1, 3, 3, 3, 2, 0, 1, 0, 1, 0, 5, 3, 3, 1, 1, 1, 1, 1, 3, 2, 1, 1, 1, 1, 1, 1, 2, 2, 4, 3, 4, 2, 0, 5, 3, 3, 1, 3, 1, 2, 0, 5, 3, 2, 0, 3, 0, 4, 2, 0, 3, 3, 1, 0, 1, 2, 2, 4, 3, 3, 2, 4, 2, 4, 1, 1, 1, 1, 1, 2, 4, 3, 4, 3, 1, 1, 1, 1, 2, 4, 4, 3, 1, 1, 3, 7, 6, 8, 9, 8, 10, 7, 6, 8, 1, 2, 4, 4, 1, 1, 4, 1, 0, 1, 2, 1, 1, 2, 4, 3, 3, 0, 1, 2, 4, 3, 2, 3, 6, 0, 1, 4, 2, 0, 5, 3, 3, 1, 6, 4, 4, 2, 2, 0, 5, 3, 3, 1, 2, 0, 5, 3, 3, 1, 2, 0, 2, 0, 5, 3, 3, 1, 2, 0, 2, 0, 5, 3, 3, 1, 2, 2, 1, 2, 1, 4, 3, 3, 6, 3, 1, 1, 1, 4, 4, 4, 4, 2, 2, 4, 2, 2, 1, 3, 3, 3, 0, 2, 5, 6, 1, 2, 1, 4, 3, 0, 1, 3, 2, 3, 1, 1, 0, 0, 2, 4, 2, 6, 4, 1, 1, 0, 3, 5, 3, 1, 2, 0, 4, 2, 2, 1, 1, 1, 1, 4, 6, 1, 8, 6, 1, 0 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state STATE-NUM when YYTABLE doesn't specify something else to do. Zero means the default is an error. */ static const yytype_uint16 yydefact[] = { 2, 0, 5, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 740, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 814, 0, 802, 623, 0, 629, 630, 631, 22, 689, 790, 98, 632, 0, 80, 0, 0, 0, 0, 0, 0, 0, 0, 131, 0, 0, 0, 0, 0, 0, 323, 324, 325, 328, 327, 326, 0, 0, 0, 0, 158, 0, 0, 0, 636, 638, 639, 633, 634, 0, 0, 640, 635, 0, 614, 23, 24, 25, 27, 26, 0, 637, 0, 0, 0, 0, 0, 0, 0, 641, 329, 28, 29, 31, 30, 32, 33, 34, 35, 36, 37, 38, 39, 40, 444, 0, 97, 70, 794, 624, 0, 0, 4, 59, 61, 64, 688, 0, 613, 0, 6, 130, 7, 9, 8, 10, 0, 0, 321, 360, 0, 0, 0, 0, 0, 0, 0, 358, 431, 432, 426, 425, 345, 427, 428, 433, 0, 0, 344, 756, 615, 0, 691, 424, 320, 759, 359, 0, 0, 757, 758, 755, 785, 789, 0, 414, 690, 11, 328, 327, 326, 0, 0, 27, 59, 130, 0, 872, 359, 871, 0, 869, 868, 430, 0, 351, 355, 0, 0, 398, 399, 400, 401, 423, 421, 420, 419, 418, 417, 416, 415, 790, 616, 0, 886, 615, 0, 380, 378, 0, 818, 0, 698, 343, 619, 0, 886, 618, 0, 628, 797, 796, 620, 0, 0, 622, 422, 0, 0, 0, 0, 348, 0, 78, 350, 0, 0, 84, 86, 0, 0, 88, 0, 0, 0, 913, 914, 918, 0, 0, 59, 912, 0, 915, 0, 0, 90, 0, 0, 0, 0, 121, 0, 0, 0, 0, 0, 0, 42, 47, 241, 0, 0, 240, 160, 159, 246, 0, 0, 0, 0, 0, 883, 146, 156, 810, 814, 855, 0, 643, 0, 0, 0, 853, 0, 16, 0, 63, 138, 150, 157, 520, 458, 838, 836, 836, 0, 877, 442, 446, 744, 360, 0, 358, 359, 0, 0, 625, 0, 626, 0, 0, 0, 120, 0, 0, 66, 232, 0, 21, 129, 0, 155, 142, 154, 326, 329, 130, 322, 111, 112, 113, 114, 115, 117, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 802, 0, 110, 793, 793, 118, 824, 0, 0, 0, 0, 0, 0, 319, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 379, 377, 0, 760, 745, 793, 0, 751, 232, 793, 0, 795, 786, 810, 0, 130, 0, 0, 92, 0, 742, 737, 698, 0, 0, 0, 0, 822, 0, 463, 697, 813, 0, 0, 66, 0, 232, 342, 0, 798, 745, 753, 621, 0, 70, 196, 0, 441, 0, 95, 0, 0, 349, 0, 0, 0, 0, 0, 87, 109, 89, 910, 911, 0, 908, 0, 0, 0, 882, 0, 116, 91, 119, 0, 0, 0, 0, 0, 0, 0, 478, 0, 485, 487, 488, 489, 490, 491, 492, 483, 505, 506, 70, 0, 106, 108, 0, 0, 44, 51, 0, 0, 46, 55, 48, 0, 18, 0, 0, 242, 0, 93, 0, 0, 94, 873, 0, 0, 360, 358, 359, 0, 902, 166, 0, 811, 0, 0, 0, 0, 642, 854, 689, 0, 0, 852, 694, 851, 62, 5, 13, 14, 0, 164, 0, 0, 451, 0, 0, 698, 0, 0, 617, 452, 842, 0, 698, 0, 0, 698, 0, 0, 0, 0, 0, 744, 0, 700, 743, 922, 341, 411, 764, 75, 69, 71, 72, 73, 74, 320, 0, 429, 692, 693, 60, 698, 0, 887, 0, 0, 0, 700, 233, 0, 436, 132, 162, 0, 383, 385, 384, 0, 0, 381, 382, 386, 388, 387, 403, 402, 405, 404, 406, 408, 409, 407, 397, 396, 390, 391, 389, 392, 393, 395, 410, 394, 792, 0, 0, 828, 0, 698, 876, 0, 875, 762, 785, 148, 140, 152, 144, 130, 0, 0, 353, 356, 362, 479, 376, 375, 374, 373, 372, 371, 370, 369, 368, 367, 366, 365, 0, 747, 746, 0, 0, 0, 0, 0, 0, 0, 870, 352, 735, 739, 697, 741, 0, 0, 886, 0, 817, 0, 816, 0, 801, 800, 0, 0, 747, 746, 346, 198, 200, 70, 449, 448, 347, 0, 70, 180, 79, 350, 0, 0, 0, 0, 0, 192, 192, 85, 0, 0, 0, 906, 698, 0, 893, 0, 0, 0, 0, 0, 696, 632, 0, 0, 614, 0, 0, 0, 0, 0, 64, 645, 613, 651, 652, 650, 0, 644, 68, 649, 0, 0, 495, 0, 0, 501, 498, 499, 507, 0, 486, 481, 0, 484, 0, 0, 0, 52, 19, 0, 0, 56, 20, 0, 0, 0, 41, 49, 0, 239, 247, 244, 0, 0, 864, 867, 866, 865, 12, 900, 901, 0, 0, 0, 0, 810, 807, 0, 462, 863, 862, 861, 0, 857, 0, 858, 860, 0, 5, 0, 0, 0, 514, 515, 523, 522, 0, 0, 697, 457, 461, 0, 467, 697, 837, 0, 465, 697, 835, 466, 0, 878, 0, 443, 0, 894, 744, 219, 921, 0, 0, 761, 745, 752, 791, 697, 889, 885, 234, 235, 612, 699, 231, 0, 744, 0, 0, 164, 438, 134, 413, 0, 472, 473, 0, 464, 697, 823, 0, 0, 232, 166, 0, 164, 162, 0, 802, 363, 0, 0, 232, 749, 750, 763, 787, 788, 0, 0, 0, 723, 705, 706, 707, 708, 0, 0, 0, 716, 715, 729, 698, 0, 737, 821, 820, 0, 799, 745, 754, 627, 0, 202, 0, 0, 76, 0, 0, 0, 0, 0, 0, 0, 172, 173, 184, 0, 70, 182, 103, 192, 0, 192, 0, 0, 916, 0, 0, 697, 907, 909, 892, 698, 891, 0, 698, 673, 674, 671, 672, 704, 0, 698, 696, 0, 0, 460, 846, 844, 844, 0, 0, 830, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 480, 0, 0, 0, 503, 504, 502, 0, 0, 482, 0, 122, 0, 125, 107, 0, 43, 53, 0, 45, 57, 50, 243, 0, 874, 96, 902, 884, 897, 165, 167, 253, 0, 0, 808, 0, 856, 0, 17, 0, 877, 163, 253, 0, 0, 454, 0, 875, 841, 840, 0, 879, 0, 894, 0, 0, 922, 0, 223, 221, 0, 747, 746, 888, 0, 0, 236, 67, 0, 744, 161, 0, 744, 0, 412, 827, 826, 0, 232, 0, 0, 0, 0, 164, 136, 628, 748, 232, 0, 0, 711, 712, 713, 714, 717, 718, 727, 0, 698, 723, 0, 710, 731, 697, 734, 736, 738, 0, 815, 748, 0, 0, 0, 0, 199, 450, 81, 0, 350, 172, 174, 810, 0, 0, 0, 0, 0, 0, 0, 0, 0, 186, 0, 903, 0, 905, 697, 0, 0, 0, 647, 697, 695, 0, 686, 0, 698, 0, 850, 0, 698, 0, 0, 698, 0, 653, 687, 685, 834, 0, 698, 656, 658, 657, 0, 0, 654, 655, 659, 661, 660, 676, 675, 678, 677, 679, 681, 682, 680, 669, 668, 663, 664, 662, 665, 666, 667, 670, 493, 0, 494, 500, 508, 509, 0, 70, 54, 58, 245, 0, 0, 0, 320, 812, 810, 354, 357, 361, 0, 15, 0, 320, 526, 0, 0, 528, 521, 524, 0, 519, 0, 0, 880, 0, 895, 445, 0, 224, 0, 220, 0, 0, 232, 238, 237, 894, 0, 253, 0, 744, 0, 232, 0, 783, 253, 877, 253, 0, 0, 364, 232, 0, 777, 0, 720, 697, 722, 0, 709, 0, 0, 698, 728, 819, 0, 70, 0, 195, 181, 0, 0, 0, 171, 99, 185, 0, 0, 188, 0, 193, 194, 70, 187, 917, 0, 890, 0, 920, 703, 702, 646, 0, 697, 459, 648, 470, 697, 845, 0, 468, 697, 843, 469, 0, 471, 697, 829, 684, 0, 0, 0, 0, 896, 899, 168, 0, 0, 0, 318, 0, 0, 0, 147, 252, 254, 0, 317, 0, 320, 0, 859, 249, 151, 517, 0, 0, 453, 839, 447, 0, 227, 218, 0, 226, 748, 232, 0, 435, 894, 320, 894, 0, 825, 0, 782, 320, 0, 320, 253, 744, 0, 776, 726, 725, 719, 0, 721, 697, 730, 70, 201, 77, 82, 101, 175, 0, 183, 189, 70, 191, 904, 0, 0, 456, 0, 849, 848, 0, 833, 832, 683, 0, 70, 126, 0, 0, 0, 0, 0, 169, 284, 282, 286, 614, 27, 0, 278, 0, 283, 295, 0, 293, 298, 0, 297, 0, 296, 0, 130, 256, 0, 258, 0, 809, 0, 518, 516, 527, 525, 228, 0, 217, 225, 232, 0, 780, 0, 0, 0, 143, 435, 894, 784, 149, 249, 153, 320, 0, 778, 0, 733, 0, 197, 0, 0, 70, 178, 100, 190, 919, 701, 0, 0, 0, 0, 0, 898, 0, 0, 0, 0, 268, 272, 0, 0, 263, 578, 577, 574, 576, 575, 595, 597, 596, 566, 537, 538, 556, 572, 571, 533, 543, 544, 546, 545, 565, 549, 547, 548, 550, 551, 552, 553, 554, 555, 557, 558, 559, 560, 561, 562, 564, 563, 534, 535, 536, 539, 540, 542, 580, 581, 590, 589, 588, 587, 586, 585, 573, 592, 582, 583, 584, 567, 568, 569, 570, 593, 594, 598, 600, 599, 601, 602, 579, 604, 603, 606, 608, 607, 541, 611, 609, 610, 605, 591, 532, 290, 529, 0, 264, 311, 312, 310, 303, 0, 304, 265, 337, 0, 0, 0, 0, 130, 139, 248, 0, 0, 0, 230, 0, 779, 0, 70, 313, 70, 133, 0, 0, 0, 145, 894, 724, 0, 70, 176, 83, 102, 0, 455, 847, 831, 496, 124, 266, 267, 340, 170, 0, 0, 287, 279, 0, 0, 0, 292, 294, 0, 0, 299, 306, 307, 305, 0, 0, 255, 0, 0, 0, 0, 250, 0, 229, 781, 0, 512, 700, 0, 0, 70, 135, 141, 0, 732, 0, 0, 0, 104, 269, 59, 0, 270, 271, 0, 0, 285, 289, 530, 531, 0, 280, 308, 309, 301, 302, 300, 338, 335, 259, 257, 339, 0, 251, 513, 699, 0, 437, 314, 0, 137, 0, 179, 497, 0, 128, 0, 320, 288, 291, 0, 744, 261, 0, 510, 434, 439, 177, 0, 0, 105, 276, 0, 319, 336, 0, 700, 331, 744, 511, 0, 127, 0, 0, 275, 894, 744, 205, 332, 333, 334, 922, 330, 0, 0, 0, 274, 0, 331, 0, 894, 0, 273, 315, 70, 260, 922, 0, 209, 207, 0, 70, 0, 0, 210, 0, 206, 262, 0, 316, 0, 213, 204, 0, 212, 123, 214, 0, 203, 211, 0, 216, 215 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { -1, 1, 2, 4, 120, 805, 544, 182, 275, 502, 506, 276, 503, 507, 122, 123, 124, 125, 126, 127, 323, 579, 580, 456, 240, 1438, 462, 1360, 1439, 1668, 763, 270, 497, 1631, 999, 1180, 1683, 339, 183, 581, 852, 1058, 1233, 131, 547, 869, 582, 601, 871, 528, 868, 583, 548, 870, 341, 291, 307, 134, 854, 808, 791, 1014, 1383, 1108, 919, 1580, 1442, 705, 925, 461, 714, 927, 1266, 697, 908, 911, 1097, 1688, 1689, 571, 572, 595, 596, 280, 281, 285, 1409, 1559, 1560, 1187, 1308, 1402, 1555, 1674, 1691, 1592, 1635, 1636, 1637, 1390, 1391, 1392, 1593, 1599, 1644, 1395, 1396, 1400, 1548, 1549, 1550, 1570, 1718, 1309, 1310, 184, 136, 1704, 1705, 1553, 1312, 137, 233, 457, 458, 138, 139, 140, 141, 142, 143, 144, 145, 1422, 146, 851, 1057, 147, 237, 569, 318, 570, 452, 553, 554, 1131, 555, 1132, 148, 149, 150, 151, 152, 740, 741, 742, 153, 154, 267, 155, 268, 485, 486, 487, 488, 489, 490, 491, 492, 493, 753, 754, 991, 494, 495, 496, 760, 1620, 156, 549, 1411, 550, 1028, 813, 1204, 1201, 1541, 1542, 157, 158, 159, 227, 234, 326, 442, 160, 946, 746, 161, 947, 843, 834, 948, 895, 1079, 1081, 1082, 1083, 897, 1245, 1246, 898, 678, 427, 195, 196, 584, 574, 408, 409, 840, 163, 228, 186, 165, 166, 167, 168, 169, 170, 171, 632, 172, 230, 231, 531, 219, 220, 635, 636, 1144, 1145, 563, 560, 564, 561, 1137, 1134, 1138, 1135, 300, 301, 799, 173, 521, 174, 568, 175, 1561, 292, 334, 590, 591, 940, 1040, 788, 789, 718, 719, 720, 261, 262, 836 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ #define YYPACT_NINF -1427 static const yytype_int16 yypact[] = { -1427, 154, -1427, -1427, 6198, 13610, 13610, 4, 13610, 13610, 13610, 11718, 13610, -1427, 13610, 13610, 13610, 13610, 13610, 13610, 13610, 13610, 13610, 13610, 13610, 13610, 14797, 14797, 11924, 13610, 15166, 101, 137, -1427, -1427, -1427, -1427, -1427, 206, -1427, 161, 13610, -1427, 137, 149, 158, 171, 137, 12088, 16176, 12252, -1427, 14587, 10730, 170, 13610, 15188, 22, -1427, -1427, -1427, 257, 335, 16, 194, 199, 266, 284, -1427, 16176, 292, 314, -1427, -1427, -1427, -1427, -1427, 270, 14113, -1427, -1427, 16176, -1427, -1427, -1427, -1427, 16176, -1427, 16176, -1427, 253, 316, 318, 324, 326, 16176, 16176, -1427, 29, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, 13610, -1427, -1427, 331, 375, 382, 382, -1427, 507, 388, 211, -1427, 342, -1427, 34, -1427, 516, -1427, -1427, -1427, -1427, 16021, 359, -1427, -1427, 341, 352, 353, 363, 365, 377, 3861, -1427, -1427, -1427, -1427, 514, -1427, -1427, -1427, 517, 524, 396, -1427, 37, 402, 464, -1427, -1427, 542, -3, 1769, 69, 413, 82, 108, 417, 9, -1427, 125, -1427, 555, -1427, -1427, -1427, 475, 425, 474, -1427, -1427, 516, 359, 16450, 2179, 16450, 13610, 16450, 16450, 10919, 426, 15435, 10919, 585, 16176, 566, 566, 153, 566, 566, 566, 566, 566, 566, 566, 566, 566, -1427, -1427, 4911, 468, -1427, 490, 512, 512, 14797, 15479, 440, 638, -1427, 475, 4911, 468, 505, 513, 451, 109, -1427, 535, 69, 12416, -1427, -1427, 13610, 9494, 655, 58, 16450, 10524, -1427, 13610, 13610, 16176, -1427, -1427, 3905, 476, -1427, 4032, 14587, 14587, 501, -1427, -1427, 477, 14467, 666, -1427, 671, -1427, 16176, 609, -1427, 492, 4242, 493, 424, -1427, 7, 4301, 14820, 16034, 16176, 62, -1427, 275, -1427, 2316, 63, -1427, -1427, -1427, 681, 71, 14797, 14797, 13610, 497, 530, -1427, -1427, 15029, 11924, 43, 343, -1427, 13774, 14797, 351, -1427, 16176, -1427, 300, 388, -1427, -1427, -1427, -1427, 15249, 13610, 13610, 13610, 687, 607, -1427, -1427, 86, 508, 16450, 509, 102, 6404, 13610, 241, 510, 401, 241, 261, 230, -1427, 16176, 14587, 511, 10936, 14587, -1427, -1427, 5067, -1427, -1427, -1427, -1427, -1427, 516, -1427, -1427, -1427, -1427, -1427, -1427, -1427, 13610, 13610, 13610, 12622, 13610, 13610, 13610, 13610, 13610, 13610, 13610, 13610, 13610, 13610, 13610, 13610, 13610, 13610, 13610, 13610, 13610, 13610, 13610, 13610, 13610, 15166, 13610, -1427, 13610, 13610, -1427, 13610, 2026, 16176, 16176, 16176, 16021, 608, 457, 5556, 13610, 13610, 13610, 13610, 13610, 13610, 13610, 13610, 13610, 13610, 13610, 13610, -1427, -1427, 3806, -1427, 111, 13610, 13610, -1427, 10936, 13610, 13610, 331, 119, 15029, 519, 516, 12828, 4391, -1427, 13610, -1427, 520, 704, 4911, 522, -13, 4460, 512, 13034, -1427, 13240, -1427, 525, 5, -1427, 130, 10936, -1427, 4627, -1427, 120, -1427, -1427, 4532, -1427, -1427, 11142, -1427, 13610, -1427, 628, 9700, 715, 537, 16362, 706, 33, 28, -1427, -1427, -1427, -1427, -1427, 14587, 14670, 528, 727, 14887, -1427, 554, -1427, -1427, -1427, 661, 13610, 662, 664, 13610, 13610, 13610, -1427, 424, -1427, -1427, -1427, -1427, -1427, -1427, -1427, 556, -1427, -1427, -1427, 546, -1427, -1427, 16176, 547, 740, 294, 16176, 549, 742, 296, 304, 16079, -1427, 16176, 13610, 512, 22, -1427, 14887, 674, -1427, 512, 52, 60, 558, 560, 968, 564, 87, 630, 557, 512, 88, 569, 15955, 16176, -1427, -1427, 700, 2023, -14, -1427, -1427, -1427, 388, -1427, -1427, -1427, 744, 646, 610, 46, -1427, 331, 648, 769, 580, 634, 119, -1427, 16450, 583, 775, 15535, 586, 778, 590, 14587, 14587, 777, 655, 86, 595, 784, -1427, 14587, 15, 729, 77, -1427, -1427, -1427, -1427, -1427, -1427, 711, 2229, -1427, -1427, -1427, -1427, 787, 629, -1427, 14797, 13610, 599, 793, 16450, 789, -1427, -1427, 680, 14326, 11331, 3038, 10919, 13610, 16406, 13977, 4448, 5086, 3149, 12600, 14329, 14329, 14329, 14329, 1761, 1761, 1761, 1761, 854, 854, 621, 621, 621, 153, 153, 153, -1427, 566, 16450, 601, 603, 15579, 615, 802, -1427, 13610, 205, 614, 119, -1427, -1427, -1427, -1427, 516, 13610, 14647, -1427, -1427, 10919, -1427, 10919, 10919, 10919, 10919, 10919, 10919, 10919, 10919, 10919, 10919, 10919, 10919, 13610, 205, 622, 623, 2335, 620, 625, 2511, 89, 637, -1427, 16450, 14981, -1427, 16176, -1427, 508, 15, 468, 14797, 16450, 14797, 15635, 20, 122, -1427, 639, 13610, -1427, -1427, -1427, 9288, 136, -1427, -1427, 16450, 16450, 137, -1427, -1427, -1427, 13610, 741, 2631, 14887, 16176, 9906, 641, 644, -1427, 50, 710, 693, -1427, 837, 651, 3274, 14587, 14887, 14887, 14887, 14887, 14887, -1427, 649, 23, 705, 654, 657, 658, 659, 14887, -11, -1427, 712, -1427, -1427, -1427, 660, -1427, 16536, -1427, 13610, 679, 16450, 682, 851, 5330, 857, -1427, 16450, 5236, -1427, 556, 790, -1427, 6610, 15236, 668, 313, -1427, 14820, 16176, 327, -1427, 16034, 16176, 16176, -1427, -1427, 2857, -1427, 16536, 858, 14797, 672, -1427, -1427, -1427, -1427, -1427, -1427, -1427, 55, 16176, 15236, 673, 15029, 15112, 860, -1427, -1427, -1427, -1427, 677, -1427, 13610, -1427, -1427, 5786, -1427, 14587, 15236, 685, -1427, -1427, -1427, -1427, 865, 13610, 15249, -1427, -1427, 16121, -1427, 13610, -1427, 13610, -1427, 13610, -1427, -1427, 683, -1427, 14587, -1427, 692, 861, 104, -1427, -1427, 280, 5322, -1427, 124, -1427, -1427, 14587, -1427, -1427, 512, 16450, -1427, 11348, -1427, 14887, 65, 694, 15236, 646, -1427, -1427, 13223, 13610, -1427, -1427, 13610, -1427, 13610, -1427, 2907, 695, 10936, 630, 867, 646, 680, 16176, 15166, 512, 2998, 696, 10936, -1427, -1427, 129, -1427, -1427, 884, 4718, 4718, 14981, -1427, -1427, -1427, -1427, 714, 57, 716, -1427, -1427, -1427, 890, 709, 520, 512, 512, 13446, -1427, 131, -1427, -1427, 3233, 306, 137, 10524, -1427, 6816, 725, 7022, 726, 2631, 14797, 732, 783, 512, 16536, 914, -1427, -1427, -1427, -1427, 489, -1427, 243, 14587, -1427, 14587, 16176, 14670, -1427, -1427, -1427, 924, -1427, 734, 787, 526, 526, 870, 870, 15779, 730, 928, 14887, 794, 16176, 15249, 14887, 14887, 14887, 4919, 16163, 14887, 14887, 14887, 14887, 14737, 14887, 14887, 14887, 14887, 14887, 14887, 14887, 14887, 14887, 14887, 14887, 14887, 14887, 14887, 14887, 14887, 14887, 14887, 14887, 14887, 14887, 14887, 16450, 13610, 13610, 13610, -1427, -1427, -1427, 13610, 13610, -1427, 424, -1427, 862, -1427, -1427, 16176, -1427, -1427, 16176, -1427, -1427, -1427, -1427, 14887, 512, -1427, 87, -1427, 844, 933, -1427, -1427, 93, 745, 512, 11554, -1427, 1883, -1427, 5992, 607, 933, -1427, 346, -41, 16450, 820, -1427, 16450, 16450, 15679, -1427, 748, 861, 14587, 655, 14587, 872, 938, 875, 13610, 205, 756, -1427, 14797, 13610, 16450, 16536, 757, 65, -1427, 754, 65, 759, 13223, 16450, 15735, 760, 10936, 764, 758, 14587, 767, 646, -1427, 451, 771, 10936, 766, 13610, -1427, -1427, -1427, -1427, -1427, -1427, 843, 768, 963, 14981, 829, -1427, 15249, 14981, -1427, -1427, -1427, 14797, 16450, -1427, 137, 945, 903, 10524, -1427, -1427, -1427, 776, 13610, 783, 512, 15029, 2631, 779, 14887, 7228, 543, 796, 13610, 30, 247, -1427, 811, -1427, 873, -1427, 14517, 965, 800, 14887, -1427, 14887, -1427, 803, -1427, 876, 997, 808, 16536, 809, 1001, 15835, 814, 1002, 815, -1427, -1427, -1427, 15877, 813, 1008, 11907, 12811, 13017, 14887, 16494, 3272, 4804, 5505, 14281, 4562, 14539, 14539, 14539, 14539, 1516, 1516, 1516, 1516, 874, 874, 526, 526, 526, 870, 870, 870, 870, 16450, 14210, 16450, -1427, 16450, -1427, 818, -1427, -1427, -1427, 16536, 16176, 14587, 15236, 66, -1427, 15029, -1427, -1427, 10919, 816, -1427, 819, 445, -1427, 160, 13610, -1427, -1427, -1427, 13610, -1427, 13610, 13610, -1427, 655, -1427, -1427, 281, 1011, 14887, -1427, 3466, 823, 10936, 512, 16450, 861, 827, -1427, 828, 65, 13610, 10936, 834, -1427, -1427, 607, -1427, 821, 830, -1427, 10936, 835, -1427, 14981, -1427, 14981, -1427, 838, -1427, 912, 841, 1034, -1427, 512, 1014, -1427, 845, -1427, -1427, 847, 848, 95, -1427, -1427, 16536, 850, 855, -1427, 3719, -1427, -1427, -1427, -1427, -1427, 14587, -1427, 14587, -1427, 16536, 15933, -1427, 14887, 15249, -1427, -1427, -1427, 14887, -1427, 14887, -1427, 14887, -1427, -1427, 14887, -1427, 14887, -1427, 13429, 14887, 13610, 853, 7434, 949, -1427, -1427, 226, 14587, 15236, -1427, 15977, 893, 2614, -1427, -1427, -1427, 608, 14375, 74, 457, 96, -1427, -1427, -1427, 900, 3544, 3600, 16450, 16450, -1427, 978, 1044, 981, 14887, 16536, 863, 10936, 866, 951, 861, 616, 861, 871, 16450, 877, -1427, 1009, 868, 1105, -1427, 65, 878, -1427, -1427, 935, -1427, 14981, -1427, 15249, -1427, -1427, 9288, -1427, -1427, -1427, -1427, 10112, -1427, -1427, -1427, 9288, -1427, 879, 14887, 16536, 939, 16536, 16536, 15975, 16536, 16031, 13429, 14166, -1427, -1427, 14587, 15236, 15236, 1060, 53, -1427, -1427, -1427, -1427, 76, 880, 79, -1427, 13980, -1427, -1427, 80, -1427, -1427, 5139, -1427, 882, -1427, 1006, 516, -1427, 14587, -1427, 608, -1427, 14233, -1427, -1427, -1427, -1427, 1062, 14887, -1427, 16536, 10936, 881, -1427, 887, 885, -64, -1427, 951, 861, -1427, -1427, -1427, -1427, 1365, 888, -1427, 14981, -1427, 961, 9288, 10318, 10112, -1427, -1427, -1427, 9288, -1427, 16536, 14887, 14887, 14887, 13610, 7640, -1427, 891, 895, 14887, 15236, -1427, -1427, 460, 15977, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, 387, -1427, 893, -1427, -1427, -1427, -1427, -1427, 67, 503, -1427, 1083, 81, 16176, 1006, 1084, 516, -1427, -1427, 902, 1087, 14887, 16536, 905, -1427, 94, -1427, -1427, -1427, -1427, 909, -64, 14283, -1427, 861, -1427, 14981, -1427, -1427, -1427, -1427, 7846, 16536, 16536, 16536, 5401, -1427, -1427, -1427, 16536, -1427, 1509, 35, -1427, -1427, 14887, 13980, 13980, 1057, -1427, 5139, 5139, 536, -1427, -1427, -1427, 14887, 1036, -1427, 917, 84, 14887, 16176, -1427, 14887, 16536, -1427, 1039, -1427, 1108, 8052, 8258, -1427, -1427, -1427, -64, -1427, 8464, 919, 1050, 1022, -1427, 1035, 985, -1427, -1427, 1041, 460, -1427, 16536, -1427, -1427, 975, -1427, 1102, -1427, -1427, -1427, -1427, 16536, 1124, -1427, -1427, 16536, 940, 16536, -1427, 115, 941, -1427, -1427, 8670, -1427, 943, -1427, -1427, 946, 977, 16176, 457, -1427, -1427, 14887, 99, -1427, 1061, -1427, -1427, -1427, -1427, 15236, 668, -1427, 984, 16176, 252, 16536, 947, 1139, 570, 99, -1427, 1072, -1427, 15236, 952, -1427, 861, 107, -1427, -1427, -1427, -1427, 14587, -1427, 955, 956, 85, -1427, 218, 570, 282, 861, 950, -1427, -1427, -1427, -1427, 14587, 1080, 1146, 1086, 218, -1427, 8876, 283, 1148, 14887, -1427, -1427, 9082, -1427, 1088, 1155, 1091, 14887, 16536, -1427, 1157, 14887, -1427, 16536, 14887, 16536, 16536 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { -1427, -1427, -1427, -507, -1427, -1427, -1427, -4, -1427, -1427, -1427, 663, 406, 404, -24, 1038, 3791, -1427, 2413, -1427, -304, -1427, 6, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -506, -1427, -1427, -176, 18, 2, -1427, -1427, -1427, -1427, -1427, -1427, 12, -1427, -1427, -1427, -1427, 13, -1427, -1427, 786, 792, 791, -128, 310, -802, 315, 378, -511, 90, -810, -1427, -253, -1427, -1427, -1427, -1427, -675, -75, -1427, -1427, -1427, -1427, -502, -1427, -543, -1427, -385, -1427, -1427, 676, -1427, -237, -1427, -1427, -988, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -266, -1427, -1427, -1427, -1427, -1427, -348, -1427, -109, -1165, -1427, -1426, -525, -1427, -159, 0, -134, -512, -1427, -355, -1427, -72, -23, 1161, -671, -371, -1427, -1427, -39, -1427, -1427, 3815, -60, -222, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -540, -784, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, 812, -1427, -1427, 210, -1427, 720, -1427, -1427, -1427, -1427, -1427, -1427, -1427, 215, -1427, 722, -1427, -1427, 453, -1427, 181, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1427, -1092, -1427, 1879, 1828, -342, -1427, -1427, 143, 3410, 4211, -1427, -1427, 265, -133, -581, -1427, -1427, 339, -659, 132, -1427, -1427, -1427, -1427, -1427, 329, -1427, -1427, -1427, 45, -814, -184, -164, -132, -1427, -1427, 51, -1427, -1427, -1427, -1427, 17, -170, -1427, 112, -1427, -1427, -1427, -395, 931, -1427, -1427, -1427, -1427, -1427, 913, -1427, -1427, -1427, 274, -1427, -1427, -1427, 41, 305, -1427, -1427, 944, -299, -985, -1427, -44, -83, -199, -212, 518, -1427, -1008, -1427, 219, 299, -1427, -1427, -1427, -178, -1015 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which number is the opposite. If zero, do what YYDEFACT says. If YYTABLE_NINF, syntax error. */ #define YYTABLE_NINF -887 static const yytype_int16 yytable[] = { 121, 346, 417, 390, 135, 308, 130, 419, 260, 236, 128, 558, 314, 315, 265, 849, 132, 133, 896, 1041, 241, 649, 129, 673, 245, 439, 1211, 831, 670, 830, 1208, 1031, 277, 412, 389, 915, 629, 804, 929, 1196, 1195, 319, 710, 336, 1638, 248, 444, 229, 258, 162, 346, 342, 1056, 321, 304, 164, 691, 305, 712, 930, 1264, 779, 1455, -768, 1011, 290, 445, 453, 1067, 779, 1300, 510, 515, 466, 467, 414, 1601, 215, 216, 471, 518, 410, 306, 1405, 290, -281, 410, 436, 1459, 1543, 1608, 290, 290, 1608, 1455, 284, 810, 793, 793, 446, 1602, 278, 793, -765, 793, 793, 1104, 950, 316, 533, 13, 13, 1202, 407, 407, 498, 421, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 1618, 290, 13, 407, 786, 787, 410, -886, 1568, 1569, 429, 557, 1085, 837, -772, 13, 696, 1624, 443, -766, 13, 1676, 437, 13, 345, 3, 592, -617, 333, 327, 329, 330, 1203, 391, -616, 322, 405, 406, 297, 1130, 602, 534, 1301, 499, 1619, -767, -803, 1302, -769, 58, 59, 60, 176, 177, 343, 1303, 414, -804, 577, -806, 803, -770, -886, 426, 761, 1677, -771, -774, -805, 811, -768, 1663, 1086, 420, 188, 209, 689, 378, 909, 910, 209, 1318, 415, 1332, 812, -440, 641, 523, 411, 379, 931, 1304, 1305, 411, 1306, 1012, 317, 279, -476, 524, 407, 713, 1265, 121, 711, 1334, 337, 121, 641, 1639, -765, 460, 1340, 450, 1342, 674, 1341, 455, 344, 504, 508, 509, 1111, 780, 1115, 1456, 1457, 600, 346, 473, 454, 781, 641, 430, 511, 516, -222, 1232, 1603, 432, 1307, 641, 411, 519, 641, 438, 1406, -775, -281, 543, -772, 1460, 1544, 1609, -222, -766, 1653, 1715, 164, 794, 883, 715, 164, 598, 1188, 680, 1359, 1408, 1257, 1024, -208, 232, -699, 577, 1244, -699, 308, 342, -699, 1053, 295, -767, -803, 309, -769, 540, 1042, 1324, 1720, 1733, 121, 295, 415, -804, 135, -806, 1423, -770, 1425, 589, 416, 514, -771, 258, -805, 116, 290, 235, 520, 520, 525, 295, 129, 1113, 1114, 530, 540, 1113, 1114, 242, 295, 539, 1380, 1381, 650, 296, 1431, 681, 243, -886, 1043, 1325, 1721, 1734, 573, 58, 59, 60, 176, 177, 343, 244, 512, 269, 333, 164, 298, 299, 1095, 1096, 333, 282, 639, 290, 643, 290, 290, 298, 299, 827, 828, 767, 838, 771, 286, 912, 229, 835, 1017, 287, 914, 772, 1596, 640, 666, -886, 309, 298, 299, 646, 1000, -886, 839, 699, -886, 297, 298, 299, 1597, 1572, 1716, 1717, 816, 295, 1003, 667, 390, 332, 683, 821, 1247, 295, 825, 1254, 344, 1598, 540, 1645, 1646, 588, 693, 866, 1044, 1326, 1722, 1735, 332, 1116, 332, 640, 1300, 1267, 332, 121, 1697, 295, 332, 389, 690, 283, 325, 694, 295, 704, 51, 332, 288, 328, 876, 587, 530, 872, 58, 59, 60, 176, 177, 343, 764, 332, 430, 295, 768, 1064, 289, 866, 540, 277, 535, 298, 299, 13, 293, 1073, 1369, 633, 541, 298, 299, 838, 1197, 1210, 545, 546, 864, 903, 1641, 1642, 164, 774, 938, 941, 1221, 1198, 294, 1223, 310, 558, 311, 839, 856, 298, 299, 668, 312, 904, 313, 671, 298, 299, 798, 800, 1070, 1604, 324, 33, 34, 35, 331, 439, 332, 344, 335, 347, 592, 592, 728, 298, 299, 1199, 1605, 1301, 338, 1606, 348, 349, 1302, 905, 58, 59, 60, 176, 177, 343, 1303, 350, 1647, 351, 1626, 1436, 58, 59, 60, 176, 177, 343, 981, 982, 983, 352, 1347, -474, 1348, 1648, 381, 391, 1649, 935, 1112, 1113, 1114, 382, 984, 72, 73, 74, 75, 76, 383, 290, 1304, 1305, 536, 1306, 730, 384, 542, 478, 479, 480, 79, 80, 385, 413, 481, 482, 573, -773, 483, 484, 1110, 1300, -475, -616, 89, 418, 302, 344, 423, 1025, 425, 536, 379, 542, 536, 542, 542, 333, 431, 344, 407, 97, 1261, 1113, 1114, 845, 557, 434, 435, 1317, 1190, 441, 1037, -615, 558, 58, 59, 60, 61, 62, 343, 440, 13, 443, 451, 1048, 68, 386, 641, 1323, 468, 375, 376, 377, 894, 378, 899, 469, 464, 1227, 913, -881, 1336, 1701, 1702, 1703, 472, 379, 1236, 474, 1712, 1710, 1435, 121, 475, 477, 517, 135, 526, 527, 874, 387, 566, 388, 567, 1726, 1723, 922, 121, 575, 576, -65, 1256, 51, 679, 129, 586, 702, 924, 599, 677, 709, 1301, 682, 344, 453, 688, 1302, 721, 58, 59, 60, 176, 177, 343, 1303, 900, 722, 901, 706, 747, 748, 750, 504, 751, 759, 762, 508, 164, 765, 766, 769, 770, 1117, 778, 1118, 790, 792, 121, 782, 920, 783, 135, 164, 1002, 1089, 785, 801, 1005, 1006, 795, 1304, 1305, 807, 1306, 806, 1576, 814, 809, 815, 129, 817, 818, 557, 819, 820, 1013, 823, 824, 558, 1069, 826, 829, 832, 833, 1314, -477, 842, 344, 844, 847, 121, 1432, 848, 850, 135, 853, 130, 859, 1123, 860, 128, 863, 164, 867, 1032, 1127, 132, 133, 862, 1424, 880, 877, 129, 58, 59, 60, 61, 62, 343, 878, 1009, 881, 1331, 1046, 68, 386, 855, 916, 932, 906, 933, 1338, 926, 530, 1019, 928, 934, 1216, 949, 162, 1345, 936, 951, 952, 1047, 164, 953, 954, 955, 957, 1690, 1209, 958, 835, 986, 988, 992, 987, 290, 995, 998, 388, 1008, 1010, 1020, 1016, 1296, 1690, 573, 1029, 1078, 1078, 894, 1021, 1036, 1711, 1098, 1027, 1230, 1038, 229, 1039, 344, 1054, 1063, 1072, 573, 1066, 1074, 1088, 372, 373, 374, 375, 376, 377, 121, 378, 121, 1090, 121, 1107, 135, 1084, 135, 1087, 1099, 557, 1627, 379, 978, 979, 980, 981, 982, 983, 1101, 1103, 1109, 1119, 129, 1106, 129, 1121, 1122, 984, 1125, 1126, 535, 984, 1185, 1179, 1186, 1048, 1189, 1419, 1355, 1129, 1205, 1207, 1241, 1212, 1213, 1142, 1214, 1217, 1222, 1220, 1224, 1226, 1229, 164, 1364, 164, 1228, 164, 1237, 920, 1105, 1231, 1235, 1238, 1240, 1243, 1239, 1250, 1251, 1253, 558, 1258, 1268, 1191, 421, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 1271, 1181, 1262, 1278, 1182, 1272, 1269, 1282, 1275, 1276, 1286, 1277, 1298, 1279, 1280, 1281, 1285, 1291, 1300, 1284, 1287, 1289, 1290, 1295, 1315, 121, 1316, 1330, 1343, 135, 1327, 130, 1333, 1335, 1344, 128, 405, 406, 1564, 1339, 1346, 132, 133, 1349, 1659, 1350, 1351, 129, 1352, 1354, 1379, 1356, 1357, 1358, 1394, 1437, 1361, 1410, 558, 13, 1377, 1362, 1414, 1415, 1443, 1416, 1421, 1418, 1434, 212, 212, 1420, 1446, 224, 162, 1429, 1426, 1249, 1450, 1454, 164, 1562, 1427, 1433, 1444, 894, 1565, 1458, 1551, 894, 1552, 1566, 1567, 1575, 1577, 224, 1365, 1588, 1366, 121, 407, 1589, 1607, 1612, 573, 1218, 1615, 573, 1614, 1252, 1617, 121, 557, 1700, 1300, 135, 1623, 1643, 1353, 1301, 1651, 1652, 1658, 1657, 1302, 1665, 58, 59, 60, 176, 177, 343, 1303, 129, 1666, 1667, -277, 1669, 1404, 1672, 1602, 1582, 1670, 1673, 1675, 1692, 1678, 1682, 1248, 1680, 1681, 1695, 1698, 1699, 164, 13, 1707, 1724, 1709, 1407, 1713, 1714, 530, 920, 1727, 1728, 164, 1736, 1304, 1305, 1729, 1306, 1739, 784, 1740, 1741, 1743, 1001, 773, 1004, 645, 1694, 346, 642, 644, 1297, 1068, 557, 1065, 1708, 1026, 1581, 1311, 1363, 1706, 344, 776, 1573, 1595, 1255, 1600, 1311, 1401, 1730, 1719, 1611, 1451, 238, 1571, 652, 1178, 757, 1176, 758, 1200, 1301, 994, 1428, 1234, 1128, 1302, 1242, 58, 59, 60, 176, 177, 343, 1303, 1080, 532, 565, 1554, 1091, 1139, 1184, 522, 1313, 1120, 894, 0, 894, 0, 0, 939, 530, 1313, 0, 0, 0, 0, 0, 0, 0, 212, 0, 0, 0, 0, 0, 212, 0, 1382, 0, 1304, 1305, 212, 1306, 1621, 0, 1622, 0, 0, 0, 573, 0, 0, 0, 0, 1628, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 344, 0, 0, 224, 224, 0, 121, 0, 0, 224, 135, 258, 0, 0, 0, 0, 1399, 0, 0, 0, 0, 0, 1430, 0, 0, 0, 0, 391, 129, 0, 0, 212, 0, 1662, 0, 0, 0, 0, 212, 212, 0, 0, 1403, 0, 0, 212, 0, 0, 1311, 0, 0, 212, 0, 0, 1311, 0, 1311, 0, 0, 0, 894, 164, 224, 0, 0, 121, 0, 0, 0, 135, 121, 0, 0, 0, 121, 1556, 0, 0, 135, 0, 1441, 0, 0, 1300, 0, 224, 0, 129, 224, 0, 0, 0, 0, 1313, 0, 1613, 129, 0, 0, 1313, 0, 1313, 1540, 573, 0, 0, 0, 0, 1547, 0, 0, 0, 0, 0, 0, 258, 0, 0, 0, 258, 164, 0, 0, 0, 13, 164, 0, 1725, 0, 164, 224, 0, 0, 0, 1731, 0, 0, 0, 0, 1557, 0, 0, 0, 0, 894, 1311, 0, 121, 121, 121, 0, 135, 0, 121, 0, 0, 0, 135, 1579, 1441, 121, 0, 0, 0, 135, 0, 0, 0, 0, 129, 212, 0, 0, 0, 0, 129, 0, 0, 0, 0, 212, 0, 129, 0, 1301, 1610, 0, 0, 0, 1302, 1313, 58, 59, 60, 176, 177, 343, 1303, 0, 0, 0, 0, 164, 164, 164, 0, 0, 0, 164, 0, 0, 0, 0, 0, 0, 164, 0, 0, 0, 0, 224, 224, 0, 0, 737, 1685, 0, 0, 0, 0, 0, 0, 0, 1304, 1305, 0, 1306, 0, 0, 0, 835, 0, 0, 0, 1655, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 835, 0, 0, 0, 0, 344, 0, 0, 0, 290, 0, 346, 0, 0, 737, -887, -887, -887, -887, 976, 977, 978, 979, 980, 981, 982, 983, 1574, 258, 0, 0, 0, 894, 0, 0, 0, 0, 121, 0, 0, 984, 135, 0, 0, 0, 36, 0, 1633, 0, 0, 0, 0, 1540, 1540, 0, 0, 1547, 1547, 0, 129, 0, 0, 0, 224, 224, 0, 0, 0, 290, 0, 0, 224, 0, 0, 0, 0, 121, 121, 0, 0, 135, 135, 0, 121, 0, 0, 0, 135, 0, 0, 212, 0, 164, 0, 0, 0, 0, 0, 129, 129, 0, 0, 0, 0, 0, 129, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 180, 121, 0, 81, 0, 135, 83, 84, 1684, 85, 181, 87, 0, 1686, 0, 164, 164, 0, 0, 0, 0, 0, 164, 129, 1696, 0, 0, 0, 0, 212, 0, 0, 0, 0, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 0, 0, 0, 0, 0, 0, 0, 1632, 164, 0, 0, 0, 0, 0, 573, 0, 121, 212, 0, 212, 135, 0, 121, 0, 0, 0, 135, 0, 0, 0, 0, 573, 0, 0, 0, 0, 0, 0, 129, 573, 0, 212, 737, 0, 129, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 224, 737, 737, 737, 737, 737, 0, 0, 0, 0, 0, 0, 0, 0, 737, 0, 164, 0, 0, 0, 0, 0, 164, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 0, 0, 0, 0, 224, -887, -887, -887, -887, 370, 371, 372, 373, 374, 375, 376, 377, 0, 378, 0, 0, 212, 0, 0, 0, 0, 0, 0, 0, 0, 379, 0, 224, 0, 212, 212, 405, 406, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 224, 0, 0, 0, 0, 0, 0, 0, 224, 214, 214, 0, 0, 226, 0, 0, 0, 0, 0, 0, 0, 0, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 0, 0, 0, 0, 0, 0, 0, 737, 0, 0, 224, 0, 353, 354, 355, 407, 0, 0, 0, 0, 0, 0, 0, 0, 213, 213, 0, 0, 225, 0, 224, 356, 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 0, 378, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 379, 0, 0, 0, 0, 0, 212, 212, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 0, 224, 0, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 737, 0, 0, 224, 737, 737, 737, 0, 0, 737, 737, 737, 737, 737, 737, 737, 737, 737, 737, 737, 737, 737, 737, 737, 737, 737, 737, 737, 737, 737, 737, 737, 737, 737, 737, 737, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 353, 354, 355, 0, 0, 0, 214, 0, 0, 0, 0, 0, 214, 737, 0, 0, 0, 0, 214, 356, 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 0, 378, 224, 0, 224, 0, 0, 0, 0, 0, 0, 0, 212, 379, 1193, 0, 0, 0, 0, 0, 0, 213, 0, 0, 0, 0, 0, 0, 36, 224, 209, 0, 214, 0, 0, 0, 0, 0, 0, 214, 214, 0, 0, 0, 0, 0, 214, 0, 0, 0, 224, 0, 214, 0, 0, 212, 0, 0, 0, 0, 0, 0, 0, 556, 0, 0, 0, 0, 0, 212, 212, 0, 737, 0, 637, 0, 0, 0, 0, 0, 0, 0, 0, 213, 224, 0, 0, 737, 0, 737, 213, 213, 0, 0, 0, 0, 0, 213, 0, 0, 0, 0, 0, 213, 0, 83, 84, 0, 85, 181, 87, 0, 737, 0, 213, 0, 0, 0, 421, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 226, 0, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 0, 224, 224, 0, 802, 212, 638, 0, 116, 0, 0, 0, 0, 0, 0, 0, 0, 353, 354, 355, 405, 406, 0, 0, 214, 0, 0, 0, 0, 737, 0, 0, 0, 0, 214, 225, 356, 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 0, 378, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 379, 0, 0, 213, 0, 0, 0, 0, 0, 0, 0, 0, 407, 224, 0, 224, 0, 0, 0, 0, 737, 224, 0, 0, 0, 737, 0, 737, 0, 737, 0, 0, 737, 0, 737, 0, 0, 737, 0, 0, 0, 0, 0, 0, 0, 224, 224, 0, 224, 0, 0, 353, 354, 355, 0, 224, 0, 743, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 356, 737, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 0, 378, 0, 224, 0, 0, 36, 0, 209, 743, 0, 0, 0, 379, 0, 0, 0, 0, 737, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 224, 224, 0, 214, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 841, 210, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 0, 0, 0, 224, 0, 0, 0, 0, 0, 737, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 180, 259, 0, 81, 82, 0, 83, 84, 213, 85, 181, 87, 214, 0, 0, 0, 0, 0, 0, 0, 737, 737, 737, 0, 0, 0, 0, 0, 737, 224, 0, 0, 0, 224, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 214, 0, 214, 211, 0, 0, 513, 0, 116, 353, 354, 355, 0, 0, 0, 213, 0, 0, 0, 0, 0, 0, 0, 0, 214, 0, 879, 0, 356, 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 213, 378, 213, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 379, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 213, 743, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 737, 0, 743, 743, 743, 743, 743, 214, 0, 0, 0, 224, 0, 0, 0, 743, 0, 0, 0, 0, 214, 214, 0, 0, 0, 0, 0, 0, 0, 0, 224, 0, 0, 0, 737, 0, 0, 0, 0, 0, 0, 997, 0, 556, 0, 737, 0, 0, 0, 0, 737, 0, 0, 737, 0, 0, 0, 0, 213, 0, 0, 0, 0, 0, 259, 259, 917, 0, 0, 1015, 259, 213, 213, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1015, 0, 0, 0, 0, 36, 0, 0, 213, 0, 0, 0, 0, 0, 0, 226, 0, 0, 0, 0, 0, 0, 36, 0, 209, 737, 0, 0, 882, 0, 0, 0, 0, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 743, 0, 0, 1055, 224, 0, 1397, 0, 0, 0, 0, 0, 0, 224, 0, 214, 214, 259, 0, 210, 259, 0, 0, 225, 0, 0, 0, 0, 224, 0, 0, 918, 0, 0, 0, 0, 0, 737, 0, 83, 84, 0, 85, 181, 87, 737, 0, 0, 0, 737, 180, 556, 737, 81, 82, 0, 83, 84, 0, 85, 181, 87, 0, 0, 0, 0, 213, 213, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 0, 0, 0, 1398, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 0, 743, 0, 211, 213, 743, 743, 743, 116, 0, 743, 743, 743, 743, 743, 743, 743, 743, 743, 743, 743, 743, 743, 743, 743, 743, 743, 743, 743, 743, 743, 743, 743, 743, 743, 743, 743, 0, 0, 0, 353, 354, 355, 0, 0, 0, 0, 0, 0, 0, 214, 0, 0, 0, 259, 717, 0, 0, 739, 356, 743, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 0, 378, 0, 0, 0, 0, 556, 0, 353, 354, 355, 214, 0, 379, 0, 0, 0, 0, 0, 213, 0, 739, 0, 0, 0, 214, 214, 356, 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 0, 378, 0, 0, 0, 0, 0, 213, 0, 0, 0, 0, 213, 379, 0, 0, 0, 0, 0, 0, 259, 259, 0, 0, 0, 0, 213, 213, 259, 743, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 743, 0, 743, 0, 0, 353, 354, 355, 0, 0, 0, 0, 0, 0, 214, 0, 0, 0, 0, 0, 0, 0, 0, 0, 356, 743, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 355, 378, 0, 0, 0, 0, 0, 0, 0, 0, 1007, 0, 0, 379, 0, 1299, 0, 356, 213, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 0, 378, 743, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 379, 0, 556, 0, 0, 0, 0, 1062, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 739, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 259, 259, 739, 739, 739, 739, 739, 0, 0, 0, 0, 0, 0, 0, 0, 739, 0, 0, 0, 0, 0, 743, 213, 0, 0, 0, 743, 0, 743, 0, 743, 0, 0, 743, 0, 743, 0, 0, 743, 0, 0, 0, 0, 0, 0, 0, 556, 1384, 0, 1393, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 1071, 378, 0, 0, 0, 743, 0, 0, 0, 0, 0, 0, 0, 379, 0, 0, 0, 0, 259, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 213, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 259, 353, 354, 355, 743, 0, 0, 0, 0, 0, 0, 0, 0, 259, 0, 0, 0, 1452, 1453, 0, 356, 739, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 0, 378, 0, 0, 0, 0, 0, 0, 0, 743, 0, 0, 0, 379, 0, 0, 0, 0, 251, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 0, 743, 743, 743, 0, 252, 0, 0, 0, 743, 1591, 0, 0, 984, 1393, 0, 0, 0, 0, 259, 0, 259, 0, 717, 0, 0, 0, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 739, 0, 0, 0, 739, 739, 739, 0, 0, 739, 739, 739, 739, 739, 739, 739, 739, 739, 739, 739, 739, 739, 739, 739, 739, 739, 739, 739, 739, 739, 739, 739, 739, 739, 739, 739, 0, 0, 0, 0, 0, 0, 253, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 739, 180, 0, 0, 81, 255, 0, 83, 84, 0, 85, 181, 87, 0, 937, 1094, 0, 0, 0, 0, 743, 0, 0, 0, 0, 256, 0, 0, 0, 0, 0, 259, 0, 259, 0, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 0, 0, 0, 257, 0, 743, 353, 354, 355, 259, 0, 0, 0, 0, 0, 0, 743, 0, 0, 0, 0, 743, 0, 0, 743, 356, 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 0, 378, 0, 0, 739, 0, 0, 0, 0, 0, 0, 0, 0, 379, 0, 0, 259, 0, 0, 739, 0, 739, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 743, 0, 353, 354, 355, 0, 0, 0, 1693, 0, 739, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 356, 1384, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 0, 378, 259, 0, 0, 0, 0, 0, 0, 0, 0, 743, 0, 379, 353, 354, 355, 0, 0, 743, 0, 0, 0, 743, 0, 0, 743, 0, 0, 0, 739, 0, 0, 356, 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 0, 378, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 379, 0, 0, 0, 1329, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 259, 0, 259, 0, 0, 0, 0, 739, 0, 0, 0, 0, 739, 0, 739, 0, 739, 0, 0, 739, 0, 739, 0, 0, 739, 0, 0, 0, 0, 0, 0, 0, 259, 0, 0, 0, 0, 0, 0, 0, 0, 0, 259, 0, 0, 0, 0, 353, 354, 355, 0, 0, 0, 0, 0, 0, 0, 0, 739, 0, 0, 0, 0, 0, 0, 1412, 356, 1264, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 0, 378, 0, 0, 0, 0, 0, 0, 0, 739, 0, 0, 0, 379, 0, 0, 0, 0, 0, 0, 0, 259, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1413, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 259, 0, 185, 187, 259, 189, 190, 191, 193, 194, 739, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 0, 0, 218, 221, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 239, 0, 0, 739, 739, 739, 0, 247, 0, 250, 0, 739, 266, 0, 271, 353, 354, 355, 0, 0, 0, 0, 0, 0, 0, 0, 744, 36, 0, 209, 0, 0, 0, 0, 356, 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 0, 378, 353, 354, 355, 0, 0, 1265, 0, 0, 0, 0, 0, 379, 744, 320, 0, 0, 0, 0, 0, 356, 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 0, 378, 0, 83, 84, 0, 85, 181, 87, 0, 0, 0, 0, 379, 0, 0, 0, 0, 739, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 259, 0, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 0, 422, 0, 1634, 0, 0, 665, 739, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 739, 0, 0, 0, 0, 739, 0, 0, 739, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 353, 354, 355, 0, 0, 448, 0, 0, 448, 0, 0, 0, 0, 0, 0, 239, 459, 0, 0, 356, 380, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 0, 378, 739, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 379, 0, 0, 0, 0, 0, 320, 0, 0, 463, 0, 0, 218, 0, 0, 0, 538, 0, 0, 0, 259, 0, 744, 0, 0, 0, 0, 0, 0, 559, 562, 562, 0, 0, 0, 259, 744, 744, 744, 744, 744, 0, 585, 0, 739, 0, 0, 0, 0, 744, 0, 0, 739, 597, 0, 0, 739, 0, 0, 739, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 603, 604, 605, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 0, 630, 0, 631, 631, 0, 634, 0, 0, 0, 0, 0, 0, 0, 651, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 0, 0, 0, 0, 0, 631, 669, 0, 597, 631, 672, 0, 0, 465, 0, 0, 651, 0, 0, 676, 0, 0, 0, 0, 0, 0, 0, 0, 685, 0, 687, 0, 353, 354, 355, 0, 597, 0, 0, 0, 744, 0, 0, 738, 0, 0, 700, 0, 701, 0, 0, 356, 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 749, 378, 0, 752, 755, 756, 0, 0, 0, 0, 0, 0, 0, 379, 738, 0, 0, 353, 354, 355, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 775, 0, 356, 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 0, 378, 0, 0, 0, 0, 744, 0, 0, 0, 744, 744, 744, 379, 0, 744, 744, 744, 744, 744, 744, 744, 744, 744, 744, 744, 744, 744, 744, 744, 744, 744, 744, 744, 744, 744, 744, 744, 744, 744, 744, 744, 0, 0, 0, 0, 0, 0, 353, 354, 355, 0, 0, 0, 0, 0, 846, 0, 0, 0, 0, 0, 0, 0, 0, 744, 0, 356, 857, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 476, 378, 0, 0, 0, 0, 0, 0, 0, 0, 865, 0, 0, 379, 0, 0, 0, 0, 0, 193, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 875, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 738, 378, 500, 0, 0, 0, 0, 907, 0, 0, 0, 0, 0, 379, 738, 738, 738, 738, 738, 744, 0, 239, 0, 0, 0, 0, 0, 738, 0, 0, 0, 0, 0, 0, 744, 0, 744, 36, 0, 209, 0, 0, 353, 354, 355, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 744, 0, 356, 985, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 0, 378, 0, 0, 0, 0, 0, 675, 0, 0, 0, 0, 0, 379, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 83, 84, 1022, 85, 181, 87, 0, 0, 0, 744, 0, 0, 0, 984, 0, 1030, 0, 0, 0, 0, 0, 1033, 0, 1034, 0, 1035, 0, 738, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 0, 0, 0, 0, 0, 0, 638, 1051, 116, 0, 0, 0, 0, 0, 0, 0, 0, 1059, 0, 0, 1060, 0, 1061, 0, 0, 0, 597, 745, 0, 0, 744, 0, 0, 0, 0, 744, 597, 744, 0, 744, 0, 0, 744, 0, 744, 0, 0, 744, 36, 0, 209, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1093, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 777, 0, 0, 0, 695, 0, 0, 0, 0, 744, 0, 0, 738, 0, 0, 0, 738, 738, 738, 0, 0, 738, 738, 738, 738, 738, 738, 738, 738, 738, 738, 738, 738, 738, 738, 738, 738, 738, 738, 738, 738, 738, 738, 738, 738, 738, 738, 738, 0, 744, 0, 0, 0, 83, 84, 0, 85, 181, 87, 0, 0, 0, 0, 0, 1075, 1076, 1077, 36, 0, 0, 0, 738, 0, 1173, 1174, 1175, 0, 0, 0, 752, 1177, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 0, 0, 744, 0, 0, 0, 692, 0, 116, 0, 0, 0, 1192, 0, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 744, 744, 744, 0, 1215, 0, 0, 0, 744, 1219, 0, 0, 1594, 984, 0, 0, 83, 84, 0, 85, 181, 87, 597, 0, 0, 0, 0, 0, 0, 0, 0, 597, 0, 1192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 738, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 0, 738, 0, 738, 239, 0, 921, 0, 0, 0, 0, 0, 0, 0, 1263, 959, 960, 961, 0, 0, 942, 943, 944, 945, 0, 0, 738, 0, 0, 0, 0, 0, 0, 956, 962, 0, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 0, 744, 0, 0, 0, 0, 0, 29, 30, 0, 0, 0, 0, 984, 0, 0, 0, 36, 0, 209, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 738, 0, 744, 0, 0, 0, 0, 0, 0, 0, 1319, 0, 0, 744, 1320, 0, 1321, 1322, 744, 0, 0, 744, 0, 0, 210, 0, 0, 0, 597, 0, 0, 0, 0, 0, 0, 0, 1337, 597, 0, 0, 0, 0, 0, 0, 1671, 0, 597, 0, 0, 0, 0, 0, 0, 0, 0, 180, 0, 1052, 81, 82, 0, 83, 84, 738, 85, 181, 87, 0, 738, 0, 738, 0, 738, 90, 0, 738, 0, 738, 0, 744, 738, 0, 0, 0, 0, 0, 0, 0, 0, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 0, 0, 1376, 428, 0, 0, 0, 0, 116, 0, 0, 738, 1140, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 744, 378, 0, 0, 0, 0, 36, 597, 744, 0, 0, 0, 744, 379, 0, 744, 0, 0, 0, 0, 738, 0, 0, 0, 0, 0, 1133, 1136, 1136, 0, 0, 1143, 1146, 1147, 1148, 1150, 1151, 1152, 1153, 1154, 1155, 1156, 1157, 1158, 1159, 1160, 1161, 1162, 1163, 1164, 1165, 1166, 1167, 1168, 1169, 1170, 1171, 1172, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 738, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 0, 1183, 0, 83, 84, 0, 85, 181, 87, 0, 0, 0, 0, 0, 0, 597, 0, 0, 0, 738, 738, 738, 0, 0, 0, 0, 0, 738, 353, 354, 355, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 0, 1586, 356, 599, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 0, 378, 0, 1545, 0, 83, 84, 1546, 85, 181, 87, 0, 0, 379, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1259, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 1273, 0, 1274, 1398, 0, 353, 354, 355, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 738, 0, 0, 0, 0, 0, 356, 1292, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 0, 378, 0, 0, 0, 738, 0, 0, 0, 0, 0, 0, 0, 379, 0, 0, 738, 36, 0, 209, 0, 738, 0, 0, 738, 0, 0, 0, 0, 353, 354, 355, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1328, 0, 0, 0, 0, 0, 356, 993, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 0, 378, 0, 0, 0, 0, 0, 0, 0, 0, 0, 738, 0, 379, 0, 0, 0, 0, 0, 0, 0, 0, 0, 83, 84, 0, 85, 181, 87, 0, 0, 0, 0, 0, 1368, 0, 0, 0, 0, 1370, 0, 1371, 0, 1372, 0, 0, 1373, 0, 1374, 0, 0, 1375, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 0, 738, 0, 989, 990, 0, 1045, 0, 116, 738, 0, 0, 0, 738, 0, 0, 738, 0, 0, 0, 1417, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 0, 0, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 10, 984, 0, 0, 0, 0, 0, 0, 0, 1445, 0, 0, 0, 0, 647, 12, 0, 0, 0, 0, 1630, 0, 648, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 15, 0, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 1563, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1583, 1584, 1585, 51, 0, 0, 0, 0, 1590, 0, 0, 58, 59, 60, 176, 177, 178, 0, 0, 65, 66, 0, 0, 0, 0, 0, 0, 0, 179, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 0, 0, 0, 89, 0, 0, 90, 0, 0, 0, 0, 0, 91, 92, 93, 94, 0, 0, 0, 0, 97, 98, 263, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 0, 0, 0, 116, 117, 0, 118, 119, 0, 0, 0, 0, 0, 0, 0, 0, 1616, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 1640, 0, 0, 0, 0, 0, 11, 12, 0, 0, 0, 1650, 0, 0, 0, 0, 1654, 0, 0, 1656, 0, 0, 0, 0, 13, 14, 15, 0, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 32, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 39, 0, 0, 0, 40, 41, 42, 43, 0, 44, 0, 45, 0, 46, 0, 0, 47, 1687, 0, 0, 48, 49, 50, 51, 52, 53, 54, 0, 55, 56, 57, 58, 59, 60, 61, 62, 63, 0, 64, 65, 66, 67, 68, 69, 0, 0, 0, 0, 70, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 78, 79, 80, 81, 82, 1737, 83, 84, 0, 85, 86, 87, 88, 1742, 0, 89, 0, 1744, 90, 0, 1745, 0, 0, 0, 91, 92, 93, 94, 95, 0, 96, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 114, 115, 1023, 116, 117, 0, 118, 119, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 14, 15, 0, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 32, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 39, 0, 0, 0, 40, 41, 42, 43, 0, 44, 0, 45, 0, 46, 0, 0, 47, 0, 0, 0, 48, 49, 50, 51, 52, 53, 54, 0, 55, 56, 57, 58, 59, 60, 61, 62, 63, 0, 64, 65, 66, 67, 68, 69, 0, 0, 0, 0, 70, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 78, 79, 80, 81, 82, 0, 83, 84, 0, 85, 86, 87, 88, 0, 0, 89, 0, 0, 90, 0, 0, 0, 0, 0, 91, 92, 93, 94, 95, 0, 96, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 114, 115, 1194, 116, 117, 0, 118, 119, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 14, 15, 0, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 32, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 39, 0, 0, 0, 40, 41, 42, 43, 0, 44, 0, 45, 0, 46, 0, 0, 47, 0, 0, 0, 48, 49, 50, 51, 52, 53, 54, 0, 55, 56, 57, 58, 59, 60, 61, 62, 63, 0, 64, 65, 66, 67, 68, 69, 0, 0, 0, 0, 70, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 78, 79, 80, 81, 82, 0, 83, 84, 0, 85, 86, 87, 88, 0, 0, 89, 0, 0, 90, 0, 0, 0, 0, 0, 91, 92, 93, 94, 95, 0, 96, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 114, 115, 0, 116, 117, 0, 118, 119, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 14, 15, 0, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 32, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 39, 0, 0, 0, 40, 41, 42, 43, 0, 44, 0, 45, 0, 46, 0, 0, 47, 0, 0, 0, 48, 49, 50, 51, 0, 53, 54, 0, 55, 0, 57, 58, 59, 60, 61, 62, 63, 0, 64, 65, 66, 0, 68, 69, 0, 0, 0, 0, 70, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 88, 0, 0, 89, 0, 0, 90, 0, 0, 0, 0, 0, 91, 92, 93, 94, 0, 0, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 114, 115, 578, 116, 117, 0, 118, 119, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 14, 15, 0, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 32, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 39, 0, 0, 0, 40, 41, 42, 43, 0, 44, 0, 45, 0, 46, 0, 0, 47, 0, 0, 0, 48, 49, 50, 51, 0, 53, 54, 0, 55, 0, 57, 58, 59, 60, 61, 62, 63, 0, 64, 65, 66, 0, 68, 69, 0, 0, 0, 0, 70, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 88, 0, 0, 89, 0, 0, 90, 0, 0, 0, 0, 0, 91, 92, 93, 94, 0, 0, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 114, 115, 996, 116, 117, 0, 118, 119, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 14, 15, 0, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 32, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 39, 0, 0, 0, 40, 41, 42, 43, 0, 44, 0, 45, 0, 46, 0, 0, 47, 0, 0, 0, 48, 49, 50, 51, 0, 53, 54, 0, 55, 0, 57, 58, 59, 60, 61, 62, 63, 0, 64, 65, 66, 0, 68, 69, 0, 0, 0, 0, 70, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 88, 0, 0, 89, 0, 0, 90, 0, 0, 0, 0, 0, 91, 92, 93, 94, 0, 0, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 114, 115, 1100, 116, 117, 0, 118, 119, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 14, 15, 0, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 32, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 39, 0, 0, 0, 40, 41, 42, 43, 1102, 44, 0, 45, 0, 46, 0, 0, 47, 0, 0, 0, 48, 49, 50, 51, 0, 53, 54, 0, 55, 0, 57, 58, 59, 60, 61, 62, 63, 0, 64, 65, 66, 0, 68, 69, 0, 0, 0, 0, 70, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 88, 0, 0, 89, 0, 0, 90, 0, 0, 0, 0, 0, 91, 92, 93, 94, 0, 0, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 114, 115, 0, 116, 117, 0, 118, 119, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 14, 15, 0, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 32, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 39, 0, 0, 0, 40, 41, 42, 43, 0, 44, 0, 45, 0, 46, 1260, 0, 47, 0, 0, 0, 48, 49, 50, 51, 0, 53, 54, 0, 55, 0, 57, 58, 59, 60, 61, 62, 63, 0, 64, 65, 66, 0, 68, 69, 0, 0, 0, 0, 70, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 88, 0, 0, 89, 0, 0, 90, 0, 0, 0, 0, 0, 91, 92, 93, 94, 0, 0, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 114, 115, 0, 116, 117, 0, 118, 119, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 14, 15, 0, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 32, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 39, 0, 0, 0, 40, 41, 42, 43, 0, 44, 0, 45, 0, 46, 0, 0, 47, 0, 0, 0, 48, 49, 50, 51, 0, 53, 54, 0, 55, 0, 57, 58, 59, 60, 61, 62, 63, 0, 64, 65, 66, 0, 68, 69, 0, 0, 0, 0, 70, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 88, 0, 0, 89, 0, 0, 90, 0, 0, 0, 0, 0, 91, 92, 93, 94, 0, 0, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 114, 115, 1378, 116, 117, 0, 118, 119, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 14, 15, 0, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 32, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 39, 0, 0, 0, 40, 41, 42, 43, 0, 44, 0, 45, 0, 46, 0, 0, 47, 0, 0, 0, 48, 49, 50, 51, 0, 53, 54, 0, 55, 0, 57, 58, 59, 60, 61, 62, 63, 0, 64, 65, 66, 0, 68, 69, 0, 0, 0, 0, 70, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 88, 0, 0, 89, 0, 0, 90, 0, 0, 0, 0, 0, 91, 92, 93, 94, 0, 0, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 114, 115, 1587, 116, 117, 0, 118, 119, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 14, 15, 0, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 32, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 39, 0, 0, 0, 40, 41, 42, 43, 0, 44, 0, 45, 1629, 46, 0, 0, 47, 0, 0, 0, 48, 49, 50, 51, 0, 53, 54, 0, 55, 0, 57, 58, 59, 60, 61, 62, 63, 0, 64, 65, 66, 0, 68, 69, 0, 0, 0, 0, 70, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 88, 0, 0, 89, 0, 0, 90, 0, 0, 0, 0, 0, 91, 92, 93, 94, 0, 0, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 114, 115, 0, 116, 117, 0, 118, 119, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 14, 15, 0, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 32, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 39, 0, 0, 0, 40, 41, 42, 43, 0, 44, 0, 45, 0, 46, 0, 0, 47, 0, 0, 0, 48, 49, 50, 51, 0, 53, 54, 0, 55, 0, 57, 58, 59, 60, 61, 62, 63, 0, 64, 65, 66, 0, 68, 69, 0, 0, 0, 0, 70, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 88, 0, 0, 89, 0, 0, 90, 0, 0, 0, 0, 0, 91, 92, 93, 94, 0, 0, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 114, 115, 1660, 116, 117, 0, 118, 119, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 14, 15, 0, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 32, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 39, 0, 0, 0, 40, 41, 42, 43, 0, 44, 0, 45, 0, 46, 0, 0, 47, 0, 0, 0, 48, 49, 50, 51, 0, 53, 54, 0, 55, 0, 57, 58, 59, 60, 61, 62, 63, 0, 64, 65, 66, 0, 68, 69, 0, 0, 0, 0, 70, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 88, 0, 0, 89, 0, 0, 90, 0, 0, 0, 0, 0, 91, 92, 93, 94, 0, 0, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 114, 115, 1661, 116, 117, 0, 118, 119, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 14, 15, 0, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 32, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 39, 0, 0, 0, 40, 41, 42, 43, 0, 44, 1664, 45, 0, 46, 0, 0, 47, 0, 0, 0, 48, 49, 50, 51, 0, 53, 54, 0, 55, 0, 57, 58, 59, 60, 61, 62, 63, 0, 64, 65, 66, 0, 68, 69, 0, 0, 0, 0, 70, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 88, 0, 0, 89, 0, 0, 90, 0, 0, 0, 0, 0, 91, 92, 93, 94, 0, 0, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 114, 115, 0, 116, 117, 0, 118, 119, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 14, 15, 0, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 32, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 39, 0, 0, 0, 40, 41, 42, 43, 0, 44, 0, 45, 0, 46, 0, 0, 47, 0, 0, 0, 48, 49, 50, 51, 0, 53, 54, 0, 55, 0, 57, 58, 59, 60, 61, 62, 63, 0, 64, 65, 66, 0, 68, 69, 0, 0, 0, 0, 70, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 88, 0, 0, 89, 0, 0, 90, 0, 0, 0, 0, 0, 91, 92, 93, 94, 0, 0, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 114, 115, 1679, 116, 117, 0, 118, 119, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 14, 15, 0, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 32, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 39, 0, 0, 0, 40, 41, 42, 43, 0, 44, 0, 45, 0, 46, 0, 0, 47, 0, 0, 0, 48, 49, 50, 51, 0, 53, 54, 0, 55, 0, 57, 58, 59, 60, 61, 62, 63, 0, 64, 65, 66, 0, 68, 69, 0, 0, 0, 0, 70, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 88, 0, 0, 89, 0, 0, 90, 0, 0, 0, 0, 0, 91, 92, 93, 94, 0, 0, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 114, 115, 1732, 116, 117, 0, 118, 119, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 14, 15, 0, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 32, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 39, 0, 0, 0, 40, 41, 42, 43, 0, 44, 0, 45, 0, 46, 0, 0, 47, 0, 0, 0, 48, 49, 50, 51, 0, 53, 54, 0, 55, 0, 57, 58, 59, 60, 61, 62, 63, 0, 64, 65, 66, 0, 68, 69, 0, 0, 0, 0, 70, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 88, 0, 0, 89, 0, 0, 90, 0, 0, 0, 0, 0, 91, 92, 93, 94, 0, 0, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 114, 115, 1738, 116, 117, 0, 118, 119, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 14, 15, 0, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 32, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 39, 0, 0, 0, 40, 41, 42, 43, 0, 44, 0, 45, 0, 46, 0, 0, 47, 0, 0, 0, 48, 49, 50, 51, 0, 53, 54, 0, 55, 0, 57, 58, 59, 60, 61, 62, 63, 0, 64, 65, 66, 0, 68, 69, 0, 0, 0, 0, 70, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 88, 0, 0, 89, 0, 0, 90, 0, 0, 0, 0, 0, 91, 92, 93, 94, 0, 0, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 114, 115, 0, 116, 117, 0, 118, 119, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 12, 0, 449, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 15, 0, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 32, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 39, 0, 0, 0, 40, 41, 42, 43, 0, 44, 0, 45, 0, 46, 0, 0, 47, 0, 0, 0, 48, 49, 50, 51, 0, 53, 54, 0, 55, 0, 57, 58, 59, 60, 176, 177, 63, 0, 64, 65, 66, 0, 0, 0, 0, 0, 0, 0, 70, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 0, 0, 0, 89, 0, 0, 90, 0, 0, 0, 0, 0, 91, 92, 93, 94, 0, 0, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 114, 115, 0, 116, 117, 0, 118, 119, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 12, 0, 703, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 15, 0, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 32, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 39, 0, 0, 0, 40, 41, 42, 43, 0, 44, 0, 45, 0, 46, 0, 0, 47, 0, 0, 0, 48, 49, 50, 51, 0, 53, 54, 0, 55, 0, 57, 58, 59, 60, 176, 177, 63, 0, 64, 65, 66, 0, 0, 0, 0, 0, 0, 0, 70, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 0, 0, 0, 89, 0, 0, 90, 0, 0, 0, 0, 0, 91, 92, 93, 94, 0, 0, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 114, 115, 0, 116, 117, 0, 118, 119, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 12, 0, 923, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 15, 0, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 32, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 39, 0, 0, 0, 40, 41, 42, 43, 0, 44, 0, 45, 0, 46, 0, 0, 47, 0, 0, 0, 48, 49, 50, 51, 0, 53, 54, 0, 55, 0, 57, 58, 59, 60, 176, 177, 63, 0, 64, 65, 66, 0, 0, 0, 0, 0, 0, 0, 70, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 0, 0, 0, 89, 0, 0, 90, 0, 0, 0, 0, 0, 91, 92, 93, 94, 0, 0, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 114, 115, 0, 116, 117, 0, 118, 119, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 12, 0, 1440, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 15, 0, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 32, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 39, 0, 0, 0, 40, 41, 42, 43, 0, 44, 0, 45, 0, 46, 0, 0, 47, 0, 0, 0, 48, 49, 50, 51, 0, 53, 54, 0, 55, 0, 57, 58, 59, 60, 176, 177, 63, 0, 64, 65, 66, 0, 0, 0, 0, 0, 0, 0, 70, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 0, 0, 0, 89, 0, 0, 90, 0, 0, 0, 0, 0, 91, 92, 93, 94, 0, 0, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 114, 115, 0, 116, 117, 0, 118, 119, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 12, 0, 1578, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 15, 0, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 32, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 39, 0, 0, 0, 40, 41, 42, 43, 0, 44, 0, 45, 0, 46, 0, 0, 47, 0, 0, 0, 48, 49, 50, 51, 0, 53, 54, 0, 55, 0, 57, 58, 59, 60, 176, 177, 63, 0, 64, 65, 66, 0, 0, 0, 0, 0, 0, 0, 70, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 0, 0, 0, 89, 0, 0, 90, 0, 0, 0, 0, 0, 91, 92, 93, 94, 0, 0, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 114, 115, 0, 116, 117, 0, 118, 119, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 15, 0, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 32, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 39, 0, 0, 0, 40, 41, 42, 43, 0, 44, 0, 45, 0, 46, 0, 0, 47, 0, 0, 0, 48, 49, 50, 51, 0, 53, 54, 0, 55, 0, 57, 58, 59, 60, 176, 177, 63, 0, 64, 65, 66, 0, 0, 0, 0, 0, 0, 0, 70, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 0, 0, 0, 89, 0, 0, 90, 0, 0, 0, 0, 0, 91, 92, 93, 94, 0, 0, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 114, 115, 0, 116, 117, 0, 118, 119, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 15, 0, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 0, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 0, 0, 0, 0, 0, 0, 0, 58, 59, 60, 176, 177, 178, 0, 0, 65, 66, 0, 0, 0, 0, 0, 0, 0, 179, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 0, 0, 0, 89, 0, 0, 90, 0, 0, 0, 0, 0, 91, 92, 93, 94, 0, 0, 0, 0, 97, 98, 263, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 264, 0, 0, 116, 117, 0, 118, 119, 5, 6, 7, 8, 9, 0, 0, 0, 0, 356, 10, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 593, 378, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 15, 379, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 0, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 0, 0, 0, 0, 0, 0, 0, 58, 59, 60, 176, 177, 178, 0, 0, 65, 66, 0, 0, 0, 0, 0, 0, 0, 179, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 0, 594, 0, 89, 0, 0, 90, 0, 0, 0, 0, 0, 91, 92, 93, 94, 0, 0, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 0, 0, 0, 116, 117, 0, 118, 119, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 15, 0, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 0, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 0, 0, 0, 0, 0, 0, 0, 58, 59, 60, 176, 177, 178, 0, 0, 65, 66, 0, 0, 0, 0, 0, 0, 0, 179, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 0, 0, 0, 89, 0, 0, 90, 0, 0, 0, 0, 0, 91, 92, 93, 94, 0, 0, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 354, 355, 698, 0, 116, 117, 0, 118, 119, 5, 6, 7, 8, 9, 0, 0, 0, 0, 356, 10, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 1049, 378, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 15, 379, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 0, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 0, 0, 0, 0, 0, 0, 0, 58, 59, 60, 176, 177, 178, 0, 0, 65, 66, 0, 0, 0, 0, 0, 0, 0, 179, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 0, 1050, 0, 89, 0, 0, 90, 0, 0, 0, 0, 0, 91, 92, 93, 94, 0, 0, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 0, 0, 0, 116, 117, 0, 118, 119, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 647, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 15, 0, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 0, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 0, 0, 0, 0, 0, 0, 0, 58, 59, 60, 176, 177, 178, 0, 0, 65, 66, 0, 0, 0, 0, 0, 0, 0, 179, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 0, 0, 0, 89, 0, 0, 90, 5, 6, 7, 8, 9, 91, 92, 93, 94, 0, 10, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 0, 0, 0, 116, 117, 0, 118, 119, 0, 14, 15, 0, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 0, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 192, 0, 0, 51, 0, 0, 0, 0, 0, 0, 0, 58, 59, 60, 176, 177, 178, 0, 0, 65, 66, 0, 0, 0, 0, 0, 0, 0, 179, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 0, 0, 0, 89, 0, 0, 90, 0, 0, 0, 0, 0, 91, 92, 93, 94, 0, 0, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 960, 961, 0, 0, 116, 117, 0, 118, 119, 5, 6, 7, 8, 9, 0, 0, 0, 0, 962, 10, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 217, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 15, 984, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 0, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 0, 0, 0, 0, 0, 0, 0, 58, 59, 60, 176, 177, 178, 0, 0, 65, 66, 0, 0, 0, 0, 0, 0, 0, 179, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 0, 0, 0, 89, 0, 0, 90, 5, 6, 7, 8, 9, 91, 92, 93, 94, 0, 10, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 0, 0, 0, 116, 117, 0, 118, 119, 0, 14, 15, 0, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 0, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 0, 0, 0, 0, 0, 0, 0, 58, 59, 60, 176, 177, 178, 0, 0, 65, 66, 0, 0, 0, 0, 0, 0, 0, 179, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 0, 0, 0, 89, 0, 0, 90, 5, 6, 7, 8, 9, 91, 92, 93, 94, 0, 10, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 246, 0, 0, 116, 117, 0, 118, 119, 0, 14, 15, 0, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 0, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 0, 0, 0, 0, 0, 0, 0, 58, 59, 60, 176, 177, 178, 0, 0, 65, 66, 0, 0, 0, 0, 0, 0, 0, 179, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 0, 0, 0, 89, 0, 0, 90, 5, 6, 7, 8, 9, 91, 92, 93, 94, 0, 10, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 249, 0, 0, 116, 117, 0, 118, 119, 0, 14, 15, 0, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 0, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 0, 0, 0, 0, 0, 0, 0, 58, 59, 60, 176, 177, 178, 0, 0, 65, 66, 0, 0, 0, 0, 0, 0, 0, 179, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 0, 0, 0, 89, 0, 0, 90, 0, 0, 0, 0, 0, 91, 92, 93, 94, 0, 0, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 447, 0, 0, 0, 116, 117, 0, 118, 119, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 10, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 606, 378, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 379, 0, 0, 14, 15, 0, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 0, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 0, 0, 0, 0, 0, 0, 0, 58, 59, 60, 176, 177, 178, 0, 0, 65, 66, 0, 0, 0, 0, 0, 0, 0, 179, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 0, 0, 0, 89, 0, 0, 90, 0, 0, 0, 0, 0, 91, 92, 93, 94, 0, 0, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 961, 0, 0, 116, 117, 0, 118, 119, 5, 6, 7, 8, 9, 0, 0, 0, 0, 962, 10, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 648, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 15, 984, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 0, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 0, 0, 0, 0, 0, 0, 0, 58, 59, 60, 176, 177, 178, 0, 0, 65, 66, 0, 0, 0, 0, 0, 0, 0, 179, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 0, 0, 0, 89, 0, 0, 90, 0, 0, 0, 0, 0, 91, 92, 93, 94, 0, 0, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 0, 0, 0, 116, 117, 0, 118, 119, 5, 6, 7, 8, 9, 0, 0, 0, 0, 962, 10, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 684, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 15, 984, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 0, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 0, 0, 0, 0, 0, 0, 0, 58, 59, 60, 176, 177, 178, 0, 0, 65, 66, 0, 0, 0, 0, 0, 0, 0, 179, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 0, 0, 0, 89, 0, 0, 90, 0, 0, 0, 0, 0, 91, 92, 93, 94, 0, 0, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 0, 0, 0, 116, 117, 0, 118, 119, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 10, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 686, 378, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 15, 379, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 0, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 0, 0, 0, 0, 0, 0, 0, 58, 59, 60, 176, 177, 178, 0, 0, 65, 66, 0, 0, 0, 0, 0, 0, 0, 179, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 0, 0, 0, 89, 0, 0, 90, 0, 0, 0, 0, 0, 91, 92, 93, 94, 0, 0, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 0, 0, 0, 116, 117, 0, 118, 119, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 10, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 1092, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 15, 984, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 0, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 0, 0, 0, 0, 0, 0, 0, 58, 59, 60, 176, 177, 178, 0, 0, 65, 66, 0, 0, 0, 0, 0, 0, 0, 179, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 0, 0, 0, 89, 0, 0, 90, 5, 6, 7, 8, 9, 91, 92, 93, 94, 0, 10, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 0, 0, 0, 116, 117, 0, 118, 119, 0, 14, 15, 0, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 0, 0, 0, 0, 33, 34, 35, 36, 37, 38, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 0, 0, 0, 0, 0, 0, 0, 58, 59, 60, 176, 177, 178, 0, 0, 65, 66, 0, 0, 0, 0, 0, 0, 0, 179, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 0, 0, 0, 89, 0, 0, 90, 5, 6, 7, 8, 9, 91, 92, 93, 94, 0, 10, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 0, 0, 0, 116, 117, 0, 118, 119, 0, 14, 15, 0, 0, 0, 0, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 28, 29, 30, 31, 0, 0, 0, 0, 33, 34, 35, 36, 537, 38, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 0, 0, 0, 0, 0, 0, 0, 58, 59, 60, 176, 177, 178, 0, 0, 65, 66, 0, 0, 0, 0, 0, 0, 0, 179, 71, 0, 72, 73, 74, 75, 76, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 180, 79, 80, 81, 82, 0, 83, 84, 0, 85, 181, 87, 0, 0, 0, 89, 0, 0, 90, 0, 0, 0, 0, 0, 91, 92, 93, 94, 0, 0, 0, 0, 97, 98, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 0, 0, 0, 0, 116, 117, 0, 118, 119, 1461, 1462, 1463, 1464, 1465, 0, 0, 1466, 1467, 1468, 1469, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1470, 1471, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 0, 378, 0, 0, 1472, 0, 0, 0, 0, 0, 0, 0, 0, 379, 0, 0, 0, 0, 1473, 1474, 1475, 1476, 1477, 1478, 1479, 0, 0, 0, 36, 0, 0, 0, 0, 0, 0, 0, 0, 1480, 1481, 1482, 1483, 1484, 1485, 1486, 1487, 1488, 1489, 1490, 1491, 1492, 1493, 1494, 1495, 1496, 1497, 1498, 1499, 1500, 1501, 1502, 1503, 1504, 1505, 1506, 1507, 1508, 1509, 1510, 1511, 1512, 1513, 1514, 1515, 1516, 1517, 1518, 1519, 1520, 0, 0, 1521, 1522, 0, 1523, 1524, 1525, 1526, 1527, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1528, 1529, 1530, 0, 0, 0, 83, 84, 0, 85, 181, 87, 1531, 0, 1532, 1533, 0, 1534, 0, 0, 0, 0, 0, 0, 1535, 0, 0, 0, 1536, 0, 1537, 0, 1538, 1539, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 353, 354, 355, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 0, 0, 0, 356, 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 0, 378, 353, 354, 355, 0, 0, 0, 0, 0, 0, 0, 0, 379, 0, 0, 0, 0, 0, 0, 0, 356, 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 251, 378, 302, 0, 0, 83, 84, 0, 85, 181, 87, 0, 0, 379, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 252, 0, 0, 0, 0, 0, 0, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 0, 36, 0, 251, 0, 0, 303, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 0, 0, 0, 0, 0, 252, 0, 0, 0, 0, 0, 0, 0, 984, 0, 0, 0, 0, 0, 0, 1449, 0, 0, 0, 0, 0, 0, 36, 0, 0, 253, 254, -887, -887, -887, -887, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 180, 378, 0, 81, 255, 0, 83, 84, 0, 85, 181, 87, 0, 379, 0, 1294, 0, 0, 0, 0, 0, 0, 36, 251, 256, 0, 0, 0, 0, 0, 0, 0, 253, 254, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 0, 252, 180, 257, 0, 81, 255, 1558, 83, 84, 0, 85, 181, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 0, 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, -319, 83, 84, 257, 85, 181, 87, 1625, 58, 59, 60, 176, 177, 343, 0, 0, 0, 251, 0, 0, 0, 0, 0, 0, 0, 0, 253, 254, 0, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 252, 180, 0, 855, 81, 255, 0, 83, 84, 0, 85, 181, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 251, 256, 0, 0, 0, 0, 0, 0, 0, 0, 344, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 470, 252, 0, 257, -887, -887, -887, -887, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 0, 0, 0, 36, 0, 0, 253, 254, 0, 0, 0, 0, 0, 984, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 180, 251, 0, 81, 255, 0, 83, 84, 0, 85, 181, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 256, 0, 0, 252, 0, 0, 0, 0, 253, 254, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 0, 36, 180, 257, 0, 81, 255, 0, 83, 84, 0, 85, 181, 87, 0, 1270, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 0, 0, 873, 257, 253, 254, 0, 0, 0, 0, 0, 36, 0, 209, 0, 0, 0, 0, 0, 0, 0, 0, 180, 0, 0, 81, 255, 0, 83, 84, 0, 85, 181, 87, 36, 0, 0, 0, 0, 0, 0, 0, 716, 0, 0, 0, 256, 0, 0, 0, 0, 210, 0, 0, 1149, 0, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 723, 724, 0, 257, 0, 0, 725, 0, 726, 0, 0, 0, 180, 0, 0, 81, 82, 0, 83, 84, 727, 85, 181, 87, 0, 0, 0, 0, 33, 34, 35, 36, 0, 0, 0, 180, 0, 0, 81, 728, 0, 83, 84, 0, 85, 181, 87, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 0, 0, 0, 211, 0, 0, 0, 0, 116, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 0, 729, 0, 72, 73, 74, 75, 76, 36, 0, 209, 0, 0, 0, 730, 0, 0, 0, 0, 180, 79, 80, 81, 731, 0, 83, 84, 0, 85, 181, 87, 36, 0, 0, 89, 0, 0, 0, 0, 0, 0, 0, 0, 732, 733, 734, 735, 0, 210, 0, 0, 97, 0, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 723, 724, 0, 736, 0, 0, 725, 0, 726, 0, 0, 0, 180, 0, 0, 81, 82, 0, 83, 84, 727, 85, 181, 87, 0, 0, 0, 0, 33, 34, 35, 36, 0, 0, 0, 0, 0, 0, 501, 728, 0, 83, 84, 0, 85, 181, 87, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 0, 0, 0, 211, 0, 0, 0, 0, 116, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 0, 729, 0, 72, 73, 74, 75, 76, 0, 0, 0, 884, 885, 0, 730, 0, 0, 0, 0, 180, 79, 80, 81, 731, 0, 83, 84, 0, 85, 181, 87, 886, 0, 0, 89, 0, 0, 0, 0, 887, 888, 889, 36, 732, 733, 734, 735, 0, 0, 0, 890, 97, 0, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 0, 0, 0, 736, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 209, 0, 0, 891, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 892, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 83, 84, 0, 85, 181, 87, 0, 0, 0, 0, 0, 210, 0, 0, 0, 0, 0, 0, 893, 0, 0, 0, 0, 529, 0, 0, 0, 0, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 180, 0, 0, 81, 82, 0, 83, 84, 0, 85, 181, 87, 36, 0, 209, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 0, 0, 0, 211, 210, 0, 0, 0, 116, 0, 0, 0, 0, 0, 0, 0, 1018, 0, 36, 0, 209, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 180, 0, 0, 81, 82, 36, 83, 84, 0, 85, 181, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 222, 0, 0, 0, 0, 0, 0, 0, 0, 272, 273, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 0, 0, 0, 211, 0, 36, 180, 0, 116, 81, 82, 0, 83, 84, 0, 85, 181, 87, 36, 0, 209, 0, 0, 0, 0, 0, 551, 0, 0, 0, 0, 274, 0, 0, 83, 84, 0, 85, 181, 87, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 0, 0, 0, 223, 210, 0, 0, 0, 116, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 180, 0, 0, 81, 82, 0, 83, 84, 0, 85, 181, 87, 0, 180, 0, 0, 81, 82, 0, 83, 84, 0, 85, 181, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 353, 354, 355, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 356, 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 0, 378, 353, 354, 355, 0, 0, 0, 0, 0, 0, 0, 0, 379, 0, 0, 0, 0, 0, 0, 0, 356, 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 0, 378, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 379, 353, 354, 355, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 424, 356, 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 0, 378, 353, 354, 355, 0, 0, 0, 0, 0, 0, 0, 0, 379, 0, 0, 0, 0, 0, 0, 433, 356, 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 0, 378, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 379, 353, 354, 355, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 822, 356, 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 0, 378, 353, 354, 355, 0, 0, 0, 0, 0, 0, 0, 0, 379, 0, 0, 0, 0, 0, 0, 861, 356, 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 0, 378, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 379, 353, 354, 355, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 902, 356, 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 0, 378, 959, 960, 961, 0, 0, 0, 0, 0, 0, 0, 0, 379, 0, 0, 0, 0, 0, 0, 1206, 962, 0, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 984, 959, 960, 961, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1225, 962, 0, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 959, 960, 961, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 984, 0, 0, 0, 0, 0, 962, 1124, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 984, 959, 960, 961, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 962, 1283, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 959, 960, 961, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 984, 0, 0, 0, 0, 0, 962, 1288, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 0, 0, 0, 0, 0, 36, 0, 796, 797, 0, 0, 0, 0, 984, 959, 960, 961, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 0, 0, 0, 0, 962, 1367, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1385, 984, 0, 36, 0, 0, 0, 0, 1447, 0, 0, 0, 1386, 1387, 83, 84, 36, 85, 181, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 180, 0, 0, 81, 1388, 0, 83, 84, 0, 85, 1389, 87, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 0, 0, 0, 0, 0, 36, 0, 0, 1448, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 340, 0, 83, 84, 0, 85, 181, 87, 0, 0, 0, 0, 505, 0, 0, 83, 84, 0, 85, 181, 87, 0, 0, 0, 0, 36, 0, 0, 0, 0, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 274, 0, 0, 83, 84, 0, 85, 181, 87, 0, 36, 0, 0, 0, 637, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 0, 0, 0, 0, 0, 0, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 83, 84, 0, 85, 181, 87, 0, 0, 0, 0, 0, 1141, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 83, 84, 0, 85, 181, 87, 0, 0, 0, 0, 0, 0, 0, 83, 84, 0, 85, 181, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 353, 354, 355, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 707, 356, 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 0, 378, 353, 354, 355, 0, 0, 0, 0, 0, 0, 0, 0, 379, 0, 0, 0, 0, 0, 0, 0, 356, 858, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 708, 378, 353, 354, 355, 0, 0, 0, 0, 0, 0, 0, 0, 379, 0, 0, 0, 0, 0, 0, 0, 356, 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 0, 378, 959, 960, 961, 0, 0, 0, 0, 0, 0, 0, 0, 379, 0, 0, 0, 0, 0, 0, 0, 962, 1293, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 959, 960, 961, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 984, 0, 0, 0, 0, 0, 962, 0, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 984 }; static const yytype_int16 yycheck[] = { 4, 135, 172, 162, 4, 88, 4, 183, 52, 32, 4, 310, 95, 96, 53, 596, 4, 4, 677, 833, 43, 392, 4, 418, 47, 224, 1041, 570, 413, 569, 1038, 815, 56, 165, 162, 706, 378, 544, 713, 1027, 1025, 113, 9, 9, 9, 49, 230, 30, 52, 4, 184, 134, 854, 113, 78, 4, 441, 81, 30, 9, 30, 9, 9, 66, 9, 69, 230, 9, 870, 9, 4, 9, 9, 251, 252, 66, 9, 26, 27, 257, 9, 66, 86, 9, 88, 9, 66, 220, 9, 9, 9, 95, 96, 9, 9, 79, 50, 9, 9, 231, 33, 79, 9, 66, 9, 9, 916, 84, 79, 66, 45, 45, 153, 127, 127, 108, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 35, 134, 45, 127, 46, 47, 66, 147, 201, 202, 211, 310, 84, 127, 66, 45, 449, 1572, 127, 66, 45, 35, 223, 45, 135, 0, 333, 147, 168, 117, 118, 119, 202, 162, 147, 113, 63, 64, 144, 952, 345, 127, 105, 165, 79, 66, 66, 110, 66, 112, 113, 114, 115, 116, 117, 118, 66, 66, 200, 66, 203, 66, 202, 196, 497, 79, 66, 199, 66, 152, 202, 1626, 144, 184, 199, 79, 200, 53, 71, 72, 79, 50, 202, 1220, 167, 8, 385, 288, 202, 65, 169, 154, 155, 202, 157, 169, 196, 204, 66, 288, 127, 202, 201, 236, 200, 1222, 201, 240, 407, 203, 202, 244, 1229, 236, 1231, 420, 1230, 240, 181, 272, 273, 274, 926, 200, 928, 201, 202, 339, 391, 262, 201, 200, 431, 211, 201, 201, 200, 1068, 200, 217, 203, 440, 202, 201, 443, 223, 201, 199, 201, 302, 202, 201, 201, 201, 197, 202, 201, 201, 236, 200, 200, 468, 240, 336, 200, 427, 200, 200, 1107, 805, 200, 199, 197, 200, 1087, 200, 388, 389, 200, 851, 79, 202, 202, 152, 202, 84, 35, 35, 35, 35, 323, 79, 202, 202, 323, 202, 1333, 202, 1335, 332, 204, 279, 202, 336, 202, 204, 339, 199, 286, 287, 288, 79, 323, 99, 100, 293, 84, 99, 100, 199, 79, 299, 125, 126, 392, 84, 1343, 428, 199, 147, 79, 79, 79, 79, 318, 112, 113, 114, 115, 116, 117, 199, 96, 202, 168, 323, 145, 146, 71, 72, 168, 123, 385, 386, 387, 388, 389, 145, 146, 566, 567, 96, 575, 96, 199, 698, 378, 574, 792, 199, 703, 96, 14, 385, 407, 199, 152, 145, 146, 390, 96, 199, 575, 451, 202, 144, 145, 146, 30, 1426, 201, 202, 554, 79, 96, 407, 584, 151, 431, 561, 1088, 79, 564, 1103, 181, 47, 84, 1601, 1602, 208, 443, 639, 161, 161, 161, 161, 151, 203, 151, 431, 4, 203, 151, 456, 201, 79, 151, 584, 440, 123, 84, 443, 79, 456, 104, 151, 199, 84, 666, 207, 418, 646, 112, 113, 114, 115, 116, 117, 501, 151, 428, 79, 505, 867, 199, 683, 84, 510, 144, 145, 146, 45, 199, 877, 1277, 382, 144, 145, 146, 682, 153, 1040, 201, 202, 636, 688, 1597, 1598, 456, 512, 721, 722, 1054, 166, 199, 1057, 199, 815, 199, 682, 602, 145, 146, 410, 199, 688, 199, 414, 145, 146, 533, 534, 873, 29, 202, 74, 75, 76, 30, 737, 151, 181, 199, 201, 721, 722, 85, 145, 146, 202, 46, 105, 35, 49, 201, 201, 110, 688, 112, 113, 114, 115, 116, 117, 118, 201, 29, 201, 1575, 1352, 112, 113, 114, 115, 116, 117, 49, 50, 51, 201, 1238, 66, 1240, 46, 66, 584, 49, 719, 98, 99, 100, 66, 65, 132, 133, 134, 135, 136, 201, 602, 154, 155, 296, 157, 143, 202, 300, 182, 183, 184, 149, 150, 147, 199, 189, 190, 570, 199, 193, 194, 923, 4, 66, 147, 163, 199, 151, 181, 201, 806, 44, 325, 65, 327, 328, 329, 330, 168, 147, 181, 127, 180, 98, 99, 100, 593, 815, 206, 9, 203, 1020, 199, 829, 147, 952, 112, 113, 114, 115, 116, 117, 147, 45, 127, 8, 842, 123, 124, 837, 1208, 168, 49, 50, 51, 677, 53, 679, 199, 201, 1063, 702, 14, 1224, 112, 113, 114, 14, 65, 1072, 79, 1704, 1698, 1350, 696, 201, 201, 14, 696, 200, 168, 648, 158, 14, 160, 96, 1719, 1713, 710, 711, 200, 200, 199, 1106, 104, 9, 696, 205, 88, 711, 199, 199, 14, 105, 200, 181, 9, 200, 110, 199, 112, 113, 114, 115, 116, 117, 118, 684, 9, 686, 201, 185, 79, 79, 766, 79, 188, 199, 770, 696, 201, 9, 201, 9, 930, 79, 932, 125, 199, 761, 200, 708, 200, 761, 711, 767, 897, 201, 66, 771, 772, 200, 154, 155, 126, 157, 30, 1434, 128, 167, 9, 761, 200, 147, 952, 200, 9, 789, 200, 9, 1087, 872, 200, 14, 197, 9, 1189, 66, 9, 181, 169, 200, 804, 1344, 9, 14, 804, 125, 804, 206, 941, 206, 804, 9, 761, 199, 818, 948, 804, 804, 203, 203, 200, 199, 804, 112, 113, 114, 115, 116, 117, 206, 779, 206, 1217, 837, 123, 124, 199, 96, 128, 200, 147, 1226, 201, 792, 793, 201, 9, 1046, 199, 804, 1235, 200, 147, 199, 837, 804, 199, 199, 199, 147, 1674, 1039, 202, 1041, 185, 14, 9, 185, 872, 79, 202, 160, 14, 201, 14, 202, 1180, 1691, 833, 14, 884, 885, 886, 206, 201, 1699, 909, 202, 1066, 197, 873, 30, 181, 199, 199, 199, 851, 30, 14, 9, 46, 47, 48, 49, 50, 51, 910, 53, 912, 200, 914, 128, 912, 199, 914, 199, 910, 1087, 1577, 65, 46, 47, 48, 49, 50, 51, 201, 201, 14, 933, 912, 199, 914, 9, 200, 65, 206, 9, 144, 65, 96, 79, 9, 1121, 199, 1330, 1250, 951, 128, 201, 1083, 79, 14, 957, 79, 199, 202, 200, 199, 199, 202, 910, 1266, 912, 200, 914, 200, 916, 917, 202, 199, 128, 9, 144, 206, 30, 73, 201, 1277, 200, 169, 1020, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 30, 1000, 201, 1131, 1003, 200, 128, 1135, 200, 128, 1138, 9, 1185, 200, 200, 9, 9, 1145, 4, 200, 200, 203, 9, 200, 203, 1024, 202, 199, 202, 1024, 14, 1024, 200, 200, 199, 1024, 63, 64, 1418, 200, 200, 1024, 1024, 200, 1620, 128, 200, 1024, 9, 30, 96, 201, 200, 200, 156, 1354, 201, 152, 1352, 45, 202, 201, 79, 14, 1363, 79, 110, 199, 128, 26, 27, 200, 128, 30, 1024, 202, 200, 1095, 1377, 14, 1024, 14, 200, 200, 200, 1084, 200, 202, 201, 1088, 79, 199, 202, 200, 128, 52, 1269, 201, 1271, 1098, 127, 201, 14, 14, 1054, 1049, 14, 1057, 201, 1098, 200, 1110, 1277, 1689, 4, 1110, 202, 55, 1246, 105, 79, 199, 9, 79, 110, 201, 112, 113, 114, 115, 116, 117, 118, 1110, 79, 108, 96, 147, 1311, 159, 33, 1440, 96, 14, 199, 79, 200, 165, 1092, 201, 199, 162, 200, 9, 1098, 45, 79, 202, 201, 1313, 200, 200, 1106, 1107, 79, 14, 1110, 14, 154, 155, 79, 157, 79, 200, 14, 79, 14, 766, 510, 770, 389, 1682, 1311, 386, 388, 1184, 871, 1352, 868, 1695, 807, 1439, 1187, 1263, 1691, 181, 515, 1429, 1459, 1104, 1543, 1196, 1306, 1723, 1711, 1555, 1379, 41, 1425, 392, 995, 486, 992, 486, 1028, 105, 758, 203, 1070, 949, 110, 1084, 112, 113, 114, 115, 116, 117, 118, 885, 294, 313, 1403, 899, 955, 1011, 287, 1187, 934, 1238, -1, 1240, -1, -1, 721, 1189, 1196, -1, -1, -1, -1, -1, -1, -1, 211, -1, -1, -1, -1, -1, 217, -1, 1301, -1, 154, 155, 223, 157, 1567, -1, 1569, -1, -1, -1, 1224, -1, -1, -1, -1, 1578, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 181, -1, -1, 251, 252, -1, 1296, -1, -1, 257, 1296, 1301, -1, -1, -1, -1, 1306, -1, -1, -1, -1, -1, 203, -1, -1, -1, -1, 1313, 1296, -1, -1, 279, -1, 1623, -1, -1, -1, -1, 286, 287, -1, -1, 1310, -1, -1, 293, -1, -1, 1334, -1, -1, 299, -1, -1, 1340, -1, 1342, -1, -1, -1, 1350, 1296, 310, -1, -1, 1355, -1, -1, -1, 1355, 1360, -1, -1, -1, 1364, 1405, -1, -1, 1364, -1, 1360, -1, -1, 4, -1, 333, -1, 1355, 336, -1, -1, -1, -1, 1334, -1, 1557, 1364, -1, -1, 1340, -1, 1342, 1392, 1344, -1, -1, -1, -1, 1398, -1, -1, -1, -1, -1, -1, 1405, -1, -1, -1, 1409, 1355, -1, -1, -1, 45, 1360, -1, 1717, -1, 1364, 378, -1, -1, -1, 1724, -1, -1, -1, -1, 1407, -1, -1, -1, -1, 1434, 1431, -1, 1437, 1438, 1439, -1, 1437, -1, 1443, -1, -1, -1, 1443, 1438, 1439, 1450, -1, -1, -1, 1450, -1, -1, -1, -1, 1437, 418, -1, -1, -1, -1, 1443, -1, -1, -1, -1, 428, -1, 1450, -1, 105, 1554, -1, -1, -1, 110, 1431, 112, 113, 114, 115, 116, 117, 118, -1, -1, -1, -1, 1437, 1438, 1439, -1, -1, -1, 1443, -1, -1, -1, -1, -1, -1, 1450, -1, -1, -1, -1, 468, 469, -1, -1, 472, 1670, -1, -1, -1, -1, -1, -1, -1, 154, 155, -1, 157, -1, -1, -1, 1704, -1, -1, -1, 1613, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1719, -1, -1, -1, -1, 181, -1, -1, -1, 1554, -1, 1686, -1, -1, 517, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 203, 1573, -1, -1, -1, 1577, -1, -1, -1, -1, 1582, -1, -1, 65, 1582, -1, -1, -1, 77, -1, 1592, -1, -1, -1, -1, 1597, 1598, -1, -1, 1601, 1602, -1, 1582, -1, -1, -1, 566, 567, -1, -1, -1, 1613, -1, -1, 574, -1, -1, -1, -1, 1621, 1622, -1, -1, 1621, 1622, -1, 1628, -1, -1, -1, 1628, -1, -1, 593, -1, 1582, -1, -1, -1, -1, -1, 1621, 1622, -1, -1, -1, -1, -1, 1628, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 148, 1662, -1, 151, -1, 1662, 154, 155, 1669, 157, 158, 159, -1, 1670, -1, 1621, 1622, -1, -1, -1, -1, -1, 1628, 1662, 1685, -1, -1, -1, -1, 648, -1, -1, -1, -1, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, -1, -1, -1, -1, -1, -1, -1, 203, 1662, -1, -1, -1, -1, -1, 1674, -1, 1725, 684, -1, 686, 1725, -1, 1731, -1, -1, -1, 1731, -1, -1, -1, -1, 1691, -1, -1, -1, -1, -1, -1, 1725, 1699, -1, 708, 709, -1, 1731, -1, -1, -1, -1, -1, -1, -1, -1, -1, 721, 722, 723, 724, 725, 726, 727, -1, -1, -1, -1, -1, -1, -1, -1, 736, -1, 1725, -1, -1, -1, -1, -1, 1731, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, -1, -1, -1, -1, 762, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, 53, -1, -1, 779, -1, -1, -1, -1, -1, -1, -1, -1, 65, -1, 790, -1, 792, 793, 63, 64, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 806, 807, -1, -1, -1, -1, -1, -1, -1, 815, 26, 27, -1, -1, 30, -1, -1, -1, -1, -1, -1, -1, -1, 829, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 842, -1, -1, -1, -1, -1, -1, -1, 850, -1, -1, 853, -1, 10, 11, 12, 127, -1, -1, -1, -1, -1, -1, -1, -1, 26, 27, -1, -1, 30, -1, 873, 29, -1, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, 53, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 65, -1, -1, -1, -1, -1, 916, 917, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 930, -1, 932, -1, 934, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 949, -1, -1, 952, 953, 954, 955, -1, -1, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 984, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 10, 11, 12, -1, -1, -1, 211, -1, -1, -1, -1, -1, 217, 1008, -1, -1, -1, -1, 223, 29, -1, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, 53, 1039, -1, 1041, -1, -1, -1, -1, -1, -1, -1, 1049, 65, 206, -1, -1, -1, -1, -1, -1, 217, -1, -1, -1, -1, -1, -1, 77, 1066, 79, -1, 279, -1, -1, -1, -1, -1, -1, 286, 287, -1, -1, -1, -1, -1, 293, -1, -1, -1, 1087, -1, 299, -1, -1, 1092, -1, -1, -1, -1, -1, -1, -1, 310, -1, -1, -1, -1, -1, 1106, 1107, -1, 1109, -1, 123, -1, -1, -1, -1, -1, -1, -1, -1, 279, 1121, -1, -1, 1124, -1, 1126, 286, 287, -1, -1, -1, -1, -1, 293, -1, -1, -1, -1, -1, 299, -1, 154, 155, -1, 157, 158, 159, -1, 1149, -1, 310, -1, -1, -1, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 378, -1, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, -1, 1185, 1186, -1, 203, 1189, 202, -1, 204, -1, -1, -1, -1, -1, -1, -1, -1, 10, 11, 12, 63, 64, -1, -1, 418, -1, -1, -1, -1, 1213, -1, -1, -1, -1, 428, 378, 29, -1, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, 53, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 65, -1, -1, 418, -1, -1, -1, -1, -1, -1, -1, -1, 127, 1269, -1, 1271, -1, -1, -1, -1, 1276, 1277, -1, -1, -1, 1281, -1, 1283, -1, 1285, -1, -1, 1288, -1, 1290, -1, -1, 1293, -1, -1, -1, -1, -1, -1, -1, 1301, 1302, -1, 1304, -1, -1, 10, 11, 12, -1, 1311, -1, 472, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 29, 1327, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, 53, -1, 1352, -1, -1, 77, -1, 79, 517, -1, -1, -1, 65, -1, -1, -1, -1, 1367, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1379, 1380, 1381, -1, 593, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 203, 117, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1405, -1, -1, -1, 1409, -1, -1, -1, -1, -1, 1415, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 148, 52, -1, 151, 152, -1, 154, 155, 593, 157, 158, 159, 648, -1, -1, -1, -1, -1, -1, -1, 1446, 1447, 1448, -1, -1, -1, -1, -1, 1454, 1455, -1, -1, -1, 1459, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 684, -1, 686, 199, -1, -1, 202, -1, 204, 10, 11, 12, -1, -1, -1, 648, -1, -1, -1, -1, -1, -1, -1, -1, 708, -1, 203, -1, 29, -1, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 684, 53, 686, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 65, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 708, 709, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1562, -1, 723, 724, 725, 726, 727, 779, -1, -1, -1, 1573, -1, -1, -1, 736, -1, -1, -1, -1, 792, 793, -1, -1, -1, -1, -1, -1, -1, -1, 1592, -1, -1, -1, 1596, -1, -1, -1, -1, -1, -1, 762, -1, 815, -1, 1607, -1, -1, -1, -1, 1612, -1, -1, 1615, -1, -1, -1, -1, 779, -1, -1, -1, -1, -1, 251, 252, 35, -1, -1, 790, 257, 792, 793, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 807, -1, -1, -1, -1, 77, -1, -1, 815, -1, -1, -1, -1, -1, -1, 873, -1, -1, -1, -1, -1, -1, 77, -1, 79, 1673, -1, -1, 203, -1, -1, -1, -1, 1681, -1, -1, -1, -1, -1, -1, -1, -1, -1, 850, -1, -1, 853, 1695, -1, 121, -1, -1, -1, -1, -1, -1, 1704, -1, 916, 917, 333, -1, 117, 336, -1, -1, 873, -1, -1, -1, -1, 1719, -1, -1, 129, -1, -1, -1, -1, -1, 1728, -1, 154, 155, -1, 157, 158, 159, 1736, -1, -1, -1, 1740, 148, 952, 1743, 151, 152, -1, 154, 155, -1, 157, 158, 159, -1, -1, -1, -1, 916, 917, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, -1, -1, -1, 199, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, -1, 949, -1, 199, 952, 953, 954, 955, 204, -1, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 984, -1, -1, -1, 10, 11, 12, -1, -1, -1, -1, -1, -1, -1, 1049, -1, -1, -1, 468, 469, -1, -1, 472, 29, 1008, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, 53, -1, -1, -1, -1, 1087, -1, 10, 11, 12, 1092, -1, 65, -1, -1, -1, -1, -1, 1049, -1, 517, -1, -1, -1, 1106, 1107, 29, -1, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, 53, -1, -1, -1, -1, -1, 1087, -1, -1, -1, -1, 1092, 65, -1, -1, -1, -1, -1, -1, 566, 567, -1, -1, -1, -1, 1106, 1107, 574, 1109, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1124, -1, 1126, -1, -1, 10, 11, 12, -1, -1, -1, -1, -1, -1, 1189, -1, -1, -1, -1, -1, -1, -1, -1, -1, 29, 1149, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 12, 53, -1, -1, -1, -1, -1, -1, -1, -1, 203, -1, -1, 65, -1, 1186, -1, 29, 1189, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, 53, 1213, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 65, -1, 1277, -1, -1, -1, -1, 203, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 709, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 721, 722, 723, 724, 725, 726, 727, -1, -1, -1, -1, -1, -1, -1, -1, 736, -1, -1, -1, -1, -1, 1276, 1277, -1, -1, -1, 1281, -1, 1283, -1, 1285, -1, -1, 1288, -1, 1290, -1, -1, 1293, -1, -1, -1, -1, -1, -1, -1, 1352, 1302, -1, 1304, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 203, 53, -1, -1, -1, 1327, -1, -1, -1, -1, -1, -1, -1, 65, -1, -1, -1, -1, 806, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1352, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 829, 10, 11, 12, 1367, -1, -1, -1, -1, -1, -1, -1, -1, 842, -1, -1, -1, 1380, 1381, -1, 29, 850, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, 53, -1, -1, -1, -1, -1, -1, -1, 1415, -1, -1, -1, 65, -1, -1, -1, -1, 29, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, 1446, 1447, 1448, -1, 55, -1, -1, -1, 1454, 1455, -1, -1, 65, 1459, -1, -1, -1, -1, 930, -1, 932, -1, 934, -1, -1, -1, 77, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 949, -1, -1, -1, 953, 954, 955, -1, -1, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 984, -1, -1, -1, -1, -1, -1, 130, 131, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1008, 148, -1, -1, 151, 152, -1, 154, 155, -1, 157, 158, 159, -1, 161, 203, -1, -1, -1, -1, 1562, -1, -1, -1, -1, 172, -1, -1, -1, -1, -1, 1039, -1, 1041, -1, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, -1, -1, -1, 199, -1, 1596, 10, 11, 12, 1066, -1, -1, -1, -1, -1, -1, 1607, -1, -1, -1, -1, 1612, -1, -1, 1615, 29, -1, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, 53, -1, -1, 1109, -1, -1, -1, -1, -1, -1, -1, -1, 65, -1, -1, 1121, -1, -1, 1124, -1, 1126, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1673, -1, 10, 11, 12, -1, -1, -1, 1681, -1, 1149, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 29, 1695, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, 53, 1185, -1, -1, -1, -1, -1, -1, -1, -1, 1728, -1, 65, 10, 11, 12, -1, -1, 1736, -1, -1, -1, 1740, -1, -1, 1743, -1, -1, -1, 1213, -1, -1, 29, -1, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, 53, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 65, -1, -1, -1, 203, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1269, -1, 1271, -1, -1, -1, -1, 1276, -1, -1, -1, -1, 1281, -1, 1283, -1, 1285, -1, -1, 1288, -1, 1290, -1, -1, 1293, -1, -1, -1, -1, -1, -1, -1, 1301, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1311, -1, -1, -1, -1, 10, 11, 12, -1, -1, -1, -1, -1, -1, -1, -1, 1327, -1, -1, -1, -1, -1, -1, 203, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, 53, -1, -1, -1, -1, -1, -1, -1, 1367, -1, -1, -1, 65, -1, -1, -1, -1, -1, -1, -1, 1379, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 203, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1405, -1, 5, 6, 1409, 8, 9, 10, 11, 12, 1415, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, 28, 29, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 41, -1, -1, 1446, 1447, 1448, -1, 48, -1, 50, -1, 1454, 53, -1, 55, 10, 11, 12, -1, -1, -1, -1, -1, -1, -1, -1, 472, 77, -1, 79, -1, -1, -1, -1, 29, -1, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, 53, 10, 11, 12, -1, -1, 201, -1, -1, -1, -1, -1, 65, 517, 113, -1, -1, -1, -1, -1, 29, -1, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, 53, -1, 154, 155, -1, 157, 158, 159, -1, -1, -1, -1, 65, -1, -1, -1, -1, 1562, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1573, -1, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, -1, 188, -1, 1592, -1, -1, 202, 1596, 204, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1607, -1, -1, -1, -1, 1612, -1, -1, 1615, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 10, 11, 12, -1, -1, 232, -1, -1, 235, -1, -1, -1, -1, -1, -1, 242, 243, -1, -1, 29, 201, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, 53, 1673, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 65, -1, -1, -1, -1, -1, 288, -1, -1, 201, -1, -1, 294, -1, -1, -1, 298, -1, -1, -1, 1704, -1, 709, -1, -1, -1, -1, -1, -1, 311, 312, 313, -1, -1, -1, 1719, 723, 724, 725, 726, 727, -1, 324, -1, 1728, -1, -1, -1, -1, 736, -1, -1, 1736, 335, -1, -1, 1740, -1, -1, 1743, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, -1, 379, -1, 381, 382, -1, 384, -1, -1, -1, -1, -1, -1, -1, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, -1, -1, -1, -1, -1, 410, 411, -1, 413, 414, 415, -1, -1, 201, -1, -1, 421, -1, -1, 424, -1, -1, -1, -1, -1, -1, -1, -1, 433, -1, 435, -1, 10, 11, 12, -1, 441, -1, -1, -1, 850, -1, -1, 472, -1, -1, 451, -1, 453, -1, -1, 29, -1, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 479, 53, -1, 482, 483, 484, -1, -1, -1, -1, -1, -1, -1, 65, 517, -1, -1, 10, 11, 12, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 513, -1, 29, -1, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, 53, -1, -1, -1, -1, 949, -1, -1, -1, 953, 954, 955, 65, -1, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 984, -1, -1, -1, -1, -1, -1, 10, 11, 12, -1, -1, -1, -1, -1, 594, -1, -1, -1, -1, -1, -1, -1, -1, 1008, -1, 29, 606, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 201, 53, -1, -1, -1, -1, -1, -1, -1, -1, 638, -1, -1, 65, -1, -1, -1, -1, -1, 647, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 665, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 709, 53, 201, -1, -1, -1, -1, 692, -1, -1, -1, -1, -1, 65, 723, 724, 725, 726, 727, 1109, -1, 706, -1, -1, -1, -1, -1, 736, -1, -1, -1, -1, -1, -1, 1124, -1, 1126, 77, -1, 79, -1, -1, 10, 11, 12, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1149, -1, 29, 747, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, 53, -1, -1, -1, -1, -1, 200, -1, -1, -1, -1, -1, 65, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 154, 155, 801, 157, 158, 159, -1, -1, -1, 1213, -1, -1, -1, 65, -1, 814, -1, -1, -1, -1, -1, 820, -1, 822, -1, 824, -1, 850, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, -1, -1, -1, -1, -1, -1, 202, 848, 204, -1, -1, -1, -1, -1, -1, -1, -1, 858, -1, -1, 861, -1, 863, -1, -1, -1, 867, 472, -1, -1, 1276, -1, -1, -1, -1, 1281, 877, 1283, -1, 1285, -1, -1, 1288, -1, 1290, -1, -1, 1293, 77, -1, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 902, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 517, -1, -1, -1, 200, -1, -1, -1, -1, 1327, -1, -1, 949, -1, -1, -1, 953, 954, 955, -1, -1, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 984, -1, 1367, -1, -1, -1, 154, 155, -1, 157, 158, 159, -1, -1, -1, -1, -1, 74, 75, 76, 77, -1, -1, -1, 1008, -1, 986, 987, 988, -1, -1, -1, 992, 993, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, -1, -1, 1415, -1, -1, -1, 202, -1, 204, -1, -1, -1, 1020, -1, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 1446, 1447, 1448, -1, 1045, -1, -1, -1, 1454, 1050, -1, -1, 1458, 65, -1, -1, 154, 155, -1, 157, 158, 159, 1063, -1, -1, -1, -1, -1, -1, -1, -1, 1072, -1, 1074, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1109, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, -1, 1124, -1, 1126, 1103, -1, 709, -1, -1, -1, -1, -1, -1, -1, 1113, 10, 11, 12, -1, -1, 723, 724, 725, 726, -1, -1, 1149, -1, -1, -1, -1, -1, -1, 736, 29, -1, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, 1562, -1, -1, -1, -1, -1, 67, 68, -1, -1, -1, -1, 65, -1, -1, -1, 77, -1, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1213, -1, 1596, -1, -1, -1, -1, -1, -1, -1, 1199, -1, -1, 1607, 1203, -1, 1205, 1206, 1612, -1, -1, 1615, -1, -1, 117, -1, -1, -1, 1217, -1, -1, -1, -1, -1, -1, -1, 1225, 1226, -1, -1, -1, -1, -1, -1, 1638, -1, 1235, -1, -1, -1, -1, -1, -1, -1, -1, 148, -1, 850, 151, 152, -1, 154, 155, 1276, 157, 158, 159, -1, 1281, -1, 1283, -1, 1285, 166, -1, 1288, -1, 1290, -1, 1673, 1293, -1, -1, -1, -1, -1, -1, -1, -1, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, -1, -1, 1294, 199, -1, -1, -1, -1, 204, -1, -1, 1327, 200, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 1728, 53, -1, -1, -1, -1, 77, 1330, 1736, -1, -1, -1, 1740, 65, -1, 1743, -1, -1, -1, -1, 1367, -1, -1, -1, -1, -1, 953, 954, 955, -1, -1, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 984, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1415, -1, -1, -1, -1, -1, -1, -1, -1, -1, 77, -1, -1, 1008, -1, 154, 155, -1, 157, 158, 159, -1, -1, -1, -1, -1, -1, 1418, -1, -1, -1, 1446, 1447, 1448, -1, -1, -1, -1, -1, 1454, 10, 11, 12, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, -1, 1449, 29, 199, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, 53, -1, 152, -1, 154, 155, 156, 157, 158, 159, -1, -1, 65, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1109, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 1124, -1, 1126, 199, -1, 10, 11, 12, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1562, -1, -1, -1, -1, -1, 29, 1149, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, 53, -1, -1, -1, 1596, -1, -1, -1, -1, -1, -1, -1, 65, -1, -1, 1607, 77, -1, 79, -1, 1612, -1, -1, 1615, -1, -1, -1, -1, 10, 11, 12, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1213, -1, -1, -1, -1, -1, 29, 195, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, 53, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1673, -1, 65, -1, -1, -1, -1, -1, -1, -1, -1, -1, 154, 155, -1, 157, 158, 159, -1, -1, -1, -1, -1, 1276, -1, -1, -1, -1, 1281, -1, 1283, -1, 1285, -1, -1, 1288, -1, 1290, -1, -1, 1293, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, -1, 1728, -1, 191, 192, -1, 202, -1, 204, 1736, -1, -1, -1, 1740, -1, -1, 1743, -1, -1, -1, 1327, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, 3, 4, 5, 6, 7, -1, -1, -1, -1, -1, 13, 65, -1, -1, -1, -1, -1, -1, -1, 1367, -1, -1, -1, -1, 27, 28, -1, -1, -1, -1, 188, -1, 35, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 47, -1, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, 1415, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, -1, -1, -1, -1, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1446, 1447, 1448, 104, -1, -1, -1, -1, 1454, -1, -1, 112, 113, 114, 115, 116, 117, -1, -1, 120, 121, -1, -1, -1, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, -1, -1, -1, 163, -1, -1, 166, -1, -1, -1, -1, -1, 172, 173, 174, 175, -1, -1, -1, -1, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, -1, -1, -1, 204, 205, -1, 207, 208, -1, -1, -1, -1, -1, -1, -1, -1, 1562, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 4, 5, 6, 7, -1, -1, -1, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, 1596, -1, -1, -1, -1, -1, 27, 28, -1, -1, -1, 1607, -1, -1, -1, -1, 1612, -1, -1, 1615, -1, -1, -1, -1, 45, 46, 47, -1, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, 70, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, 81, -1, -1, -1, 85, 86, 87, 88, -1, 90, -1, 92, -1, 94, -1, -1, 97, 1673, -1, -1, 101, 102, 103, 104, 105, 106, 107, -1, 109, 110, 111, 112, 113, 114, 115, 116, 117, -1, 119, 120, 121, 122, 123, 124, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, 1728, 154, 155, -1, 157, 158, 159, 160, 1736, -1, 163, -1, 1740, 166, -1, 1743, -1, -1, -1, 172, 173, 174, 175, 176, -1, 178, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, 201, 202, 203, 204, 205, -1, 207, 208, 3, 4, 5, 6, 7, -1, -1, -1, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 27, 28, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 45, 46, 47, -1, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, 70, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, 81, -1, -1, -1, 85, 86, 87, 88, -1, 90, -1, 92, -1, 94, -1, -1, 97, -1, -1, -1, 101, 102, 103, 104, 105, 106, 107, -1, 109, 110, 111, 112, 113, 114, 115, 116, 117, -1, 119, 120, 121, 122, 123, 124, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, 160, -1, -1, 163, -1, -1, 166, -1, -1, -1, -1, -1, 172, 173, 174, 175, 176, -1, 178, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, 201, 202, 203, 204, 205, -1, 207, 208, 3, 4, 5, 6, 7, -1, -1, -1, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 27, 28, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 45, 46, 47, -1, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, 70, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, 81, -1, -1, -1, 85, 86, 87, 88, -1, 90, -1, 92, -1, 94, -1, -1, 97, -1, -1, -1, 101, 102, 103, 104, 105, 106, 107, -1, 109, 110, 111, 112, 113, 114, 115, 116, 117, -1, 119, 120, 121, 122, 123, 124, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, 160, -1, -1, 163, -1, -1, 166, -1, -1, -1, -1, -1, 172, 173, 174, 175, 176, -1, 178, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, 201, 202, -1, 204, 205, -1, 207, 208, 3, 4, 5, 6, 7, -1, -1, -1, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 27, 28, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 45, 46, 47, -1, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, 70, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, 81, -1, -1, -1, 85, 86, 87, 88, -1, 90, -1, 92, -1, 94, -1, -1, 97, -1, -1, -1, 101, 102, 103, 104, -1, 106, 107, -1, 109, -1, 111, 112, 113, 114, 115, 116, 117, -1, 119, 120, 121, -1, 123, 124, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, 160, -1, -1, 163, -1, -1, 166, -1, -1, -1, -1, -1, 172, 173, 174, 175, -1, -1, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, 201, 202, 203, 204, 205, -1, 207, 208, 3, 4, 5, 6, 7, -1, -1, -1, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 27, 28, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 45, 46, 47, -1, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, 70, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, 81, -1, -1, -1, 85, 86, 87, 88, -1, 90, -1, 92, -1, 94, -1, -1, 97, -1, -1, -1, 101, 102, 103, 104, -1, 106, 107, -1, 109, -1, 111, 112, 113, 114, 115, 116, 117, -1, 119, 120, 121, -1, 123, 124, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, 160, -1, -1, 163, -1, -1, 166, -1, -1, -1, -1, -1, 172, 173, 174, 175, -1, -1, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, 201, 202, 203, 204, 205, -1, 207, 208, 3, 4, 5, 6, 7, -1, -1, -1, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 27, 28, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 45, 46, 47, -1, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, 70, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, 81, -1, -1, -1, 85, 86, 87, 88, -1, 90, -1, 92, -1, 94, -1, -1, 97, -1, -1, -1, 101, 102, 103, 104, -1, 106, 107, -1, 109, -1, 111, 112, 113, 114, 115, 116, 117, -1, 119, 120, 121, -1, 123, 124, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, 160, -1, -1, 163, -1, -1, 166, -1, -1, -1, -1, -1, 172, 173, 174, 175, -1, -1, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, 201, 202, 203, 204, 205, -1, 207, 208, 3, 4, 5, 6, 7, -1, -1, -1, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 27, 28, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 45, 46, 47, -1, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, 70, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, 81, -1, -1, -1, 85, 86, 87, 88, 89, 90, -1, 92, -1, 94, -1, -1, 97, -1, -1, -1, 101, 102, 103, 104, -1, 106, 107, -1, 109, -1, 111, 112, 113, 114, 115, 116, 117, -1, 119, 120, 121, -1, 123, 124, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, 160, -1, -1, 163, -1, -1, 166, -1, -1, -1, -1, -1, 172, 173, 174, 175, -1, -1, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, 201, 202, -1, 204, 205, -1, 207, 208, 3, 4, 5, 6, 7, -1, -1, -1, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 27, 28, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 45, 46, 47, -1, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, 70, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, 81, -1, -1, -1, 85, 86, 87, 88, -1, 90, -1, 92, -1, 94, 95, -1, 97, -1, -1, -1, 101, 102, 103, 104, -1, 106, 107, -1, 109, -1, 111, 112, 113, 114, 115, 116, 117, -1, 119, 120, 121, -1, 123, 124, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, 160, -1, -1, 163, -1, -1, 166, -1, -1, -1, -1, -1, 172, 173, 174, 175, -1, -1, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, 201, 202, -1, 204, 205, -1, 207, 208, 3, 4, 5, 6, 7, -1, -1, -1, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 27, 28, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 45, 46, 47, -1, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, 70, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, 81, -1, -1, -1, 85, 86, 87, 88, -1, 90, -1, 92, -1, 94, -1, -1, 97, -1, -1, -1, 101, 102, 103, 104, -1, 106, 107, -1, 109, -1, 111, 112, 113, 114, 115, 116, 117, -1, 119, 120, 121, -1, 123, 124, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, 160, -1, -1, 163, -1, -1, 166, -1, -1, -1, -1, -1, 172, 173, 174, 175, -1, -1, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, 201, 202, 203, 204, 205, -1, 207, 208, 3, 4, 5, 6, 7, -1, -1, -1, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 27, 28, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 45, 46, 47, -1, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, 70, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, 81, -1, -1, -1, 85, 86, 87, 88, -1, 90, -1, 92, -1, 94, -1, -1, 97, -1, -1, -1, 101, 102, 103, 104, -1, 106, 107, -1, 109, -1, 111, 112, 113, 114, 115, 116, 117, -1, 119, 120, 121, -1, 123, 124, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, 160, -1, -1, 163, -1, -1, 166, -1, -1, -1, -1, -1, 172, 173, 174, 175, -1, -1, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, 201, 202, 203, 204, 205, -1, 207, 208, 3, 4, 5, 6, 7, -1, -1, -1, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 27, 28, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 45, 46, 47, -1, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, 70, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, 81, -1, -1, -1, 85, 86, 87, 88, -1, 90, -1, 92, 93, 94, -1, -1, 97, -1, -1, -1, 101, 102, 103, 104, -1, 106, 107, -1, 109, -1, 111, 112, 113, 114, 115, 116, 117, -1, 119, 120, 121, -1, 123, 124, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, 160, -1, -1, 163, -1, -1, 166, -1, -1, -1, -1, -1, 172, 173, 174, 175, -1, -1, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, 201, 202, -1, 204, 205, -1, 207, 208, 3, 4, 5, 6, 7, -1, -1, -1, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 27, 28, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 45, 46, 47, -1, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, 70, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, 81, -1, -1, -1, 85, 86, 87, 88, -1, 90, -1, 92, -1, 94, -1, -1, 97, -1, -1, -1, 101, 102, 103, 104, -1, 106, 107, -1, 109, -1, 111, 112, 113, 114, 115, 116, 117, -1, 119, 120, 121, -1, 123, 124, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, 160, -1, -1, 163, -1, -1, 166, -1, -1, -1, -1, -1, 172, 173, 174, 175, -1, -1, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, 201, 202, 203, 204, 205, -1, 207, 208, 3, 4, 5, 6, 7, -1, -1, -1, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 27, 28, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 45, 46, 47, -1, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, 70, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, 81, -1, -1, -1, 85, 86, 87, 88, -1, 90, -1, 92, -1, 94, -1, -1, 97, -1, -1, -1, 101, 102, 103, 104, -1, 106, 107, -1, 109, -1, 111, 112, 113, 114, 115, 116, 117, -1, 119, 120, 121, -1, 123, 124, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, 160, -1, -1, 163, -1, -1, 166, -1, -1, -1, -1, -1, 172, 173, 174, 175, -1, -1, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, 201, 202, 203, 204, 205, -1, 207, 208, 3, 4, 5, 6, 7, -1, -1, -1, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 27, 28, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 45, 46, 47, -1, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, 70, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, 81, -1, -1, -1, 85, 86, 87, 88, -1, 90, 91, 92, -1, 94, -1, -1, 97, -1, -1, -1, 101, 102, 103, 104, -1, 106, 107, -1, 109, -1, 111, 112, 113, 114, 115, 116, 117, -1, 119, 120, 121, -1, 123, 124, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, 160, -1, -1, 163, -1, -1, 166, -1, -1, -1, -1, -1, 172, 173, 174, 175, -1, -1, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, 201, 202, -1, 204, 205, -1, 207, 208, 3, 4, 5, 6, 7, -1, -1, -1, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 27, 28, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 45, 46, 47, -1, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, 70, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, 81, -1, -1, -1, 85, 86, 87, 88, -1, 90, -1, 92, -1, 94, -1, -1, 97, -1, -1, -1, 101, 102, 103, 104, -1, 106, 107, -1, 109, -1, 111, 112, 113, 114, 115, 116, 117, -1, 119, 120, 121, -1, 123, 124, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, 160, -1, -1, 163, -1, -1, 166, -1, -1, -1, -1, -1, 172, 173, 174, 175, -1, -1, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, 201, 202, 203, 204, 205, -1, 207, 208, 3, 4, 5, 6, 7, -1, -1, -1, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 27, 28, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 45, 46, 47, -1, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, 70, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, 81, -1, -1, -1, 85, 86, 87, 88, -1, 90, -1, 92, -1, 94, -1, -1, 97, -1, -1, -1, 101, 102, 103, 104, -1, 106, 107, -1, 109, -1, 111, 112, 113, 114, 115, 116, 117, -1, 119, 120, 121, -1, 123, 124, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, 160, -1, -1, 163, -1, -1, 166, -1, -1, -1, -1, -1, 172, 173, 174, 175, -1, -1, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, 201, 202, 203, 204, 205, -1, 207, 208, 3, 4, 5, 6, 7, -1, -1, -1, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 27, 28, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 45, 46, 47, -1, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, 70, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, 81, -1, -1, -1, 85, 86, 87, 88, -1, 90, -1, 92, -1, 94, -1, -1, 97, -1, -1, -1, 101, 102, 103, 104, -1, 106, 107, -1, 109, -1, 111, 112, 113, 114, 115, 116, 117, -1, 119, 120, 121, -1, 123, 124, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, 160, -1, -1, 163, -1, -1, 166, -1, -1, -1, -1, -1, 172, 173, 174, 175, -1, -1, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, 201, 202, 203, 204, 205, -1, 207, 208, 3, 4, 5, 6, 7, -1, -1, -1, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 27, 28, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 45, 46, 47, -1, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, 70, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, 81, -1, -1, -1, 85, 86, 87, 88, -1, 90, -1, 92, -1, 94, -1, -1, 97, -1, -1, -1, 101, 102, 103, 104, -1, 106, 107, -1, 109, -1, 111, 112, 113, 114, 115, 116, 117, -1, 119, 120, 121, -1, 123, 124, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, 160, -1, -1, 163, -1, -1, 166, -1, -1, -1, -1, -1, 172, 173, 174, 175, -1, -1, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, 201, 202, -1, 204, 205, -1, 207, 208, 3, 4, 5, 6, 7, -1, -1, -1, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 27, 28, -1, 30, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 47, -1, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, 70, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, 81, -1, -1, -1, 85, 86, 87, 88, -1, 90, -1, 92, -1, 94, -1, -1, 97, -1, -1, -1, 101, 102, 103, 104, -1, 106, 107, -1, 109, -1, 111, 112, 113, 114, 115, 116, 117, -1, 119, 120, 121, -1, -1, -1, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, -1, -1, -1, 163, -1, -1, 166, -1, -1, -1, -1, -1, 172, 173, 174, 175, -1, -1, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, 201, 202, -1, 204, 205, -1, 207, 208, 3, 4, 5, 6, 7, -1, -1, -1, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 27, 28, -1, 30, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 47, -1, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, 70, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, 81, -1, -1, -1, 85, 86, 87, 88, -1, 90, -1, 92, -1, 94, -1, -1, 97, -1, -1, -1, 101, 102, 103, 104, -1, 106, 107, -1, 109, -1, 111, 112, 113, 114, 115, 116, 117, -1, 119, 120, 121, -1, -1, -1, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, -1, -1, -1, 163, -1, -1, 166, -1, -1, -1, -1, -1, 172, 173, 174, 175, -1, -1, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, 201, 202, -1, 204, 205, -1, 207, 208, 3, 4, 5, 6, 7, -1, -1, -1, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 27, 28, -1, 30, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 47, -1, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, 70, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, 81, -1, -1, -1, 85, 86, 87, 88, -1, 90, -1, 92, -1, 94, -1, -1, 97, -1, -1, -1, 101, 102, 103, 104, -1, 106, 107, -1, 109, -1, 111, 112, 113, 114, 115, 116, 117, -1, 119, 120, 121, -1, -1, -1, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, -1, -1, -1, 163, -1, -1, 166, -1, -1, -1, -1, -1, 172, 173, 174, 175, -1, -1, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, 201, 202, -1, 204, 205, -1, 207, 208, 3, 4, 5, 6, 7, -1, -1, -1, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 27, 28, -1, 30, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 47, -1, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, 70, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, 81, -1, -1, -1, 85, 86, 87, 88, -1, 90, -1, 92, -1, 94, -1, -1, 97, -1, -1, -1, 101, 102, 103, 104, -1, 106, 107, -1, 109, -1, 111, 112, 113, 114, 115, 116, 117, -1, 119, 120, 121, -1, -1, -1, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, -1, -1, -1, 163, -1, -1, 166, -1, -1, -1, -1, -1, 172, 173, 174, 175, -1, -1, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, 201, 202, -1, 204, 205, -1, 207, 208, 3, 4, 5, 6, 7, -1, -1, -1, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 27, 28, -1, 30, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 47, -1, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, 70, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, 81, -1, -1, -1, 85, 86, 87, 88, -1, 90, -1, 92, -1, 94, -1, -1, 97, -1, -1, -1, 101, 102, 103, 104, -1, 106, 107, -1, 109, -1, 111, 112, 113, 114, 115, 116, 117, -1, 119, 120, 121, -1, -1, -1, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, -1, -1, -1, 163, -1, -1, 166, -1, -1, -1, -1, -1, 172, 173, 174, 175, -1, -1, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, 201, 202, -1, 204, 205, -1, 207, 208, 3, 4, 5, 6, 7, -1, -1, -1, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 27, 28, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 47, -1, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, 70, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, 81, -1, -1, -1, 85, 86, 87, 88, -1, 90, -1, 92, -1, 94, -1, -1, 97, -1, -1, -1, 101, 102, 103, 104, -1, 106, 107, -1, 109, -1, 111, 112, 113, 114, 115, 116, 117, -1, 119, 120, 121, -1, -1, -1, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, -1, -1, -1, 163, -1, -1, 166, -1, -1, -1, -1, -1, 172, 173, 174, 175, -1, -1, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, 201, 202, -1, 204, 205, -1, 207, 208, 3, 4, 5, 6, 7, -1, -1, -1, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 28, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 47, -1, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, -1, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, -1, -1, -1, -1, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 104, -1, -1, -1, -1, -1, -1, -1, 112, 113, 114, 115, 116, 117, -1, -1, 120, 121, -1, -1, -1, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, -1, -1, -1, 163, -1, -1, 166, -1, -1, -1, -1, -1, 172, 173, 174, 175, -1, -1, -1, -1, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, 201, -1, -1, 204, 205, -1, 207, 208, 3, 4, 5, 6, 7, -1, -1, -1, -1, 29, 13, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 35, 53, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 47, 65, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, -1, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, -1, -1, -1, -1, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 104, -1, -1, -1, -1, -1, -1, -1, 112, 113, 114, 115, 116, 117, -1, -1, 120, 121, -1, -1, -1, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, -1, 161, -1, 163, -1, -1, 166, -1, -1, -1, -1, -1, 172, 173, 174, 175, -1, -1, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, -1, -1, -1, 204, 205, -1, 207, 208, 3, 4, 5, 6, 7, -1, -1, -1, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 28, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 47, -1, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, -1, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, -1, -1, -1, -1, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 104, -1, -1, -1, -1, -1, -1, -1, 112, 113, 114, 115, 116, 117, -1, -1, 120, 121, -1, -1, -1, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, -1, -1, -1, 163, -1, -1, 166, -1, -1, -1, -1, -1, 172, 173, 174, 175, -1, -1, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, 11, 12, 202, -1, 204, 205, -1, 207, 208, 3, 4, 5, 6, 7, -1, -1, -1, -1, 29, 13, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 35, 53, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 47, 65, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, -1, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, -1, -1, -1, -1, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 104, -1, -1, -1, -1, -1, -1, -1, 112, 113, 114, 115, 116, 117, -1, -1, 120, 121, -1, -1, -1, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, -1, 161, -1, 163, -1, -1, 166, -1, -1, -1, -1, -1, 172, 173, 174, 175, -1, -1, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, -1, -1, -1, 204, 205, -1, 207, 208, 3, 4, 5, 6, 7, -1, -1, -1, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 27, 28, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 47, -1, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, -1, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, -1, -1, -1, -1, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 104, -1, -1, -1, -1, -1, -1, -1, 112, 113, 114, 115, 116, 117, -1, -1, 120, 121, -1, -1, -1, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, -1, -1, -1, 163, -1, -1, 166, 3, 4, 5, 6, 7, 172, 173, 174, 175, -1, 13, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, -1, -1, -1, 204, 205, -1, 207, 208, -1, 46, 47, -1, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, -1, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, -1, -1, -1, -1, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 101, -1, -1, 104, -1, -1, -1, -1, -1, -1, -1, 112, 113, 114, 115, 116, 117, -1, -1, 120, 121, -1, -1, -1, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, -1, -1, -1, 163, -1, -1, 166, -1, -1, -1, -1, -1, 172, 173, 174, 175, -1, -1, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, 11, 12, -1, -1, 204, 205, -1, 207, 208, 3, 4, 5, 6, 7, -1, -1, -1, -1, 29, 13, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 35, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 47, 65, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, -1, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, -1, -1, -1, -1, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 104, -1, -1, -1, -1, -1, -1, -1, 112, 113, 114, 115, 116, 117, -1, -1, 120, 121, -1, -1, -1, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, -1, -1, -1, 163, -1, -1, 166, 3, 4, 5, 6, 7, 172, 173, 174, 175, -1, 13, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, -1, -1, -1, 204, 205, -1, 207, 208, -1, 46, 47, -1, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, -1, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, -1, -1, -1, -1, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 104, -1, -1, -1, -1, -1, -1, -1, 112, 113, 114, 115, 116, 117, -1, -1, 120, 121, -1, -1, -1, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, -1, -1, -1, 163, -1, -1, 166, 3, 4, 5, 6, 7, 172, 173, 174, 175, -1, 13, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, 201, -1, -1, 204, 205, -1, 207, 208, -1, 46, 47, -1, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, -1, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, -1, -1, -1, -1, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 104, -1, -1, -1, -1, -1, -1, -1, 112, 113, 114, 115, 116, 117, -1, -1, 120, 121, -1, -1, -1, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, -1, -1, -1, 163, -1, -1, 166, 3, 4, 5, 6, 7, 172, 173, 174, 175, -1, 13, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, 201, -1, -1, 204, 205, -1, 207, 208, -1, 46, 47, -1, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, -1, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, -1, -1, -1, -1, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 104, -1, -1, -1, -1, -1, -1, -1, 112, 113, 114, 115, 116, 117, -1, -1, 120, 121, -1, -1, -1, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, -1, -1, -1, 163, -1, -1, 166, -1, -1, -1, -1, -1, 172, 173, 174, 175, -1, -1, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, 200, -1, -1, -1, 204, 205, -1, 207, 208, 3, 4, 5, 6, 7, -1, -1, -1, -1, -1, 13, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 30, 53, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 65, -1, -1, 46, 47, -1, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, -1, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, -1, -1, -1, -1, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 104, -1, -1, -1, -1, -1, -1, -1, 112, 113, 114, 115, 116, 117, -1, -1, 120, 121, -1, -1, -1, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, -1, -1, -1, 163, -1, -1, 166, -1, -1, -1, -1, -1, 172, 173, 174, 175, -1, -1, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, 12, -1, -1, 204, 205, -1, 207, 208, 3, 4, 5, 6, 7, -1, -1, -1, -1, 29, 13, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 35, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 47, 65, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, -1, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, -1, -1, -1, -1, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 104, -1, -1, -1, -1, -1, -1, -1, 112, 113, 114, 115, 116, 117, -1, -1, 120, 121, -1, -1, -1, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, -1, -1, -1, 163, -1, -1, 166, -1, -1, -1, -1, -1, 172, 173, 174, 175, -1, -1, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, -1, -1, -1, 204, 205, -1, 207, 208, 3, 4, 5, 6, 7, -1, -1, -1, -1, 29, 13, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 35, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 47, 65, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, -1, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, -1, -1, -1, -1, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 104, -1, -1, -1, -1, -1, -1, -1, 112, 113, 114, 115, 116, 117, -1, -1, 120, 121, -1, -1, -1, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, -1, -1, -1, 163, -1, -1, 166, -1, -1, -1, -1, -1, 172, 173, 174, 175, -1, -1, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, -1, -1, -1, 204, 205, -1, 207, 208, 3, 4, 5, 6, 7, -1, -1, -1, -1, -1, 13, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 35, 53, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 47, 65, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, -1, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, -1, -1, -1, -1, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 104, -1, -1, -1, -1, -1, -1, -1, 112, 113, 114, 115, 116, 117, -1, -1, 120, 121, -1, -1, -1, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, -1, -1, -1, 163, -1, -1, 166, -1, -1, -1, -1, -1, 172, 173, 174, 175, -1, -1, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, -1, -1, -1, 204, 205, -1, 207, 208, 3, 4, 5, 6, 7, -1, -1, -1, -1, -1, 13, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 35, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 47, 65, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, -1, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, -1, -1, -1, -1, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 104, -1, -1, -1, -1, -1, -1, -1, 112, 113, 114, 115, 116, 117, -1, -1, 120, 121, -1, -1, -1, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, -1, -1, -1, 163, -1, -1, 166, 3, 4, 5, 6, 7, 172, 173, 174, 175, -1, 13, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, -1, -1, -1, 204, 205, -1, 207, 208, -1, 46, 47, -1, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, -1, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, -1, -1, -1, -1, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 104, -1, -1, -1, -1, -1, -1, -1, 112, 113, 114, 115, 116, 117, -1, -1, 120, 121, -1, -1, -1, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, -1, -1, -1, 163, -1, -1, 166, 3, 4, 5, 6, 7, 172, 173, 174, 175, -1, 13, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, -1, -1, -1, 204, 205, -1, 207, 208, -1, 46, 47, -1, -1, -1, -1, 52, -1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 66, 67, 68, 69, -1, -1, -1, -1, 74, 75, 76, 77, 78, 79, -1, -1, -1, -1, -1, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 104, -1, -1, -1, -1, -1, -1, -1, 112, 113, 114, 115, 116, 117, -1, -1, 120, 121, -1, -1, -1, -1, -1, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, -1, -1, -1, 163, -1, -1, 166, -1, -1, -1, -1, -1, 172, 173, 174, 175, -1, -1, -1, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, -1, -1, 199, -1, -1, -1, -1, 204, 205, -1, 207, 208, 3, 4, 5, 6, 7, -1, -1, 10, 11, 12, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 27, 28, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, 53, -1, -1, 53, -1, -1, -1, -1, -1, -1, -1, -1, 65, -1, -1, -1, -1, 67, 68, 69, 70, 71, 72, 73, -1, -1, -1, 77, -1, -1, -1, -1, -1, -1, -1, -1, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, -1, -1, 129, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 148, 149, 150, -1, -1, -1, 154, 155, -1, 157, 158, 159, 160, -1, 162, 163, -1, 165, -1, -1, -1, -1, -1, -1, 172, -1, -1, -1, 176, -1, 178, -1, 180, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 10, 11, 12, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 77, -1, -1, -1, -1, 29, -1, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, 53, 10, 11, 12, -1, -1, -1, -1, -1, -1, -1, -1, 65, -1, -1, -1, -1, -1, -1, -1, 29, -1, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 29, 53, 151, -1, -1, 154, 155, -1, 157, 158, 159, -1, -1, 65, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 55, -1, -1, -1, -1, -1, -1, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, -1, 77, -1, 29, -1, -1, 202, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1, 55, -1, -1, -1, -1, -1, -1, -1, 65, -1, -1, -1, -1, -1, -1, 187, -1, -1, -1, -1, -1, -1, 77, -1, -1, 130, 131, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 148, 53, -1, 151, 152, -1, 154, 155, -1, 157, 158, 159, -1, 65, -1, 186, -1, -1, -1, -1, -1, -1, 77, 29, 172, -1, -1, -1, -1, -1, -1, -1, 130, 131, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, -1, 55, 148, 199, -1, 151, 152, 203, 154, 155, -1, 157, 158, 159, -1, -1, -1, -1, -1, -1, -1, -1, -1, 77, -1, -1, 172, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 104, 154, 155, 199, 157, 158, 159, 203, 112, 113, 114, 115, 116, 117, -1, -1, -1, 29, -1, -1, -1, -1, -1, -1, -1, -1, 130, 131, -1, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 55, 148, -1, 199, 151, 152, -1, 154, 155, -1, 157, 158, 159, -1, -1, -1, -1, -1, -1, -1, -1, -1, 77, -1, 29, 172, -1, -1, -1, -1, -1, -1, -1, -1, 181, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 104, 55, -1, 199, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, 77, -1, -1, 130, 131, -1, -1, -1, -1, -1, 65, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 148, 29, -1, 151, 152, -1, 154, 155, -1, 157, 158, 159, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 172, -1, -1, 55, -1, -1, -1, -1, 130, 131, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, -1, 77, 148, 199, -1, 151, 152, -1, 154, 155, -1, 157, 158, 159, -1, 161, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 172, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, -1, -1, 68, 199, 130, 131, -1, -1, -1, -1, -1, 77, -1, 79, -1, -1, -1, -1, -1, -1, -1, -1, 148, -1, -1, 151, 152, -1, 154, 155, -1, 157, 158, 159, 77, -1, -1, -1, -1, -1, -1, -1, 85, -1, -1, -1, 172, -1, -1, -1, -1, 117, -1, -1, 30, -1, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 46, 47, -1, 199, -1, -1, 52, -1, 54, -1, -1, -1, 148, -1, -1, 151, 152, -1, 154, 155, 66, 157, 158, 159, -1, -1, -1, -1, 74, 75, 76, 77, -1, -1, -1, 148, -1, -1, 151, 85, -1, 154, 155, -1, 157, 158, 159, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, -1, -1, -1, 199, -1, -1, -1, -1, 204, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, -1, 130, -1, 132, 133, 134, 135, 136, 77, -1, 79, -1, -1, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, 77, -1, -1, 163, -1, -1, -1, -1, -1, -1, -1, -1, 172, 173, 174, 175, -1, 117, -1, -1, 180, -1, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 46, 47, -1, 199, -1, -1, 52, -1, 54, -1, -1, -1, 148, -1, -1, 151, 152, -1, 154, 155, 66, 157, 158, 159, -1, -1, -1, -1, 74, 75, 76, 77, -1, -1, -1, -1, -1, -1, 151, 85, -1, 154, 155, -1, 157, 158, 159, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, -1, -1, -1, 199, -1, -1, -1, -1, 204, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, -1, 130, -1, 132, 133, 134, 135, 136, -1, -1, -1, 46, 47, -1, 143, -1, -1, -1, -1, 148, 149, 150, 151, 152, -1, 154, 155, -1, 157, 158, 159, 66, -1, -1, 163, -1, -1, -1, -1, 74, 75, 76, 77, 172, 173, 174, 175, -1, -1, -1, 85, 180, -1, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, -1, -1, -1, 199, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 77, -1, 79, -1, -1, 130, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 154, 155, -1, 157, 158, 159, -1, -1, -1, -1, -1, 117, -1, -1, -1, -1, -1, -1, 172, -1, -1, -1, -1, 129, -1, -1, -1, -1, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 148, -1, -1, 151, 152, -1, 154, 155, -1, 157, 158, 159, 77, -1, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, -1, -1, -1, 199, 117, -1, -1, -1, 204, -1, -1, -1, -1, -1, -1, -1, 129, -1, 77, -1, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 148, -1, -1, 151, 152, 77, 154, 155, -1, 157, 158, 159, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 117, -1, -1, -1, -1, -1, -1, -1, -1, 104, 105, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, -1, -1, -1, 199, -1, 77, 148, -1, 204, 151, 152, -1, 154, 155, -1, 157, 158, 159, 77, -1, 79, -1, -1, -1, -1, -1, 85, -1, -1, -1, -1, 151, -1, -1, 154, 155, -1, 157, 158, 159, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, -1, -1, -1, 199, 117, -1, -1, -1, 204, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 148, -1, -1, 151, 152, -1, 154, 155, -1, 157, 158, 159, -1, 148, -1, -1, 151, 152, -1, 154, 155, -1, 157, 158, 159, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 10, 11, 12, -1, -1, -1, -1, -1, 204, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 29, -1, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, 53, 10, 11, 12, -1, -1, -1, -1, -1, -1, -1, -1, 65, -1, -1, -1, -1, -1, -1, -1, 29, -1, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, 53, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 65, 10, 11, 12, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 128, 29, -1, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, 53, 10, 11, 12, -1, -1, -1, -1, -1, -1, -1, -1, 65, -1, -1, -1, -1, -1, -1, 128, 29, -1, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, 53, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 65, 10, 11, 12, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 128, 29, -1, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, 53, 10, 11, 12, -1, -1, -1, -1, -1, -1, -1, -1, 65, -1, -1, -1, -1, -1, -1, 128, 29, -1, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, 53, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 65, 10, 11, 12, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 128, 29, -1, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, 53, 10, 11, 12, -1, -1, -1, -1, -1, -1, -1, -1, 65, -1, -1, -1, -1, -1, -1, 128, 29, -1, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 65, 10, 11, 12, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 128, 29, -1, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 10, 11, 12, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 65, -1, -1, -1, -1, -1, 29, 128, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 65, 10, 11, 12, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 29, 128, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 10, 11, 12, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 65, -1, -1, -1, -1, -1, 29, 128, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1, 77, -1, 79, 80, -1, -1, -1, -1, 65, 10, 11, 12, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 77, -1, -1, -1, -1, -1, 29, 128, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 118, 65, -1, 77, -1, -1, -1, -1, 128, -1, -1, -1, 130, 131, 154, 155, 77, 157, 158, 159, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 148, -1, -1, 151, 152, -1, 154, 155, -1, 157, 158, 159, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, -1, -1, -1, -1, -1, 77, -1, -1, 128, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 152, -1, 154, 155, -1, 157, 158, 159, -1, -1, -1, -1, 151, -1, -1, 154, 155, -1, 157, 158, 159, -1, -1, -1, -1, 77, -1, -1, -1, -1, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 151, -1, -1, 154, 155, -1, 157, 158, 159, -1, 77, -1, -1, -1, 123, -1, -1, -1, -1, -1, -1, -1, -1, 77, -1, -1, -1, -1, -1, -1, -1, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 154, 155, -1, 157, 158, 159, -1, -1, -1, -1, -1, 123, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 154, 155, -1, 157, 158, 159, -1, -1, -1, -1, -1, -1, -1, 154, 155, -1, 157, 158, 159, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 10, 11, 12, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 28, 29, -1, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, 53, 10, 11, 12, -1, -1, -1, -1, -1, -1, -1, -1, 65, -1, -1, -1, -1, -1, -1, -1, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 96, 53, 10, 11, 12, -1, -1, -1, -1, -1, -1, -1, -1, 65, -1, -1, -1, -1, -1, -1, -1, 29, -1, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, 53, 10, 11, 12, -1, -1, -1, -1, -1, -1, -1, -1, 65, -1, -1, -1, -1, -1, -1, -1, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 10, 11, 12, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 65, -1, -1, -1, -1, -1, 29, -1, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 65 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint16 yystos[] = { 0, 210, 211, 0, 212, 3, 4, 5, 6, 7, 13, 27, 28, 45, 46, 47, 52, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68, 69, 70, 74, 75, 76, 77, 78, 79, 81, 85, 86, 87, 88, 90, 92, 94, 97, 101, 102, 103, 104, 105, 106, 107, 109, 110, 111, 112, 113, 114, 115, 116, 117, 119, 120, 121, 122, 123, 124, 129, 130, 132, 133, 134, 135, 136, 143, 148, 149, 150, 151, 152, 154, 155, 157, 158, 159, 160, 163, 166, 172, 173, 174, 175, 176, 178, 180, 181, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 199, 201, 202, 204, 205, 207, 208, 213, 216, 223, 224, 225, 226, 227, 228, 231, 247, 248, 252, 255, 260, 266, 324, 325, 330, 334, 335, 336, 337, 338, 339, 340, 341, 343, 346, 357, 358, 359, 360, 361, 365, 366, 368, 387, 397, 398, 399, 404, 407, 425, 430, 432, 433, 434, 435, 436, 437, 438, 439, 441, 462, 464, 466, 115, 116, 117, 129, 148, 158, 216, 247, 324, 340, 432, 340, 199, 340, 340, 340, 101, 340, 340, 423, 424, 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, 79, 117, 199, 224, 398, 399, 432, 432, 35, 340, 445, 446, 340, 117, 199, 224, 398, 399, 400, 431, 437, 442, 443, 199, 331, 401, 199, 331, 347, 332, 340, 233, 331, 199, 199, 199, 331, 201, 340, 216, 201, 340, 29, 55, 130, 131, 152, 172, 199, 216, 227, 467, 479, 480, 182, 201, 337, 340, 367, 369, 202, 240, 340, 104, 105, 151, 217, 220, 223, 79, 204, 292, 293, 123, 123, 79, 294, 199, 199, 199, 199, 216, 264, 468, 199, 199, 79, 84, 144, 145, 146, 459, 460, 151, 202, 223, 223, 216, 265, 468, 152, 199, 199, 199, 199, 468, 468, 79, 196, 349, 330, 340, 341, 432, 229, 202, 84, 402, 459, 84, 459, 459, 30, 151, 168, 469, 199, 9, 201, 35, 246, 152, 263, 468, 117, 181, 247, 325, 201, 201, 201, 201, 201, 201, 10, 11, 12, 29, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 53, 65, 201, 66, 66, 201, 202, 147, 124, 158, 160, 266, 323, 324, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 63, 64, 127, 427, 428, 66, 202, 429, 199, 66, 202, 204, 438, 199, 246, 247, 14, 340, 201, 128, 44, 216, 422, 199, 330, 432, 147, 432, 128, 206, 9, 409, 330, 432, 469, 147, 199, 403, 127, 427, 428, 429, 200, 340, 30, 231, 8, 351, 9, 201, 231, 232, 332, 333, 340, 216, 278, 235, 201, 201, 201, 480, 480, 168, 199, 104, 480, 14, 216, 79, 201, 201, 201, 182, 183, 184, 189, 190, 193, 194, 370, 371, 372, 373, 374, 375, 376, 377, 378, 382, 383, 384, 241, 108, 165, 201, 151, 218, 221, 223, 151, 219, 222, 223, 223, 9, 201, 96, 202, 432, 9, 201, 14, 9, 201, 432, 463, 463, 330, 341, 432, 200, 168, 258, 129, 432, 444, 445, 66, 127, 144, 460, 78, 340, 432, 84, 144, 460, 223, 215, 201, 202, 253, 261, 388, 390, 85, 204, 352, 353, 355, 399, 438, 464, 340, 452, 454, 340, 451, 453, 451, 14, 96, 465, 348, 350, 288, 289, 425, 426, 200, 200, 200, 203, 230, 231, 248, 255, 260, 425, 340, 205, 207, 208, 216, 470, 471, 480, 35, 161, 290, 291, 340, 467, 199, 468, 256, 246, 340, 340, 340, 30, 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, 400, 340, 340, 440, 440, 340, 447, 448, 123, 202, 216, 437, 438, 264, 216, 265, 263, 247, 27, 35, 334, 337, 340, 367, 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, 202, 216, 437, 440, 340, 290, 440, 340, 444, 246, 200, 340, 199, 421, 9, 409, 330, 200, 216, 35, 340, 35, 340, 200, 200, 437, 290, 202, 216, 437, 200, 229, 282, 202, 337, 340, 340, 88, 30, 231, 276, 201, 28, 96, 14, 9, 200, 30, 202, 279, 480, 85, 227, 476, 477, 478, 199, 9, 46, 47, 52, 54, 66, 85, 130, 143, 152, 172, 173, 174, 175, 199, 224, 225, 227, 362, 363, 364, 398, 404, 405, 406, 185, 79, 340, 79, 79, 340, 379, 380, 340, 340, 372, 382, 188, 385, 229, 199, 239, 223, 201, 9, 96, 223, 201, 9, 96, 96, 220, 216, 340, 293, 405, 79, 9, 200, 200, 200, 200, 200, 201, 46, 47, 474, 475, 125, 269, 199, 9, 200, 200, 79, 80, 216, 461, 216, 66, 203, 203, 212, 214, 30, 126, 268, 167, 50, 152, 167, 392, 128, 9, 409, 200, 147, 200, 9, 409, 128, 200, 9, 409, 200, 480, 480, 14, 351, 288, 197, 9, 410, 480, 481, 127, 427, 428, 429, 203, 9, 409, 169, 432, 340, 200, 9, 410, 14, 344, 249, 125, 267, 199, 468, 340, 30, 206, 206, 128, 203, 9, 409, 340, 469, 199, 259, 254, 262, 257, 246, 68, 432, 340, 469, 199, 206, 203, 200, 206, 203, 200, 46, 47, 66, 74, 75, 76, 85, 130, 143, 172, 216, 412, 414, 417, 420, 216, 432, 432, 128, 427, 428, 429, 200, 340, 283, 71, 72, 284, 229, 331, 229, 333, 96, 35, 129, 273, 432, 405, 216, 30, 231, 277, 201, 280, 201, 280, 9, 169, 128, 147, 9, 409, 200, 161, 470, 471, 472, 470, 405, 405, 405, 405, 405, 408, 411, 199, 84, 147, 199, 199, 199, 199, 405, 147, 202, 10, 11, 12, 29, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 65, 340, 185, 185, 14, 191, 192, 381, 9, 195, 385, 79, 203, 398, 202, 243, 96, 221, 216, 96, 222, 216, 216, 203, 14, 432, 201, 9, 169, 216, 270, 398, 202, 444, 129, 432, 14, 206, 340, 203, 212, 480, 270, 202, 391, 14, 340, 352, 216, 340, 340, 340, 201, 480, 197, 30, 473, 426, 35, 79, 161, 202, 216, 437, 480, 35, 161, 340, 405, 288, 199, 398, 268, 345, 250, 340, 340, 340, 203, 199, 290, 269, 30, 268, 267, 468, 400, 203, 199, 290, 14, 74, 75, 76, 216, 413, 413, 414, 415, 416, 199, 84, 144, 199, 9, 409, 200, 421, 35, 340, 203, 71, 72, 285, 331, 231, 203, 201, 89, 201, 273, 432, 199, 128, 272, 14, 229, 280, 98, 99, 100, 280, 203, 480, 480, 216, 476, 9, 200, 409, 128, 206, 9, 409, 408, 216, 352, 354, 356, 405, 456, 458, 405, 455, 457, 455, 200, 123, 216, 405, 449, 450, 405, 405, 405, 30, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 405, 340, 340, 340, 380, 340, 370, 79, 244, 216, 216, 405, 475, 96, 9, 298, 200, 199, 334, 337, 340, 206, 203, 465, 298, 153, 166, 202, 387, 394, 153, 202, 393, 128, 128, 201, 473, 480, 351, 481, 79, 14, 79, 340, 469, 199, 432, 340, 200, 288, 202, 288, 199, 128, 199, 290, 200, 202, 480, 202, 268, 251, 403, 199, 290, 200, 128, 206, 9, 409, 415, 144, 352, 418, 419, 414, 432, 331, 30, 73, 231, 201, 333, 272, 444, 273, 200, 405, 95, 98, 201, 340, 30, 201, 281, 203, 169, 128, 161, 30, 200, 405, 405, 200, 128, 9, 409, 200, 200, 9, 409, 128, 200, 9, 409, 200, 128, 203, 9, 409, 405, 30, 186, 200, 229, 216, 480, 398, 4, 105, 110, 118, 154, 155, 157, 203, 299, 322, 323, 324, 329, 425, 444, 203, 202, 203, 50, 340, 340, 340, 340, 351, 35, 79, 161, 14, 405, 203, 199, 290, 473, 200, 298, 200, 288, 340, 290, 200, 298, 465, 298, 202, 199, 290, 200, 414, 414, 200, 128, 200, 9, 409, 30, 229, 201, 200, 200, 200, 236, 201, 201, 281, 229, 480, 480, 128, 405, 352, 405, 405, 405, 405, 405, 405, 340, 202, 203, 96, 125, 126, 467, 271, 398, 118, 130, 131, 152, 158, 308, 309, 310, 398, 156, 314, 315, 121, 199, 216, 316, 317, 300, 247, 480, 9, 201, 323, 200, 295, 152, 389, 203, 203, 79, 14, 79, 405, 199, 290, 200, 110, 342, 473, 203, 473, 200, 200, 203, 202, 203, 298, 288, 200, 128, 414, 352, 229, 234, 237, 30, 231, 275, 229, 200, 405, 128, 128, 128, 187, 229, 480, 398, 398, 14, 9, 201, 202, 202, 9, 201, 3, 4, 5, 6, 7, 10, 11, 12, 13, 27, 28, 53, 67, 68, 69, 70, 71, 72, 73, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 129, 130, 132, 133, 134, 135, 136, 148, 149, 150, 160, 162, 163, 165, 172, 176, 178, 180, 181, 216, 395, 396, 9, 201, 152, 156, 216, 317, 318, 319, 201, 79, 328, 246, 301, 467, 247, 203, 296, 297, 467, 14, 405, 290, 200, 199, 202, 201, 202, 320, 342, 473, 295, 203, 200, 414, 128, 30, 231, 274, 275, 229, 405, 405, 405, 340, 203, 201, 201, 405, 398, 304, 311, 404, 309, 14, 30, 47, 312, 315, 9, 33, 200, 29, 46, 49, 14, 9, 201, 468, 328, 14, 246, 201, 14, 405, 200, 35, 79, 386, 229, 229, 202, 320, 203, 473, 414, 229, 93, 188, 242, 203, 216, 227, 305, 306, 307, 9, 203, 405, 396, 396, 55, 313, 318, 318, 29, 46, 49, 405, 79, 199, 201, 405, 468, 405, 79, 9, 410, 203, 203, 229, 320, 91, 201, 79, 108, 238, 147, 96, 404, 159, 14, 302, 199, 35, 79, 200, 203, 201, 199, 165, 245, 216, 323, 324, 405, 286, 287, 426, 303, 79, 398, 243, 162, 216, 201, 200, 9, 410, 112, 113, 114, 326, 327, 286, 79, 271, 201, 473, 426, 481, 200, 200, 201, 201, 202, 321, 326, 35, 79, 161, 473, 202, 229, 481, 79, 14, 79, 321, 229, 203, 35, 79, 161, 14, 405, 203, 79, 14, 79, 405, 14, 405, 405 }; #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) #define YYEMPTY (-2) #define YYEOF 0 #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab #define YYERROR goto yyerrorlab /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. Once GCC version 2 has supplanted version 1, this can go. */ #define YYFAIL goto yyerrlab #define YYRECOVERING() (!!yyerrstatus) #define YYBACKUP(Token, Value) \ do \ if (yychar == YYEMPTY && yylen == 1) \ { \ yychar = (Token); \ yylval = (Value); \ yytoken = YYTRANSLATE (yychar); \ YYPOPSTACK (1); \ goto yybackup; \ } \ else \ { \ yyerror (&yylloc, _p, YY_("syntax error: cannot back up")); \ YYERROR; \ } \ while (YYID (0)) #define YYTERROR 1 #define YYERRCODE 256 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. If N is 0, then set CURRENT to the empty location which ends the previous symbol: RHS[0] (always defined). */ #define YYRHSLOC(Rhs, K) ((Rhs)[K]) #ifndef YYLLOC_DEFAULT # define YYLLOC_DEFAULT(Current, Rhs, N) \ do \ if (YYID (N)) \ { \ (Current).line0 = YYRHSLOC (Rhs, 1).line0; \ (Current).char0 = YYRHSLOC (Rhs, 1).char0; \ (Current).line1 = YYRHSLOC (Rhs, N).line1; \ (Current).char1 = YYRHSLOC (Rhs, N).char1; \ } \ else \ { \ (Current).line0 = (Current).line1 = \ YYRHSLOC (Rhs, 0).line1; \ (Current).char0 = (Current).char1 = \ YYRHSLOC (Rhs, 0).char1; \ } \ while (YYID (0)) #endif /* YY_LOCATION_PRINT -- Print the location on the stream. This macro was not mandated originally: define only if we know we won't break user code: when these are the locations we know. */ #ifndef YY_LOCATION_PRINT # if YYLTYPE_IS_TRIVIAL # define YY_LOCATION_PRINT(File, Loc) \ fprintf (File, "%d.%d-%d.%d", \ (Loc).line0, (Loc).char0, \ (Loc).line1, (Loc).char1) # else # define YY_LOCATION_PRINT(File, Loc) ((void) 0) # endif #endif /* YYLEX -- calling `yylex' with the right arguments. */ #ifdef YYLEX_PARAM # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM) #else # define YYLEX yylex (&yylval, &yylloc, _p) #endif /* Enable debugging if requested. */ #if YYDEBUG # ifndef YYFPRINTF # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ # define YYFPRINTF fprintf # endif # define YYDPRINTF(Args) \ do { \ if (yydebug) \ YYFPRINTF Args; \ } while (YYID (0)) # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, \ Type, Value, Location, _p); \ YYFPRINTF (stderr, "\n"); \ } \ } while (YYID (0)) /*--------------------------------. | Print this symbol on YYOUTPUT. | `--------------------------------*/ /*ARGSUSED*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, HPHP::HPHP_PARSER_NS::Parser *_p) #else static void yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, _p) FILE *yyoutput; int yytype; YYSTYPE const * const yyvaluep; YYLTYPE const * const yylocationp; HPHP::HPHP_PARSER_NS::Parser *_p; #endif { if (!yyvaluep) return; YYUSE (yylocationp); YYUSE (_p); # ifdef YYPRINT if (yytype < YYNTOKENS) YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); # else YYUSE (yyoutput); # endif switch (yytype) { default: break; } } /*--------------------------------. | Print this symbol on YYOUTPUT. | `--------------------------------*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, HPHP::HPHP_PARSER_NS::Parser *_p) #else static void yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, _p) FILE *yyoutput; int yytype; YYSTYPE const * const yyvaluep; YYLTYPE const * const yylocationp; HPHP::HPHP_PARSER_NS::Parser *_p; #endif { if (yytype < YYNTOKENS) YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); else YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); YY_LOCATION_PRINT (yyoutput, *yylocationp); YYFPRINTF (yyoutput, ": "); yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, _p); YYFPRINTF (yyoutput, ")"); } /*------------------------------------------------------------------. | yy_stack_print -- Print the state stack from its BOTTOM up to its | | TOP (included). | `------------------------------------------------------------------*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) #else static void yy_stack_print (yybottom, yytop) yytype_int16 *yybottom; yytype_int16 *yytop; #endif { YYFPRINTF (stderr, "Stack now"); for (; yybottom <= yytop; yybottom++) { int yybot = *yybottom; YYFPRINTF (stderr, " %d", yybot); } YYFPRINTF (stderr, "\n"); } # define YY_STACK_PRINT(Bottom, Top) \ do { \ if (yydebug) \ yy_stack_print ((Bottom), (Top)); \ } while (YYID (0)) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, HPHP::HPHP_PARSER_NS::Parser *_p) #else static void yy_reduce_print (yyvsp, yylsp, yyrule, _p) YYSTYPE *yyvsp; YYLTYPE *yylsp; int yyrule; HPHP::HPHP_PARSER_NS::Parser *_p; #endif { int yynrhs = yyr2[yyrule]; int yyi; unsigned long int yylno = yyrline[yyrule]; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], &(yyvsp[(yyi + 1) - (yynrhs)]) , &(yylsp[(yyi + 1) - (yynrhs)]) , _p); YYFPRINTF (stderr, "\n"); } } # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ yy_reduce_print (yyvsp, yylsp, Rule, _p); \ } while (YYID (0)) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ # define YYDPRINTF(Args) # define YY_SYMBOL_PRINT(Title, Type, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ /* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only if the built-in stack extension method is used). Do not make this value too large; the results are undefined if YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) evaluated with infinite-precision integer arithmetic. */ #ifndef YYMAXDEPTH # define YYMAXDEPTH 10000 #endif #if YYERROR_VERBOSE # ifndef yystrlen # if defined __GLIBC__ && defined _STRING_H # define yystrlen strlen # else /* Return the length of YYSTR. */ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static YYSIZE_T yystrlen (const char *yystr) #else static YYSIZE_T yystrlen (yystr) const char *yystr; #endif { YYSIZE_T yylen; for (yylen = 0; yystr[yylen]; yylen++) continue; return yylen; } # endif # endif # ifndef yystpcpy # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE # define yystpcpy stpcpy # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static char * yystpcpy (char *yydest, const char *yysrc) #else static char * yystpcpy (yydest, yysrc) char *yydest; const char *yysrc; #endif { char *yyd = yydest; const char *yys = yysrc; while ((*yyd++ = *yys++) != '\0') continue; return yyd - 1; } # endif # endif # ifndef yytnamerr /* Copy to YYRES the contents of YYSTR after stripping away unnecessary quotes and backslashes, so that it's suitable for yyerror. The heuristic is that double-quoting is unnecessary unless the string contains an apostrophe, a comma, or backslash (other than backslash-backslash). YYSTR is taken from yytname. If YYRES is null, do not copy; instead, return the length of what the result would have been. */ static YYSIZE_T yytnamerr (char *yyres, const char *yystr) { if (*yystr == '"') { YYSIZE_T yyn = 0; char const *yyp = yystr; for (;;) switch (*++yyp) { case '\'': case ',': goto do_not_strip_quotes; case '\\': if (*++yyp != '\\') goto do_not_strip_quotes; /* Fall through. */ default: if (yyres) yyres[yyn] = *yyp; yyn++; break; case '"': if (yyres) yyres[yyn] = '\0'; return yyn; } do_not_strip_quotes: ; } if (! yyres) return yystrlen (yystr); return yystpcpy (yyres, yystr) - yyres; } # endif /* Copy into YYRESULT an error message about the unexpected token YYCHAR while in state YYSTATE. Return the number of bytes copied, including the terminating null byte. If YYRESULT is null, do not copy anything; just return the number of bytes that would be copied. As a special case, return 0 if an ordinary "syntax error" message will do. Return YYSIZE_MAXIMUM if overflow occurs during size calculation. */ static YYSIZE_T yysyntax_error (char *yyresult, int yystate, int yychar) { int yyn = yypact[yystate]; if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) return 0; else { int yytype = YYTRANSLATE (yychar); YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); YYSIZE_T yysize = yysize0; YYSIZE_T yysize1; int yysize_overflow = 0; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; int yyx; # if 0 /* This is so xgettext sees the translatable formats that are constructed on the fly. */ YY_("syntax error, unexpected %s"); YY_("syntax error, unexpected %s, expecting %s"); YY_("syntax error, unexpected %s, expecting %s or %s"); YY_("syntax error, unexpected %s, expecting %s or %s or %s"); YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); # endif char *yyfmt; char const *yyf; static char const yyunexpected[] = "syntax error, unexpected %s"; static char const yyexpecting[] = ", expecting %s"; static char const yyor[] = " or %s"; char yyformat[sizeof yyunexpected + sizeof yyexpecting - 1 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) * (sizeof yyor - 1))]; char const *yyprefix = yyexpecting; /* Start YYX at -YYN if negative to avoid negative indexes in YYCHECK. */ int yyxbegin = yyn < 0 ? -yyn : 0; /* Stay within bounds of both yycheck and yytname. */ int yychecklim = YYLAST - yyn + 1; int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; int yycount = 1; yyarg[0] = yytname[yytype]; yyfmt = yystpcpy (yyformat, yyunexpected); for (yyx = yyxbegin; yyx < yyxend; ++yyx) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) { if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) { yycount = 1; yysize = yysize0; yyformat[sizeof yyunexpected - 1] = '\0'; break; } yyarg[yycount++] = yytname[yyx]; yysize1 = yysize + yytnamerr (0, yytname[yyx]); yysize_overflow |= (yysize1 < yysize); yysize = yysize1; yyfmt = yystpcpy (yyfmt, yyprefix); yyprefix = yyor; } yyf = YY_(yyformat); yysize1 = yysize + yystrlen (yyf); yysize_overflow |= (yysize1 < yysize); yysize = yysize1; if (yysize_overflow) return YYSIZE_MAXIMUM; if (yyresult) { /* Avoid sprintf, as that infringes on the user's name space. Don't have undefined behavior even if the translation produced a string with the wrong number of "%s"s. */ char *yyp = yyresult; int yyi = 0; while ((*yyp = *yyf) != '\0') { if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) { yyp += yytnamerr (yyp, yyarg[yyi++]); yyf += 2; } else { yyp++; yyf++; } } } return yysize; } } #endif /* YYERROR_VERBOSE */ /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ /*ARGSUSED*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, HPHP::HPHP_PARSER_NS::Parser *_p) #else static void yydestruct (yymsg, yytype, yyvaluep, yylocationp, _p) const char *yymsg; int yytype; YYSTYPE *yyvaluep; YYLTYPE *yylocationp; HPHP::HPHP_PARSER_NS::Parser *_p; #endif { YYUSE (yyvaluep); YYUSE (yylocationp); YYUSE (_p); if (!yymsg) yymsg = "Deleting"; YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); switch (yytype) { default: break; } } /* Prevent warnings from -Wmissing-prototypes. */ #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus int yyparse (void *YYPARSE_PARAM); #else int yyparse (); #endif #else /* ! YYPARSE_PARAM */ #if defined __STDC__ || defined __cplusplus int yyparse (HPHP::HPHP_PARSER_NS::Parser *_p); #else int yyparse (); #endif #endif /* ! YYPARSE_PARAM */ /*-------------------------. | yyparse or yypush_parse. | `-------------------------*/ #ifdef YYPARSE_PARAM #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) int yyparse (void *YYPARSE_PARAM) #else int yyparse (YYPARSE_PARAM) void *YYPARSE_PARAM; #endif #else /* ! YYPARSE_PARAM */ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) int yyparse (HPHP::HPHP_PARSER_NS::Parser *_p) #else int yyparse (_p) HPHP::HPHP_PARSER_NS::Parser *_p; #endif #endif { /* The lookahead symbol. */ int yychar; /* The semantic value of the lookahead symbol. */ YYSTYPE yylval; /* Location data for the lookahead symbol. */ YYLTYPE yylloc; /* Number of syntax errors so far. */ int yynerrs; int yystate; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; /* The stacks and their tools: `yyss': related to states. `yyvs': related to semantic values. `yyls': related to locations. Refer to the stacks thru separate pointers, to allow yyoverflow to reallocate them elsewhere. */ /* The state stack. */ yytype_int16 yyssa[YYINITDEPTH]; yytype_int16 *yyss; yytype_int16 *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; YYSTYPE *yyvs; YYSTYPE *yyvsp; /* The location stack. */ YYLTYPE yylsa[YYINITDEPTH]; YYLTYPE *yyls; YYLTYPE *yylsp; /* The locations where the error started and ended. */ YYLTYPE yyerror_range[2]; YYSIZE_T yystacksize; int yyn; int yyresult; /* Lookahead token as an internal (translated) token number. */ int yytoken; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; YYLTYPE yyloc; #if YYERROR_VERBOSE /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; char *yymsg = yymsgbuf; YYSIZE_T yymsg_alloc = sizeof yymsgbuf; #endif #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; yytoken = 0; yyss = yyssa; yyvs = yyvsa; yyls = yylsa; yystacksize = YYINITDEPTH; YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ yyssp = yyss; yyvsp = yyvs; yylsp = yyls; #if YYLTYPE_IS_TRIVIAL /* Initialize the default location before parsing starts. */ yylloc.line0 = yylloc.line1 = 1; yylloc.char0 = yylloc.char1 = 1; #endif goto yysetstate; /*------------------------------------------------------------. | yynewstate -- Push a new state, which is found in yystate. | `------------------------------------------------------------*/ yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; yysetstate: *yyssp = yystate; if (yyss + yystacksize - 1 <= yyssp) { /* Get the current used size of the three stacks, in elements. */ YYSIZE_T yysize = yyssp - yyss + 1; #ifdef yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; yytype_int16 *yyss1 = yyss; YYLTYPE *yyls1 = yyls; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), &yyls1, yysize * sizeof (*yylsp), &yystacksize); yyls = yyls1; yyss = yyss1; yyvs = yyvs1; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE goto yyexhaustedlab; # else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; { yytype_int16 *yyss1 = yyss; struct yyalloc *yyptr = (struct yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); memset(yyptr, 0, YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; YYSTACK_RELOCATE (yyss_alloc, yyss); YYSTACK_RELOCATE_RESET (yyvs_alloc, yyvs); YYSTACK_RELOCATE (yyls_alloc, yyls); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif #endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; yylsp = yyls + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); if (yystate == YYFINAL) YYACCEPT; goto yybackup; /*-----------. | yybackup. | `-----------*/ yybackup: /* Do appropriate processing given the current state. Read a lookahead token if we need one and don't already have one. */ /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; } if (yychar <= YYEOF) { yychar = yytoken = YYEOF; YYDPRINTF ((stderr, "Now at end of input.\n")); } else { yytoken = YYTRANSLATE (yychar); YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); } /* If the proper action on seeing token YYTOKEN is to reduce or to detect an error, take that action. */ yyn += yytoken; if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) goto yydefault; yyn = yytable[yyn]; if (yyn <= 0) { if (yyn == 0 || yyn == YYTABLE_NINF) goto yyerrlab; yyn = -yyn; goto yyreduce; } /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); /* Discard the shifted token. */ yychar = YYEMPTY; yystate = yyn; *++yyvsp = yylval; *++yylsp = yylloc; goto yynewstate; /*-----------------------------------------------------------. | yydefault -- do the default action for the current state. | `-----------------------------------------------------------*/ yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; goto yyreduce; /*-----------------------------. | yyreduce -- Do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: `$$ = $1'. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison users should not rely upon it. Assigning to YYVAL unconditionally makes the parser a bit smaller, and it avoids a GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; /* Default location. */ YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); YY_REDUCE_PRINT (yyn); switch (yyn) { case 2: /* Line 1455 of yacc.c */ #line 733 "hphp.y" { _p->onNewLabelScope(true); _p->initParseTree();;} break; case 3: /* Line 1455 of yacc.c */ #line 736 "hphp.y" { _p->popLabelInfo(); _p->finiParseTree(); _p->onCompleteLabelScope(true);;} break; case 4: /* Line 1455 of yacc.c */ #line 743 "hphp.y" { _p->addTopStatement((yyvsp[(2) - (2)]));;} break; case 5: /* Line 1455 of yacc.c */ #line 744 "hphp.y" { ;} break; case 6: /* Line 1455 of yacc.c */ #line 747 "hphp.y" { _p->nns((yyvsp[(1) - (1)]).num(), (yyvsp[(1) - (1)]).text()); (yyval) = (yyvsp[(1) - (1)]);;} break; case 7: /* Line 1455 of yacc.c */ #line 748 "hphp.y" { _p->nns(); (yyval) = (yyvsp[(1) - (1)]);;} break; case 8: /* Line 1455 of yacc.c */ #line 749 "hphp.y" { _p->nns(); (yyval) = (yyvsp[(1) - (1)]);;} break; case 9: /* Line 1455 of yacc.c */ #line 750 "hphp.y" { _p->nns(); (yyval) = (yyvsp[(1) - (1)]);;} break; case 10: /* Line 1455 of yacc.c */ #line 751 "hphp.y" { _p->nns(); (yyval) = (yyvsp[(1) - (1)]);;} break; case 11: /* Line 1455 of yacc.c */ #line 752 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]); ;} break; case 12: /* Line 1455 of yacc.c */ #line 753 "hphp.y" { _p->onHaltCompiler(); _p->finiParseTree(); YYACCEPT;;} break; case 13: /* Line 1455 of yacc.c */ #line 756 "hphp.y" { _p->onNamespaceStart((yyvsp[(2) - (3)]).text(), true); (yyval).reset();;} break; case 14: /* Line 1455 of yacc.c */ #line 758 "hphp.y" { _p->onNamespaceStart((yyvsp[(2) - (3)]).text());;} break; case 15: /* Line 1455 of yacc.c */ #line 759 "hphp.y" { _p->onNamespaceEnd(); (yyval) = (yyvsp[(5) - (6)]);;} break; case 16: /* Line 1455 of yacc.c */ #line 760 "hphp.y" { _p->onNamespaceStart("");;} break; case 17: /* Line 1455 of yacc.c */ #line 761 "hphp.y" { _p->onNamespaceEnd(); (yyval) = (yyvsp[(4) - (5)]);;} break; case 18: /* Line 1455 of yacc.c */ #line 762 "hphp.y" { _p->nns(); (yyval).reset();;} break; case 19: /* Line 1455 of yacc.c */ #line 764 "hphp.y" { _p->nns(); (yyval).reset();;} break; case 20: /* Line 1455 of yacc.c */ #line 766 "hphp.y" { _p->nns(); (yyval).reset();;} break; case 21: /* Line 1455 of yacc.c */ #line 767 "hphp.y" { _p->nns(); _p->finishStatement((yyval), (yyvsp[(1) - (2)])); (yyval) = 1;;} break; case 22: /* Line 1455 of yacc.c */ #line 772 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 23: /* Line 1455 of yacc.c */ #line 773 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 24: /* Line 1455 of yacc.c */ #line 774 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 25: /* Line 1455 of yacc.c */ #line 775 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 26: /* Line 1455 of yacc.c */ #line 776 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 27: /* Line 1455 of yacc.c */ #line 777 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 28: /* Line 1455 of yacc.c */ #line 778 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 29: /* Line 1455 of yacc.c */ #line 779 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 30: /* Line 1455 of yacc.c */ #line 780 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 31: /* Line 1455 of yacc.c */ #line 781 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 32: /* Line 1455 of yacc.c */ #line 782 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 33: /* Line 1455 of yacc.c */ #line 783 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 34: /* Line 1455 of yacc.c */ #line 784 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 35: /* Line 1455 of yacc.c */ #line 785 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 36: /* Line 1455 of yacc.c */ #line 786 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 37: /* Line 1455 of yacc.c */ #line 787 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 38: /* Line 1455 of yacc.c */ #line 788 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 39: /* Line 1455 of yacc.c */ #line 789 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 40: /* Line 1455 of yacc.c */ #line 790 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 41: /* Line 1455 of yacc.c */ #line 795 "hphp.y" { ;} break; case 42: /* Line 1455 of yacc.c */ #line 796 "hphp.y" { ;} break; case 43: /* Line 1455 of yacc.c */ #line 801 "hphp.y" { ;} break; case 44: /* Line 1455 of yacc.c */ #line 802 "hphp.y" { ;} break; case 45: /* Line 1455 of yacc.c */ #line 807 "hphp.y" { ;} break; case 46: /* Line 1455 of yacc.c */ #line 808 "hphp.y" { ;} break; case 47: /* Line 1455 of yacc.c */ #line 812 "hphp.y" { _p->onUse((yyvsp[(1) - (1)]).text(),"");;} break; case 48: /* Line 1455 of yacc.c */ #line 813 "hphp.y" { _p->onUse((yyvsp[(2) - (2)]).text(),"");;} break; case 49: /* Line 1455 of yacc.c */ #line 814 "hphp.y" { _p->onUse((yyvsp[(1) - (3)]).text(),(yyvsp[(3) - (3)]).text());;} break; case 50: /* Line 1455 of yacc.c */ #line 816 "hphp.y" { _p->onUse((yyvsp[(2) - (4)]).text(),(yyvsp[(4) - (4)]).text());;} break; case 51: /* Line 1455 of yacc.c */ #line 820 "hphp.y" { _p->onUseFunction((yyvsp[(1) - (1)]).text(),"");;} break; case 52: /* Line 1455 of yacc.c */ #line 821 "hphp.y" { _p->onUseFunction((yyvsp[(2) - (2)]).text(),"");;} break; case 53: /* Line 1455 of yacc.c */ #line 822 "hphp.y" { _p->onUseFunction((yyvsp[(1) - (3)]).text(),(yyvsp[(3) - (3)]).text());;} break; case 54: /* Line 1455 of yacc.c */ #line 824 "hphp.y" { _p->onUseFunction((yyvsp[(2) - (4)]).text(),(yyvsp[(4) - (4)]).text());;} break; case 55: /* Line 1455 of yacc.c */ #line 828 "hphp.y" { _p->onUseConst((yyvsp[(1) - (1)]).text(),"");;} break; case 56: /* Line 1455 of yacc.c */ #line 829 "hphp.y" { _p->onUseConst((yyvsp[(2) - (2)]).text(),"");;} break; case 57: /* Line 1455 of yacc.c */ #line 830 "hphp.y" { _p->onUseConst((yyvsp[(1) - (3)]).text(),(yyvsp[(3) - (3)]).text());;} break; case 58: /* Line 1455 of yacc.c */ #line 832 "hphp.y" { _p->onUseConst((yyvsp[(2) - (4)]).text(),(yyvsp[(4) - (4)]).text());;} break; case 59: /* Line 1455 of yacc.c */ #line 836 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 60: /* Line 1455 of yacc.c */ #line 838 "hphp.y" { (yyval) = (yyvsp[(1) - (3)]) + (yyvsp[(2) - (3)]) + (yyvsp[(3) - (3)]); (yyval) = (yyvsp[(1) - (3)]).num() | 2;;} break; case 61: /* Line 1455 of yacc.c */ #line 841 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]); (yyval) = (yyval).num() | 1;;} break; case 62: /* Line 1455 of yacc.c */ #line 843 "hphp.y" { (yyval).set((yyvsp[(3) - (3)]).num() | 2, _p->nsDecl((yyvsp[(3) - (3)]).text()));;} break; case 63: /* Line 1455 of yacc.c */ #line 844 "hphp.y" { (yyval) = (yyvsp[(2) - (2)]); (yyval) = (yyval).num() | 2;;} break; case 64: /* Line 1455 of yacc.c */ #line 847 "hphp.y" { if ((yyvsp[(1) - (1)]).num() & 1) { (yyvsp[(1) - (1)]).setText(_p->resolve((yyvsp[(1) - (1)]).text(),0)); } (yyval) = (yyvsp[(1) - (1)]);;} break; case 65: /* Line 1455 of yacc.c */ #line 854 "hphp.y" { if ((yyvsp[(1) - (2)]).num() & 1) { (yyvsp[(1) - (2)]).setText(_p->resolve((yyvsp[(1) - (2)]).text(),0)); } (yyval) = (yyvsp[(1) - (2)]);;} break; case 66: /* Line 1455 of yacc.c */ #line 861 "hphp.y" { if ((yyvsp[(1) - (2)]).num() & 1) { (yyvsp[(1) - (2)]).setText(_p->resolve((yyvsp[(1) - (2)]).text(),1)); } _p->onTypeAnnotation((yyval), (yyvsp[(1) - (2)]), (yyvsp[(2) - (2)]));;} break; case 67: /* Line 1455 of yacc.c */ #line 869 "hphp.y" { (yyvsp[(3) - (5)]).setText(_p->nsDecl((yyvsp[(3) - (5)]).text())); _p->onConst((yyval),(yyvsp[(3) - (5)]),(yyvsp[(5) - (5)]));;} break; case 68: /* Line 1455 of yacc.c */ #line 872 "hphp.y" { (yyvsp[(2) - (4)]).setText(_p->nsDecl((yyvsp[(2) - (4)]).text())); _p->onConst((yyval),(yyvsp[(2) - (4)]),(yyvsp[(4) - (4)]));;} break; case 69: /* Line 1455 of yacc.c */ #line 878 "hphp.y" { _p->addStatement((yyval),(yyvsp[(1) - (2)]),(yyvsp[(2) - (2)]));;} break; case 70: /* Line 1455 of yacc.c */ #line 879 "hphp.y" { _p->onStatementListStart((yyval));;} break; case 71: /* Line 1455 of yacc.c */ #line 882 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 72: /* Line 1455 of yacc.c */ #line 883 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 73: /* Line 1455 of yacc.c */ #line 884 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 74: /* Line 1455 of yacc.c */ #line 885 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 75: /* Line 1455 of yacc.c */ #line 888 "hphp.y" { _p->onBlock((yyval), (yyvsp[(2) - (3)]));;} break; case 76: /* Line 1455 of yacc.c */ #line 892 "hphp.y" { _p->onIf((yyval),(yyvsp[(2) - (5)]),(yyvsp[(3) - (5)]),(yyvsp[(4) - (5)]),(yyvsp[(5) - (5)]));;} break; case 77: /* Line 1455 of yacc.c */ #line 897 "hphp.y" { _p->onIf((yyval),(yyvsp[(2) - (8)]),(yyvsp[(4) - (8)]),(yyvsp[(5) - (8)]),(yyvsp[(6) - (8)]));;} break; case 78: /* Line 1455 of yacc.c */ #line 898 "hphp.y" { _p->onNewLabelScope(false); _p->pushLabelScope();;} break; case 79: /* Line 1455 of yacc.c */ #line 900 "hphp.y" { _p->popLabelScope(); _p->onWhile((yyval),(yyvsp[(2) - (4)]),(yyvsp[(4) - (4)])); _p->onCompleteLabelScope(false);;} break; case 80: /* Line 1455 of yacc.c */ #line 904 "hphp.y" { _p->onNewLabelScope(false); _p->pushLabelScope();;} break; case 81: /* Line 1455 of yacc.c */ #line 907 "hphp.y" { _p->popLabelScope(); _p->onDo((yyval),(yyvsp[(3) - (6)]),(yyvsp[(5) - (6)])); _p->onCompleteLabelScope(false);;} break; case 82: /* Line 1455 of yacc.c */ #line 911 "hphp.y" { _p->onNewLabelScope(false); _p->pushLabelScope();;} break; case 83: /* Line 1455 of yacc.c */ #line 913 "hphp.y" { _p->popLabelScope(); _p->onFor((yyval),(yyvsp[(3) - (10)]),(yyvsp[(5) - (10)]),(yyvsp[(7) - (10)]),(yyvsp[(10) - (10)])); _p->onCompleteLabelScope(false);;} break; case 84: /* Line 1455 of yacc.c */ #line 916 "hphp.y" { _p->onNewLabelScope(false); _p->pushLabelScope();;} break; case 85: /* Line 1455 of yacc.c */ #line 918 "hphp.y" { _p->popLabelScope(); _p->onSwitch((yyval),(yyvsp[(2) - (4)]),(yyvsp[(4) - (4)])); _p->onCompleteLabelScope(false);;} break; case 86: /* Line 1455 of yacc.c */ #line 921 "hphp.y" { _p->onBreakContinue((yyval), true, NULL);;} break; case 87: /* Line 1455 of yacc.c */ #line 922 "hphp.y" { _p->onBreakContinue((yyval), true, &(yyvsp[(2) - (3)]));;} break; case 88: /* Line 1455 of yacc.c */ #line 923 "hphp.y" { _p->onBreakContinue((yyval), false, NULL);;} break; case 89: /* Line 1455 of yacc.c */ #line 924 "hphp.y" { _p->onBreakContinue((yyval), false, &(yyvsp[(2) - (3)]));;} break; case 90: /* Line 1455 of yacc.c */ #line 925 "hphp.y" { _p->onReturn((yyval), NULL);;} break; case 91: /* Line 1455 of yacc.c */ #line 926 "hphp.y" { _p->onReturn((yyval), &(yyvsp[(2) - (3)]));;} break; case 92: /* Line 1455 of yacc.c */ #line 927 "hphp.y" { _p->onYieldBreak((yyval));;} break; case 93: /* Line 1455 of yacc.c */ #line 928 "hphp.y" { _p->onGlobal((yyval), (yyvsp[(2) - (3)]));;} break; case 94: /* Line 1455 of yacc.c */ #line 929 "hphp.y" { _p->onStatic((yyval), (yyvsp[(2) - (3)]));;} break; case 95: /* Line 1455 of yacc.c */ #line 930 "hphp.y" { _p->onEcho((yyval), (yyvsp[(2) - (3)]), 0);;} break; case 96: /* Line 1455 of yacc.c */ #line 931 "hphp.y" { _p->onUnset((yyval), (yyvsp[(3) - (5)]));;} break; case 97: /* Line 1455 of yacc.c */ #line 932 "hphp.y" { (yyval).reset(); (yyval) = ';';;} break; case 98: /* Line 1455 of yacc.c */ #line 933 "hphp.y" { _p->onEcho((yyval), (yyvsp[(1) - (1)]), 1);;} break; case 99: /* Line 1455 of yacc.c */ #line 936 "hphp.y" { _p->onNewLabelScope(false); _p->pushLabelScope();;} break; case 100: /* Line 1455 of yacc.c */ #line 938 "hphp.y" { _p->popLabelScope(); _p->onForEach((yyval),(yyvsp[(3) - (9)]),(yyvsp[(5) - (9)]),(yyvsp[(6) - (9)]),(yyvsp[(9) - (9)]), false); _p->onCompleteLabelScope(false);;} break; case 101: /* Line 1455 of yacc.c */ #line 943 "hphp.y" { _p->onNewLabelScope(false); _p->pushLabelScope();;} break; case 102: /* Line 1455 of yacc.c */ #line 945 "hphp.y" { _p->popLabelScope(); _p->onForEach((yyval),(yyvsp[(3) - (10)]),(yyvsp[(6) - (10)]),(yyvsp[(7) - (10)]),(yyvsp[(10) - (10)]), true); _p->onCompleteLabelScope(false);;} break; case 103: /* Line 1455 of yacc.c */ #line 949 "hphp.y" { _p->onBlock((yyval), (yyvsp[(5) - (5)])); (yyval) = T_DECLARE;;} break; case 104: /* Line 1455 of yacc.c */ #line 956 "hphp.y" { _p->onCompleteLabelScope(false);;} break; case 105: /* Line 1455 of yacc.c */ #line 957 "hphp.y" { _p->onTry((yyval),(yyvsp[(2) - (13)]),(yyvsp[(5) - (13)]),(yyvsp[(6) - (13)]),(yyvsp[(9) - (13)]),(yyvsp[(11) - (13)]),(yyvsp[(13) - (13)]));;} break; case 106: /* Line 1455 of yacc.c */ #line 960 "hphp.y" { _p->onCompleteLabelScope(false);;} break; case 107: /* Line 1455 of yacc.c */ #line 961 "hphp.y" { _p->onTry((yyval), (yyvsp[(2) - (5)]), (yyvsp[(5) - (5)]));;} break; case 108: /* Line 1455 of yacc.c */ #line 962 "hphp.y" { _p->onThrow((yyval), (yyvsp[(2) - (3)]));;} break; case 109: /* Line 1455 of yacc.c */ #line 963 "hphp.y" { _p->onGoto((yyval), (yyvsp[(2) - (3)]), true); _p->addGoto((yyvsp[(2) - (3)]).text(), _p->getLocation(), &(yyval));;} break; case 110: /* Line 1455 of yacc.c */ #line 967 "hphp.y" { _p->onExpStatement((yyval), (yyvsp[(1) - (2)]));;} break; case 111: /* Line 1455 of yacc.c */ #line 968 "hphp.y" { _p->onExpStatement((yyval), (yyvsp[(1) - (2)]));;} break; case 112: /* Line 1455 of yacc.c */ #line 969 "hphp.y" { _p->onExpStatement((yyval), (yyvsp[(1) - (2)]));;} break; case 113: /* Line 1455 of yacc.c */ #line 970 "hphp.y" { _p->onExpStatement((yyval), (yyvsp[(1) - (2)]));;} break; case 114: /* Line 1455 of yacc.c */ #line 971 "hphp.y" { _p->onExpStatement((yyval), (yyvsp[(1) - (2)]));;} break; case 115: /* Line 1455 of yacc.c */ #line 972 "hphp.y" { _p->onExpStatement((yyval), (yyvsp[(1) - (2)]));;} break; case 116: /* Line 1455 of yacc.c */ #line 973 "hphp.y" { _p->onReturn((yyval), &(yyvsp[(2) - (3)])); ;} break; case 117: /* Line 1455 of yacc.c */ #line 974 "hphp.y" { _p->onExpStatement((yyval), (yyvsp[(1) - (2)]));;} break; case 118: /* Line 1455 of yacc.c */ #line 975 "hphp.y" { _p->onExpStatement((yyval), (yyvsp[(1) - (2)]));;} break; case 119: /* Line 1455 of yacc.c */ #line 976 "hphp.y" { _p->onReturn((yyval), &(yyvsp[(2) - (3)])); ;} break; case 120: /* Line 1455 of yacc.c */ #line 977 "hphp.y" { _p->onLabel((yyval), (yyvsp[(1) - (2)])); _p->addLabel((yyvsp[(1) - (2)]).text(), _p->getLocation(), &(yyval)); _p->onScopeLabel((yyval), (yyvsp[(1) - (2)]));;} break; case 121: /* Line 1455 of yacc.c */ #line 985 "hphp.y" { _p->onNewLabelScope(false);;} break; case 122: /* Line 1455 of yacc.c */ #line 986 "hphp.y" { (yyval) = (yyvsp[(3) - (4)]);;} break; case 123: /* Line 1455 of yacc.c */ #line 995 "hphp.y" { _p->onCatch((yyval), (yyvsp[(1) - (9)]), (yyvsp[(4) - (9)]), (yyvsp[(5) - (9)]), (yyvsp[(8) - (9)]));;} break; case 124: /* Line 1455 of yacc.c */ #line 996 "hphp.y" { (yyval).reset();;} break; case 125: /* Line 1455 of yacc.c */ #line 1000 "hphp.y" { _p->onNewLabelScope(false); _p->pushLabelScope();;} break; case 126: /* Line 1455 of yacc.c */ #line 1002 "hphp.y" { _p->popLabelScope(); _p->onFinally((yyval), (yyvsp[(3) - (4)])); _p->onCompleteLabelScope(false);;} break; case 127: /* Line 1455 of yacc.c */ #line 1008 "hphp.y" { (yyval) = (yyvsp[(2) - (2)]);;} break; case 128: /* Line 1455 of yacc.c */ #line 1009 "hphp.y" { (yyval).reset();;} break; case 129: /* Line 1455 of yacc.c */ #line 1013 "hphp.y" { (yyval) = 1;;} break; case 130: /* Line 1455 of yacc.c */ #line 1014 "hphp.y" { (yyval).reset();;} break; case 131: /* Line 1455 of yacc.c */ #line 1018 "hphp.y" { _p->pushFuncLocation(); ;} break; case 132: /* Line 1455 of yacc.c */ #line 1023 "hphp.y" { (yyvsp[(3) - (3)]).setText(_p->nsDecl((yyvsp[(3) - (3)]).text())); _p->onNewLabelScope(true); _p->onFunctionStart((yyvsp[(3) - (3)])); _p->pushLabelInfo();;} break; case 133: /* Line 1455 of yacc.c */ #line 1029 "hphp.y" { _p->onFunction((yyval),nullptr,(yyvsp[(8) - (9)]),(yyvsp[(2) - (9)]),(yyvsp[(3) - (9)]),(yyvsp[(6) - (9)]),(yyvsp[(9) - (9)]),nullptr); _p->popLabelInfo(); _p->popTypeScope(); _p->onCompleteLabelScope(true);;} break; case 134: /* Line 1455 of yacc.c */ #line 1035 "hphp.y" { (yyvsp[(4) - (4)]).setText(_p->nsDecl((yyvsp[(4) - (4)]).text())); _p->onNewLabelScope(true); _p->onFunctionStart((yyvsp[(4) - (4)])); _p->pushLabelInfo();;} break; case 135: /* Line 1455 of yacc.c */ #line 1041 "hphp.y" { _p->onFunction((yyval),&(yyvsp[(1) - (10)]),(yyvsp[(9) - (10)]),(yyvsp[(3) - (10)]),(yyvsp[(4) - (10)]),(yyvsp[(7) - (10)]),(yyvsp[(10) - (10)]),nullptr); _p->popLabelInfo(); _p->popTypeScope(); _p->onCompleteLabelScope(true);;} break; case 136: /* Line 1455 of yacc.c */ #line 1047 "hphp.y" { (yyvsp[(5) - (5)]).setText(_p->nsDecl((yyvsp[(5) - (5)]).text())); _p->onNewLabelScope(true); _p->onFunctionStart((yyvsp[(5) - (5)])); _p->pushLabelInfo();;} break; case 137: /* Line 1455 of yacc.c */ #line 1053 "hphp.y" { _p->onFunction((yyval),&(yyvsp[(2) - (11)]),(yyvsp[(10) - (11)]),(yyvsp[(4) - (11)]),(yyvsp[(5) - (11)]),(yyvsp[(8) - (11)]),(yyvsp[(11) - (11)]),&(yyvsp[(1) - (11)])); _p->popLabelInfo(); _p->popTypeScope(); _p->onCompleteLabelScope(true);;} break; case 138: /* Line 1455 of yacc.c */ #line 1061 "hphp.y" { (yyvsp[(2) - (2)]).setText(_p->nsDecl((yyvsp[(2) - (2)]).text())); _p->onClassStart(T_ENUM,(yyvsp[(2) - (2)]));;} break; case 139: /* Line 1455 of yacc.c */ #line 1065 "hphp.y" { _p->onEnum((yyval),(yyvsp[(2) - (9)]),(yyvsp[(5) - (9)]),(yyvsp[(8) - (9)]),0); ;} break; case 140: /* Line 1455 of yacc.c */ #line 1069 "hphp.y" { (yyvsp[(3) - (3)]).setText(_p->nsDecl((yyvsp[(3) - (3)]).text())); _p->onClassStart(T_ENUM,(yyvsp[(3) - (3)]));;} break; case 141: /* Line 1455 of yacc.c */ #line 1073 "hphp.y" { _p->onEnum((yyval),(yyvsp[(3) - (10)]),(yyvsp[(6) - (10)]),(yyvsp[(9) - (10)]),&(yyvsp[(1) - (10)])); ;} break; case 142: /* Line 1455 of yacc.c */ #line 1079 "hphp.y" { (yyvsp[(2) - (2)]).setText(_p->nsDecl((yyvsp[(2) - (2)]).text())); _p->onClassStart((yyvsp[(1) - (2)]).num(),(yyvsp[(2) - (2)]));;} break; case 143: /* Line 1455 of yacc.c */ #line 1082 "hphp.y" { Token stmts; if (_p->peekClass()) { xhp_collect_attributes(_p,stmts,(yyvsp[(7) - (8)])); } else { stmts = (yyvsp[(7) - (8)]); } _p->onClass((yyval),(yyvsp[(1) - (8)]).num(),(yyvsp[(2) - (8)]),(yyvsp[(4) - (8)]),(yyvsp[(5) - (8)]), stmts,0,nullptr); if (_p->peekClass()) { _p->xhpResetAttributes(); } _p->popClass(); _p->popTypeScope();;} break; case 144: /* Line 1455 of yacc.c */ #line 1097 "hphp.y" { (yyvsp[(3) - (3)]).setText(_p->nsDecl((yyvsp[(3) - (3)]).text())); _p->onClassStart((yyvsp[(2) - (3)]).num(),(yyvsp[(3) - (3)]));;} break; case 145: /* Line 1455 of yacc.c */ #line 1100 "hphp.y" { Token stmts; if (_p->peekClass()) { xhp_collect_attributes(_p,stmts,(yyvsp[(8) - (9)])); } else { stmts = (yyvsp[(8) - (9)]); } _p->onClass((yyval),(yyvsp[(2) - (9)]).num(),(yyvsp[(3) - (9)]),(yyvsp[(5) - (9)]),(yyvsp[(6) - (9)]), stmts,&(yyvsp[(1) - (9)]),nullptr); if (_p->peekClass()) { _p->xhpResetAttributes(); } _p->popClass(); _p->popTypeScope();;} break; case 146: /* Line 1455 of yacc.c */ #line 1114 "hphp.y" { (yyvsp[(2) - (2)]).setText(_p->nsDecl((yyvsp[(2) - (2)]).text())); _p->onClassStart(T_INTERFACE,(yyvsp[(2) - (2)]));;} break; case 147: /* Line 1455 of yacc.c */ #line 1117 "hphp.y" { _p->onInterface((yyval),(yyvsp[(2) - (7)]),(yyvsp[(4) - (7)]),(yyvsp[(6) - (7)]),0); _p->popClass(); _p->popTypeScope();;} break; case 148: /* Line 1455 of yacc.c */ #line 1122 "hphp.y" { (yyvsp[(3) - (3)]).setText(_p->nsDecl((yyvsp[(3) - (3)]).text())); _p->onClassStart(T_INTERFACE,(yyvsp[(3) - (3)]));;} break; case 149: /* Line 1455 of yacc.c */ #line 1125 "hphp.y" { _p->onInterface((yyval),(yyvsp[(3) - (8)]),(yyvsp[(5) - (8)]),(yyvsp[(7) - (8)]),&(yyvsp[(1) - (8)])); _p->popClass(); _p->popTypeScope();;} break; case 150: /* Line 1455 of yacc.c */ #line 1132 "hphp.y" { (yyvsp[(2) - (2)]).setText(_p->nsDecl((yyvsp[(2) - (2)]).text())); _p->onClassStart(T_TRAIT, (yyvsp[(2) - (2)]));;} break; case 151: /* Line 1455 of yacc.c */ #line 1135 "hphp.y" { Token t_ext; t_ext.reset(); _p->onClass((yyval),T_TRAIT,(yyvsp[(2) - (7)]),t_ext,(yyvsp[(4) - (7)]), (yyvsp[(6) - (7)]), 0, nullptr); _p->popClass(); _p->popTypeScope();;} break; case 152: /* Line 1455 of yacc.c */ #line 1143 "hphp.y" { (yyvsp[(3) - (3)]).setText(_p->nsDecl((yyvsp[(3) - (3)]).text())); _p->onClassStart(T_TRAIT, (yyvsp[(3) - (3)]));;} break; case 153: /* Line 1455 of yacc.c */ #line 1146 "hphp.y" { Token t_ext; t_ext.reset(); _p->onClass((yyval),T_TRAIT,(yyvsp[(3) - (8)]),t_ext,(yyvsp[(5) - (8)]), (yyvsp[(7) - (8)]), &(yyvsp[(1) - (8)]), nullptr); _p->popClass(); _p->popTypeScope();;} break; case 154: /* Line 1455 of yacc.c */ #line 1154 "hphp.y" { _p->pushClass(false); (yyval) = (yyvsp[(1) - (1)]);;} break; case 155: /* Line 1455 of yacc.c */ #line 1155 "hphp.y" { (yyvsp[(1) - (1)]).xhpLabel(); _p->pushTypeScope(); _p->pushClass(true); (yyval) = (yyvsp[(1) - (1)]);;} break; case 156: /* Line 1455 of yacc.c */ #line 1159 "hphp.y" { _p->pushClass(false); (yyval) = (yyvsp[(1) - (1)]);;} break; case 157: /* Line 1455 of yacc.c */ #line 1162 "hphp.y" { _p->pushClass(false); (yyval) = (yyvsp[(1) - (1)]);;} break; case 158: /* Line 1455 of yacc.c */ #line 1165 "hphp.y" { (yyval) = T_CLASS;;} break; case 159: /* Line 1455 of yacc.c */ #line 1166 "hphp.y" { (yyval) = T_ABSTRACT;;} break; case 160: /* Line 1455 of yacc.c */ #line 1167 "hphp.y" { (yyval) = T_FINAL;;} break; case 161: /* Line 1455 of yacc.c */ #line 1171 "hphp.y" { (yyval) = (yyvsp[(2) - (2)]);;} break; case 162: /* Line 1455 of yacc.c */ #line 1172 "hphp.y" { (yyval).reset();;} break; case 163: /* Line 1455 of yacc.c */ #line 1175 "hphp.y" { (yyval) = (yyvsp[(2) - (2)]);;} break; case 164: /* Line 1455 of yacc.c */ #line 1176 "hphp.y" { (yyval).reset();;} break; case 165: /* Line 1455 of yacc.c */ #line 1179 "hphp.y" { (yyval) = (yyvsp[(2) - (2)]);;} break; case 166: /* Line 1455 of yacc.c */ #line 1180 "hphp.y" { (yyval).reset();;} break; case 167: /* Line 1455 of yacc.c */ #line 1183 "hphp.y" { _p->onInterfaceName((yyval), NULL, (yyvsp[(1) - (1)]));;} break; case 168: /* Line 1455 of yacc.c */ #line 1185 "hphp.y" { _p->onInterfaceName((yyval), &(yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]));;} break; case 169: /* Line 1455 of yacc.c */ #line 1188 "hphp.y" { _p->onTraitName((yyval), NULL, (yyvsp[(1) - (1)]));;} break; case 170: /* Line 1455 of yacc.c */ #line 1190 "hphp.y" { _p->onTraitName((yyval), &(yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]));;} break; case 171: /* Line 1455 of yacc.c */ #line 1194 "hphp.y" { (yyval) = (yyvsp[(2) - (2)]);;} break; case 172: /* Line 1455 of yacc.c */ #line 1195 "hphp.y" { (yyval).reset();;} break; case 173: /* Line 1455 of yacc.c */ #line 1198 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 174: /* Line 1455 of yacc.c */ #line 1199 "hphp.y" { (yyval) = (yyvsp[(2) - (2)]); (yyval) = 1;;} break; case 175: /* Line 1455 of yacc.c */ #line 1200 "hphp.y" { _p->onListAssignment((yyval), (yyvsp[(3) - (4)]), NULL);;} break; case 176: /* Line 1455 of yacc.c */ #line 1204 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 177: /* Line 1455 of yacc.c */ #line 1206 "hphp.y" { (yyval) = (yyvsp[(2) - (4)]);;} break; case 178: /* Line 1455 of yacc.c */ #line 1209 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 179: /* Line 1455 of yacc.c */ #line 1211 "hphp.y" { (yyval) = (yyvsp[(2) - (4)]);;} break; case 180: /* Line 1455 of yacc.c */ #line 1214 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 181: /* Line 1455 of yacc.c */ #line 1216 "hphp.y" { (yyval) = (yyvsp[(2) - (4)]);;} break; case 182: /* Line 1455 of yacc.c */ #line 1219 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 183: /* Line 1455 of yacc.c */ #line 1221 "hphp.y" { (yyval) = (yyvsp[(2) - (4)]);;} break; case 186: /* Line 1455 of yacc.c */ #line 1231 "hphp.y" { (yyval) = (yyvsp[(2) - (3)]);;} break; case 187: /* Line 1455 of yacc.c */ #line 1232 "hphp.y" { (yyval) = (yyvsp[(3) - (4)]);;} break; case 188: /* Line 1455 of yacc.c */ #line 1233 "hphp.y" { (yyval) = (yyvsp[(2) - (4)]);;} break; case 189: /* Line 1455 of yacc.c */ #line 1234 "hphp.y" { (yyval) = (yyvsp[(3) - (5)]);;} break; case 190: /* Line 1455 of yacc.c */ #line 1239 "hphp.y" { _p->onCase((yyval),(yyvsp[(1) - (5)]),&(yyvsp[(3) - (5)]),(yyvsp[(5) - (5)]));;} break; case 191: /* Line 1455 of yacc.c */ #line 1241 "hphp.y" { _p->onCase((yyval),(yyvsp[(1) - (4)]),NULL,(yyvsp[(4) - (4)]));;} break; case 192: /* Line 1455 of yacc.c */ #line 1242 "hphp.y" { (yyval).reset();;} break; case 193: /* Line 1455 of yacc.c */ #line 1245 "hphp.y" { (yyval).reset();;} break; case 194: /* Line 1455 of yacc.c */ #line 1246 "hphp.y" { (yyval).reset();;} break; case 195: /* Line 1455 of yacc.c */ #line 1251 "hphp.y" { _p->onElseIf((yyval),(yyvsp[(1) - (4)]),(yyvsp[(3) - (4)]),(yyvsp[(4) - (4)]));;} break; case 196: /* Line 1455 of yacc.c */ #line 1252 "hphp.y" { (yyval).reset();;} break; case 197: /* Line 1455 of yacc.c */ #line 1257 "hphp.y" { _p->onElseIf((yyval),(yyvsp[(1) - (5)]),(yyvsp[(3) - (5)]),(yyvsp[(5) - (5)]));;} break; case 198: /* Line 1455 of yacc.c */ #line 1258 "hphp.y" { (yyval).reset();;} break; case 199: /* Line 1455 of yacc.c */ #line 1261 "hphp.y" { (yyval) = (yyvsp[(2) - (2)]);;} break; case 200: /* Line 1455 of yacc.c */ #line 1262 "hphp.y" { (yyval).reset();;} break; case 201: /* Line 1455 of yacc.c */ #line 1265 "hphp.y" { (yyval) = (yyvsp[(3) - (3)]);;} break; case 202: /* Line 1455 of yacc.c */ #line 1266 "hphp.y" { (yyval).reset();;} break; case 203: /* Line 1455 of yacc.c */ #line 1274 "hphp.y" { _p->onVariadicParam((yyval),&(yyvsp[(1) - (7)]),(yyvsp[(5) - (7)]),(yyvsp[(7) - (7)]),false, &(yyvsp[(3) - (7)]),&(yyvsp[(4) - (7)])); ;} break; case 204: /* Line 1455 of yacc.c */ #line 1280 "hphp.y" { validate_hh_variadic_variant( _p, (yyvsp[(3) - (6)]), (yyvsp[(5) - (6)]), &(yyvsp[(4) - (6)])); (yyval) = (yyvsp[(1) - (6)]); ;} break; case 205: /* Line 1455 of yacc.c */ #line 1284 "hphp.y" { (yyval) = (yyvsp[(1) - (2)]);;} break; case 206: /* Line 1455 of yacc.c */ #line 1288 "hphp.y" { _p->onVariadicParam((yyval),NULL,(yyvsp[(3) - (5)]),(yyvsp[(5) - (5)]),false, &(yyvsp[(1) - (5)]),&(yyvsp[(2) - (5)])); ;} break; case 207: /* Line 1455 of yacc.c */ #line 1293 "hphp.y" { validate_hh_variadic_variant( _p, (yyvsp[(1) - (4)]), (yyvsp[(3) - (4)]), &(yyvsp[(2) - (4)])); (yyval).reset(); ;} break; case 208: /* Line 1455 of yacc.c */ #line 1296 "hphp.y" { (yyval).reset(); ;} break; case 209: /* Line 1455 of yacc.c */ #line 1302 "hphp.y" { _p->onParam((yyval),NULL,(yyvsp[(3) - (4)]),(yyvsp[(4) - (4)]),0, NULL,&(yyvsp[(1) - (4)]),&(yyvsp[(2) - (4)]));;} break; case 210: /* Line 1455 of yacc.c */ #line 1306 "hphp.y" { _p->onParam((yyval),NULL,(yyvsp[(3) - (5)]),(yyvsp[(5) - (5)]),1, NULL,&(yyvsp[(1) - (5)]),&(yyvsp[(2) - (5)]));;} break; case 211: /* Line 1455 of yacc.c */ #line 1311 "hphp.y" { _p->onParam((yyval),NULL,(yyvsp[(3) - (7)]),(yyvsp[(5) - (7)]),1, &(yyvsp[(7) - (7)]),&(yyvsp[(1) - (7)]),&(yyvsp[(2) - (7)]));;} break; case 212: /* Line 1455 of yacc.c */ #line 1316 "hphp.y" { _p->onParam((yyval),NULL,(yyvsp[(3) - (6)]),(yyvsp[(4) - (6)]),0, &(yyvsp[(6) - (6)]),&(yyvsp[(1) - (6)]),&(yyvsp[(2) - (6)]));;} break; case 213: /* Line 1455 of yacc.c */ #line 1321 "hphp.y" { _p->onParam((yyval),&(yyvsp[(1) - (6)]),(yyvsp[(5) - (6)]),(yyvsp[(6) - (6)]),0, NULL,&(yyvsp[(3) - (6)]),&(yyvsp[(4) - (6)]));;} break; case 214: /* Line 1455 of yacc.c */ #line 1326 "hphp.y" { _p->onParam((yyval),&(yyvsp[(1) - (7)]),(yyvsp[(5) - (7)]),(yyvsp[(7) - (7)]),1, NULL,&(yyvsp[(3) - (7)]),&(yyvsp[(4) - (7)]));;} break; case 215: /* Line 1455 of yacc.c */ #line 1332 "hphp.y" { _p->onParam((yyval),&(yyvsp[(1) - (9)]),(yyvsp[(5) - (9)]),(yyvsp[(7) - (9)]),1, &(yyvsp[(9) - (9)]),&(yyvsp[(3) - (9)]),&(yyvsp[(4) - (9)]));;} break; case 216: /* Line 1455 of yacc.c */ #line 1338 "hphp.y" { _p->onParam((yyval),&(yyvsp[(1) - (8)]),(yyvsp[(5) - (8)]),(yyvsp[(6) - (8)]),0, &(yyvsp[(8) - (8)]),&(yyvsp[(3) - (8)]),&(yyvsp[(4) - (8)]));;} break; case 217: /* Line 1455 of yacc.c */ #line 1346 "hphp.y" { _p->onVariadicParam((yyval),&(yyvsp[(1) - (6)]),(yyvsp[(4) - (6)]),(yyvsp[(6) - (6)]), false,&(yyvsp[(3) - (6)]),NULL); ;} break; case 218: /* Line 1455 of yacc.c */ #line 1351 "hphp.y" { validate_hh_variadic_variant( _p, (yyvsp[(3) - (5)]), (yyvsp[(4) - (5)]), NULL); (yyval) = (yyvsp[(1) - (5)]); ;} break; case 219: /* Line 1455 of yacc.c */ #line 1355 "hphp.y" { (yyval) = (yyvsp[(1) - (2)]);;} break; case 220: /* Line 1455 of yacc.c */ #line 1358 "hphp.y" { _p->onVariadicParam((yyval),NULL,(yyvsp[(2) - (4)]),(yyvsp[(4) - (4)]), false,&(yyvsp[(1) - (4)]),NULL); ;} break; case 221: /* Line 1455 of yacc.c */ #line 1362 "hphp.y" { validate_hh_variadic_variant( _p, (yyvsp[(1) - (3)]), (yyvsp[(2) - (3)]), NULL); (yyval).reset(); ;} break; case 222: /* Line 1455 of yacc.c */ #line 1365 "hphp.y" { (yyval).reset();;} break; case 223: /* Line 1455 of yacc.c */ #line 1370 "hphp.y" { _p->onParam((yyval),NULL,(yyvsp[(2) - (3)]),(yyvsp[(3) - (3)]),false, NULL,&(yyvsp[(1) - (3)]),NULL); ;} break; case 224: /* Line 1455 of yacc.c */ #line 1373 "hphp.y" { _p->onParam((yyval),NULL,(yyvsp[(2) - (4)]),(yyvsp[(4) - (4)]),true, NULL,&(yyvsp[(1) - (4)]),NULL); ;} break; case 225: /* Line 1455 of yacc.c */ #line 1377 "hphp.y" { _p->onParam((yyval),NULL,(yyvsp[(2) - (6)]),(yyvsp[(4) - (6)]),true, &(yyvsp[(6) - (6)]),&(yyvsp[(1) - (6)]),NULL); ;} break; case 226: /* Line 1455 of yacc.c */ #line 1381 "hphp.y" { _p->onParam((yyval),NULL,(yyvsp[(2) - (5)]),(yyvsp[(3) - (5)]),false, &(yyvsp[(5) - (5)]),&(yyvsp[(1) - (5)]),NULL); ;} break; case 227: /* Line 1455 of yacc.c */ #line 1385 "hphp.y" { _p->onParam((yyval),&(yyvsp[(1) - (5)]),(yyvsp[(4) - (5)]),(yyvsp[(5) - (5)]),false, NULL,&(yyvsp[(3) - (5)]),NULL); ;} break; case 228: /* Line 1455 of yacc.c */ #line 1389 "hphp.y" { _p->onParam((yyval),&(yyvsp[(1) - (6)]),(yyvsp[(4) - (6)]),(yyvsp[(6) - (6)]),true, NULL,&(yyvsp[(3) - (6)]),NULL); ;} break; case 229: /* Line 1455 of yacc.c */ #line 1394 "hphp.y" { _p->onParam((yyval),&(yyvsp[(1) - (8)]),(yyvsp[(4) - (8)]),(yyvsp[(6) - (8)]),true, &(yyvsp[(8) - (8)]),&(yyvsp[(3) - (8)]),NULL); ;} break; case 230: /* Line 1455 of yacc.c */ #line 1399 "hphp.y" { _p->onParam((yyval),&(yyvsp[(1) - (7)]),(yyvsp[(4) - (7)]),(yyvsp[(5) - (7)]),false, &(yyvsp[(7) - (7)]),&(yyvsp[(3) - (7)]),NULL); ;} break; case 231: /* Line 1455 of yacc.c */ #line 1405 "hphp.y" { (yyval) = (yyvsp[(1) - (2)]);;} break; case 232: /* Line 1455 of yacc.c */ #line 1406 "hphp.y" { (yyval).reset();;} break; case 233: /* Line 1455 of yacc.c */ #line 1409 "hphp.y" { _p->onCallParam((yyval),NULL,(yyvsp[(1) - (1)]),false,false);;} break; case 234: /* Line 1455 of yacc.c */ #line 1410 "hphp.y" { _p->onCallParam((yyval),NULL,(yyvsp[(2) - (2)]),true,false);;} break; case 235: /* Line 1455 of yacc.c */ #line 1411 "hphp.y" { _p->onCallParam((yyval),NULL,(yyvsp[(2) - (2)]),false,true);;} break; case 236: /* Line 1455 of yacc.c */ #line 1413 "hphp.y" { _p->onCallParam((yyval),&(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),false, false);;} break; case 237: /* Line 1455 of yacc.c */ #line 1415 "hphp.y" { _p->onCallParam((yyval),&(yyvsp[(1) - (4)]),(yyvsp[(4) - (4)]),false,true);;} break; case 238: /* Line 1455 of yacc.c */ #line 1417 "hphp.y" { _p->onCallParam((yyval),&(yyvsp[(1) - (4)]),(yyvsp[(4) - (4)]),true, false);;} break; case 239: /* Line 1455 of yacc.c */ #line 1421 "hphp.y" { _p->onGlobalVar((yyval), &(yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]));;} break; case 240: /* Line 1455 of yacc.c */ #line 1422 "hphp.y" { _p->onGlobalVar((yyval), NULL, (yyvsp[(1) - (1)]));;} break; case 241: /* Line 1455 of yacc.c */ #line 1425 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 242: /* Line 1455 of yacc.c */ #line 1426 "hphp.y" { (yyval) = (yyvsp[(2) - (2)]); (yyval) = 1;;} break; case 243: /* Line 1455 of yacc.c */ #line 1427 "hphp.y" { (yyval) = (yyvsp[(3) - (4)]); (yyval) = 1;;} break; case 244: /* Line 1455 of yacc.c */ #line 1431 "hphp.y" { _p->onStaticVariable((yyval),&(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),0);;} break; case 245: /* Line 1455 of yacc.c */ #line 1433 "hphp.y" { _p->onStaticVariable((yyval),&(yyvsp[(1) - (5)]),(yyvsp[(3) - (5)]),&(yyvsp[(5) - (5)]));;} break; case 246: /* Line 1455 of yacc.c */ #line 1434 "hphp.y" { _p->onStaticVariable((yyval),0,(yyvsp[(1) - (1)]),0);;} break; case 247: /* Line 1455 of yacc.c */ #line 1435 "hphp.y" { _p->onStaticVariable((yyval),0,(yyvsp[(1) - (3)]),&(yyvsp[(3) - (3)]));;} break; case 248: /* Line 1455 of yacc.c */ #line 1440 "hphp.y" { _p->onClassStatement((yyval), (yyvsp[(1) - (2)]), (yyvsp[(2) - (2)]));;} break; case 249: /* Line 1455 of yacc.c */ #line 1441 "hphp.y" { (yyval).reset();;} break; case 250: /* Line 1455 of yacc.c */ #line 1444 "hphp.y" { _p->onClassVariableStart ((yyval),NULL,(yyvsp[(1) - (2)]),NULL);;} break; case 251: /* Line 1455 of yacc.c */ #line 1449 "hphp.y" { _p->onClassConstant((yyval),0,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]));;} break; case 252: /* Line 1455 of yacc.c */ #line 1455 "hphp.y" { _p->onClassStatement((yyval), (yyvsp[(1) - (2)]), (yyvsp[(2) - (2)]));;} break; case 253: /* Line 1455 of yacc.c */ #line 1456 "hphp.y" { (yyval).reset();;} break; case 254: /* Line 1455 of yacc.c */ #line 1459 "hphp.y" { _p->onClassVariableModifer((yyvsp[(1) - (1)]));;} break; case 255: /* Line 1455 of yacc.c */ #line 1460 "hphp.y" { _p->onClassVariableStart ((yyval),&(yyvsp[(1) - (4)]),(yyvsp[(3) - (4)]),NULL);;} break; case 256: /* Line 1455 of yacc.c */ #line 1463 "hphp.y" { _p->onClassVariableModifer((yyvsp[(1) - (2)]));;} break; case 257: /* Line 1455 of yacc.c */ #line 1464 "hphp.y" { _p->onClassVariableStart ((yyval),&(yyvsp[(1) - (5)]),(yyvsp[(4) - (5)]),&(yyvsp[(2) - (5)]));;} break; case 258: /* Line 1455 of yacc.c */ #line 1466 "hphp.y" { _p->onClassVariableStart ((yyval),NULL,(yyvsp[(1) - (2)]),NULL);;} break; case 259: /* Line 1455 of yacc.c */ #line 1470 "hphp.y" { _p->onNewLabelScope(true); _p->onMethodStart((yyvsp[(4) - (5)]), (yyvsp[(1) - (5)])); _p->pushLabelInfo();;} break; case 260: /* Line 1455 of yacc.c */ #line 1476 "hphp.y" { _p->onMethod((yyval),(yyvsp[(1) - (10)]),(yyvsp[(9) - (10)]),(yyvsp[(3) - (10)]),(yyvsp[(4) - (10)]),(yyvsp[(7) - (10)]),(yyvsp[(10) - (10)]),nullptr); _p->popLabelInfo(); _p->popTypeScope(); _p->onCompleteLabelScope(true);;} break; case 261: /* Line 1455 of yacc.c */ #line 1483 "hphp.y" { _p->onNewLabelScope(true); _p->onMethodStart((yyvsp[(5) - (6)]), (yyvsp[(2) - (6)])); _p->pushLabelInfo();;} break; case 262: /* Line 1455 of yacc.c */ #line 1489 "hphp.y" { _p->onMethod((yyval),(yyvsp[(2) - (11)]),(yyvsp[(10) - (11)]),(yyvsp[(4) - (11)]),(yyvsp[(5) - (11)]),(yyvsp[(8) - (11)]),(yyvsp[(11) - (11)]),&(yyvsp[(1) - (11)])); _p->popLabelInfo(); _p->popTypeScope(); _p->onCompleteLabelScope(true);;} break; case 263: /* Line 1455 of yacc.c */ #line 1494 "hphp.y" { _p->xhpSetAttributes((yyvsp[(2) - (3)]));;} break; case 264: /* Line 1455 of yacc.c */ #line 1496 "hphp.y" { xhp_category_stmt(_p,(yyval),(yyvsp[(2) - (3)]));;} break; case 265: /* Line 1455 of yacc.c */ #line 1498 "hphp.y" { xhp_children_stmt(_p,(yyval),(yyvsp[(2) - (3)]));;} break; case 266: /* Line 1455 of yacc.c */ #line 1500 "hphp.y" { _p->onClassRequire((yyval), (yyvsp[(3) - (4)]), true); ;} break; case 267: /* Line 1455 of yacc.c */ #line 1502 "hphp.y" { _p->onClassRequire((yyval), (yyvsp[(3) - (4)]), false); ;} break; case 268: /* Line 1455 of yacc.c */ #line 1503 "hphp.y" { Token t; t.reset(); _p->onTraitUse((yyval),(yyvsp[(2) - (3)]),t); ;} break; case 269: /* Line 1455 of yacc.c */ #line 1506 "hphp.y" { _p->onTraitUse((yyval),(yyvsp[(2) - (5)]),(yyvsp[(4) - (5)])); ;} break; case 270: /* Line 1455 of yacc.c */ #line 1509 "hphp.y" { _p->onTraitRule((yyval),(yyvsp[(1) - (2)]),(yyvsp[(2) - (2)])); ;} break; case 271: /* Line 1455 of yacc.c */ #line 1510 "hphp.y" { _p->onTraitRule((yyval),(yyvsp[(1) - (2)]),(yyvsp[(2) - (2)])); ;} break; case 272: /* Line 1455 of yacc.c */ #line 1511 "hphp.y" { (yyval).reset(); ;} break; case 273: /* Line 1455 of yacc.c */ #line 1517 "hphp.y" { _p->onTraitPrecRule((yyval),(yyvsp[(1) - (6)]),(yyvsp[(3) - (6)]),(yyvsp[(5) - (6)]));;} break; case 274: /* Line 1455 of yacc.c */ #line 1521 "hphp.y" { _p->onTraitAliasRuleModify((yyval),(yyvsp[(1) - (5)]),(yyvsp[(3) - (5)]), (yyvsp[(4) - (5)]));;} break; case 275: /* Line 1455 of yacc.c */ #line 1524 "hphp.y" { Token t; t.reset(); _p->onTraitAliasRuleModify((yyval),(yyvsp[(1) - (4)]),(yyvsp[(3) - (4)]), t);;} break; case 276: /* Line 1455 of yacc.c */ #line 1531 "hphp.y" { _p->onTraitAliasRuleStart((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]));;} break; case 277: /* Line 1455 of yacc.c */ #line 1532 "hphp.y" { Token t; t.reset(); _p->onTraitAliasRuleStart((yyval),t,(yyvsp[(1) - (1)]));;} break; case 278: /* Line 1455 of yacc.c */ #line 1537 "hphp.y" { xhp_attribute_list(_p,(yyval), _p->xhpGetAttributes(),(yyvsp[(1) - (1)]));;} break; case 279: /* Line 1455 of yacc.c */ #line 1540 "hphp.y" { xhp_attribute_list(_p,(yyval), &(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]));;} break; case 280: /* Line 1455 of yacc.c */ #line 1547 "hphp.y" { xhp_attribute(_p,(yyval),(yyvsp[(1) - (4)]),(yyvsp[(2) - (4)]),(yyvsp[(3) - (4)]),(yyvsp[(4) - (4)])); (yyval) = 1;;} break; case 281: /* Line 1455 of yacc.c */ #line 1549 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]); (yyval) = 0;;} break; case 282: /* Line 1455 of yacc.c */ #line 1553 "hphp.y" { (yyval) = 4;;} break; case 283: /* Line 1455 of yacc.c */ #line 1554 "hphp.y" { /* This case handles all types other than "array", "var" and "enum". For now we just use type code 5; later xhp_attribute() will fix up the type code as appropriate. */ (yyval) = 5; (yyval).setText((yyvsp[(1) - (1)]));;} break; case 284: /* Line 1455 of yacc.c */ #line 1560 "hphp.y" { (yyval) = 6;;} break; case 285: /* Line 1455 of yacc.c */ #line 1562 "hphp.y" { (yyval) = (yyvsp[(3) - (4)]); (yyval) = 7;;} break; case 286: /* Line 1455 of yacc.c */ #line 1563 "hphp.y" { (yyval) = 9; ;} break; case 287: /* Line 1455 of yacc.c */ #line 1567 "hphp.y" { _p->onArrayPair((yyval), 0,0,(yyvsp[(1) - (1)]),0);;} break; case 288: /* Line 1455 of yacc.c */ #line 1569 "hphp.y" { _p->onArrayPair((yyval),&(yyvsp[(1) - (3)]),0,(yyvsp[(3) - (3)]),0);;} break; case 289: /* Line 1455 of yacc.c */ #line 1573 "hphp.y" { (yyval) = (yyvsp[(2) - (2)]);;} break; case 290: /* Line 1455 of yacc.c */ #line 1574 "hphp.y" { scalar_null(_p, (yyval));;} break; case 291: /* Line 1455 of yacc.c */ #line 1578 "hphp.y" { scalar_num(_p, (yyval), "1");;} break; case 292: /* Line 1455 of yacc.c */ #line 1579 "hphp.y" { scalar_num(_p, (yyval), "0");;} break; case 293: /* Line 1455 of yacc.c */ #line 1583 "hphp.y" { Token t; scalar_num(_p, t, "1"); _p->onArrayPair((yyval),0,&(yyvsp[(1) - (1)]),t,0);;} break; case 294: /* Line 1455 of yacc.c */ #line 1586 "hphp.y" { Token t; scalar_num(_p, t, "1"); _p->onArrayPair((yyval),&(yyvsp[(1) - (3)]),&(yyvsp[(3) - (3)]),t,0);;} break; case 295: /* Line 1455 of yacc.c */ #line 1591 "hphp.y" { _p->onScalar((yyval), T_CONSTANT_ENCAPSED_STRING, (yyvsp[(1) - (1)]));;} break; case 296: /* Line 1455 of yacc.c */ #line 1596 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]); (yyval) = 2;;} break; case 297: /* Line 1455 of yacc.c */ #line 1597 "hphp.y" { (yyval) = -1; if ((yyvsp[(1) - (1)]).same("any")) (yyval) = 1;;} break; case 298: /* Line 1455 of yacc.c */ #line 1599 "hphp.y" { (yyval) = 0;;} break; case 299: /* Line 1455 of yacc.c */ #line 1603 "hphp.y" { xhp_children_paren(_p, (yyval), (yyvsp[(2) - (3)]), 0);;} break; case 300: /* Line 1455 of yacc.c */ #line 1604 "hphp.y" { xhp_children_paren(_p, (yyval), (yyvsp[(2) - (4)]), 1);;} break; case 301: /* Line 1455 of yacc.c */ #line 1605 "hphp.y" { xhp_children_paren(_p, (yyval), (yyvsp[(2) - (4)]), 2);;} break; case 302: /* Line 1455 of yacc.c */ #line 1606 "hphp.y" { xhp_children_paren(_p, (yyval), (yyvsp[(2) - (4)]), 3);;} break; case 303: /* Line 1455 of yacc.c */ #line 1610 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 304: /* Line 1455 of yacc.c */ #line 1611 "hphp.y" { xhp_children_decl(_p,(yyval),(yyvsp[(1) - (1)]),0, 0);;} break; case 305: /* Line 1455 of yacc.c */ #line 1612 "hphp.y" { xhp_children_decl(_p,(yyval),(yyvsp[(1) - (2)]),1, 0);;} break; case 306: /* Line 1455 of yacc.c */ #line 1613 "hphp.y" { xhp_children_decl(_p,(yyval),(yyvsp[(1) - (2)]),2, 0);;} break; case 307: /* Line 1455 of yacc.c */ #line 1614 "hphp.y" { xhp_children_decl(_p,(yyval),(yyvsp[(1) - (2)]),3, 0);;} break; case 308: /* Line 1455 of yacc.c */ #line 1616 "hphp.y" { xhp_children_decl(_p,(yyval),(yyvsp[(1) - (3)]),4,&(yyvsp[(3) - (3)]));;} break; case 309: /* Line 1455 of yacc.c */ #line 1618 "hphp.y" { xhp_children_decl(_p,(yyval),(yyvsp[(1) - (3)]),5,&(yyvsp[(3) - (3)]));;} break; case 310: /* Line 1455 of yacc.c */ #line 1622 "hphp.y" { (yyval) = -1; if ((yyvsp[(1) - (1)]).same("any")) (yyval) = 1; else if ((yyvsp[(1) - (1)]).same("pcdata")) (yyval) = 2;;} break; case 311: /* Line 1455 of yacc.c */ #line 1625 "hphp.y" { (yyvsp[(1) - (1)]).xhpLabel(); (yyval) = (yyvsp[(1) - (1)]); (yyval) = 3;;} break; case 312: /* Line 1455 of yacc.c */ #line 1626 "hphp.y" { (yyvsp[(1) - (1)]).xhpLabel(0); (yyval) = (yyvsp[(1) - (1)]); (yyval) = 4;;} break; case 313: /* Line 1455 of yacc.c */ #line 1630 "hphp.y" { (yyval).reset();;} break; case 314: /* Line 1455 of yacc.c */ #line 1631 "hphp.y" { _p->finishStatement((yyval), (yyvsp[(2) - (3)])); (yyval) = 1;;} break; case 315: /* Line 1455 of yacc.c */ #line 1635 "hphp.y" { (yyval).reset();;} break; case 316: /* Line 1455 of yacc.c */ #line 1636 "hphp.y" { _p->finishStatement((yyval), (yyvsp[(2) - (3)])); (yyval) = 1;;} break; case 317: /* Line 1455 of yacc.c */ #line 1639 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 318: /* Line 1455 of yacc.c */ #line 1640 "hphp.y" { (yyval).reset();;} break; case 319: /* Line 1455 of yacc.c */ #line 1643 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 320: /* Line 1455 of yacc.c */ #line 1644 "hphp.y" { (yyval).reset();;} break; case 321: /* Line 1455 of yacc.c */ #line 1647 "hphp.y" { _p->onMemberModifier((yyval),NULL,(yyvsp[(1) - (1)]));;} break; case 322: /* Line 1455 of yacc.c */ #line 1649 "hphp.y" { _p->onMemberModifier((yyval),&(yyvsp[(1) - (2)]),(yyvsp[(2) - (2)]));;} break; case 323: /* Line 1455 of yacc.c */ #line 1652 "hphp.y" { (yyval) = T_PUBLIC;;} break; case 324: /* Line 1455 of yacc.c */ #line 1653 "hphp.y" { (yyval) = T_PROTECTED;;} break; case 325: /* Line 1455 of yacc.c */ #line 1654 "hphp.y" { (yyval) = T_PRIVATE;;} break; case 326: /* Line 1455 of yacc.c */ #line 1655 "hphp.y" { (yyval) = T_STATIC;;} break; case 327: /* Line 1455 of yacc.c */ #line 1656 "hphp.y" { (yyval) = T_ABSTRACT;;} break; case 328: /* Line 1455 of yacc.c */ #line 1657 "hphp.y" { (yyval) = T_FINAL;;} break; case 329: /* Line 1455 of yacc.c */ #line 1658 "hphp.y" { (yyval) = T_ASYNC;;} break; case 330: /* Line 1455 of yacc.c */ #line 1662 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 331: /* Line 1455 of yacc.c */ #line 1663 "hphp.y" { (yyval).reset();;} break; case 332: /* Line 1455 of yacc.c */ #line 1666 "hphp.y" { (yyval) = T_PUBLIC;;} break; case 333: /* Line 1455 of yacc.c */ #line 1667 "hphp.y" { (yyval) = T_PROTECTED;;} break; case 334: /* Line 1455 of yacc.c */ #line 1668 "hphp.y" { (yyval) = T_PRIVATE;;} break; case 335: /* Line 1455 of yacc.c */ #line 1672 "hphp.y" { _p->onClassVariable((yyval),&(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),0);;} break; case 336: /* Line 1455 of yacc.c */ #line 1674 "hphp.y" { _p->onClassVariable((yyval),&(yyvsp[(1) - (5)]),(yyvsp[(3) - (5)]),&(yyvsp[(5) - (5)]));;} break; case 337: /* Line 1455 of yacc.c */ #line 1675 "hphp.y" { _p->onClassVariable((yyval),0,(yyvsp[(1) - (1)]),0);;} break; case 338: /* Line 1455 of yacc.c */ #line 1676 "hphp.y" { _p->onClassVariable((yyval),0,(yyvsp[(1) - (3)]),&(yyvsp[(3) - (3)]));;} break; case 339: /* Line 1455 of yacc.c */ #line 1680 "hphp.y" { _p->onClassConstant((yyval),&(yyvsp[(1) - (5)]),(yyvsp[(3) - (5)]),(yyvsp[(5) - (5)]));;} break; case 340: /* Line 1455 of yacc.c */ #line 1682 "hphp.y" { _p->onClassConstant((yyval),0,(yyvsp[(2) - (4)]),(yyvsp[(4) - (4)]));;} break; case 341: /* Line 1455 of yacc.c */ #line 1686 "hphp.y" { (yyval) = (yyvsp[(2) - (3)]);;} break; case 342: /* Line 1455 of yacc.c */ #line 1688 "hphp.y" { _p->onNewObject((yyval), (yyvsp[(2) - (3)]), (yyvsp[(3) - (3)]));;} break; case 343: /* Line 1455 of yacc.c */ #line 1689 "hphp.y" { UEXP((yyval),(yyvsp[(2) - (2)]),T_CLONE,1);;} break; case 344: /* Line 1455 of yacc.c */ #line 1690 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 345: /* Line 1455 of yacc.c */ #line 1691 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 346: /* Line 1455 of yacc.c */ #line 1694 "hphp.y" { (yyval) = (yyvsp[(2) - (3)]);;} break; case 347: /* Line 1455 of yacc.c */ #line 1698 "hphp.y" { _p->onExprListElem((yyval), &(yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]));;} break; case 348: /* Line 1455 of yacc.c */ #line 1699 "hphp.y" { _p->onExprListElem((yyval), NULL, (yyvsp[(1) - (1)]));;} break; case 349: /* Line 1455 of yacc.c */ #line 1703 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 350: /* Line 1455 of yacc.c */ #line 1704 "hphp.y" { (yyval).reset();;} break; case 351: /* Line 1455 of yacc.c */ #line 1708 "hphp.y" { _p->onYield((yyval), (yyvsp[(2) - (2)]));;} break; case 352: /* Line 1455 of yacc.c */ #line 1709 "hphp.y" { _p->onYieldPair((yyval), (yyvsp[(2) - (4)]), (yyvsp[(4) - (4)]));;} break; case 353: /* Line 1455 of yacc.c */ #line 1713 "hphp.y" { _p->onAssign((yyval), (yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), 0, true);;} break; case 354: /* Line 1455 of yacc.c */ #line 1718 "hphp.y" { _p->onListAssignment((yyval), (yyvsp[(3) - (6)]), &(yyvsp[(6) - (6)]), true);;} break; case 355: /* Line 1455 of yacc.c */ #line 1722 "hphp.y" { _p->onAwait((yyval), (yyvsp[(2) - (2)])); ;} break; case 356: /* Line 1455 of yacc.c */ #line 1726 "hphp.y" { _p->onAssign((yyval), (yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), 0, true);;} break; case 357: /* Line 1455 of yacc.c */ #line 1731 "hphp.y" { _p->onListAssignment((yyval), (yyvsp[(3) - (6)]), &(yyvsp[(6) - (6)]), true);;} break; case 358: /* Line 1455 of yacc.c */ #line 1735 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 359: /* Line 1455 of yacc.c */ #line 1736 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 360: /* Line 1455 of yacc.c */ #line 1737 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 361: /* Line 1455 of yacc.c */ #line 1741 "hphp.y" { _p->onListAssignment((yyval), (yyvsp[(3) - (6)]), &(yyvsp[(6) - (6)]));;} break; case 362: /* Line 1455 of yacc.c */ #line 1742 "hphp.y" { _p->onAssign((yyval), (yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), 0);;} break; case 363: /* Line 1455 of yacc.c */ #line 1743 "hphp.y" { _p->onAssign((yyval), (yyvsp[(1) - (4)]), (yyvsp[(4) - (4)]), 1);;} break; case 364: /* Line 1455 of yacc.c */ #line 1746 "hphp.y" { _p->onAssignNew((yyval),(yyvsp[(1) - (6)]),(yyvsp[(5) - (6)]),(yyvsp[(6) - (6)]));;} break; case 365: /* Line 1455 of yacc.c */ #line 1747 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_PLUS_EQUAL);;} break; case 366: /* Line 1455 of yacc.c */ #line 1748 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_MINUS_EQUAL);;} break; case 367: /* Line 1455 of yacc.c */ #line 1749 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_MUL_EQUAL);;} break; case 368: /* Line 1455 of yacc.c */ #line 1750 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_DIV_EQUAL);;} break; case 369: /* Line 1455 of yacc.c */ #line 1751 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_CONCAT_EQUAL);;} break; case 370: /* Line 1455 of yacc.c */ #line 1752 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_MOD_EQUAL);;} break; case 371: /* Line 1455 of yacc.c */ #line 1753 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_AND_EQUAL);;} break; case 372: /* Line 1455 of yacc.c */ #line 1754 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_OR_EQUAL);;} break; case 373: /* Line 1455 of yacc.c */ #line 1755 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_XOR_EQUAL);;} break; case 374: /* Line 1455 of yacc.c */ #line 1756 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_SL_EQUAL);;} break; case 375: /* Line 1455 of yacc.c */ #line 1757 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_SR_EQUAL);;} break; case 376: /* Line 1455 of yacc.c */ #line 1758 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_POW_EQUAL);;} break; case 377: /* Line 1455 of yacc.c */ #line 1759 "hphp.y" { UEXP((yyval),(yyvsp[(1) - (2)]),T_INC,0);;} break; case 378: /* Line 1455 of yacc.c */ #line 1760 "hphp.y" { UEXP((yyval),(yyvsp[(2) - (2)]),T_INC,1);;} break; case 379: /* Line 1455 of yacc.c */ #line 1761 "hphp.y" { UEXP((yyval),(yyvsp[(1) - (2)]),T_DEC,0);;} break; case 380: /* Line 1455 of yacc.c */ #line 1762 "hphp.y" { UEXP((yyval),(yyvsp[(2) - (2)]),T_DEC,1);;} break; case 381: /* Line 1455 of yacc.c */ #line 1763 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_BOOLEAN_OR);;} break; case 382: /* Line 1455 of yacc.c */ #line 1764 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_BOOLEAN_AND);;} break; case 383: /* Line 1455 of yacc.c */ #line 1765 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_LOGICAL_OR);;} break; case 384: /* Line 1455 of yacc.c */ #line 1766 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_LOGICAL_AND);;} break; case 385: /* Line 1455 of yacc.c */ #line 1767 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_LOGICAL_XOR);;} break; case 386: /* Line 1455 of yacc.c */ #line 1768 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'|');;} break; case 387: /* Line 1455 of yacc.c */ #line 1769 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'&');;} break; case 388: /* Line 1455 of yacc.c */ #line 1770 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'^');;} break; case 389: /* Line 1455 of yacc.c */ #line 1771 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'.');;} break; case 390: /* Line 1455 of yacc.c */ #line 1772 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'+');;} break; case 391: /* Line 1455 of yacc.c */ #line 1773 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'-');;} break; case 392: /* Line 1455 of yacc.c */ #line 1774 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'*');;} break; case 393: /* Line 1455 of yacc.c */ #line 1775 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'/');;} break; case 394: /* Line 1455 of yacc.c */ #line 1776 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_POW);;} break; case 395: /* Line 1455 of yacc.c */ #line 1777 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'%');;} break; case 396: /* Line 1455 of yacc.c */ #line 1778 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_SL);;} break; case 397: /* Line 1455 of yacc.c */ #line 1779 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_SR);;} break; case 398: /* Line 1455 of yacc.c */ #line 1780 "hphp.y" { UEXP((yyval),(yyvsp[(2) - (2)]),'+',1);;} break; case 399: /* Line 1455 of yacc.c */ #line 1781 "hphp.y" { UEXP((yyval),(yyvsp[(2) - (2)]),'-',1);;} break; case 400: /* Line 1455 of yacc.c */ #line 1782 "hphp.y" { UEXP((yyval),(yyvsp[(2) - (2)]),'!',1);;} break; case 401: /* Line 1455 of yacc.c */ #line 1783 "hphp.y" { UEXP((yyval),(yyvsp[(2) - (2)]),'~',1);;} break; case 402: /* Line 1455 of yacc.c */ #line 1784 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_IS_IDENTICAL);;} break; case 403: /* Line 1455 of yacc.c */ #line 1785 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_IS_NOT_IDENTICAL);;} break; case 404: /* Line 1455 of yacc.c */ #line 1786 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_IS_EQUAL);;} break; case 405: /* Line 1455 of yacc.c */ #line 1787 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_IS_NOT_EQUAL);;} break; case 406: /* Line 1455 of yacc.c */ #line 1788 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'<');;} break; case 407: /* Line 1455 of yacc.c */ #line 1789 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]), T_IS_SMALLER_OR_EQUAL);;} break; case 408: /* Line 1455 of yacc.c */ #line 1791 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'>');;} break; case 409: /* Line 1455 of yacc.c */ #line 1792 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]), T_IS_GREATER_OR_EQUAL);;} break; case 410: /* Line 1455 of yacc.c */ #line 1795 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_INSTANCEOF);;} break; case 411: /* Line 1455 of yacc.c */ #line 1796 "hphp.y" { (yyval) = (yyvsp[(2) - (3)]);;} break; case 412: /* Line 1455 of yacc.c */ #line 1797 "hphp.y" { _p->onQOp((yyval), (yyvsp[(1) - (5)]), &(yyvsp[(3) - (5)]), (yyvsp[(5) - (5)]));;} break; case 413: /* Line 1455 of yacc.c */ #line 1798 "hphp.y" { _p->onQOp((yyval), (yyvsp[(1) - (4)]), 0, (yyvsp[(4) - (4)]));;} break; case 414: /* Line 1455 of yacc.c */ #line 1799 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 415: /* Line 1455 of yacc.c */ #line 1800 "hphp.y" { UEXP((yyval),(yyvsp[(2) - (2)]),T_INT_CAST,1);;} break; case 416: /* Line 1455 of yacc.c */ #line 1801 "hphp.y" { UEXP((yyval),(yyvsp[(2) - (2)]),T_DOUBLE_CAST,1);;} break; case 417: /* Line 1455 of yacc.c */ #line 1802 "hphp.y" { UEXP((yyval),(yyvsp[(2) - (2)]),T_STRING_CAST,1);;} break; case 418: /* Line 1455 of yacc.c */ #line 1803 "hphp.y" { UEXP((yyval),(yyvsp[(2) - (2)]),T_ARRAY_CAST,1);;} break; case 419: /* Line 1455 of yacc.c */ #line 1804 "hphp.y" { UEXP((yyval),(yyvsp[(2) - (2)]),T_OBJECT_CAST,1);;} break; case 420: /* Line 1455 of yacc.c */ #line 1805 "hphp.y" { UEXP((yyval),(yyvsp[(2) - (2)]),T_BOOL_CAST,1);;} break; case 421: /* Line 1455 of yacc.c */ #line 1806 "hphp.y" { UEXP((yyval),(yyvsp[(2) - (2)]),T_UNSET_CAST,1);;} break; case 422: /* Line 1455 of yacc.c */ #line 1807 "hphp.y" { UEXP((yyval),(yyvsp[(2) - (2)]),T_EXIT,1);;} break; case 423: /* Line 1455 of yacc.c */ #line 1808 "hphp.y" { UEXP((yyval),(yyvsp[(2) - (2)]),'@',1);;} break; case 424: /* Line 1455 of yacc.c */ #line 1809 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]); ;} break; case 425: /* Line 1455 of yacc.c */ #line 1810 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]); ;} break; case 426: /* Line 1455 of yacc.c */ #line 1811 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]); ;} break; case 427: /* Line 1455 of yacc.c */ #line 1812 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]); ;} break; case 428: /* Line 1455 of yacc.c */ #line 1813 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]); ;} break; case 429: /* Line 1455 of yacc.c */ #line 1814 "hphp.y" { _p->onEncapsList((yyval),'`',(yyvsp[(2) - (3)]));;} break; case 430: /* Line 1455 of yacc.c */ #line 1815 "hphp.y" { UEXP((yyval),(yyvsp[(2) - (2)]),T_PRINT,1);;} break; case 431: /* Line 1455 of yacc.c */ #line 1816 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 432: /* Line 1455 of yacc.c */ #line 1817 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 433: /* Line 1455 of yacc.c */ #line 1818 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 434: /* Line 1455 of yacc.c */ #line 1825 "hphp.y" { (yyval) = (yyvsp[(3) - (5)]);;} break; case 435: /* Line 1455 of yacc.c */ #line 1826 "hphp.y" { (yyval).reset();;} break; case 436: /* Line 1455 of yacc.c */ #line 1831 "hphp.y" { Token t; _p->onNewLabelScope(true); _p->onClosureStart(t); _p->pushLabelInfo(); ;} break; case 437: /* Line 1455 of yacc.c */ #line 1837 "hphp.y" { _p->finishStatement((yyvsp[(10) - (11)]), (yyvsp[(10) - (11)])); (yyvsp[(10) - (11)]) = 1; (yyval) = _p->onClosure(ClosureType::Long, nullptr, (yyvsp[(2) - (11)]),(yyvsp[(5) - (11)]),(yyvsp[(8) - (11)]),(yyvsp[(10) - (11)])); _p->popLabelInfo(); _p->onCompleteLabelScope(true);;} break; case 438: /* Line 1455 of yacc.c */ #line 1845 "hphp.y" { Token t; _p->onNewLabelScope(true); _p->onClosureStart(t); _p->pushLabelInfo(); ;} break; case 439: /* Line 1455 of yacc.c */ #line 1851 "hphp.y" { _p->finishStatement((yyvsp[(11) - (12)]), (yyvsp[(11) - (12)])); (yyvsp[(11) - (12)]) = 1; (yyval) = _p->onClosure(ClosureType::Long, &(yyvsp[(1) - (12)]), (yyvsp[(3) - (12)]),(yyvsp[(6) - (12)]),(yyvsp[(9) - (12)]),(yyvsp[(11) - (12)])); _p->popLabelInfo(); _p->onCompleteLabelScope(true);;} break; case 440: /* Line 1455 of yacc.c */ #line 1860 "hphp.y" { _p->pushFuncLocation(); Token t; _p->onNewLabelScope(true); _p->onClosureStart(t); _p->pushLabelInfo(); Token u; _p->onParam((yyvsp[(1) - (1)]),NULL,u,(yyvsp[(1) - (1)]),0, NULL,NULL,NULL);;} break; case 441: /* Line 1455 of yacc.c */ #line 1868 "hphp.y" { Token v; Token w; _p->finishStatement((yyvsp[(3) - (3)]), (yyvsp[(3) - (3)])); (yyvsp[(3) - (3)]) = 1; (yyval) = _p->onClosure(ClosureType::Short, nullptr, v,(yyvsp[(1) - (3)]),w,(yyvsp[(3) - (3)])); _p->popLabelInfo(); _p->onCompleteLabelScope(true);;} break; case 442: /* Line 1455 of yacc.c */ #line 1876 "hphp.y" { _p->pushFuncLocation(); Token t; _p->onNewLabelScope(true); _p->onClosureStart(t); _p->pushLabelInfo(); Token u; _p->onParam((yyvsp[(2) - (2)]),NULL,u,(yyvsp[(2) - (2)]),0, NULL,NULL,NULL);;} break; case 443: /* Line 1455 of yacc.c */ #line 1884 "hphp.y" { Token v; Token w; (yyvsp[(1) - (4)]) = T_ASYNC; _p->onMemberModifier((yyvsp[(1) - (4)]), nullptr, (yyvsp[(1) - (4)])); _p->finishStatement((yyvsp[(4) - (4)]), (yyvsp[(4) - (4)])); (yyvsp[(4) - (4)]) = 1; (yyval) = _p->onClosure(ClosureType::Short, &(yyvsp[(1) - (4)]), v,(yyvsp[(2) - (4)]),w,(yyvsp[(4) - (4)])); _p->popLabelInfo(); _p->onCompleteLabelScope(true);;} break; case 444: /* Line 1455 of yacc.c */ #line 1893 "hphp.y" { _p->pushFuncLocation(); Token t; _p->onNewLabelScope(true); _p->onClosureStart(t); _p->pushLabelInfo();;} break; case 445: /* Line 1455 of yacc.c */ #line 1901 "hphp.y" { Token u; Token v; _p->finishStatement((yyvsp[(6) - (6)]), (yyvsp[(6) - (6)])); (yyvsp[(6) - (6)]) = 1; (yyval) = _p->onClosure(ClosureType::Short, nullptr, u,(yyvsp[(3) - (6)]),v,(yyvsp[(6) - (6)])); _p->popLabelInfo(); _p->onCompleteLabelScope(true);;} break; case 446: /* Line 1455 of yacc.c */ #line 1909 "hphp.y" { _p->pushFuncLocation(); Token t; _p->onNewLabelScope(true); _p->onClosureStart(t); _p->pushLabelInfo();;} break; case 447: /* Line 1455 of yacc.c */ #line 1917 "hphp.y" { Token u; Token v; (yyvsp[(1) - (7)]) = T_ASYNC; _p->onMemberModifier((yyvsp[(1) - (7)]), nullptr, (yyvsp[(1) - (7)])); _p->finishStatement((yyvsp[(7) - (7)]), (yyvsp[(7) - (7)])); (yyvsp[(7) - (7)]) = 1; (yyval) = _p->onClosure(ClosureType::Short, &(yyvsp[(1) - (7)]), u,(yyvsp[(4) - (7)]),v,(yyvsp[(7) - (7)])); _p->popLabelInfo(); _p->onCompleteLabelScope(true);;} break; case 448: /* Line 1455 of yacc.c */ #line 1929 "hphp.y" { (yyval) = _p->onExprForLambda((yyvsp[(2) - (2)]));;} break; case 449: /* Line 1455 of yacc.c */ #line 1930 "hphp.y" { (yyval) = _p->onExprForLambda((yyvsp[(2) - (2)]));;} break; case 450: /* Line 1455 of yacc.c */ #line 1932 "hphp.y" { (yyval) = (yyvsp[(3) - (4)]); ;} break; case 451: /* Line 1455 of yacc.c */ #line 1936 "hphp.y" { validate_shape_keyname((yyvsp[(1) - (1)]), _p); _p->onScalar((yyval), T_CONSTANT_ENCAPSED_STRING, (yyvsp[(1) - (1)])); ;} break; case 452: /* Line 1455 of yacc.c */ #line 1938 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]); ;} break; case 453: /* Line 1455 of yacc.c */ #line 1945 "hphp.y" { _p->onArrayPair((yyval),&(yyvsp[(1) - (5)]),&(yyvsp[(3) - (5)]),(yyvsp[(5) - (5)]),0); ;} break; case 454: /* Line 1455 of yacc.c */ #line 1948 "hphp.y" { _p->onArrayPair((yyval), 0,&(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),0); ;} break; case 455: /* Line 1455 of yacc.c */ #line 1955 "hphp.y" { _p->onArrayPair((yyval),&(yyvsp[(1) - (5)]),&(yyvsp[(3) - (5)]),(yyvsp[(5) - (5)]),0); ;} break; case 456: /* Line 1455 of yacc.c */ #line 1958 "hphp.y" { _p->onArrayPair((yyval), 0,&(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),0); ;} break; case 457: /* Line 1455 of yacc.c */ #line 1963 "hphp.y" { (yyval) = (yyvsp[(1) - (2)]); ;} break; case 458: /* Line 1455 of yacc.c */ #line 1964 "hphp.y" { (yyval).reset(); ;} break; case 459: /* Line 1455 of yacc.c */ #line 1969 "hphp.y" { (yyval) = (yyvsp[(1) - (2)]); ;} break; case 460: /* Line 1455 of yacc.c */ #line 1970 "hphp.y" { (yyval).reset(); ;} break; case 461: /* Line 1455 of yacc.c */ #line 1974 "hphp.y" { _p->onArray((yyval), (yyvsp[(3) - (4)]), T_ARRAY);;} break; case 462: /* Line 1455 of yacc.c */ #line 1978 "hphp.y" { _p->onArray((yyval),(yyvsp[(3) - (4)]),T_ARRAY);;} break; case 463: /* Line 1455 of yacc.c */ #line 1979 "hphp.y" { _p->onArray((yyval),(yyvsp[(2) - (3)]),T_ARRAY);;} break; case 464: /* Line 1455 of yacc.c */ #line 1984 "hphp.y" { Token t; _p->onName(t,(yyvsp[(1) - (4)]),Parser::StringName); BEXP((yyval),t,(yyvsp[(3) - (4)]),T_COLLECTION);;} break; case 465: /* Line 1455 of yacc.c */ #line 1990 "hphp.y" { _p->onCheckedArray((yyval),(yyvsp[(3) - (4)]),T_MIARRAY);;} break; case 466: /* Line 1455 of yacc.c */ #line 1991 "hphp.y" { _p->onCheckedArray((yyval),(yyvsp[(3) - (4)]),T_MSARRAY);;} break; case 467: /* Line 1455 of yacc.c */ #line 1995 "hphp.y" { _p->onCheckedArray((yyval),(yyvsp[(3) - (4)]),T_VARRAY);;} break; case 468: /* Line 1455 of yacc.c */ #line 2000 "hphp.y" { _p->onCheckedArray((yyval),(yyvsp[(3) - (4)]),T_MIARRAY);;} break; case 469: /* Line 1455 of yacc.c */ #line 2002 "hphp.y" { _p->onCheckedArray((yyval),(yyvsp[(3) - (4)]),T_MSARRAY);;} break; case 470: /* Line 1455 of yacc.c */ #line 2007 "hphp.y" { _p->onCheckedArray((yyval),(yyvsp[(3) - (4)]),T_VARRAY);;} break; case 471: /* Line 1455 of yacc.c */ #line 2012 "hphp.y" { Token t; _p->onName(t,(yyvsp[(1) - (4)]),Parser::StringName); BEXP((yyval),t,(yyvsp[(3) - (4)]),T_COLLECTION);;} break; case 472: /* Line 1455 of yacc.c */ #line 2019 "hphp.y" { _p->onRefDim((yyval), (yyvsp[(1) - (4)]), (yyvsp[(3) - (4)]));;} break; case 473: /* Line 1455 of yacc.c */ #line 2021 "hphp.y" { _p->onRefDim((yyval), (yyvsp[(1) - (4)]), (yyvsp[(3) - (4)]));;} break; case 474: /* Line 1455 of yacc.c */ #line 2025 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 475: /* Line 1455 of yacc.c */ #line 2026 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 476: /* Line 1455 of yacc.c */ #line 2027 "hphp.y" { _p->onScalar((yyval), T_CONSTANT_ENCAPSED_STRING, (yyvsp[(1) - (1)])); ;} break; case 477: /* Line 1455 of yacc.c */ #line 2029 "hphp.y" { (yyval) = (yyvsp[(2) - (3)]);;} break; case 478: /* Line 1455 of yacc.c */ #line 2033 "hphp.y" { _p->onQuery((yyval), (yyvsp[(1) - (2)]), (yyvsp[(2) - (2)])); ;} break; case 479: /* Line 1455 of yacc.c */ #line 2037 "hphp.y" { _p->onAssign((yyval), (yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), 0, true);;} break; case 480: /* Line 1455 of yacc.c */ #line 2041 "hphp.y" { _p->onFromClause((yyval), (yyvsp[(2) - (4)]), (yyvsp[(4) - (4)])); ;} break; case 481: /* Line 1455 of yacc.c */ #line 2046 "hphp.y" { _p->onQueryBody((yyval), &(yyvsp[(1) - (2)]), (yyvsp[(2) - (2)]), NULL); ;} break; case 482: /* Line 1455 of yacc.c */ #line 2048 "hphp.y" { _p->onQueryBody((yyval), &(yyvsp[(1) - (3)]), (yyvsp[(2) - (3)]), &(yyvsp[(3) - (3)])); ;} break; case 483: /* Line 1455 of yacc.c */ #line 2050 "hphp.y" { _p->onQueryBody((yyval), NULL, (yyvsp[(1) - (1)]), NULL); ;} break; case 484: /* Line 1455 of yacc.c */ #line 2052 "hphp.y" { _p->onQueryBody((yyval), NULL, (yyvsp[(1) - (2)]), &(yyvsp[(2) - (2)])); ;} break; case 485: /* Line 1455 of yacc.c */ #line 2056 "hphp.y" { _p->onQueryBodyClause((yyval), NULL, (yyvsp[(1) - (1)])); ;} break; case 486: /* Line 1455 of yacc.c */ #line 2058 "hphp.y" { _p->onQueryBodyClause((yyval), &(yyvsp[(1) - (2)]), (yyvsp[(2) - (2)])); ;} break; case 487: /* Line 1455 of yacc.c */ #line 2062 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 488: /* Line 1455 of yacc.c */ #line 2063 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 489: /* Line 1455 of yacc.c */ #line 2064 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 490: /* Line 1455 of yacc.c */ #line 2065 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 491: /* Line 1455 of yacc.c */ #line 2066 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 492: /* Line 1455 of yacc.c */ #line 2067 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 493: /* Line 1455 of yacc.c */ #line 2071 "hphp.y" { _p->onFromClause((yyval), (yyvsp[(2) - (4)]), (yyvsp[(4) - (4)])); ;} break; case 494: /* Line 1455 of yacc.c */ #line 2075 "hphp.y" { _p->onLetClause((yyval), (yyvsp[(2) - (4)]), (yyvsp[(4) - (4)])); ;} break; case 495: /* Line 1455 of yacc.c */ #line 2079 "hphp.y" { _p->onWhereClause((yyval), (yyvsp[(2) - (2)])); ;} break; case 496: /* Line 1455 of yacc.c */ #line 2084 "hphp.y" { _p->onJoinClause((yyval), (yyvsp[(2) - (8)]), (yyvsp[(4) - (8)]), (yyvsp[(6) - (8)]), (yyvsp[(8) - (8)])); ;} break; case 497: /* Line 1455 of yacc.c */ #line 2089 "hphp.y" { _p->onJoinIntoClause((yyval), (yyvsp[(2) - (10)]), (yyvsp[(4) - (10)]), (yyvsp[(6) - (10)]), (yyvsp[(8) - (10)]), (yyvsp[(10) - (10)])); ;} break; case 498: /* Line 1455 of yacc.c */ #line 2093 "hphp.y" { _p->onOrderbyClause((yyval), (yyvsp[(2) - (2)])); ;} break; case 499: /* Line 1455 of yacc.c */ #line 2097 "hphp.y" { _p->onOrdering((yyval), NULL, (yyvsp[(1) - (1)])); ;} break; case 500: /* Line 1455 of yacc.c */ #line 2098 "hphp.y" { _p->onOrdering((yyval), &(yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); ;} break; case 501: /* Line 1455 of yacc.c */ #line 2102 "hphp.y" { _p->onOrderingExpr((yyval), (yyvsp[(1) - (1)]), NULL); ;} break; case 502: /* Line 1455 of yacc.c */ #line 2103 "hphp.y" { _p->onOrderingExpr((yyval), (yyvsp[(1) - (2)]), &(yyvsp[(2) - (2)])); ;} break; case 503: /* Line 1455 of yacc.c */ #line 2107 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 504: /* Line 1455 of yacc.c */ #line 2108 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 505: /* Line 1455 of yacc.c */ #line 2112 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 506: /* Line 1455 of yacc.c */ #line 2113 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 507: /* Line 1455 of yacc.c */ #line 2117 "hphp.y" { _p->onSelectClause((yyval), (yyvsp[(2) - (2)])); ;} break; case 508: /* Line 1455 of yacc.c */ #line 2121 "hphp.y" { _p->onGroupClause((yyval), (yyvsp[(2) - (4)]), (yyvsp[(4) - (4)])); ;} break; case 509: /* Line 1455 of yacc.c */ #line 2125 "hphp.y" { _p->onIntoClause((yyval), (yyvsp[(2) - (3)]), (yyvsp[(3) - (3)])); ;} break; case 510: /* Line 1455 of yacc.c */ #line 2129 "hphp.y" { _p->onClosureParam((yyval),&(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),0);;} break; case 511: /* Line 1455 of yacc.c */ #line 2130 "hphp.y" { _p->onClosureParam((yyval),&(yyvsp[(1) - (4)]),(yyvsp[(4) - (4)]),1);;} break; case 512: /* Line 1455 of yacc.c */ #line 2131 "hphp.y" { _p->onClosureParam((yyval), 0,(yyvsp[(1) - (1)]),0);;} break; case 513: /* Line 1455 of yacc.c */ #line 2132 "hphp.y" { _p->onClosureParam((yyval), 0,(yyvsp[(2) - (2)]),1);;} break; case 514: /* Line 1455 of yacc.c */ #line 2139 "hphp.y" { xhp_tag(_p,(yyval),(yyvsp[(2) - (4)]),(yyvsp[(3) - (4)]));;} break; case 515: /* Line 1455 of yacc.c */ #line 2142 "hphp.y" { Token t1; _p->onArray(t1,(yyvsp[(1) - (2)])); Token t2; _p->onArray(t2,(yyvsp[(2) - (2)])); Token file; scalar_file(_p, file); Token line; scalar_line(_p, line); _p->onCallParam((yyvsp[(1) - (2)]),NULL,t1,0,0); _p->onCallParam((yyval), &(yyvsp[(1) - (2)]),t2,0,0); _p->onCallParam((yyvsp[(1) - (2)]), &(yyvsp[(1) - (2)]),file,0,0); _p->onCallParam((yyvsp[(1) - (2)]), &(yyvsp[(1) - (2)]),line,0,0); (yyval).setText("");;} break; case 516: /* Line 1455 of yacc.c */ #line 2153 "hphp.y" { Token file; scalar_file(_p, file); Token line; scalar_line(_p, line); _p->onArray((yyvsp[(4) - (6)]),(yyvsp[(1) - (6)])); _p->onArray((yyvsp[(5) - (6)]),(yyvsp[(3) - (6)])); _p->onCallParam((yyvsp[(2) - (6)]),NULL,(yyvsp[(4) - (6)]),0,0); _p->onCallParam((yyval), &(yyvsp[(2) - (6)]),(yyvsp[(5) - (6)]),0,0); _p->onCallParam((yyvsp[(2) - (6)]), &(yyvsp[(2) - (6)]),file,0,0); _p->onCallParam((yyvsp[(2) - (6)]), &(yyvsp[(2) - (6)]),line,0,0); (yyval).setText((yyvsp[(6) - (6)]).text());;} break; case 517: /* Line 1455 of yacc.c */ #line 2164 "hphp.y" { (yyval).reset(); (yyval).setText("");;} break; case 518: /* Line 1455 of yacc.c */ #line 2165 "hphp.y" { (yyval).reset(); (yyval).setText((yyvsp[(1) - (1)]));;} break; case 519: /* Line 1455 of yacc.c */ #line 2170 "hphp.y" { _p->onArrayPair((yyval),&(yyvsp[(1) - (4)]),&(yyvsp[(2) - (4)]),(yyvsp[(4) - (4)]),0);;} break; case 520: /* Line 1455 of yacc.c */ #line 2171 "hphp.y" { (yyval).reset();;} break; case 521: /* Line 1455 of yacc.c */ #line 2174 "hphp.y" { _p->onArrayPair((yyval),&(yyvsp[(1) - (2)]),0,(yyvsp[(2) - (2)]),0);;} break; case 522: /* Line 1455 of yacc.c */ #line 2175 "hphp.y" { (yyval).reset();;} break; case 523: /* Line 1455 of yacc.c */ #line 2178 "hphp.y" { _p->onScalar((yyval), T_CONSTANT_ENCAPSED_STRING, (yyvsp[(1) - (1)]));;} break; case 524: /* Line 1455 of yacc.c */ #line 2182 "hphp.y" { (yyvsp[(1) - (1)]).xhpDecode(); _p->onScalar((yyval), T_CONSTANT_ENCAPSED_STRING, (yyvsp[(1) - (1)]));;} break; case 525: /* Line 1455 of yacc.c */ #line 2185 "hphp.y" { (yyval) = (yyvsp[(2) - (3)]);;} break; case 526: /* Line 1455 of yacc.c */ #line 2188 "hphp.y" { (yyval).reset(); if ((yyvsp[(1) - (1)]).htmlTrim()) { (yyvsp[(1) - (1)]).xhpDecode(); _p->onScalar((yyval), T_CONSTANT_ENCAPSED_STRING, (yyvsp[(1) - (1)])); } ;} break; case 527: /* Line 1455 of yacc.c */ #line 2195 "hphp.y" { (yyval) = (yyvsp[(2) - (3)]); ;} break; case 528: /* Line 1455 of yacc.c */ #line 2196 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]); ;} break; case 529: /* Line 1455 of yacc.c */ #line 2200 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 530: /* Line 1455 of yacc.c */ #line 2202 "hphp.y" { (yyval) = (yyvsp[(1) - (3)]) + ":" + (yyvsp[(3) - (3)]);;} break; case 531: /* Line 1455 of yacc.c */ #line 2204 "hphp.y" { (yyval) = (yyvsp[(1) - (3)]) + "-" + (yyvsp[(3) - (3)]);;} break; case 532: /* Line 1455 of yacc.c */ #line 2207 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 533: /* Line 1455 of yacc.c */ #line 2208 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 534: /* Line 1455 of yacc.c */ #line 2209 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 535: /* Line 1455 of yacc.c */ #line 2210 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 536: /* Line 1455 of yacc.c */ #line 2211 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 537: /* Line 1455 of yacc.c */ #line 2212 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 538: /* Line 1455 of yacc.c */ #line 2213 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 539: /* Line 1455 of yacc.c */ #line 2214 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 540: /* Line 1455 of yacc.c */ #line 2215 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 541: /* Line 1455 of yacc.c */ #line 2216 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 542: /* Line 1455 of yacc.c */ #line 2217 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 543: /* Line 1455 of yacc.c */ #line 2218 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 544: /* Line 1455 of yacc.c */ #line 2219 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 545: /* Line 1455 of yacc.c */ #line 2220 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 546: /* Line 1455 of yacc.c */ #line 2221 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 547: /* Line 1455 of yacc.c */ #line 2222 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 548: /* Line 1455 of yacc.c */ #line 2223 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 549: /* Line 1455 of yacc.c */ #line 2224 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 550: /* Line 1455 of yacc.c */ #line 2225 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 551: /* Line 1455 of yacc.c */ #line 2226 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 552: /* Line 1455 of yacc.c */ #line 2227 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 553: /* Line 1455 of yacc.c */ #line 2228 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 554: /* Line 1455 of yacc.c */ #line 2229 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 555: /* Line 1455 of yacc.c */ #line 2230 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 556: /* Line 1455 of yacc.c */ #line 2231 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 557: /* Line 1455 of yacc.c */ #line 2232 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 558: /* Line 1455 of yacc.c */ #line 2233 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 559: /* Line 1455 of yacc.c */ #line 2234 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 560: /* Line 1455 of yacc.c */ #line 2235 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 561: /* Line 1455 of yacc.c */ #line 2236 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 562: /* Line 1455 of yacc.c */ #line 2237 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 563: /* Line 1455 of yacc.c */ #line 2238 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 564: /* Line 1455 of yacc.c */ #line 2239 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 565: /* Line 1455 of yacc.c */ #line 2240 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 566: /* Line 1455 of yacc.c */ #line 2241 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 567: /* Line 1455 of yacc.c */ #line 2242 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 568: /* Line 1455 of yacc.c */ #line 2243 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 569: /* Line 1455 of yacc.c */ #line 2244 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 570: /* Line 1455 of yacc.c */ #line 2245 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 571: /* Line 1455 of yacc.c */ #line 2246 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 572: /* Line 1455 of yacc.c */ #line 2247 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 573: /* Line 1455 of yacc.c */ #line 2248 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 574: /* Line 1455 of yacc.c */ #line 2249 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 575: /* Line 1455 of yacc.c */ #line 2250 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 576: /* Line 1455 of yacc.c */ #line 2251 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 577: /* Line 1455 of yacc.c */ #line 2252 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 578: /* Line 1455 of yacc.c */ #line 2253 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 579: /* Line 1455 of yacc.c */ #line 2254 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 580: /* Line 1455 of yacc.c */ #line 2255 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 581: /* Line 1455 of yacc.c */ #line 2256 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 582: /* Line 1455 of yacc.c */ #line 2257 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 583: /* Line 1455 of yacc.c */ #line 2258 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 584: /* Line 1455 of yacc.c */ #line 2259 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 585: /* Line 1455 of yacc.c */ #line 2260 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 586: /* Line 1455 of yacc.c */ #line 2261 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 587: /* Line 1455 of yacc.c */ #line 2262 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 588: /* Line 1455 of yacc.c */ #line 2263 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 589: /* Line 1455 of yacc.c */ #line 2264 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 590: /* Line 1455 of yacc.c */ #line 2265 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 591: /* Line 1455 of yacc.c */ #line 2266 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 592: /* Line 1455 of yacc.c */ #line 2267 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 593: /* Line 1455 of yacc.c */ #line 2268 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 594: /* Line 1455 of yacc.c */ #line 2269 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 595: /* Line 1455 of yacc.c */ #line 2270 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 596: /* Line 1455 of yacc.c */ #line 2271 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 597: /* Line 1455 of yacc.c */ #line 2272 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 598: /* Line 1455 of yacc.c */ #line 2273 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 599: /* Line 1455 of yacc.c */ #line 2274 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 600: /* Line 1455 of yacc.c */ #line 2275 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 601: /* Line 1455 of yacc.c */ #line 2276 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 602: /* Line 1455 of yacc.c */ #line 2277 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 603: /* Line 1455 of yacc.c */ #line 2278 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 604: /* Line 1455 of yacc.c */ #line 2279 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 605: /* Line 1455 of yacc.c */ #line 2280 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 606: /* Line 1455 of yacc.c */ #line 2281 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 607: /* Line 1455 of yacc.c */ #line 2282 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 608: /* Line 1455 of yacc.c */ #line 2283 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 609: /* Line 1455 of yacc.c */ #line 2284 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 610: /* Line 1455 of yacc.c */ #line 2285 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 611: /* Line 1455 of yacc.c */ #line 2286 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 612: /* Line 1455 of yacc.c */ #line 2291 "hphp.y" { _p->onCall((yyval),0,(yyvsp[(1) - (4)]),(yyvsp[(3) - (4)]),NULL);;} break; case 613: /* Line 1455 of yacc.c */ #line 2295 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 614: /* Line 1455 of yacc.c */ #line 2296 "hphp.y" { (yyvsp[(1) - (1)]).xhpLabel(); (yyval) = (yyvsp[(1) - (1)]);;} break; case 615: /* Line 1455 of yacc.c */ #line 2299 "hphp.y" { _p->onName((yyval),(yyvsp[(1) - (1)]),Parser::StringName);;} break; case 616: /* Line 1455 of yacc.c */ #line 2300 "hphp.y" { _p->onName((yyval),(yyvsp[(1) - (1)]),Parser::StaticName);;} break; case 617: /* Line 1455 of yacc.c */ #line 2301 "hphp.y" { _p->onName((yyval),(yyvsp[(1) - (1)]), Parser::StaticClassExprName);;} break; case 618: /* Line 1455 of yacc.c */ #line 2305 "hphp.y" { _p->onName((yyval),(yyvsp[(1) - (1)]),Parser::StringName);;} break; case 619: /* Line 1455 of yacc.c */ #line 2306 "hphp.y" { _p->onName((yyval),(yyvsp[(1) - (1)]),Parser::StaticName);;} break; case 620: /* Line 1455 of yacc.c */ #line 2307 "hphp.y" { _p->onName((yyval),(yyvsp[(1) - (1)]),Parser::ExprName);;} break; case 621: /* Line 1455 of yacc.c */ #line 2311 "hphp.y" { (yyval).reset();;} break; case 622: /* Line 1455 of yacc.c */ #line 2312 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 623: /* Line 1455 of yacc.c */ #line 2313 "hphp.y" { (yyval).reset();;} break; case 624: /* Line 1455 of yacc.c */ #line 2317 "hphp.y" { (yyval).reset();;} break; case 625: /* Line 1455 of yacc.c */ #line 2318 "hphp.y" { _p->addEncap((yyval), NULL, (yyvsp[(1) - (1)]), 0);;} break; case 626: /* Line 1455 of yacc.c */ #line 2319 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 627: /* Line 1455 of yacc.c */ #line 2323 "hphp.y" { (yyval) = (yyvsp[(2) - (3)]);;} break; case 628: /* Line 1455 of yacc.c */ #line 2324 "hphp.y" { (yyval).reset();;} break; case 629: /* Line 1455 of yacc.c */ #line 2328 "hphp.y" { _p->onScalar((yyval), T_LNUMBER, (yyvsp[(1) - (1)]));;} break; case 630: /* Line 1455 of yacc.c */ #line 2329 "hphp.y" { _p->onScalar((yyval), T_DNUMBER, (yyvsp[(1) - (1)]));;} break; case 631: /* Line 1455 of yacc.c */ #line 2330 "hphp.y" { _p->onScalar((yyval), T_ONUMBER, (yyvsp[(1) - (1)]));;} break; case 632: /* Line 1455 of yacc.c */ #line 2331 "hphp.y" { _p->onScalar((yyval), T_CONSTANT_ENCAPSED_STRING, (yyvsp[(1) - (1)]));;} break; case 633: /* Line 1455 of yacc.c */ #line 2333 "hphp.y" { _p->onScalar((yyval), T_LINE, (yyvsp[(1) - (1)]));;} break; case 634: /* Line 1455 of yacc.c */ #line 2334 "hphp.y" { _p->onScalar((yyval), T_FILE, (yyvsp[(1) - (1)]));;} break; case 635: /* Line 1455 of yacc.c */ #line 2335 "hphp.y" { _p->onScalar((yyval), T_DIR, (yyvsp[(1) - (1)]));;} break; case 636: /* Line 1455 of yacc.c */ #line 2336 "hphp.y" { _p->onScalar((yyval), T_CLASS_C, (yyvsp[(1) - (1)]));;} break; case 637: /* Line 1455 of yacc.c */ #line 2337 "hphp.y" { _p->onScalar((yyval), T_TRAIT_C, (yyvsp[(1) - (1)]));;} break; case 638: /* Line 1455 of yacc.c */ #line 2338 "hphp.y" { _p->onScalar((yyval), T_METHOD_C, (yyvsp[(1) - (1)]));;} break; case 639: /* Line 1455 of yacc.c */ #line 2339 "hphp.y" { _p->onScalar((yyval), T_FUNC_C, (yyvsp[(1) - (1)]));;} break; case 640: /* Line 1455 of yacc.c */ #line 2340 "hphp.y" { _p->onScalar((yyval), T_NS_C, (yyvsp[(1) - (1)]));;} break; case 641: /* Line 1455 of yacc.c */ #line 2341 "hphp.y" { _p->onScalar((yyval), T_COMPILER_HALT_OFFSET, (yyvsp[(1) - (1)]));;} break; case 642: /* Line 1455 of yacc.c */ #line 2344 "hphp.y" { _p->onScalar((yyval), T_CONSTANT_ENCAPSED_STRING, (yyvsp[(2) - (3)]));;} break; case 643: /* Line 1455 of yacc.c */ #line 2346 "hphp.y" { (yyval).setText(""); _p->onScalar((yyval), T_CONSTANT_ENCAPSED_STRING, (yyval));;} break; case 644: /* Line 1455 of yacc.c */ #line 2350 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 645: /* Line 1455 of yacc.c */ #line 2351 "hphp.y" { _p->onConstantValue((yyval), (yyvsp[(1) - (1)]));;} break; case 646: /* Line 1455 of yacc.c */ #line 2353 "hphp.y" { _p->onArray((yyval),(yyvsp[(3) - (4)]),T_ARRAY); ;} break; case 647: /* Line 1455 of yacc.c */ #line 2354 "hphp.y" { _p->onArray((yyval),(yyvsp[(2) - (3)]),T_ARRAY); ;} break; case 648: /* Line 1455 of yacc.c */ #line 2356 "hphp.y" { _p->onArray((yyval),(yyvsp[(3) - (4)]),T_ARRAY); ;} break; case 649: /* Line 1455 of yacc.c */ #line 2357 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 650: /* Line 1455 of yacc.c */ #line 2358 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 651: /* Line 1455 of yacc.c */ #line 2359 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 652: /* Line 1455 of yacc.c */ #line 2360 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 653: /* Line 1455 of yacc.c */ #line 2361 "hphp.y" { (yyval) = (yyvsp[(2) - (3)]);;} break; case 654: /* Line 1455 of yacc.c */ #line 2363 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_BOOLEAN_OR);;} break; case 655: /* Line 1455 of yacc.c */ #line 2365 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_BOOLEAN_AND);;} break; case 656: /* Line 1455 of yacc.c */ #line 2367 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_LOGICAL_OR);;} break; case 657: /* Line 1455 of yacc.c */ #line 2369 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_LOGICAL_AND);;} break; case 658: /* Line 1455 of yacc.c */ #line 2371 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_LOGICAL_XOR);;} break; case 659: /* Line 1455 of yacc.c */ #line 2372 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'|');;} break; case 660: /* Line 1455 of yacc.c */ #line 2373 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'&');;} break; case 661: /* Line 1455 of yacc.c */ #line 2374 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'^');;} break; case 662: /* Line 1455 of yacc.c */ #line 2375 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'.');;} break; case 663: /* Line 1455 of yacc.c */ #line 2376 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'+');;} break; case 664: /* Line 1455 of yacc.c */ #line 2377 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'-');;} break; case 665: /* Line 1455 of yacc.c */ #line 2378 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'*');;} break; case 666: /* Line 1455 of yacc.c */ #line 2379 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'/');;} break; case 667: /* Line 1455 of yacc.c */ #line 2380 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'%');;} break; case 668: /* Line 1455 of yacc.c */ #line 2381 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_SL);;} break; case 669: /* Line 1455 of yacc.c */ #line 2382 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_SR);;} break; case 670: /* Line 1455 of yacc.c */ #line 2383 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_POW);;} break; case 671: /* Line 1455 of yacc.c */ #line 2384 "hphp.y" { UEXP((yyval),(yyvsp[(2) - (2)]),'!',1);;} break; case 672: /* Line 1455 of yacc.c */ #line 2385 "hphp.y" { UEXP((yyval),(yyvsp[(2) - (2)]),'~',1);;} break; case 673: /* Line 1455 of yacc.c */ #line 2386 "hphp.y" { UEXP((yyval),(yyvsp[(2) - (2)]),'+',1);;} break; case 674: /* Line 1455 of yacc.c */ #line 2387 "hphp.y" { UEXP((yyval),(yyvsp[(2) - (2)]),'-',1);;} break; case 675: /* Line 1455 of yacc.c */ #line 2389 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_IS_IDENTICAL);;} break; case 676: /* Line 1455 of yacc.c */ #line 2391 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_IS_NOT_IDENTICAL);;} break; case 677: /* Line 1455 of yacc.c */ #line 2393 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_IS_EQUAL);;} break; case 678: /* Line 1455 of yacc.c */ #line 2395 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_IS_NOT_EQUAL);;} break; case 679: /* Line 1455 of yacc.c */ #line 2396 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'<');;} break; case 680: /* Line 1455 of yacc.c */ #line 2398 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]), T_IS_SMALLER_OR_EQUAL);;} break; case 681: /* Line 1455 of yacc.c */ #line 2400 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'>');;} break; case 682: /* Line 1455 of yacc.c */ #line 2403 "hphp.y" { BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]), T_IS_GREATER_OR_EQUAL);;} break; case 683: /* Line 1455 of yacc.c */ #line 2406 "hphp.y" { _p->onQOp((yyval), (yyvsp[(1) - (5)]), &(yyvsp[(3) - (5)]), (yyvsp[(5) - (5)]));;} break; case 684: /* Line 1455 of yacc.c */ #line 2407 "hphp.y" { _p->onQOp((yyval), (yyvsp[(1) - (4)]), 0, (yyvsp[(4) - (4)]));;} break; case 685: /* Line 1455 of yacc.c */ #line 2413 "hphp.y" { _p->onClassConst((yyval), (yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), 1);;} break; case 686: /* Line 1455 of yacc.c */ #line 2415 "hphp.y" { (yyvsp[(1) - (3)]).xhpLabel(); _p->onClassConst((yyval), (yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), 1);;} break; case 687: /* Line 1455 of yacc.c */ #line 2419 "hphp.y" { _p->onClassClass((yyval), (yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), 1);;} break; case 688: /* Line 1455 of yacc.c */ #line 2423 "hphp.y" { _p->onConstantValue((yyval), (yyvsp[(1) - (1)]));;} break; case 689: /* Line 1455 of yacc.c */ #line 2424 "hphp.y" { _p->onConstantValue((yyval), (yyvsp[(1) - (1)]));;} break; case 690: /* Line 1455 of yacc.c */ #line 2425 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 691: /* Line 1455 of yacc.c */ #line 2426 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 692: /* Line 1455 of yacc.c */ #line 2427 "hphp.y" { _p->onEncapsList((yyval),'"',(yyvsp[(2) - (3)]));;} break; case 693: /* Line 1455 of yacc.c */ #line 2428 "hphp.y" { _p->onEncapsList((yyval),'\'',(yyvsp[(2) - (3)]));;} break; case 694: /* Line 1455 of yacc.c */ #line 2430 "hphp.y" { _p->onEncapsList((yyval),T_START_HEREDOC, (yyvsp[(2) - (3)]));;} break; case 695: /* Line 1455 of yacc.c */ #line 2435 "hphp.y" { (yyval) = (yyvsp[(1) - (2)]);;} break; case 696: /* Line 1455 of yacc.c */ #line 2436 "hphp.y" { (yyval).reset();;} break; case 697: /* Line 1455 of yacc.c */ #line 2440 "hphp.y" { (yyval).reset();;} break; case 698: /* Line 1455 of yacc.c */ #line 2441 "hphp.y" { (yyval).reset();;} break; case 699: /* Line 1455 of yacc.c */ #line 2444 "hphp.y" { only_in_hh_syntax(_p); (yyval).reset();;} break; case 700: /* Line 1455 of yacc.c */ #line 2445 "hphp.y" { (yyval).reset();;} break; case 701: /* Line 1455 of yacc.c */ #line 2451 "hphp.y" { _p->onArrayPair((yyval),&(yyvsp[(1) - (5)]),&(yyvsp[(3) - (5)]),(yyvsp[(5) - (5)]),0);;} break; case 702: /* Line 1455 of yacc.c */ #line 2453 "hphp.y" { _p->onArrayPair((yyval),&(yyvsp[(1) - (3)]), 0,(yyvsp[(3) - (3)]),0);;} break; case 703: /* Line 1455 of yacc.c */ #line 2455 "hphp.y" { _p->onArrayPair((yyval), 0,&(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),0);;} break; case 704: /* Line 1455 of yacc.c */ #line 2456 "hphp.y" { _p->onArrayPair((yyval), 0, 0,(yyvsp[(1) - (1)]),0);;} break; case 705: /* Line 1455 of yacc.c */ #line 2460 "hphp.y" { _p->onScalar((yyval), T_LNUMBER, (yyvsp[(1) - (1)]));;} break; case 706: /* Line 1455 of yacc.c */ #line 2461 "hphp.y" { _p->onScalar((yyval), T_DNUMBER, (yyvsp[(1) - (1)]));;} break; case 707: /* Line 1455 of yacc.c */ #line 2462 "hphp.y" { _p->onScalar((yyval), T_ONUMBER, (yyvsp[(1) - (1)]));;} break; case 708: /* Line 1455 of yacc.c */ #line 2463 "hphp.y" { _p->onScalar((yyval), T_CONSTANT_ENCAPSED_STRING, (yyvsp[(1) - (1)]));;} break; case 709: /* Line 1455 of yacc.c */ #line 2467 "hphp.y" { _p->onScalar((yyval), T_CONSTANT_ENCAPSED_STRING, (yyvsp[(2) - (3)]));;} break; case 710: /* Line 1455 of yacc.c */ #line 2469 "hphp.y" { (yyval).setText(""); _p->onScalar((yyval), T_CONSTANT_ENCAPSED_STRING, (yyval));;} break; case 711: /* Line 1455 of yacc.c */ #line 2472 "hphp.y" { _p->onScalar((yyval),T_LNUMBER,(yyvsp[(1) - (1)]));;} break; case 712: /* Line 1455 of yacc.c */ #line 2473 "hphp.y" { _p->onScalar((yyval),T_DNUMBER,(yyvsp[(1) - (1)]));;} break; case 713: /* Line 1455 of yacc.c */ #line 2474 "hphp.y" { _p->onScalar((yyval),T_ONUMBER,(yyvsp[(1) - (1)]));;} break; case 714: /* Line 1455 of yacc.c */ #line 2475 "hphp.y" { constant_ae(_p,(yyval),(yyvsp[(1) - (1)]));;} break; case 715: /* Line 1455 of yacc.c */ #line 2478 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 716: /* Line 1455 of yacc.c */ #line 2479 "hphp.y" { constant_ae(_p,(yyval),(yyvsp[(1) - (1)]));;} break; case 717: /* Line 1455 of yacc.c */ #line 2480 "hphp.y" { UEXP((yyval),(yyvsp[(2) - (2)]),'+',1);;} break; case 718: /* Line 1455 of yacc.c */ #line 2481 "hphp.y" { UEXP((yyval),(yyvsp[(2) - (2)]),'-',1);;} break; case 719: /* Line 1455 of yacc.c */ #line 2483 "hphp.y" { _p->onArray((yyval),(yyvsp[(3) - (4)]),T_ARRAY);;} break; case 720: /* Line 1455 of yacc.c */ #line 2484 "hphp.y" { _p->onArray((yyval),(yyvsp[(2) - (3)]),T_ARRAY);;} break; case 721: /* Line 1455 of yacc.c */ #line 2486 "hphp.y" { _p->onArray((yyval),(yyvsp[(3) - (4)]),T_ARRAY); ;} break; case 722: /* Line 1455 of yacc.c */ #line 2491 "hphp.y" { (yyval) = (yyvsp[(1) - (2)]);;} break; case 723: /* Line 1455 of yacc.c */ #line 2492 "hphp.y" { (yyval).reset();;} break; case 724: /* Line 1455 of yacc.c */ #line 2497 "hphp.y" { _p->onArrayPair((yyval),&(yyvsp[(1) - (5)]),&(yyvsp[(3) - (5)]),(yyvsp[(5) - (5)]),0);;} break; case 725: /* Line 1455 of yacc.c */ #line 2499 "hphp.y" { _p->onArrayPair((yyval),&(yyvsp[(1) - (3)]), 0,(yyvsp[(3) - (3)]),0);;} break; case 726: /* Line 1455 of yacc.c */ #line 2501 "hphp.y" { _p->onArrayPair((yyval), 0,&(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),0);;} break; case 727: /* Line 1455 of yacc.c */ #line 2502 "hphp.y" { _p->onArrayPair((yyval), 0, 0,(yyvsp[(1) - (1)]),0);;} break; case 728: /* Line 1455 of yacc.c */ #line 2506 "hphp.y" { _p->onArrayPair((yyval),&(yyvsp[(1) - (3)]), 0,(yyvsp[(3) - (3)]),0);;} break; case 729: /* Line 1455 of yacc.c */ #line 2507 "hphp.y" { _p->onArrayPair((yyval), 0, 0,(yyvsp[(1) - (1)]),0);;} break; case 730: /* Line 1455 of yacc.c */ #line 2512 "hphp.y" { (yyval) = (yyvsp[(1) - (2)]); ;} break; case 731: /* Line 1455 of yacc.c */ #line 2513 "hphp.y" { (yyval).reset(); ;} break; case 732: /* Line 1455 of yacc.c */ #line 2518 "hphp.y" { _p->onArrayPair((yyval),&(yyvsp[(1) - (5)]),&(yyvsp[(3) - (5)]),(yyvsp[(5) - (5)]),0); ;} break; case 733: /* Line 1455 of yacc.c */ #line 2521 "hphp.y" { _p->onArrayPair((yyval), 0,&(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),0); ;} break; case 734: /* Line 1455 of yacc.c */ #line 2526 "hphp.y" { (yyval) = (yyvsp[(1) - (2)]);;} break; case 735: /* Line 1455 of yacc.c */ #line 2527 "hphp.y" { (yyval).reset();;} break; case 736: /* Line 1455 of yacc.c */ #line 2530 "hphp.y" { _p->onArray((yyval),(yyvsp[(2) - (3)]),T_ARRAY);;} break; case 737: /* Line 1455 of yacc.c */ #line 2531 "hphp.y" { Token t; t.reset(); _p->onArray((yyval),t,T_ARRAY);;} break; case 738: /* Line 1455 of yacc.c */ #line 2538 "hphp.y" { _p->onUserAttribute((yyval),&(yyvsp[(1) - (4)]),(yyvsp[(3) - (4)]),(yyvsp[(4) - (4)]));;} break; case 739: /* Line 1455 of yacc.c */ #line 2540 "hphp.y" { _p->onUserAttribute((yyval), 0,(yyvsp[(1) - (2)]),(yyvsp[(2) - (2)]));;} break; case 740: /* Line 1455 of yacc.c */ #line 2543 "hphp.y" { only_in_hh_syntax(_p);;} break; case 741: /* Line 1455 of yacc.c */ #line 2545 "hphp.y" { (yyval) = (yyvsp[(2) - (3)]);;} break; case 742: /* Line 1455 of yacc.c */ #line 2548 "hphp.y" { (yyval) = (yyvsp[(2) - (3)]);;} break; case 743: /* Line 1455 of yacc.c */ #line 2551 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 744: /* Line 1455 of yacc.c */ #line 2552 "hphp.y" { (yyval).reset();;} break; case 745: /* Line 1455 of yacc.c */ #line 2556 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 746: /* Line 1455 of yacc.c */ #line 2558 "hphp.y" { (yyval) = (yyvsp[(2) - (2)]);;} break; case 747: /* Line 1455 of yacc.c */ #line 2562 "hphp.y" { (yyval) = (yyvsp[(2) - (2)]);;} break; case 748: /* Line 1455 of yacc.c */ #line 2563 "hphp.y" { (yyval) = (yyvsp[(3) - (4)]);;} break; case 749: /* Line 1455 of yacc.c */ #line 2567 "hphp.y" { (yyval) = (yyvsp[(2) - (3)]);;} break; case 750: /* Line 1455 of yacc.c */ #line 2568 "hphp.y" { (yyval) = (yyvsp[(2) - (3)]);;} break; case 751: /* Line 1455 of yacc.c */ #line 2572 "hphp.y" { _p->onRefDim((yyval), (yyvsp[(1) - (2)]), (yyvsp[(2) - (2)]));;} break; case 752: /* Line 1455 of yacc.c */ #line 2574 "hphp.y" { _p->onRefDim((yyval), (yyvsp[(2) - (4)]), (yyvsp[(4) - (4)]));;} break; case 753: /* Line 1455 of yacc.c */ #line 2579 "hphp.y" { _p->onRefDim((yyval), (yyvsp[(1) - (2)]), (yyvsp[(2) - (2)]));;} break; case 754: /* Line 1455 of yacc.c */ #line 2581 "hphp.y" { _p->onRefDim((yyval), (yyvsp[(2) - (4)]), (yyvsp[(4) - (4)]));;} break; case 755: /* Line 1455 of yacc.c */ #line 2585 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 756: /* Line 1455 of yacc.c */ #line 2586 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 757: /* Line 1455 of yacc.c */ #line 2587 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 758: /* Line 1455 of yacc.c */ #line 2588 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 759: /* Line 1455 of yacc.c */ #line 2589 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 760: /* Line 1455 of yacc.c */ #line 2590 "hphp.y" { _p->onObjectProperty((yyval),(yyvsp[(1) - (2)]),(yyvsp[(2) - (2)]));;} break; case 761: /* Line 1455 of yacc.c */ #line 2592 "hphp.y" { _p->onObjectProperty((yyval),(yyvsp[(2) - (4)]),(yyvsp[(4) - (4)]));;} break; case 762: /* Line 1455 of yacc.c */ #line 2595 "hphp.y" { _p->onStaticMember((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]));;} break; case 763: /* Line 1455 of yacc.c */ #line 2597 "hphp.y" { _p->onCall((yyval),1,(yyvsp[(1) - (4)]),(yyvsp[(3) - (4)]),NULL);;} break; case 764: /* Line 1455 of yacc.c */ #line 2598 "hphp.y" { (yyval) = (yyvsp[(2) - (3)]);;} break; case 765: /* Line 1455 of yacc.c */ #line 2602 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 766: /* Line 1455 of yacc.c */ #line 2603 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 767: /* Line 1455 of yacc.c */ #line 2604 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 768: /* Line 1455 of yacc.c */ #line 2605 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 769: /* Line 1455 of yacc.c */ #line 2607 "hphp.y" { _p->onObjectProperty((yyval),(yyvsp[(1) - (2)]),(yyvsp[(2) - (2)]));;} break; case 770: /* Line 1455 of yacc.c */ #line 2609 "hphp.y" { _p->onObjectProperty((yyval),(yyvsp[(2) - (4)]),(yyvsp[(4) - (4)]));;} break; case 771: /* Line 1455 of yacc.c */ #line 2611 "hphp.y" { _p->onCall((yyval),1,(yyvsp[(1) - (4)]),(yyvsp[(3) - (4)]),NULL);;} break; case 772: /* Line 1455 of yacc.c */ #line 2612 "hphp.y" { (yyval) = (yyvsp[(2) - (3)]);;} break; case 773: /* Line 1455 of yacc.c */ #line 2616 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 774: /* Line 1455 of yacc.c */ #line 2617 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 775: /* Line 1455 of yacc.c */ #line 2618 "hphp.y" { (yyval) = (yyvsp[(2) - (3)]);;} break; case 776: /* Line 1455 of yacc.c */ #line 2624 "hphp.y" { _p->onObjectMethodCall((yyval),(yyvsp[(1) - (7)]),(yyvsp[(3) - (7)]),(yyvsp[(6) - (7)]));;} break; case 777: /* Line 1455 of yacc.c */ #line 2627 "hphp.y" { _p->onObjectMethodCall((yyval),(yyvsp[(1) - (6)]),(yyvsp[(3) - (6)]),(yyvsp[(5) - (6)]));;} break; case 778: /* Line 1455 of yacc.c */ #line 2630 "hphp.y" { _p->onObjectMethodCall((yyval),(yyvsp[(1) - (8)]),(yyvsp[(4) - (8)]),(yyvsp[(7) - (8)]));;} break; case 779: /* Line 1455 of yacc.c */ #line 2634 "hphp.y" { _p->onObjectMethodCall((yyval),(yyvsp[(2) - (9)]),(yyvsp[(5) - (9)]),(yyvsp[(8) - (9)]));;} break; case 780: /* Line 1455 of yacc.c */ #line 2638 "hphp.y" { _p->onObjectMethodCall((yyval),(yyvsp[(2) - (8)]),(yyvsp[(5) - (8)]),(yyvsp[(7) - (8)]));;} break; case 781: /* Line 1455 of yacc.c */ #line 2642 "hphp.y" { _p->onObjectMethodCall((yyval),(yyvsp[(2) - (10)]),(yyvsp[(6) - (10)]),(yyvsp[(9) - (10)]));;} break; case 782: /* Line 1455 of yacc.c */ #line 2649 "hphp.y" { _p->onCall((yyval),0,(yyvsp[(3) - (7)]),(yyvsp[(6) - (7)]),&(yyvsp[(1) - (7)]));;} break; case 783: /* Line 1455 of yacc.c */ #line 2653 "hphp.y" { _p->onCall((yyval),1,(yyvsp[(3) - (6)]),(yyvsp[(5) - (6)]),&(yyvsp[(1) - (6)]));;} break; case 784: /* Line 1455 of yacc.c */ #line 2657 "hphp.y" { _p->onCall((yyval),1,(yyvsp[(4) - (8)]),(yyvsp[(7) - (8)]),&(yyvsp[(1) - (8)]));;} break; case 785: /* Line 1455 of yacc.c */ #line 2661 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 786: /* Line 1455 of yacc.c */ #line 2663 "hphp.y" { _p->onIndirectRef((yyval),(yyvsp[(1) - (2)]),(yyvsp[(2) - (2)]));;} break; case 787: /* Line 1455 of yacc.c */ #line 2668 "hphp.y" { _p->onRefDim((yyval), (yyvsp[(1) - (4)]), (yyvsp[(3) - (4)]));;} break; case 788: /* Line 1455 of yacc.c */ #line 2669 "hphp.y" { _p->onRefDim((yyval), (yyvsp[(1) - (4)]), (yyvsp[(3) - (4)]));;} break; case 789: /* Line 1455 of yacc.c */ #line 2670 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 790: /* Line 1455 of yacc.c */ #line 2673 "hphp.y" { _p->onSimpleVariable((yyval), (yyvsp[(1) - (1)]));;} break; case 791: /* Line 1455 of yacc.c */ #line 2674 "hphp.y" { _p->onDynamicVariable((yyval), (yyvsp[(3) - (4)]), 0);;} break; case 792: /* Line 1455 of yacc.c */ #line 2677 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 793: /* Line 1455 of yacc.c */ #line 2678 "hphp.y" { (yyval).reset();;} break; case 794: /* Line 1455 of yacc.c */ #line 2682 "hphp.y" { (yyval) = 1;;} break; case 795: /* Line 1455 of yacc.c */ #line 2683 "hphp.y" { (yyval)++;;} break; case 796: /* Line 1455 of yacc.c */ #line 2687 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 797: /* Line 1455 of yacc.c */ #line 2688 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 798: /* Line 1455 of yacc.c */ #line 2689 "hphp.y" { _p->onObjectProperty((yyval),(yyvsp[(1) - (2)]),(yyvsp[(2) - (2)]));;} break; case 799: /* Line 1455 of yacc.c */ #line 2691 "hphp.y" { _p->onObjectProperty((yyval),(yyvsp[(2) - (4)]),(yyvsp[(4) - (4)]));;} break; case 800: /* Line 1455 of yacc.c */ #line 2694 "hphp.y" { _p->onStaticMember((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]));;} break; case 801: /* Line 1455 of yacc.c */ #line 2695 "hphp.y" { (yyval) = (yyvsp[(2) - (3)]);;} break; case 803: /* Line 1455 of yacc.c */ #line 2699 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]);;} break; case 804: /* Line 1455 of yacc.c */ #line 2701 "hphp.y" { _p->onObjectProperty((yyval),(yyvsp[(1) - (2)]),(yyvsp[(2) - (2)]));;} break; case 805: /* Line 1455 of yacc.c */ #line 2703 "hphp.y" { _p->onObjectProperty((yyval),(yyvsp[(2) - (4)]),(yyvsp[(4) - (4)]));;} break; case 806: /* Line 1455 of yacc.c */ #line 2704 "hphp.y" { (yyval) = (yyvsp[(2) - (3)]);;} break; case 807: /* Line 1455 of yacc.c */ #line 2708 "hphp.y" { _p->onAListVar((yyval),&(yyvsp[(1) - (2)]),NULL);;} break; case 808: /* Line 1455 of yacc.c */ #line 2709 "hphp.y" { _p->onAListVar((yyval),&(yyvsp[(1) - (3)]),&(yyvsp[(3) - (3)]));;} break; case 809: /* Line 1455 of yacc.c */ #line 2711 "hphp.y" { _p->onAListSub((yyval),&(yyvsp[(1) - (6)]),(yyvsp[(5) - (6)]));;} break; case 810: /* Line 1455 of yacc.c */ #line 2712 "hphp.y" { _p->onAListVar((yyval),NULL,NULL);;} break; case 811: /* Line 1455 of yacc.c */ #line 2713 "hphp.y" { _p->onAListVar((yyval),NULL,&(yyvsp[(1) - (1)]));;} break; case 812: /* Line 1455 of yacc.c */ #line 2714 "hphp.y" { _p->onAListSub((yyval),NULL,(yyvsp[(3) - (4)]));;} break; case 813: /* Line 1455 of yacc.c */ #line 2719 "hphp.y" { (yyval) = (yyvsp[(1) - (2)]);;} break; case 814: /* Line 1455 of yacc.c */ #line 2720 "hphp.y" { (yyval).reset();;} break; case 815: /* Line 1455 of yacc.c */ #line 2724 "hphp.y" { _p->onArrayPair((yyval),&(yyvsp[(1) - (5)]),&(yyvsp[(3) - (5)]),(yyvsp[(5) - (5)]),0);;} break; case 816: /* Line 1455 of yacc.c */ #line 2725 "hphp.y" { _p->onArrayPair((yyval),&(yyvsp[(1) - (3)]), 0,(yyvsp[(3) - (3)]),0);;} break; case 817: /* Line 1455 of yacc.c */ #line 2726 "hphp.y" { _p->onArrayPair((yyval), 0,&(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),0);;} break; case 818: /* Line 1455 of yacc.c */ #line 2727 "hphp.y" { _p->onArrayPair((yyval), 0, 0,(yyvsp[(1) - (1)]),0);;} break; case 819: /* Line 1455 of yacc.c */ #line 2730 "hphp.y" { _p->onArrayPair((yyval),&(yyvsp[(1) - (6)]),&(yyvsp[(3) - (6)]),(yyvsp[(6) - (6)]),1);;} break; case 820: /* Line 1455 of yacc.c */ #line 2732 "hphp.y" { _p->onArrayPair((yyval),&(yyvsp[(1) - (4)]), 0,(yyvsp[(4) - (4)]),1);;} break; case 821: /* Line 1455 of yacc.c */ #line 2733 "hphp.y" { _p->onArrayPair((yyval), 0,&(yyvsp[(1) - (4)]),(yyvsp[(4) - (4)]),1);;} break; case 822: /* Line 1455 of yacc.c */ #line 2734 "hphp.y" { _p->onArrayPair((yyval), 0, 0,(yyvsp[(2) - (2)]),1);;} break; case 823: /* Line 1455 of yacc.c */ #line 2739 "hphp.y" { (yyval) = (yyvsp[(1) - (2)]);;} break; case 824: /* Line 1455 of yacc.c */ #line 2740 "hphp.y" { _p->onEmptyCollection((yyval));;} break; case 825: /* Line 1455 of yacc.c */ #line 2744 "hphp.y" { _p->onCollectionPair((yyval),&(yyvsp[(1) - (5)]),&(yyvsp[(3) - (5)]),(yyvsp[(5) - (5)]));;} break; case 826: /* Line 1455 of yacc.c */ #line 2745 "hphp.y" { _p->onCollectionPair((yyval),&(yyvsp[(1) - (3)]), 0,(yyvsp[(3) - (3)]));;} break; case 827: /* Line 1455 of yacc.c */ #line 2746 "hphp.y" { _p->onCollectionPair((yyval), 0,&(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]));;} break; case 828: /* Line 1455 of yacc.c */ #line 2747 "hphp.y" { _p->onCollectionPair((yyval), 0, 0,(yyvsp[(1) - (1)]));;} break; case 829: /* Line 1455 of yacc.c */ #line 2752 "hphp.y" { (yyval) = (yyvsp[(1) - (2)]);;} break; case 830: /* Line 1455 of yacc.c */ #line 2753 "hphp.y" { _p->onEmptyCollection((yyval));;} break; case 831: /* Line 1455 of yacc.c */ #line 2758 "hphp.y" { _p->onCollectionPair((yyval),&(yyvsp[(1) - (5)]),&(yyvsp[(3) - (5)]),(yyvsp[(5) - (5)]));;} break; case 832: /* Line 1455 of yacc.c */ #line 2760 "hphp.y" { _p->onCollectionPair((yyval),&(yyvsp[(1) - (3)]), 0,(yyvsp[(3) - (3)]));;} break; case 833: /* Line 1455 of yacc.c */ #line 2762 "hphp.y" { _p->onCollectionPair((yyval), 0,&(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]));;} break; case 834: /* Line 1455 of yacc.c */ #line 2763 "hphp.y" { _p->onCollectionPair((yyval), 0, 0,(yyvsp[(1) - (1)]));;} break; case 835: /* Line 1455 of yacc.c */ #line 2768 "hphp.y" { (yyval) = (yyvsp[(1) - (2)]);;} break; case 836: /* Line 1455 of yacc.c */ #line 2769 "hphp.y" { _p->onEmptyCheckedArray((yyval));;} break; case 837: /* Line 1455 of yacc.c */ #line 2773 "hphp.y" { (yyval) = (yyvsp[(1) - (2)]);;} break; case 838: /* Line 1455 of yacc.c */ #line 2774 "hphp.y" { _p->onEmptyCheckedArray((yyval));;} break; case 839: /* Line 1455 of yacc.c */ #line 2778 "hphp.y" { _p->onCheckedArrayPair((yyval),&(yyvsp[(1) - (5)]),&(yyvsp[(3) - (5)]),(yyvsp[(5) - (5)]));;} break; case 840: /* Line 1455 of yacc.c */ #line 2779 "hphp.y" { _p->onCheckedArrayPair((yyval), 0,&(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]));;} break; case 841: /* Line 1455 of yacc.c */ #line 2782 "hphp.y" { _p->onCheckedArrayPair((yyval),&(yyvsp[(1) - (3)]), 0,(yyvsp[(3) - (3)]));;} break; case 842: /* Line 1455 of yacc.c */ #line 2783 "hphp.y" { _p->onCheckedArrayPair((yyval), 0, 0,(yyvsp[(1) - (1)]));;} break; case 843: /* Line 1455 of yacc.c */ #line 2788 "hphp.y" { (yyval) = (yyvsp[(1) - (2)]);;} break; case 844: /* Line 1455 of yacc.c */ #line 2789 "hphp.y" { _p->onEmptyCheckedArray((yyval));;} break; case 845: /* Line 1455 of yacc.c */ #line 2793 "hphp.y" { (yyval) = (yyvsp[(1) - (2)]);;} break; case 846: /* Line 1455 of yacc.c */ #line 2794 "hphp.y" { _p->onEmptyCheckedArray((yyval));;} break; case 847: /* Line 1455 of yacc.c */ #line 2799 "hphp.y" { _p->onCheckedArrayPair((yyval),&(yyvsp[(1) - (5)]),&(yyvsp[(3) - (5)]),(yyvsp[(5) - (5)]));;} break; case 848: /* Line 1455 of yacc.c */ #line 2801 "hphp.y" { _p->onCheckedArrayPair((yyval), 0,&(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]));;} break; case 849: /* Line 1455 of yacc.c */ #line 2805 "hphp.y" { _p->onCheckedArrayPair((yyval),&(yyvsp[(1) - (3)]), 0,(yyvsp[(3) - (3)]));;} break; case 850: /* Line 1455 of yacc.c */ #line 2806 "hphp.y" { _p->onCheckedArrayPair((yyval), 0, 0,(yyvsp[(1) - (1)]));;} break; case 851: /* Line 1455 of yacc.c */ #line 2810 "hphp.y" { _p->addEncap((yyval), &(yyvsp[(1) - (2)]), (yyvsp[(2) - (2)]), -1);;} break; case 852: /* Line 1455 of yacc.c */ #line 2812 "hphp.y" { _p->addEncap((yyval), &(yyvsp[(1) - (2)]), (yyvsp[(2) - (2)]), 0);;} break; case 853: /* Line 1455 of yacc.c */ #line 2813 "hphp.y" { _p->addEncap((yyval), NULL, (yyvsp[(1) - (1)]), -1);;} break; case 854: /* Line 1455 of yacc.c */ #line 2815 "hphp.y" { _p->addEncap((yyval), NULL, (yyvsp[(1) - (2)]), 0); _p->addEncap((yyval), &(yyval), (yyvsp[(2) - (2)]), -1); ;} break; case 855: /* Line 1455 of yacc.c */ #line 2820 "hphp.y" { _p->onSimpleVariable((yyval), (yyvsp[(1) - (1)]));;} break; case 856: /* Line 1455 of yacc.c */ #line 2822 "hphp.y" { _p->encapRefDim((yyval), (yyvsp[(1) - (4)]), (yyvsp[(3) - (4)]));;} break; case 857: /* Line 1455 of yacc.c */ #line 2824 "hphp.y" { _p->encapObjProp((yyval), (yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]));;} break; case 858: /* Line 1455 of yacc.c */ #line 2826 "hphp.y" { _p->onDynamicVariable((yyval), (yyvsp[(2) - (3)]), 1);;} break; case 859: /* Line 1455 of yacc.c */ #line 2828 "hphp.y" { _p->encapArray((yyval), (yyvsp[(2) - (6)]), (yyvsp[(4) - (6)]));;} break; case 860: /* Line 1455 of yacc.c */ #line 2829 "hphp.y" { (yyval) = (yyvsp[(2) - (3)]);;} break; case 861: /* Line 1455 of yacc.c */ #line 2832 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]); (yyval) = T_STRING;;} break; case 862: /* Line 1455 of yacc.c */ #line 2833 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]); (yyval) = T_NUM_STRING;;} break; case 863: /* Line 1455 of yacc.c */ #line 2834 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]); (yyval) = T_VARIABLE;;} break; case 864: /* Line 1455 of yacc.c */ #line 2838 "hphp.y" { UEXP((yyval),(yyvsp[(3) - (4)]),T_ISSET,1);;} break; case 865: /* Line 1455 of yacc.c */ #line 2839 "hphp.y" { UEXP((yyval),(yyvsp[(3) - (4)]),T_EMPTY,1);;} break; case 866: /* Line 1455 of yacc.c */ #line 2840 "hphp.y" { UEXP((yyval),(yyvsp[(3) - (4)]),'!',1);;} break; case 867: /* Line 1455 of yacc.c */ #line 2841 "hphp.y" { UEXP((yyval),(yyvsp[(3) - (4)]),'!',1);;} break; case 868: /* Line 1455 of yacc.c */ #line 2842 "hphp.y" { UEXP((yyval),(yyvsp[(2) - (2)]),T_INCLUDE,1);;} break; case 869: /* Line 1455 of yacc.c */ #line 2843 "hphp.y" { UEXP((yyval),(yyvsp[(2) - (2)]),T_INCLUDE_ONCE,1);;} break; case 870: /* Line 1455 of yacc.c */ #line 2844 "hphp.y" { UEXP((yyval),(yyvsp[(3) - (4)]),T_EVAL,1);;} break; case 871: /* Line 1455 of yacc.c */ #line 2845 "hphp.y" { UEXP((yyval),(yyvsp[(2) - (2)]),T_REQUIRE,1);;} break; case 872: /* Line 1455 of yacc.c */ #line 2846 "hphp.y" { UEXP((yyval),(yyvsp[(2) - (2)]),T_REQUIRE_ONCE,1);;} break; case 873: /* Line 1455 of yacc.c */ #line 2850 "hphp.y" { _p->onExprListElem((yyval), NULL, (yyvsp[(1) - (1)]));;} break; case 874: /* Line 1455 of yacc.c */ #line 2851 "hphp.y" { _p->onExprListElem((yyval), &(yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]));;} break; case 875: /* Line 1455 of yacc.c */ #line 2856 "hphp.y" { _p->onClassConst((yyval), (yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), 0);;} break; case 876: /* Line 1455 of yacc.c */ #line 2858 "hphp.y" { _p->onClassClass((yyval), (yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), 0);;} break; case 879: /* Line 1455 of yacc.c */ #line 2872 "hphp.y" { (yyvsp[(2) - (5)]).setText(_p->nsDecl((yyvsp[(2) - (5)]).text())); _p->onTypedef((yyval), (yyvsp[(2) - (5)]), (yyvsp[(4) - (5)])); _p->popTypeScope(); ;} break; case 880: /* Line 1455 of yacc.c */ #line 2876 "hphp.y" { (yyvsp[(2) - (6)]).setText(_p->nsDecl((yyvsp[(2) - (6)]).text())); _p->onTypedef((yyval), (yyvsp[(2) - (6)]), (yyvsp[(5) - (6)])); _p->popTypeScope(); ;} break; case 881: /* Line 1455 of yacc.c */ #line 2882 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]); ;} break; case 882: /* Line 1455 of yacc.c */ #line 2883 "hphp.y" { only_in_hh_syntax(_p); (yyval) = (yyvsp[(2) - (2)]); ;} break; case 883: /* Line 1455 of yacc.c */ #line 2889 "hphp.y" { _p->pushTypeScope(); (yyval) = (yyvsp[(1) - (1)]); ;} break; case 884: /* Line 1455 of yacc.c */ #line 2893 "hphp.y" { _p->pushTypeScope(); (yyval) = (yyvsp[(1) - (4)]); ;} break; case 885: /* Line 1455 of yacc.c */ #line 2899 "hphp.y" { (yyval) = (yyvsp[(2) - (3)]); ;} break; case 886: /* Line 1455 of yacc.c */ #line 2900 "hphp.y" { (yyval).reset(); ;} break; case 887: /* Line 1455 of yacc.c */ #line 2904 "hphp.y" { Token t; t.reset(); _p->onTypeList((yyvsp[(1) - (1)]), t); (yyval) = (yyvsp[(1) - (1)]); ;} break; case 888: /* Line 1455 of yacc.c */ #line 2907 "hphp.y" { _p->onTypeList((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); (yyval) = (yyvsp[(1) - (3)]); ;} break; case 889: /* Line 1455 of yacc.c */ #line 2913 "hphp.y" { (yyval) = (yyvsp[(1) - (2)]); ;} break; case 890: /* Line 1455 of yacc.c */ #line 2918 "hphp.y" { (yyval) = (yyvsp[(1) - (3)]); ;} break; case 891: /* Line 1455 of yacc.c */ #line 2919 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]); ;} break; case 892: /* Line 1455 of yacc.c */ #line 2920 "hphp.y" { (yyval).reset(); ;} break; case 893: /* Line 1455 of yacc.c */ #line 2921 "hphp.y" { (yyval).reset(); ;} break; case 894: /* Line 1455 of yacc.c */ #line 2925 "hphp.y" { (yyval).reset(); ;} break; case 895: /* Line 1455 of yacc.c */ #line 2926 "hphp.y" { only_in_hh_syntax(_p); (yyval) = (yyvsp[(2) - (2)]); ;} break; case 896: /* Line 1455 of yacc.c */ #line 2931 "hphp.y" { _p->addTypeVar((yyvsp[(4) - (4)]).text()); ;} break; case 897: /* Line 1455 of yacc.c */ #line 2932 "hphp.y" { _p->addTypeVar((yyvsp[(2) - (2)]).text()); ;} break; case 898: /* Line 1455 of yacc.c */ #line 2935 "hphp.y" { _p->addTypeVar((yyvsp[(4) - (6)]).text()); ;} break; case 899: /* Line 1455 of yacc.c */ #line 2937 "hphp.y" { _p->addTypeVar((yyvsp[(2) - (4)]).text()); ;} break; case 900: /* Line 1455 of yacc.c */ #line 2941 "hphp.y" {;} break; case 901: /* Line 1455 of yacc.c */ #line 2942 "hphp.y" {;} break; case 902: /* Line 1455 of yacc.c */ #line 2943 "hphp.y" {;} break; case 903: /* Line 1455 of yacc.c */ #line 2949 "hphp.y" { validate_shape_keyname((yyvsp[(1) - (3)]), _p); ;} break; case 904: /* Line 1455 of yacc.c */ #line 2954 "hphp.y" { ;} break; case 907: /* Line 1455 of yacc.c */ #line 2966 "hphp.y" { (yyval) = (yyvsp[(1) - (2)]); ;} break; case 908: /* Line 1455 of yacc.c */ #line 2968 "hphp.y" {;} break; case 909: /* Line 1455 of yacc.c */ #line 2972 "hphp.y" { (yyval).setText("array"); ;} break; case 910: /* Line 1455 of yacc.c */ #line 2979 "hphp.y" { only_in_hh_syntax(_p); _p->onTypeSpecialization((yyvsp[(2) - (2)]), '?'); (yyval) = (yyvsp[(2) - (2)]); ;} break; case 911: /* Line 1455 of yacc.c */ #line 2982 "hphp.y" { only_in_hh_syntax(_p); _p->onTypeSpecialization((yyvsp[(2) - (2)]), '@'); (yyval) = (yyvsp[(2) - (2)]); ;} break; case 912: /* Line 1455 of yacc.c */ #line 2985 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]); ;} break; case 913: /* Line 1455 of yacc.c */ #line 2986 "hphp.y" { Token t; t.reset(); (yyvsp[(1) - (1)]).setText("array"); _p->onTypeAnnotation((yyval), (yyvsp[(1) - (1)]), t); ;} break; case 914: /* Line 1455 of yacc.c */ #line 2989 "hphp.y" { Token t; t.reset(); (yyvsp[(1) - (1)]).setText("callable"); _p->onTypeAnnotation((yyval), (yyvsp[(1) - (1)]), t); ;} break; case 915: /* Line 1455 of yacc.c */ #line 2992 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]); ;} break; case 916: /* Line 1455 of yacc.c */ #line 2994 "hphp.y" { (yyvsp[(1) - (4)]).setText("array"); _p->onTypeAnnotation((yyval), (yyvsp[(1) - (4)]), (yyvsp[(3) - (4)])); ;} break; case 917: /* Line 1455 of yacc.c */ #line 2997 "hphp.y" { _p->onTypeList((yyvsp[(3) - (6)]), (yyvsp[(5) - (6)])); (yyvsp[(1) - (6)]).setText("array"); _p->onTypeAnnotation((yyval), (yyvsp[(1) - (6)]), (yyvsp[(3) - (6)])); ;} break; case 918: /* Line 1455 of yacc.c */ #line 3000 "hphp.y" { (yyvsp[(1) - (1)]).xhpLabel(); Token t; t.reset(); _p->onTypeAnnotation((yyval), (yyvsp[(1) - (1)]), t); _p->onTypeSpecialization((yyval), 'x'); ;} break; case 919: /* Line 1455 of yacc.c */ #line 3006 "hphp.y" { only_in_hh_syntax(_p); _p->onTypeList((yyvsp[(7) - (8)]), (yyvsp[(4) - (8)])); _p->onTypeAnnotation((yyval), (yyvsp[(2) - (8)]), (yyvsp[(7) - (8)])); _p->onTypeSpecialization((yyval), 'f'); ;} break; case 920: /* Line 1455 of yacc.c */ #line 3012 "hphp.y" { only_in_hh_syntax(_p); _p->onTypeList((yyvsp[(2) - (6)]), (yyvsp[(4) - (6)])); Token t; t.reset(); t.setText("array"); _p->onTypeAnnotation((yyval), t, (yyvsp[(2) - (6)])); _p->onTypeSpecialization((yyval), 't'); ;} break; case 921: /* Line 1455 of yacc.c */ #line 3020 "hphp.y" { (yyval) = (yyvsp[(1) - (1)]); ;} break; case 922: /* Line 1455 of yacc.c */ #line 3021 "hphp.y" { (yyval).reset(); ;} break; /* Line 1455 of yacc.c */ #line 13542 "hphp.tab.cpp" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; *++yylsp = yyloc; /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ yyn = yyr1[yyn]; yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTOKENS]; goto yynewstate; /*------------------------------------. | yyerrlab -- here on detecting error | `------------------------------------*/ yyerrlab: /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; #if ! YYERROR_VERBOSE yyerror (&yylloc, _p, YY_("syntax error")); #else { YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) { YYSIZE_T yyalloc = 2 * yysize; if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) yyalloc = YYSTACK_ALLOC_MAXIMUM; if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); yymsg = (char *) YYSTACK_ALLOC (yyalloc); if (yymsg) yymsg_alloc = yyalloc; else { yymsg = yymsgbuf; yymsg_alloc = sizeof yymsgbuf; } } if (0 < yysize && yysize <= yymsg_alloc) { (void) yysyntax_error (yymsg, yystate, yychar); yyerror (&yylloc, _p, yymsg); } else { yyerror (&yylloc, _p, YY_("syntax error")); if (yysize != 0) goto yyexhaustedlab; } } #endif } yyerror_range[0] = yylloc; if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) { /* Return failure if at end of input. */ if (yychar == YYEOF) YYABORT; } else { yydestruct ("Error: discarding", yytoken, &yylval, &yylloc, _p); yychar = YYEMPTY; } } /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; /*---------------------------------------------------. | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: /* Pacify compilers like GCC when the user code never invokes YYERROR and the label yyerrorlab therefore never appears in user code. */ if (/*CONSTCOND*/ 0) goto yyerrorlab; yyerror_range[0] = yylsp[1-yylen]; /* Do not reclaim the symbols of the rule which action triggered this YYERROR. */ YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); yystate = *yyssp; goto yyerrlab1; /*-------------------------------------------------------------. | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; if (yyn != YYPACT_NINF) { yyn += YYTERROR; if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) { yyn = yytable[yyn]; if (0 < yyn) break; } } /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) YYABORT; yyerror_range[0] = *yylsp; yydestruct ("Error: popping", yystos[yystate], yyvsp, yylsp, _p); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } *++yyvsp = yylval; yyerror_range[1] = yylloc; /* Using YYLLOC is tempting, but would change the location of the lookahead. YYLOC is available though. */ YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); *++yylsp = yyloc; /* Shift the error token. */ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); yystate = yyn; goto yynewstate; /*-------------------------------------. | yyacceptlab -- YYACCEPT comes here. | `-------------------------------------*/ yyacceptlab: yyresult = 0; goto yyreturn; /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ yyabortlab: yyresult = 1; goto yyreturn; #if !defined(yyoverflow) || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ yyexhaustedlab: yyerror (&yylloc, _p, YY_("memory exhausted")); yyresult = 2; /* Fall through. */ #endif yyreturn: if (yychar != YYEMPTY) yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc, _p); /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); YY_STACK_PRINT (yyss, yyssp); while (yyssp != yyss) { yydestruct ("Cleanup: popping", yystos[*yyssp], yyvsp, yylsp, _p); YYPOPSTACK (1); } #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); YYSTACK_CLEANUP; #endif #if YYERROR_VERBOSE if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); #endif /* Make sure YYID is used. */ return YYID (yyresult); } /* Line 1675 of yacc.c */ #line 3024 "hphp.y" bool Parser::parseImpl() { return yyparse(this) == 0; }
#include "Shared/Components/FoodComponent.h"
#include "global.h" void testBool1() { bool bs[15]; for (int i = 0; i < 15; ++i) { bs[i] = i % 2 == 0 ? true : false; } unsigned char buf[64]; unsigned char * p = (unsigned char * )bs; for (int j = 0; j < 15; ++j) { buf[j] = * p; p++; } cout << buf[8] << endl; }
/** * Copyright 2020 Huawei Technologies Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "src/runtime/kernel/arm/fp32_grad/power_grad.h" #include "schema/model_generated.h" #include "src/kernel_registry.h" #include "include/errorcode.h" #include "nnacl/fp32/arithmetic_fp32.h" #include "src/runtime/runtime_api.h" using mindspore::lite::KernelRegistrar; using mindspore::lite::RET_ERROR; using mindspore::lite::RET_OK; using mindspore::schema::PrimitiveType_PowerGrad; namespace mindspore::kernel { int PowerGradCPUKernel::Init() { if (in_tensors_.size() != 2) { MS_LOG(ERROR) << "Power Grad Filter should have 2 inputs"; return RET_ERROR; } if (out_tensors_.size() != 1) { MS_LOG(ERROR) << "Power Grad Filter should have one output"; return RET_ERROR; } return RET_OK; } int PowerGradCPUKernel::ReSize() { return RET_OK; } int PowerGradCPUKernel::Execute(int task_id) { auto dy_addr = reinterpret_cast<float *>(in_tensors_.at(0)->MutableData()); auto x_addr = reinterpret_cast<float *>(in_tensors_.at(1)->MutableData()); auto dx_addr = reinterpret_cast<float *>(out_tensors_.at(0)->MutableData()); int length = in_tensors_.at(0)->ElementsNum(); int stride = UP_DIV(length, thread_count_); int count = MSMIN(stride, length - stride * task_id); count = (count < 0) ? 0 : count; int start = stride * task_id; int end = start + count; float exp = power_ - 1; Power(&(x_addr[start]), &exp, &(dx_addr[start]), count, scale_, shift_, true); ElementMul(&(dx_addr[start]), &(dy_addr[start]), &(dx_addr[start]), count); float scale = scale_ * power_; for (int i = start; i < end; i++) { dx_addr[i] *= scale; } return RET_OK; } int PowerGradRun(void *cdata, int task_id) { auto power_kernel = reinterpret_cast<PowerGradCPUKernel *>(cdata); auto error_code = power_kernel->Execute(task_id); if (error_code != RET_OK) { MS_LOG(ERROR) << "power grad error task_id[" << task_id << "] error_code[" << error_code << "]"; return RET_ERROR; } return RET_OK; } int PowerGradCPUKernel::Run() { int error_code = ParallelLaunch(this->context_->thread_pool_, PowerGradRun, this, thread_count_); if (error_code != RET_OK) { MS_LOG(ERROR) << "power grad function error error_code[" << error_code << "]"; return RET_ERROR; } return RET_OK; } kernel::LiteKernel *CpuPowerGradFp32KernelCreator(const std::vector<lite::Tensor *> &inputs, const std::vector<lite::Tensor *> &outputs, OpParameter *opParameter, const lite::InnerContext *ctx, const kernel::KernelKey &desc) { MS_ASSERT(opParameter != nullptr); MS_ASSERT(desc.type == schema::PrimitiveType_PowerGrad); auto *kernel = new (std::nothrow) PowerGradCPUKernel(opParameter, inputs, outputs, ctx); if (kernel == nullptr) { MS_LOG(ERROR) << "new PowerGradCPUKernel fail!"; free(opParameter); return nullptr; } auto ret = kernel->Init(); if (ret != RET_OK) { MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast<schema::PrimitiveType>(opParameter->type_)); delete kernel; return nullptr; } return kernel; } REG_KERNEL(kCPU, kNumberTypeFloat32, PrimitiveType_PowerGrad, CpuPowerGradFp32KernelCreator) } // namespace mindspore::kernel
/* * Copyright 2015 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include "GrAAConvexTessellator.h" #include "SkCanvas.h" #include "SkPath.h" #include "SkPoint.h" #include "SkString.h" #include "GrPathUtils.h" // Next steps: // add an interactive sample app slide // add debug check that all points are suitably far apart // test more degenerate cases // The tolerance for fusing vertices and eliminating colinear lines (It is in device space). static const SkScalar kClose = (SK_Scalar1 / 16); static const SkScalar kCloseSqd = kClose * kClose; // tesselation tolerance values, in device space pixels static const SkScalar kQuadTolerance = 0.2f; static const SkScalar kCubicTolerance = 0.2f; static const SkScalar kConicTolerance = 0.5f; // dot product below which we use a round cap between curve segments static const SkScalar kRoundCapThreshold = 0.8f; // dot product above which we consider two adjacent curves to be part of the "same" curve static const SkScalar kCurveConnectionThreshold = 0.8f; static bool intersect(const SkPoint& p0, const SkPoint& n0, const SkPoint& p1, const SkPoint& n1, SkScalar* t) { const SkPoint v = p1 - p0; SkScalar perpDot = n0.fX * n1.fY - n0.fY * n1.fX; if (SkScalarNearlyZero(perpDot)) { return false; } *t = (v.fX * n1.fY - v.fY * n1.fX) / perpDot; SkASSERT(SkScalarIsFinite(*t)); return true; } // This is a special case version of intersect where we have the vector // perpendicular to the second line rather than the vector parallel to it. static SkScalar perp_intersect(const SkPoint& p0, const SkPoint& n0, const SkPoint& p1, const SkPoint& perp) { const SkPoint v = p1 - p0; SkScalar perpDot = n0.dot(perp); return v.dot(perp) / perpDot; } static bool duplicate_pt(const SkPoint& p0, const SkPoint& p1) { SkScalar distSq = SkPointPriv::DistanceToSqd(p0, p1); return distSq < kCloseSqd; } static SkScalar abs_dist_from_line(const SkPoint& p0, const SkVector& v, const SkPoint& test) { SkPoint testV = test - p0; SkScalar dist = testV.fX * v.fY - testV.fY * v.fX; return SkScalarAbs(dist); } int GrAAConvexTessellator::addPt(const SkPoint& pt, SkScalar depth, SkScalar coverage, bool movable, CurveState curve) { this->validate(); int index = fPts.count(); *fPts.push() = pt; *fCoverages.push() = coverage; *fMovable.push() = movable; *fCurveState.push() = curve; this->validate(); return index; } void GrAAConvexTessellator::popLastPt() { this->validate(); fPts.pop(); fCoverages.pop(); fMovable.pop(); fCurveState.pop(); this->validate(); } void GrAAConvexTessellator::popFirstPtShuffle() { this->validate(); fPts.removeShuffle(0); fCoverages.removeShuffle(0); fMovable.removeShuffle(0); fCurveState.removeShuffle(0); this->validate(); } void GrAAConvexTessellator::updatePt(int index, const SkPoint& pt, SkScalar depth, SkScalar coverage) { this->validate(); SkASSERT(fMovable[index]); fPts[index] = pt; fCoverages[index] = coverage; } void GrAAConvexTessellator::addTri(int i0, int i1, int i2) { if (i0 == i1 || i1 == i2 || i2 == i0) { return; } *fIndices.push() = i0; *fIndices.push() = i1; *fIndices.push() = i2; } void GrAAConvexTessellator::rewind() { fPts.rewind(); fCoverages.rewind(); fMovable.rewind(); fIndices.rewind(); fNorms.rewind(); fCurveState.rewind(); fInitialRing.rewind(); fCandidateVerts.rewind(); #if GR_AA_CONVEX_TESSELLATOR_VIZ fRings.rewind(); // TODO: leak in this case! #else fRings[0].rewind(); fRings[1].rewind(); #endif } void GrAAConvexTessellator::computeBisectors() { fBisectors.setCount(fNorms.count()); int prev = fBisectors.count() - 1; for (int cur = 0; cur < fBisectors.count(); prev = cur, ++cur) { fBisectors[cur] = fNorms[cur] + fNorms[prev]; if (!fBisectors[cur].normalize()) { SkASSERT(SkPointPriv::kLeft_Side == fSide || SkPointPriv::kRight_Side == fSide); SkPointPriv::SetOrthog(&fBisectors[cur], fNorms[cur], (SkPointPriv::Side)-fSide); SkVector other; SkPointPriv::SetOrthog(&other, fNorms[prev], fSide); fBisectors[cur] += other; SkAssertResult(fBisectors[cur].normalize()); } else { fBisectors[cur].negate(); // make the bisector face in } if (fCurveState[prev] == kIndeterminate_CurveState) { if (fCurveState[cur] == kSharp_CurveState) { fCurveState[prev] = kSharp_CurveState; } else { if (SkScalarAbs(fNorms[cur].dot(fNorms[prev])) > kCurveConnectionThreshold) { fCurveState[prev] = kCurve_CurveState; fCurveState[cur] = kCurve_CurveState; } else { fCurveState[prev] = kSharp_CurveState; fCurveState[cur] = kSharp_CurveState; } } } SkASSERT(SkScalarNearlyEqual(1.0f, fBisectors[cur].length())); } } // Create as many rings as we need to (up to a predefined limit) to reach the specified target // depth. If we are in fill mode, the final ring will automatically be fanned. bool GrAAConvexTessellator::createInsetRings(Ring& previousRing, SkScalar initialDepth, SkScalar initialCoverage, SkScalar targetDepth, SkScalar targetCoverage, Ring** finalRing) { static const int kMaxNumRings = 8; if (previousRing.numPts() < 3) { return false; } Ring* currentRing = &previousRing; int i; for (i = 0; i < kMaxNumRings; ++i) { Ring* nextRing = this->getNextRing(currentRing); SkASSERT(nextRing != currentRing); bool done = this->createInsetRing(*currentRing, nextRing, initialDepth, initialCoverage, targetDepth, targetCoverage, i == 0); currentRing = nextRing; if (done) { break; } currentRing->init(*this); } if (kMaxNumRings == i) { // Bail if we've exceeded the amount of time we want to throw at this. this->terminate(*currentRing); return false; } bool done = currentRing->numPts() >= 3; if (done) { currentRing->init(*this); } *finalRing = currentRing; return done; } // The general idea here is to, conceptually, start with the original polygon and slide // the vertices along the bisectors until the first intersection. At that // point two of the edges collapse and the process repeats on the new polygon. // The polygon state is captured in the Ring class while the GrAAConvexTessellator // controls the iteration. The CandidateVerts holds the formative points for the // next ring. bool GrAAConvexTessellator::tessellate(const SkMatrix& m, const SkPath& path) { if (!this->extractFromPath(m, path)) { return false; } SkScalar coverage = 1.0f; SkScalar scaleFactor = 0.0f; if (SkStrokeRec::kStrokeAndFill_Style == fStyle) { SkASSERT(m.isSimilarity()); scaleFactor = m.getMaxScale(); // x and y scale are the same SkScalar effectiveStrokeWidth = scaleFactor * fStrokeWidth; Ring outerStrokeAndAARing; this->createOuterRing(fInitialRing, effectiveStrokeWidth / 2 + kAntialiasingRadius, 0.0, &outerStrokeAndAARing); // discard all the triangles added between the originating ring and the new outer ring fIndices.rewind(); outerStrokeAndAARing.init(*this); outerStrokeAndAARing.makeOriginalRing(); // Add the outer stroke ring's normals to the originating ring's normals // so it can also act as an originating ring fNorms.setCount(fNorms.count() + outerStrokeAndAARing.numPts()); for (int i = 0; i < outerStrokeAndAARing.numPts(); ++i) { SkASSERT(outerStrokeAndAARing.index(i) < fNorms.count()); fNorms[outerStrokeAndAARing.index(i)] = outerStrokeAndAARing.norm(i); } // the bisectors are only needed for the computation of the outer ring fBisectors.rewind(); Ring* insetAARing; this->createInsetRings(outerStrokeAndAARing, 0.0f, 0.0f, 2*kAntialiasingRadius, 1.0f, &insetAARing); SkDEBUGCODE(this->validate();) return true; } if (SkStrokeRec::kStroke_Style == fStyle) { SkASSERT(fStrokeWidth >= 0.0f); SkASSERT(m.isSimilarity()); scaleFactor = m.getMaxScale(); // x and y scale are the same SkScalar effectiveStrokeWidth = scaleFactor * fStrokeWidth; Ring outerStrokeRing; this->createOuterRing(fInitialRing, effectiveStrokeWidth / 2 - kAntialiasingRadius, coverage, &outerStrokeRing); outerStrokeRing.init(*this); Ring outerAARing; this->createOuterRing(outerStrokeRing, kAntialiasingRadius * 2, 0.0f, &outerAARing); } else { Ring outerAARing; this->createOuterRing(fInitialRing, kAntialiasingRadius, 0.0f, &outerAARing); } // the bisectors are only needed for the computation of the outer ring fBisectors.rewind(); if (SkStrokeRec::kStroke_Style == fStyle && fInitialRing.numPts() > 2) { SkASSERT(fStrokeWidth >= 0.0f); SkScalar effectiveStrokeWidth = scaleFactor * fStrokeWidth; Ring* insetStrokeRing; SkScalar strokeDepth = effectiveStrokeWidth / 2 - kAntialiasingRadius; if (this->createInsetRings(fInitialRing, 0.0f, coverage, strokeDepth, coverage, &insetStrokeRing)) { Ring* insetAARing; this->createInsetRings(*insetStrokeRing, strokeDepth, coverage, strokeDepth + kAntialiasingRadius * 2, 0.0f, &insetAARing); } } else { Ring* insetAARing; this->createInsetRings(fInitialRing, 0.0f, 0.5f, kAntialiasingRadius, 1.0f, &insetAARing); } SkDEBUGCODE(this->validate();) return true; } SkScalar GrAAConvexTessellator::computeDepthFromEdge(int edgeIdx, const SkPoint& p) const { SkASSERT(edgeIdx < fNorms.count()); SkPoint v = p - fPts[edgeIdx]; SkScalar depth = -fNorms[edgeIdx].dot(v); return depth; } // Find a point that is 'desiredDepth' away from the 'edgeIdx'-th edge and lies // along the 'bisector' from the 'startIdx'-th point. bool GrAAConvexTessellator::computePtAlongBisector(int startIdx, const SkVector& bisector, int edgeIdx, SkScalar desiredDepth, SkPoint* result) const { const SkPoint& norm = fNorms[edgeIdx]; // First find the point where the edge and the bisector intersect SkPoint newP; SkScalar t = perp_intersect(fPts[startIdx], bisector, fPts[edgeIdx], norm); if (SkScalarNearlyEqual(t, 0.0f)) { // the start point was one of the original ring points SkASSERT(startIdx < fPts.count()); newP = fPts[startIdx]; } else if (t < 0.0f) { newP = bisector; newP.scale(t); newP += fPts[startIdx]; } else { return false; } // Then offset along the bisector from that point the correct distance SkScalar dot = bisector.dot(norm); t = -desiredDepth / dot; *result = bisector; result->scale(t); *result += newP; return true; } bool GrAAConvexTessellator::extractFromPath(const SkMatrix& m, const SkPath& path) { SkASSERT(SkPath::kConvex_Convexity == path.getConvexity()); // Outer ring: 3*numPts // Middle ring: numPts // Presumptive inner ring: numPts this->reservePts(5*path.countPoints()); // Outer ring: 12*numPts // Middle ring: 0 // Presumptive inner ring: 6*numPts + 6 fIndices.setReserve(18*path.countPoints() + 6); fNorms.setReserve(path.countPoints()); // TODO: is there a faster way to extract the points from the path? Perhaps // get all the points via a new entry point, transform them all in bulk // and then walk them to find duplicates? SkPath::Iter iter(path, true); SkPoint pts[4]; SkPath::Verb verb; while ((verb = iter.next(pts, true, true)) != SkPath::kDone_Verb) { switch (verb) { case SkPath::kLine_Verb: this->lineTo(m, pts[1], kSharp_CurveState); break; case SkPath::kQuad_Verb: this->quadTo(m, pts); break; case SkPath::kCubic_Verb: this->cubicTo(m, pts); break; case SkPath::kConic_Verb: this->conicTo(m, pts, iter.conicWeight()); break; case SkPath::kMove_Verb: case SkPath::kClose_Verb: case SkPath::kDone_Verb: break; } } if (this->numPts() < 2) { return false; } // check if last point is a duplicate of the first point. If so, remove it. if (duplicate_pt(fPts[this->numPts()-1], fPts[0])) { this->popLastPt(); fNorms.pop(); } SkASSERT(fPts.count() == fNorms.count()+1); if (this->numPts() >= 3) { if (abs_dist_from_line(fPts.top(), fNorms.top(), fPts[0]) < kClose) { // The last point is on the line from the second to last to the first point. this->popLastPt(); fNorms.pop(); } *fNorms.push() = fPts[0] - fPts.top(); SkDEBUGCODE(SkScalar len =) SkPoint::Normalize(&fNorms.top()); SkASSERT(len > 0.0f); SkASSERT(fPts.count() == fNorms.count()); } if (this->numPts() >= 3 && abs_dist_from_line(fPts[0], fNorms.top(), fPts[1]) < kClose) { // The first point is on the line from the last to the second. this->popFirstPtShuffle(); fNorms.removeShuffle(0); fNorms[0] = fPts[1] - fPts[0]; SkDEBUGCODE(SkScalar len =) SkPoint::Normalize(&fNorms[0]); SkASSERT(len > 0.0f); SkASSERT(SkScalarNearlyEqual(1.0f, fNorms[0].length())); } if (this->numPts() >= 3) { // Check the cross product of the final trio SkScalar cross = SkPoint::CrossProduct(fNorms[0], fNorms.top()); if (cross > 0.0f) { fSide = SkPointPriv::kRight_Side; } else { fSide = SkPointPriv::kLeft_Side; } // Make all the normals face outwards rather than along the edge for (int cur = 0; cur < fNorms.count(); ++cur) { SkPointPriv::SetOrthog(&fNorms[cur], fNorms[cur], fSide); SkASSERT(SkScalarNearlyEqual(1.0f, fNorms[cur].length())); } this->computeBisectors(); } else if (this->numPts() == 2) { // We've got two points, so we're degenerate. if (fStyle == SkStrokeRec::kFill_Style) { // it's a fill, so we don't need to worry about degenerate paths return false; } // For stroking, we still need to process the degenerate path, so fix it up fSide = SkPointPriv::kLeft_Side; // Make all the normals face outwards rather than along the edge for (int cur = 0; cur < fNorms.count(); ++cur) { SkPointPriv::SetOrthog(&fNorms[cur], fNorms[cur], fSide); SkASSERT(SkScalarNearlyEqual(1.0f, fNorms[cur].length())); } fNorms.push(SkPoint::Make(-fNorms[0].fX, -fNorms[0].fY)); // we won't actually use the bisectors, so just push zeroes fBisectors.push(SkPoint::Make(0.0, 0.0)); fBisectors.push(SkPoint::Make(0.0, 0.0)); } else { return false; } fCandidateVerts.setReserve(this->numPts()); fInitialRing.setReserve(this->numPts()); for (int i = 0; i < this->numPts(); ++i) { fInitialRing.addIdx(i, i); } fInitialRing.init(fNorms, fBisectors); this->validate(); return true; } GrAAConvexTessellator::Ring* GrAAConvexTessellator::getNextRing(Ring* lastRing) { #if GR_AA_CONVEX_TESSELLATOR_VIZ Ring* ring = *fRings.push() = new Ring; ring->setReserve(fInitialRing.numPts()); ring->rewind(); return ring; #else // Flip flop back and forth between fRings[0] & fRings[1] int nextRing = (lastRing == &fRings[0]) ? 1 : 0; fRings[nextRing].setReserve(fInitialRing.numPts()); fRings[nextRing].rewind(); return &fRings[nextRing]; #endif } void GrAAConvexTessellator::fanRing(const Ring& ring) { // fan out from point 0 int startIdx = ring.index(0); for (int cur = ring.numPts() - 2; cur >= 0; --cur) { this->addTri(startIdx, ring.index(cur), ring.index(cur + 1)); } } void GrAAConvexTessellator::createOuterRing(const Ring& previousRing, SkScalar outset, SkScalar coverage, Ring* nextRing) { const int numPts = previousRing.numPts(); if (numPts == 0) { return; } int prev = numPts - 1; int lastPerpIdx = -1, firstPerpIdx = -1; const SkScalar outsetSq = outset * outset; SkScalar miterLimitSq = outset * fMiterLimit; miterLimitSq = miterLimitSq * miterLimitSq; for (int cur = 0; cur < numPts; ++cur) { int originalIdx = previousRing.index(cur); // For each vertex of the original polygon we add at least two points to the // outset polygon - one extending perpendicular to each impinging edge. Connecting these // two points yields a bevel join. We need one additional point for a mitered join, and // a round join requires one or more points depending upon curvature. // The perpendicular point for the last edge SkPoint normal1 = previousRing.norm(prev); SkPoint perp1 = normal1; perp1.scale(outset); perp1 += this->point(originalIdx); // The perpendicular point for the next edge. SkPoint normal2 = previousRing.norm(cur); SkPoint perp2 = normal2; perp2.scale(outset); perp2 += fPts[originalIdx]; CurveState curve = fCurveState[originalIdx]; // We know it isn't a duplicate of the prior point (since it and this // one are just perpendicular offsets from the non-merged polygon points) int perp1Idx = this->addPt(perp1, -outset, coverage, false, curve); nextRing->addIdx(perp1Idx, originalIdx); int perp2Idx; // For very shallow angles all the corner points could fuse. if (duplicate_pt(perp2, this->point(perp1Idx))) { perp2Idx = perp1Idx; } else { perp2Idx = this->addPt(perp2, -outset, coverage, false, curve); } if (perp2Idx != perp1Idx) { if (curve == kCurve_CurveState) { // bevel or round depending upon curvature SkScalar dotProd = normal1.dot(normal2); if (dotProd < kRoundCapThreshold) { // Currently we "round" by creating a single extra point, which produces // good results for common cases. For thick strokes with high curvature, we will // need to add more points; for the time being we simply fall back to software // rendering for thick strokes. SkPoint miter = previousRing.bisector(cur); miter.setLength(-outset); miter += fPts[originalIdx]; // For very shallow angles all the corner points could fuse if (!duplicate_pt(miter, this->point(perp1Idx))) { int miterIdx; miterIdx = this->addPt(miter, -outset, coverage, false, kSharp_CurveState); nextRing->addIdx(miterIdx, originalIdx); // The two triangles for the corner this->addTri(originalIdx, perp1Idx, miterIdx); this->addTri(originalIdx, miterIdx, perp2Idx); } } else { this->addTri(originalIdx, perp1Idx, perp2Idx); } } else { switch (fJoin) { case SkPaint::Join::kMiter_Join: { // The bisector outset point SkPoint miter = previousRing.bisector(cur); SkScalar dotProd = normal1.dot(normal2); SkScalar sinHalfAngleSq = SkScalarHalf(SK_Scalar1 + dotProd); SkScalar lengthSq = sk_ieee_float_divide(outsetSq, sinHalfAngleSq); if (lengthSq > miterLimitSq) { // just bevel it this->addTri(originalIdx, perp1Idx, perp2Idx); break; } miter.setLength(-SkScalarSqrt(lengthSq)); miter += fPts[originalIdx]; // For very shallow angles all the corner points could fuse if (!duplicate_pt(miter, this->point(perp1Idx))) { int miterIdx; miterIdx = this->addPt(miter, -outset, coverage, false, kSharp_CurveState); nextRing->addIdx(miterIdx, originalIdx); // The two triangles for the corner this->addTri(originalIdx, perp1Idx, miterIdx); this->addTri(originalIdx, miterIdx, perp2Idx); } break; } case SkPaint::Join::kBevel_Join: this->addTri(originalIdx, perp1Idx, perp2Idx); break; default: // kRound_Join is unsupported for now. GrAALinearizingConvexPathRenderer is // only willing to draw mitered or beveled, so we should never get here. SkASSERT(false); } } nextRing->addIdx(perp2Idx, originalIdx); } if (0 == cur) { // Store the index of the first perpendicular point to finish up firstPerpIdx = perp1Idx; SkASSERT(-1 == lastPerpIdx); } else { // The triangles for the previous edge int prevIdx = previousRing.index(prev); this->addTri(prevIdx, perp1Idx, originalIdx); this->addTri(prevIdx, lastPerpIdx, perp1Idx); } // Track the last perpendicular outset point so we can construct the // trailing edge triangles. lastPerpIdx = perp2Idx; prev = cur; } // pick up the final edge rect int lastIdx = previousRing.index(numPts - 1); this->addTri(lastIdx, firstPerpIdx, previousRing.index(0)); this->addTri(lastIdx, lastPerpIdx, firstPerpIdx); this->validate(); } // Something went wrong in the creation of the next ring. If we're filling the shape, just go ahead // and fan it. void GrAAConvexTessellator::terminate(const Ring& ring) { if (fStyle != SkStrokeRec::kStroke_Style) { this->fanRing(ring); } } static SkScalar compute_coverage(SkScalar depth, SkScalar initialDepth, SkScalar initialCoverage, SkScalar targetDepth, SkScalar targetCoverage) { if (SkScalarNearlyEqual(initialDepth, targetDepth)) { return targetCoverage; } SkScalar result = (depth - initialDepth) / (targetDepth - initialDepth) * (targetCoverage - initialCoverage) + initialCoverage; return SkScalarClampMax(result, 1.0f); } // return true when processing is complete bool GrAAConvexTessellator::createInsetRing(const Ring& lastRing, Ring* nextRing, SkScalar initialDepth, SkScalar initialCoverage, SkScalar targetDepth, SkScalar targetCoverage, bool forceNew) { bool done = false; fCandidateVerts.rewind(); // Loop through all the points in the ring and find the intersection with the smallest depth SkScalar minDist = SK_ScalarMax, minT = 0.0f; int minEdgeIdx = -1; for (int cur = 0; cur < lastRing.numPts(); ++cur) { int next = (cur + 1) % lastRing.numPts(); SkScalar t; bool result = intersect(this->point(lastRing.index(cur)), lastRing.bisector(cur), this->point(lastRing.index(next)), lastRing.bisector(next), &t); if (!result) { continue; } SkScalar dist = -t * lastRing.norm(cur).dot(lastRing.bisector(cur)); if (minDist > dist) { minDist = dist; minT = t; minEdgeIdx = cur; } } if (minEdgeIdx == -1) { return false; } SkPoint newPt = lastRing.bisector(minEdgeIdx); newPt.scale(minT); newPt += this->point(lastRing.index(minEdgeIdx)); SkScalar depth = this->computeDepthFromEdge(lastRing.origEdgeID(minEdgeIdx), newPt); if (depth >= targetDepth) { // None of the bisectors intersect before reaching the desired depth. // Just step them all to the desired depth depth = targetDepth; done = true; } // 'dst' stores where each point in the last ring maps to/transforms into // in the next ring. SkTDArray<int> dst; dst.setCount(lastRing.numPts()); // Create the first point (who compares with no one) if (!this->computePtAlongBisector(lastRing.index(0), lastRing.bisector(0), lastRing.origEdgeID(0), depth, &newPt)) { this->terminate(lastRing); return true; } dst[0] = fCandidateVerts.addNewPt(newPt, lastRing.index(0), lastRing.origEdgeID(0), !this->movable(lastRing.index(0))); // Handle the middle points (who only compare with the prior point) for (int cur = 1; cur < lastRing.numPts()-1; ++cur) { if (!this->computePtAlongBisector(lastRing.index(cur), lastRing.bisector(cur), lastRing.origEdgeID(cur), depth, &newPt)) { this->terminate(lastRing); return true; } if (!duplicate_pt(newPt, fCandidateVerts.lastPoint())) { dst[cur] = fCandidateVerts.addNewPt(newPt, lastRing.index(cur), lastRing.origEdgeID(cur), !this->movable(lastRing.index(cur))); } else { dst[cur] = fCandidateVerts.fuseWithPrior(lastRing.origEdgeID(cur)); } } // Check on the last point (handling the wrap around) int cur = lastRing.numPts()-1; if (!this->computePtAlongBisector(lastRing.index(cur), lastRing.bisector(cur), lastRing.origEdgeID(cur), depth, &newPt)) { this->terminate(lastRing); return true; } bool dupPrev = duplicate_pt(newPt, fCandidateVerts.lastPoint()); bool dupNext = duplicate_pt(newPt, fCandidateVerts.firstPoint()); if (!dupPrev && !dupNext) { dst[cur] = fCandidateVerts.addNewPt(newPt, lastRing.index(cur), lastRing.origEdgeID(cur), !this->movable(lastRing.index(cur))); } else if (dupPrev && !dupNext) { dst[cur] = fCandidateVerts.fuseWithPrior(lastRing.origEdgeID(cur)); } else if (!dupPrev && dupNext) { dst[cur] = fCandidateVerts.fuseWithNext(); } else { bool dupPrevVsNext = duplicate_pt(fCandidateVerts.firstPoint(), fCandidateVerts.lastPoint()); if (!dupPrevVsNext) { dst[cur] = fCandidateVerts.fuseWithPrior(lastRing.origEdgeID(cur)); } else { const int fused = fCandidateVerts.fuseWithBoth(); dst[cur] = fused; const int targetIdx = dst[cur - 1]; for (int i = cur - 1; i >= 0 && dst[i] == targetIdx; i--) { dst[i] = fused; } } } // Fold the new ring's points into the global pool for (int i = 0; i < fCandidateVerts.numPts(); ++i) { int newIdx; if (fCandidateVerts.needsToBeNew(i) || forceNew) { // if the originating index is still valid then this point wasn't // fused (and is thus movable) SkScalar coverage = compute_coverage(depth, initialDepth, initialCoverage, targetDepth, targetCoverage); newIdx = this->addPt(fCandidateVerts.point(i), depth, coverage, fCandidateVerts.originatingIdx(i) != -1, kSharp_CurveState); } else { SkASSERT(fCandidateVerts.originatingIdx(i) != -1); this->updatePt(fCandidateVerts.originatingIdx(i), fCandidateVerts.point(i), depth, targetCoverage); newIdx = fCandidateVerts.originatingIdx(i); } nextRing->addIdx(newIdx, fCandidateVerts.origEdge(i)); } // 'dst' currently has indices into the ring. Remap these to be indices // into the global pool since the triangulation operates in that space. for (int i = 0; i < dst.count(); ++i) { dst[i] = nextRing->index(dst[i]); } for (int i = 0; i < lastRing.numPts(); ++i) { int next = (i + 1) % lastRing.numPts(); this->addTri(lastRing.index(i), lastRing.index(next), dst[next]); this->addTri(lastRing.index(i), dst[next], dst[i]); } if (done && fStyle != SkStrokeRec::kStroke_Style) { // fill or stroke-and-fill this->fanRing(*nextRing); } if (nextRing->numPts() < 3) { done = true; } return done; } void GrAAConvexTessellator::validate() const { SkASSERT(fPts.count() == fMovable.count()); SkASSERT(fPts.count() == fCoverages.count()); SkASSERT(fPts.count() == fCurveState.count()); SkASSERT(0 == (fIndices.count() % 3)); SkASSERT(!fBisectors.count() || fBisectors.count() == fNorms.count()); } ////////////////////////////////////////////////////////////////////////////// void GrAAConvexTessellator::Ring::init(const GrAAConvexTessellator& tess) { this->computeNormals(tess); this->computeBisectors(tess); } void GrAAConvexTessellator::Ring::init(const SkTDArray<SkVector>& norms, const SkTDArray<SkVector>& bisectors) { for (int i = 0; i < fPts.count(); ++i) { fPts[i].fNorm = norms[i]; fPts[i].fBisector = bisectors[i]; } } // Compute the outward facing normal at each vertex. void GrAAConvexTessellator::Ring::computeNormals(const GrAAConvexTessellator& tess) { for (int cur = 0; cur < fPts.count(); ++cur) { int next = (cur + 1) % fPts.count(); fPts[cur].fNorm = tess.point(fPts[next].fIndex) - tess.point(fPts[cur].fIndex); SkPoint::Normalize(&fPts[cur].fNorm); SkPointPriv::SetOrthog(&fPts[cur].fNorm, fPts[cur].fNorm, tess.side()); } } void GrAAConvexTessellator::Ring::computeBisectors(const GrAAConvexTessellator& tess) { int prev = fPts.count() - 1; for (int cur = 0; cur < fPts.count(); prev = cur, ++cur) { fPts[cur].fBisector = fPts[cur].fNorm + fPts[prev].fNorm; if (!fPts[cur].fBisector.normalize()) { SkASSERT(SkPointPriv::kLeft_Side == tess.side() || SkPointPriv::kRight_Side == tess.side()); SkPointPriv::SetOrthog(&fPts[cur].fBisector, fPts[cur].fNorm, (SkPointPriv::Side)-tess.side()); SkVector other; SkPointPriv::SetOrthog(&other, fPts[prev].fNorm, tess.side()); fPts[cur].fBisector += other; SkAssertResult(fPts[cur].fBisector.normalize()); } else { fPts[cur].fBisector.negate(); // make the bisector face in } } } ////////////////////////////////////////////////////////////////////////////// #ifdef SK_DEBUG // Is this ring convex? bool GrAAConvexTessellator::Ring::isConvex(const GrAAConvexTessellator& tess) const { if (fPts.count() < 3) { return true; } SkPoint prev = tess.point(fPts[0].fIndex) - tess.point(fPts.top().fIndex); SkPoint cur = tess.point(fPts[1].fIndex) - tess.point(fPts[0].fIndex); SkScalar minDot = prev.fX * cur.fY - prev.fY * cur.fX; SkScalar maxDot = minDot; prev = cur; for (int i = 1; i < fPts.count(); ++i) { int next = (i + 1) % fPts.count(); cur = tess.point(fPts[next].fIndex) - tess.point(fPts[i].fIndex); SkScalar dot = prev.fX * cur.fY - prev.fY * cur.fX; minDot = SkMinScalar(minDot, dot); maxDot = SkMaxScalar(maxDot, dot); prev = cur; } if (SkScalarNearlyEqual(maxDot, 0.0f, 0.005f)) { maxDot = 0; } if (SkScalarNearlyEqual(minDot, 0.0f, 0.005f)) { minDot = 0; } return (maxDot >= 0.0f) == (minDot >= 0.0f); } #endif void GrAAConvexTessellator::lineTo(const SkPoint& p, CurveState curve) { if (this->numPts() > 0 && duplicate_pt(p, this->lastPoint())) { return; } SkASSERT(fPts.count() <= 1 || fPts.count() == fNorms.count()+1); if (this->numPts() >= 2 && abs_dist_from_line(fPts.top(), fNorms.top(), p) < kClose) { // The old last point is on the line from the second to last to the new point this->popLastPt(); fNorms.pop(); // double-check that the new last point is not a duplicate of the new point. In an ideal // world this wouldn't be necessary (since it's only possible for non-convex paths), but // floating point precision issues mean it can actually happen on paths that were // determined to be convex. if (duplicate_pt(p, this->lastPoint())) { return; } } SkScalar initialRingCoverage = (SkStrokeRec::kFill_Style == fStyle) ? 0.5f : 1.0f; this->addPt(p, 0.0f, initialRingCoverage, false, curve); if (this->numPts() > 1) { *fNorms.push() = fPts.top() - fPts[fPts.count()-2]; SkDEBUGCODE(SkScalar len =) SkPoint::Normalize(&fNorms.top()); SkASSERT(len > 0.0f); SkASSERT(SkScalarNearlyEqual(1.0f, fNorms.top().length())); } } void GrAAConvexTessellator::lineTo(const SkMatrix& m, SkPoint p, CurveState curve) { m.mapPoints(&p, 1); this->lineTo(p, curve); } void GrAAConvexTessellator::quadTo(const SkPoint pts[3]) { int maxCount = GrPathUtils::quadraticPointCount(pts, kQuadTolerance); fPointBuffer.setReserve(maxCount); SkPoint* target = fPointBuffer.begin(); int count = GrPathUtils::generateQuadraticPoints(pts[0], pts[1], pts[2], kQuadTolerance, &target, maxCount); fPointBuffer.setCount(count); for (int i = 0; i < count - 1; i++) { this->lineTo(fPointBuffer[i], kCurve_CurveState); } this->lineTo(fPointBuffer[count - 1], kIndeterminate_CurveState); } void GrAAConvexTessellator::quadTo(const SkMatrix& m, SkPoint pts[3]) { m.mapPoints(pts, 3); this->quadTo(pts); } void GrAAConvexTessellator::cubicTo(const SkMatrix& m, SkPoint pts[4]) { m.mapPoints(pts, 4); int maxCount = GrPathUtils::cubicPointCount(pts, kCubicTolerance); fPointBuffer.setReserve(maxCount); SkPoint* target = fPointBuffer.begin(); int count = GrPathUtils::generateCubicPoints(pts[0], pts[1], pts[2], pts[3], kCubicTolerance, &target, maxCount); fPointBuffer.setCount(count); for (int i = 0; i < count - 1; i++) { this->lineTo(fPointBuffer[i], kCurve_CurveState); } this->lineTo(fPointBuffer[count - 1], kIndeterminate_CurveState); } // include down here to avoid compilation errors caused by "-" overload in SkGeometry.h #include "SkGeometry.h" void GrAAConvexTessellator::conicTo(const SkMatrix& m, SkPoint pts[3], SkScalar w) { m.mapPoints(pts, 3); SkAutoConicToQuads quadder; const SkPoint* quads = quadder.computeQuads(pts, w, kConicTolerance); SkPoint lastPoint = *(quads++); int count = quadder.countQuads(); for (int i = 0; i < count; ++i) { SkPoint quadPts[3]; quadPts[0] = lastPoint; quadPts[1] = quads[0]; quadPts[2] = i == count - 1 ? pts[2] : quads[1]; this->quadTo(quadPts); lastPoint = quadPts[2]; quads += 2; } } ////////////////////////////////////////////////////////////////////////////// #if GR_AA_CONVEX_TESSELLATOR_VIZ static const SkScalar kPointRadius = 0.02f; static const SkScalar kArrowStrokeWidth = 0.0f; static const SkScalar kArrowLength = 0.2f; static const SkScalar kEdgeTextSize = 0.1f; static const SkScalar kPointTextSize = 0.02f; static void draw_point(SkCanvas* canvas, const SkPoint& p, SkScalar paramValue, bool stroke) { SkPaint paint; SkASSERT(paramValue <= 1.0f); int gs = int(255*paramValue); paint.setARGB(255, gs, gs, gs); canvas->drawCircle(p.fX, p.fY, kPointRadius, paint); if (stroke) { SkPaint stroke; stroke.setColor(SK_ColorYELLOW); stroke.setStyle(SkPaint::kStroke_Style); stroke.setStrokeWidth(kPointRadius/3.0f); canvas->drawCircle(p.fX, p.fY, kPointRadius, stroke); } } static void draw_line(SkCanvas* canvas, const SkPoint& p0, const SkPoint& p1, SkColor color) { SkPaint p; p.setColor(color); canvas->drawLine(p0.fX, p0.fY, p1.fX, p1.fY, p); } static void draw_arrow(SkCanvas*canvas, const SkPoint& p, const SkPoint &n, SkScalar len, SkColor color) { SkPaint paint; paint.setColor(color); paint.setStrokeWidth(kArrowStrokeWidth); paint.setStyle(SkPaint::kStroke_Style); canvas->drawLine(p.fX, p.fY, p.fX + len * n.fX, p.fY + len * n.fY, paint); } void GrAAConvexTessellator::Ring::draw(SkCanvas* canvas, const GrAAConvexTessellator& tess) const { SkPaint paint; paint.setTextSize(kEdgeTextSize); for (int cur = 0; cur < fPts.count(); ++cur) { int next = (cur + 1) % fPts.count(); draw_line(canvas, tess.point(fPts[cur].fIndex), tess.point(fPts[next].fIndex), SK_ColorGREEN); SkPoint mid = tess.point(fPts[cur].fIndex) + tess.point(fPts[next].fIndex); mid.scale(0.5f); if (fPts.count()) { draw_arrow(canvas, mid, fPts[cur].fNorm, kArrowLength, SK_ColorRED); mid.fX += (kArrowLength/2) * fPts[cur].fNorm.fX; mid.fY += (kArrowLength/2) * fPts[cur].fNorm.fY; } SkString num; num.printf("%d", this->origEdgeID(cur)); canvas->drawString(num, mid.fX, mid.fY, paint); if (fPts.count()) { draw_arrow(canvas, tess.point(fPts[cur].fIndex), fPts[cur].fBisector, kArrowLength, SK_ColorBLUE); } } } void GrAAConvexTessellator::draw(SkCanvas* canvas) const { for (int i = 0; i < fIndices.count(); i += 3) { SkASSERT(fIndices[i] < this->numPts()) ; SkASSERT(fIndices[i+1] < this->numPts()) ; SkASSERT(fIndices[i+2] < this->numPts()) ; draw_line(canvas, this->point(this->fIndices[i]), this->point(this->fIndices[i+1]), SK_ColorBLACK); draw_line(canvas, this->point(this->fIndices[i+1]), this->point(this->fIndices[i+2]), SK_ColorBLACK); draw_line(canvas, this->point(this->fIndices[i+2]), this->point(this->fIndices[i]), SK_ColorBLACK); } fInitialRing.draw(canvas, *this); for (int i = 0; i < fRings.count(); ++i) { fRings[i]->draw(canvas, *this); } for (int i = 0; i < this->numPts(); ++i) { draw_point(canvas, this->point(i), 0.5f + (this->depth(i)/(2 * kAntialiasingRadius)), !this->movable(i)); SkPaint paint; paint.setTextSize(kPointTextSize); paint.setTextAlign(SkPaint::kCenter_Align); if (this->depth(i) <= -kAntialiasingRadius) { paint.setColor(SK_ColorWHITE); } SkString num; num.printf("%d", i); canvas->drawString(num, this->point(i).fX, this->point(i).fY+(kPointRadius/2.0f), paint); } } #endif
#include <iostream> #include <fstream> #include "hungarian.h" #include "problems.h" #include "mincost_maxflow.tpp" #include "geom_object.h" /** * Compile with: g++ -O3 -std=c++17 -o bin/test src/test.cpp -lstdc++fs * or: g++ -g -std=c++17 -o bin/test src/test.cpp -lstdc++fs * */ using namespace std; void test1(){ Hungarian_method method = Hungarian_method(); method.read_mtx("data/test/test1.in",100); method.init(); method.sparse_all(2); auto p=method.Gamma(); cout<<p.first<<" "<<p.second<<" "<<((double) p.first/p.second)*100.0<<endl; } void test2(){ pair<int,int> pair0={28,28}; string folder1="data/mnist/train/data"; string folder2="models/wgan/generator_1000/data"; vector<vector<double> > v1(28,vector<double>(28,0)); vector<vector<double> > v2(28,vector<double>(28,0)); v1[1][1]=1; v2[2][2]=1; cout<<euclidian_dist(v1,v2)<<endl; generate_graph(100,pair0, folder1, folder2); const char* filename="/tmp/mnist_mtx.txt"; Hungarian_method method = Hungarian_method(); method.run(filename,"data/test/test3.out",2000); vector<vector<double> > mtx; beolv<double>(mtx,filename,2000); Flow<double> f; auto p=f.minCost_maxMatching_flow(mtx); cout<<p.first<<" "<<p.second<<endl; std::cout<<"===== END ====="<<endl; } int main(){ ofstream myfile("./valami.txt"); myfile<<"100\n"<<"Szoveg\n"; cout<<"100\n"<<"Szoveg\n"; myfile.close(); return 0; }
// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include "operation/conv2d_transpose.h" #include "driver/nvidia_tensorrt/converter/converter.h" #include "operation/conv2d.h" #include "utility/debug.h" #include "utility/logging.h" namespace nnadapter { namespace nvidia_tensorrt { int ConvertConv2DTranspose(Converter* converter, core::Operation* operation) { CONV_2D_TRANSPOSE_OPERATION_EXTRACT_INPUTS_OUTPUTS // TensorRT doesn't support output_channel_size % groups != 0 case NNADAPTER_CHECK_EQ((output_channel_size % group), 0); NNADAPTER_CHECK_EQ(fuse_code, NNADAPTER_FUSED_NONE); if (auto_pad != NNADAPTER_AUTO_PAD_NONE) { operation::UpdateConv2DPadAndDilation( input_operand->type.dimensions.data[2], filter_height, auto_pad, &pad_height_top, &pad_height_bottom, stride_height, &dilation_height); operation::UpdateConv2DPadAndDilation( input_operand->type.dimensions.data[3], filter_width, auto_pad, &pad_width_left, &pad_width_right, stride_width, &dilation_width); } // Convert to trt tensors and node auto input_tensor = converter->GetMappedTensor(input_operand); if (!input_tensor) { input_tensor = converter->ConvertOperand(input_operand); } auto weight = converter->OperandToWeights(filter_operand); auto bias = converter->OperandToWeights(bias_operand); auto conv_layer = converter->network()->addDeconvolutionNd( *input_tensor, output_channel_size, nvinfer1::Dims2(filter_height, filter_width), weight, bias); NNADAPTER_CHECK(conv_layer); conv_layer->setStrideNd(nvinfer1::Dims2(stride_height, stride_width)); conv_layer->setPrePadding(nvinfer1::Dims2(pad_height_top, pad_width_left)); conv_layer->setPostPadding( nvinfer1::Dims2(pad_height_bottom, pad_width_right)); conv_layer->setDilationNd(nvinfer1::Dims2(dilation_height, dilation_width)); conv_layer->setNbGroups(group); auto output_tensor = conv_layer->getOutput(0); converter->UpdateTensorMap(output_operand, output_tensor); return NNADAPTER_NO_ERROR; } } // namespace nvidia_tensorrt } // namespace nnadapter
// Copyright (c) 2015-2017, RAPtor Developer Team // License: Simplified BSD, http://opensource.org/licenses/BSD-2-Clause #include "gtest/gtest.h" #include "mpi.h" #include "raptor.hpp" #include "tests/hypre_compare.hpp" #include <iostream> #include <fstream> using namespace raptor; void form_hypre_weights(double** weight_ptr, int n_rows) { int rank; MPI_Comm_rank(MPI_COMM_WORLD, &rank); hypre_SeedRand(2747 + rank); double* weights; if (n_rows) { weights = new double[n_rows]; for (int i = 0; i < n_rows; i++) { weights[i] = hypre_Rand(); } } *weight_ptr = weights; } int main(int argc, char** argv) { MPI_Init(&argc, &argv); ::testing::InitGoogleTest(&argc, argv); int temp = RUN_ALL_TESTS(); MPI_Finalize(); return temp; } // end of main() // TEST(TestHypreAgg, TestsInRuge_Stuben) { int rank, num_procs; MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &num_procs); FILE* f; int cf; double strong_threshold = 0.25; int hyp_coarsen_type = 8; // PMIS int hyp_interp_type = 6; // Extended int p_max_elmts = 0; int agg_num_levels = 0; ParCSRMatrix* A; ParVector x, b; ParMultilevel* ml; HYPRE_IJMatrix Aij; hypre_ParCSRMatrix* A_hyp; int n; aligned_vector<int> grid; double* stencil; hypre_ParVector* x_hyp; hypre_ParVector* b_hyp; HYPRE_IJVector x_h_ij; HYPRE_IJVector b_h_ij; HYPRE_Solver solver_data; hypre_ParCSRMatrix** A_array; hypre_ParCSRMatrix** P_array; #ifdef USING_MFEM /************************************ **** Test Anisotropic Diffusion ***********************************/ std::string mesh_file = std::string(MFEM_MESH_DIR) + "/star-surf.mesh"; int order = 3; int seq_refines = 4; int par_refines = 0; A = mfem_grad_div(x, b, mesh_file.c_str(), order, seq_refines, par_refines); ml = new ParRugeStubenSolver(strong_threshold, PMIS, Extended, Classical, SOR); form_hypre_weights(&ml->weights, A->local_num_rows); ml->setup(A); Aij = convert(A); HYPRE_IJMatrixGetObject(Aij, (void**) &A_hyp); compare(A, A_hyp); // Convert vectors... needed for Hypre Setup x_h_ij = convert(x); b_h_ij = convert(b); HYPRE_IJVectorGetObject(x_h_ij, (void **) &x_hyp); HYPRE_IJVectorGetObject(b_h_ij, (void **) &b_hyp); // Setup Hypre Hierarchy solver_data = hypre_create_hierarchy(A_hyp, x_hyp, b_hyp, hyp_coarsen_type, hyp_interp_type, p_max_elmts, agg_num_levels, strong_threshold); A_array = hypre_ParAMGDataAArray((hypre_ParAMGData*) solver_data); P_array = hypre_ParAMGDataPArray((hypre_ParAMGData*) solver_data); double* weights; form_hypre_weights(&weights, A->local_num_rows); for (int level = 0; level < ml->num_levels - 1; level++) { ParCSRMatrix* Al = ml->levels[level]->A; HYPRE_IJMatrix Al_ij; hypre_ParCSRMatrix* A_h; Al_ij = convert(Al); HYPRE_IJMatrixGetObject(Al_ij, (void**) &A_h); // compare(Al, A_h); hypre_ParCSRMatrix* S_h; hypre_BoomerAMGCreateS(A_h, strong_threshold, 1.0, 1, NULL, &S_h); ParCSRMatrix* S = Al->strength(Classical, strong_threshold); // compareS(S, S_h); int* CF_marker; aligned_vector<int> states; aligned_vector<int> off_proc_states; hypre_BoomerAMGCoarsenPMIS(S_h, A_h, 0, 0, &CF_marker); split_pmis(S, states, off_proc_states, false, weights); compare_states(Al->local_num_rows, states, CF_marker); int* coarse_dof_func = NULL; int* coarse_pnts_global = NULL; hypre_ParCSRMatrix* P_h; int local_num_vars = hypre_CSRMatrixNumRows(hypre_ParCSRMatrixDiag(A_h)); hypre_BoomerAMGCoarseParms(MPI_COMM_WORLD, local_num_vars, 1, NULL, CF_marker, &coarse_dof_func, &coarse_pnts_global); hypre_BoomerAMGBuildExtPIInterp(A_h, CF_marker, S_h, coarse_pnts_global, 1, NULL, 0, 0.3, 0, NULL, &P_h); ParCSRMatrix* P = extended_interpolation(Al, S, states, off_proc_states, 0.3); compare(P, P_h); hypre_ParCSRMatrix* A_h_c; hypre_BoomerAMGBuildCoarseOperatorKT(P_h, A_h, P_h, false, &A_h_c); ParCSRMatrix* AP = Al->mult(P); ParCSCMatrix* P_csc = P->to_ParCSC(); ParCSRMatrix* Ac = AP->mult_T(P_csc); hypre_ParCSRMatrixDestroy(A_h_c); hypre_ParCSRMatrixDestroy(P_h); hypre_ParCSRMatrixDestroy(S_h); HYPRE_IJMatrixDestroy(Al_ij); delete[] CF_marker; delete Ac; delete P_csc; delete AP; delete P; delete S; compare(ml->levels[level]->P, P_array[level]); compare(ml->levels[level+1]->A, A_array[level+1]); } delete[] weights; hypre_BoomerAMGDestroy(solver_data); HYPRE_IJMatrixDestroy(Aij); HYPRE_IJVectorDestroy(x_h_ij); HYPRE_IJVectorDestroy(b_h_ij); delete ml; delete A; #endif } // end of TEST(TestHypreAgg, TestsInRuge_Stuben) //
// Copyright 2002 - 2008, 2010, 2011 National Technology Engineering // Solutions of Sandia, LLC (NTESS). Under the terms of Contract // DE-NA0003525 with NTESS, the U.S. Government retains certain rights // in this software. // // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. #ifndef adapt_UniformRefinerPattern_Tri3_Tri3_4_sierra_hpp #define adapt_UniformRefinerPattern_Tri3_Tri3_4_sierra_hpp //#include "UniformRefinerPattern.hpp" #include <adapt/sierra_element/RefinementTopology.hpp> #include <adapt/sierra_element/StdMeshObjTopologies.hpp> #include "UniformRefinerPattern_Line2_Line2_2_sierra.hpp" namespace percept { template <> class UniformRefinerPattern<shards::Triangle<3>, shards::Triangle<3>, 4, SierraPort > : public URP<shards::Triangle<3>,shards::Triangle<3> > { #define EDGE_BREAKER_T3_T3_4_S 1 #if EDGE_BREAKER_T3_T3_4_S UniformRefinerPattern<shards::Line<2>, shards::Line<2>, 2, SierraPort > * m_edge_breaker; #endif public: UniformRefinerPattern(percept::PerceptMesh& eMesh, BlockNamesType block_names = BlockNamesType()) : URP<shards::Triangle<3>, shards::Triangle<3> >(eMesh), m_edge_breaker (0) { m_primaryEntityRank = m_eMesh.face_rank(); if (m_eMesh.get_spatial_dim() == 2) m_primaryEntityRank = stk::topology::ELEMENT_RANK; setNeededParts(eMesh, block_names, true); Elem::StdMeshObjTopologies::bootstrap(); #if EDGE_BREAKER_T3_T3_4_S //m_edge_breaker = Teuchos::rcp( new UniformRefinerPattern<shards::Line<2>, shards::Line<2>, 2, SierraPort > (eMesh, block_names) ); if (m_eMesh.get_spatial_dim() == 2) { m_edge_breaker = new UniformRefinerPattern<shards::Line<2>, shards::Line<2>, 2, SierraPort > (eMesh, block_names) ; } #endif } ~UniformRefinerPattern() { if (m_edge_breaker) delete m_edge_breaker; } void setSubPatterns( std::vector<UniformRefinerPatternBase *>& bp, percept::PerceptMesh& eMesh ) { EXCEPTWATCH; bp.resize(2); if (eMesh.get_spatial_dim() == 2) { bp[0] = this; #if EDGE_BREAKER_T3_T3_4_S if (m_eMesh.get_spatial_dim() == 2) { bp[1] = m_edge_breaker; } #endif } else if (eMesh.get_spatial_dim() == 3) { bp.resize(0); // FIXME // std::cout << "ERROR" ; // exit(1); } } virtual void doBreak() {} void fillNeededEntities(std::vector<NeededEntityType>& needed_entities) { needed_entities.resize(1); needed_entities[0].first = m_eMesh.edge_rank(); //needed_entities[1] = (m_eMesh.get_spatial_dim() == 2 ? stk::topology::ELEMENT_RANK : m_eMesh.face_rank()); setToOne(needed_entities); } virtual unsigned getNumNewElemPerElem() { return 4; } void createNewElements(percept::PerceptMesh& eMesh, NodeRegistry& nodeRegistry, stk::mesh::Entity element, NewSubEntityNodesType& new_sub_entity_nodes, vector<stk::mesh::Entity>::iterator& element_pool, vector<stk::mesh::Entity>::iterator& ft_element_pool, stk::mesh::FieldBase *proc_rank_field=0) { genericRefine_createNewElements(eMesh, nodeRegistry, element, new_sub_entity_nodes, element_pool, ft_element_pool, proc_rank_field); } }; } #endif
/* * Copyright Droids Corporation, Microb Technology, Eirbot (2005) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Revision : $Id: trajectory_manager.c,v 1.4.4.17 2009-05-18 12:28:36 zer0 Exp $ * */ /* Trajectory Manager v3 - zer0 - for Eurobot 2010 */ #include <string.h> #include <stdlib.h> #include <stdint.h> #include <math.h> #include <quadramp/quadramp.h> #include <aversive/position_manager/position_manager.h> extern "C" { #include <aversive/control_system_manager/control_system_manager.h> #include <aversive/math/vect2/vect2.h> #include <aversive/robot_system/robot_system.h> } #include <aversive/trajectory_manager/trajectory_manager.h> #include <aversive/trajectory_manager/trajectory_manager_utils.h> #include <aversive/trajectory_manager/trajectory_manager_core.h> /** set speed consign in quadramp filter */ void set_quadramp_speed(struct trajectory* traj, double d_speed, double a_speed) { struct quadramp_filter *q_d, *q_a; q_d = static_cast<struct quadramp_filter*>(traj->csm_distance->consign_filter_params); q_a = static_cast<struct quadramp_filter*>(traj->csm_angle->consign_filter_params); quadramp_set_1st_order_vars(q_d, fabs(d_speed), fabs(d_speed)); quadramp_set_1st_order_vars(q_a, fabs(a_speed), fabs(a_speed)); } /** get angle speed consign in quadramp filter */ double get_quadramp_angle_speed(struct trajectory* traj) { struct quadramp_filter* q_a; q_a = static_cast<struct quadramp_filter*>(traj->csm_angle->consign_filter_params); return q_a->var_1st_ord_pos; } /** get distance speed consign in quadramp filter */ double get_quadramp_distance_speed(struct trajectory* traj) { struct quadramp_filter* q_d; q_d = static_cast<struct quadramp_filter*>(traj->csm_distance->consign_filter_params); return q_d->var_1st_ord_pos; } /** set speed consign in quadramp filter */ void set_quadramp_acc(struct trajectory* traj, double d_acc, double a_acc) { struct quadramp_filter *q_d, *q_a; q_d = static_cast<struct quadramp_filter*>(traj->csm_distance->consign_filter_params); q_a = static_cast<struct quadramp_filter*>(traj->csm_angle->consign_filter_params); quadramp_set_2nd_order_vars(q_d, fabs(d_acc), fabs(d_acc)); quadramp_set_2nd_order_vars(q_a, fabs(a_acc), fabs(a_acc)); } /** remove event if any */ void delete_event(struct trajectory* traj) { set_quadramp_speed(traj, traj->d_speed, traj->a_speed); set_quadramp_acc(traj, traj->d_acc, traj->a_acc); traj->scheduled = false; } /** schedule the trajectory event */ void schedule_event(struct trajectory* traj) { traj->scheduled = true; } /** do a modulo 2.pi -> [-Pi,+Pi], knowing that 'a' is in [-3Pi,+3Pi] */ double simple_modulo_2pi(double a) { if (a < -M_PI) { a += M_2PI; } else if (a > M_PI) { a -= M_2PI; } return a; } /** do a modulo 2.pi -> [-Pi,+Pi] */ double modulo_2pi(double a) { double res = a - (((int32_t)(a / M_2PI)) * M_2PI); return simple_modulo_2pi(res); } /** near the target (dist) ? */ uint8_t is_robot_in_dist_window(struct trajectory* traj, double d_win) { double d = traj->target.pol.distance - rs_get_distance(traj->robot); d = fabs(d); d = d / traj->position->phys.distance_imp_per_mm; return d < d_win; } /** near the target (dist in x,y) ? */ uint8_t is_robot_in_xy_window(struct trajectory* traj, double d_win) { double x1 = traj->target.cart.x; double y1 = traj->target.cart.y; double x2 = position_get_x_double_unsafe(traj->position); double y2 = position_get_y_double_unsafe(traj->position); return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)) < d_win; } /** near the angle target in radian ? Only valid if * traj->target.pol.angle is set (i.e. an angle command, not an xy * command) */ uint8_t is_robot_in_angle_window(struct trajectory* traj, double a_win_rad) { double a; /* convert relative angle from imp to rad */ a = traj->target.pol.angle - rs_get_angle(traj->robot); a /= traj->position->phys.distance_imp_per_mm; a /= traj->position->phys.track_mm; a *= 2.; return fabs(a) < a_win_rad; } enum trajectory_state trajectory_get_state(struct trajectory* traj) { absl::MutexLock l(&traj->lock_); return traj->state; } int trajectory_moving_backward(struct trajectory* traj) { return cs_get_consign(traj->csm_distance) < cs_get_filtered_consign(traj->csm_distance); } int trajectory_moving_forward(struct trajectory* traj) { return cs_get_consign(traj->csm_distance) > cs_get_filtered_consign(traj->csm_distance); } int trajectory_turning(struct trajectory* traj) { if (trajectory_moving_forward(traj)) { return 0; } if (trajectory_moving_backward(traj)) { return 0; } return cs_get_consign(traj->csm_angle) != cs_get_filtered_consign(traj->csm_angle); } /* distance unit conversions */ double pos_mm2imp(struct trajectory* traj, double pos) { absl::ReaderMutexLock l(&traj->position->lock_); return pos * traj->position->phys.distance_imp_per_mm; } double pos_imp2mm(struct trajectory* traj, double pos) { absl::ReaderMutexLock l(&traj->position->lock_); return pos / traj->position->phys.distance_imp_per_mm; } double speed_mm2imp(struct trajectory* traj, double speed) { absl::ReaderMutexLock l(&traj->position->lock_); return speed * traj->position->phys.distance_imp_per_mm / traj->cs_hz; } double speed_imp2mm(struct trajectory* traj, double speed) { absl::ReaderMutexLock l(&traj->position->lock_); return speed * traj->cs_hz / traj->position->phys.distance_imp_per_mm; } double acc_mm2imp(struct trajectory* traj, double acc) { absl::ReaderMutexLock l(&traj->position->lock_); return acc * traj->position->phys.distance_imp_per_mm / (traj->cs_hz * traj->cs_hz); } double acc_imp2mm(struct trajectory* traj, double acc) { absl::ReaderMutexLock l(&traj->position->lock_); return acc * traj->cs_hz * traj->cs_hz / traj->position->phys.distance_imp_per_mm; } /* angle unit conversions */ double pos_rd2imp(struct trajectory* traj, double pos) { absl::ReaderMutexLock l(&traj->position->lock_); return pos * (traj->position->phys.distance_imp_per_mm * traj->position->phys.track_mm / 2.); } double pos_imp2rd(struct trajectory* traj, double pos) { absl::ReaderMutexLock l(&traj->position->lock_); return pos / (traj->position->phys.distance_imp_per_mm * traj->position->phys.track_mm / 2.); } double speed_rd2imp(struct trajectory* traj, double speed) { absl::ReaderMutexLock l(&traj->position->lock_); return speed * (traj->position->phys.distance_imp_per_mm * traj->position->phys.track_mm / (2. * traj->cs_hz)); } double speed_imp2rd(struct trajectory* traj, double speed) { absl::ReaderMutexLock l(&traj->position->lock_); return speed / (traj->position->phys.distance_imp_per_mm * traj->position->phys.track_mm / (2. * traj->cs_hz)); } double acc_rd2imp(struct trajectory* traj, double acc) { absl::ReaderMutexLock l(&traj->position->lock_); return acc * (traj->position->phys.distance_imp_per_mm * traj->position->phys.track_mm / (2. * traj->cs_hz * traj->cs_hz)); } double acc_imp2rd(struct trajectory* traj, double acc) { absl::ReaderMutexLock l(&traj->position->lock_); return acc / (traj->position->phys.distance_imp_per_mm * traj->position->phys.track_mm / (2. * traj->cs_hz * traj->cs_hz)); }
#include "CPlusPlus_Common.h" #include "CHOP_CPlusPlusBase.h" //// class CustomCHOP : public CHOP_CPlusPlusBase { public: CustomCHOP(const OP_NodeInfo* info) {} virtual ~CustomCHOP() {} void setupParameters(OP_ParameterManager* manager, void* reserved1) override {} void getGeneralInfo(CHOP_GeneralInfo* info, const OP_Inputs *inputs, void* reserved1) override {} bool getOutputInfo(CHOP_OutputInfo* info, const OP_Inputs *inputs, void *reserved1) override { info->numSamples = 600; info->numChannels = 1; return true; } void getChannelName(int32_t index, OP_String *name, const OP_Inputs *inputs, void* reserved1) override { name->setString("chan1"); } void execute(CHOP_Output* output, const OP_Inputs* inputs, void* reserved1) override { for (int i = 0; i < output->numSamples; i++) { float d = (float)i / (output->numSamples - 1); output->channels[0][i] = sin(d * 3.1415 * 2); } } }; //// extern "C" { DLLEXPORT void FillCHOPPluginInfo(CHOP_PluginInfo *info) { // Always set this to CHOPCPlusPlusAPIVersion. info->apiVersion = CHOPCPlusPlusAPIVersion; // The opType is the unique name for this CHOP. It must start with a // capital A-Z character, and all the following characters must lower case // or numbers (a-z, 0-9) info->customOPInfo.opType->setString("Testop"); // The opLabel is the text that will show up in the OP Create Dialog info->customOPInfo.opLabel->setString("Test OP"); // Information about the author of this OP info->customOPInfo.authorName->setString("Author Name"); info->customOPInfo.authorEmail->setString("email@email.com"); // This CHOP can work with 0 inputs info->customOPInfo.minInputs = 0; // It can accept up to 1 input though, which changes it's behavior info->customOPInfo.maxInputs = 1; } DLLEXPORT CHOP_CPlusPlusBase* CreateCHOPInstance(const OP_NodeInfo* info) { return new CustomCHOP(info); } DLLEXPORT void DestroyCHOPInstance(CHOP_CPlusPlusBase* instance) { delete (CustomCHOP*)instance; } };
// -*- C++ -*- // // Package: SiStripTools // Class: LargeEvents // /**\class LargeEvents LargeEvents.cc DPGAnalysis/SiStripTools/LargeEvents.cc Description: templated EDFilter to select events with large number of SiStripDigi or SiStripCluster Implementation: <Notes on implementation> */ // // Original Author: Andrea Venturi // Created: Tue Oct 21 20:55:22 CEST 2008 // // // system include files #include <memory> #include <string> // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/EDFilter.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/ESWatcher.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/Utilities/interface/InputTag.h" #include "DataFormats/SiStripDigi/interface/SiStripDigi.h" #include "DataFormats/SiStripCluster/interface/SiStripCluster.h" #include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h" #include "DataFormats/Common/interface/DetSetVector.h" #include "DataFormats/Common/interface/DetSetVectorNew.h" #include "DataFormats/Common/interface/DetSet.h" #include "CalibFormats/SiStripObjects/interface/SiStripQuality.h" #include "CalibTracker/Records/interface/SiStripQualityRcd.h" // // class declaration // template <class T> class LargeEvents : public edm::EDFilter { public: explicit LargeEvents(const edm::ParameterSet&); ~LargeEvents() override; private: void beginJob() override; bool filter(edm::Event&, const edm::EventSetup&) override; void endJob() override; // ----------member data --------------------------- edm::EDGetTokenT<T> _collectionToken; int _absthr; int _modthr; bool _useQuality; const SiStripQuality* _qualityHandle = nullptr; edm::ESWatcher<SiStripQualityRcd> _qualityWatcher; edm::ESGetToken<SiStripQuality, SiStripQualityRcd> _qualityToken; }; // // constants, enums and typedefs // // // static data member definitions // // // constructors and destructor // template <class T> LargeEvents<T>::LargeEvents(const edm::ParameterSet& iConfig) : _collectionToken(consumes<T>(iConfig.getParameter<edm::InputTag>("collectionName"))), _absthr(iConfig.getUntrackedParameter<int>("absoluteThreshold")), _modthr(iConfig.getUntrackedParameter<int>("moduleThreshold")), _useQuality(iConfig.getUntrackedParameter<bool>("useQuality", false)), _qualityToken(esConsumes(edm::ESInputTag{"", iConfig.getUntrackedParameter<std::string>("qualityLabel", "")})) { //now do what ever initialization is needed } template <class T> LargeEvents<T>::~LargeEvents() { // do anything here that needs to be done at desctruction time // (e.g. close files, deallocate resources etc.) } // // member functions // // ------------ method called on each new Event ------------ template <class T> bool LargeEvents<T>::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) { using namespace edm; if (_useQuality) { if (_qualityWatcher.check(iSetup)) { _qualityHandle = &iSetup.getData(_qualityToken); LogDebug("SiStripQualityUpdated") << "SiStripQuality has changed and it will be updated"; } } Handle<T> digis; iEvent.getByToken(_collectionToken, digis); int ndigitot = 0; for (typename T::const_iterator it = digis->begin(); it != digis->end(); it++) { if (!_useQuality || !_qualityHandle->IsModuleBad(it->detId())) { if (_modthr < 0 || int(it->size()) < _modthr) { ndigitot += it->size(); } } } if (ndigitot > _absthr) { LogDebug("LargeEventSelected") << "event with " << ndigitot << " digi/cluster selected"; return true; } return false; } // ------------ method called once each job just before starting event loop ------------ template <class T> void LargeEvents<T>::beginJob() {} // ------------ method called once each job just after ending the event loop ------------ template <class T> void LargeEvents<T>::endJob() {} //define this as a plug-in typedef LargeEvents<edm::DetSetVector<SiStripDigi> > LargeSiStripDigiEvents; typedef LargeEvents<edmNew::DetSetVector<SiStripCluster> > LargeSiStripClusterEvents; typedef LargeEvents<edmNew::DetSetVector<SiPixelCluster> > LargeSiPixelClusterEvents; DEFINE_FWK_MODULE(LargeSiStripDigiEvents); DEFINE_FWK_MODULE(LargeSiStripClusterEvents); DEFINE_FWK_MODULE(LargeSiPixelClusterEvents);
#pragma once #include "dbfield.hpp" #include "utility/template_magic.hpp" #include "utility/constexpr_algorithms.hpp" #include "parameter_pack/parameter_pack_helpers.hpp" #include "tuple/tuple_helpers.hpp" #include "assert/advanced_assert.h" #include "utility/memory_cast.hpp" #include <array> #include <limits> #include <string_view> #include <tuple> template <typename T, auto bitPattern> struct Tombstone { using FieldType = T; static constexpr auto id = FieldType::id; static constexpr bool is_valid_v = true; static_assert(FieldType::staticSize() == sizeof(bitPattern)); static_assert(FieldType::isField()); [[nodiscard]] consteval static auto tombstoneValue() noexcept { return bitPattern; } template <typename U> [[nodiscard]] constexpr static bool isTombstoneValue(U&& value) noexcept { static_assert(sizeof(value) == sizeof(bitPattern)); if constexpr (is_equal_comparable_v<remove_cv_and_reference_t<U>, decltype(bitPattern)>) return value == bitPattern; else { const auto localBitPattern = bitPattern; return ::memcmp(std::addressof(value), std::addressof(localBitPattern), sizeof(bitPattern)) == 0; } } }; template <auto fieldId, bool is_array> struct Tombstone<Field<std::string, fieldId, is_array>, 0> { using FieldType = Field<std::string, fieldId, is_array>; static constexpr auto id = fieldId; static constexpr bool is_valid_v = true; [[nodiscard]] consteval static std::string_view tombstoneValue() noexcept { return std::string_view(tombstoneString, std::size(tombstoneString) - 1); } template <typename U> [[nodiscard]] constexpr static bool isTombstoneValue(const std::string& value) noexcept { return value == tombstoneValue(); } private: static constexpr const char tombstoneString[] = "#1IcX~|"; }; template<> struct Tombstone<void, 0> { using FieldType = void; static constexpr auto id = -1; static constexpr bool is_valid_v = false; template <typename T> static constexpr bool isTombstoneValue(T&&) noexcept { return false; } }; using NoTombstone = Tombstone<void, 0>; // For the purposes of testing DbRecord only // The first of the fields is always the primary key template <class TombstoneField /* TODO: concept */, typename... FieldsSequence> class DbRecord { public: // Traits static consteval bool isRecord() noexcept { return true; } static consteval bool hasTombstone() noexcept { return TombstoneField::is_valid_v; } template <size_t index> using FieldTypeByIndex_t = pack::type_by_index<index, FieldsSequence...>; template <auto id> using FieldById_t = ::FieldById_t<id, FieldsSequence...>; using FieldTypesPack = type_pack<FieldsSequence...>; using KeyField = typename FieldTypesPack::template Type<0>; public: constexpr DbRecord() = default; template <typename... Values> constexpr explicit DbRecord(Values&&... values) : _fields{std::forward<Values>(values)...} { static_assert(sizeof...(Values) == sizeof...(FieldsSequence)); } template <typename Field> constexpr const auto& fieldValue() const & noexcept { return std::get<pack::index_for_type_v<Field, FieldsSequence...>>(_fields).value; } template <typename Field> constexpr auto& fieldValue() & noexcept { return std::get<pack::index_for_type_v<Field, FieldsSequence...>>(_fields).value; } static consteval bool allFieldsHaveStaticSize() noexcept { bool nonStaticSizeFieldDetected = false; pack::for_type<FieldsSequence...>([&nonStaticSizeFieldDetected](auto type) { if (!decltype(type)::type::sizeKnownAtCompileTime()) nonStaticSizeFieldDetected = true; }); return nonStaticSizeFieldDetected == false; } static consteval size_t staticFieldsCount() noexcept { size_t count = 0; static_for<0, sizeof...(FieldsSequence)>([&count](auto i) { using FieldType = pack::type_by_index<i, FieldsSequence...>; if constexpr (FieldType::sizeKnownAtCompileTime() == true) ++count; }); return count; } static consteval size_t staticFieldsSize() noexcept { size_t totalSize = 0; static_for<0, staticFieldsCount()>([&totalSize](auto i) { using FieldType = pack::type_by_index<i, FieldsSequence...>; static_assert(FieldType::sizeKnownAtCompileTime() == true); totalSize += FieldType::staticSize(); }); return totalSize; } size_t totalSize() const noexcept { size_t totalSize = staticFieldsSize(); static_for<staticFieldsCount(), sizeof...(FieldsSequence)>([&totalSize, this](auto i) { using FieldType = pack::type_by_index<i, FieldsSequence...>; static_assert(FieldType::sizeKnownAtCompileTime() == false); totalSize += std::get<i>(_fields).fieldSize(); }); return totalSize; } template <int index> constexpr auto& fieldAtIndex() & noexcept { return std::get<index>(_fields); } template <int index> constexpr const auto& fieldAtIndex() const & noexcept { return std::get<index>(_fields); } static consteval size_t fieldCount() noexcept { return sizeof...(FieldsSequence); } template <typename U> static constexpr bool isTombstoneValue(U&& value) noexcept { return TombstoneField::isTombstoneValue(std::forward<U>(value)); } constexpr bool operator==(const DbRecord& other) const noexcept { return _fields == other._fields; } template <typename F> static constexpr bool has_field_v = pack::has_type_v<F, FieldsSequence...>; // // All the junk below is for compile-time correctness validation only. // private: static consteval bool checkAssertions() noexcept { static_assert(sizeof...(FieldsSequence) > 0); static_assert((FieldsSequence::isField() && ...), "All template parameter types must be Fields!"); static_assert(TombstoneField::is_valid_v == true || TombstoneField::is_valid_v == false, "The first template parameter must beither Tombstone<FieldType>, or NoTombstone."); static_assert(!TombstoneField::is_valid_v || pack::has_type_v<typename TombstoneField::FieldType, FieldsSequence...>, "The tombstone field must be one of the fields in this DbRecord"); static_assert(std::is_same_v<typename pack::type_by_index<0, FieldsSequence...>, std::tuple_element_t<0, std::tuple<FieldsSequence...>>>); constexpr_for_z<1, sizeof...(FieldsSequence)>([](auto index) { using Field1 = typename pack::type_by_index<index - 1, FieldsSequence...>; using Field2 = typename pack::type_by_index<index, FieldsSequence...>; static_assert(!(Field1::sizeKnownAtCompileTime() == false && Field2::sizeKnownAtCompileTime() == true), "All the fields with compile-time size must be grouped before fields with dynamic size."); static_assert(pack::type_count<Field1, FieldsSequence...>() == 1 && pack::type_count<Field2, FieldsSequence...>() == 1, "Each unique field type shall only be specified once within a record!"); static_assert(Field1::id != Field2::id, "All the fields must have different IDs!"); static_assert(std::is_same_v<Field2, std::tuple_element_t<index, std::tuple<FieldsSequence...>>>); }); return true; } static_assert(checkAssertions()); static_assert(std::numeric_limits<unsigned char>::digits == 8, "No funny business!"); static_assert(sizeof...(FieldsSequence) > 0); private: std::tuple<FieldsSequence...> _fields; };
/*****************************************************************************/ /** * @file Stl.cpp * @author Naohisa Sakamoto */ /*---------------------------------------------------------------------------- * * Copyright (c) Visualization Laboratory, Kyoto University. * All rights reserved. * See http://www.viz.media.kyoto-u.ac.jp/kvs/copyright/ for details. * * $Id: Stl.cpp 1718 2014-03-08 08:59:23Z naohisa.sakamoto@gmail.com $ */ /*****************************************************************************/ #include "Stl.h" #include <cstring> #include <kvs/File> #include <kvs/Assert> namespace { const int MaxLineLength = 256; const char* const Delimiter = " \t\n\r"; const std::string FileTypeToString[2] = { "ascii", "binary" }; } namespace { /*===========================================================================*/ /** * @brief Returns true if the file type is 'ascii'. * @param ifs [in] file pointer * @return true ('ascii') or false ('binary') */ /*===========================================================================*/ bool IsAsciiType( FILE* ifs ) { // Go back file-pointer to head. fseek( ifs, 0, SEEK_SET ); // Check file type. char buffer[ ::MaxLineLength ]; while ( fgets( buffer, ::MaxLineLength, ifs ) != 0 ) { if ( buffer[0] == '\n' ) continue; const char* head = strtok( buffer, ::Delimiter ); if ( !strcmp( head, "solid" ) ) break; else if ( !strcmp( head, "facet" ) ) return true; else return false; } size_t counter = 0; while ( fgets( buffer, ::MaxLineLength, ifs ) != 0 ) { if ( counter > 5 ) return false; if ( buffer[0] == '\n' ) continue; if ( strstr( buffer, "endsolid" ) ) return true; if ( strstr( buffer, "facet" ) ) return true; counter++; } return false; } } // end of namespace namespace kvs { bool Stl::CheckExtension( const std::string& filename ) { const kvs::File file( filename ); if ( file.extension() == "stl" || file.extension() == "STL" || file.extension() == "stla" || file.extension() == "STLA" || file.extension() == "stlb" || file.extension() == "STLB" || file.extension() == "sla" || file.extension() == "SLA" || file.extension() == "slb" || file.extension() == "SLB" ) { return true; } return false; } /*===========================================================================*/ /** * @brief Constructs a new STL class. */ /*===========================================================================*/ Stl::Stl(): m_file_type( Stl::Ascii ) { } /*===========================================================================*/ /** * @brief Constructs a new STL class and reads a file. * @param filename [in] filename */ /*===========================================================================*/ Stl::Stl( const std::string& filename ): m_file_type( Stl::Ascii ) { this->read( filename ); } /*===========================================================================*/ /** * @brief Destructs the STL class. */ /*===========================================================================*/ Stl::~Stl() { } /*===========================================================================*/ /** * @brief Prints the file information. * @param os [in] output stream * @param indent [in] indent */ /*===========================================================================*/ void Stl::print( std::ostream& os, const kvs::Indent& indent ) const { os << indent << "Filename : " << BaseClass::filename() << std::endl; os << indent << "File type : " << ::FileTypeToString[ m_file_type ] << std::endl; os << indent << "Number of triangles : " << m_normals.size() / 3; } /*===========================================================================*/ /** * @brief Read a STL file. * @param filename [in] filename * @return true, if the reading process is done successfully */ /*===========================================================================*/ bool Stl::read( const std::string& filename ) { BaseClass::setFilename( filename ); BaseClass::setSuccess( true ); FILE* ifs = fopen( filename.c_str(), "r" ); if ( !ifs ) { kvsMessageError( "Cannot open %s.", filename.c_str() ); BaseClass::setSuccess( false ); return false; } bool success = false; if ( ::IsAsciiType( ifs ) ) { m_file_type = Stl::Ascii; success = this->read_ascii( ifs ); } else { m_file_type = Stl::Binary; success = this->read_binary( ifs ); } BaseClass::setSuccess( success ); fclose( ifs ); return success; } /*===========================================================================*/ /** * @brief Writes the polygon data to a file as STL format. * @param filename [in] filename * @return true, if the writting process is done successfully */ /*===========================================================================*/ bool Stl::write( const std::string& filename ) { KVS_ASSERT( ( m_normals.size() / 3 ) == ( m_coords.size() / 9 ) ); BaseClass::setFilename( filename ); BaseClass::setSuccess( true ); FILE* ofs = fopen( filename.c_str(), "w" ); if ( !ofs ) { kvsMessageError( "Cannot open %s.", filename.c_str() ); BaseClass::setSuccess( false ); return false; } bool success = false; if ( m_file_type == Stl::Ascii ) { success = this->write_ascii( ofs ); } else { success = this->write_binary( ofs ); } BaseClass::setSuccess( success ); fclose( ofs ); return success; } /*===========================================================================*/ /** * @brief Check file type whether the ascii or the binary. * @param ifs [in] file pointer * @return true, if the file type is ascii */ /*===========================================================================*/ bool Stl::is_ascii_type( FILE* ifs ) { // Go back file-pointer to head. fseek( ifs, 0, SEEK_SET ); // Check file type. char buffer[ ::MaxLineLength ]; while ( fgets( buffer, ::MaxLineLength, ifs ) != 0 ) { if ( buffer[0] == '\n' ) continue; const char* head = strtok( buffer, ::Delimiter ); if ( !strcmp( head, "solid" ) ) break; else if ( !strcmp( head, "facet" ) ) return true; else return false; } size_t counter = 0; while ( fgets( buffer, ::MaxLineLength, ifs ) != 0 ) { if ( counter > 5 ) return false; if ( buffer[0] == '\n' ) continue; if ( strstr( buffer, "endsolid" ) ) return true; if ( strstr( buffer, "facet" ) ) return true; counter++; } return false; } /*===========================================================================*/ /** * @brief Reads the polygon data as ascii format. * @param ifs [in] file pointer * @return true, if the reading process is done successfully */ /*===========================================================================*/ bool Stl::read_ascii( FILE* ifs ) { // Go back file-pointer to head. fseek( ifs, 0, SEEK_SET ); // Check head line. char buffer[ ::MaxLineLength ]; while ( fgets( buffer, ::MaxLineLength, ifs ) != 0 ) { if ( buffer[0] == '\n' ) continue; const char* head = strtok( buffer, ::Delimiter ); if ( !strcmp( head, "solid" ) ) break; if ( !strcmp( head, "facet" ) ) { fseek( ifs, 0, SEEK_SET ); break; } } std::vector<kvs::Real32> normals; std::vector<kvs::Real32> coords; while ( fgets( buffer, ::MaxLineLength, ifs ) != 0 ) { if ( buffer[0] == '\n' ) continue; if ( strstr( buffer, "endsolid" ) ) break; // facet const char* facet = strtok( buffer, ::Delimiter ); if ( !strcmp( facet, "facet" ) ) { strtok( 0, ::Delimiter ); // 'normal' normals.push_back( static_cast<kvs::Real32>( atof( strtok( 0, ::Delimiter ) ) ) ); normals.push_back( static_cast<kvs::Real32>( atof( strtok( 0, ::Delimiter ) ) ) ); normals.push_back( static_cast<kvs::Real32>( atof( strtok( 0, ::Delimiter ) ) ) ); } else { kvsMessageError("Cannot find 'facet'."); return false; } // outer loop if ( fgets( buffer, ::MaxLineLength, ifs ) == 0 ) return false; const char* outer = strtok( buffer, ::Delimiter ); const char* loop = strtok( 0, ::Delimiter ); if ( strcmp( outer, "outer" ) || strcmp( loop, "loop" ) ) { kvsMessageError("Cannot find 'outer loop'."); return false; } // vertex 0 if ( fgets( buffer, ::MaxLineLength, ifs ) == 0 ) return false; const char* vertex0 = strtok( buffer, ::Delimiter ); if ( !strcmp( vertex0, "vertex" ) ) { coords.push_back( static_cast<kvs::Real32>( atof( strtok( 0, ::Delimiter ) ) ) ); coords.push_back( static_cast<kvs::Real32>( atof( strtok( 0, ::Delimiter ) ) ) ); coords.push_back( static_cast<kvs::Real32>( atof( strtok( 0, ::Delimiter ) ) ) ); } else { kvsMessageError("Cannot find 'vertex' (0)."); return false; } // vertex 1 if ( fgets( buffer, ::MaxLineLength, ifs ) == 0 ) return false; const char* vertex1 = strtok( buffer, ::Delimiter ); if ( !strcmp( vertex1, "vertex" ) ) { coords.push_back( static_cast<kvs::Real32>( atof( strtok( 0, ::Delimiter ) ) ) ); coords.push_back( static_cast<kvs::Real32>( atof( strtok( 0, ::Delimiter ) ) ) ); coords.push_back( static_cast<kvs::Real32>( atof( strtok( 0, ::Delimiter ) ) ) ); } else { kvsMessageError("Cannot find 'vertex' (1)."); return false; } // vertex 2 if ( fgets( buffer, ::MaxLineLength, ifs ) == 0 ) return false; const char* vertex2 = strtok( buffer, ::Delimiter ); if ( !strcmp( vertex2, "vertex" ) ) { coords.push_back( static_cast<kvs::Real32>( atof( strtok( 0, ::Delimiter ) ) ) ); coords.push_back( static_cast<kvs::Real32>( atof( strtok( 0, ::Delimiter ) ) ) ); coords.push_back( static_cast<kvs::Real32>( atof( strtok( 0, ::Delimiter ) ) ) ); } else { kvsMessageError("Cannot find 'vertex' (2)."); return false; } // endloop if ( fgets( buffer, ::MaxLineLength, ifs ) == 0 ) return false; const char* endloop = strtok( buffer, ::Delimiter ); if ( strcmp( endloop, "endloop" ) ) { kvsMessageError("Cannot find 'endloop'."); return false; } // endfacet if ( fgets( buffer, ::MaxLineLength, ifs ) == 0 ) return false; const char* endfacet = strtok( buffer, ::Delimiter ); if ( strcmp( endfacet, "endfacet" ) ) { kvsMessageError("Cannot find 'endfacet'."); return false; } } m_normals = kvs::ValueArray<kvs::Real32>( normals ); m_coords = kvs::ValueArray<kvs::Real32>( coords ); return true; } /*===========================================================================*/ /** * @brief Reads the polygon data as binary format. * @param ifs [in] file pointer * @return true, if the reading process is done successfully */ /*===========================================================================*/ bool Stl::read_binary( FILE* ifs ) { // Go back file-pointer to head. fseek( ifs, 0, SEEK_SET ); // Read header string (80bytes). const size_t HeaderLength = 80; char buffer[ HeaderLength ]; if ( fread( buffer, sizeof( char ), HeaderLength, ifs ) != HeaderLength ) { kvsMessageError("Cannot read a header string (80byets)."); return false; } // Read a number of triangles (4bytes). kvs::UInt32 ntriangles = 0; if ( fread( &ntriangles, sizeof( kvs::UInt32 ), 1, ifs ) != 1 ) { kvsMessageError("Cannot read a number of triangles."); return false; } // Memory allocation. m_normals.allocate( ntriangles * 3 ); m_coords.allocate( ntriangles * 9 ); // Read trianbles. kvs::Real32* normals = m_normals.data(); kvs::Real32* coords = m_coords.data(); kvs::UInt32 index3 = 0; kvs::UInt32 index9 = 0; for ( kvs::UInt32 i = 0; i < ntriangles; i++, index3 += 3, index9 += 9 ) { // Normal vector (4x3=12byets) if ( fread( normals + index3, sizeof( kvs::Real32 ), 3, ifs ) != 3 ) { kvsMessageError("Cannot read a normal vector."); m_normals.release(); return false; } // Coordinate value (4x3=12bytes) if ( fread( coords + index9, sizeof( kvs::Real32 ), 9, ifs ) != 9 ) { kvsMessageError("Cannot read a coordinate value."); m_coords.release(); return false; } // Unused (2bytes) // NOTE: This block is sometimes used for storing color infomartion, // but we don't currently supported such color STL format. char unused[2]; if ( fread( unused, sizeof( char ), 2, ifs ) != 2 ) { kvsMessageError("Cannot read unused block (2bytes)."); m_normals.release(); m_coords.release(); return false; } } return true; } /*===========================================================================*/ /** * @brief Writes the polygon data as ascii format. * @param ifs [in] file pointer * @return true, if the writting process is done successfully */ /*===========================================================================*/ bool Stl::write_ascii( FILE* ofs ) { const char* header = "Generated by KVS"; fprintf( ofs, "solid %s\n", header ); const size_t ntriangles = m_normals.size() / 3; size_t index3 = 0; size_t index9 = 0; for ( size_t i = 0; i < ntriangles; i++, index3 += 3, index9 += 9 ) { fprintf( ofs, "facet normal %f %f %f\n", m_normals[ index3 + 0 ], m_normals[ index3 + 1 ], m_normals[ index3 + 2 ] ); fprintf( ofs, "outer loop\n" ); fprintf( ofs, "vertex %f %f %f\n", m_coords[ index9 + 0 ], m_coords[ index9 + 1 ], m_coords[ index9 + 2 ] ); fprintf( ofs, "vertex %f %f %f\n", m_coords[ index9 + 3 ], m_coords[ index9 + 4 ], m_coords[ index9 + 5 ] ); fprintf( ofs, "vertex %f %f %f\n", m_coords[ index9 + 6 ], m_coords[ index9 + 7 ], m_coords[ index9 + 8 ] ); fprintf( ofs, "endloop\n" ); fprintf( ofs, "endfacet\n" ); } fprintf( ofs, "endsolid\n" ); return true; } /*===========================================================================*/ /** * @brief Writes the polygon data as binary format. * @param ifs [in] file pointer * @return true, if the writting process is done successfully */ /*===========================================================================*/ bool Stl::write_binary( FILE* ofs ) { // Header string (80bytes). char header[80]; memset( header, 0, 80 ); sprintf( header, "Generated by KVS" ); if ( fwrite( header, sizeof( char ), 80, ofs ) != 80 ) { kvsMessageError("Cannot write a header string (80bytes)."); return false; } // Number of triangles (4bytes). const kvs::UInt32 ntriangles = static_cast<kvs::UInt32>( m_normals.size() / 3 ); if ( fwrite( &ntriangles, sizeof( kvs::UInt32 ), 1, ofs ) != 1 ) { kvsMessageError("Cannot write a number of triangles."); return false; } // Triangles (50*ntriangles bytes) const kvs::Real32* normals = m_normals.data(); const kvs::Real32* coords = m_coords.data(); size_t index3 = 0; size_t index9 = 0; for ( size_t i = 0; i < ntriangles; i++, index3 += 3, index9 += 9 ) { // Normal vector if ( fwrite( normals + index3, sizeof( kvs::Real32 ), 3, ofs ) != 3 ) { kvsMessageError("Cannot write a normal vector."); return false; } // Coordinate values if ( fwrite( coords + index9, sizeof( kvs::Real32 ), 9, ofs ) != 9 ) { kvsMessageError("Cannot write a coordinate values (3 vertices = 9 elements)."); return false; } // Unused block (2bytes) const char unused[2] = {0,0}; if ( fwrite( unused, sizeof( char ), 2, ofs ) != 2 ) { kvsMessageError("Cannot write a unused block (2byets)."); return false; } } return true; } } // end of namespace kvs
/*============================================================================= Copyright (C) 2016 yumetodo Distributed under the Boost Software License, Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ #include "../include/string_split.hpp" #include <iostream> int to_int(const std::string& s) { return std::stoi(s); } int main() { std::string s = "arikitari na world!"; const auto s_1 = s | split(' ')[1]; if ("na" != s_1) return 1; std::string s2 = "123,421,113"; //lamda or class contain operator() const auto n1 = s2 | split(',') >> [](const std::string& s) { return std::stoi(s); }; //std::stoi's prototype is int(const std::string&, std::size_t*, int), not int(const std::string&). //const auto n2 = s2 | split(',') >> std::stoi; //function-pointer const auto n2 = s2 | split(',') >> to_int; if (n1 != n2) return 2; s2 | split(',') >> [](std::string&& s) { std::cout << s << std::endl; }; #ifdef STRING_SPLIT_HAS_CXX17_STRING_VIEW std::string_view sw = "arikitari na sekai"; const auto r = sw | split(' ') >> back(); #endif return 0; }
/* * Copyright (C) 2016 Turi * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <cstdlib> #include <iostream> #include <boost/program_options.hpp> #include <regex> #include <boost/algorithm/string.hpp> #include <fileio/fs_utils.hpp> #include <fileio/sanitize_url.hpp> #include <fileio/general_fstream.hpp> #include <fileio/s3_api.hpp> namespace po = boost::program_options; constexpr size_t BUFFER_SIZE = 4 * 1024 * 1024; /* 4MB */ void print_help(char** argv) { std::cout << "Usage: \n"; std::cout << argv[0] << " cp [src] [dst]\n"; std::cout << argv[0] << " mkdir [dst]\n"; std::cout << argv[0] << " ls [path]\n"; std::cout << argv[0] << " rm [path] # deletes one file\n"; std::cout << argv[0] << " rmr [path] # recursive deletion of a directory\n\n"; std::cout << "All paths can be local, hdfs, or s3:// paths\n"; std::cout << "The environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY will be used if available\n"; std::cout << "file globs are supported for ls. Not for the rest\n"; } void include_s3_environment(std::string& path) { if (boost::starts_with(path, "s3://")) { size_t colon_count = 0; for (char c: path) colon_count += (c == ':'); // we probably already have the secret keys in the URL if (colon_count >= 2) return; // otherwise, lets try to add the keys const char* accesskey = getenv("AWS_ACCESS_KEY_ID"); const char* secretkey = getenv("AWS_SECRET_ACCESS_KEY"); if (accesskey != NULL && secretkey != NULL) { path = path.substr(5); // remove the s3:// if (boost::starts_with(path, "/")) path = path.substr(1); // people may accidentally put s3:/// path = "s3://" + std::string(accesskey) + ":" + std::string(secretkey) + ":" + path; } } } bool file_copy(std::string srcpath, std::string dstpath) { try { graphlab::general_ifstream fin(srcpath); graphlab::general_ofstream fout(dstpath); char* buffer = new char[BUFFER_SIZE]; size_t filesize = fin.file_size(); std::cout << "Copying " << filesize << " bytes\n"; while(fin.good()) { fin.read(buffer, BUFFER_SIZE); fout.write(buffer, fin.gcount()); } } catch (std::string s) { std::cerr << s << "\n"; return false; } return true; } bool recursive_copy(std::string srcpath, std::string dstpath) { // both src and dst must be directories // I am copying the contents of src into the contents of dst // create descendent directories bool success = graphlab::fileio::create_directory(dstpath); if (!success) { std::cerr << "Unable to create directory at " << graphlab::sanitize_url(dstpath) << "\n"; return false; } auto srcentries = graphlab::fileio::get_directory_listing(srcpath); for(auto srcfile: srcentries) { std::string dstfile = dstpath + "/" + graphlab::fileio::get_filename(srcfile.first); if (srcfile.second == graphlab::fileio::file_status::REGULAR_FILE) { // is a file. copy it success = file_copy(srcfile.first, dstfile); } else { // is a directory. recursively copy it success = recursive_copy(srcfile.first, dstfile); } if (!success) return false; } return true; } /// cp implementation. Behaves like cp. int cp_impl(std::string srcpath, std::string dstpath) { auto src_type = graphlab::fileio::get_file_status(srcpath); auto dst_type = graphlab::fileio::get_file_status(dstpath); if (src_type == graphlab::fileio::file_status::MISSING) { // missing source file std::cerr << "Source file missing\n"; return 1; } else if (src_type == graphlab::fileio::file_status::REGULAR_FILE) { // source file is a single file if (dst_type == graphlab::fileio::file_status::MISSING || dst_type == graphlab::fileio::file_status::REGULAR_FILE) { // target is missing, or I am overwriting file_copy(srcpath, dstpath); } else { // if target is a directory... we need to come up with the target filename file_copy(srcpath, dstpath + "/" + graphlab::fileio::get_filename(srcpath)); } } else if (src_type == graphlab::fileio::file_status::DIRECTORY) { // copying a directory if (dst_type == graphlab::fileio::file_status::REGULAR_FILE) { std::cerr << "Cannot create target directory. File already exists"; return 1; } else { recursive_copy(srcpath, dstpath + "/" + graphlab::fileio::get_filename(srcpath)); } } return 0; } /// glob free ls int simple_ls_impl(std::string url) { try { auto response = graphlab::fileio::get_directory_listing(url); for(auto entry: response) { std::cout << graphlab::sanitize_url(entry.first); if (entry.second == graphlab::fileio::file_status::DIRECTORY) { std::cout << "/"; } std::cout << "\n"; } std::cout << "\n"; std::cout << response.size() << " entries found\n"; } catch (std::string s) { std::cerr << s << "\n"; return 1; } return 0; } std::string glob_to_regex(std::string glob) { // this is horribly incomplete. But works sufficiently boost::replace_all(glob, "/", "\\/"); boost::replace_all(glob, "?", "."); boost::replace_all(glob, "*", ".*"); return glob; } /// enumerates contents of "url", testing the rest against the glob int glob_ls_impl(std::string url, std::string glob) { try { size_t ctr = 0; auto response = graphlab::fileio::get_directory_listing(url); std::regex glob_regex(glob_to_regex(glob)); for(auto entry: response) { if (std::regex_match(graphlab::fileio::get_filename(entry.first), glob_regex)) { std::cout << graphlab::sanitize_url(entry.first); ++ctr; if (entry.second == graphlab::fileio::file_status::DIRECTORY) { std::cout << "/"; } std::cout << "\n"; } } std::cout << "\n"; std::cout << ctr << " entries found\n"; } catch (std::string s) { std::cerr << s << "\n"; return 1; } std::cout << "\n"; return 0; } int main(int argc, char** argv) { if (argc == 1) { print_help(argv); return 0; } std::string command = argv[1]; if (command == "cp" && argc == 4) { std::string srcpath = argv[2]; std::string dstpath = argv[3]; // if srcpath or dstpath have a trailing slash, drop it if (boost::ends_with(srcpath, "/")) srcpath = srcpath.substr(0, srcpath.length() - 1); if (boost::ends_with(dstpath, "/")) dstpath = dstpath.substr(0, dstpath.length() - 1); include_s3_environment(srcpath); include_s3_environment(dstpath); return cp_impl(srcpath, dstpath); } else if (command == "mkdir" && argc == 3) { std::string dstpath = argv[2]; bool success = graphlab::fileio::create_directory(dstpath); if (!success) { std::cerr << "Unable to create directory at " << graphlab::sanitize_url(dstpath) << "\n"; return false; } } else if (command == "rm" && argc == 3) { std::string dstpath = argv[2]; include_s3_environment(dstpath); bool success = graphlab::fileio::delete_path(dstpath); if (!success) { std::cerr << "Unable to delete path at " << graphlab::sanitize_url(dstpath) << "\n"; return false; } } else if (command == "rmr" && argc == 3) { std::string dstpath = argv[2]; include_s3_environment(dstpath); bool success = graphlab::fileio::delete_path_recursive(dstpath); if (!success) { std::cerr << "Unable to recursively delete path at " << graphlab::sanitize_url(dstpath) << "\n"; return false; } } else if (command == "ls" && argc == 3) { std::string url = argv[2]; include_s3_environment(url); std::string filename = graphlab::fileio::get_filename(url); // is there globs? size_t globchars = 0; for (char c: filename) globchars += (c == '*' || c == '?'); if (globchars == 0) { return simple_ls_impl(url); } else { return glob_ls_impl(graphlab::fileio::get_dirname(url), filename); } } else if (command == "--help") { print_help(argv); } else { std::cout << "Invalid command\n"; return 1; } return 0; }
#include "FWCore/Framework/interface/EDAnalyzer.h" #include "FWCore/Framework/interface/Run.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "DataFormats/Common/interface/Handle.h" #include "DataFormats/HLTReco/interface/TriggerObject.h" #include "DataFormats/HLTReco/interface/TriggerEvent.h" #include "DQMServices/Core/interface/DQMStore.h" // see header file for information. #include "FourVectorHLT.h" using namespace edm; FourVectorHLT::FourVectorHLT(const edm::ParameterSet& iConfig) { LogDebug("FourVectorHLT") << "constructor...."; dbe_ = Service<DQMStore>().operator->(); if (!dbe_) { LogWarning("Status") << "unable to get DQMStore service?"; } dirname_ = "HLT/FourVectorHLT"; if (dbe_ != nullptr) { LogDebug("Status") << "Setting current directory to " << dirname_; dbe_->setCurrentFolder(dirname_); } // plotting paramters ptMin_ = iConfig.getUntrackedParameter<double>("ptMin", 0.); ptMax_ = iConfig.getUntrackedParameter<double>("ptMax", 200.); nBins_ = iConfig.getUntrackedParameter<unsigned int>("Nbins", 50); plotAll_ = iConfig.getUntrackedParameter<bool>("plotAll", false); // this is the list of paths to look at. std::vector<edm::ParameterSet> filters = iConfig.getParameter<std::vector<edm::ParameterSet> >("filters"); for (std::vector<edm::ParameterSet>::iterator filterconf = filters.begin(); filterconf != filters.end(); filterconf++) { std::string me = filterconf->getParameter<std::string>("name"); int objectType = filterconf->getParameter<unsigned int>("type"); float ptMin = filterconf->getUntrackedParameter<double>("ptMin"); float ptMax = filterconf->getUntrackedParameter<double>("ptMax"); hltPaths_.push_back(PathInfo(me, objectType, ptMin, ptMax)); } if (!hltPaths_.empty() && plotAll_) { // these two ought to be mutually exclusive.... LogWarning("Configuration") << "Using both plotAll and a list. " "list will be ignored."; hltPaths_.clear(); } triggerSummaryLabel_ = iConfig.getParameter<edm::InputTag>("triggerSummaryLabel"); //set Token(-s) triggerSummaryToken_ = consumes<trigger::TriggerEvent>(iConfig.getParameter<edm::InputTag>("triggerSummaryLabel")); } FourVectorHLT::~FourVectorHLT() { // do anything here that needs to be done at desctruction time // (e.g. close files, deallocate resources etc.) } // // member functions // // ------------ method called to for each event ------------ void FourVectorHLT::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { using namespace edm; using namespace trigger; ++nev_; LogDebug("Status") << "analyze"; edm::Handle<TriggerEvent> triggerObj; iEvent.getByToken(triggerSummaryToken_, triggerObj); if (!triggerObj.isValid()) { edm::LogInfo("Status") << "Summary HLT object (TriggerEvent) not found, " "skipping event"; return; } const trigger::TriggerObjectCollection& toc(triggerObj->getObjects()); if (plotAll_) { for (size_t ia = 0; ia < triggerObj->sizeFilters(); ++ia) { std::string fullname = triggerObj->filterTag(ia).encode(); // the name can have in it the module label as well as the process and // other labels - strip 'em std::string name; size_t p = fullname.find_first_of(':'); if (p != std::string::npos) { name = fullname.substr(0, p); } else { name = fullname; } LogDebug("Parameter") << "filter " << ia << ", full name = " << fullname << ", p = " << p << ", abbreviated = " << name; PathInfoCollection::iterator pic = hltPaths_.find(name); if (pic == hltPaths_.end()) { // doesn't exist - add it MonitorElement *et(nullptr), *eta(nullptr), *phi(nullptr), *etavsphi(nullptr); std::string histoname(name + "_et"); LogDebug("Status") << "new histo with name " << histoname; dbe_->setCurrentFolder(dirname_); std::string title(name + " E_{T}"); et = dbe_->book1D(histoname.c_str(), title.c_str(), nBins_, 0, 100); histoname = name + "_eta"; title = name + " #eta"; eta = dbe_->book1D(histoname.c_str(), title.c_str(), nBins_, -2.7, 2.7); histoname = name + "_phi"; title = name + " #phi"; phi = dbe_->book1D(histoname.c_str(), title.c_str(), nBins_, -3.14, 3.14); histoname = name + "_etaphi"; title = name + " #eta vs #phi"; etavsphi = dbe_->book2D(histoname.c_str(), title.c_str(), nBins_, -2.7, 2.7, nBins_, -3.14, 3.14); // no idea how to get the bin boundries in this mode PathInfo e(name, 0, et, eta, phi, etavsphi, ptMin_, ptMax_); hltPaths_.push_back(e); pic = hltPaths_.begin() + hltPaths_.size() - 1; } const trigger::Keys& k = triggerObj->filterKeys(ia); for (trigger::Keys::const_iterator ki = k.begin(); ki != k.end(); ++ki) { LogDebug("Parameters") << "pt, eta, phi = " << toc[*ki].pt() << ", " << toc[*ki].eta() << ", " << toc[*ki].phi(); pic->getEtHisto()->Fill(toc[*ki].pt()); pic->getEtaHisto()->Fill(toc[*ki].eta()); pic->getPhiHisto()->Fill(toc[*ki].phi()); pic->getEtaVsPhiHisto()->Fill(toc[*ki].eta(), toc[*ki].phi()); } } } else { // not plotAll_ for (PathInfoCollection::iterator v = hltPaths_.begin(); v != hltPaths_.end(); ++v) { const int index = triggerObj->filterIndex(v->getName()); if (index >= triggerObj->sizeFilters()) { continue; // not in this event } LogDebug("Status") << "filling ... "; const trigger::Keys& k = triggerObj->filterKeys(index); for (trigger::Keys::const_iterator ki = k.begin(); ki != k.end(); ++ki) { v->getEtHisto()->Fill(toc[*ki].pt()); v->getEtaHisto()->Fill(toc[*ki].eta()); v->getPhiHisto()->Fill(toc[*ki].phi()); v->getEtaVsPhiHisto()->Fill(toc[*ki].eta(), toc[*ki].phi()); } } } } // -- method called once each job just before starting event loop -------- void FourVectorHLT::beginJob() { nev_ = 0; DQMStore* dbe = nullptr; dbe = Service<DQMStore>().operator->(); if (dbe) { dbe->setCurrentFolder(dirname_); if (!plotAll_) { for (PathInfoCollection::iterator v = hltPaths_.begin(); v != hltPaths_.end(); ++v) { MonitorElement *et, *eta, *phi, *etavsphi = nullptr; std::string histoname(v->getName() + "_et"); std::string title(v->getName() + " E_t"); et = dbe->book1D(histoname.c_str(), title.c_str(), nBins_, v->getPtMin(), v->getPtMax()); histoname = v->getName() + "_eta"; title = v->getName() + " #eta"; eta = dbe->book1D(histoname.c_str(), title.c_str(), nBins_, -2.7, 2.7); histoname = v->getName() + "_phi"; title = v->getName() + " #phi"; phi = dbe->book1D(histoname.c_str(), histoname.c_str(), nBins_, -3.14, 3.14); histoname = v->getName() + "_etaphi"; title = v->getName() + " #eta vs #phi"; etavsphi = dbe->book2D(histoname.c_str(), title.c_str(), nBins_, -2.7, 2.7, nBins_, -3.14, 3.14); v->setHistos(et, eta, phi, etavsphi); } } // ! plotAll_ - for plotAll we discover it during the event } } // - method called once each job just after ending the event loop ------------ void FourVectorHLT::endJob() { LogInfo("Status") << "endJob: analyzed " << nev_ << " events"; return; } // BeginRun void FourVectorHLT::beginRun(const edm::Run& run, const edm::EventSetup& c) { LogDebug("Status") << "beginRun, run " << run.id(); } /// EndRun void FourVectorHLT::endRun(const edm::Run& run, const edm::EventSetup& c) { LogDebug("Status") << "endRun, run " << run.id(); }
/* Copyright (c) 2005-2018, University of Oxford. All rights reserved. University of Oxford means the Chancellor, Masters and Scholars of the University of Oxford, having an administrative office at Wellington Square, Oxford OX1 2JD, UK. This file is part of Chaste. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the University of Oxford nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef TOYCOMPRESSIBLEMATERIALLAW_HPP_ #define TOYCOMPRESSIBLEMATERIALLAW_HPP_ #include "AbstractIsotropicCompressibleMaterialLaw.hpp" /* * Simple material law W(I1,I2,I3) = c1(I1-3) + c2(I2-3) + c3(I3-1), * which may not correspond to a physically acceptable law but can * still be used to test the code. */ template<unsigned DIM> class ToyCompressibleMaterialLaw : public AbstractIsotropicCompressibleMaterialLaw<DIM> { private: double mC1; double mC2; double mC3; public: double Get_dW_dI1(double I1, double I2, double I3) { return mC1; } double Get_dW_dI2(double I1, double I2, double I3) { return mC2; } double Get_dW_dI3(double I1, double I2, double I3) { return mC3; } double Get_d2W_dI1(double I1, double I2, double I3) { return 0.0; } double Get_d2W_dI2(double I1, double I2, double I3) { return 0.0; } double Get_d2W_dI3(double I1, double I2, double I3) { return 0.0; } double Get_d2W_dI2I3(double I1, double I2, double I3) { return 0.0; } double Get_d2W_dI1I3(double I1, double I2, double I3) { return 0.0; } double Get_d2W_dI1I2(double I1, double I2, double I3) { return 0.0; } ToyCompressibleMaterialLaw(double c1, double c2, double c3) { assert(c1 > 0.0); assert(DIM!=2 || c2==0.0); mC1 = c1; mC2 = c2; mC3 = c3; if (DIM==3 && fabs(c1+2*c2+c3)>1e-8) { EXCEPTION("c1+2*c2+c3 should be equal to zero"); } } }; #endif /* TOYCOMPRESSIBLEMATERIALLAW_HPP_ */
/* * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. * */ #include "precompiled.hpp" #include "compiler/compileLog.hpp" #include "gc/shared/barrierSet.hpp" #include "gc/shared/c2/barrierSetC2.hpp" #include "memory/allocation.inline.hpp" #include "opto/addnode.hpp" #include "opto/callnode.hpp" #include "opto/cfgnode.hpp" #include "opto/loopnode.hpp" #include "opto/matcher.hpp" #include "opto/movenode.hpp" #include "opto/mulnode.hpp" #include "opto/opcodes.hpp" #include "opto/phaseX.hpp" #include "opto/subnode.hpp" #include "runtime/sharedRuntime.hpp" // Portions of code courtesy of Clifford Click // Optimization - Graph Style #include "math.h" //============================================================================= //------------------------------Identity--------------------------------------- // If right input is a constant 0, return the left input. Node* SubNode::Identity(PhaseGVN* phase) { assert(in(1) != this, "Must already have called Value"); assert(in(2) != this, "Must already have called Value"); // Remove double negation const Type *zero = add_id(); if( phase->type( in(1) )->higher_equal( zero ) && in(2)->Opcode() == Opcode() && phase->type( in(2)->in(1) )->higher_equal( zero ) ) { return in(2)->in(2); } // Convert "(X+Y) - Y" into X and "(X+Y) - X" into Y if (in(1)->Opcode() == Op_AddI) { if (in(1)->in(2) == in(2)) { return in(1)->in(1); } if (in(1)->in(1) == in(2)) { return in(1)->in(2); } // Also catch: "(X + Opaque2(Y)) - Y". In this case, 'Y' is a loop-varying // trip counter and X is likely to be loop-invariant (that's how O2 Nodes // are originally used, although the optimizer sometimes jiggers things). // This folding through an O2 removes a loop-exit use of a loop-varying // value and generally lowers register pressure in and around the loop. if (in(1)->in(2)->Opcode() == Op_Opaque2 && in(1)->in(2)->in(1) == in(2)) { return in(1)->in(1); } } return ( phase->type( in(2) )->higher_equal( zero ) ) ? in(1) : this; } //------------------------------Value------------------------------------------ // A subtract node differences it's two inputs. const Type* SubNode::Value_common(PhaseTransform *phase) const { const Node* in1 = in(1); const Node* in2 = in(2); // Either input is TOP ==> the result is TOP const Type* t1 = (in1 == this) ? Type::TOP : phase->type(in1); if( t1 == Type::TOP ) return Type::TOP; const Type* t2 = (in2 == this) ? Type::TOP : phase->type(in2); if( t2 == Type::TOP ) return Type::TOP; // Not correct for SubFnode and AddFNode (must check for infinity) // Equal? Subtract is zero if (in1->eqv_uncast(in2)) return add_id(); // Either input is BOTTOM ==> the result is the local BOTTOM if( t1 == Type::BOTTOM || t2 == Type::BOTTOM ) return bottom_type(); return NULL; } const Type* SubNode::Value(PhaseGVN* phase) const { const Type* t = Value_common(phase); if (t != NULL) { return t; } const Type* t1 = phase->type(in(1)); const Type* t2 = phase->type(in(2)); return sub(t1,t2); // Local flavor of type subtraction } SubNode* SubNode::make(Node* in1, Node* in2, BasicType bt) { switch (bt) { case T_INT: return new SubINode(in1, in2); case T_LONG: return new SubLNode(in1, in2); default: fatal("Not implemented for %s", type2name(bt)); } return NULL; } //============================================================================= //------------------------------Helper function-------------------------------- static bool is_cloop_increment(Node* inc) { precond(inc->Opcode() == Op_AddI || inc->Opcode() == Op_AddL); if (!inc->in(1)->is_Phi()) { return false; } const PhiNode* phi = inc->in(1)->as_Phi(); if (!phi->region()->is_CountedLoop()) { return false; } return inc == phi->region()->as_CountedLoop()->incr(); } // Given the expression '(x + C) - v', or // 'v - (x + C)', we examine nodes '+' and 'v': // // 1. Do not convert if '+' is a counted-loop increment, because the '-' is // loop invariant and converting extends the live-range of 'x' to overlap // with the '+', forcing another register to be used in the loop. // // 2. Do not convert if 'v' is a counted-loop induction variable, because // 'x' might be invariant. // static bool ok_to_convert(Node* inc, Node* var) { return !(is_cloop_increment(inc) || var->is_cloop_ind_var()); } //------------------------------Ideal------------------------------------------ Node *SubINode::Ideal(PhaseGVN *phase, bool can_reshape){ Node *in1 = in(1); Node *in2 = in(2); uint op1 = in1->Opcode(); uint op2 = in2->Opcode(); #ifdef ASSERT // Check for dead loop if ((in1 == this) || (in2 == this) || ((op1 == Op_AddI || op1 == Op_SubI) && ((in1->in(1) == this) || (in1->in(2) == this) || (in1->in(1) == in1) || (in1->in(2) == in1)))) { assert(false, "dead loop in SubINode::Ideal"); } #endif const Type *t2 = phase->type( in2 ); if( t2 == Type::TOP ) return NULL; // Convert "x-c0" into "x+ -c0". if( t2->base() == Type::Int ){ // Might be bottom or top... const TypeInt *i = t2->is_int(); if( i->is_con() ) return new AddINode(in1, phase->intcon(-i->get_con())); } // Convert "(x+c0) - y" into (x-y) + c0" // Do not collapse (x+c0)-y if "+" is a loop increment or // if "y" is a loop induction variable. if( op1 == Op_AddI && ok_to_convert(in1, in2) ) { const Type *tadd = phase->type( in1->in(2) ); if( tadd->singleton() && tadd != Type::TOP ) { Node *sub2 = phase->transform( new SubINode( in1->in(1), in2 )); return new AddINode( sub2, in1->in(2) ); } } // Convert "x - (y+c0)" into "(x-y) - c0" // Need the same check as in above optimization but reversed. if (op2 == Op_AddI && ok_to_convert(in2, in1)) { Node* in21 = in2->in(1); Node* in22 = in2->in(2); const TypeInt* tcon = phase->type(in22)->isa_int(); if (tcon != NULL && tcon->is_con()) { Node* sub2 = phase->transform( new SubINode(in1, in21) ); Node* neg_c0 = phase->intcon(- tcon->get_con()); return new AddINode(sub2, neg_c0); } } const Type *t1 = phase->type( in1 ); if( t1 == Type::TOP ) return NULL; #ifdef ASSERT // Check for dead loop if ((op2 == Op_AddI || op2 == Op_SubI) && ((in2->in(1) == this) || (in2->in(2) == this) || (in2->in(1) == in2) || (in2->in(2) == in2))) { assert(false, "dead loop in SubINode::Ideal"); } #endif // Convert "x - (x+y)" into "-y" if (op2 == Op_AddI && in1 == in2->in(1)) { return new SubINode(phase->intcon(0), in2->in(2)); } // Convert "(x-y) - x" into "-y" if (op1 == Op_SubI && in1->in(1) == in2) { return new SubINode(phase->intcon(0), in1->in(2)); } // Convert "x - (y+x)" into "-y" if (op2 == Op_AddI && in1 == in2->in(2)) { return new SubINode(phase->intcon(0), in2->in(1)); } // Convert "0 - (x-y)" into "y-x", leave the double negation "-(-y)" to SubNode::Identity(). if (t1 == TypeInt::ZERO && op2 == Op_SubI && phase->type(in2->in(1)) != TypeInt::ZERO) { return new SubINode(in2->in(2), in2->in(1)); } // Convert "0 - (x+con)" into "-con-x" jint con; if( t1 == TypeInt::ZERO && op2 == Op_AddI && (con = in2->in(2)->find_int_con(0)) != 0 ) return new SubINode( phase->intcon(-con), in2->in(1) ); // Convert "(X+A) - (X+B)" into "A - B" if( op1 == Op_AddI && op2 == Op_AddI && in1->in(1) == in2->in(1) ) return new SubINode( in1->in(2), in2->in(2) ); // Convert "(A+X) - (B+X)" into "A - B" if( op1 == Op_AddI && op2 == Op_AddI && in1->in(2) == in2->in(2) ) return new SubINode( in1->in(1), in2->in(1) ); // Convert "(A+X) - (X+B)" into "A - B" if( op1 == Op_AddI && op2 == Op_AddI && in1->in(2) == in2->in(1) ) return new SubINode( in1->in(1), in2->in(2) ); // Convert "(X+A) - (B+X)" into "A - B" if( op1 == Op_AddI && op2 == Op_AddI && in1->in(1) == in2->in(2) ) return new SubINode( in1->in(2), in2->in(1) ); // Convert "A-(B-C)" into (A+C)-B", since add is commutative and generally // nicer to optimize than subtract. if( op2 == Op_SubI && in2->outcnt() == 1) { Node *add1 = phase->transform( new AddINode( in1, in2->in(2) ) ); return new SubINode( add1, in2->in(1) ); } // Associative if (op1 == Op_MulI && op2 == Op_MulI) { Node* sub_in1 = NULL; Node* sub_in2 = NULL; Node* mul_in = NULL; if (in1->in(1) == in2->in(1)) { // Convert "a*b-a*c into a*(b-c) sub_in1 = in1->in(2); sub_in2 = in2->in(2); mul_in = in1->in(1); } else if (in1->in(2) == in2->in(1)) { // Convert a*b-b*c into b*(a-c) sub_in1 = in1->in(1); sub_in2 = in2->in(2); mul_in = in1->in(2); } else if (in1->in(2) == in2->in(2)) { // Convert a*c-b*c into (a-b)*c sub_in1 = in1->in(1); sub_in2 = in2->in(1); mul_in = in1->in(2); } else if (in1->in(1) == in2->in(2)) { // Convert a*b-c*a into a*(b-c) sub_in1 = in1->in(2); sub_in2 = in2->in(1); mul_in = in1->in(1); } if (mul_in != NULL) { Node* sub = phase->transform(new SubINode(sub_in1, sub_in2)); return new MulINode(mul_in, sub); } } // Convert "0-(A>>31)" into "(A>>>31)" if ( op2 == Op_RShiftI ) { Node *in21 = in2->in(1); Node *in22 = in2->in(2); const TypeInt *zero = phase->type(in1)->isa_int(); const TypeInt *t21 = phase->type(in21)->isa_int(); const TypeInt *t22 = phase->type(in22)->isa_int(); if ( t21 && t22 && zero == TypeInt::ZERO && t22->is_con(31) ) { return new URShiftINode(in21, in22); } } return NULL; } //------------------------------sub-------------------------------------------- // A subtract node differences it's two inputs. const Type *SubINode::sub( const Type *t1, const Type *t2 ) const { const TypeInt *r0 = t1->is_int(); // Handy access const TypeInt *r1 = t2->is_int(); int32_t lo = java_subtract(r0->_lo, r1->_hi); int32_t hi = java_subtract(r0->_hi, r1->_lo); // We next check for 32-bit overflow. // If that happens, we just assume all integers are possible. if( (((r0->_lo ^ r1->_hi) >= 0) || // lo ends have same signs OR ((r0->_lo ^ lo) >= 0)) && // lo results have same signs AND (((r0->_hi ^ r1->_lo) >= 0) || // hi ends have same signs OR ((r0->_hi ^ hi) >= 0)) ) // hi results have same signs return TypeInt::make(lo,hi,MAX2(r0->_widen,r1->_widen)); else // Overflow; assume all integers return TypeInt::INT; } //============================================================================= //------------------------------Ideal------------------------------------------ Node *SubLNode::Ideal(PhaseGVN *phase, bool can_reshape) { Node *in1 = in(1); Node *in2 = in(2); uint op1 = in1->Opcode(); uint op2 = in2->Opcode(); #ifdef ASSERT // Check for dead loop if ((in1 == this) || (in2 == this) || ((op1 == Op_AddL || op1 == Op_SubL) && ((in1->in(1) == this) || (in1->in(2) == this) || (in1->in(1) == in1) || (in1->in(2) == in1)))) { assert(false, "dead loop in SubLNode::Ideal"); } #endif if( phase->type( in2 ) == Type::TOP ) return NULL; const TypeLong *i = phase->type( in2 )->isa_long(); // Convert "x-c0" into "x+ -c0". if( i && // Might be bottom or top... i->is_con() ) return new AddLNode(in1, phase->longcon(-i->get_con())); // Convert "(x+c0) - y" into (x-y) + c0" // Do not collapse (x+c0)-y if "+" is a loop increment or // if "y" is a loop induction variable. if( op1 == Op_AddL && ok_to_convert(in1, in2) ) { Node *in11 = in1->in(1); const Type *tadd = phase->type( in1->in(2) ); if( tadd->singleton() && tadd != Type::TOP ) { Node *sub2 = phase->transform( new SubLNode( in11, in2 )); return new AddLNode( sub2, in1->in(2) ); } } // Convert "x - (y+c0)" into "(x-y) - c0" // Need the same check as in above optimization but reversed. if (op2 == Op_AddL && ok_to_convert(in2, in1)) { Node* in21 = in2->in(1); Node* in22 = in2->in(2); const TypeLong* tcon = phase->type(in22)->isa_long(); if (tcon != NULL && tcon->is_con()) { Node* sub2 = phase->transform( new SubLNode(in1, in21) ); Node* neg_c0 = phase->longcon(- tcon->get_con()); return new AddLNode(sub2, neg_c0); } } const Type *t1 = phase->type( in1 ); if( t1 == Type::TOP ) return NULL; #ifdef ASSERT // Check for dead loop if ((op2 == Op_AddL || op2 == Op_SubL) && ((in2->in(1) == this) || (in2->in(2) == this) || (in2->in(1) == in2) || (in2->in(2) == in2))) { assert(false, "dead loop in SubLNode::Ideal"); } #endif // Convert "x - (x+y)" into "-y" if (op2 == Op_AddL && in1 == in2->in(1)) { return new SubLNode(phase->makecon(TypeLong::ZERO), in2->in(2)); } // Convert "x - (y+x)" into "-y" if (op2 == Op_AddL && in1 == in2->in(2)) { return new SubLNode(phase->makecon(TypeLong::ZERO), in2->in(1)); } // Convert "0 - (x-y)" into "y-x", leave the double negation "-(-y)" to SubNode::Identity. if (t1 == TypeLong::ZERO && op2 == Op_SubL && phase->type(in2->in(1)) != TypeLong::ZERO) { return new SubLNode(in2->in(2), in2->in(1)); } // Convert "(X+A) - (X+B)" into "A - B" if( op1 == Op_AddL && op2 == Op_AddL && in1->in(1) == in2->in(1) ) return new SubLNode( in1->in(2), in2->in(2) ); // Convert "(A+X) - (B+X)" into "A - B" if( op1 == Op_AddL && op2 == Op_AddL && in1->in(2) == in2->in(2) ) return new SubLNode( in1->in(1), in2->in(1) ); // Convert "A-(B-C)" into (A+C)-B" if( op2 == Op_SubL && in2->outcnt() == 1) { Node *add1 = phase->transform( new AddLNode( in1, in2->in(2) ) ); return new SubLNode( add1, in2->in(1) ); } // Associative if (op1 == Op_MulL && op2 == Op_MulL) { Node* sub_in1 = NULL; Node* sub_in2 = NULL; Node* mul_in = NULL; if (in1->in(1) == in2->in(1)) { // Convert "a*b-a*c into a*(b+c) sub_in1 = in1->in(2); sub_in2 = in2->in(2); mul_in = in1->in(1); } else if (in1->in(2) == in2->in(1)) { // Convert a*b-b*c into b*(a-c) sub_in1 = in1->in(1); sub_in2 = in2->in(2); mul_in = in1->in(2); } else if (in1->in(2) == in2->in(2)) { // Convert a*c-b*c into (a-b)*c sub_in1 = in1->in(1); sub_in2 = in2->in(1); mul_in = in1->in(2); } else if (in1->in(1) == in2->in(2)) { // Convert a*b-c*a into a*(b-c) sub_in1 = in1->in(2); sub_in2 = in2->in(1); mul_in = in1->in(1); } if (mul_in != NULL) { Node* sub = phase->transform(new SubLNode(sub_in1, sub_in2)); return new MulLNode(mul_in, sub); } } // Convert "0L-(A>>63)" into "(A>>>63)" if ( op2 == Op_RShiftL ) { Node *in21 = in2->in(1); Node *in22 = in2->in(2); const TypeLong *zero = phase->type(in1)->isa_long(); const TypeLong *t21 = phase->type(in21)->isa_long(); const TypeInt *t22 = phase->type(in22)->isa_int(); if ( t21 && t22 && zero == TypeLong::ZERO && t22->is_con(63) ) { return new URShiftLNode(in21, in22); } } return NULL; } //------------------------------sub-------------------------------------------- // A subtract node differences it's two inputs. const Type *SubLNode::sub( const Type *t1, const Type *t2 ) const { const TypeLong *r0 = t1->is_long(); // Handy access const TypeLong *r1 = t2->is_long(); jlong lo = java_subtract(r0->_lo, r1->_hi); jlong hi = java_subtract(r0->_hi, r1->_lo); // We next check for 32-bit overflow. // If that happens, we just assume all integers are possible. if( (((r0->_lo ^ r1->_hi) >= 0) || // lo ends have same signs OR ((r0->_lo ^ lo) >= 0)) && // lo results have same signs AND (((r0->_hi ^ r1->_lo) >= 0) || // hi ends have same signs OR ((r0->_hi ^ hi) >= 0)) ) // hi results have same signs return TypeLong::make(lo,hi,MAX2(r0->_widen,r1->_widen)); else // Overflow; assume all integers return TypeLong::LONG; } //============================================================================= //------------------------------Value------------------------------------------ // A subtract node differences its two inputs. const Type* SubFPNode::Value(PhaseGVN* phase) const { const Node* in1 = in(1); const Node* in2 = in(2); // Either input is TOP ==> the result is TOP const Type* t1 = (in1 == this) ? Type::TOP : phase->type(in1); if( t1 == Type::TOP ) return Type::TOP; const Type* t2 = (in2 == this) ? Type::TOP : phase->type(in2); if( t2 == Type::TOP ) return Type::TOP; // if both operands are infinity of same sign, the result is NaN; do // not replace with zero if (t1->is_finite() && t2->is_finite() && in1 == in2) { return add_id(); } // Either input is BOTTOM ==> the result is the local BOTTOM const Type *bot = bottom_type(); if( (t1 == bot) || (t2 == bot) || (t1 == Type::BOTTOM) || (t2 == Type::BOTTOM) ) return bot; return sub(t1,t2); // Local flavor of type subtraction } //============================================================================= //------------------------------Ideal------------------------------------------ Node *SubFNode::Ideal(PhaseGVN *phase, bool can_reshape) { const Type *t2 = phase->type( in(2) ); // Convert "x-c0" into "x+ -c0". if( t2->base() == Type::FloatCon ) { // Might be bottom or top... // return new (phase->C, 3) AddFNode(in(1), phase->makecon( TypeF::make(-t2->getf()) ) ); } // Cannot replace 0.0-X with -X because a 'fsub' bytecode computes // 0.0-0.0 as +0.0, while a 'fneg' bytecode computes -0.0. //if( phase->type(in(1)) == TypeF::ZERO ) //return new (phase->C, 2) NegFNode(in(2)); return NULL; } //------------------------------sub-------------------------------------------- // A subtract node differences its two inputs. const Type *SubFNode::sub( const Type *t1, const Type *t2 ) const { // no folding if one of operands is infinity or NaN, do not do constant folding if( g_isfinite(t1->getf()) && g_isfinite(t2->getf()) ) { return TypeF::make( t1->getf() - t2->getf() ); } else if( g_isnan(t1->getf()) ) { return t1; } else if( g_isnan(t2->getf()) ) { return t2; } else { return Type::FLOAT; } } //============================================================================= //------------------------------Ideal------------------------------------------ Node *SubDNode::Ideal(PhaseGVN *phase, bool can_reshape){ const Type *t2 = phase->type( in(2) ); // Convert "x-c0" into "x+ -c0". if( t2->base() == Type::DoubleCon ) { // Might be bottom or top... // return new (phase->C, 3) AddDNode(in(1), phase->makecon( TypeD::make(-t2->getd()) ) ); } // Cannot replace 0.0-X with -X because a 'dsub' bytecode computes // 0.0-0.0 as +0.0, while a 'dneg' bytecode computes -0.0. //if( phase->type(in(1)) == TypeD::ZERO ) //return new (phase->C, 2) NegDNode(in(2)); return NULL; } //------------------------------sub-------------------------------------------- // A subtract node differences its two inputs. const Type *SubDNode::sub( const Type *t1, const Type *t2 ) const { // no folding if one of operands is infinity or NaN, do not do constant folding if( g_isfinite(t1->getd()) && g_isfinite(t2->getd()) ) { return TypeD::make( t1->getd() - t2->getd() ); } else if( g_isnan(t1->getd()) ) { return t1; } else if( g_isnan(t2->getd()) ) { return t2; } else { return Type::DOUBLE; } } //============================================================================= //------------------------------Idealize--------------------------------------- // Unlike SubNodes, compare must still flatten return value to the // range -1, 0, 1. // And optimizations like those for (X + Y) - X fail if overflow happens. Node* CmpNode::Identity(PhaseGVN* phase) { return this; } #ifndef PRODUCT //----------------------------related------------------------------------------ // Related nodes of comparison nodes include all data inputs (until hitting a // control boundary) as well as all outputs until and including control nodes // as well as their projections. In compact mode, data inputs till depth 1 and // all outputs till depth 1 are considered. void CmpNode::related(GrowableArray<Node*> *in_rel, GrowableArray<Node*> *out_rel, bool compact) const { if (compact) { this->collect_nodes(in_rel, 1, false, true); this->collect_nodes(out_rel, -1, false, false); } else { this->collect_nodes_in_all_data(in_rel, false); this->collect_nodes_out_all_ctrl_boundary(out_rel); // Now, find all control nodes in out_rel, and include their projections // and projection targets (if any) in the result. GrowableArray<Node*> proj(Compile::current()->unique()); for (GrowableArrayIterator<Node*> it = out_rel->begin(); it != out_rel->end(); ++it) { Node* n = *it; if (n->is_CFG() && !n->is_Proj()) { // Assume projections and projection targets are found at levels 1 and 2. n->collect_nodes(&proj, -2, false, false); for (GrowableArrayIterator<Node*> p = proj.begin(); p != proj.end(); ++p) { out_rel->append_if_missing(*p); } proj.clear(); } } } } #endif CmpNode *CmpNode::make(Node *in1, Node *in2, BasicType bt, bool unsigned_comp) { switch (bt) { case T_INT: if (unsigned_comp) { return new CmpUNode(in1, in2); } return new CmpINode(in1, in2); case T_LONG: if (unsigned_comp) { return new CmpULNode(in1, in2); } return new CmpLNode(in1, in2); default: fatal("Not implemented for %s", type2name(bt)); } return NULL; } //============================================================================= //------------------------------cmp-------------------------------------------- // Simplify a CmpI (compare 2 integers) node, based on local information. // If both inputs are constants, compare them. const Type *CmpINode::sub( const Type *t1, const Type *t2 ) const { const TypeInt *r0 = t1->is_int(); // Handy access const TypeInt *r1 = t2->is_int(); if( r0->_hi < r1->_lo ) // Range is always low? return TypeInt::CC_LT; else if( r0->_lo > r1->_hi ) // Range is always high? return TypeInt::CC_GT; else if( r0->is_con() && r1->is_con() ) { // comparing constants? assert(r0->get_con() == r1->get_con(), "must be equal"); return TypeInt::CC_EQ; // Equal results. } else if( r0->_hi == r1->_lo ) // Range is never high? return TypeInt::CC_LE; else if( r0->_lo == r1->_hi ) // Range is never low? return TypeInt::CC_GE; return TypeInt::CC; // else use worst case results } // Simplify a CmpU (compare 2 integers) node, based on local information. // If both inputs are constants, compare them. const Type *CmpUNode::sub( const Type *t1, const Type *t2 ) const { assert(!t1->isa_ptr(), "obsolete usage of CmpU"); // comparing two unsigned ints const TypeInt *r0 = t1->is_int(); // Handy access const TypeInt *r1 = t2->is_int(); // Current installed version // Compare ranges for non-overlap juint lo0 = r0->_lo; juint hi0 = r0->_hi; juint lo1 = r1->_lo; juint hi1 = r1->_hi; // If either one has both negative and positive values, // it therefore contains both 0 and -1, and since [0..-1] is the // full unsigned range, the type must act as an unsigned bottom. bool bot0 = ((jint)(lo0 ^ hi0) < 0); bool bot1 = ((jint)(lo1 ^ hi1) < 0); if (bot0 || bot1) { // All unsigned values are LE -1 and GE 0. if (lo0 == 0 && hi0 == 0) { return TypeInt::CC_LE; // 0 <= bot } else if ((jint)lo0 == -1 && (jint)hi0 == -1) { return TypeInt::CC_GE; // -1 >= bot } else if (lo1 == 0 && hi1 == 0) { return TypeInt::CC_GE; // bot >= 0 } else if ((jint)lo1 == -1 && (jint)hi1 == -1) { return TypeInt::CC_LE; // bot <= -1 } } else { // We can use ranges of the form [lo..hi] if signs are the same. assert(lo0 <= hi0 && lo1 <= hi1, "unsigned ranges are valid"); // results are reversed, '-' > '+' for unsigned compare if (hi0 < lo1) { return TypeInt::CC_LT; // smaller } else if (lo0 > hi1) { return TypeInt::CC_GT; // greater } else if (hi0 == lo1 && lo0 == hi1) { return TypeInt::CC_EQ; // Equal results } else if (lo0 >= hi1) { return TypeInt::CC_GE; } else if (hi0 <= lo1) { // Check for special case in Hashtable::get. (See below.) if ((jint)lo0 >= 0 && (jint)lo1 >= 0 && is_index_range_check()) return TypeInt::CC_LT; return TypeInt::CC_LE; } } // Check for special case in Hashtable::get - the hash index is // mod'ed to the table size so the following range check is useless. // Check for: (X Mod Y) CmpU Y, where the mod result and Y both have // to be positive. // (This is a gross hack, since the sub method never // looks at the structure of the node in any other case.) if ((jint)lo0 >= 0 && (jint)lo1 >= 0 && is_index_range_check()) return TypeInt::CC_LT; return TypeInt::CC; // else use worst case results } const Type* CmpUNode::Value(PhaseGVN* phase) const { const Type* t = SubNode::Value_common(phase); if (t != NULL) { return t; } const Node* in1 = in(1); const Node* in2 = in(2); const Type* t1 = phase->type(in1); const Type* t2 = phase->type(in2); assert(t1->isa_int(), "CmpU has only Int type inputs"); if (t2 == TypeInt::INT) { // Compare to bottom? return bottom_type(); } uint in1_op = in1->Opcode(); if (in1_op == Op_AddI || in1_op == Op_SubI) { // The problem rise when result of AddI(SubI) may overflow // signed integer value. Let say the input type is // [256, maxint] then +128 will create 2 ranges due to // overflow: [minint, minint+127] and [384, maxint]. // But C2 type system keep only 1 type range and as result // it use general [minint, maxint] for this case which we // can't optimize. // // Make 2 separate type ranges based on types of AddI(SubI) inputs // and compare results of their compare. If results are the same // CmpU node can be optimized. const Node* in11 = in1->in(1); const Node* in12 = in1->in(2); const Type* t11 = (in11 == in1) ? Type::TOP : phase->type(in11); const Type* t12 = (in12 == in1) ? Type::TOP : phase->type(in12); // Skip cases when input types are top or bottom. if ((t11 != Type::TOP) && (t11 != TypeInt::INT) && (t12 != Type::TOP) && (t12 != TypeInt::INT)) { const TypeInt *r0 = t11->is_int(); const TypeInt *r1 = t12->is_int(); jlong lo_r0 = r0->_lo; jlong hi_r0 = r0->_hi; jlong lo_r1 = r1->_lo; jlong hi_r1 = r1->_hi; if (in1_op == Op_SubI) { jlong tmp = hi_r1; hi_r1 = -lo_r1; lo_r1 = -tmp; // Note, for substructing [minint,x] type range // long arithmetic provides correct overflow answer. // The confusion come from the fact that in 32-bit // -minint == minint but in 64-bit -minint == maxint+1. } jlong lo_long = lo_r0 + lo_r1; jlong hi_long = hi_r0 + hi_r1; int lo_tr1 = min_jint; int hi_tr1 = (int)hi_long; int lo_tr2 = (int)lo_long; int hi_tr2 = max_jint; bool underflow = lo_long != (jlong)lo_tr2; bool overflow = hi_long != (jlong)hi_tr1; // Use sub(t1, t2) when there is no overflow (one type range) // or when both overflow and underflow (too complex). if ((underflow != overflow) && (hi_tr1 < lo_tr2)) { // Overflow only on one boundary, compare 2 separate type ranges. int w = MAX2(r0->_widen, r1->_widen); // _widen does not matter here const TypeInt* tr1 = TypeInt::make(lo_tr1, hi_tr1, w); const TypeInt* tr2 = TypeInt::make(lo_tr2, hi_tr2, w); const Type* cmp1 = sub(tr1, t2); const Type* cmp2 = sub(tr2, t2); if (cmp1 == cmp2) { return cmp1; // Hit! } } } } return sub(t1, t2); // Local flavor of type subtraction } bool CmpUNode::is_index_range_check() const { // Check for the "(X ModI Y) CmpU Y" shape return (in(1)->Opcode() == Op_ModI && in(1)->in(2)->eqv_uncast(in(2))); } //------------------------------Idealize--------------------------------------- Node *CmpINode::Ideal( PhaseGVN *phase, bool can_reshape ) { if (phase->type(in(2))->higher_equal(TypeInt::ZERO)) { switch (in(1)->Opcode()) { case Op_CmpL3: // Collapse a CmpL3/CmpI into a CmpL return new CmpLNode(in(1)->in(1),in(1)->in(2)); case Op_CmpF3: // Collapse a CmpF3/CmpI into a CmpF return new CmpFNode(in(1)->in(1),in(1)->in(2)); case Op_CmpD3: // Collapse a CmpD3/CmpI into a CmpD return new CmpDNode(in(1)->in(1),in(1)->in(2)); //case Op_SubI: // If (x - y) cannot overflow, then ((x - y) <?> 0) // can be turned into (x <?> y). // This is handled (with more general cases) by Ideal_sub_algebra. } } return NULL; // No change } Node *CmpLNode::Ideal( PhaseGVN *phase, bool can_reshape ) { const TypeLong *t2 = phase->type(in(2))->isa_long(); if (Opcode() == Op_CmpL && in(1)->Opcode() == Op_ConvI2L && t2 && t2->is_con()) { const jlong con = t2->get_con(); if (con >= min_jint && con <= max_jint) { return new CmpINode(in(1)->in(1), phase->intcon((jint)con)); } } return NULL; } //============================================================================= // Simplify a CmpL (compare 2 longs ) node, based on local information. // If both inputs are constants, compare them. const Type *CmpLNode::sub( const Type *t1, const Type *t2 ) const { const TypeLong *r0 = t1->is_long(); // Handy access const TypeLong *r1 = t2->is_long(); if( r0->_hi < r1->_lo ) // Range is always low? return TypeInt::CC_LT; else if( r0->_lo > r1->_hi ) // Range is always high? return TypeInt::CC_GT; else if( r0->is_con() && r1->is_con() ) { // comparing constants? assert(r0->get_con() == r1->get_con(), "must be equal"); return TypeInt::CC_EQ; // Equal results. } else if( r0->_hi == r1->_lo ) // Range is never high? return TypeInt::CC_LE; else if( r0->_lo == r1->_hi ) // Range is never low? return TypeInt::CC_GE; return TypeInt::CC; // else use worst case results } // Simplify a CmpUL (compare 2 unsigned longs) node, based on local information. // If both inputs are constants, compare them. const Type* CmpULNode::sub(const Type* t1, const Type* t2) const { assert(!t1->isa_ptr(), "obsolete usage of CmpUL"); // comparing two unsigned longs const TypeLong* r0 = t1->is_long(); // Handy access const TypeLong* r1 = t2->is_long(); // Current installed version // Compare ranges for non-overlap julong lo0 = r0->_lo; julong hi0 = r0->_hi; julong lo1 = r1->_lo; julong hi1 = r1->_hi; // If either one has both negative and positive values, // it therefore contains both 0 and -1, and since [0..-1] is the // full unsigned range, the type must act as an unsigned bottom. bool bot0 = ((jlong)(lo0 ^ hi0) < 0); bool bot1 = ((jlong)(lo1 ^ hi1) < 0); if (bot0 || bot1) { // All unsigned values are LE -1 and GE 0. if (lo0 == 0 && hi0 == 0) { return TypeInt::CC_LE; // 0 <= bot } else if ((jlong)lo0 == -1 && (jlong)hi0 == -1) { return TypeInt::CC_GE; // -1 >= bot } else if (lo1 == 0 && hi1 == 0) { return TypeInt::CC_GE; // bot >= 0 } else if ((jlong)lo1 == -1 && (jlong)hi1 == -1) { return TypeInt::CC_LE; // bot <= -1 } } else { // We can use ranges of the form [lo..hi] if signs are the same. assert(lo0 <= hi0 && lo1 <= hi1, "unsigned ranges are valid"); // results are reversed, '-' > '+' for unsigned compare if (hi0 < lo1) { return TypeInt::CC_LT; // smaller } else if (lo0 > hi1) { return TypeInt::CC_GT; // greater } else if (hi0 == lo1 && lo0 == hi1) { return TypeInt::CC_EQ; // Equal results } else if (lo0 >= hi1) { return TypeInt::CC_GE; } else if (hi0 <= lo1) { return TypeInt::CC_LE; } } return TypeInt::CC; // else use worst case results } //============================================================================= //------------------------------sub-------------------------------------------- // Simplify an CmpP (compare 2 pointers) node, based on local information. // If both inputs are constants, compare them. const Type *CmpPNode::sub( const Type *t1, const Type *t2 ) const { const TypePtr *r0 = t1->is_ptr(); // Handy access const TypePtr *r1 = t2->is_ptr(); // Undefined inputs makes for an undefined result if( TypePtr::above_centerline(r0->_ptr) || TypePtr::above_centerline(r1->_ptr) ) return Type::TOP; if (r0 == r1 && r0->singleton()) { // Equal pointer constants (klasses, nulls, etc.) return TypeInt::CC_EQ; } // See if it is 2 unrelated classes. const TypeOopPtr* oop_p0 = r0->isa_oopptr(); const TypeOopPtr* oop_p1 = r1->isa_oopptr(); bool both_oop_ptr = oop_p0 && oop_p1; if (both_oop_ptr) { Node* in1 = in(1)->uncast(); Node* in2 = in(2)->uncast(); AllocateNode* alloc1 = AllocateNode::Ideal_allocation(in1, NULL); AllocateNode* alloc2 = AllocateNode::Ideal_allocation(in2, NULL); if (MemNode::detect_ptr_independence(in1, alloc1, in2, alloc2, NULL)) { return TypeInt::CC_GT; // different pointers } } const TypeKlassPtr* klass_p0 = r0->isa_klassptr(); const TypeKlassPtr* klass_p1 = r1->isa_klassptr(); if (both_oop_ptr || (klass_p0 && klass_p1)) { // both or neither are klass pointers ciKlass* klass0 = NULL; bool xklass0 = false; ciKlass* klass1 = NULL; bool xklass1 = false; if (oop_p0) { klass0 = oop_p0->klass(); xklass0 = oop_p0->klass_is_exact(); } else { assert(klass_p0, "must be non-null if oop_p0 is null"); klass0 = klass_p0->klass(); xklass0 = klass_p0->klass_is_exact(); } if (oop_p1) { klass1 = oop_p1->klass(); xklass1 = oop_p1->klass_is_exact(); } else { assert(klass_p1, "must be non-null if oop_p1 is null"); klass1 = klass_p1->klass(); xklass1 = klass_p1->klass_is_exact(); } if (klass0 && klass1 && klass0->is_loaded() && !klass0->is_interface() && // do not trust interfaces klass1->is_loaded() && !klass1->is_interface() && (!klass0->is_obj_array_klass() || !klass0->as_obj_array_klass()->base_element_klass()->is_interface()) && (!klass1->is_obj_array_klass() || !klass1->as_obj_array_klass()->base_element_klass()->is_interface())) { bool unrelated_classes = false; // See if neither subclasses the other, or if the class on top // is precise. In either of these cases, the compare is known // to fail if at least one of the pointers is provably not null. if (klass0->equals(klass1)) { // if types are unequal but klasses are equal // Do nothing; we know nothing for imprecise types } else if (klass0->is_subtype_of(klass1)) { // If klass1's type is PRECISE, then classes are unrelated. unrelated_classes = xklass1; } else if (klass1->is_subtype_of(klass0)) { // If klass0's type is PRECISE, then classes are unrelated. unrelated_classes = xklass0; } else { // Neither subtypes the other unrelated_classes = true; } if (unrelated_classes) { // The oops classes are known to be unrelated. If the joined PTRs of // two oops is not Null and not Bottom, then we are sure that one // of the two oops is non-null, and the comparison will always fail. TypePtr::PTR jp = r0->join_ptr(r1->_ptr); if (jp != TypePtr::Null && jp != TypePtr::BotPTR) { return TypeInt::CC_GT; } } } } // Known constants can be compared exactly // Null can be distinguished from any NotNull pointers // Unknown inputs makes an unknown result if( r0->singleton() ) { intptr_t bits0 = r0->get_con(); if( r1->singleton() ) return bits0 == r1->get_con() ? TypeInt::CC_EQ : TypeInt::CC_GT; return ( r1->_ptr == TypePtr::NotNull && bits0==0 ) ? TypeInt::CC_GT : TypeInt::CC; } else if( r1->singleton() ) { intptr_t bits1 = r1->get_con(); return ( r0->_ptr == TypePtr::NotNull && bits1==0 ) ? TypeInt::CC_GT : TypeInt::CC; } else return TypeInt::CC; } static inline Node* isa_java_mirror_load(PhaseGVN* phase, Node* n) { // Return the klass node for (indirect load from OopHandle) // LoadBarrier?(LoadP(LoadP(AddP(foo:Klass, #java_mirror)))) // or NULL if not matching. BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2(); n = bs->step_over_gc_barrier(n); if (n->Opcode() != Op_LoadP) return NULL; const TypeInstPtr* tp = phase->type(n)->isa_instptr(); if (!tp || tp->klass() != phase->C->env()->Class_klass()) return NULL; Node* adr = n->in(MemNode::Address); // First load from OopHandle: ((OopHandle)mirror)->resolve(); may need barrier. if (adr->Opcode() != Op_LoadP || !phase->type(adr)->isa_rawptr()) return NULL; adr = adr->in(MemNode::Address); intptr_t off = 0; Node* k = AddPNode::Ideal_base_and_offset(adr, phase, off); if (k == NULL) return NULL; const TypeKlassPtr* tkp = phase->type(k)->isa_klassptr(); if (!tkp || off != in_bytes(Klass::java_mirror_offset())) return NULL; // We've found the klass node of a Java mirror load. return k; } static inline Node* isa_const_java_mirror(PhaseGVN* phase, Node* n) { // for ConP(Foo.class) return ConP(Foo.klass) // otherwise return NULL if (!n->is_Con()) return NULL; const TypeInstPtr* tp = phase->type(n)->isa_instptr(); if (!tp) return NULL; ciType* mirror_type = tp->java_mirror_type(); // TypeInstPtr::java_mirror_type() returns non-NULL for compile- // time Class constants only. if (!mirror_type) return NULL; // x.getClass() == int.class can never be true (for all primitive types) // Return a ConP(NULL) node for this case. if (mirror_type->is_classless()) { return phase->makecon(TypePtr::NULL_PTR); } // return the ConP(Foo.klass) assert(mirror_type->is_klass(), "mirror_type should represent a Klass*"); return phase->makecon(TypeKlassPtr::make(mirror_type->as_klass())); } //------------------------------Ideal------------------------------------------ // Normalize comparisons between Java mirror loads to compare the klass instead. // // Also check for the case of comparing an unknown klass loaded from the primary // super-type array vs a known klass with no subtypes. This amounts to // checking to see an unknown klass subtypes a known klass with no subtypes; // this only happens on an exact match. We can shorten this test by 1 load. Node *CmpPNode::Ideal( PhaseGVN *phase, bool can_reshape ) { // Normalize comparisons between Java mirrors into comparisons of the low- // level klass, where a dependent load could be shortened. // // The new pattern has a nice effect of matching the same pattern used in the // fast path of instanceof/checkcast/Class.isInstance(), which allows // redundant exact type check be optimized away by GVN. // For example, in // if (x.getClass() == Foo.class) { // Foo foo = (Foo) x; // // ... use a ... // } // a CmpPNode could be shared between if_acmpne and checkcast { Node* k1 = isa_java_mirror_load(phase, in(1)); Node* k2 = isa_java_mirror_load(phase, in(2)); Node* conk2 = isa_const_java_mirror(phase, in(2)); if (k1 && (k2 || conk2)) { Node* lhs = k1; Node* rhs = (k2 != NULL) ? k2 : conk2; set_req_X(1, lhs, phase); set_req_X(2, rhs, phase); return this; } } // Constant pointer on right? const TypeKlassPtr* t2 = phase->type(in(2))->isa_klassptr(); if (t2 == NULL || !t2->klass_is_exact()) return NULL; // Get the constant klass we are comparing to. ciKlass* superklass = t2->klass(); // Now check for LoadKlass on left. Node* ldk1 = in(1); if (ldk1->is_DecodeNKlass()) { ldk1 = ldk1->in(1); if (ldk1->Opcode() != Op_LoadNKlass ) return NULL; } else if (ldk1->Opcode() != Op_LoadKlass ) return NULL; // Take apart the address of the LoadKlass: Node* adr1 = ldk1->in(MemNode::Address); intptr_t con2 = 0; Node* ldk2 = AddPNode::Ideal_base_and_offset(adr1, phase, con2); if (ldk2 == NULL) return NULL; if (con2 == oopDesc::klass_offset_in_bytes()) { // We are inspecting an object's concrete class. // Short-circuit the check if the query is abstract. if (superklass->is_interface() || superklass->is_abstract()) { // Make it come out always false: this->set_req(2, phase->makecon(TypePtr::NULL_PTR)); return this; } } // Check for a LoadKlass from primary supertype array. // Any nested loadklass from loadklass+con must be from the p.s. array. if (ldk2->is_DecodeNKlass()) { // Keep ldk2 as DecodeN since it could be used in CmpP below. if (ldk2->in(1)->Opcode() != Op_LoadNKlass ) return NULL; } else if (ldk2->Opcode() != Op_LoadKlass) return NULL; // Verify that we understand the situation if (con2 != (intptr_t) superklass->super_check_offset()) return NULL; // Might be element-klass loading from array klass // If 'superklass' has no subklasses and is not an interface, then we are // assured that the only input which will pass the type check is // 'superklass' itself. // // We could be more liberal here, and allow the optimization on interfaces // which have a single implementor. This would require us to increase the // expressiveness of the add_dependency() mechanism. // %%% Do this after we fix TypeOopPtr: Deps are expressive enough now. // Object arrays must have their base element have no subtypes while (superklass->is_obj_array_klass()) { ciType* elem = superklass->as_obj_array_klass()->element_type(); superklass = elem->as_klass(); } if (superklass->is_instance_klass()) { ciInstanceKlass* ik = superklass->as_instance_klass(); if (ik->has_subklass() || ik->is_interface()) return NULL; // Add a dependency if there is a chance that a subclass will be added later. if (!ik->is_final()) { phase->C->dependencies()->assert_leaf_type(ik); } } // Bypass the dependent load, and compare directly this->set_req(1,ldk2); return this; } //============================================================================= //------------------------------sub-------------------------------------------- // Simplify an CmpN (compare 2 pointers) node, based on local information. // If both inputs are constants, compare them. const Type *CmpNNode::sub( const Type *t1, const Type *t2 ) const { ShouldNotReachHere(); return bottom_type(); } //------------------------------Ideal------------------------------------------ Node *CmpNNode::Ideal( PhaseGVN *phase, bool can_reshape ) { return NULL; } //============================================================================= //------------------------------Value------------------------------------------ // Simplify an CmpF (compare 2 floats ) node, based on local information. // If both inputs are constants, compare them. const Type* CmpFNode::Value(PhaseGVN* phase) const { const Node* in1 = in(1); const Node* in2 = in(2); // Either input is TOP ==> the result is TOP const Type* t1 = (in1 == this) ? Type::TOP : phase->type(in1); if( t1 == Type::TOP ) return Type::TOP; const Type* t2 = (in2 == this) ? Type::TOP : phase->type(in2); if( t2 == Type::TOP ) return Type::TOP; // Not constants? Don't know squat - even if they are the same // value! If they are NaN's they compare to LT instead of EQ. const TypeF *tf1 = t1->isa_float_constant(); const TypeF *tf2 = t2->isa_float_constant(); if( !tf1 || !tf2 ) return TypeInt::CC; // This implements the Java bytecode fcmpl, so unordered returns -1. if( tf1->is_nan() || tf2->is_nan() ) return TypeInt::CC_LT; if( tf1->_f < tf2->_f ) return TypeInt::CC_LT; if( tf1->_f > tf2->_f ) return TypeInt::CC_GT; assert( tf1->_f == tf2->_f, "do not understand FP behavior" ); return TypeInt::CC_EQ; } //============================================================================= //------------------------------Value------------------------------------------ // Simplify an CmpD (compare 2 doubles ) node, based on local information. // If both inputs are constants, compare them. const Type* CmpDNode::Value(PhaseGVN* phase) const { const Node* in1 = in(1); const Node* in2 = in(2); // Either input is TOP ==> the result is TOP const Type* t1 = (in1 == this) ? Type::TOP : phase->type(in1); if( t1 == Type::TOP ) return Type::TOP; const Type* t2 = (in2 == this) ? Type::TOP : phase->type(in2); if( t2 == Type::TOP ) return Type::TOP; // Not constants? Don't know squat - even if they are the same // value! If they are NaN's they compare to LT instead of EQ. const TypeD *td1 = t1->isa_double_constant(); const TypeD *td2 = t2->isa_double_constant(); if( !td1 || !td2 ) return TypeInt::CC; // This implements the Java bytecode dcmpl, so unordered returns -1. if( td1->is_nan() || td2->is_nan() ) return TypeInt::CC_LT; if( td1->_d < td2->_d ) return TypeInt::CC_LT; if( td1->_d > td2->_d ) return TypeInt::CC_GT; assert( td1->_d == td2->_d, "do not understand FP behavior" ); return TypeInt::CC_EQ; } //------------------------------Ideal------------------------------------------ Node *CmpDNode::Ideal(PhaseGVN *phase, bool can_reshape){ // Check if we can change this to a CmpF and remove a ConvD2F operation. // Change (CMPD (F2D (float)) (ConD value)) // To (CMPF (float) (ConF value)) // Valid when 'value' does not lose precision as a float. // Benefits: eliminates conversion, does not require 24-bit mode // NaNs prevent commuting operands. This transform works regardless of the // order of ConD and ConvF2D inputs by preserving the original order. int idx_f2d = 1; // ConvF2D on left side? if( in(idx_f2d)->Opcode() != Op_ConvF2D ) idx_f2d = 2; // No, swap to check for reversed args int idx_con = 3-idx_f2d; // Check for the constant on other input if( ConvertCmpD2CmpF && in(idx_f2d)->Opcode() == Op_ConvF2D && in(idx_con)->Opcode() == Op_ConD ) { const TypeD *t2 = in(idx_con)->bottom_type()->is_double_constant(); double t2_value_as_double = t2->_d; float t2_value_as_float = (float)t2_value_as_double; if( t2_value_as_double == (double)t2_value_as_float ) { // Test value can be represented as a float // Eliminate the conversion to double and create new comparison Node *new_in1 = in(idx_f2d)->in(1); Node *new_in2 = phase->makecon( TypeF::make(t2_value_as_float) ); if( idx_f2d != 1 ) { // Must flip args to match original order Node *tmp = new_in1; new_in1 = new_in2; new_in2 = tmp; } CmpFNode *new_cmp = (Opcode() == Op_CmpD3) ? new CmpF3Node( new_in1, new_in2 ) : new CmpFNode ( new_in1, new_in2 ) ; return new_cmp; // Changed to CmpFNode } // Testing value required the precision of a double } return NULL; // No change } //============================================================================= //------------------------------cc2logical------------------------------------- // Convert a condition code type to a logical type const Type *BoolTest::cc2logical( const Type *CC ) const { if( CC == Type::TOP ) return Type::TOP; if( CC->base() != Type::Int ) return TypeInt::BOOL; // Bottom or worse const TypeInt *ti = CC->is_int(); if( ti->is_con() ) { // Only 1 kind of condition codes set? // Match low order 2 bits int tmp = ((ti->get_con()&3) == (_test&3)) ? 1 : 0; if( _test & 4 ) tmp = 1-tmp; // Optionally complement result return TypeInt::make(tmp); // Boolean result } if( CC == TypeInt::CC_GE ) { if( _test == ge ) return TypeInt::ONE; if( _test == lt ) return TypeInt::ZERO; } if( CC == TypeInt::CC_LE ) { if( _test == le ) return TypeInt::ONE; if( _test == gt ) return TypeInt::ZERO; } return TypeInt::BOOL; } //------------------------------dump_spec------------------------------------- // Print special per-node info void BoolTest::dump_on(outputStream *st) const { const char *msg[] = {"eq","gt","of","lt","ne","le","nof","ge"}; st->print("%s", msg[_test]); } // Returns the logical AND of two tests (or 'never' if both tests can never be true). // For example, a test for 'le' followed by a test for 'lt' is equivalent with 'lt'. BoolTest::mask BoolTest::merge(BoolTest other) const { const mask res[illegal+1][illegal+1] = { // eq, gt, of, lt, ne, le, nof, ge, never, illegal {eq, never, illegal, never, never, eq, illegal, eq, never, illegal}, // eq {never, gt, illegal, never, gt, never, illegal, gt, never, illegal}, // gt {illegal, illegal, illegal, illegal, illegal, illegal, illegal, illegal, never, illegal}, // of {never, never, illegal, lt, lt, lt, illegal, never, never, illegal}, // lt {never, gt, illegal, lt, ne, lt, illegal, gt, never, illegal}, // ne {eq, never, illegal, lt, lt, le, illegal, eq, never, illegal}, // le {illegal, illegal, illegal, illegal, illegal, illegal, illegal, illegal, never, illegal}, // nof {eq, gt, illegal, never, gt, eq, illegal, ge, never, illegal}, // ge {never, never, never, never, never, never, never, never, never, illegal}, // never {illegal, illegal, illegal, illegal, illegal, illegal, illegal, illegal, illegal, illegal}}; // illegal return res[_test][other._test]; } //============================================================================= uint BoolNode::hash() const { return (Node::hash() << 3)|(_test._test+1); } uint BoolNode::size_of() const { return sizeof(BoolNode); } //------------------------------operator==------------------------------------- bool BoolNode::cmp( const Node &n ) const { const BoolNode *b = (const BoolNode *)&n; // Cast up return (_test._test == b->_test._test); } //-------------------------------make_predicate-------------------------------- Node* BoolNode::make_predicate(Node* test_value, PhaseGVN* phase) { if (test_value->is_Con()) return test_value; if (test_value->is_Bool()) return test_value; if (test_value->is_CMove() && test_value->in(CMoveNode::Condition)->is_Bool()) { BoolNode* bol = test_value->in(CMoveNode::Condition)->as_Bool(); const Type* ftype = phase->type(test_value->in(CMoveNode::IfFalse)); const Type* ttype = phase->type(test_value->in(CMoveNode::IfTrue)); if (ftype == TypeInt::ZERO && !TypeInt::ZERO->higher_equal(ttype)) { return bol; } else if (ttype == TypeInt::ZERO && !TypeInt::ZERO->higher_equal(ftype)) { return phase->transform( bol->negate(phase) ); } // Else fall through. The CMove gets in the way of the test. // It should be the case that make_predicate(bol->as_int_value()) == bol. } Node* cmp = new CmpINode(test_value, phase->intcon(0)); cmp = phase->transform(cmp); Node* bol = new BoolNode(cmp, BoolTest::ne); return phase->transform(bol); } //--------------------------------as_int_value--------------------------------- Node* BoolNode::as_int_value(PhaseGVN* phase) { // Inverse to make_predicate. The CMove probably boils down to a Conv2B. Node* cmov = CMoveNode::make(NULL, this, phase->intcon(0), phase->intcon(1), TypeInt::BOOL); return phase->transform(cmov); } //----------------------------------negate------------------------------------- BoolNode* BoolNode::negate(PhaseGVN* phase) { return new BoolNode(in(1), _test.negate()); } // Change "bool eq/ne (cmp (add/sub A B) C)" into false/true if add/sub // overflows and we can prove that C is not in the two resulting ranges. // This optimization is similar to the one performed by CmpUNode::Value(). Node* BoolNode::fold_cmpI(PhaseGVN* phase, SubNode* cmp, Node* cmp1, int cmp_op, int cmp1_op, const TypeInt* cmp2_type) { // Only optimize eq/ne integer comparison of add/sub if((_test._test == BoolTest::eq || _test._test == BoolTest::ne) && (cmp_op == Op_CmpI) && (cmp1_op == Op_AddI || cmp1_op == Op_SubI)) { // Skip cases were inputs of add/sub are not integers or of bottom type const TypeInt* r0 = phase->type(cmp1->in(1))->isa_int(); const TypeInt* r1 = phase->type(cmp1->in(2))->isa_int(); if ((r0 != NULL) && (r0 != TypeInt::INT) && (r1 != NULL) && (r1 != TypeInt::INT) && (cmp2_type != TypeInt::INT)) { // Compute exact (long) type range of add/sub result jlong lo_long = r0->_lo; jlong hi_long = r0->_hi; if (cmp1_op == Op_AddI) { lo_long += r1->_lo; hi_long += r1->_hi; } else { lo_long -= r1->_hi; hi_long -= r1->_lo; } // Check for over-/underflow by casting to integer int lo_int = (int)lo_long; int hi_int = (int)hi_long; bool underflow = lo_long != (jlong)lo_int; bool overflow = hi_long != (jlong)hi_int; if ((underflow != overflow) && (hi_int < lo_int)) { // Overflow on one boundary, compute resulting type ranges: // tr1 [MIN_INT, hi_int] and tr2 [lo_int, MAX_INT] int w = MAX2(r0->_widen, r1->_widen); // _widen does not matter here const TypeInt* tr1 = TypeInt::make(min_jint, hi_int, w); const TypeInt* tr2 = TypeInt::make(lo_int, max_jint, w); // Compare second input of cmp to both type ranges const Type* sub_tr1 = cmp->sub(tr1, cmp2_type); const Type* sub_tr2 = cmp->sub(tr2, cmp2_type); if (sub_tr1 == TypeInt::CC_LT && sub_tr2 == TypeInt::CC_GT) { // The result of the add/sub will never equal cmp2. Replace BoolNode // by false (0) if it tests for equality and by true (1) otherwise. return ConINode::make((_test._test == BoolTest::eq) ? 0 : 1); } } } } return NULL; } static bool is_counted_loop_cmp(Node *cmp) { Node *n = cmp->in(1)->in(1); return n != NULL && n->is_Phi() && n->in(0) != NULL && n->in(0)->is_CountedLoop() && n->in(0)->as_CountedLoop()->phi() == n; } //------------------------------Ideal------------------------------------------ Node *BoolNode::Ideal(PhaseGVN *phase, bool can_reshape) { // Change "bool tst (cmp con x)" into "bool ~tst (cmp x con)". // This moves the constant to the right. Helps value-numbering. Node *cmp = in(1); if( !cmp->is_Sub() ) return NULL; int cop = cmp->Opcode(); if( cop == Op_FastLock || cop == Op_FastUnlock || cmp->is_SubTypeCheck()) return NULL; Node *cmp1 = cmp->in(1); Node *cmp2 = cmp->in(2); if( !cmp1 ) return NULL; if (_test._test == BoolTest::overflow || _test._test == BoolTest::no_overflow) { return NULL; } // Constant on left? Node *con = cmp1; uint op2 = cmp2->Opcode(); // Move constants to the right of compare's to canonicalize. // Do not muck with Opaque1 nodes, as this indicates a loop // guard that cannot change shape. if( con->is_Con() && !cmp2->is_Con() && op2 != Op_Opaque1 && // Because of NaN's, CmpD and CmpF are not commutative cop != Op_CmpD && cop != Op_CmpF && // Protect against swapping inputs to a compare when it is used by a // counted loop exit, which requires maintaining the loop-limit as in(2) !is_counted_loop_exit_test() ) { // Ok, commute the constant to the right of the cmp node. // Clone the Node, getting a new Node of the same class cmp = cmp->clone(); // Swap inputs to the clone cmp->swap_edges(1, 2); cmp = phase->transform( cmp ); return new BoolNode( cmp, _test.commute() ); } // Change "bool eq/ne (cmp (and X 16) 16)" into "bool ne/eq (cmp (and X 16) 0)". if (cop == Op_CmpI && (_test._test == BoolTest::eq || _test._test == BoolTest::ne) && cmp1->Opcode() == Op_AndI && cmp2->Opcode() == Op_ConI && cmp1->in(2)->Opcode() == Op_ConI) { const TypeInt *t12 = phase->type(cmp2)->isa_int(); const TypeInt *t112 = phase->type(cmp1->in(2))->isa_int(); if (t12 && t12->is_con() && t112 && t112->is_con() && t12->get_con() == t112->get_con() && is_power_of_2(t12->get_con())) { Node *ncmp = phase->transform(new CmpINode(cmp1, phase->intcon(0))); return new BoolNode(ncmp, _test.negate()); } } // Same for long type: change "bool eq/ne (cmp (and X 16) 16)" into "bool ne/eq (cmp (and X 16) 0)". if (cop == Op_CmpL && (_test._test == BoolTest::eq || _test._test == BoolTest::ne) && cmp1->Opcode() == Op_AndL && cmp2->Opcode() == Op_ConL && cmp1->in(2)->Opcode() == Op_ConL) { const TypeLong *t12 = phase->type(cmp2)->isa_long(); const TypeLong *t112 = phase->type(cmp1->in(2))->isa_long(); if (t12 && t12->is_con() && t112 && t112->is_con() && t12->get_con() == t112->get_con() && is_power_of_2(t12->get_con())) { Node *ncmp = phase->transform(new CmpLNode(cmp1, phase->longcon(0))); return new BoolNode(ncmp, _test.negate()); } } // Change "bool eq/ne (cmp (xor X 1) 0)" into "bool ne/eq (cmp X 0)". // The XOR-1 is an idiom used to flip the sense of a bool. We flip the // test instead. int cmp1_op = cmp1->Opcode(); const TypeInt* cmp2_type = phase->type(cmp2)->isa_int(); if (cmp2_type == NULL) return NULL; Node* j_xor = cmp1; if( cmp2_type == TypeInt::ZERO && cmp1_op == Op_XorI && j_xor->in(1) != j_xor && // An xor of itself is dead phase->type( j_xor->in(1) ) == TypeInt::BOOL && phase->type( j_xor->in(2) ) == TypeInt::ONE && (_test._test == BoolTest::eq || _test._test == BoolTest::ne) ) { Node *ncmp = phase->transform(new CmpINode(j_xor->in(1),cmp2)); return new BoolNode( ncmp, _test.negate() ); } // Change ((x & m) u<= m) or ((m & x) u<= m) to always true // Same with ((x & m) u< m+1) and ((m & x) u< m+1) if (cop == Op_CmpU && cmp1_op == Op_AndI) { Node* bound = NULL; if (_test._test == BoolTest::le) { bound = cmp2; } else if (_test._test == BoolTest::lt && cmp2->Opcode() == Op_AddI && cmp2->in(2)->find_int_con(0) == 1) { bound = cmp2->in(1); } if (cmp1->in(2) == bound || cmp1->in(1) == bound) { return ConINode::make(1); } } // Change ((x & (m - 1)) u< m) into (m > 0) // This is the off-by-one variant of the above if (cop == Op_CmpU && _test._test == BoolTest::lt && cmp1_op == Op_AndI) { Node* l = cmp1->in(1); Node* r = cmp1->in(2); for (int repeat = 0; repeat < 2; repeat++) { bool match = r->Opcode() == Op_AddI && r->in(2)->find_int_con(0) == -1 && r->in(1) == cmp2; if (match) { // arraylength known to be non-negative, so a (arraylength != 0) is sufficient, // but to be compatible with the array range check pattern, use (arraylength u> 0) Node* ncmp = cmp2->Opcode() == Op_LoadRange ? phase->transform(new CmpUNode(cmp2, phase->intcon(0))) : phase->transform(new CmpINode(cmp2, phase->intcon(0))); return new BoolNode(ncmp, BoolTest::gt); } else { // commute and try again l = cmp1->in(2); r = cmp1->in(1); } } } // Change x u< 1 or x u<= 0 to x == 0 if (cop == Op_CmpU && cmp1_op != Op_LoadRange && ((_test._test == BoolTest::lt && cmp2->find_int_con(-1) == 1) || (_test._test == BoolTest::le && cmp2->find_int_con(-1) == 0))) { Node* ncmp = phase->transform(new CmpINode(cmp1, phase->intcon(0))); return new BoolNode(ncmp, BoolTest::eq); } // Change (arraylength <= 0) or (arraylength == 0) // into (arraylength u<= 0) // Also change (arraylength != 0) into (arraylength u> 0) // The latter version matches the code pattern generated for // array range checks, which will more likely be optimized later. if (cop == Op_CmpI && cmp1_op == Op_LoadRange && cmp2->find_int_con(-1) == 0) { if (_test._test == BoolTest::le || _test._test == BoolTest::eq) { Node* ncmp = phase->transform(new CmpUNode(cmp1, cmp2)); return new BoolNode(ncmp, BoolTest::le); } else if (_test._test == BoolTest::ne) { Node* ncmp = phase->transform(new CmpUNode(cmp1, cmp2)); return new BoolNode(ncmp, BoolTest::gt); } } // Change "bool eq/ne (cmp (Conv2B X) 0)" into "bool eq/ne (cmp X 0)". // This is a standard idiom for branching on a boolean value. Node *c2b = cmp1; if( cmp2_type == TypeInt::ZERO && cmp1_op == Op_Conv2B && (_test._test == BoolTest::eq || _test._test == BoolTest::ne) ) { Node *ncmp = phase->transform(phase->type(c2b->in(1))->isa_int() ? (Node*)new CmpINode(c2b->in(1),cmp2) : (Node*)new CmpPNode(c2b->in(1),phase->makecon(TypePtr::NULL_PTR)) ); return new BoolNode( ncmp, _test._test ); } // Comparing a SubI against a zero is equal to comparing the SubI // arguments directly. This only works for eq and ne comparisons // due to possible integer overflow. if ((_test._test == BoolTest::eq || _test._test == BoolTest::ne) && (cop == Op_CmpI) && (cmp1_op == Op_SubI) && ( cmp2_type == TypeInt::ZERO ) ) { Node *ncmp = phase->transform( new CmpINode(cmp1->in(1),cmp1->in(2))); return new BoolNode( ncmp, _test._test ); } // Same as above but with and AddI of a constant if ((_test._test == BoolTest::eq || _test._test == BoolTest::ne) && cop == Op_CmpI && cmp1_op == Op_AddI && cmp1->in(2) != NULL && phase->type(cmp1->in(2))->isa_int() && phase->type(cmp1->in(2))->is_int()->is_con() && cmp2_type == TypeInt::ZERO && !is_counted_loop_cmp(cmp) // modifying the exit test of a counted loop messes the counted loop shape ) { const TypeInt* cmp1_in2 = phase->type(cmp1->in(2))->is_int(); Node *ncmp = phase->transform( new CmpINode(cmp1->in(1),phase->intcon(-cmp1_in2->_hi))); return new BoolNode( ncmp, _test._test ); } // Change "bool eq/ne (cmp (phi (X -X) 0))" into "bool eq/ne (cmp X 0)" // since zero check of conditional negation of an integer is equal to // zero check of the integer directly. if ((_test._test == BoolTest::eq || _test._test == BoolTest::ne) && (cop == Op_CmpI) && (cmp2_type == TypeInt::ZERO) && (cmp1_op == Op_Phi)) { // There should be a diamond phi with true path at index 1 or 2 PhiNode *phi = cmp1->as_Phi(); int idx_true = phi->is_diamond_phi(); if (idx_true != 0) { // True input is in(idx_true) while false input is in(3 - idx_true) Node *tin = phi->in(idx_true); Node *fin = phi->in(3 - idx_true); if ((tin->Opcode() == Op_SubI) && (phase->type(tin->in(1)) == TypeInt::ZERO) && (tin->in(2) == fin)) { // Found conditional negation at true path, create a new CmpINode without that Node *ncmp = phase->transform(new CmpINode(fin, cmp2)); return new BoolNode(ncmp, _test._test); } if ((fin->Opcode() == Op_SubI) && (phase->type(fin->in(1)) == TypeInt::ZERO) && (fin->in(2) == tin)) { // Found conditional negation at false path, create a new CmpINode without that Node *ncmp = phase->transform(new CmpINode(tin, cmp2)); return new BoolNode(ncmp, _test._test); } } } // Change (-A vs 0) into (A vs 0) by commuting the test. Disallow in the // most general case because negating 0x80000000 does nothing. Needed for // the CmpF3/SubI/CmpI idiom. if( cop == Op_CmpI && cmp1_op == Op_SubI && cmp2_type == TypeInt::ZERO && phase->type( cmp1->in(1) ) == TypeInt::ZERO && phase->type( cmp1->in(2) )->higher_equal(TypeInt::SYMINT) ) { Node *ncmp = phase->transform( new CmpINode(cmp1->in(2),cmp2)); return new BoolNode( ncmp, _test.commute() ); } // Try to optimize signed integer comparison return fold_cmpI(phase, cmp->as_Sub(), cmp1, cop, cmp1_op, cmp2_type); // The transformation below is not valid for either signed or unsigned // comparisons due to wraparound concerns at MAX_VALUE and MIN_VALUE. // This transformation can be resurrected when we are able to // make inferences about the range of values being subtracted from // (or added to) relative to the wraparound point. // // // Remove +/-1's if possible. // // "X <= Y-1" becomes "X < Y" // // "X+1 <= Y" becomes "X < Y" // // "X < Y+1" becomes "X <= Y" // // "X-1 < Y" becomes "X <= Y" // // Do not this to compares off of the counted-loop-end. These guys are // // checking the trip counter and they want to use the post-incremented // // counter. If they use the PRE-incremented counter, then the counter has // // to be incremented in a private block on a loop backedge. // if( du && du->cnt(this) && du->out(this)[0]->Opcode() == Op_CountedLoopEnd ) // return NULL; // #ifndef PRODUCT // // Do not do this in a wash GVN pass during verification. // // Gets triggered by too many simple optimizations to be bothered with // // re-trying it again and again. // if( !phase->allow_progress() ) return NULL; // #endif // // Not valid for unsigned compare because of corner cases in involving zero. // // For example, replacing "X-1 <u Y" with "X <=u Y" fails to throw an // // exception in case X is 0 (because 0-1 turns into 4billion unsigned but // // "0 <=u Y" is always true). // if( cmp->Opcode() == Op_CmpU ) return NULL; // int cmp2_op = cmp2->Opcode(); // if( _test._test == BoolTest::le ) { // if( cmp1_op == Op_AddI && // phase->type( cmp1->in(2) ) == TypeInt::ONE ) // return clone_cmp( cmp, cmp1->in(1), cmp2, phase, BoolTest::lt ); // else if( cmp2_op == Op_AddI && // phase->type( cmp2->in(2) ) == TypeInt::MINUS_1 ) // return clone_cmp( cmp, cmp1, cmp2->in(1), phase, BoolTest::lt ); // } else if( _test._test == BoolTest::lt ) { // if( cmp1_op == Op_AddI && // phase->type( cmp1->in(2) ) == TypeInt::MINUS_1 ) // return clone_cmp( cmp, cmp1->in(1), cmp2, phase, BoolTest::le ); // else if( cmp2_op == Op_AddI && // phase->type( cmp2->in(2) ) == TypeInt::ONE ) // return clone_cmp( cmp, cmp1, cmp2->in(1), phase, BoolTest::le ); // } } //------------------------------Value------------------------------------------ // Simplify a Bool (convert condition codes to boolean (1 or 0)) node, // based on local information. If the input is constant, do it. const Type* BoolNode::Value(PhaseGVN* phase) const { return _test.cc2logical( phase->type( in(1) ) ); } #ifndef PRODUCT //------------------------------dump_spec-------------------------------------- // Dump special per-node info void BoolNode::dump_spec(outputStream *st) const { st->print("["); _test.dump_on(st); st->print("]"); } //-------------------------------related--------------------------------------- // A BoolNode's related nodes are all of its data inputs, and all of its // outputs until control nodes are hit, which are included. In compact // representation, inputs till level 3 and immediate outputs are included. void BoolNode::related(GrowableArray<Node*> *in_rel, GrowableArray<Node*> *out_rel, bool compact) const { if (compact) { this->collect_nodes(in_rel, 3, false, true); this->collect_nodes(out_rel, -1, false, false); } else { this->collect_nodes_in_all_data(in_rel, false); this->collect_nodes_out_all_ctrl_boundary(out_rel); } } #endif //----------------------is_counted_loop_exit_test------------------------------ // Returns true if node is used by a counted loop node. bool BoolNode::is_counted_loop_exit_test() { for( DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++ ) { Node* use = fast_out(i); if (use->is_CountedLoopEnd()) { return true; } } return false; } //============================================================================= //------------------------------Value------------------------------------------ // Compute sqrt const Type* SqrtDNode::Value(PhaseGVN* phase) const { const Type *t1 = phase->type( in(1) ); if( t1 == Type::TOP ) return Type::TOP; if( t1->base() != Type::DoubleCon ) return Type::DOUBLE; double d = t1->getd(); if( d < 0.0 ) return Type::DOUBLE; return TypeD::make( sqrt( d ) ); } const Type* SqrtFNode::Value(PhaseGVN* phase) const { const Type *t1 = phase->type( in(1) ); if( t1 == Type::TOP ) return Type::TOP; if( t1->base() != Type::FloatCon ) return Type::FLOAT; float f = t1->getf(); if( f < 0.0f ) return Type::FLOAT; return TypeF::make( (float)sqrt( (double)f ) ); }
#pragma once #include <iostream> #include <type_traits> #include <chrono> namespace utils { template <typename Fn, typename ResType = std::invoke_result_t<Fn>> auto measure(Fn fn) -> ResType { static_assert(std::is_invocable<Fn>::value, "Fn must be callable and accept no argument"); constexpr bool is_void = std::is_void<ResType>::value; typedef typename std::conditional<is_void, char, ResType>::type result_t; result_t result; const auto before = std::chrono::high_resolution_clock::now(); if constexpr (is_void) { fn(); } else { result = fn(); } const auto after = std::chrono::high_resolution_clock::now(); std::chrono::duration<double, std::milli> timing = after - before; std::cout << "Execution time: " << timing.count() << "ms\n"; if constexpr (is_void) { return; } else { return result; } } } //time
/* Copyright (c) 2015-2022 The Khronos Group Inc. * Copyright (c) 2015-2022 Valve Corporation * Copyright (c) 2015-2022 LunarG, Inc. * Copyright (C) 2015-2022 Google Inc. * Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Author: Courtney Goeltzenleuchter <courtneygo@google.com> * Author: Tobin Ehlis <tobine@google.com> * Author: Chris Forbes <chrisf@ijw.co.nz> * Author: Mark Lobodzinski <mark@lunarg.com> * Author: Dave Houlton <daveh@lunarg.com> * Author: John Zulauf <jzulauf@lunarg.com> * Author: Tobias Hector <tobias.hector@amd.com> * Author: Jeremy Gebben <jeremyg@lunarg.com> */ #include "image_state.h" #include "pipeline_state.h" #include "descriptor_sets.h" #include "state_tracker.h" #include <limits> static VkImageSubresourceRange MakeImageFullRange(const VkImageCreateInfo &create_info) { const auto format = create_info.format; VkImageSubresourceRange init_range{0, 0, VK_REMAINING_MIP_LEVELS, 0, VK_REMAINING_ARRAY_LAYERS}; #ifdef VK_USE_PLATFORM_ANDROID_KHR const VkExternalFormatANDROID *external_format_android = LvlFindInChain<VkExternalFormatANDROID>(&create_info); bool is_external_format_conversion = (external_format_android != nullptr && external_format_android->externalFormat != 0); #else bool is_external_format_conversion = false; #endif if (FormatIsColor(format) || FormatIsMultiplane(format) || is_external_format_conversion) { init_range.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; // Normalization will expand this for multiplane } else { init_range.aspectMask = (FormatHasDepth(format) ? VK_IMAGE_ASPECT_DEPTH_BIT : 0) | (FormatHasStencil(format) ? VK_IMAGE_ASPECT_STENCIL_BIT : 0); } return NormalizeSubresourceRange(create_info, init_range); } static uint32_t ResolveRemainingLevels(const VkImageSubresourceRange *range, uint32_t mip_levels) { // Return correct number of mip levels taking into account VK_REMAINING_MIP_LEVELS uint32_t mip_level_count = range->levelCount; if (range->levelCount == VK_REMAINING_MIP_LEVELS) { mip_level_count = mip_levels - range->baseMipLevel; } return mip_level_count; } static uint32_t ResolveRemainingLayers(const VkImageSubresourceRange *range, uint32_t layers) { // Return correct number of layers taking into account VK_REMAINING_ARRAY_LAYERS uint32_t array_layer_count = range->layerCount; if (range->layerCount == VK_REMAINING_ARRAY_LAYERS) { array_layer_count = layers - range->baseArrayLayer; } return array_layer_count; } VkImageSubresourceRange NormalizeSubresourceRange(const VkImageCreateInfo &image_create_info, const VkImageSubresourceRange &range) { VkImageSubresourceRange norm = range; norm.levelCount = ResolveRemainingLevels(&range, image_create_info.mipLevels); norm.layerCount = ResolveRemainingLayers(&range, image_create_info.arrayLayers); // For multiplanar formats, IMAGE_ASPECT_COLOR is equivalent to adding the aspect of the individual planes if (FormatIsMultiplane(image_create_info.format)) { if (norm.aspectMask & VK_IMAGE_ASPECT_COLOR_BIT) { norm.aspectMask &= ~VK_IMAGE_ASPECT_COLOR_BIT; norm.aspectMask |= (VK_IMAGE_ASPECT_PLANE_0_BIT | VK_IMAGE_ASPECT_PLANE_1_BIT); if (FormatPlaneCount(image_create_info.format) > 2) { norm.aspectMask |= VK_IMAGE_ASPECT_PLANE_2_BIT; } } } return norm; } static bool IsDepthSliced(const VkImageCreateInfo &image_create_info, const VkImageViewCreateInfo &create_info) { return ((image_create_info.flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) != 0) && (create_info.viewType == VK_IMAGE_VIEW_TYPE_2D || create_info.viewType == VK_IMAGE_VIEW_TYPE_2D_ARRAY); } VkImageSubresourceRange NormalizeSubresourceRange(const VkImageCreateInfo &image_create_info, const VkImageViewCreateInfo &create_info) { auto subres_range = create_info.subresourceRange; // if we're mapping a 3D image to a 2d image view, convert the view's subresource range to be compatible with the // image's understanding of the world. From the VkImageSubresourceRange section of the Vulkan spec: // // When the VkImageSubresourceRange structure is used to select a subset of the slices of a 3D image’s mip level in // order to create a 2D or 2D array image view of a 3D image created with VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT, // baseArrayLayer and layerCount specify the first slice index and the number of slices to include in the created // image view. Such an image view can be used as a framebuffer attachment that refers only to the specified range // of slices of the selected mip level. However, any layout transitions performed on such an attachment view during // a render pass instance still apply to the entire subresource referenced which includes all the slices of the // selected mip level. // if (IsDepthSliced(image_create_info, create_info)) { subres_range.baseArrayLayer = 0; subres_range.layerCount = 1; } return NormalizeSubresourceRange(image_create_info, subres_range); } static VkExternalMemoryHandleTypeFlags GetExternalHandleType(const VkImageCreateInfo *pCreateInfo) { const auto *external_memory_info = LvlFindInChain<VkExternalMemoryImageCreateInfo>(pCreateInfo->pNext); return external_memory_info ? external_memory_info->handleTypes : 0; } static VkSwapchainKHR GetSwapchain(const VkImageCreateInfo *pCreateInfo) { const auto *swapchain_info = LvlFindInChain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext); return swapchain_info ? swapchain_info->swapchain : VK_NULL_HANDLE; } #ifdef VK_USE_PLATFORM_ANDROID_KHR static uint64_t GetExternalFormat(const VkImageCreateInfo *info) { const VkExternalFormatANDROID *ext_format_android = LvlFindInChain<VkExternalFormatANDROID>(info->pNext); return ext_format_android ? ext_format_android->externalFormat : 0; } #else static uint64_t GetExternalFormat(const VkImageCreateInfo *info) { return 0; } #endif // VK_USE_PLATFORM_ANDROID_KHR static IMAGE_STATE::MemoryReqs GetMemoryRequirements(const ValidationStateTracker *dev_data, VkImage img, const VkImageCreateInfo *create_info, bool disjoint, bool is_external_ahb) { IMAGE_STATE::MemoryReqs result{}; // Record the memory requirements in case they won't be queried // External AHB memory can't be queried until after memory is bound if (!is_external_ahb) { if (disjoint == false) { DispatchGetImageMemoryRequirements(dev_data->device, img, &result[0]); } else { uint32_t plane_count = FormatPlaneCount(create_info->format); static const std::array<VkImageAspectFlagBits, 3> aspects{VK_IMAGE_ASPECT_PLANE_0_BIT, VK_IMAGE_ASPECT_PLANE_1_BIT, VK_IMAGE_ASPECT_PLANE_2_BIT}; assert(plane_count <= aspects.size()); auto image_plane_req = lvl_init_struct<VkImagePlaneMemoryRequirementsInfo>(); auto mem_req_info2 = lvl_init_struct<VkImageMemoryRequirementsInfo2>(&image_plane_req); mem_req_info2.image = img; for (uint32_t i = 0; i < plane_count; i++) { auto mem_reqs2 = lvl_init_struct<VkMemoryRequirements2>(); image_plane_req.planeAspect = aspects[i]; switch (dev_data->device_extensions.vk_khr_get_memory_requirements2) { case kEnabledByApiLevel: DispatchGetImageMemoryRequirements2(dev_data->device, &mem_req_info2, &mem_reqs2); break; case kEnabledByCreateinfo: DispatchGetImageMemoryRequirements2KHR(dev_data->device, &mem_req_info2, &mem_reqs2); break; default: // The VK_KHR_sampler_ycbcr_conversion extension requires VK_KHR_get_memory_requirements2, // so validation of this vkCreateImage call should have already failed. assert(false); } result[i] = mem_reqs2.memoryRequirements; } } } return result; } static IMAGE_STATE::SparseReqs GetSparseRequirements(const ValidationStateTracker *dev_data, VkImage img, const VkImageCreateInfo *create_info) { IMAGE_STATE::SparseReqs result; if (create_info->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) { uint32_t count = 0; DispatchGetImageSparseMemoryRequirements(dev_data->device, img, &count, nullptr); result.resize(count); DispatchGetImageSparseMemoryRequirements(dev_data->device, img, &count, result.data()); } return result; } static bool SparseMetaDataRequired(const IMAGE_STATE::SparseReqs &sparse_reqs) { bool result = false; for (const auto &req : sparse_reqs) { if (req.formatProperties.aspectMask & VK_IMAGE_ASPECT_METADATA_BIT) { result = true; break; } } return result; } IMAGE_STATE::IMAGE_STATE(const ValidationStateTracker *dev_data, VkImage img, const VkImageCreateInfo *pCreateInfo, VkFormatFeatureFlags2KHR ff) : BINDABLE(img, kVulkanObjectTypeImage, (pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != 0, (pCreateInfo->flags & VK_IMAGE_CREATE_PROTECTED_BIT) == 0, GetExternalHandleType(pCreateInfo)), safe_create_info(pCreateInfo), createInfo(*safe_create_info.ptr()), shared_presentable(false), layout_locked(false), ahb_format(GetExternalFormat(pCreateInfo)), full_range{MakeImageFullRange(*pCreateInfo)}, create_from_swapchain(GetSwapchain(pCreateInfo)), swapchain_image_index(0), format_features(ff), disjoint((pCreateInfo->flags & VK_IMAGE_CREATE_DISJOINT_BIT) != 0), requirements(GetMemoryRequirements(dev_data, img, pCreateInfo, disjoint, IsExternalAHB())), memory_requirements_checked{{false, false, false}}, sparse_requirements(GetSparseRequirements(dev_data, img, pCreateInfo)), sparse_metadata_required(SparseMetaDataRequired(sparse_requirements)), get_sparse_reqs_called(false), sparse_metadata_bound(false), subresource_encoder(full_range), fragment_encoder(nullptr), store_device_as_workaround(dev_data->device) {} // TODO REMOVE WHEN encoder can be const IMAGE_STATE::IMAGE_STATE(const ValidationStateTracker *dev_data, VkImage img, const VkImageCreateInfo *pCreateInfo, VkSwapchainKHR swapchain, uint32_t swapchain_index, VkFormatFeatureFlags2KHR ff) : BINDABLE(img, kVulkanObjectTypeImage, (pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != 0, (pCreateInfo->flags & VK_IMAGE_CREATE_PROTECTED_BIT) == 0, GetExternalHandleType(pCreateInfo)), safe_create_info(pCreateInfo), createInfo(*safe_create_info.ptr()), shared_presentable(false), layout_locked(false), ahb_format(GetExternalFormat(pCreateInfo)), full_range{MakeImageFullRange(*pCreateInfo)}, create_from_swapchain(swapchain), swapchain_image_index(swapchain_index), format_features(ff), disjoint((pCreateInfo->flags & VK_IMAGE_CREATE_DISJOINT_BIT) != 0), requirements{}, memory_requirements_checked{false, false, false}, sparse_requirements{}, sparse_metadata_required(false), get_sparse_reqs_called(false), sparse_metadata_bound(false), subresource_encoder(full_range), fragment_encoder(nullptr), store_device_as_workaround(dev_data->device) { // TODO REMOVE WHEN encoder can be const fragment_encoder = std::unique_ptr<const subresource_adapter::ImageRangeEncoder>(new subresource_adapter::ImageRangeEncoder(*this)); } void IMAGE_STATE::Destroy() { // NOTE: due to corner cases in aliased images, the layout_range_map MUST not be cleaned up here. // If it is, bad local entries could be created by CMD_BUFFER_STATE::GetImageSubresourceLayoutMap() // If an aliasing image was being destroyed (and layout_range_map was reset()), a nullptr keyed // entry could get put into CMD_BUFFER_STATE::aliased_image_layout_map. if (bind_swapchain) { bind_swapchain->RemoveParent(this); bind_swapchain = nullptr; } BINDABLE::Destroy(); } void IMAGE_STATE::NotifyInvalidate(const BASE_NODE::NodeList &invalid_nodes, bool unlink) { BINDABLE::NotifyInvalidate(invalid_nodes, unlink); if (unlink) { bind_swapchain = nullptr; } } bool IMAGE_STATE::IsCreateInfoEqual(const VkImageCreateInfo &other_createInfo) const { bool is_equal = (createInfo.sType == other_createInfo.sType) && (createInfo.flags == other_createInfo.flags); is_equal = is_equal && IsImageTypeEqual(other_createInfo) && IsFormatEqual(other_createInfo); is_equal = is_equal && IsMipLevelsEqual(other_createInfo) && IsArrayLayersEqual(other_createInfo); is_equal = is_equal && IsUsageEqual(other_createInfo) && IsInitialLayoutEqual(other_createInfo); is_equal = is_equal && IsExtentEqual(other_createInfo) && IsTilingEqual(other_createInfo); is_equal = is_equal && IsSamplesEqual(other_createInfo) && IsSharingModeEqual(other_createInfo); return is_equal && ((createInfo.sharingMode == VK_SHARING_MODE_CONCURRENT) ? IsQueueFamilyIndicesEqual(other_createInfo) : true); } // Check image compatibility rules for VK_NV_dedicated_allocation_image_aliasing bool IMAGE_STATE::IsCreateInfoDedicatedAllocationImageAliasingCompatible(const VkImageCreateInfo &other_createInfo) const { bool is_compatible = (createInfo.sType == other_createInfo.sType) && (createInfo.flags == other_createInfo.flags); is_compatible = is_compatible && IsImageTypeEqual(other_createInfo) && IsFormatEqual(other_createInfo); is_compatible = is_compatible && IsMipLevelsEqual(other_createInfo); is_compatible = is_compatible && IsUsageEqual(other_createInfo) && IsInitialLayoutEqual(other_createInfo); is_compatible = is_compatible && IsSamplesEqual(other_createInfo) && IsSharingModeEqual(other_createInfo); is_compatible = is_compatible && ((createInfo.sharingMode == VK_SHARING_MODE_CONCURRENT) ? IsQueueFamilyIndicesEqual(other_createInfo) : true); is_compatible = is_compatible && IsTilingEqual(other_createInfo); is_compatible = is_compatible && createInfo.extent.width <= other_createInfo.extent.width && createInfo.extent.height <= other_createInfo.extent.height && createInfo.extent.depth <= other_createInfo.extent.depth && createInfo.arrayLayers <= other_createInfo.arrayLayers; return is_compatible; } bool IMAGE_STATE::IsCompatibleAliasing(IMAGE_STATE *other_image_state) const { if (!IsSwapchainImage() && !other_image_state->IsSwapchainImage() && !(createInfo.flags & other_image_state->createInfo.flags & VK_IMAGE_CREATE_ALIAS_BIT)) { return false; } const auto binding = Binding(); const auto other_binding = other_image_state->Binding(); if ((create_from_swapchain == VK_NULL_HANDLE) && binding && other_binding && (binding->memory_state == other_binding->memory_state) && (binding->memory_offset == other_binding->memory_offset) && IsCreateInfoEqual(other_image_state->createInfo)) { return true; } if (bind_swapchain && (bind_swapchain == other_image_state->bind_swapchain) && (swapchain_image_index == other_image_state->swapchain_image_index)) { return true; } return false; } void IMAGE_STATE::SetInitialLayoutMap() { if (layout_range_map) { return; } if ((createInfo.flags & VK_IMAGE_CREATE_ALIAS_BIT) != 0) { // Look for another aliasing image and point at its layout state. // ObjectBindings() is thread safe since returns by value, and once // the weak_ptr is successfully locked, the other image state won't // be freed out from under us. for (auto const &memory_state : GetBoundMemoryStates()) { for (auto &entry : memory_state->ObjectBindings()) { if (entry.first.type == kVulkanObjectTypeImage) { auto base_node = entry.second.lock(); if (base_node) { auto other_image = static_cast<IMAGE_STATE *>(base_node.get()); if (other_image != this && other_image->IsCompatibleAliasing(this)) { layout_range_map = other_image->layout_range_map; break; } } } } } } else if (bind_swapchain) { // Swapchains can also alias if multiple images are bound (or retrieved // with vkGetSwapchainImages()) for a (single swapchain, index) pair. // ObjectBindings() is thread safe since returns by value, and once // the weak_ptr is successfully locked, the other image state won't // be freed out from under us. for (auto &entry : bind_swapchain->ObjectBindings()) { if (entry.first.type == kVulkanObjectTypeImage) { auto base_node = entry.second.lock(); if (base_node) { auto other_image = static_cast<IMAGE_STATE *>(base_node.get()); if (other_image != this && other_image->IsCompatibleAliasing(this)) { layout_range_map = other_image->layout_range_map; break; } } } } } // ... otherwise set up the new map. if (!layout_range_map) { // set up the new map completely before making it available auto new_map = std::make_shared<GlobalImageLayoutRangeMap>(subresource_encoder.SubresourceCount()); auto range_gen = subresource_adapter::RangeGenerator(subresource_encoder); for (; range_gen->non_empty(); ++range_gen) { new_map->insert(new_map->end(), std::make_pair(*range_gen, createInfo.initialLayout)); } layout_range_map = std::move(new_map); } } void IMAGE_STATE::SetSwapchain(std::shared_ptr<SWAPCHAIN_NODE> &swapchain, uint32_t swapchain_index) { assert(IsSwapchainImage()); bind_swapchain = swapchain; swapchain_image_index = swapchain_index; bind_swapchain->AddParent(this); } VkDeviceSize IMAGE_STATE::GetFakeBaseAddress() const { if (!IsSwapchainImage()) { return BINDABLE::GetFakeBaseAddress(); } if (!bind_swapchain) { return 0; } return bind_swapchain->images[swapchain_image_index].fake_base_address; } VkExtent3D IMAGE_STATE::GetSubresourceExtent(VkImageAspectFlags aspect_mask, uint32_t mip_level) const { // Return zero extent if mip level doesn't exist if (mip_level >= createInfo.mipLevels) { return VkExtent3D{0, 0, 0}; } // Don't allow mip adjustment to create 0 dim, but pass along a 0 if that's what subresource specified VkExtent3D extent = createInfo.extent; // If multi-plane, adjust per-plane extent if (FormatIsMultiplane(createInfo.format)) { VkExtent2D divisors = FindMultiplaneExtentDivisors(createInfo.format, aspect_mask); extent.width /= divisors.width; extent.height /= divisors.height; } if (createInfo.flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) { extent.width = (0 == extent.width ? 0 : std::max(2U, 1 + ((extent.width - 1) >> mip_level))); extent.height = (0 == extent.height ? 0 : std::max(2U, 1 + ((extent.height - 1) >> mip_level))); extent.depth = (0 == extent.depth ? 0 : std::max(2U, 1 + ((extent.depth - 1) >> mip_level))); } else { extent.width = (0 == extent.width ? 0 : std::max(1U, extent.width >> mip_level)); extent.height = (0 == extent.height ? 0 : std::max(1U, extent.height >> mip_level)); extent.depth = (0 == extent.depth ? 0 : std::max(1U, extent.depth >> mip_level)); } // Image arrays have an effective z extent that isn't diminished by mip level if (VK_IMAGE_TYPE_3D != createInfo.imageType) { extent.depth = createInfo.arrayLayers; } return extent; } // Returns the effective extent of an image subresource, adjusted for mip level and array depth. VkExtent3D IMAGE_STATE::GetSubresourceExtent(const VkImageSubresourceLayers &subresource) const { return GetSubresourceExtent(subresource.aspectMask, subresource.mipLevel); } static VkSamplerYcbcrConversion GetSamplerConversion(const VkImageViewCreateInfo *ci) { auto *conversion_info = LvlFindInChain<VkSamplerYcbcrConversionInfo>(ci->pNext); return conversion_info ? conversion_info->conversion : VK_NULL_HANDLE; } static VkImageUsageFlags GetInheritedUsage(const VkImageViewCreateInfo *ci, const IMAGE_STATE &image_state) { auto usage_create_info = LvlFindInChain<VkImageViewUsageCreateInfo>(ci->pNext); return (usage_create_info) ? usage_create_info->usage : image_state.createInfo.usage; } static float GetImageViewMinLod(const VkImageViewCreateInfo* ci) { auto image_view_min_lod = LvlFindInChain<VkImageViewMinLodCreateInfoEXT>(ci->pNext); return (image_view_min_lod) ? image_view_min_lod->minLod : 0.0f; } IMAGE_VIEW_STATE::IMAGE_VIEW_STATE(const std::shared_ptr<IMAGE_STATE> &im, VkImageView iv, const VkImageViewCreateInfo *ci, VkFormatFeatureFlags2KHR ff, const VkFilterCubicImageViewImageFormatPropertiesEXT &cubic_props) : BASE_NODE(iv, kVulkanObjectTypeImageView), safe_create_info(ci), create_info(*safe_create_info.ptr()), normalized_subresource_range(::NormalizeSubresourceRange(im->createInfo, *ci)), range_generator(im->subresource_encoder, normalized_subresource_range), samples(im->createInfo.samples), // When the image has a external format the views format must be VK_FORMAT_UNDEFINED and it is required to use a sampler // Ycbcr conversion. Thus we can't extract any meaningful information from the format parameter. As a Sampler Ycbcr // conversion must be used the shader type is always float. descriptor_format_bits(im->HasAHBFormat() ? static_cast<unsigned>(DESCRIPTOR_REQ_COMPONENT_TYPE_FLOAT) : DescriptorRequirementsBitsFromFormat(ci->format)), samplerConversion(GetSamplerConversion(ci)), filter_cubic_props(cubic_props), min_lod(GetImageViewMinLod(ci)), format_features(ff), inherited_usage(GetInheritedUsage(ci, *im)), image_state(im) {} void IMAGE_VIEW_STATE::Destroy() { if (image_state) { image_state->RemoveParent(this); image_state = nullptr; } BASE_NODE::Destroy(); } bool IMAGE_VIEW_STATE::IsDepthSliced() const { return ::IsDepthSliced(image_state->createInfo, create_info); } VkOffset3D IMAGE_VIEW_STATE::GetOffset() const { VkOffset3D result = {0, 0, 0}; if (IsDepthSliced()) { result.z = create_info.subresourceRange.baseArrayLayer; } return result; } VkExtent3D IMAGE_VIEW_STATE::GetExtent() const { VkExtent3D result = image_state->createInfo.extent; if (IsDepthSliced()) { result.depth = create_info.subresourceRange.layerCount; } return result; } uint32_t IMAGE_VIEW_STATE::GetAttachmentLayerCount() const { if (create_info.subresourceRange.layerCount == VK_REMAINING_ARRAY_LAYERS && !IsDepthSliced()) { return image_state->createInfo.arrayLayers; } return create_info.subresourceRange.layerCount; } static safe_VkImageCreateInfo GetImageCreateInfo(const VkSwapchainCreateInfoKHR *pCreateInfo) { auto image_ci = LvlInitStruct<VkImageCreateInfo>(); // Pull out the format list only. This stack variable will get copied onto the heap // by the 'safe' constructor used to build the return value below. VkImageFormatListCreateInfo fmt_info; auto chain_fmt_info = LvlFindInChain<VkImageFormatListCreateInfo>(pCreateInfo->pNext); if (chain_fmt_info) { fmt_info = *chain_fmt_info; fmt_info.pNext = nullptr; image_ci.pNext = &fmt_info; } else { image_ci.pNext = nullptr; } image_ci.flags = 0; // to be updated below image_ci.imageType = VK_IMAGE_TYPE_2D; image_ci.format = pCreateInfo->imageFormat; image_ci.extent.width = pCreateInfo->imageExtent.width; image_ci.extent.height = pCreateInfo->imageExtent.height; image_ci.extent.depth = 1; image_ci.mipLevels = 1; image_ci.arrayLayers = pCreateInfo->imageArrayLayers; image_ci.samples = VK_SAMPLE_COUNT_1_BIT; image_ci.tiling = VK_IMAGE_TILING_OPTIMAL; image_ci.usage = pCreateInfo->imageUsage; image_ci.sharingMode = pCreateInfo->imageSharingMode; image_ci.queueFamilyIndexCount = pCreateInfo->queueFamilyIndexCount; image_ci.pQueueFamilyIndices = pCreateInfo->pQueueFamilyIndices; image_ci.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; if (pCreateInfo->flags & VK_SWAPCHAIN_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT_KHR) { image_ci.flags |= VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT; } if (pCreateInfo->flags & VK_SWAPCHAIN_CREATE_PROTECTED_BIT_KHR) { image_ci.flags |= VK_IMAGE_CREATE_PROTECTED_BIT; } if (pCreateInfo->flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) { image_ci.flags |= (VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT); } return safe_VkImageCreateInfo(&image_ci); } SWAPCHAIN_NODE::SWAPCHAIN_NODE(ValidationStateTracker *dev_data_, const VkSwapchainCreateInfoKHR *pCreateInfo, VkSwapchainKHR swapchain) : BASE_NODE(swapchain, kVulkanObjectTypeSwapchainKHR), createInfo(pCreateInfo), shared_presentable(VK_PRESENT_MODE_SHARED_DEMAND_REFRESH_KHR == pCreateInfo->presentMode || VK_PRESENT_MODE_SHARED_CONTINUOUS_REFRESH_KHR == pCreateInfo->presentMode), image_create_info(GetImageCreateInfo(pCreateInfo)), dev_data(dev_data_) {} void SWAPCHAIN_NODE::PresentImage(uint32_t image_index) { if (image_index >= images.size()) return; assert(acquired_images > 0); acquired_images--; images[image_index].acquired = false; if (shared_presentable) { IMAGE_STATE *image_state = images[image_index].image_state; if (image_state) { image_state->layout_locked = true; } } } void SWAPCHAIN_NODE::AcquireImage(uint32_t image_index) { if (image_index >= images.size()) return; assert(acquired_images < std::numeric_limits<uint32_t>::max()); acquired_images++; images[image_index].acquired = true; if (shared_presentable) { IMAGE_STATE *image_state = images[image_index].image_state; if (image_state) { image_state->shared_presentable = shared_presentable; } } } void SWAPCHAIN_NODE::Destroy() { for (auto &swapchain_image : images) { if (swapchain_image.image_state) { RemoveParent(swapchain_image.image_state); dev_data->Destroy<IMAGE_STATE>(swapchain_image.image_state->image()); } // NOTE: We don't have access to dev_data->fake_memory.Free() here, but it is currently a no-op } images.clear(); if (surface) { surface->RemoveParent(this); surface = nullptr; } BASE_NODE::Destroy(); } void SWAPCHAIN_NODE::NotifyInvalidate(const BASE_NODE::NodeList &invalid_nodes, bool unlink) { BASE_NODE::NotifyInvalidate(invalid_nodes, unlink); if (unlink) { surface = nullptr; } } void SURFACE_STATE::Destroy() { if (swapchain) { swapchain = nullptr; } BASE_NODE::Destroy(); } void SURFACE_STATE::RemoveParent(BASE_NODE *parent_node) { if (swapchain == parent_node) { swapchain = nullptr; } BASE_NODE::RemoveParent(parent_node); } void SURFACE_STATE::SetQueueSupport(VkPhysicalDevice phys_dev, uint32_t qfi, bool supported) { auto guard = Lock(); assert(phys_dev); GpuQueue key{phys_dev, qfi}; gpu_queue_support_[key] = supported; } bool SURFACE_STATE::GetQueueSupport(VkPhysicalDevice phys_dev, uint32_t qfi) const { auto guard = Lock(); assert(phys_dev); GpuQueue key{phys_dev, qfi}; auto iter = gpu_queue_support_.find(key); if (iter != gpu_queue_support_.end()) { return iter->second; } VkBool32 supported = VK_FALSE; DispatchGetPhysicalDeviceSurfaceSupportKHR(phys_dev, qfi, surface(), &supported); gpu_queue_support_[key] = (supported == VK_TRUE); return supported == VK_TRUE; } void SURFACE_STATE::SetPresentModes(VkPhysicalDevice phys_dev, std::vector<VkPresentModeKHR> &&modes) { auto guard = Lock(); assert(phys_dev); present_modes_[phys_dev] = std::move(modes); } std::vector<VkPresentModeKHR> SURFACE_STATE::GetPresentModes(VkPhysicalDevice phys_dev) const { auto guard = Lock(); assert(phys_dev); auto iter = present_modes_.find(phys_dev); if (iter != present_modes_.end()) { return iter->second; } std::vector<VkPresentModeKHR> result; uint32_t count = 0; DispatchGetPhysicalDeviceSurfacePresentModesKHR(phys_dev, surface(), &count, nullptr); result.resize(count); DispatchGetPhysicalDeviceSurfacePresentModesKHR(phys_dev, surface(), &count, result.data()); return result; } void SURFACE_STATE::SetFormats(VkPhysicalDevice phys_dev, std::vector<VkSurfaceFormatKHR> &&fmts) { auto guard = Lock(); assert(phys_dev); formats_[phys_dev] = std::move(fmts); } std::vector<VkSurfaceFormatKHR> SURFACE_STATE::GetFormats(VkPhysicalDevice phys_dev) const { auto guard = Lock(); assert(phys_dev); auto iter = formats_.find(phys_dev); if (iter != formats_.end()) { return iter->second; } std::vector<VkSurfaceFormatKHR> result; uint32_t count = 0; DispatchGetPhysicalDeviceSurfaceFormatsKHR(phys_dev, surface(), &count, nullptr); result.resize(count); DispatchGetPhysicalDeviceSurfaceFormatsKHR(phys_dev, surface(), &count, result.data()); formats_[phys_dev] = result; return result; } void SURFACE_STATE::SetCapabilities(VkPhysicalDevice phys_dev, const VkSurfaceCapabilitiesKHR &caps) { auto guard = Lock(); assert(phys_dev); capabilities_[phys_dev] = caps; } VkSurfaceCapabilitiesKHR SURFACE_STATE::GetCapabilities(VkPhysicalDevice phys_dev) const { auto guard = Lock(); assert(phys_dev); auto iter = capabilities_.find(phys_dev); if (iter != capabilities_.end()) { return iter->second; } VkSurfaceCapabilitiesKHR result{}; DispatchGetPhysicalDeviceSurfaceCapabilitiesKHR(phys_dev, surface(), &result); capabilities_[phys_dev] = result; return result; }
#include "./lib.hpp" #include <cstdint> #include <iostream> int main() { std::int32_t a{21}; std::int32_t b{22}; std::int32_t c = lib::add(a, b); std::cout << "a = " << a << std::endl << "b = " << b << std::endl << "c = " << c << std::endl; return 0; }
// Copyright (c) 2011-2014 The Bitcoin developers // Copyright (c) 2014-2015 The Dash developers // Copyright (c) 2015-2017 The PIVX developers // Copyright (c) 2018-2019 The csocoin Core developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "transactionrecord.h" #include "base58.h" #include "obfuscation.h" #include "swifttx.h" #include "timedata.h" #include "wallet.h" #include <stdint.h> /* Return positive answer if transaction should be shown in list. */ bool TransactionRecord::showTransaction(const CWalletTx& wtx) { if (wtx.IsCoinBase()) { // Ensures we show generated coins / mined transactions at depth 1 if (!wtx.IsInMainChain()) { return false; } } return true; } /* * Decompose CWallet transaction to model transaction records. */ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet* wallet, const CWalletTx& wtx) { QList<TransactionRecord> parts; int64_t nTime = wtx.GetTxTime(); CAmount nCredit = wtx.GetCredit(ISMINE_ALL); CAmount nDebit = wtx.GetDebit(ISMINE_ALL); CAmount nNet = nCredit - nDebit; uint256 hash = wtx.GetHash(); std::map<std::string, std::string> mapValue = wtx.mapValue; if (wtx.IsCoinStake()) { TransactionRecord sub(hash, nTime); CTxDestination address; if (!ExtractDestination(wtx.vout[1].scriptPubKey, address)) return parts; if (!IsMine(*wallet, address)) { //if the address is not yours then it means you have a tx sent to you in someone elses coinstake tx for (unsigned int i = 1; i < wtx.vout.size(); i++) { CTxDestination outAddress; if (ExtractDestination(wtx.vout[i].scriptPubKey, outAddress)) { if (IsMine(*wallet, outAddress)) { isminetype mine = wallet->IsMine(wtx.vout[i]); sub.involvesWatchAddress = mine & ISMINE_WATCH_ONLY; sub.type = TransactionRecord::MNReward; sub.address = CBitcoinAddress(outAddress).ToString(); sub.credit = wtx.vout[i].nValue; } } } } else { //stake reward isminetype mine = wallet->IsMine(wtx.vout[1]); sub.involvesWatchAddress = mine & ISMINE_WATCH_ONLY; sub.type = TransactionRecord::StakeMint; sub.address = CBitcoinAddress(address).ToString(); sub.credit = nNet; } parts.append(sub); } else if (nNet > 0 || wtx.IsCoinBase()) { // // Credit // BOOST_FOREACH (const CTxOut& txout, wtx.vout) { isminetype mine = wallet->IsMine(txout); if (mine) { TransactionRecord sub(hash, nTime); CTxDestination address; sub.idx = parts.size(); // sequence number sub.credit = txout.nValue; sub.involvesWatchAddress = mine & ISMINE_WATCH_ONLY; if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*wallet, address)) { // Received by csocoin Address sub.type = TransactionRecord::RecvWithAddress; sub.address = CBitcoinAddress(address).ToString(); } else { // Received by IP connection (deprecated features), or a multisignature or other non-simple transaction sub.type = TransactionRecord::RecvFromOther; sub.address = mapValue["from"]; } if (wtx.IsCoinBase()) { // Generated sub.type = TransactionRecord::Generated; } parts.append(sub); } } } else { bool fAllFromMeDenom = true; int nFromMe = 0; bool involvesWatchAddress = false; isminetype fAllFromMe = ISMINE_SPENDABLE; BOOST_FOREACH (const CTxIn& txin, wtx.vin) { if (wallet->IsMine(txin)) { fAllFromMeDenom = fAllFromMeDenom && wallet->IsDenominated(txin); nFromMe++; } isminetype mine = wallet->IsMine(txin); if (mine & ISMINE_WATCH_ONLY) involvesWatchAddress = true; if (fAllFromMe > mine) fAllFromMe = mine; } isminetype fAllToMe = ISMINE_SPENDABLE; bool fAllToMeDenom = true; int nToMe = 0; BOOST_FOREACH (const CTxOut& txout, wtx.vout) { if (wallet->IsMine(txout)) { fAllToMeDenom = fAllToMeDenom && wallet->IsDenominatedAmount(txout.nValue); nToMe++; } isminetype mine = wallet->IsMine(txout); if (mine & ISMINE_WATCH_ONLY) involvesWatchAddress = true; if (fAllToMe > mine) fAllToMe = mine; } if (fAllFromMeDenom && fAllToMeDenom && nFromMe * nToMe) { parts.append(TransactionRecord(hash, nTime, TransactionRecord::ObfuscationDenominate, "", -nDebit, nCredit)); parts.last().involvesWatchAddress = false; // maybe pass to TransactionRecord as constructor argument } else if (fAllFromMe && fAllToMe) { // Payment to self // TODO: this section still not accurate but covers most cases, // might need some additional work however TransactionRecord sub(hash, nTime); // Payment to self by default sub.type = TransactionRecord::SendToSelf; sub.address = ""; if (mapValue["DS"] == "1") { sub.type = TransactionRecord::Obfuscated; CTxDestination address; if (ExtractDestination(wtx.vout[0].scriptPubKey, address)) { // Sent to csocoin Address sub.address = CBitcoinAddress(address).ToString(); } else { // Sent to IP, or other non-address transaction like OP_EVAL sub.address = mapValue["to"]; } } else { for (unsigned int nOut = 0; nOut < wtx.vout.size(); nOut++) { const CTxOut& txout = wtx.vout[nOut]; sub.idx = parts.size(); if (wallet->IsCollateralAmount(txout.nValue)) sub.type = TransactionRecord::ObfuscationMakeCollaterals; if (wallet->IsDenominatedAmount(txout.nValue)) sub.type = TransactionRecord::ObfuscationCreateDenominations; if (nDebit - wtx.GetValueOut() == OBFUSCATION_COLLATERAL) sub.type = TransactionRecord::ObfuscationCollateralPayment; } } CAmount nChange = wtx.GetChange(); sub.debit = -(nDebit - nChange); sub.credit = nCredit - nChange; parts.append(sub); parts.last().involvesWatchAddress = involvesWatchAddress; // maybe pass to TransactionRecord as constructor argument } else if (fAllFromMe) { // // Debit // CAmount nTxFee = nDebit - wtx.GetValueOut(); for (unsigned int nOut = 0; nOut < wtx.vout.size(); nOut++) { const CTxOut& txout = wtx.vout[nOut]; TransactionRecord sub(hash, nTime); sub.idx = parts.size(); sub.involvesWatchAddress = involvesWatchAddress; if (wallet->IsMine(txout)) { // Ignore parts sent to self, as this is usually the change // from a transaction sent back to our own address. continue; } CTxDestination address; if (ExtractDestination(txout.scriptPubKey, address)) { // Sent to csocoin Address sub.type = TransactionRecord::SendToAddress; sub.address = CBitcoinAddress(address).ToString(); } else { // Sent to IP, or other non-address transaction like OP_EVAL sub.type = TransactionRecord::SendToOther; sub.address = mapValue["to"]; } if (mapValue["DS"] == "1") { sub.type = TransactionRecord::Obfuscated; } CAmount nValue = txout.nValue; /* Add fee to first output */ if (nTxFee > 0) { nValue += nTxFee; nTxFee = 0; } sub.debit = -nValue; parts.append(sub); } } else { // // Mixed debit transaction, can't break down payees // parts.append(TransactionRecord(hash, nTime, TransactionRecord::Other, "", nNet, 0)); parts.last().involvesWatchAddress = involvesWatchAddress; } } return parts; } void TransactionRecord::updateStatus(const CWalletTx& wtx) { AssertLockHeld(cs_main); // Determine transaction status // Find the block the tx is in CBlockIndex* pindex = NULL; BlockMap::iterator mi = mapBlockIndex.find(wtx.hashBlock); if (mi != mapBlockIndex.end()) pindex = (*mi).second; int CurrentBlock = (int)chainActive.Height(); // Sort order, unrecorded transactions sort to the top status.sortKey = strprintf("%010d-%01d-%010u-%03d", (pindex ? pindex->nHeight : std::numeric_limits<int>::max()), (wtx.IsCoinBase() ? 1 : 0), wtx.nTimeReceived, idx); status.countsForBalance = wtx.IsTrusted() && !(wtx.GetBlocksToMaturity() > 0); status.depth = wtx.GetDepthInMainChain(); status.cur_num_blocks = CurrentBlock; status.cur_num_ix_locks = nCompleteTXLocks; if (!IsFinalTx(wtx, CurrentBlock + 1)) { if (wtx.nLockTime < LOCKTIME_THRESHOLD) { status.status = TransactionStatus::OpenUntilBlock; status.open_for = wtx.nLockTime - CurrentBlock; } else { status.status = TransactionStatus::OpenUntilDate; status.open_for = wtx.nLockTime; } } // For generated transactions, determine maturity else if (type == TransactionRecord::Generated || type == TransactionRecord::StakeMint || type == TransactionRecord::MNReward) { if (wtx.GetBlocksToMaturity() > 0) { status.status = TransactionStatus::Immature; if (wtx.IsInMainChain()) { status.matures_in = wtx.GetBlocksToMaturity(); // Check if the block was requested by anyone if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0) status.status = TransactionStatus::MaturesWarning; } else { status.status = TransactionStatus::NotAccepted; } } else { status.status = TransactionStatus::Confirmed; } } else { if (status.depth < 0) { status.status = TransactionStatus::Conflicted; } else if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0) { status.status = TransactionStatus::Offline; } else if (status.depth == 0) { status.status = TransactionStatus::Unconfirmed; } else if (status.depth < RecommendedNumConfirmations) { status.status = TransactionStatus::Confirming; } else { status.status = TransactionStatus::Confirmed; } } } bool TransactionRecord::statusUpdateNeeded() { AssertLockHeld(cs_main); return status.cur_num_blocks != chainActive.Height() || status.cur_num_ix_locks != nCompleteTXLocks; } QString TransactionRecord::getTxID() const { return QString::fromStdString(hash.ToString()); } int TransactionRecord::getOutputIndex() const { return idx; }
// Copyright 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "ui/ozone/platform/wayland/wayland_native_display_delegate.h" #include "ui/display/types/display_snapshot.h" #include "ui/display/types/native_display_observer.h" #include "ui/ozone/platform/wayland/wayland_connection.h" namespace ui { WaylandNativeDisplayDelegate::WaylandNativeDisplayDelegate( WaylandConnection* connection) : connection_(connection) {} WaylandNativeDisplayDelegate::~WaylandNativeDisplayDelegate() { connection_->PrimaryOutput()->SetObserver(nullptr); } void WaylandNativeDisplayDelegate::Initialize() { // TODO(msisov): Add support for secondary output. WaylandOutput* primary_output = connection_->PrimaryOutput(); if (!primary_output) NOTREACHED() << "Asynchronous display data fetching is not available"; primary_output->SetObserver(this); } void WaylandNativeDisplayDelegate::TakeDisplayControl( display::DisplayControlCallback callback) { NOTREACHED(); } void WaylandNativeDisplayDelegate::RelinquishDisplayControl( display::DisplayControlCallback callback) { NOTREACHED(); } void WaylandNativeDisplayDelegate::GetDisplays( display::GetDisplaysCallback callback) { if (displays_ready_) connection_->PrimaryOutput()->GetDisplaysSnapshot(std::move(callback)); } void WaylandNativeDisplayDelegate::Configure( const display::DisplaySnapshot& output, const display::DisplayMode* mode, const gfx::Point& origin, display::ConfigureCallback callback) { NOTREACHED(); } void WaylandNativeDisplayDelegate::GetHDCPState( const display::DisplaySnapshot& output, display::GetHDCPStateCallback callback) { NOTREACHED(); } void WaylandNativeDisplayDelegate::SetHDCPState( const display::DisplaySnapshot& output, display::HDCPState state, display::SetHDCPStateCallback callback) { NOTREACHED(); } bool WaylandNativeDisplayDelegate::SetColorCorrection( const display::DisplaySnapshot& output, const std::vector<display::GammaRampRGBEntry>& degamma_lut, const std::vector<display::GammaRampRGBEntry>& gamma_lut, const std::vector<float>& correction_matrix) { NOTREACHED(); return false; } void WaylandNativeDisplayDelegate::AddObserver( display::NativeDisplayObserver* observer) { observers_.AddObserver(observer); } void WaylandNativeDisplayDelegate::RemoveObserver( display::NativeDisplayObserver* observer) { observers_.RemoveObserver(observer); } display::FakeDisplayController* WaylandNativeDisplayDelegate::GetFakeDisplayController() { return nullptr; } void WaylandNativeDisplayDelegate::OnOutputReadyForUse() { if (!displays_ready_) displays_ready_ = true; for (display::NativeDisplayObserver& observer : observers_) observer.OnConfigurationChanged(); } } // namespace ui
// Copyright (c) 2012-2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "scriptnum10.h" #include "script/script.h" #include "test/test_gozer.h" #include <boost/test/unit_test.hpp> #include <limits.h> #include <stdint.h> BOOST_FIXTURE_TEST_SUITE(scriptnum_tests, BasicTestingSetup) /** A selection of numbers that do not trigger int64_t overflow * when added/subtracted. */ static const int64_t values[] = { 0, 1, -2, 127, 128, -255, 256, (1LL << 15) - 1, -(1LL << 16), (1LL << 24) - 1, (1LL << 31), 1 - (1LL << 32), 1LL << 40 }; static const int64_t offsets[] = { 1, 0x79, 0x80, 0x81, 0xFF, 0x7FFF, 0x8000, 0xFFFF, 0x10000}; static bool verify(const CScriptNum10& bignum, const CScriptNum& scriptnum) { return bignum.getvch() == scriptnum.getvch() && bignum.getint() == scriptnum.getint(); } static void CheckCreateVch(const int64_t& num) { CScriptNum10 bignum(num); CScriptNum scriptnum(num); BOOST_CHECK(verify(bignum, scriptnum)); std::vector<unsigned char> vch = bignum.getvch(); CScriptNum10 bignum2(bignum.getvch(), false); vch = scriptnum.getvch(); CScriptNum scriptnum2(scriptnum.getvch(), false); BOOST_CHECK(verify(bignum2, scriptnum2)); CScriptNum10 bignum3(scriptnum2.getvch(), false); CScriptNum scriptnum3(bignum2.getvch(), false); BOOST_CHECK(verify(bignum3, scriptnum3)); } static void CheckCreateInt(const int64_t& num) { CScriptNum10 bignum(num); CScriptNum scriptnum(num); BOOST_CHECK(verify(bignum, scriptnum)); BOOST_CHECK(verify(CScriptNum10(bignum.getint()), CScriptNum(scriptnum.getint()))); BOOST_CHECK(verify(CScriptNum10(scriptnum.getint()), CScriptNum(bignum.getint()))); BOOST_CHECK(verify(CScriptNum10(CScriptNum10(scriptnum.getint()).getint()), CScriptNum(CScriptNum(bignum.getint()).getint()))); } static void CheckAdd(const int64_t& num1, const int64_t& num2) { const CScriptNum10 bignum1(num1); const CScriptNum10 bignum2(num2); const CScriptNum scriptnum1(num1); const CScriptNum scriptnum2(num2); CScriptNum10 bignum3(num1); CScriptNum10 bignum4(num1); CScriptNum scriptnum3(num1); CScriptNum scriptnum4(num1); // int64_t overflow is undefined. bool invalid = (((num2 > 0) && (num1 > (std::numeric_limits<int64_t>::max() - num2))) || ((num2 < 0) && (num1 < (std::numeric_limits<int64_t>::min() - num2)))); if (!invalid) { BOOST_CHECK(verify(bignum1 + bignum2, scriptnum1 + scriptnum2)); BOOST_CHECK(verify(bignum1 + bignum2, scriptnum1 + num2)); BOOST_CHECK(verify(bignum1 + bignum2, scriptnum2 + num1)); } } static void CheckNegate(const int64_t& num) { const CScriptNum10 bignum(num); const CScriptNum scriptnum(num); // -INT64_MIN is undefined if (num != std::numeric_limits<int64_t>::min()) BOOST_CHECK(verify(-bignum, -scriptnum)); } static void CheckSubtract(const int64_t& num1, const int64_t& num2) { const CScriptNum10 bignum1(num1); const CScriptNum10 bignum2(num2); const CScriptNum scriptnum1(num1); const CScriptNum scriptnum2(num2); bool invalid = false; // int64_t overflow is undefined. invalid = ((num2 > 0 && num1 < std::numeric_limits<int64_t>::min() + num2) || (num2 < 0 && num1 > std::numeric_limits<int64_t>::max() + num2)); if (!invalid) { BOOST_CHECK(verify(bignum1 - bignum2, scriptnum1 - scriptnum2)); BOOST_CHECK(verify(bignum1 - bignum2, scriptnum1 - num2)); } invalid = ((num1 > 0 && num2 < std::numeric_limits<int64_t>::min() + num1) || (num1 < 0 && num2 > std::numeric_limits<int64_t>::max() + num1)); if (!invalid) { BOOST_CHECK(verify(bignum2 - bignum1, scriptnum2 - scriptnum1)); BOOST_CHECK(verify(bignum2 - bignum1, scriptnum2 - num1)); } } static void CheckCompare(const int64_t& num1, const int64_t& num2) { const CScriptNum10 bignum1(num1); const CScriptNum10 bignum2(num2); const CScriptNum scriptnum1(num1); const CScriptNum scriptnum2(num2); BOOST_CHECK((bignum1 == bignum1) == (scriptnum1 == scriptnum1)); BOOST_CHECK((bignum1 != bignum1) == (scriptnum1 != scriptnum1)); BOOST_CHECK((bignum1 < bignum1) == (scriptnum1 < scriptnum1)); BOOST_CHECK((bignum1 > bignum1) == (scriptnum1 > scriptnum1)); BOOST_CHECK((bignum1 >= bignum1) == (scriptnum1 >= scriptnum1)); BOOST_CHECK((bignum1 <= bignum1) == (scriptnum1 <= scriptnum1)); BOOST_CHECK((bignum1 == bignum1) == (scriptnum1 == num1)); BOOST_CHECK((bignum1 != bignum1) == (scriptnum1 != num1)); BOOST_CHECK((bignum1 < bignum1) == (scriptnum1 < num1)); BOOST_CHECK((bignum1 > bignum1) == (scriptnum1 > num1)); BOOST_CHECK((bignum1 >= bignum1) == (scriptnum1 >= num1)); BOOST_CHECK((bignum1 <= bignum1) == (scriptnum1 <= num1)); BOOST_CHECK((bignum1 == bignum2) == (scriptnum1 == scriptnum2)); BOOST_CHECK((bignum1 != bignum2) == (scriptnum1 != scriptnum2)); BOOST_CHECK((bignum1 < bignum2) == (scriptnum1 < scriptnum2)); BOOST_CHECK((bignum1 > bignum2) == (scriptnum1 > scriptnum2)); BOOST_CHECK((bignum1 >= bignum2) == (scriptnum1 >= scriptnum2)); BOOST_CHECK((bignum1 <= bignum2) == (scriptnum1 <= scriptnum2)); BOOST_CHECK((bignum1 == bignum2) == (scriptnum1 == num2)); BOOST_CHECK((bignum1 != bignum2) == (scriptnum1 != num2)); BOOST_CHECK((bignum1 < bignum2) == (scriptnum1 < num2)); BOOST_CHECK((bignum1 > bignum2) == (scriptnum1 > num2)); BOOST_CHECK((bignum1 >= bignum2) == (scriptnum1 >= num2)); BOOST_CHECK((bignum1 <= bignum2) == (scriptnum1 <= num2)); } static void RunCreate(const int64_t& num) { CheckCreateInt(num); CScriptNum scriptnum(num); if (scriptnum.getvch().size() <= CScriptNum::nDefaultMaxNumSize) CheckCreateVch(num); else { BOOST_CHECK_THROW (CheckCreateVch(num), scriptnum10_error); } } static void RunOperators(const int64_t& num1, const int64_t& num2) { CheckAdd(num1, num2); CheckSubtract(num1, num2); CheckNegate(num1); CheckCompare(num1, num2); } BOOST_AUTO_TEST_CASE(creation) { for(size_t i = 0; i < sizeof(values) / sizeof(values[0]); ++i) { for(size_t j = 0; j < sizeof(offsets) / sizeof(offsets[0]); ++j) { RunCreate(values[i]); RunCreate(values[i] + offsets[j]); RunCreate(values[i] - offsets[j]); } } } BOOST_AUTO_TEST_CASE(operators) { for(size_t i = 0; i < sizeof(values) / sizeof(values[0]); ++i) { for(size_t j = 0; j < sizeof(offsets) / sizeof(offsets[0]); ++j) { RunOperators(values[i], values[i]); RunOperators(values[i], -values[i]); RunOperators(values[i], values[j]); RunOperators(values[i], -values[j]); RunOperators(values[i] + values[j], values[j]); RunOperators(values[i] + values[j], -values[j]); RunOperators(values[i] - values[j], values[j]); RunOperators(values[i] - values[j], -values[j]); RunOperators(values[i] + values[j], values[i] + values[j]); RunOperators(values[i] + values[j], values[i] - values[j]); RunOperators(values[i] - values[j], values[i] + values[j]); RunOperators(values[i] - values[j], values[i] - values[j]); } } } BOOST_AUTO_TEST_SUITE_END()
/* This file is part of Corrade. Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Vladimír Vondruš <mosra@centrum.cz> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "File.h" #include <cstddef> #include <utility> #ifdef _MSC_VER #include <algorithm> /* std::max() */ #endif #include "Corrade/TestSuite/Comparator.h" #include "Corrade/Utility/DebugStl.h" #include "Corrade/Utility/Directory.h" namespace Corrade { namespace TestSuite { #ifndef DOXYGEN_GENERATING_OUTPUT Comparator<Compare::File>::Comparator(std::string pathPrefix): _actualState{State::ReadError}, _expectedState{State::ReadError}, _pathPrefix{std::move(pathPrefix)} {} ComparisonStatusFlags Comparator<Compare::File>::operator()(const std::string& actualFilename, const std::string& expectedFilename) { _actualFilename = Utility::Directory::join(_pathPrefix, actualFilename); _expectedFilename = Utility::Directory::join(_pathPrefix, expectedFilename); if(!Utility::Directory::exists(_actualFilename)) return ComparisonStatusFlag::Failed; _actualState = State::Success; /* Read the actual file contents before the expected so if the expected file can't be read, we can still save actual file contents */ _actualContents = Utility::Directory::readString(_actualFilename); /* If this fails, we already have the actual contents so we can save them */ if(!Utility::Directory::exists(_expectedFilename)) return ComparisonStatusFlag::Diagnostic|ComparisonStatusFlag::Failed; _expectedContents = Utility::Directory::readString(_expectedFilename); _expectedState = State::Success; return _actualContents == _expectedContents ? ComparisonStatusFlags{} : ComparisonStatusFlag::Diagnostic|ComparisonStatusFlag::Failed; } void Comparator<Compare::File>::printMessage(ComparisonStatusFlags, Utility::Debug& out, const char* actual, const char* expected) const { if(_actualState != State::Success) { out << "Actual file" << actual << "(" + _actualFilename + ")" << "cannot be read."; return; } if(_expectedState != State::Success) { out << "Expected file" << expected << "(" + _expectedFilename + ")" << "cannot be read."; return; } out << "Files" << actual << "and" << expected << "have different"; if(_actualContents.size() != _expectedContents.size()) out << "size, actual" << _actualContents.size() << "but" << _expectedContents.size() << "expected."; else out << "contents."; for(std::size_t i = 0, end = std::max(_actualContents.size(), _expectedContents.size()); i != end; ++i) { if(_actualContents.size() > i && _expectedContents.size() > i && _actualContents[i] == _expectedContents[i]) continue; /** @todo do this without std::string */ if(_actualContents.size() <= i) out << "Expected has character" << std::string() + _expectedContents[i]; else if(_expectedContents.size() <= i) out << "Actual has character" << std::string() + _actualContents[i]; else out << "Actual character" << std::string() + _actualContents[i] << "but" << std::string() + _expectedContents[i] << "expected"; out << "on position" << i << Utility::Debug::nospace << "."; break; } } void Comparator<Compare::File>::saveDiagnostic(ComparisonStatusFlags, Utility::Debug& out, const std::string& path) { std::string filename = Utility::Directory::join(path, Utility::Directory::filename(_expectedFilename)); if(Utility::Directory::writeString(filename, _actualContents)) out << "->" << filename; } #endif namespace Compare { File::File(const std::string& pathPrefix): _c{pathPrefix} {} #ifndef DOXYGEN_GENERATING_OUTPUT Comparator<File> File::comparator() { return _c; } #endif } }}