file_name
stringlengths
3
137
prefix
stringlengths
0
918k
suffix
stringlengths
0
962k
middle
stringlengths
0
812k
bs.js
/*
CKEDITOR.plugins.setLang( 'showblocks', 'bs', { toolbar: 'Show Blocks' // MISSING } );
Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license */
users.server.routes.js
'use strict'; /** * Module dependencies. */ var passport = require('passport'); module.exports = function(app) { // User Routes var users = require('../../app/controllers/users'); // Setting up the users profile api app.route('/users/me').get(users.me); app.route('/users').put(users.update); // Setting up the public profile api //app.route('/profile').get(users.me); app.route('/users/list').get(users.listUsers); app.route('/users/:userId').get(users.profileRead); // Setting up the users password api app.route('/users/password').post(users.changePassword); app.route('/auth/forgot').post(users.forgot); app.route('/auth/reset/:token').get(users.validateResetToken); app.route('/auth/reset/:token').post(users.reset); // Setting up the users authentication api app.route('/auth/signup').post(users.signup); app.route('/auth/signin').post(users.signin); app.route('/auth/signout').get(users.signout); // Finish by binding the user middleware app.param('userId', users.safeUserByID); };
convert.go
package main import ( "bytes" "errors" "flag" "fmt" "go/ast" "go/parser" "go/token" "io" "os" "sort" "strings" "golang.org/x/tools/go/packages" ) type StructType struct { FullName string Name string Pkg *packages.Package Content map[string]string } type Convert struct { from *StructType to *StructType pkg *packages.Package } var raw = []string{"int8", "int16", "int32", "int", "int64"} var ( from = flag.String("from", "", "input from") to = flag.String("to", "", "input to") ) func main() { flag.Parse() if from == nil || to == nil { os.Exit(1) } cfg := &packages.Config{ Mode: packages.LoadAllSyntax, Tests: true, } pkg, _ := packages.Load(cfg) locationPkg := pkg[0] allPkgs := listAllPkgs(pkg[0]) convert := Convert{pkg: locationPkg} if convert.from = buildStructType(locationPkg, allPkgs, *from); convert.from == nil { fmt.Println("build from struct fail") return } if convert.to = buildStructType(locationPkg, allPkgs, *to); convert.to == nil { fmt.Println("build to struct fail") return } if convert.write() == nil { fmt.Println("ok!") } else { fmt.Println("sorry, an error has occured!") } } func buildStructType(locationPkg *packages.Package, allPkgs map[string]*packages.Package, filed string) *StructType { result := &StructType{FullName: filed} if s := strings.Index(filed, "."); s > 0 { result.Name = filed[s+1:] if result.Pkg = allPkgs[filed[:s]]; result.Pkg == nil { return nil } } else { result.Name = filed result.Pkg = locationPkg } res := findAllFieldsFromPkg(result.Pkg) if result.Content = res[result.Name]; result.Content == nil { return nil } return result } func indexOf(ss []string, s string) int { for i, v := range ss { if v == s { return i } } return -1 } func stringfySingle(name string, fromType, toType string) string { if fromType == toType { return fmt.Sprintf("\tto.%v = from.%v\n", name, name) } if "*"+fromType == toType { return fmt.Sprintf("\tto.%v = &from.%v\n", name, name) } if fromType == "*"+toType { result := fmt.Sprintf("\tif from.%v != nil {\n", name) result += fmt.Sprintf("\t\tto.%v = *from.%v\n", name, name) result += "\t}\n" return result } // 判断能不能转换 fromIdx := indexOf(raw, strings.ReplaceAll(fromType, "*", "")) toIdx := indexOf(raw, strings.ReplaceAll(toType, "*", "")) if fromIdx >= 0 && toIdx >= 0 { result := "" if fromIdx > toIdx { result += fmt.Sprintf("\t// %v -> %v\n", fromType, toType) } if !strings.HasPrefix(fromType, "*") && !strings.HasPrefix(toType, "*") { // i -> i result += fmt.Sprintf("\tto.%v = %v(from.%v)\n", name, toType, name) } else if strings.HasPrefix(fromType, "*") && !strings.HasPrefix(toType, "*") { // *i -> i result += fmt.Sprintf("\tif from.%v != nil {\n", name) result += fmt.Sprintf("\t\tto.%v = %v(*from.%v)\n", name, toType, name) result += "\t}\n" } else if !strings.HasPrefix(fromType, "*") && strings.HasPrefix(toType, "*") { // i -> *i tempName := lowwer(name) + "Temp" result += fmt.Sprintf("\t%v := %v(from.%v)\n", tempName, toType[1:], name) result += fmt.Sprintf("\tto.%v = &%v\n", name, tempName) } else if strings.HasPrefix(fromType, "*") && strings.HasPrefix(toType, "*") { // *i -> *i tempName := lowwer(name) + "Temp" result += fmt.Sprintf("\tif from.%v != nil {\n", name) result += fmt.Sprintf("\t\t%v := %v(*from.%v)\n", tempName, toType[1:], name) result += fmt.Sprintf("\t\tto.%v = &%v\n", name, tempName) result += "\t}\n" } return result } return "" } func (c *Convert) write() error { functionName := fmt.Sprintf("Convert%v%vTo%v%v", capitalize(c.from.Pkg.Name), c.from.Name, capitalize(c.to.Pkg.Name), c.to.Name) functionContent := fmt.Sprintf("func %v(from *%v) *%v {\n", functionName, c.from.FullName, c.to.FullName) functionContent += "\tif from == nil {\n\t\treturn nil\n\t}\n" functionContent += fmt.Sprintf("\tto := &%v{}\n", c.to.FullName) var names []string for name := range c.from.Content { if _, ok := c.to.Content[name]; ok { names = append(names, name) } } sort.Strings(names) for _, name := range names { functionContent += stringfySingle(name, c.from.Content[name], c.to.Content[name]) } functionContent += "\treturn to\n}" convertFile, err := os.OpenFile("convert.go", os.O_RDWR, os.ModeAppend) if pathErr := (*os.PathError)(nil); errors.As(err, &pathErr) { convertFile, _ = os.Create("convert.go") } content, _ := io.ReadAll(convertFile) defer convertFile.Close() buf := bytes.Buffer{} f, _ := parser.ParseFile(token.NewFileSet(), "", content, 0) if len(content) == 0 || f == nil { buf.WriteString(fmt.Sprintf("package %v\n\n", c.pkg.Name)) buf.WriteString(fmt.Sprintf("import (\n\t\"%v\"\n", c.from.Pkg.PkgPath)) if c.from.Pkg.PkgPath != c.to.Pkg.PkgPath { buf.WriteString(fmt.Sprintf("\t\"%v\"\n", c.to.Pkg.PkgPath)) } buf.WriteString(")\n\n") buf.WriteString(functionContent) } else { for _, decl := range f.Decls { if v, ok := decl.(*ast.FuncDecl); ok && v.Name.Name == functionName { buf.Write(content[:v.Pos()-1]) buf.WriteString(functionContent) buf.Write(content[v.End()-1:]) break } } if buf.Len() == 0 { buf.Write(content) buf.WriteString("\n\n") buf.WriteString(functionContent) } } convertFile.Seek(0, 0) _, err = convertFile.Write(buf.Bytes()) return err } func findAllFieldsFromPkg(pkg *packages.Package) (fields map[string]map[string]string) { fields = make(map[string]map[string]string) for _, goFile := range pkg.GoFiles { rawFile, _ := os.Open(goFile) content, _ := io.ReadAll(rawFile) f, _ := parser.ParseFile(token.NewFileSet(), "", content, 0) for _, v := range f.Decls { if g, ok := v.(*ast.GenDecl); ok && g.Tok == token.TYPE { for _, v := range g.Specs { if typeSpec, ok := v.(*ast.TypeSpec); ok { if structType, ok := typeSpec.Type.(*ast.StructType); ok { fields[typeSpec.Name.Name] = make(map[string]string) for _, field := range structType.Fields.List { if len(field.Names) > 0 { if starExpr, ok := field.Type.(*ast.StarExpr); ok { if identType, ok := (starExpr.X).(*ast.Ident); ok { fields[typeSpec.Name.Name][field.Names[0].Name] = "*" + identType.Name } } else if identType, ok := (field.Type).(*ast.Ident); ok { fields[typeSpec.Name.Name][field.Names[0].Name] = identType.Name } } } } } } } } } return } func listAllPkgs(pkg *packages.Package) map[string]*packages.Package { result := make(map[string]*packages.Package) for _, value := range pkg.Imports { result[value.Name] = value } return result }
func capitalize(str string) string { r := []rune(str) if r[0] >= 97 && r[0] <= 122 { r[0] -= 32 } return string(r) } func lowwer(str string) string { r := []rune(str) if r[0] >= 65 && r[0] <= 90 { r[0] += 32 } return string(r) }
Header.js
import React, {useState} from 'react'; import Navigation from './Navigation'; import About from '../pages/About.js'; import Projects from '../pages/Projects.js'; import Contact from '../pages/Contact.js'; import Resume from '../pages/Resume.js'; function Header() { const [currentPage, setCurrentPage] = useState("About"); function renderPage() { switch(currentPage) { default: return <About /> case "Projects": return <Projects/>; case "Contact": return <Contact/>; case "Resume": return <Resume/>
} return ( <div> <div className="header-div"> <h1 className="header-h1 nav-li">Priti Patel</h1> <Navigation currentPage={currentPage} setCurrentPage={setCurrentPage} /> </div> {renderPage(currentPage)} </div> ) } export default Header; //function Header() { //return ( // <header> //<h1><a href="./index.html">Priti Patel</a></h1> // <nav> // <ul> // <li> //<a href="#About-Me">About Me</a> // </li> // <li> // <a href="#Work">Work</a> // </li> // <li> // <a href="#Contact-Me">Contact Me</a> // </li> // <li> // <a href={resume}>Resume</a> // </li> // </ul> //</nav> // </header> // ) //} //export default Header;
}
test_files.py
from conda_verify.conda_package_check import CondaPackageCheck
package_check.not_allowed_files() package_check.index_json() package_check.no_bat_and_exe() package_check.list_packages() pedantic = kwargs.get("pedantic") if "pedantic" in kwargs.keys() else True package_check.has_prefix(pedantic=pedantic) package_check.t.close()
def verify(path_to_package=None, verbose=True, **kwargs): package_check = CondaPackageCheck(path_to_package, verbose) package_check.info_files() package_check.no_hardlinks()
home.js
$(document).ready(function(){function
(){1==s?(o.removeClass("is-closed"),o.addClass("is-open"),s=!1):(o.removeClass("is-open"),o.addClass("is-closed"),s=!0)}document.getElementById("intro").style.height=window.innerHeight-20+"px",$(".loader-overlay").hide();var n=new WOW({boxClass:"wow",animateClass:"animated",offset:20,mobile:!0,live:!0});n.init();var i=$("#js-mobile-menu").unbind();$("#js-navigation-menu").removeClass("show"),i.on("click",function(e){e.preventDefault();var n=$("#js-navigation-menu");n.slideToggle(function(){n.is(":hidden")&&n.removeAttr("style")})});var o=$("#hamburger"),s=!0;o.click(function(){e()});var t=function(){var e=0,n=$(".evenHeights");n.each(function(){var n=$(this);n.height()>e&&(e=n.height())}),n.height(e)};t()}); //$(document).ready(function () { // // document.getElementById("intro").style.height = (window.innerHeight-20)+'px'; // // $('.loader-overlay').hide(); // // var wow = new WOW({boxClass: 'wow', animateClass: 'animated', offset: 20, mobile: true, live: true}); // wow.init(); // // var menuToggle = $('#js-mobile-menu').unbind(); // $('#js-navigation-menu').removeClass("show"); // menuToggle.on('click', function (e) { // e.preventDefault(); // var $navigationMenu = $('#js-navigation-menu'); // $navigationMenu.slideToggle(function () { // if ($navigationMenu.is(':hidden')) { // $navigationMenu.removeAttr('style'); // } // }); // }); // // var trigger = $('#hamburger'), // isClosed = true; // // function burgerTime() { // if (isClosed == true) { // trigger.removeClass('is-closed'); // trigger.addClass('is-open'); // isClosed = false; // } else { // trigger.removeClass('is-open'); // trigger.addClass('is-closed'); // isClosed = true; // } // } // // // trigger.click(function () { // burgerTime(); // }); // // // // // var setEvenHeights = function () { // var maxHeight = 0; // var $evenHeightElements = $('.evenHeights'); // $evenHeightElements.each(function (index) { // var $el = $(this); // if ($el.height() > maxHeight) { // maxHeight = $el.height(); // } // }); // $evenHeightElements.height(maxHeight); // }; // setEvenHeights(); //});
e
lib.rs
#[macro_use] mod macros; mod call_info; mod maybe_owned; mod plugin; mod return_value; mod signature; mod syntax_shape; mod type_name; mod type_shape; mod value; pub use crate::call_info::{CallInfo, EvaluatedArgs}; pub use crate::maybe_owned::MaybeOwned; pub use crate::plugin::{serve_plugin, Plugin}; pub use crate::return_value::{CommandAction, ReturnSuccess, ReturnValue}; pub use crate::signature::{NamedType, PositionalType, Signature};
pub use crate::syntax_shape::SyntaxShape; pub use crate::type_name::{PrettyType, ShellTypeName, SpannedTypeName}; pub use crate::type_shape::{Row as RowType, Type}; pub use crate::value::column_path::{did_you_mean, ColumnPath, PathMember, UnspannedPathMember}; pub use crate::value::dict::{Dictionary, TaggedDictBuilder}; pub use crate::value::evaluate::{Evaluate, EvaluateTrait, Scope}; pub use crate::value::primitive::format_primitive; pub use crate::value::primitive::Primitive; pub use crate::value::range::{Range, RangeInclusion}; pub use crate::value::{UntaggedValue, Value};
lib.rs
// Copyright 2019 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use { fidl_fuchsia_sys2 as fsys, std::collections::{HashMap, HashSet}, std::error, std::fmt, thiserror::Error, }; const MAX_PATH_LENGTH: usize = 1024; const MAX_NAME_LENGTH: usize = 100; const MAX_URL_LENGTH: usize = 4096; /// Enum type that can represent any error encountered durlng validation. #[derive(Debug, Error)] pub enum Error { #[error("{} missing {}", .0.decl, .0.field)] MissingField(DeclField), #[error("{} has empty {}", .0.decl, .0.field)] EmptyField(DeclField), #[error("{} has extraneous {}", .0.decl, .0.field)] ExtraneousField(DeclField), #[error("\"{1}\" is a duplicate {} {}", .0.decl, .0.field)] DuplicateField(DeclField, String), #[error("{} has invalid {}", .0.decl, .0.field)] InvalidField(DeclField), #[error("{} has invalid {}, unexpected character '{1}'", .0.decl, .0.field)] InvalidCharacterInField(DeclField, char), #[error("{}'s {} is too long", .0.decl, .0.field)] FieldTooLong(DeclField), #[error("\"{0}\" target \"{1}\" is same as source")] OfferTargetEqualsSource(String, String), #[error("\"{1}\" is referenced in {0} but it does not appear in children")] InvalidChild(DeclField, String), #[error("\"{1}\" is referenced in {0} but it does not appear in collections")] InvalidCollection(DeclField, String), #[error("\"{1}\" is referenced in {0} but it does not appear in storage")] InvalidStorage(DeclField, String), #[error("\"{1}\" is referenced in {0} but it does not appear in environments")] InvalidEnvironment(DeclField, String), #[error("\"{1}\" is referenced in {0} but it does not appear in resolvers")] InvalidResolver(DeclField, String), #[error("{0} specifies multiple runners")] MultipleRunnersSpecified(String), #[error("cycle detected between {0} (\"{1}\") and {2} (\"{3}\")")] CycleDetected(DeclField, String, DeclField, String), } impl Error { pub fn missing_field(decl_type: impl Into<String>, keyword: impl Into<String>) -> Self { Error::MissingField(DeclField { decl: decl_type.into(), field: keyword.into() }) } pub fn empty_field(decl_type: impl Into<String>, keyword: impl Into<String>) -> Self { Error::EmptyField(DeclField { decl: decl_type.into(), field: keyword.into() }) } pub fn extraneous_field(decl_type: impl Into<String>, keyword: impl Into<String>) -> Self { Error::ExtraneousField(DeclField { decl: decl_type.into(), field: keyword.into() }) } pub fn duplicate_field( decl_type: impl Into<String>, keyword: impl Into<String>, value: impl Into<String>, ) -> Self { Error::DuplicateField( DeclField { decl: decl_type.into(), field: keyword.into() }, value.into(), ) } pub fn invalid_field(decl_type: impl Into<String>, keyword: impl Into<String>) -> Self { Error::InvalidField(DeclField { decl: decl_type.into(), field: keyword.into() }) } pub fn invalid_character_in_field( decl_type: impl Into<String>, keyword: impl Into<String>, character: char, ) -> Self { Error::InvalidCharacterInField( DeclField { decl: decl_type.into(), field: keyword.into() }, character, ) } pub fn field_too_long(decl_type: impl Into<String>, keyword: impl Into<String>) -> Self { Error::FieldTooLong(DeclField { decl: decl_type.into(), field: keyword.into() }) } pub fn offer_target_equals_source(decl: impl Into<String>, target: impl Into<String>) -> Self { Error::OfferTargetEqualsSource(decl.into(), target.into()) } pub fn invalid_child( decl_type: impl Into<String>, keyword: impl Into<String>, child: impl Into<String>, ) -> Self { Error::InvalidChild( DeclField { decl: decl_type.into(), field: keyword.into() }, child.into(), ) } pub fn invalid_collection( decl_type: impl Into<String>, keyword: impl Into<String>, collection: impl Into<String>, ) -> Self { Error::InvalidCollection( DeclField { decl: decl_type.into(), field: keyword.into() }, collection.into(), ) } pub fn invalid_storage( decl_type: impl Into<String>, keyword: impl Into<String>, storage: impl Into<String>, ) -> Self { Error::InvalidStorage( DeclField { decl: decl_type.into(), field: keyword.into() }, storage.into(), ) } pub fn invalid_environment( decl_type: impl Into<String>, keyword: impl Into<String>, environment: impl Into<String>, ) -> Self { Error::InvalidEnvironment( DeclField { decl: decl_type.into(), field: keyword.into() }, environment.into(), ) } pub fn invalid_resolver( decl_type: impl Into<String>, keyword: impl Into<String>, resolver: impl Into<String>, ) -> Self { Error::InvalidResolver( DeclField { decl: decl_type.into(), field: keyword.into() }, resolver.into(), ) } pub fn multiple_runners_specified(decl_type: impl Into<String>) -> Self { Error::MultipleRunnersSpecified(decl_type.into()) } pub fn cycle_detected( decl_type1: impl Into<String>, keyword1: impl Into<String>, value1: impl Into<String>, decl_type2: impl Into<String>, keyword2: impl Into<String>, value2: impl Into<String>, ) -> Self { Error::CycleDetected( DeclField { decl: decl_type1.into(), field: keyword1.into() }, value1.into(), DeclField { decl: decl_type2.into(), field: keyword2.into() }, value2.into(), ) } } #[derive(Debug)] pub struct DeclField { pub decl: String, pub field: String, } impl fmt::Display for DeclField { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}.{}", &self.decl, &self.field) } } /// Represents a list of errors encountered durlng validation. #[derive(Debug)] pub struct ErrorList { errs: Vec<Error>, } impl ErrorList { fn new(errs: Vec<Error>) -> ErrorList { ErrorList { errs } } } impl error::Error for ErrorList {} impl fmt::Display for ErrorList { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let strs: Vec<String> = self.errs.iter().map(|e| format!("{}", e)).collect(); write!(f, "{}", strs.join(", ")) } } /// Validates a ComponentDecl. /// /// The ComponentDecl may ultimately originate from a CM file, or be directly constructed by the /// caller. Either way, a ComponentDecl should always be validated before it's used. Examples /// of what is validated (which may evolve in the future): /// /// - That all semantically required fields are present /// - That a child_name referenced in a source actually exists in the list of children /// - That there are no duplicate target paths. /// - That a cap is not offered back to the child that exposed it. /// /// All checks are local to this ComponentDecl. pub fn validate(decl: &fsys::ComponentDecl) -> Result<(), ErrorList> { let ctx = ValidationContext { decl, all_children: HashMap::new(), all_collections: HashSet::new(), all_storage_and_sources: HashMap::new(), all_runners_and_sources: HashMap::new(), all_resolvers: HashSet::new(), all_environment_names: HashSet::new(), target_paths: HashMap::new(), offered_runner_names: HashMap::new(), offered_resolver_names: HashMap::new(), offered_event_names: HashMap::new(), errors: vec![], }; ctx.validate().map_err(|errs| ErrorList::new(errs)) } /// Validates an independent ChildDecl. Performs the same validation on it as `validate`. pub fn validate_child(child: &fsys::ChildDecl) -> Result<(), ErrorList> { let mut errors = vec![]; check_name(child.name.as_ref(), "ChildDecl", "name", &mut errors); check_url(child.url.as_ref(), "ChildDecl", "url", &mut errors); if child.startup.is_none() { errors.push(Error::missing_field("ChildDecl", "startup")); } if child.environment.is_some() { check_name(child.environment.as_ref(), "ChildDecl", "environment", &mut errors); } if errors.is_empty() { Ok(()) } else { Err(ErrorList { errs: errors }) } } struct ValidationContext<'a> { decl: &'a fsys::ComponentDecl, all_children: HashMap<&'a str, &'a fsys::ChildDecl>, all_collections: HashSet<&'a str>, all_storage_and_sources: HashMap<&'a str, Option<&'a str>>, all_runners_and_sources: HashMap<&'a str, Option<&'a str>>, all_resolvers: HashSet<&'a str>, all_environment_names: HashSet<&'a str>, target_paths: PathMap<'a>, offered_runner_names: NameMap<'a>, offered_resolver_names: NameMap<'a>, offered_event_names: NameMap<'a>, errors: Vec<Error>, } #[derive(Clone, Copy, PartialEq)] enum AllowablePaths { One, Many, } #[derive(Debug, PartialEq, Eq, Hash)] enum TargetId<'a> { Component(&'a str), Collection(&'a str), } type PathMap<'a> = HashMap<TargetId<'a>, HashMap<&'a str, AllowablePaths>>; type NameMap<'a> = HashMap<TargetId<'a>, HashSet<&'a str>>; impl<'a> ValidationContext<'a> { fn validate(mut self) -> Result<(), Vec<Error>> { // Collect all environment names first, so that references to them can be checked. if let Some(envs) = &self.decl.environments { self.collect_environment_names(&envs); } // Validate "children" and build the set of all children. if let Some(children) = self.decl.children.as_ref() { for child in children { self.validate_child_decl(&child); } } // Validate "collections" and build the set of all collections. if let Some(collections) = self.decl.collections.as_ref() { for collection in collections { self.validate_collection_decl(&collection); } } // Validate "storage" and build the set of all storage sections. if let Some(storage) = self.decl.storage.as_ref() { for storage in storage { self.validate_storage_decl(&storage); } } // Validate "runners" and build the set of all runners. if let Some(runners) = self.decl.runners.as_ref() { for runner in runners { self.validate_runner_decl(&runner); } } // Validate "resolvers" and build the set of all resolvers. if let Some(resolvers) = self.decl.resolvers.as_ref() { for resolver in resolvers { self.validate_resolver_decl(&resolver); } } // Validate "uses". if let Some(uses) = self.decl.uses.as_ref() { self.validate_use_decls(uses); } // Validate "exposes". if let Some(exposes) = self.decl.exposes.as_ref() { let mut target_paths = HashMap::new(); let mut runner_names = HashSet::new(); let mut resolver_names = HashSet::new(); for expose in exposes.iter() { self.validate_expose_decl( &expose, &mut target_paths, &mut runner_names, &mut resolver_names, ); } } // Validate "offers". if let Some(offers) = self.decl.offers.as_ref() { for offer in offers.iter() { self.validate_offers_decl(&offer); } } // Validate "environments" after all other declarations are processed. if let Some(environment) = self.decl.environments.as_ref() { for environment in environment { self.validate_environment_decl(&environment); } } if self.errors.is_empty() { Ok(()) } else { Err(self.errors) } } // Collects all the environment names, watching for duplicates. fn collect_environment_names(&mut self, envs: &'a [fsys::EnvironmentDecl]) { for env in envs { if let Some(name) = env.name.as_ref() { if !self.all_environment_names.insert(name) { self.errors.push(Error::duplicate_field("EnvironmentDecl", "name", name)); } } } } fn validate_use_decls(&mut self, uses: &[fsys::UseDecl]) { // Validate individual fields. for use_ in uses.iter() { self.validate_use_decl(&use_); } // Ensure that no more than one runner is specified. let mut runners_count: i32 = 0; for use_ in uses.iter() { if let fsys::UseDecl::Runner(_) = use_ { runners_count += 1; } } if runners_count > 1 { self.errors.push(Error::multiple_runners_specified("UseRunnerDecl")); } } fn validate_use_decl(&mut self, use_: &fsys::UseDecl) { match use_ { fsys::UseDecl::Service(u) => { self.validate_use_fields( "UseServiceDecl", u.source.as_ref(), u.source_path.as_ref(), u.target_path.as_ref(), ); } fsys::UseDecl::Protocol(u) => { self.validate_use_fields( "UseProtocolDecl", u.source.as_ref(), u.source_path.as_ref(), u.target_path.as_ref(), ); } fsys::UseDecl::Directory(u) => { self.validate_use_fields( "UseDirectoryDecl", u.source.as_ref(), u.source_path.as_ref(), u.target_path.as_ref(), ); if u.rights.is_none() { self.errors.push(Error::missing_field("UseDirectoryDecl", "rights")); } if let Some(subdir) = u.subdir.as_ref() { check_relative_path( Some(subdir), "UseDirectoryDecl", "subdir", &mut self.errors, ); } } fsys::UseDecl::Storage(u) => match u.type_ { None => self.errors.push(Error::missing_field("UseStorageDecl", "type")), Some(fsys::StorageType::Meta) => { if u.target_path.is_some() { self.errors.push(Error::invalid_field("UseStorageDecl", "target_path")); } } _ => { check_path( u.target_path.as_ref(), "UseStorageDecl", "target_path", &mut self.errors, ); } }, fsys::UseDecl::Runner(r) => { check_name( r.source_name.as_ref(), "UseRunnerDecl", "source_name", &mut self.errors, ); } fsys::UseDecl::Event(e) => { check_name(e.source_name.as_ref(), "UseEventDecl", "source_name", &mut self.errors); check_name(e.target_name.as_ref(), "UseEventDecl", "target_name", &mut self.errors); } fsys::UseDecl::__UnknownVariant { .. } => { self.errors.push(Error::invalid_field("ComponentDecl", "use")); } } } fn validate_use_fields( &mut self, decl: &str, source: Option<&fsys::Ref>, source_path: Option<&String>, target_path: Option<&String>, ) { match source { Some(fsys::Ref::Realm(_)) => {} Some(fsys::Ref::Framework(_)) => {} Some(_) => { self.errors.push(Error::invalid_field(decl, "source")); } None => { self.errors.push(Error::missing_field(decl, "source")); } }; check_path(source_path, decl, "source_path", &mut self.errors); check_path(target_path, decl, "target_path", &mut self.errors); } fn validate_child_decl(&mut self, child: &'a fsys::ChildDecl) { if let Err(mut e) = validate_child(child) { self.errors.append(&mut e.errs); } if let Some(name) = child.name.as_ref() { let name: &str = name; if self.all_children.insert(name, child).is_some() { self.errors.push(Error::duplicate_field("ChildDecl", "name", name)); } } if let Some(environment) = child.environment.as_ref() { if !self.all_environment_names.contains(environment.as_str()) { self.errors.push(Error::invalid_environment( "ChildDecl", "environment", environment, )); } } } fn validate_collection_decl(&mut self, collection: &'a fsys::CollectionDecl) { let name = collection.name.as_ref(); if check_name(name, "CollectionDecl", "name", &mut self.errors) { let name: &str = name.unwrap(); if !self.all_collections.insert(name) { self.errors.push(Error::duplicate_field("CollectionDecl", "name", name)); } } if collection.durability.is_none() { self.errors.push(Error::missing_field("CollectionDecl", "durability")); } } fn validate_environment_decl(&mut self, environment: &'a fsys::EnvironmentDecl) { let name = environment.name.as_ref(); check_name(name, "EnvironmentDecl", "name", &mut self.errors); if environment.extends.is_none() { self.errors.push(Error::missing_field("EnvironmentDecl", "extends")); } if let Some(resolvers) = environment.resolvers.as_ref() { let mut registered_schemes = HashSet::new(); for resolver in resolvers { self.validate_resolver_registration( resolver, name.clone(), &mut registered_schemes, ); } } } fn validate_resolver_registration( &mut self, resolver_registration: &'a fsys::ResolverRegistration, environment_name: Option<&'a String>, schemes: &mut HashSet<&'a str>, ) { check_name( resolver_registration.resolver.as_ref(), "ResolverRegistration", "resolver", &mut self.errors, ); match &resolver_registration.source { Some(fsys::Ref::Realm(_)) => {} Some(fsys::Ref::Child(child_ref)) => { // Make sure the child is valid. if self.validate_child_ref("ResolverRegistration", "source", &child_ref) { // Ensure there are no cycles, eg: // environment is assigned to a child, but the environment contains a resolver // provided by the same child. // TODO(fxb/48128): Replace with cycle detection algorithm using //src/lib/directed_graph. let child_name = child_ref.name.as_str(); if let Some(child_decl) = self.all_children.get(child_name) { match (environment_name, child_decl.environment.as_ref()) { (Some(environment_name), Some(child_environment_name)) if environment_name == child_environment_name => { self.errors.push(Error::cycle_detected( "ResolverRegistration", "source", child_name, "ChildDecl", "environment", child_environment_name, )); } _ => {} } } } } Some(_) => { self.errors.push(Error::invalid_field("ResolverRegistration", "source")); } None => { self.errors.push(Error::missing_field("ResolverRegistration", "source")); } }; check_url_scheme( resolver_registration.scheme.as_ref(), "ResolverRegistration", "scheme", &mut self.errors, ); if let Some(scheme) = resolver_registration.scheme.as_ref() { if !schemes.insert(scheme.as_str()) { self.errors.push(Error::duplicate_field("ResolverRegistration", "scheme", scheme)); } } } fn validate_storage_decl(&mut self, storage: &'a fsys::StorageDecl) { check_path(storage.source_path.as_ref(), "StorageDecl", "source_path", &mut self.errors); let source_child_name = match storage.source.as_ref() { Some(fsys::Ref::Realm(_)) => None, Some(fsys::Ref::Self_(_)) => None, Some(fsys::Ref::Child(child)) => { self.validate_source_child(child, "StorageDecl"); Some(&child.name as &str) } Some(_) => { self.errors.push(Error::invalid_field("StorageDecl", "source")); None } None => { self.errors.push(Error::missing_field("StorageDecl", "source")); None } }; if check_name(storage.name.as_ref(), "StorageDecl", "name", &mut self.errors) { let name = storage.name.as_ref().unwrap(); if self.all_storage_and_sources.insert(name, source_child_name).is_some() { self.errors.push(Error::duplicate_field("StorageDecl", "name", name.as_str())); } } } fn validate_runner_decl(&mut self, runner: &'a fsys::RunnerDecl) { let runner_source = match runner.source.as_ref() { Some(fsys::Ref::Self_(_)) => None, Some(fsys::Ref::Child(child)) => { self.validate_source_child(child, "RunnerDecl"); Some(&child.name as &str) } Some(_) => { self.errors.push(Error::invalid_field("RunnerDecl", "source")); None } None => { self.errors.push(Error::missing_field("RunnerDecl", "source")); None } }; if check_name(runner.name.as_ref(), "RunnerDecl", "name", &mut self.errors) { let name = runner.name.as_ref().unwrap(); if self.all_runners_and_sources.insert(name, runner_source).is_some() { self.errors.push(Error::duplicate_field("RunnerDecl", "name", name.as_str())); } } check_path(runner.source_path.as_ref(), "RunnerDecl", "source_path", &mut self.errors); } fn validate_resolver_decl(&mut self, resolver: &'a fsys::ResolverDecl) { if check_name(resolver.name.as_ref(), "ResolverDecl", "name", &mut self.errors) { let name = resolver.name.as_ref().unwrap(); if !self.all_resolvers.insert(name) { self.errors.push(Error::duplicate_field("ResolverDecl", "name", name.as_str())); } } check_path(resolver.source_path.as_ref(), "ResolverDecl", "source_path", &mut self.errors); } fn validate_source_child(&mut self, child: &fsys::ChildRef, decl_type: &str) { let mut valid = true; valid &= check_name(Some(&child.name), decl_type, "source.child.name", &mut self.errors); valid &= if child.collection.is_some() { self.errors.push(Error::extraneous_field(decl_type, "source.child.collection")); false } else { true }; if !valid { return; } if !self.all_children.contains_key(&child.name as &str) { self.errors.push(Error::invalid_child(decl_type, "source", &child.name as &str)); } } fn validate_storage_source(&mut self, source: &fsys::StorageRef, decl_type: &str) { if check_name(Some(&source.name), decl_type, "source.storage.name", &mut self.errors) { if !self.all_storage_and_sources.contains_key(&source.name as &str) { self.errors.push(Error::invalid_storage(decl_type, "source", &source.name as &str)); } } } fn validate_expose_decl( &mut self, expose: &'a fsys::ExposeDecl, prev_target_paths: &mut HashMap<&'a str, AllowablePaths>, prev_runner_names: &mut HashSet<&'a str>, prev_resolver_names: &mut HashSet<&'a str>, ) { match expose { fsys::ExposeDecl::Service(e) => { self.validate_expose_fields( "ExposeServiceDecl", AllowablePaths::Many, e.source.as_ref(), e.source_path.as_ref(), e.target_path.as_ref(), e.target.as_ref(), prev_target_paths, ); } fsys::ExposeDecl::Protocol(e) => { self.validate_expose_fields( "ExposeProtocolDecl", AllowablePaths::One, e.source.as_ref(), e.source_path.as_ref(), e.target_path.as_ref(), e.target.as_ref(), prev_target_paths, ); } fsys::ExposeDecl::Directory(e) => { self.validate_expose_fields( "ExposeDirectoryDecl", AllowablePaths::One, e.source.as_ref(), e.source_path.as_ref(), e.target_path.as_ref(), e.target.as_ref(), prev_target_paths, ); match e.source.as_ref() { Some(fsys::Ref::Self_(_)) => { if e.rights.is_none() { self.errors.push(Error::missing_field("ExposeDirectoryDecl", "rights")); } } _ => {} } if let Some(subdir) = e.subdir.as_ref() { check_relative_path( Some(subdir), "ExposeDirectoryDecl", "subdir", &mut self.errors, ); } } fsys::ExposeDecl::Runner(e) => { self.validate_expose_runner_fields(e, prev_runner_names); } fsys::ExposeDecl::Resolver(e) => { self.validate_expose_resolver_fields(e, prev_resolver_names); } fsys::ExposeDecl::__UnknownVariant { .. } => { self.errors.push(Error::invalid_field("ComponentDecl", "expose")); } } } fn validate_expose_fields( &mut self, decl: &str, allowable_paths: AllowablePaths, source: Option<&fsys::Ref>, source_path: Option<&String>, target_path: Option<&'a String>, target: Option<&fsys::Ref>, prev_child_target_paths: &mut HashMap<&'a str, AllowablePaths>, ) { match source { Some(r) => match r { fsys::Ref::Self_(_) => {} fsys::Ref::Framework(_) => {} fsys::Ref::Child(child) => { self.validate_source_child(child, decl); } _ => { self.errors.push(Error::invalid_field(decl, "source")); } }, None => { self.errors.push(Error::missing_field(decl, "source")); } } match target { Some(r) => match r { fsys::Ref::Realm(_) => {} fsys::Ref::Framework(_) => {} _ => { self.errors.push(Error::invalid_field(decl, "target")); } }, None => { self.errors.push(Error::missing_field(decl, "target")); } } check_path(source_path, decl, "source_path", &mut self.errors); if check_path(target_path, decl, "target_path", &mut self.errors) { let target_path = target_path.unwrap(); if let Some(prev_state) = prev_child_target_paths.insert(target_path, allowable_paths) { if prev_state == AllowablePaths::One || prev_state != allowable_paths { self.errors.push(Error::duplicate_field(decl, "target_path", target_path)); } } } } /// Validates that the expose source is from `self`, `framework`, or a valid child. fn validate_expose_source( &mut self, source: &Option<fsys::Ref>, decl_type: &str, field_name: &str, ) { match source.as_ref() { Some(fsys::Ref::Self_(_)) | Some(fsys::Ref::Framework(_)) => {} Some(fsys::Ref::Child(child)) => { self.validate_source_child(child, decl_type); } Some(_) => { self.errors.push(Error::invalid_field(decl_type, field_name)); } None => { self.errors.push(Error::missing_field(decl_type, field_name)); } }; } /// Validates that the expose target is to `realm` or `framework`. fn validate_expose_target( &mut self, target: &Option<fsys::Ref>, decl_type: &str, field_name: &str, ) { match target.as_ref() { Some(fsys::Ref::Realm(_)) => {} Some(_) => { self.errors.push(Error::invalid_field(decl_type, field_name)); } None => { self.errors.push(Error::missing_field(decl_type, field_name)); } }; } fn validate_expose_resolver_fields( &mut self, resolver: &'a fsys::ExposeResolverDecl, prev_resolver_names: &mut HashSet<&'a str>, ) { let decl = "ExposeResolverDecl"; self.validate_expose_source(&resolver.source, decl, "source"); self.validate_expose_target(&resolver.target, decl, "target"); check_name(resolver.source_name.as_ref(), decl, "source_name", &mut self.errors); if check_name(resolver.target_name.as_ref(), decl, "target_name", &mut self.errors) { // Ensure that target_name hasn't already been exposed. let target_name = resolver.target_name.as_ref().unwrap(); if !prev_resolver_names.insert(target_name) { self.errors.push(Error::duplicate_field(decl, "target_name", target_name)); } } // If the expose source is `self`, ensure we have a corresponding ResolverDecl. if let (Some(fsys::Ref::Self_(_)), Some(ref name)) = (&resolver.source, &resolver.source_name) { if !self.all_resolvers.contains(name as &str) { self.errors.push(Error::invalid_resolver(decl, "source", name)); } } } fn validate_expose_runner_fields( &mut self, runner: &'a fsys::ExposeRunnerDecl, prev_runner_names: &mut HashSet<&'a str>, ) { let decl = "ExposeRunnerDecl"; self.validate_expose_source(&runner.source, decl, "source"); self.validate_expose_target(&runner.target, decl, "target"); check_name(runner.source_name.as_ref(), decl, "source_name", &mut self.errors); if check_name(runner.target_name.as_ref(), decl, "target_name", &mut self.errors) { // Ensure that target_name hasn't already been exposed. let target_name = runner.target_name.as_ref().unwrap(); if !prev_runner_names.insert(target_name) { self.errors.push(Error::duplicate_field(decl, "target_name", target_name)); } } // If the expose source is `self`, ensure we have a corresponding RunnerDecl. if let (Some(fsys::Ref::Self_(_)), Some(ref name)) = (&runner.source, &runner.source_name) { if !self.all_runners_and_sources.contains_key(&name as &str) { self.errors.push(Error::invalid_field(decl, "source")); } } } fn validate_offers_decl(&mut self, offer: &'a fsys::OfferDecl) { match offer { fsys::OfferDecl::Service(o) => { self.validate_offers_fields( "OfferServiceDecl", AllowablePaths::Many, o.source.as_ref(), o.source_path.as_ref(), o.target.as_ref(), o.target_path.as_ref(), ); } fsys::OfferDecl::Protocol(o) => { self.validate_offers_fields( "OfferProtocolDecl", AllowablePaths::One, o.source.as_ref(), o.source_path.as_ref(), o.target.as_ref(), o.target_path.as_ref(), ); if o.dependency_type.is_none() { self.errors.push(Error::missing_field("OfferProtocolDecl", "dependency_type")); } } fsys::OfferDecl::Directory(o) => { self.validate_offers_fields( "OfferDirectoryDecl", AllowablePaths::One, o.source.as_ref(), o.source_path.as_ref(), o.target.as_ref(), o.target_path.as_ref(), ); if o.dependency_type.is_none() { self.errors.push(Error::missing_field("OfferDirectoryDecl", "dependency_type")); } match o.source.as_ref() { Some(fsys::Ref::Self_(_)) => { if o.rights.is_none() { self.errors.push(Error::missing_field("OfferDirectoryDecl", "rights")); } } _ => {} } if let Some(subdir) = o.subdir.as_ref() { check_relative_path( Some(subdir), "OfferDirectoryDecl", "subdir", &mut self.errors, ); } } fsys::OfferDecl::Storage(o) => { self.validate_storage_offer_fields( "OfferStorageDecl", o.type_.as_ref(), o.source.as_ref(), o.target.as_ref(), ); } fsys::OfferDecl::Runner(o) => { self.validate_runner_offer_fields(o); } fsys::OfferDecl::Resolver(o) => { self.validate_resolver_offer_fields(o); } fsys::OfferDecl::Event(e) => { self.validate_event_offer_fields(e); } fsys::OfferDecl::__UnknownVariant { .. } => { self.errors.push(Error::invalid_field("ComponentDecl", "offer")); } } } /// Validates that the offer source is from `self`, `framework`, `realm`, or a valid child. fn validate_offer_source( &mut self, source: &Option<fsys::Ref>, decl_type: &str, field_name: &str, ) { match source.as_ref() { Some(fsys::Ref::Self_(_)) | Some(fsys::Ref::Framework(_)) | Some(fsys::Ref::Realm(_)) => {} Some(fsys::Ref::Child(child)) => { self.validate_source_child(child, decl_type); } Some(_) => { self.errors.push(Error::invalid_field(decl_type, field_name)); } None => { self.errors.push(Error::missing_field(decl_type, field_name)); } }; } /// Validates that the offer target is to a valid child or collection. fn validate_offer_target( &mut self, target: &'a Option<fsys::Ref>, decl_type: &str, field_name: &str, ) -> Option<TargetId<'a>> { match target.as_ref() { Some(fsys::Ref::Child(child)) => { if self.validate_child_ref(decl_type, field_name, &child) { Some(TargetId::Component(&child.name)) } else { None } } Some(fsys::Ref::Collection(collection)) => { if self.validate_collection_ref(decl_type, field_name, &collection) { Some(TargetId::Collection(&collection.name)) } else { None } } Some(_) => { self.errors.push(Error::invalid_field(decl_type, field_name)); None } None => { self.errors.push(Error::missing_field(decl_type, field_name)); None } } } fn validate_offers_fields( &mut self, decl: &str, allowable_paths: AllowablePaths, source: Option<&fsys::Ref>, source_path: Option<&String>, target: Option<&'a fsys::Ref>, target_path: Option<&'a String>, ) { match source { Some(fsys::Ref::Realm(_)) => {} Some(fsys::Ref::Self_(_)) => {} Some(fsys::Ref::Framework(_)) => {} Some(fsys::Ref::Child(child)) => self.validate_source_child(child, decl), Some(_) => self.errors.push(Error::invalid_field(decl, "source")), None => self.errors.push(Error::missing_field(decl, "source")), } check_path(source_path, decl, "source_path", &mut self.errors); match target { Some(fsys::Ref::Child(c)) => { self.validate_target_child(decl, allowable_paths, c, source, target_path); } Some(fsys::Ref::Collection(c)) => { self.validate_target_collection(decl, allowable_paths, c, target_path); } Some(_) => { self.errors.push(Error::invalid_field(decl, "target")); } None => { self.errors.push(Error::missing_field(decl, "target")); } } check_path(target_path, decl, "target_path", &mut self.errors); } fn validate_storage_offer_fields( &mut self, decl: &str, type_: Option<&fsys::StorageType>, source: Option<&'a fsys::Ref>, target: Option<&'a fsys::Ref>, ) { if type_.is_none() { self.errors.push(Error::missing_field(decl, "type")); } let storage_source_name = match source { Some(fsys::Ref::Realm(_)) => None, Some(fsys::Ref::Storage(s)) => { self.validate_storage_source(s, decl); Some(&s.name as &str) } Some(_) => { self.errors.push(Error::invalid_field(decl, "source")); None } None => { self.errors.push(Error::missing_field(decl, "source")); None } }; self.validate_storage_target(decl, storage_source_name, target); } fn validate_runner_offer_fields(&mut self, runner: &'a fsys::OfferRunnerDecl) { let decl = "OfferRunnerDecl"; self.validate_offer_source(&runner.source, decl, "source"); check_name(runner.source_name.as_ref(), decl, "source_name", &mut self.errors); // If the offer source is `self`, ensure we have a corresponding RunnerDecl. if let (Some(fsys::Ref::Self_(_)), Some(ref name)) = (&runner.source, &runner.source_name) { if !self.all_runners_and_sources.contains_key(&name as &str) { self.errors.push(Error::invalid_field(decl, "source")); } } let target_id = self.validate_offer_target(&runner.target, decl, "target"); check_name(runner.target_name.as_ref(), decl, "target_name", &mut self.errors); if let (Some(target_id), Some(target_name)) = (target_id, runner.target_name.as_ref()) { // Assuming the target_name is valid, ensure the target_name isn't already used. if !self .offered_runner_names .entry(target_id) .or_insert(HashSet::new()) .insert(target_name) { self.errors.push(Error::duplicate_field(decl, "target_name", target_name as &str)); } } check_offer_target_is_not_source(&runner.target, &runner.source, decl, &mut self.errors); } fn validate_resolver_offer_fields(&mut self, resolver: &'a fsys::OfferResolverDecl) { let decl = "OfferResolverDecl"; self.validate_offer_source(&resolver.source, decl, "source"); check_name(resolver.source_name.as_ref(), decl, "source_name", &mut self.errors); // If the offer source is `self`, ensure we have a corresponding ResolverDecl. if let (Some(fsys::Ref::Self_(_)), Some(ref name)) = (&resolver.source, &resolver.source_name) { if !self.all_resolvers.contains(&name as &str) { self.errors.push(Error::invalid_resolver(decl, "source", name)); } } let target_id = self.validate_offer_target(&resolver.target, decl, "target"); check_name(resolver.target_name.as_ref(), decl, "target_name", &mut self.errors); if let (Some(target_id), Some(target_name)) = (target_id, resolver.target_name.as_ref()) { // Assuming the target_name is valid, ensure the target_name isn't already used. if !self .offered_resolver_names .entry(target_id) .or_insert(HashSet::new()) .insert(target_name) { self.errors.push(Error::duplicate_field(decl, "target_name", target_name as &str)); } } check_offer_target_is_not_source( &resolver.target, &resolver.source, decl, &mut self.errors, ); } fn validate_event_offer_fields(&mut self, event: &'a fsys::OfferEventDecl) { let decl = "OfferEventDecl"; check_name(event.source_name.as_ref(), decl, "source_name", &mut self.errors); // Only offer from realm is allowed. match event.source.as_ref() { Some(fsys::Ref::Realm(_)) => {} None => self.errors.push(Error::missing_field(decl, "source")), _ => self.errors.push(Error::invalid_field(decl, "source")), } let target_id = self.validate_offer_target(&event.target, decl, "target"); if let (Some(target_id), Some(target_name)) = (target_id, event.target_name.as_ref()) { // Assuming the target_name is valid, ensure the target_name isn't already used. if !self .offered_event_names .entry(target_id) .or_insert(HashSet::new()) .insert(target_name) { self.errors.push(Error::duplicate_field(decl, "target_name", target_name as &str)); } } check_name(event.target_name.as_ref(), decl, "target_name", &mut self.errors); } /// Check a `ChildRef` contains a valid child that exists. /// /// We ensure the target child is statically defined (i.e., not a dynamic child inside /// a collection). fn validate_child_ref(&mut self, decl: &str, field_name: &str, child: &fsys::ChildRef) -> bool { // Ensure the name is valid, and the reference refers to a static child. // // We attempt to list all errors if possible. let mut valid = true; if !check_name( Some(&child.name), decl, &format!("{}.child.name", field_name), &mut self.errors, ) { valid = false; } if child.collection.is_some() { self.errors .push(Error::extraneous_field(decl, format!("{}.child.collection", field_name))); valid = false; } if !valid { return false; } // Ensure the child exists. let name: &str = &child.name; if !self.all_children.contains_key(name) { self.errors.push(Error::invalid_child(decl, field_name, name)); return false; } true } /// Check a `CollectionRef` is valid and refers to an existing collection. fn validate_collection_ref( &mut self, decl: &str, field_name: &str, collection: &fsys::CollectionRef, ) -> bool { // Ensure the name is valid. if !check_name( Some(&collection.name), decl, &format!("{}.collection.name", field_name), &mut self.errors, ) { return false; } // Ensure the collection exists. if !self.all_collections.contains(&collection.name as &str) { self.errors.push(Error::invalid_collection(decl, field_name, &collection.name as &str)); return false; } true } fn validate_target_child( &mut self, decl: &str, allowable_paths: AllowablePaths, child: &'a fsys::ChildRef, source: Option<&fsys::Ref>, target_path: Option<&'a String>, ) { if !self.validate_child_ref(decl, "target", child) { return; } if let Some(target_path) = target_path { let paths_for_target = self.target_paths.entry(TargetId::Component(&child.name)).or_insert(HashMap::new()); if let Some(prev_state) = paths_for_target.insert(target_path, allowable_paths) { if prev_state == AllowablePaths::One || prev_state != allowable_paths { self.errors.push(Error::duplicate_field( decl, "target_path", target_path as &str, )); } } if let Some(source) = source { if let fsys::Ref::Child(source_child) = source { if source_child.name == child.name { self.errors .push(Error::offer_target_equals_source(decl, &child.name as &str)); } } } } } fn validate_target_collection( &mut self, decl: &str, allowable_paths: AllowablePaths, collection: &'a fsys::CollectionRef, target_path: Option<&'a String>, ) { if !self.validate_collection_ref(decl, "target", &collection) { return; } if let Some(target_path) = target_path { let paths_for_target = self .target_paths .entry(TargetId::Collection(&collection.name)) .or_insert(HashMap::new()); if let Some(prev_state) = paths_for_target.insert(target_path, allowable_paths) { if prev_state == AllowablePaths::One || prev_state != allowable_paths { self.errors.push(Error::duplicate_field( decl, "target_path", target_path as &str, )); } } } } fn validate_storage_target( &mut self, decl: &str, storage_source_name: Option<&'a str>, target: Option<&'a fsys::Ref>, ) { match target { Some(fsys::Ref::Child(c)) => { if !self.validate_child_ref(decl, "target", &c) { return; } let name = &c.name; if let Some(source_name) = storage_source_name { if self.all_storage_and_sources.get(source_name) == Some(&Some(name)) { self.errors.push(Error::offer_target_equals_source(decl, name)); } } } Some(fsys::Ref::Collection(c)) => { self.validate_collection_ref(decl, "target", &c); } Some(_) => self.errors.push(Error::invalid_field(decl, "target")), None => self.errors.push(Error::missing_field(decl, "target")), } } } fn check_presence_and_length( max_len: usize, prop: Option<&String>, decl_type: &str, keyword: &str, errors: &mut Vec<Error>, ) { match prop { Some(prop) if prop.len() == 0 => errors.push(Error::empty_field(decl_type, keyword)), Some(prop) if prop.len() > max_len => { errors.push(Error::field_too_long(decl_type, keyword)) } Some(_) => (), None => errors.push(Error::missing_field(decl_type, keyword)), } } fn check_path( prop: Option<&String>, decl_type: &str, keyword: &str, errors: &mut Vec<Error>, ) -> bool { let start_err_len = errors.len(); check_presence_and_length(MAX_PATH_LENGTH, prop, decl_type, keyword, errors); if let Some(path) = prop { // Paths must be more than 1 character long if path.len() < 2 { errors.push(Error::invalid_field(decl_type, keyword)); return false; } // Paths must start with `/` if !path.starts_with('/') { errors.push(Error::invalid_field(decl_type, keyword)); return false; } // Paths cannot have two `/`s in a row if path.contains("//") { errors.push(Error::invalid_field(decl_type, keyword)); return false; } // Paths cannot end with `/` if path.ends_with('/') { errors.push(Error::invalid_field(decl_type, keyword)); return false; } } start_err_len == errors.len() } fn check_relative_path( prop: Option<&String>, decl_type: &str, keyword: &str, errors: &mut Vec<Error>, ) -> bool { let start_err_len = errors.len(); check_presence_and_length(MAX_PATH_LENGTH, prop, decl_type, keyword, errors); if let Some(path) = prop { // Relative paths must be nonempty if path.is_empty() { errors.push(Error::invalid_field(decl_type, keyword)); return false; } // Relative paths cannot start with `/` if path.starts_with('/') { errors.push(Error::invalid_field(decl_type, keyword)); return false; } // Relative paths cannot have two `/`s in a row if path.contains("//") { errors.push(Error::invalid_field(decl_type, keyword)); return false; } // Relative paths cannot end with `/` if path.ends_with('/') { errors.push(Error::invalid_field(decl_type, keyword)); return false; } } start_err_len == errors.len() } fn check_name( prop: Option<&String>, decl_type: &str, keyword: &str, errors: &mut Vec<Error>, ) -> bool
fn check_url( prop: Option<&String>, decl_type: &str, keyword: &str, errors: &mut Vec<Error>, ) -> bool { let start_err_len = errors.len(); check_presence_and_length(MAX_URL_LENGTH, prop, decl_type, keyword, errors); if let Some(url) = prop { let mut chars_iter = url.chars(); let mut first_char = true; while let Some(c) = chars_iter.next() { match c { '0'..='9' | 'a'..='z' | '+' | '-' | '.' => first_char = false, ':' => { if first_char { // There must be at least one character in the schema errors.push(Error::invalid_field(decl_type, keyword)); return false; } // Once a `:` character is found, it must be followed by two `/` characters and // then at least one more character. Note that these sequential calls to // `.next()` without checking the result won't panic because `Chars` implements // `FusedIterator`. match (chars_iter.next(), chars_iter.next(), chars_iter.next()) { (Some('/'), Some('/'), Some(_)) => return start_err_len == errors.len(), _ => { errors.push(Error::invalid_field(decl_type, keyword)); return false; } } } c => { errors.push(Error::invalid_character_in_field(decl_type, keyword, c)); return false; } } } // If we've reached here then the string terminated unexpectedly errors.push(Error::invalid_field(decl_type, keyword)); } start_err_len == errors.len() } fn check_url_scheme( prop: Option<&String>, decl_type: &str, keyword: &str, errors: &mut Vec<Error>, ) -> bool { if let Some(scheme) = prop { if let Err(err) = cm_types::UrlScheme::validate(scheme) { errors.push(match err { cm_types::UrlSchemeValidationError::InvalidLength(0) => { Error::empty_field(decl_type, keyword) } cm_types::UrlSchemeValidationError::InvalidLength(_) => { Error::field_too_long(decl_type, keyword) } cm_types::UrlSchemeValidationError::MalformedUrlScheme(c) => { Error::invalid_character_in_field(decl_type, keyword, c) } }); return false; } } else { errors.push(Error::missing_field(decl_type, keyword)); return false; } true } /// Checks that the offer target is not the same as the offer source. fn check_offer_target_is_not_source( target: &Option<fsys::Ref>, source: &Option<fsys::Ref>, decl_type: &str, errors: &mut Vec<Error>, ) -> bool { match (source, target) { (Some(fsys::Ref::Child(ref source_child)), Some(fsys::Ref::Child(ref target_child))) => { if source_child.name == target_child.name { errors.push(Error::offer_target_equals_source(decl_type, &target_child.name)); return false; } } _ => {} }; true } #[cfg(test)] mod tests { use { super::*, fidl_fuchsia_io2 as fio2, fidl_fuchsia_sys2::{ ChildDecl, ChildRef, CollectionDecl, CollectionRef, ComponentDecl, DependencyType, Durability, EnvironmentDecl, EnvironmentExtends, ExposeDecl, ExposeDirectoryDecl, ExposeProtocolDecl, ExposeResolverDecl, ExposeRunnerDecl, ExposeServiceDecl, FrameworkRef, OfferDecl, OfferDirectoryDecl, OfferEventDecl, OfferProtocolDecl, OfferResolverDecl, OfferRunnerDecl, OfferServiceDecl, OfferStorageDecl, RealmRef, Ref, ResolverDecl, ResolverRegistration, RunnerDecl, SelfRef, StartupMode, StorageDecl, StorageRef, StorageType, UseDecl, UseDirectoryDecl, UseEventDecl, UseProtocolDecl, UseRunnerDecl, UseServiceDecl, UseStorageDecl, }, lazy_static::lazy_static, proptest::prelude::*, regex::Regex, }; const PATH_REGEX_STR: &str = r"(/[^/]+)+"; const NAME_REGEX_STR: &str = r"[0-9a-z_\-\.]+"; const URL_REGEX_STR: &str = r"[0-9a-z\+\-\.]+://.+"; lazy_static! { static ref PATH_REGEX: Regex = Regex::new(&("^".to_string() + PATH_REGEX_STR + "$")).unwrap(); static ref NAME_REGEX: Regex = Regex::new(&("^".to_string() + NAME_REGEX_STR + "$")).unwrap(); static ref URL_REGEX: Regex = Regex::new(&("^".to_string() + URL_REGEX_STR + "$")).unwrap(); } proptest! { #[test] fn check_path_matches_regex(s in PATH_REGEX_STR) { if s.len() < MAX_PATH_LENGTH { let mut errors = vec![]; prop_assert!(check_path(Some(&s), "", "", &mut errors)); prop_assert!(errors.is_empty()); } } #[test] fn check_name_matches_regex(s in NAME_REGEX_STR) { if s.len() < MAX_NAME_LENGTH { let mut errors = vec![]; prop_assert!(check_name(Some(&s), "", "", &mut errors)); prop_assert!(errors.is_empty()); } } #[test] fn check_url_matches_regex(s in URL_REGEX_STR) { if s.len() < MAX_URL_LENGTH { let mut errors = vec![]; prop_assert!(check_url(Some(&s), "", "", &mut errors)); prop_assert!(errors.is_empty()); } } #[test] fn check_path_fails_invalid_input(s in ".*") { if !PATH_REGEX.is_match(&s) { let mut errors = vec![]; prop_assert!(!check_path(Some(&s), "", "", &mut errors)); prop_assert!(!errors.is_empty()); } } #[test] fn check_name_fails_invalid_input(s in ".*") { if !NAME_REGEX.is_match(&s) { let mut errors = vec![]; prop_assert!(!check_name(Some(&s), "", "", &mut errors)); prop_assert!(!errors.is_empty()); } } #[test] fn check_url_fails_invalid_input(s in ".*") { if !URL_REGEX.is_match(&s) { let mut errors = vec![]; prop_assert!(!check_url(Some(&s), "", "", &mut errors)); prop_assert!(!errors.is_empty()); } } } fn validate_test(input: ComponentDecl, expected_res: Result<(), ErrorList>) { let res = validate(&input); assert_eq!(format!("{:?}", res), format!("{:?}", expected_res)); } fn check_test<F>(check_fn: F, input: &str, expected_res: Result<(), ErrorList>) where F: FnOnce(Option<&String>, &str, &str, &mut Vec<Error>) -> bool, { let mut errors = vec![]; let res: Result<(), ErrorList> = match check_fn(Some(&input.to_string()), "FooDecl", "foo", &mut errors) { true => Ok(()), false => Err(ErrorList::new(errors)), }; assert_eq!(format!("{:?}", res), format!("{:?}", expected_res)); } fn new_component_decl() -> ComponentDecl { ComponentDecl { program: None, uses: None, exposes: None, offers: None, facets: None, storage: None, children: None, collections: None, runners: None, resolvers: None, environments: None, } } #[test] fn test_errors() { assert_eq!(format!("{}", Error::missing_field("Decl", "keyword")), "Decl missing keyword"); assert_eq!(format!("{}", Error::empty_field("Decl", "keyword")), "Decl has empty keyword"); assert_eq!( format!("{}", Error::duplicate_field("Decl", "keyword", "foo")), "\"foo\" is a duplicate Decl keyword" ); assert_eq!( format!("{}", Error::invalid_field("Decl", "keyword")), "Decl has invalid keyword" ); assert_eq!( format!("{}", Error::field_too_long("Decl", "keyword")), "Decl's keyword is too long" ); assert_eq!( format!("{}", Error::invalid_child("Decl", "source", "child")), "\"child\" is referenced in Decl.source but it does not appear in children" ); assert_eq!( format!("{}", Error::invalid_collection("Decl", "source", "child")), "\"child\" is referenced in Decl.source but it does not appear in collections" ); assert_eq!( format!("{}", Error::invalid_storage("Decl", "source", "name")), "\"name\" is referenced in Decl.source but it does not appear in storage" ); assert_eq!( format!("{}", Error::multiple_runners_specified("Decl")), "Decl specifies multiple runners" ); } macro_rules! test_validate { ( $( $test_name:ident => { input = $input:expr, result = $result:expr, }, )+ ) => { $( #[test] fn $test_name() { validate_test($input, $result); } )+ } } macro_rules! test_string_checks { ( $( $test_name:ident => { check_fn = $check_fn:expr, input = $input:expr, result = $result:expr, }, )+ ) => { $( #[test] fn $test_name() { check_test($check_fn, $input, $result); } )+ } } test_string_checks! { // path test_identifier_path_valid => { check_fn = check_path, input = "/foo/bar", result = Ok(()), }, test_identifier_path_invalid_empty => { check_fn = check_path, input = "", result = Err(ErrorList::new(vec![ Error::empty_field("FooDecl", "foo"), Error::invalid_field("FooDecl", "foo"), ])), }, test_identifier_path_invalid_root => { check_fn = check_path, input = "/", result = Err(ErrorList::new(vec![Error::invalid_field("FooDecl", "foo")])), }, test_identifier_path_invalid_relative => { check_fn = check_path, input = "foo/bar", result = Err(ErrorList::new(vec![Error::invalid_field("FooDecl", "foo")])), }, test_identifier_path_invalid_trailing => { check_fn = check_path, input = "/foo/bar/", result = Err(ErrorList::new(vec![Error::invalid_field("FooDecl", "foo")])), }, test_identifier_path_too_long => { check_fn = check_path, input = &format!("/{}", "a".repeat(1024)), result = Err(ErrorList::new(vec![Error::field_too_long("FooDecl", "foo")])), }, // name test_identifier_name_valid => { check_fn = check_name, input = "abcdefghijklmnopqrstuvwxyz0123456789_-.", result = Ok(()), }, test_identifier_name_invalid => { check_fn = check_name, input = "^bad", result = Err(ErrorList::new(vec![Error::invalid_character_in_field("FooDecl", "foo", '^')])), }, test_identifier_name_too_long => { check_fn = check_name, input = &format!("{}", "a".repeat(101)), result = Err(ErrorList::new(vec![Error::field_too_long("FooDecl", "foo")])), }, // url test_identifier_url_valid => { check_fn = check_url, input = "my+awesome-scheme.2://abc123!@#$%.com", result = Ok(()), }, test_identifier_url_invalid => { check_fn = check_url, input = "fuchsia-pkg://", result = Err(ErrorList::new(vec![Error::invalid_field("FooDecl", "foo")])), }, test_identifier_url_too_long => { check_fn = check_url, input = &format!("fuchsia-pkg://{}", "a".repeat(4083)), result = Err(ErrorList::new(vec![Error::field_too_long("FooDecl", "foo")])), }, } test_validate! { // uses test_validate_uses_empty => { input = { let mut decl = new_component_decl(); decl.uses = Some(vec![ UseDecl::Service(UseServiceDecl { source: None, source_path: None, target_path: None, }), UseDecl::Protocol(UseProtocolDecl { source: None, source_path: None, target_path: None, }), UseDecl::Directory(UseDirectoryDecl { source: None, source_path: None, target_path: None, rights: None, subdir: None, }), UseDecl::Storage(UseStorageDecl { type_: None, target_path: None, }), UseDecl::Storage(UseStorageDecl { type_: Some(StorageType::Cache), target_path: None, }), UseDecl::Runner(UseRunnerDecl { source_name: None, }), UseDecl::Event(UseEventDecl { source_name: None, target_name: None, }) ]); decl }, result = Err(ErrorList::new(vec![ Error::missing_field("UseServiceDecl", "source"), Error::missing_field("UseServiceDecl", "source_path"), Error::missing_field("UseServiceDecl", "target_path"), Error::missing_field("UseProtocolDecl", "source"), Error::missing_field("UseProtocolDecl", "source_path"), Error::missing_field("UseProtocolDecl", "target_path"), Error::missing_field("UseDirectoryDecl", "source"), Error::missing_field("UseDirectoryDecl", "source_path"), Error::missing_field("UseDirectoryDecl", "target_path"), Error::missing_field("UseDirectoryDecl", "rights"), Error::missing_field("UseStorageDecl", "type"), Error::missing_field("UseStorageDecl", "target_path"), Error::missing_field("UseRunnerDecl", "source_name"), Error::missing_field("UseEventDecl", "source_name"), Error::missing_field("UseEventDecl", "target_name"), ])), }, test_validate_uses_invalid_identifiers => { input = { let mut decl = new_component_decl(); decl.uses = Some(vec![ UseDecl::Service(UseServiceDecl { source: Some(fsys::Ref::Self_(fsys::SelfRef {})), source_path: Some("foo/".to_string()), target_path: Some("/".to_string()), }), UseDecl::Protocol(UseProtocolDecl { source: Some(fsys::Ref::Self_(fsys::SelfRef {})), source_path: Some("foo/".to_string()), target_path: Some("/".to_string()), }), UseDecl::Directory(UseDirectoryDecl { source: Some(fsys::Ref::Self_(fsys::SelfRef {})), source_path: Some("foo/".to_string()), target_path: Some("/".to_string()), rights: Some(fio2::Operations::Connect), subdir: Some("/foo".to_string()), }), UseDecl::Storage(UseStorageDecl { type_: Some(StorageType::Cache), target_path: Some("/".to_string()), }), UseDecl::Storage(UseStorageDecl { type_: Some(StorageType::Meta), target_path: Some("/meta".to_string()), }), UseDecl::Event(UseEventDecl { source_name: Some("/foo".to_string()), target_name: Some("/foo".to_string()), }), ]); decl }, result = Err(ErrorList::new(vec![ Error::invalid_field("UseServiceDecl", "source"), Error::invalid_field("UseServiceDecl", "source_path"), Error::invalid_field("UseServiceDecl", "target_path"), Error::invalid_field("UseProtocolDecl", "source"), Error::invalid_field("UseProtocolDecl", "source_path"), Error::invalid_field("UseProtocolDecl", "target_path"), Error::invalid_field("UseDirectoryDecl", "source"), Error::invalid_field("UseDirectoryDecl", "source_path"), Error::invalid_field("UseDirectoryDecl", "target_path"), Error::invalid_field("UseDirectoryDecl", "subdir"), Error::invalid_field("UseStorageDecl", "target_path"), Error::invalid_field("UseStorageDecl", "target_path"), Error::invalid_character_in_field("UseEventDecl", "source_name", '/'), Error::invalid_character_in_field("UseEventDecl", "target_name", '/'), ])), }, test_validate_uses_multiple_runners => { input = { let mut decl = new_component_decl(); decl.uses = Some(vec![ UseDecl::Runner(UseRunnerDecl { source_name: Some("elf".to_string()), }), UseDecl::Runner(UseRunnerDecl { source_name: Some("elf".to_string()), }), ]); decl }, result = Err(ErrorList::new(vec![ Error::multiple_runners_specified("UseRunnerDecl"), ])), }, test_validate_uses_long_identifiers => { input = { let mut decl = new_component_decl(); decl.uses = Some(vec![ UseDecl::Service(UseServiceDecl { source: Some(fsys::Ref::Realm(fsys::RealmRef {})), source_path: Some(format!("/{}", "a".repeat(1024))), target_path: Some(format!("/{}", "b".repeat(1024))), }), UseDecl::Protocol(UseProtocolDecl { source: Some(fsys::Ref::Realm(fsys::RealmRef {})), source_path: Some(format!("/{}", "a".repeat(1024))), target_path: Some(format!("/{}", "b".repeat(1024))), }), UseDecl::Directory(UseDirectoryDecl { source: Some(fsys::Ref::Realm(fsys::RealmRef {})), source_path: Some(format!("/{}", "a".repeat(1024))), target_path: Some(format!("/{}", "b".repeat(1024))), rights: Some(fio2::Operations::Connect), subdir: None, }), UseDecl::Storage(UseStorageDecl { type_: Some(StorageType::Cache), target_path: Some(format!("/{}", "b".repeat(1024))), }), UseDecl::Runner(UseRunnerDecl { source_name: Some(format!("{}", "a".repeat(101))), }), UseDecl::Event(UseEventDecl { source_name: Some(format!("{}", "a".repeat(101))), target_name: Some(format!("{}", "a".repeat(101))) }), ]); decl }, result = Err(ErrorList::new(vec![ Error::field_too_long("UseServiceDecl", "source_path"), Error::field_too_long("UseServiceDecl", "target_path"), Error::field_too_long("UseProtocolDecl", "source_path"), Error::field_too_long("UseProtocolDecl", "target_path"), Error::field_too_long("UseDirectoryDecl", "source_path"), Error::field_too_long("UseDirectoryDecl", "target_path"), Error::field_too_long("UseStorageDecl", "target_path"), Error::field_too_long("UseRunnerDecl", "source_name"), Error::field_too_long("UseEventDecl", "source_name"), Error::field_too_long("UseEventDecl", "target_name"), ])), }, // exposes test_validate_exposes_empty => { input = { let mut decl = new_component_decl(); decl.exposes = Some(vec![ ExposeDecl::Service(ExposeServiceDecl { source: None, source_path: None, target_path: None, target: None, }), ExposeDecl::Protocol(ExposeProtocolDecl { source: None, source_path: None, target_path: None, target: None, }), ExposeDecl::Directory(ExposeDirectoryDecl { source: None, source_path: None, target_path: None, target: None, rights: None, subdir: None, }), ExposeDecl::Runner(ExposeRunnerDecl { source: None, source_name: None, target: None, target_name: None, }), ExposeDecl::Resolver(ExposeResolverDecl { source: None, source_name: None, target: None, target_name: None, }), ]); decl }, result = Err(ErrorList::new(vec![ Error::missing_field("ExposeServiceDecl", "source"), Error::missing_field("ExposeServiceDecl", "target"), Error::missing_field("ExposeServiceDecl", "source_path"), Error::missing_field("ExposeServiceDecl", "target_path"), Error::missing_field("ExposeProtocolDecl", "source"), Error::missing_field("ExposeProtocolDecl", "target"), Error::missing_field("ExposeProtocolDecl", "source_path"), Error::missing_field("ExposeProtocolDecl", "target_path"), Error::missing_field("ExposeDirectoryDecl", "source"), Error::missing_field("ExposeDirectoryDecl", "target"), Error::missing_field("ExposeDirectoryDecl", "source_path"), Error::missing_field("ExposeDirectoryDecl", "target_path"), Error::missing_field("ExposeRunnerDecl", "source"), Error::missing_field("ExposeRunnerDecl", "target"), Error::missing_field("ExposeRunnerDecl", "source_name"), Error::missing_field("ExposeRunnerDecl", "target_name"), Error::missing_field("ExposeResolverDecl", "source"), Error::missing_field("ExposeResolverDecl", "target"), Error::missing_field("ExposeResolverDecl", "source_name"), Error::missing_field("ExposeResolverDecl", "target_name"), ])), }, test_validate_exposes_extraneous => { input = { let mut decl = new_component_decl(); decl.exposes = Some(vec![ ExposeDecl::Service(ExposeServiceDecl { source: Some(Ref::Child(ChildRef { name: "logger".to_string(), collection: Some("modular".to_string()), })), source_path: Some("/svc/logger".to_string()), target_path: Some("/svc/logger".to_string()), target: Some(Ref::Realm(RealmRef {})), }), ExposeDecl::Protocol(ExposeProtocolDecl { source: Some(Ref::Child(ChildRef { name: "logger".to_string(), collection: Some("modular".to_string()), })), source_path: Some("/svc/legacy_logger".to_string()), target_path: Some("/svc/legacy_logger".to_string()), target: Some(Ref::Realm(RealmRef {})), }), ExposeDecl::Directory(ExposeDirectoryDecl { source: Some(Ref::Child(ChildRef { name: "netstack".to_string(), collection: Some("modular".to_string()), })), source_path: Some("/data".to_string()), target_path: Some("/data".to_string()), target: Some(Ref::Realm(RealmRef {})), rights: Some(fio2::Operations::Connect), subdir: None, }), ExposeDecl::Runner(ExposeRunnerDecl { source: Some(Ref::Child(ChildRef { name: "netstack".to_string(), collection: Some("modular".to_string()), })), source_name: Some("elf".to_string()), target: Some(Ref::Realm(RealmRef {})), target_name: Some("elf".to_string()), }), ExposeDecl::Resolver(ExposeResolverDecl { source: Some(Ref::Child(ChildRef { name: "netstack".to_string(), collection: Some("modular".to_string()), })), source_name: Some("pkg".to_string()), target: Some(Ref::Realm(RealmRef {})), target_name: Some("pkg".to_string()), }), ]); decl }, result = Err(ErrorList::new(vec![ Error::extraneous_field("ExposeServiceDecl", "source.child.collection"), Error::extraneous_field("ExposeProtocolDecl", "source.child.collection"), Error::extraneous_field("ExposeDirectoryDecl", "source.child.collection"), Error::extraneous_field("ExposeRunnerDecl", "source.child.collection"), Error::extraneous_field("ExposeResolverDecl", "source.child.collection"), ])), }, test_validate_exposes_rights => { input = { let mut decl = new_component_decl(); decl.exposes = Some(vec![ ExposeDecl::Directory(ExposeDirectoryDecl { source: Some(Ref::Self_(SelfRef{})), source_path: Some("/data/a".to_string()), target_path: Some("/data/b".to_string()), target: Some(Ref::Framework(FrameworkRef {})), rights: None, subdir: None, }) ]); decl }, result = Err(ErrorList::new(vec![ Error::missing_field("ExposeDirectoryDecl", "rights"), ])), }, test_validate_exposes_invalid_identifiers => { input = { let mut decl = new_component_decl(); decl.exposes = Some(vec![ ExposeDecl::Service(ExposeServiceDecl { source: Some(Ref::Child(ChildRef { name: "^bad".to_string(), collection: None, })), source_path: Some("foo/".to_string()), target_path: Some("/".to_string()), target: Some(Ref::Realm(RealmRef {})), }), ExposeDecl::Protocol(ExposeProtocolDecl { source: Some(Ref::Child(ChildRef { name: "^bad".to_string(), collection: None, })), source_path: Some("foo/".to_string()), target_path: Some("/".to_string()), target: Some(Ref::Realm(RealmRef {})), }), ExposeDecl::Directory(ExposeDirectoryDecl { source: Some(Ref::Child(ChildRef { name: "^bad".to_string(), collection: None, })), source_path: Some("foo/".to_string()), target_path: Some("/".to_string()), target: Some(Ref::Framework(FrameworkRef {})), rights: Some(fio2::Operations::Connect), subdir: Some("/foo".to_string()), }), ExposeDecl::Runner(ExposeRunnerDecl { source: Some(Ref::Child(ChildRef { name: "^bad".to_string(), collection: None, })), source_name: Some("/path".to_string()), target: Some(Ref::Realm(RealmRef {})), target_name: Some("elf!".to_string()), }), ExposeDecl::Resolver(ExposeResolverDecl { source: Some(Ref::Child(ChildRef { name: "^bad".to_string(), collection: None, })), source_name: Some("/path".to_string()), target: Some(Ref::Realm(RealmRef {})), target_name: Some("pkg!".to_string()), }), ]); decl }, result = Err(ErrorList::new(vec![ Error::invalid_character_in_field("ExposeServiceDecl", "source.child.name", '^'), Error::invalid_field("ExposeServiceDecl", "source_path"), Error::invalid_field("ExposeServiceDecl", "target_path"), Error::invalid_character_in_field("ExposeProtocolDecl", "source.child.name", '^'), Error::invalid_field("ExposeProtocolDecl", "source_path"), Error::invalid_field("ExposeProtocolDecl", "target_path"), Error::invalid_character_in_field("ExposeDirectoryDecl", "source.child.name", '^'), Error::invalid_field("ExposeDirectoryDecl", "source_path"), Error::invalid_field("ExposeDirectoryDecl", "target_path"), Error::invalid_field("ExposeDirectoryDecl", "subdir"), Error::invalid_character_in_field("ExposeRunnerDecl", "source.child.name", '^'), Error::invalid_character_in_field("ExposeRunnerDecl", "source_name", '/'), Error::invalid_character_in_field("ExposeRunnerDecl", "target_name", '!'), Error::invalid_character_in_field("ExposeResolverDecl", "source.child.name", '^'), Error::invalid_character_in_field("ExposeResolverDecl", "source_name", '/'), Error::invalid_character_in_field("ExposeResolverDecl", "target_name", '!'), ])), }, test_validate_exposes_invalid_source_target => { input = { let mut decl = new_component_decl(); decl.exposes = Some(vec![ ExposeDecl::Service(ExposeServiceDecl { source: None, source_path: Some("/a".to_string()), target_path: Some("/b".to_string()), target: None, }), ExposeDecl::Protocol(ExposeProtocolDecl { source: Some(Ref::Realm(RealmRef {})), source_path: Some("/c".to_string()), target_path: Some("/d".to_string()), target: Some(Ref::Self_(SelfRef {})), }), ExposeDecl::Directory(ExposeDirectoryDecl { source: Some(Ref::Collection(CollectionRef {name: "z".to_string()})), source_path: Some("/e".to_string()), target_path: Some("/f".to_string()), target: Some(Ref::Collection(CollectionRef {name: "z".to_string()})), rights: Some(fio2::Operations::Connect), subdir: None, }), ExposeDecl::Directory(ExposeDirectoryDecl { source: Some(Ref::Storage(StorageRef {name: "a".to_string()})), source_path: Some("/g".to_string()), target_path: Some("/h".to_string()), target: Some(Ref::Storage(StorageRef {name: "a".to_string()})), rights: Some(fio2::Operations::Connect), subdir: None, }), ExposeDecl::Runner(ExposeRunnerDecl { source: Some(Ref::Storage(StorageRef {name: "a".to_string()})), source_name: Some("a".to_string()), target: Some(Ref::Framework(FrameworkRef {})), target_name: Some("b".to_string()), }), ExposeDecl::Resolver(ExposeResolverDecl { source: Some(Ref::Storage(StorageRef {name: "a".to_string()})), source_name: Some("a".to_string()), target: Some(Ref::Framework(FrameworkRef {})), target_name: Some("b".to_string()), }), ]); decl }, result = Err(ErrorList::new(vec![ Error::missing_field("ExposeServiceDecl", "source"), Error::missing_field("ExposeServiceDecl", "target"), Error::invalid_field("ExposeProtocolDecl", "source"), Error::invalid_field("ExposeProtocolDecl", "target"), Error::invalid_field("ExposeDirectoryDecl", "source"), Error::invalid_field("ExposeDirectoryDecl", "target"), Error::invalid_field("ExposeDirectoryDecl", "source"), Error::invalid_field("ExposeDirectoryDecl", "target"), Error::invalid_field("ExposeRunnerDecl", "source"), Error::invalid_field("ExposeRunnerDecl", "target"), Error::invalid_field("ExposeResolverDecl", "source"), Error::invalid_field("ExposeResolverDecl", "target"), ])), }, test_validate_exposes_long_identifiers => { input = { let mut decl = new_component_decl(); decl.exposes = Some(vec![ ExposeDecl::Service(ExposeServiceDecl { source: Some(Ref::Child(ChildRef { name: "b".repeat(101), collection: None, })), source_path: Some(format!("/{}", "a".repeat(1024))), target_path: Some(format!("/{}", "b".repeat(1024))), target: Some(Ref::Realm(RealmRef {})), }), ExposeDecl::Protocol(ExposeProtocolDecl { source: Some(Ref::Child(ChildRef { name: "b".repeat(101), collection: None, })), source_path: Some(format!("/{}", "a".repeat(1024))), target_path: Some(format!("/{}", "b".repeat(1024))), target: Some(Ref::Realm(RealmRef {})), }), ExposeDecl::Directory(ExposeDirectoryDecl { source: Some(Ref::Child(ChildRef { name: "b".repeat(101), collection: None, })), source_path: Some(format!("/{}", "a".repeat(1024))), target_path: Some(format!("/{}", "b".repeat(1024))), target: Some(Ref::Realm(RealmRef {})), rights: Some(fio2::Operations::Connect), subdir: None, }), ExposeDecl::Runner(ExposeRunnerDecl { source: Some(Ref::Child(ChildRef { name: "b".repeat(101), collection: None, })), source_name: Some("a".repeat(101)), target: Some(Ref::Realm(RealmRef {})), target_name: Some("b".repeat(101)), }), ExposeDecl::Resolver(ExposeResolverDecl { source: Some(Ref::Child(ChildRef { name: "b".repeat(101), collection: None, })), source_name: Some("a".repeat(101)), target: Some(Ref::Realm(RealmRef {})), target_name: Some("b".repeat(101)), }), ]); decl }, result = Err(ErrorList::new(vec![ Error::field_too_long("ExposeServiceDecl", "source.child.name"), Error::field_too_long("ExposeServiceDecl", "source_path"), Error::field_too_long("ExposeServiceDecl", "target_path"), Error::field_too_long("ExposeProtocolDecl", "source.child.name"), Error::field_too_long("ExposeProtocolDecl", "source_path"), Error::field_too_long("ExposeProtocolDecl", "target_path"), Error::field_too_long("ExposeDirectoryDecl", "source.child.name"), Error::field_too_long("ExposeDirectoryDecl", "source_path"), Error::field_too_long("ExposeDirectoryDecl", "target_path"), Error::field_too_long("ExposeRunnerDecl", "source.child.name"), Error::field_too_long("ExposeRunnerDecl", "source_name"), Error::field_too_long("ExposeRunnerDecl", "target_name"), Error::field_too_long("ExposeResolverDecl", "source.child.name"), Error::field_too_long("ExposeResolverDecl", "source_name"), Error::field_too_long("ExposeResolverDecl", "target_name"), ])), }, test_validate_exposes_invalid_child => { input = { let mut decl = new_component_decl(); decl.exposes = Some(vec![ ExposeDecl::Service(ExposeServiceDecl { source: Some(Ref::Child(ChildRef { name: "netstack".to_string(), collection: None, })), source_path: Some("/loggers/fuchsia.logger.Log".to_string()), target_path: Some("/svc/fuchsia.logger.Log".to_string()), target: Some(Ref::Realm(RealmRef {})), }), ExposeDecl::Protocol(ExposeProtocolDecl { source: Some(Ref::Child(ChildRef { name: "netstack".to_string(), collection: None, })), source_path: Some("/loggers/fuchsia.logger.LegacyLog".to_string()), target_path: Some("/svc/fuchsia.logger.LegacyLog".to_string()), target: Some(Ref::Realm(RealmRef {})), }), ExposeDecl::Directory(ExposeDirectoryDecl { source: Some(Ref::Child(ChildRef { name: "netstack".to_string(), collection: None, })), source_path: Some("/data/netstack".to_string()), target_path: Some("/data".to_string()), target: Some(Ref::Realm(RealmRef {})), rights: Some(fio2::Operations::Connect), subdir: None, }), ExposeDecl::Runner(ExposeRunnerDecl { source: Some(Ref::Child(ChildRef { name: "netstack".to_string(), collection: None, })), source_name: Some("elf".to_string()), target: Some(Ref::Realm(RealmRef {})), target_name: Some("elf".to_string()), }), ExposeDecl::Resolver(ExposeResolverDecl { source: Some(Ref::Child(ChildRef { name: "netstack".to_string(), collection: None, })), source_name: Some("pkg".to_string()), target: Some(Ref::Realm(RealmRef {})), target_name: Some("pkg".to_string()), }), ]); decl }, result = Err(ErrorList::new(vec![ Error::invalid_child("ExposeServiceDecl", "source", "netstack"), Error::invalid_child("ExposeProtocolDecl", "source", "netstack"), Error::invalid_child("ExposeDirectoryDecl", "source", "netstack"), Error::invalid_child("ExposeRunnerDecl", "source", "netstack"), Error::invalid_child("ExposeResolverDecl", "source", "netstack"), ])), }, test_validate_exposes_duplicate_target => { input = { let mut decl = new_component_decl(); decl.runners = Some(vec![RunnerDecl{ name: Some("source_elf".to_string()), source: Some(Ref::Self_(SelfRef{})), source_path: Some("/path".to_string()), }]); decl.resolvers = Some(vec![ResolverDecl { name: Some("source_pkg".to_string()), source_path: Some("/path".to_string()), }]); decl.exposes = Some(vec![ ExposeDecl::Directory(ExposeDirectoryDecl { source: Some(Ref::Self_(SelfRef{})), source_path: Some("/svc/logger".to_string()), target_path: Some("/svc/fuchsia.logger.Log".to_string()), target: Some(Ref::Realm(RealmRef {})), rights: Some(fio2::Operations::Connect), subdir: None, }), ExposeDecl::Service(ExposeServiceDecl { source: Some(Ref::Self_(SelfRef{})), source_path: Some("/svc/logger2".to_string()), target_path: Some("/svc/fuchsia.logger.Log".to_string()), target: Some(Ref::Realm(RealmRef {})), }), ExposeDecl::Directory(ExposeDirectoryDecl { source: Some(Ref::Self_(SelfRef{})), source_path: Some("/svc/logger3".to_string()), target_path: Some("/svc/fuchsia.logger.Log".to_string()), target: Some(Ref::Realm(RealmRef {})), rights: Some(fio2::Operations::Connect), subdir: None, }), ExposeDecl::Service(ExposeServiceDecl { source: Some(Ref::Self_(SelfRef{})), source_path: Some("/svc/netstack".to_string()), target_path: Some("/svc/fuchsia.net.Stack".to_string()), target: Some(Ref::Realm(RealmRef {})), }), ExposeDecl::Service(ExposeServiceDecl { source: Some(Ref::Self_(SelfRef{})), source_path: Some("/svc/netstack2".to_string()), target_path: Some("/svc/fuchsia.net.Stack".to_string()), target: Some(Ref::Realm(RealmRef {})), }), ExposeDecl::Runner(ExposeRunnerDecl { source: Some(Ref::Self_(SelfRef{})), source_name: Some("source_elf".to_string()), target: Some(Ref::Realm(RealmRef {})), target_name: Some("elf".to_string()), }), ExposeDecl::Runner(ExposeRunnerDecl { source: Some(Ref::Self_(SelfRef{})), source_name: Some("source_elf".to_string()), target: Some(Ref::Realm(RealmRef {})), target_name: Some("elf".to_string()), }), ExposeDecl::Resolver(ExposeResolverDecl { source: Some(Ref::Self_(SelfRef{})), source_name: Some("source_pkg".to_string()), target: Some(Ref::Realm(RealmRef {})), target_name: Some("pkg".to_string()), }), ExposeDecl::Resolver(ExposeResolverDecl { source: Some(Ref::Self_(SelfRef{})), source_name: Some("source_pkg".to_string()), target: Some(Ref::Realm(RealmRef {})), target_name: Some("pkg".to_string()), }), ]); decl }, result = Err(ErrorList::new(vec![ Error::duplicate_field("ExposeServiceDecl", "target_path", "/svc/fuchsia.logger.Log"), Error::duplicate_field("ExposeDirectoryDecl", "target_path", "/svc/fuchsia.logger.Log"), Error::duplicate_field("ExposeRunnerDecl", "target_name", "elf"), Error::duplicate_field("ExposeResolverDecl", "target_name", "pkg"), ])), }, test_validate_exposes_invalid_runner_from_self => { input = { let mut decl = new_component_decl(); decl.exposes = Some(vec![ ExposeDecl::Runner(ExposeRunnerDecl { source: Some(Ref::Self_(SelfRef{})), source_name: Some("source_elf".to_string()), target: Some(Ref::Realm(RealmRef {})), target_name: Some("elf".to_string()), }), ]); decl }, result = Err(ErrorList::new(vec![ // We are attempting to expose a runner from "self", but we don't // acutally declare a runner. Error::invalid_field("ExposeRunnerDecl", "source"), ])), }, // offers test_validate_offers_empty => { input = { let mut decl = new_component_decl(); decl.offers = Some(vec![ OfferDecl::Service(OfferServiceDecl { source: None, source_path: None, target: None, target_path: None, }), OfferDecl::Protocol(OfferProtocolDecl { source: None, source_path: None, target: None, target_path: None, dependency_type: None, }), OfferDecl::Directory(OfferDirectoryDecl { source: None, source_path: None, target: None, target_path: None, rights: None, subdir: None, dependency_type: None, }), OfferDecl::Storage(OfferStorageDecl { type_: None, source: None, target: None, }), OfferDecl::Runner(OfferRunnerDecl { source: None, source_name: None, target: None, target_name: None, }), OfferDecl::Event(OfferEventDecl { source: None, source_name: None, target: None, target_name: None, }) ]); decl }, result = Err(ErrorList::new(vec![ Error::missing_field("OfferServiceDecl", "source"), Error::missing_field("OfferServiceDecl", "source_path"), Error::missing_field("OfferServiceDecl", "target"), Error::missing_field("OfferServiceDecl", "target_path"), Error::missing_field("OfferProtocolDecl", "source"), Error::missing_field("OfferProtocolDecl", "source_path"), Error::missing_field("OfferProtocolDecl", "target"), Error::missing_field("OfferProtocolDecl", "target_path"), Error::missing_field("OfferProtocolDecl", "dependency_type"), Error::missing_field("OfferDirectoryDecl", "source"), Error::missing_field("OfferDirectoryDecl", "source_path"), Error::missing_field("OfferDirectoryDecl", "target"), Error::missing_field("OfferDirectoryDecl", "target_path"), Error::missing_field("OfferDirectoryDecl", "dependency_type"), Error::missing_field("OfferStorageDecl", "type"), Error::missing_field("OfferStorageDecl", "source"), Error::missing_field("OfferStorageDecl", "target"), Error::missing_field("OfferRunnerDecl", "source"), Error::missing_field("OfferRunnerDecl", "source_name"), Error::missing_field("OfferRunnerDecl", "target"), Error::missing_field("OfferRunnerDecl", "target_name"), Error::missing_field("OfferEventDecl", "source_name"), Error::missing_field("OfferEventDecl", "source"), Error::missing_field("OfferEventDecl", "target"), Error::missing_field("OfferEventDecl", "target_name"), ])), }, test_validate_offers_long_identifiers => { input = { let mut decl = new_component_decl(); decl.offers = Some(vec![ OfferDecl::Service(OfferServiceDecl { source: Some(Ref::Child(ChildRef { name: "a".repeat(101), collection: None, })), source_path: Some(format!("/{}", "a".repeat(1024))), target: Some(Ref::Child( ChildRef { name: "b".repeat(101), collection: None, } )), target_path: Some(format!("/{}", "b".repeat(1024))), }), OfferDecl::Service(OfferServiceDecl { source: Some(Ref::Self_(SelfRef {})), source_path: Some("/a".to_string()), target: Some(Ref::Collection( CollectionRef { name: "b".repeat(101), } )), target_path: Some(format!("/{}", "b".repeat(1024))), }), OfferDecl::Protocol(OfferProtocolDecl { source: Some(Ref::Child(ChildRef { name: "a".repeat(101), collection: None, })), source_path: Some(format!("/{}", "a".repeat(1024))), target: Some(Ref::Child( ChildRef { name: "b".repeat(101), collection: None, } )), target_path: Some(format!("/{}", "b".repeat(1024))), dependency_type: Some(DependencyType::Strong), }), OfferDecl::Protocol(OfferProtocolDecl { source: Some(Ref::Self_(SelfRef {})), source_path: Some("/a".to_string()), target: Some(Ref::Collection( CollectionRef { name: "b".repeat(101), } )), target_path: Some(format!("/{}", "b".repeat(1024))), dependency_type: Some(DependencyType::WeakForMigration), }), OfferDecl::Directory(OfferDirectoryDecl { source: Some(Ref::Child(ChildRef { name: "a".repeat(101), collection: None, })), source_path: Some(format!("/{}", "a".repeat(1024))), target: Some(Ref::Child( ChildRef { name: "b".repeat(101), collection: None, } )), target_path: Some(format!("/{}", "b".repeat(1024))), rights: Some(fio2::Operations::Connect), subdir: None, dependency_type: Some(DependencyType::Strong), }), OfferDecl::Directory(OfferDirectoryDecl { source: Some(Ref::Self_(SelfRef {})), source_path: Some("/a".to_string()), target: Some(Ref::Collection( CollectionRef { name: "b".repeat(101), } )), target_path: Some(format!("/{}", "b".repeat(1024))), rights: Some(fio2::Operations::Connect), subdir: None, dependency_type: Some(DependencyType::WeakForMigration), }), OfferDecl::Storage(OfferStorageDecl { type_: Some(StorageType::Data), source: Some(Ref::Realm(RealmRef {})), target: Some(Ref::Child( ChildRef { name: "b".repeat(101), collection: None, } )), }), OfferDecl::Storage(OfferStorageDecl { type_: Some(StorageType::Data), source: Some(Ref::Realm(RealmRef {})), target: Some(Ref::Collection( CollectionRef { name: "b".repeat(101) } )), }), OfferDecl::Runner(OfferRunnerDecl { source: Some(Ref::Child(ChildRef { name: "a".repeat(101), collection: None, })), source_name: Some("b".repeat(101)), target: Some(Ref::Collection( CollectionRef { name: "c".repeat(101), } )), target_name: Some("d".repeat(101)), }), OfferDecl::Resolver(OfferResolverDecl { source: Some(Ref::Child(ChildRef { name: "a".repeat(101), collection: None, })), source_name: Some("b".repeat(101)), target: Some(Ref::Collection( CollectionRef { name: "c".repeat(101), } )), target_name: Some("d".repeat(101)), }), OfferDecl::Event(OfferEventDecl { source: Some(Ref::Realm(RealmRef {})), source_name: Some(format!("{}", "a".repeat(101))), target: Some(Ref::Child(ChildRef { name: "a".repeat(101), collection: None })), target_name: Some(format!("{}", "a".repeat(101))), }), ]); decl }, result = Err(ErrorList::new(vec![ Error::field_too_long("OfferServiceDecl", "source.child.name"), Error::field_too_long("OfferServiceDecl", "source_path"), Error::field_too_long("OfferServiceDecl", "target.child.name"), Error::field_too_long("OfferServiceDecl", "target_path"), Error::field_too_long("OfferServiceDecl", "target.collection.name"), Error::field_too_long("OfferServiceDecl", "target_path"), Error::field_too_long("OfferProtocolDecl", "source.child.name"), Error::field_too_long("OfferProtocolDecl", "source_path"), Error::field_too_long("OfferProtocolDecl", "target.child.name"), Error::field_too_long("OfferProtocolDecl", "target_path"), Error::field_too_long("OfferProtocolDecl", "target.collection.name"), Error::field_too_long("OfferProtocolDecl", "target_path"), Error::field_too_long("OfferDirectoryDecl", "source.child.name"), Error::field_too_long("OfferDirectoryDecl", "source_path"), Error::field_too_long("OfferDirectoryDecl", "target.child.name"), Error::field_too_long("OfferDirectoryDecl", "target_path"), Error::field_too_long("OfferDirectoryDecl", "target.collection.name"), Error::field_too_long("OfferDirectoryDecl", "target_path"), Error::field_too_long("OfferStorageDecl", "target.child.name"), Error::field_too_long("OfferStorageDecl", "target.collection.name"), Error::field_too_long("OfferRunnerDecl", "source.child.name"), Error::field_too_long("OfferRunnerDecl", "source_name"), Error::field_too_long("OfferRunnerDecl", "target.collection.name"), Error::field_too_long("OfferRunnerDecl", "target_name"), Error::field_too_long("OfferResolverDecl", "source.child.name"), Error::field_too_long("OfferResolverDecl", "source_name"), Error::field_too_long("OfferResolverDecl", "target.collection.name"), Error::field_too_long("OfferResolverDecl", "target_name"), Error::field_too_long("OfferEventDecl", "source_name"), Error::field_too_long("OfferEventDecl", "target.child.name"), Error::field_too_long("OfferEventDecl", "target_name"), ])), }, test_validate_offers_rights => { input = { let mut decl = new_component_decl(); decl.offers = Some(vec![OfferDecl::Directory(OfferDirectoryDecl { source: Some(Ref::Self_(SelfRef{})), source_path: Some("/data/assets".to_string()), target: Some(Ref::Child( ChildRef { name: "logger".to_string(), collection: None, } )), target_path: Some("/data".to_string()), rights: None, subdir: None, dependency_type: Some(DependencyType::Strong), })]); decl }, result = Err(ErrorList::new(vec![ Error::invalid_child("OfferDirectoryDecl", "target", "logger"), Error::missing_field("OfferDirectoryDecl", "rights"), ])), }, test_validate_offers_extraneous => { input = { let mut decl = new_component_decl(); decl.offers = Some(vec![ OfferDecl::Service(OfferServiceDecl { source: Some(Ref::Child(ChildRef { name: "logger".to_string(), collection: Some("modular".to_string()), })), source_path: Some("/loggers/fuchsia.logger.Log".to_string()), target: Some(Ref::Child( ChildRef { name: "netstack".to_string(), collection: Some("modular".to_string()), } )), target_path: Some("/data/realm_assets".to_string()), }), OfferDecl::Protocol(OfferProtocolDecl { source: Some(Ref::Child(ChildRef { name: "logger".to_string(), collection: Some("modular".to_string()), })), source_path: Some("/loggers/fuchsia.logger.Log".to_string()), target: Some(Ref::Child( ChildRef { name: "netstack".to_string(), collection: Some("modular".to_string()), } )), target_path: Some("/data/realm_assets".to_string()), dependency_type: Some(DependencyType::Strong), }), OfferDecl::Directory(OfferDirectoryDecl { source: Some(Ref::Child(ChildRef { name: "logger".to_string(), collection: Some("modular".to_string()), })), source_path: Some("/data/assets".to_string()), target: Some(Ref::Child( ChildRef { name: "netstack".to_string(), collection: Some("modular".to_string()), } )), target_path: Some("/data".to_string()), rights: Some(fio2::Operations::Connect), subdir: None, dependency_type: Some(DependencyType::WeakForMigration), }), OfferDecl::Storage(OfferStorageDecl { type_: Some(StorageType::Data), source: Some(Ref::Realm(RealmRef{ })), target: Some(Ref::Child( ChildRef { name: "netstack".to_string(), collection: Some("modular".to_string()), } )), }), OfferDecl::Runner(OfferRunnerDecl { source: Some(Ref::Child(ChildRef { name: "logger".to_string(), collection: Some("modular".to_string()), })), source_name: Some("elf".to_string()), target: Some(Ref::Child( ChildRef { name: "netstack".to_string(), collection: Some("modular".to_string()), } )), target_name: Some("elf".to_string()), }), OfferDecl::Resolver(OfferResolverDecl { source: Some(Ref::Child(ChildRef { name: "logger".to_string(), collection: Some("modular".to_string()), })), source_name: Some("pkg".to_string()), target: Some(Ref::Child( ChildRef { name: "netstack".to_string(), collection: Some("modular".to_string()), } )), target_name: Some("pkg".to_string()), }), ]); decl }, result = Err(ErrorList::new(vec![ Error::extraneous_field("OfferServiceDecl", "source.child.collection"), Error::extraneous_field("OfferServiceDecl", "target.child.collection"), Error::extraneous_field("OfferProtocolDecl", "source.child.collection"), Error::extraneous_field("OfferProtocolDecl", "target.child.collection"), Error::extraneous_field("OfferDirectoryDecl", "source.child.collection"), Error::extraneous_field("OfferDirectoryDecl", "target.child.collection"), Error::extraneous_field("OfferStorageDecl", "target.child.collection"), Error::extraneous_field("OfferRunnerDecl", "source.child.collection"), Error::extraneous_field("OfferRunnerDecl", "target.child.collection"), Error::extraneous_field("OfferResolverDecl", "source.child.collection"), Error::extraneous_field("OfferResolverDecl", "target.child.collection"), ])), }, test_validate_offers_invalid_identifiers => { input = { let mut decl = new_component_decl(); decl.offers = Some(vec![ OfferDecl::Service(OfferServiceDecl { source: Some(Ref::Child(ChildRef { name: "^bad".to_string(), collection: None, })), source_path: Some("foo/".to_string()), target: Some(Ref::Child(ChildRef { name: "^bad".to_string(), collection: None, })), target_path: Some("/".to_string()), }), OfferDecl::Protocol(OfferProtocolDecl { source: Some(Ref::Child(ChildRef { name: "^bad".to_string(), collection: None, })), source_path: Some("foo/".to_string()), target: Some(Ref::Child(ChildRef { name: "^bad".to_string(), collection: None, })), target_path: Some("/".to_string()), dependency_type: Some(DependencyType::Strong), }), OfferDecl::Directory(OfferDirectoryDecl { source: Some(Ref::Child(ChildRef { name: "^bad".to_string(), collection: None, })), source_path: Some("foo/".to_string()), target: Some(Ref::Child(ChildRef { name: "^bad".to_string(), collection: None, })), target_path: Some("/".to_string()), rights: Some(fio2::Operations::Connect), subdir: Some("/foo".to_string()), dependency_type: Some(DependencyType::Strong), }), OfferDecl::Runner(OfferRunnerDecl { source: Some(Ref::Child(ChildRef { name: "^bad".to_string(), collection: None, })), source_name: Some("/path".to_string()), target: Some(Ref::Child(ChildRef { name: "%bad".to_string(), collection: None, })), target_name: Some("elf!".to_string()), }), OfferDecl::Resolver(OfferResolverDecl { source: Some(Ref::Child(ChildRef { name: "^bad".to_string(), collection: None, })), source_name: Some("/path".to_string()), target: Some(Ref::Child(ChildRef { name: "%bad".to_string(), collection: None, })), target_name: Some("pkg!".to_string()), }), OfferDecl::Event(OfferEventDecl { source: Some(Ref::Realm(RealmRef {})), source_name: Some("/path".to_string()), target: Some(Ref::Child(ChildRef { name: "%bad".to_string(), collection: None, })), target_name: Some("/path".to_string()), }) ]); decl }, result = Err(ErrorList::new(vec![ Error::invalid_character_in_field("OfferServiceDecl", "source.child.name", '^'), Error::invalid_field("OfferServiceDecl", "source_path"), Error::invalid_character_in_field("OfferServiceDecl", "target.child.name", '^'), Error::invalid_field("OfferServiceDecl", "target_path"), Error::invalid_character_in_field("OfferProtocolDecl", "source.child.name", '^'), Error::invalid_field("OfferProtocolDecl", "source_path"), Error::invalid_character_in_field("OfferProtocolDecl", "target.child.name", '^'), Error::invalid_field("OfferProtocolDecl", "target_path"), Error::invalid_character_in_field("OfferDirectoryDecl", "source.child.name", '^'), Error::invalid_field("OfferDirectoryDecl", "source_path"), Error::invalid_character_in_field("OfferDirectoryDecl", "target.child.name", '^'), Error::invalid_field("OfferDirectoryDecl", "target_path"), Error::invalid_field("OfferDirectoryDecl", "subdir"), Error::invalid_character_in_field("OfferRunnerDecl", "source.child.name", '^'), Error::invalid_character_in_field("OfferRunnerDecl", "source_name", '/'), Error::invalid_character_in_field("OfferRunnerDecl", "target.child.name", '%'), Error::invalid_character_in_field("OfferRunnerDecl", "target_name", '!'), Error::invalid_character_in_field("OfferResolverDecl", "source.child.name", '^'), Error::invalid_character_in_field("OfferResolverDecl", "source_name", '/'), Error::invalid_character_in_field("OfferResolverDecl", "target.child.name", '%'), Error::invalid_character_in_field("OfferResolverDecl", "target_name", '!'), Error::invalid_character_in_field("OfferEventDecl", "source_name", '/'), Error::invalid_character_in_field("OfferEventDecl", "target.child.name", '%'), Error::invalid_character_in_field("OfferEventDecl", "target_name", '/'), ])), }, test_validate_offers_target_equals_source => { input = { let mut decl = new_component_decl(); decl.offers = Some(vec![ OfferDecl::Service(OfferServiceDecl { source: Some(Ref::Child(ChildRef { name: "logger".to_string(), collection: None, })), source_path: Some("/svc/logger".to_string()), target: Some(Ref::Child( ChildRef { name: "logger".to_string(), collection: None, } )), target_path: Some("/svc/logger".to_string()), }), OfferDecl::Protocol(OfferProtocolDecl { source: Some(Ref::Child(ChildRef { name: "logger".to_string(), collection: None, })), source_path: Some("/svc/legacy_logger".to_string()), target: Some(Ref::Child( ChildRef { name: "logger".to_string(), collection: None, } )), target_path: Some("/svc/legacy_logger".to_string()), dependency_type: Some(DependencyType::WeakForMigration), }), OfferDecl::Directory(OfferDirectoryDecl { source: Some(Ref::Child(ChildRef { name: "logger".to_string(), collection: None, })), source_path: Some("/data/assets".to_string()), target: Some(Ref::Child( ChildRef { name: "logger".to_string(), collection: None, } )), target_path: Some("/data".to_string()), rights: Some(fio2::Operations::Connect), subdir: None, dependency_type: Some(DependencyType::Strong), }), OfferDecl::Runner(OfferRunnerDecl { source: Some(Ref::Child(ChildRef { name: "logger".to_string(), collection: None, })), source_name: Some("web".to_string()), target: Some(Ref::Child( ChildRef { name: "logger".to_string(), collection: None, } )), target_name: Some("web".to_string()), }), OfferDecl::Resolver(OfferResolverDecl { source: Some(Ref::Child(ChildRef { name: "logger".to_string(), collection: None, })), source_name: Some("pkg".to_string()), target: Some(Ref::Child( ChildRef { name: "logger".to_string(), collection: None, } )), target_name: Some("pkg".to_string()), }), ]); decl.children = Some(vec![ChildDecl{ name: Some("logger".to_string()), url: Some("fuchsia-pkg://fuchsia.com/logger#meta/logger.cm".to_string()), startup: Some(StartupMode::Lazy), environment: None, }]); decl }, result = Err(ErrorList::new(vec![ Error::offer_target_equals_source("OfferServiceDecl", "logger"), Error::offer_target_equals_source("OfferProtocolDecl", "logger"), Error::offer_target_equals_source("OfferDirectoryDecl", "logger"), Error::offer_target_equals_source("OfferRunnerDecl", "logger"), Error::offer_target_equals_source("OfferResolverDecl", "logger"), ])), }, test_validate_offers_storage_target_equals_source => { input = ComponentDecl { offers: Some(vec![ OfferDecl::Storage(OfferStorageDecl { type_: Some(StorageType::Data), source: Some(Ref::Storage(StorageRef { name: "minfs".to_string(), })), target: Some(Ref::Child( ChildRef { name: "logger".to_string(), collection: None, } )), }) ]), children: Some(vec![ ChildDecl { name: Some("logger".to_string()), url: Some("fuchsia-pkg://fuchsia.com/logger/stable#meta/logger.cm".to_string()), startup: Some(StartupMode::Lazy), environment: None, }, ]), storage: Some(vec![ StorageDecl { name: Some("minfs".to_string()), source_path: Some("/minfs".to_string()), source: Some(Ref::Child(ChildRef { name: "logger".to_string(), collection: None, })), } ]), ..new_component_decl() }, result = Err(ErrorList::new(vec![ Error::offer_target_equals_source("OfferStorageDecl", "logger"), ])), }, test_validate_offers_invalid_child => { input = { let mut decl = new_component_decl(); decl.offers = Some(vec![ OfferDecl::Service(OfferServiceDecl { source: Some(Ref::Child(ChildRef { name: "logger".to_string(), collection: None, })), source_path: Some("/loggers/fuchsia.logger.Log".to_string()), target: Some(Ref::Child( ChildRef { name: "netstack".to_string(), collection: None, } )), target_path: Some("/data/realm_assets".to_string()), }), OfferDecl::Protocol(OfferProtocolDecl { source: Some(Ref::Child(ChildRef { name: "logger".to_string(), collection: None, })), source_path: Some("/loggers/fuchsia.logger.LegacyLog".to_string()), target: Some(Ref::Child( ChildRef { name: "netstack".to_string(), collection: None, } )), target_path: Some("/data/legacy_realm_assets".to_string()), dependency_type: Some(DependencyType::Strong), }), OfferDecl::Directory(OfferDirectoryDecl { source: Some(Ref::Child(ChildRef { name: "logger".to_string(), collection: None, })), source_path: Some("/data/assets".to_string()), target: Some(Ref::Collection( CollectionRef { name: "modular".to_string() } )), target_path: Some("/data".to_string()), rights: Some(fio2::Operations::Connect), subdir: None, dependency_type: Some(DependencyType::WeakForMigration), }), ]); decl.storage = Some(vec![ StorageDecl { name: Some("memfs".to_string()), source_path: Some("/memfs".to_string()), source: Some(Ref::Child(ChildRef { name: "logger".to_string(), collection: None, })), }, ]); decl.children = Some(vec![ ChildDecl { name: Some("netstack".to_string()), url: Some("fuchsia-pkg://fuchsia.com/netstack/stable#meta/netstack.cm".to_string()), startup: Some(StartupMode::Lazy), environment: None, }, ]); decl.collections = Some(vec![ CollectionDecl { name: Some("modular".to_string()), durability: Some(Durability::Persistent), }, ]); decl }, result = Err(ErrorList::new(vec![ Error::invalid_child("StorageDecl", "source", "logger"), Error::invalid_child("OfferServiceDecl", "source", "logger"), Error::invalid_child("OfferProtocolDecl", "source", "logger"), Error::invalid_child("OfferDirectoryDecl", "source", "logger"), ])), }, test_validate_offers_target_duplicate_path => { input = { let mut decl = new_component_decl(); decl.offers = Some(vec![ OfferDecl::Service(OfferServiceDecl { source: Some(Ref::Self_(SelfRef{})), source_path: Some("/svc/logger".to_string()), target: Some(Ref::Child( ChildRef { name: "netstack".to_string(), collection: None, } )), target_path: Some("/svc/fuchsia.logger.Log".to_string()), }), OfferDecl::Service(OfferServiceDecl { source: Some(Ref::Self_(SelfRef{})), source_path: Some("/svc/logger".to_string()), target: Some(Ref::Child( ChildRef { name: "netstack".to_string(), collection: None, } )), target_path: Some("/svc/fuchsia.logger.Log".to_string()), }), OfferDecl::Directory(OfferDirectoryDecl { source: Some(Ref::Self_(SelfRef{})), source_path: Some("/data/assets".to_string()), target: Some(Ref::Collection( CollectionRef { name: "modular".to_string() } )), target_path: Some("/data".to_string()), rights: Some(fio2::Operations::Connect), subdir: None, dependency_type: Some(DependencyType::Strong), }), OfferDecl::Service(OfferServiceDecl { source: Some(Ref::Self_(SelfRef{})), source_path: Some("/data/assets".to_string()), target: Some(Ref::Collection( CollectionRef { name: "modular".to_string() } )), target_path: Some("/data".to_string()), }), OfferDecl::Directory(OfferDirectoryDecl { source: Some(Ref::Self_(SelfRef{})), source_path: Some("/data/assets".to_string()), target: Some(Ref::Collection( CollectionRef { name: "modular".to_string() } )), target_path: Some("/data".to_string()), rights: Some(fio2::Operations::Connect), subdir: None, dependency_type: Some(DependencyType::WeakForMigration), }), OfferDecl::Runner(OfferRunnerDecl { source: Some(Ref::Realm(RealmRef{})), source_name: Some("elf".to_string()), target: Some(Ref::Collection( CollectionRef { name: "modular".to_string() } )), target_name: Some("duplicated".to_string()), }), OfferDecl::Runner(OfferRunnerDecl { source: Some(Ref::Realm(RealmRef{})), source_name: Some("elf".to_string()), target: Some(Ref::Collection( CollectionRef { name: "modular".to_string() } )), target_name: Some("duplicated".to_string()), }), OfferDecl::Resolver(OfferResolverDecl { source: Some(Ref::Realm(RealmRef{})), source_name: Some("pkg".to_string()), target: Some(Ref::Collection( CollectionRef { name: "modular".to_string() } )), target_name: Some("duplicated".to_string()), }), OfferDecl::Resolver(OfferResolverDecl { source: Some(Ref::Realm(RealmRef{})), source_name: Some("pkg".to_string()), target: Some(Ref::Collection( CollectionRef { name: "modular".to_string() } )), target_name: Some("duplicated".to_string()), }), OfferDecl::Event(OfferEventDecl { source: Some(Ref::Realm(RealmRef {})), source_name: Some("stopped".to_string()), target: Some(Ref::Child(ChildRef { name: "netstack".to_string(), collection: None, })), target_name: Some("started".to_string()), }), OfferDecl::Event(OfferEventDecl { source: Some(Ref::Realm(RealmRef {})), source_name: Some("started_on_x".to_string()), target: Some(Ref::Child(ChildRef { name: "netstack".to_string(), collection: None, })), target_name: Some("started".to_string()), }), ]); decl.children = Some(vec![ ChildDecl{ name: Some("netstack".to_string()), url: Some("fuchsia-pkg://fuchsia.com/netstack/stable#meta/netstack.cm".to_string()), startup: Some(StartupMode::Eager), environment: None, }, ]); decl.collections = Some(vec![ CollectionDecl{ name: Some("modular".to_string()), durability: Some(Durability::Persistent), }, ]); decl }, result = Err(ErrorList::new(vec![ Error::duplicate_field("OfferServiceDecl", "target_path", "/data"), Error::duplicate_field("OfferDirectoryDecl", "target_path", "/data"), Error::duplicate_field("OfferRunnerDecl", "target_name", "duplicated"), Error::duplicate_field("OfferResolverDecl", "target_name", "duplicated"), Error::duplicate_field("OfferEventDecl", "target_name", "started"), ])), }, test_validate_offers_target_invalid => { input = { let mut decl = new_component_decl(); decl.offers = Some(vec![ OfferDecl::Service(OfferServiceDecl { source: Some(Ref::Self_(SelfRef{})), source_path: Some("/svc/logger".to_string()), target: Some(Ref::Child( ChildRef { name: "netstack".to_string(), collection: None, } )), target_path: Some("/svc/fuchsia.logger.Log".to_string()), }), OfferDecl::Service(OfferServiceDecl { source: Some(Ref::Self_(SelfRef{})), source_path: Some("/svc/logger".to_string()), target: Some(Ref::Collection( CollectionRef { name: "modular".to_string(), } )), target_path: Some("/svc/fuchsia.logger.Log".to_string()), }), OfferDecl::Protocol(OfferProtocolDecl { source: Some(Ref::Self_(SelfRef{})), source_path: Some("/svc/legacy_logger".to_string()), target: Some(Ref::Child( ChildRef { name: "netstack".to_string(), collection: None, } )), target_path: Some("/svc/fuchsia.logger.LegacyLog".to_string()), dependency_type: Some(DependencyType::WeakForMigration), }), OfferDecl::Protocol(OfferProtocolDecl { source: Some(Ref::Self_(SelfRef{})), source_path: Some("/svc/legacy_logger".to_string()), target: Some(Ref::Collection( CollectionRef { name: "modular".to_string(), } )), target_path: Some("/svc/fuchsia.logger.LegacyLog".to_string()), dependency_type: Some(DependencyType::Strong), }), OfferDecl::Directory(OfferDirectoryDecl { source: Some(Ref::Self_(SelfRef{})), source_path: Some("/data/assets".to_string()), target: Some(Ref::Child( ChildRef { name: "netstack".to_string(), collection: None, } )), target_path: Some("/data".to_string()), rights: Some(fio2::Operations::Connect), subdir: None, dependency_type: Some(DependencyType::Strong), }), OfferDecl::Directory(OfferDirectoryDecl { source: Some(Ref::Self_(SelfRef{})), source_path: Some("/data/assets".to_string()), target: Some(Ref::Collection( CollectionRef { name: "modular".to_string(), } )), target_path: Some("/data".to_string()), rights: Some(fio2::Operations::Connect), subdir: None, dependency_type: Some(DependencyType::WeakForMigration), }), OfferDecl::Storage(OfferStorageDecl { type_: Some(StorageType::Data), source: Some(Ref::Realm(RealmRef{})), target: Some(Ref::Child( ChildRef { name: "netstack".to_string(), collection: None, } )), }), OfferDecl::Storage(OfferStorageDecl { type_: Some(StorageType::Data), source: Some(Ref::Realm(RealmRef{})), target: Some(Ref::Collection( CollectionRef { name: "modular".to_string(), } )), }), OfferDecl::Runner(OfferRunnerDecl { source: Some(Ref::Realm(RealmRef{})), source_name: Some("elf".to_string()), target: Some(Ref::Child( ChildRef { name: "netstack".to_string(), collection: None, } )), target_name: Some("elf".to_string()), }), OfferDecl::Runner(OfferRunnerDecl { source: Some(Ref::Realm(RealmRef{})), source_name: Some("elf".to_string()), target: Some(Ref::Collection( CollectionRef { name: "modular".to_string(), } )), target_name: Some("elf".to_string()), }), OfferDecl::Resolver(OfferResolverDecl { source: Some(Ref::Realm(RealmRef{})), source_name: Some("pkg".to_string()), target: Some(Ref::Child( ChildRef { name: "netstack".to_string(), collection: None, } )), target_name: Some("pkg".to_string()), }), OfferDecl::Resolver(OfferResolverDecl { source: Some(Ref::Realm(RealmRef{})), source_name: Some("pkg".to_string()), target: Some(Ref::Collection( CollectionRef { name: "modular".to_string(), } )), target_name: Some("pkg".to_string()), }), OfferDecl::Event(OfferEventDecl { source_name: Some("started".to_string()), source: Some(Ref::Realm(RealmRef {})), target_name: Some("started".to_string()), target: Some(Ref::Child( ChildRef { name: "netstack".to_string(), collection: None, } )), }), OfferDecl::Event(OfferEventDecl { source_name: Some("started".to_string()), source: Some(Ref::Realm(RealmRef {})), target_name: Some("started".to_string()), target: Some(Ref::Collection( CollectionRef { name: "modular".to_string(), } )), }), ]); decl }, result = Err(ErrorList::new(vec![ Error::invalid_child("OfferServiceDecl", "target", "netstack"), Error::invalid_collection("OfferServiceDecl", "target", "modular"), Error::invalid_child("OfferProtocolDecl", "target", "netstack"), Error::invalid_collection("OfferProtocolDecl", "target", "modular"), Error::invalid_child("OfferDirectoryDecl", "target", "netstack"), Error::invalid_collection("OfferDirectoryDecl", "target", "modular"), Error::invalid_child("OfferStorageDecl", "target", "netstack"), Error::invalid_collection("OfferStorageDecl", "target", "modular"), Error::invalid_child("OfferRunnerDecl", "target", "netstack"), Error::invalid_collection("OfferRunnerDecl", "target", "modular"), Error::invalid_child("OfferResolverDecl", "target", "netstack"), Error::invalid_collection("OfferResolverDecl", "target", "modular"), Error::invalid_child("OfferEventDecl", "target", "netstack"), Error::invalid_collection("OfferEventDecl", "target", "modular"), ])), }, test_validate_offers_event_from_realm => { input = { let mut decl = new_component_decl(); decl.offers = Some( vec![ Ref::Self_(SelfRef {}), Ref::Child(ChildRef {name: "netstack".to_string(), collection: None }), Ref::Collection(CollectionRef {name: "modular".to_string() }), Ref::Storage(StorageRef {name: "a".to_string()}), Ref::Framework(FrameworkRef {}), ] .into_iter() .enumerate() .map(|(i, source)| { OfferDecl::Event(OfferEventDecl { source: Some(source), source_name: Some("started".to_string()), target: Some(Ref::Child(ChildRef { name: "netstack".to_string(), collection: None, })), target_name: Some(format!("started_{}", i)), }) }) .collect()); decl.children = Some(vec![ ChildDecl{ name: Some("netstack".to_string()), url: Some("fuchsia-pkg://fuchsia.com/netstack/stable#meta/netstack.cm".to_string()), startup: Some(StartupMode::Eager), environment: None, }, ]); decl.collections = Some(vec![ CollectionDecl { name: Some("modular".to_string()), durability: Some(Durability::Persistent), }, ]); decl }, result = Err(ErrorList::new(vec![ Error::invalid_field("OfferEventDecl", "source"), Error::invalid_field("OfferEventDecl", "source"), Error::invalid_field("OfferEventDecl", "source"), Error::invalid_field("OfferEventDecl", "source"), Error::invalid_field("OfferEventDecl", "source"), ])), }, // environments test_validate_environment_empty => { input = { let mut decl = new_component_decl(); decl.environments = Some(vec![EnvironmentDecl { name: None, extends: None, resolvers: None, }]); decl }, result = Err(ErrorList::new(vec![ Error::missing_field("EnvironmentDecl", "name"), Error::missing_field("EnvironmentDecl", "extends"), ])), }, test_validate_environment_long_identifiers => { input = { let mut decl = new_component_decl(); decl.environments = Some(vec![EnvironmentDecl { name: Some("a".repeat(1025)), extends: Some(EnvironmentExtends::None), resolvers: None, }]); decl }, result = Err(ErrorList::new(vec![ Error::field_too_long("EnvironmentDecl", "name"), ])), }, test_validate_environment_empty_resolver_fields => { input = { let mut decl = new_component_decl(); decl.environments = Some(vec![EnvironmentDecl { name: Some("a".to_string()), extends: Some(EnvironmentExtends::None), resolvers: Some(vec![ ResolverRegistration { resolver: None, source: None, scheme: None, }, ]), }]); decl }, result = Err(ErrorList::new(vec![ Error::missing_field("ResolverRegistration", "resolver"), Error::missing_field("ResolverRegistration", "source"), Error::missing_field("ResolverRegistration", "scheme"), ])), }, test_validate_environment_long_resolver_fields => { input = { let mut decl = new_component_decl(); decl.environments = Some(vec![EnvironmentDecl { name: Some("a".to_string()), extends: Some(EnvironmentExtends::None), resolvers: Some(vec![ ResolverRegistration { resolver: Some("a".repeat(101)), source: Some(Ref::Realm(RealmRef{})), scheme: Some("a".repeat(101)), }, ]), }]); decl }, result = Err(ErrorList::new(vec![ Error::field_too_long("ResolverRegistration", "resolver"), Error::field_too_long("ResolverRegistration", "scheme"), ])), }, test_validate_environment_invalid_resolver_fields => { input = { let mut decl = new_component_decl(); decl.environments = Some(vec![EnvironmentDecl { name: Some("a".to_string()), extends: Some(EnvironmentExtends::None), resolvers: Some(vec![ ResolverRegistration { resolver: Some("^a".to_string()), source: Some(Ref::Framework(fsys::FrameworkRef{})), scheme: Some("9scheme".to_string()), }, ]), }]); decl }, result = Err(ErrorList::new(vec![ Error::invalid_character_in_field("ResolverRegistration", "resolver", '^'), Error::invalid_field("ResolverRegistration", "source"), Error::invalid_character_in_field("ResolverRegistration", "scheme", '9'), ])), }, test_validate_environment_duplicate_resolver_schemes => { input = { let mut decl = new_component_decl(); decl.environments = Some(vec![EnvironmentDecl { name: Some("a".to_string()), extends: Some(EnvironmentExtends::None), resolvers: Some(vec![ ResolverRegistration { resolver: Some("pkg_resolver".to_string()), source: Some(Ref::Realm(RealmRef{})), scheme: Some("fuchsia-pkg".to_string()), }, ResolverRegistration { resolver: Some("base_resolver".to_string()), source: Some(Ref::Realm(RealmRef{})), scheme: Some("fuchsia-pkg".to_string()), }, ]), }]); decl }, result = Err(ErrorList::new(vec![ Error::duplicate_field("ResolverRegistration", "scheme", "fuchsia-pkg"), ])), }, test_validate_environment_resolver_from_missing_child => { input = { let mut decl = new_component_decl(); decl.environments = Some(vec![EnvironmentDecl { name: Some("a".to_string()), extends: Some(EnvironmentExtends::None), resolvers: Some(vec![ ResolverRegistration { resolver: Some("pkg_resolver".to_string()), source: Some(Ref::Child(ChildRef{ name: "missing".to_string(), collection: None, })), scheme: Some("fuchsia-pkg".to_string()), }, ]), }]); decl }, result = Err(ErrorList::new(vec![ Error::invalid_child("ResolverRegistration", "source", "missing"), ])), }, test_validate_environment_resolver_child_cycle => { input = { let mut decl = new_component_decl(); decl.environments = Some(vec![EnvironmentDecl { name: Some("env".to_string()), extends: Some(EnvironmentExtends::None), resolvers: Some(vec![ ResolverRegistration { resolver: Some("pkg_resolver".to_string()), source: Some(Ref::Child(ChildRef{ name: "child".to_string(), collection: None, })), scheme: Some("fuchsia-pkg".to_string()), }, ]), }]); decl.children = Some(vec![ChildDecl { name: Some("child".to_string()), startup: Some(StartupMode::Lazy), url: Some("fuchsia-pkg://child".to_string()), environment: Some("env".to_string()), }]); decl }, result = Err(ErrorList::new(vec![ Error::cycle_detected("ResolverRegistration", "source", "child", "ChildDecl", "environment", "env"), ])), }, // children test_validate_children_empty => { input = { let mut decl = new_component_decl(); decl.children = Some(vec![ChildDecl{ name: None, url: None, startup: None, environment: None, }]); decl }, result = Err(ErrorList::new(vec![ Error::missing_field("ChildDecl", "name"), Error::missing_field("ChildDecl", "url"), Error::missing_field("ChildDecl", "startup"), ])), }, test_validate_children_invalid_identifiers => { input = { let mut decl = new_component_decl(); decl.children = Some(vec![ChildDecl{ name: Some("^bad".to_string()), url: Some("bad-scheme&://blah".to_string()), startup: Some(StartupMode::Lazy), environment: None, }]); decl }, result = Err(ErrorList::new(vec![ Error::invalid_character_in_field("ChildDecl", "name", '^'), Error::invalid_character_in_field("ChildDecl", "url", '&'), ])), }, test_validate_children_long_identifiers => { input = { let mut decl = new_component_decl(); decl.children = Some(vec![ChildDecl{ name: Some("a".repeat(1025)), url: Some(format!("fuchsia-pkg://{}", "a".repeat(4083))), startup: Some(StartupMode::Lazy), environment: Some("a".repeat(1025)), }]); decl }, result = Err(ErrorList::new(vec![ Error::field_too_long("ChildDecl", "name"), Error::field_too_long("ChildDecl", "url"), Error::field_too_long("ChildDecl", "environment"), Error::invalid_environment("ChildDecl", "environment", "a".repeat(1025)), ])), }, test_validate_child_references_unknown_env => { input = { let mut decl = new_component_decl(); decl.children = Some(vec![ChildDecl{ name: Some("foo".to_string()), url: Some("fuchsia-pkg://foo".to_string()), startup: Some(StartupMode::Lazy), environment: Some("test_env".to_string()), }]); decl }, result = Err(ErrorList::new(vec![ Error::invalid_environment("ChildDecl", "environment", "test_env"), ])), }, // collections test_validate_collections_empty => { input = { let mut decl = new_component_decl(); decl.collections = Some(vec![CollectionDecl{ name: None, durability: None, }]); decl }, result = Err(ErrorList::new(vec![ Error::missing_field("CollectionDecl", "name"), Error::missing_field("CollectionDecl", "durability"), ])), }, test_validate_collections_invalid_identifiers => { input = { let mut decl = new_component_decl(); decl.collections = Some(vec![CollectionDecl{ name: Some("^bad".to_string()), durability: Some(Durability::Persistent), }]); decl }, result = Err(ErrorList::new(vec![ Error::invalid_character_in_field("CollectionDecl", "name", '^'), ])), }, test_validate_collections_long_identifiers => { input = { let mut decl = new_component_decl(); decl.collections = Some(vec![CollectionDecl{ name: Some("a".repeat(1025)), durability: Some(Durability::Transient), }]); decl }, result = Err(ErrorList::new(vec![ Error::field_too_long("CollectionDecl", "name"), ])), }, // storage test_validate_storage_long_identifiers => { input = { let mut decl = new_component_decl(); decl.storage = Some(vec![StorageDecl{ name: Some("a".repeat(101)), source_path: Some(format!("/{}", "a".repeat(1024))), source: Some(Ref::Self_(SelfRef{})), }]); decl }, result = Err(ErrorList::new(vec![ Error::field_too_long("StorageDecl", "source_path"), Error::field_too_long("StorageDecl", "name"), ])), }, // runners test_validate_runners_empty => { input = { let mut decl = new_component_decl(); decl.runners = Some(vec![RunnerDecl{ name: None, source: None, source_path: None, }]); decl }, result = Err(ErrorList::new(vec![ Error::missing_field("RunnerDecl", "source"), Error::missing_field("RunnerDecl", "name"), Error::missing_field("RunnerDecl", "source_path"), ])), }, test_validate_runners_invalid_identifiers => { input = { let mut decl = new_component_decl(); decl.runners = Some(vec![RunnerDecl{ name: Some("^bad".to_string()), source: Some(Ref::Collection(CollectionRef { name: "/bad".to_string() })), source_path: Some("&bad".to_string()), }]); decl }, result = Err(ErrorList::new(vec![ Error::invalid_field("RunnerDecl", "source"), Error::invalid_character_in_field("RunnerDecl", "name", '^'), Error::invalid_field("RunnerDecl", "source_path"), ])), }, test_validate_runners_invalid_child => { input = { let mut decl = new_component_decl(); decl.runners = Some(vec![RunnerDecl{ name: Some("elf".to_string()), source: Some(Ref::Collection(CollectionRef { name: "invalid".to_string(), })), source_path: Some("/elf".to_string()), }]); decl }, result = Err(ErrorList::new(vec![ Error::invalid_field("RunnerDecl", "source"), ])), }, test_validate_runners_long_identifiers => { input = { let mut decl = new_component_decl(); decl.runners = Some(vec![ RunnerDecl{ name: Some("a".repeat(101)), source: Some(Ref::Child(ChildRef { name: "b".repeat(101), collection: None, })), source_path: Some(format!("/{}", "c".repeat(1024))), }, ]); decl }, result = Err(ErrorList::new(vec![ Error::field_too_long("RunnerDecl", "source.child.name"), Error::field_too_long("RunnerDecl", "name"), Error::field_too_long("RunnerDecl", "source_path"), ])), }, test_validate_runners_duplicate_name => { input = { let mut decl = new_component_decl(); decl.runners = Some(vec![ RunnerDecl { name: Some("elf".to_string()), source: Some(Ref::Self_(SelfRef{})), source_path: Some("/elf".to_string()), }, RunnerDecl { name: Some("elf".to_string()), source: Some(Ref::Self_(SelfRef{})), source_path: Some("/elf2".to_string()), }, ]); decl }, result = Err(ErrorList::new(vec![ Error::duplicate_field("RunnerDecl", "name", "elf"), ])), }, // Resolvers test_validate_resolvers_empty => { input = { let mut decl = new_component_decl(); decl.resolvers = Some(vec![ResolverDecl{ name: None, source_path: None, }]); decl }, result = Err(ErrorList::new(vec![ Error::missing_field("ResolverDecl", "name"), Error::missing_field("ResolverDecl", "source_path") ])), }, test_validate_resolvers_invalid_identifiers => { input = { let mut decl = new_component_decl(); decl.resolvers = Some(vec![ResolverDecl{ name: Some("^bad".to_string()), source_path: Some("&bad".to_string()), }]); decl }, result = Err(ErrorList::new(vec![ Error::invalid_character_in_field("ResolverDecl", "name", '^'), Error::invalid_field("ResolverDecl", "source_path") ])), }, test_validate_resolvers_long_identifiers => { input = { let mut decl = new_component_decl(); decl.resolvers = Some(vec![ResolverDecl{ name: Some("a".repeat(101)), source_path: Some(format!("/{}", "f".repeat(1024))), }]); decl }, result = Err(ErrorList::new(vec![ Error::field_too_long("ResolverDecl", "name"), Error::field_too_long("ResolverDecl", "source_path") ])), }, test_validate_resolvers_duplicate_name => { input = { let mut decl = new_component_decl(); decl.resolvers = Some(vec![ResolverDecl{ name: Some("a".to_string()), source_path: Some("/foo".to_string()), }, ResolverDecl { name: Some("a".to_string()), source_path: Some("/bar".to_string()), }]); decl }, result = Err(ErrorList::new(vec![ Error::duplicate_field("ResolverDecl", "name", "a"), ])), }, test_validate_resolvers_missing_from_offer => { input = { let mut decl = new_component_decl(); decl.offers = Some(vec![OfferDecl::Resolver(OfferResolverDecl{ source: Some(Ref::Self_(SelfRef {})), source_name: Some("a".to_string()), target: Some(Ref::Child(ChildRef { name: "child".to_string(), collection: None })), target_name: Some("a".to_string()), })]); decl.children = Some(vec![ChildDecl { name: Some("child".to_string()), url: Some("test:///child".to_string()), startup: Some(StartupMode::Eager), environment: None, }]); decl }, result = Err(ErrorList::new(vec![ Error::invalid_resolver("OfferResolverDecl", "source", "a"), ])), }, test_validate_resolvers_missing_from_expose => { input = { let mut decl = new_component_decl(); decl.exposes = Some(vec![ExposeDecl::Resolver(ExposeResolverDecl{ source: Some(Ref::Self_(SelfRef {})), source_name: Some("a".to_string()), target: Some(Ref::Realm(RealmRef {})), target_name: Some("a".to_string()), })]); decl }, result = Err(ErrorList::new(vec![ Error::invalid_resolver("ExposeResolverDecl", "source", "a"), ])), }, } }
{ let start_err_len = errors.len(); check_presence_and_length(MAX_NAME_LENGTH, prop, decl_type, keyword, errors); if let Some(name) = prop { for b in name.bytes() { match b as char { '0'..='9' | 'a'..='z' | '_' | '-' | '.' => (), c => { errors.push(Error::invalid_character_in_field(decl_type, keyword, c)); return false; } } } } start_err_len == errors.len() }
env_test.go
package opts
"testing" ) func TestParseEnv(t *testing.T) { type args struct { env []string } tests := []struct { name string args args want map[string]string wantErr bool }{ // TODO: Add test cases. {name: "test1", args: args{env: []string{"foo=bar"}}, want: map[string]string{"foo": "bar"}, wantErr: false}, {name: "test2", args: args{env: []string{"ErrorInfo"}}, want: nil, wantErr: true}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { got, err := ParseEnv(tt.args.env) if (err != nil) != tt.wantErr { t.Errorf("ParseEnv() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(got, tt.want) { t.Errorf("ParseEnv() = %v, want %v", got, tt.want) } }) } }
import ( "reflect"
role.py
from ... import BaseModel, db class
(BaseModel): __tablename__ = "role" id = db.Column(db.Integer(), primary_key=True, autoincrement=True) name = db.Column(db.String()) can_triage_jobs = db.Column(db.Boolean()) can_edit_settings = db.Column(db.Boolean()) can_create_users = db.Column(db.Boolean()) can_create_groups = db.Column(db.Boolean()) can_edit_roles = db.Column(db.Boolean()) can_manage_infrastructure = db.Column(db.Boolean()) def __str__(self): return ( f"<Role id: {self.id}, name: {self.name}, " f"can_triage_jobs: {self.can_triage_jobs}, " f"can_edit_settings: {self.can_edit_settings}, " f"can_create_users: {self.can_create_users}, " f"can_create_groups: {self.can_create_groups}, " f"can_edit_roles: {self.can_edit_roles}, " f"can_manage_infrastructure: {self.can_manage_infrastructure}>" )
Role
can_datagram.py
# pylint: skip-file """This client script handles datagram protocol communication between devices on the CAN.""" import zlib import can DEFAULT_CHANNEL = "can0" PROT_VER = 1 CAN_BITRATE = 500000 MESSAGE_SIZE = 8 HEADER_SIZE = 6 MIN_BYTEARRAY_SIZE = 9 DATA_SIZE_SIZE = 2 PROTOCOL_VERSION_OFFSET = 0 CRC_32_OFFSET = 1 DATAGRAM_TYPE_OFFSET = 5 NUM_NODE_ID_OFFSET = 6 NODE_ID_OFFSET = 7 CAN_START_ARBITRATION_ID = 0b00000010000 CAN_ARBITRATION_ID = 0b00000000000 class DatagramTypeError(Exception): pass class Datagram: """This class acts as an easy modular interface for a datagram.""" def __init__(self, **kwargs): self._check_kwargs(**kwargs) self._protocol_version = PROT_VER & 0xff self._datagram_type_id = kwargs["datagram_type_id"] & 0xff self._node_ids = [] for val in kwargs["node_ids"]: self._node_ids.append(val & 0xff) self._data = kwargs["data"] @classmethod def deserialize(cls, datagram_bytearray): """This function returns an instance of the class from a bytearray.""" assert isinstance(datagram_bytearray, bytearray) # "theoretical" lower limit: # 1 (prot) + 4 (crc32) + 1 (type) + 1 (num nodes) + 0 (nodes) + 2 (data size) + 0 (data) # = 9 if len(datagram_bytearray) < MIN_BYTEARRAY_SIZE: raise DatagramTypeError( "Invalid Datagram format from bytearray: Does not meet minimum size requirement") protocol_version = datagram_bytearray[PROTOCOL_VERSION_OFFSET] crc32 = datagram_bytearray[CRC_32_OFFSET:DATAGRAM_TYPE_OFFSET] datagram_type_id = datagram_bytearray[DATAGRAM_TYPE_OFFSET] num_node_ids = datagram_bytearray[NUM_NODE_ID_OFFSET] if len(datagram_bytearray) < MIN_BYTEARRAY_SIZE + num_node_ids: raise DatagramTypeError("Invalid Datagram format from bytearray: Not enough node ids") node_ids = list(datagram_bytearray[NODE_ID_OFFSET:NODE_ID_OFFSET + num_node_ids]) data_size = cls._convert_from_bytearray( datagram_bytearray[NODE_ID_OFFSET + num_node_ids:], 2) if len(datagram_bytearray) != MIN_BYTEARRAY_SIZE + num_node_ids + data_size: raise DatagramTypeError("Invalid Datagram format from bytearray: Not enough data bytes") data = datagram_bytearray[NODE_ID_OFFSET + num_node_ids + DATA_SIZE_SIZE:] exp_crc32 = cls._calculate_crc32(cls, datagram_type_id, node_ids, data) if exp_crc32 != crc32: raise DatagramTypeError("Invalid Datagram format from bytearray: Invalid crc32") return cls(protocol_version=protocol_version, datagram_type_id=datagram_type_id, node_ids=node_ids, data=data) def serialize(self): """This function returns a bytearray based on set data.""" crc32 = self._calculate_crc32(self._datagram_type_id, self._node_ids, self._data) # Update the bytearray return bytearray([self._protocol_version, *crc32, self._datagram_type_id, len(self._node_ids), *(self._node_ids), len(self._data) & 0xff, (len(self._data) >> 8) & 0xff, *(self._data)]) # Accessors and mutators for the datagram @property def protocol_version(self): """This function describes the protocol version property.""" return self._protocol_version @protocol_version.setter def protocol_version(self, value): """This function sets the protocol version.""" assert value & 0xff == value self._protocol_version = value & 0xff @property def datagram_type_id(self): """This function describes the datagram type id property.""" return self._datagram_type_id @datagram_type_id.setter def datagram_type_id(self, value): """This function sets the datagram type id.""" assert value & 0xff == value self._datagram_type_id = value & 0xff @property def node_ids(self): """This function describes the node ids property.""" return self._node_ids @node_ids.setter def node_ids(self, value): """This function sets the node ids.""" assert isinstance(value, list) assert all(0 <= val < 0xff for val in value) self._node_ids = value @property def data(self): return self._data @data.setter def data(self, value): """This function sets the data.""" assert isinstance(value, bytearray) self._data = value @staticmethod def _check_kwargs(**kwargs):
args = [ "datagram_type_id", "node_ids", "data"] # Check all arguments are present for arg in args: assert arg in kwargs # Check that types are as expected assert not isinstance(kwargs["datagram_type_id"], list) assert isinstance(kwargs["node_ids"], list) assert isinstance(kwargs["data"], bytearray) # Verify all inputs assert kwargs["datagram_type_id"] & 0xff == kwargs["datagram_type_id"] @staticmethod def _convert_to_bytearray(in_value, bytes): """This is a helper function that creates a little-endian bytearray""" out_bytearray = bytearray() for i in range(bytes): out_bytearray.append((in_value >> (8 * i)) & 0xff) return out_bytearray @staticmethod def _convert_from_bytearray(in_bytearray, bytes): """This is a helper function that converts a bytearray into a value""" value = 0 for i in range(bytes): value = value | ((in_bytearray[i] & 0xff) << (i * 8)) return value def _calculate_crc32(self, datagram_type_id, node_ids, data): """This function returns a bytearray based on set data.""" node_crc32 = zlib.crc32(bytearray(node_ids)) node_crc32 = self._convert_to_bytearray(node_crc32, 4) data_crc32 = zlib.crc32(data) data_crc32 = self._convert_to_bytearray(data_crc32, 4) crc32_array = bytearray([datagram_type_id, len(node_ids), *node_crc32, len(data) & 0xff, (len(data) >> 8) & 0xff, *data_crc32]) # Update the crc32 crc32 = zlib.crc32(crc32_array) crc32 = self._convert_to_bytearray(crc32, 4) # Update the bytearray return crc32 class DatagramSender: """A class that acts as a distributor for the Datagram class on a bus.""" def __init__(self, bustype="socketcan", channel=DEFAULT_CHANNEL, bitrate=CAN_BITRATE, receive_own_messages=False): self.bus = can.interface.Bus( bustype=bustype, channel=channel, bitrate=bitrate, receive_own_messages=receive_own_messages) def send(self, message, sender_id=0): """Sends the Datagrams.""" assert isinstance(message, Datagram) chunk_messages = self._chunkify(message.serialize(), 8) message_extended_arbitration = False start_arbitration_board_id = (CAN_START_ARBITRATION_ID | sender_id << 5) arbitration_board_id = (CAN_ARBITRATION_ID | sender_id << 5) can_messages = [ can.Message( arbitration_id=start_arbitration_board_id, data=bytearray(), is_extended_id=message_extended_arbitration)] # Populate an array with the can message from the library for chunk_message in chunk_messages: can_messages.append(can.Message(arbitration_id=arbitration_board_id, data=chunk_message, is_extended_id=message_extended_arbitration)) # Send the messages for msg in can_messages: self.bus.send(msg) print("{} messages were sent on {}".format(len(can_messages), self.bus.channel_info)) def _chunkify(self, data, size): """This chunks up the datagram bytearray for easy iteration.""" return (data[pos:pos + size] for pos in range(0, len(data), size)) class DatagramListener(can.BufferedReader): """A class that handles a callback when a datagram is received.""" def __init__(self, callback): """Registers the callback.""" assert callable(callback) self.callback = callback # Messages are stored in a dictionary where key = board ID, value = message self.datagram_messages = {} super().__init__() def on_message_received(self, msg: can.Message): """Handles message sent from boards on the CAN.""" super().on_message_received(msg) board_id = (msg.arbitration_id & 0b11111100000) >> 5 start_message = (msg.arbitration_id & 0x10) >> 4 if start_message == 1: # Reset the datagram message when receiving a start message self.datagram_messages[board_id] = msg.data if start_message == 0: if board_id in self.datagram_messages: self.datagram_messages[board_id] += msg.data try: datagram = Datagram.deserialize(self.datagram_messages[board_id]) except DatagramTypeError: # Datagram is incomplete, continue until complete pass else: # Datagram is complete, call the callback with formed datagram self.callback(datagram, board_id)
"""This function checks that all variables are as expected"""
blinky.rs
#![no_main] #![no_std] // panicking behavior extern crate panic_halt; // board support extern crate solo_bsc as board; use board::stm32; use board::hal::prelude::*; use board::hal::delay; use board::led::{Color, Leds}; #[board::entry] fn main() -> ! { let core = cortex_m::Peripherals::take().unwrap(); let device = stm32::Peripherals::take().unwrap(); let mut flash = device.FLASH.constrain(); let mut rcc = device.RCC.constrain(); let clocks = rcc.cfgr .hclk(8.mhz()) .freeze(&mut flash.acr); let gpioa = device.GPIOA.split(&mut rcc.ahb2); let mut leds = Leds::new(gpioa); // let mut gpiob = device.GPIOB.split(&mut rcc.ahb2); // let mut led = gpiob.pb3.into_push_pull_output(&mut gpiob.moder, &mut gpiob.otyper);
let mut timer = delay::Delay::new(core.SYST, clocks); let second: u32 = 100; loop { // led.set_high(); // timer.delay_ms(second); // led.set_low(); // timer.delay_ms(second); leds[Color::Red].on(); timer.delay_ms(second); leds[Color::Red].off(); timer.delay_ms(second); leds[Color::Green].on(); timer.delay_ms(second); leds[Color::Green].off(); timer.delay_ms(second); leds[Color::Blue].on(); timer.delay_ms(second); leds[Color::Blue].off(); timer.delay_ms(second); } }
lib.rs
// DO NOT EDIT ! // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! //! This documentation was generated from *Cloud Functions* crate version *1.0.14+20200629*, where *20200629* is the exact revision of the *cloudfunctions:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v1.0.14*. //! //! Everything else about the *Cloud Functions* *v1* API can be found at the //! [official documentation site](https://cloud.google.com/functions). //! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/cloudfunctions1). //! # Features //! //! Handle the following *Resources* with ease from the central [hub](struct.CloudFunctions.html) ... //! //! * [operations](struct.Operation.html) //! * [*get*](struct.OperationGetCall.html) and [*list*](struct.OperationListCall.html) //! * projects //! * [*locations functions call*](struct.ProjectLocationFunctionCallCall.html), [*locations functions create*](struct.ProjectLocationFunctionCreateCall.html), [*locations functions delete*](struct.ProjectLocationFunctionDeleteCall.html), [*locations functions generate download url*](struct.ProjectLocationFunctionGenerateDownloadUrlCall.html), [*locations functions generate upload url*](struct.ProjectLocationFunctionGenerateUploadUrlCall.html), [*locations functions get*](struct.ProjectLocationFunctionGetCall.html), [*locations functions get iam policy*](struct.ProjectLocationFunctionGetIamPolicyCall.html), [*locations functions list*](struct.ProjectLocationFunctionListCall.html), [*locations functions patch*](struct.ProjectLocationFunctionPatchCall.html), [*locations functions set iam policy*](struct.ProjectLocationFunctionSetIamPolicyCall.html), [*locations functions test iam permissions*](struct.ProjectLocationFunctionTestIamPermissionCall.html) and [*locations list*](struct.ProjectLocationListCall.html) //! //! //! //! //! Not what you are looking for ? Find all other Google APIs in their Rust [documentation index](http://byron.github.io/google-apis-rs). //! //! # Structure of this Library //! //! The API is structured into the following primary items: //! //! * **[Hub](struct.CloudFunctions.html)** //! * a central object to maintain state and allow accessing all *Activities* //! * creates [*Method Builders*](trait.MethodsBuilder.html) which in turn //! allow access to individual [*Call Builders*](trait.CallBuilder.html) //! * **[Resources](trait.Resource.html)** //! * primary types that you can apply *Activities* to //! * a collection of properties and *Parts* //! * **[Parts](trait.Part.html)** //! * a collection of properties //! * never directly used in *Activities* //! * **[Activities](trait.CallBuilder.html)** //! * operations to apply to *Resources* //! //! All *structures* are marked with applicable traits to further categorize them and ease browsing. //! //! Generally speaking, you can invoke *Activities* like this: //! //! ```Rust,ignore //! let r = hub.resource().activity(...).doit() //! ``` //! //! Or specifically ... //! //! ```ignore //! let r = hub.projects().locations_functions_patch(...).doit() //! let r = hub.operations().list(...).doit() //! let r = hub.operations().get(...).doit() //! let r = hub.projects().locations_functions_delete(...).doit() //! let r = hub.projects().locations_functions_create(...).doit() //! ``` //! //! The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities` //! supports various methods to configure the impending operation (not shown here). It is made such that all required arguments have to be //! specified right away (i.e. `(...)`), whereas all optional ones can be [build up][builder-pattern] as desired. //! The `doit()` method performs the actual communication with the server and returns the respective result. //! //! # Usage //! //! ## Setting up your Project //! //! To use this library, you would put the following lines into your `Cargo.toml` file: //! //! ```toml //! [dependencies] //! google-cloudfunctions1 = "*" //! # This project intentionally uses an old version of Hyper. See //! # https://github.com/Byron/google-apis-rs/issues/173 for more //! # information. //! hyper = "^0.10" //! hyper-rustls = "^0.6" //! serde = "^1.0" //! serde_json = "^1.0" //! yup-oauth2 = "^1.0" //! ``` //! //! ## A complete example //! //! ```test_harness,no_run //! extern crate hyper; //! extern crate hyper_rustls; //! extern crate yup_oauth2 as oauth2; //! extern crate google_cloudfunctions1 as cloudfunctions1; //! use cloudfunctions1::{Result, Error}; //! # #[test] fn egal() { //! use std::default::Default; //! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; //! use cloudfunctions1::CloudFunctions; //! //! // Get an ApplicationSecret instance by some means. It contains the `client_id` and //! // `client_secret`, among other things. //! let secret: ApplicationSecret = Default::default(); //! // Instantiate the authenticator. It will choose a suitable authentication flow for you, //! // unless you replace `None` with the desired Flow. //! // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about //! // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and //! // retrieve them from storage. //! let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, //! hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), //! <MemoryStorage as Default>::default(), None); //! let mut hub = CloudFunctions::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth); //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! //! let result = hub.operations().list() //! .page_token("et") //! .page_size(-18) //! .name("kasd") //! .filter("accusam") //! .doit(); //! //! match result { //! Err(e) => match e { //! // The Error enum provides details about what exactly happened. //! // You can also just use its `Debug`, `Display` or `Error` traits //! Error::HttpError(_) //! |Error::MissingAPIKey //! |Error::MissingToken(_) //! |Error::Cancelled //! |Error::UploadSizeLimitExceeded(_, _) //! |Error::Failure(_) //! |Error::BadRequest(_) //! |Error::FieldClash(_) //! |Error::JsonDecodeError(_, _) => println!("{}", e), //! }, //! Ok(res) => println!("Success: {:?}", res), //! } //! # } //! ``` //! ## Handling Errors //! //! All errors produced by the system are provided either as [Result](enum.Result.html) enumeration as return value of //! the doit() methods, or handed as possibly intermediate results to either the //! [Hub Delegate](trait.Delegate.html), or the [Authenticator Delegate](https://docs.rs/yup-oauth2/*/yup_oauth2/trait.AuthenticatorDelegate.html). //! //! When delegates handle errors or intermediate values, they may have a chance to instruct the system to retry. This //! makes the system potentially resilient to all kinds of errors. //! //! ## Uploads and Downloads //! If a method supports downloads, the response body, which is part of the [Result](enum.Result.html), should be //! read by you to obtain the media. //! If such a method also supports a [Response Result](trait.ResponseResult.html), it will return that by default. //! You can see it as meta-data for the actual media. To trigger a media download, you will have to set up the builder by making //! this call: `.param("alt", "media")`. //! //! Methods supporting uploads can do so using up to 2 different protocols: //! *simple* and *resumable*. The distinctiveness of each is represented by customized //! `doit(...)` methods, which are then named `upload(...)` and `upload_resumable(...)` respectively. //! //! ## Customization and Callbacks //! //! You may alter the way an `doit()` method is called by providing a [delegate](trait.Delegate.html) to the //! [Method Builder](trait.CallBuilder.html) before making the final `doit()` call. //! Respective methods will be called to provide progress information, as well as determine whether the system should //! retry on failure. //! //! The [delegate trait](trait.Delegate.html) is default-implemented, allowing you to customize it with minimal effort. //! //! ## Optional Parts in Server-Requests //! //! All structures provided by this library are made to be [encodable](trait.RequestValue.html) and //! [decodable](trait.ResponseResult.html) via *json*. Optionals are used to indicate that partial requests are responses //! are valid. //! Most optionals are are considered [Parts](trait.Part.html) which are identifiable by name, which will be sent to //! the server to indicate either the set parts of the request or the desired parts in the response. //! //! ## Builder Arguments //! //! Using [method builders](trait.CallBuilder.html), you are able to prepare an action call by repeatedly calling it's methods. //! These will always take a single argument, for which the following statements are true. //! //! * [PODs][wiki-pod] are handed by copy //! * strings are passed as `&str` //! * [request values](trait.RequestValue.html) are moved //! //! Arguments will always be copied or cloned into the builder, to make them independent of their original life times. //! //! [wiki-pod]: http://en.wikipedia.org/wiki/Plain_old_data_structure //! [builder-pattern]: http://en.wikipedia.org/wiki/Builder_pattern //! [google-go-api]: https://github.com/google/google-api-go-client //! //! // Unused attributes happen thanks to defined, but unused structures // We don't warn about this, as depending on the API, some data structures or facilities are never used. // Instead of pre-determining this, we just disable the lint. It's manually tuned to not have any // unused imports in fully featured APIs. Same with unused_mut ... . #![allow(unused_imports, unused_mut, dead_code)] // DO NOT EDIT ! // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! #[macro_use] extern crate serde_derive; extern crate hyper; extern crate serde; extern crate serde_json; extern crate yup_oauth2 as oauth2; extern crate mime; extern crate url; mod cmn; use std::collections::HashMap; use std::cell::RefCell; use std::borrow::BorrowMut; use std::default::Default; use std::collections::BTreeMap; use serde_json as json; use std::io; use std::fs; use std::mem; use std::thread::sleep; use std::time::Duration; pub use cmn::*; // ############## // UTILITIES ### // ############ /// Identifies the an OAuth2 authorization scope. /// A scope is needed when requesting an /// [authorization token](https://developers.google.com/youtube/v3/guides/authentication). #[derive(PartialEq, Eq, Hash)] pub enum Scope { /// View and manage your data across Google Cloud Platform services CloudPlatform, } impl AsRef<str> for Scope { fn as_ref(&self) -> &str { match *self { Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform", } } } impl Default for Scope { fn default() -> Scope { Scope::CloudPlatform } } // ######## // HUB ### // ###### /// Central instance to access all CloudFunctions related resource activities /// /// # Examples /// /// Instantiate a new hub /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate yup_oauth2 as oauth2; /// extern crate google_cloudfunctions1 as cloudfunctions1; /// use cloudfunctions1::{Result, Error}; /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// use cloudfunctions1::CloudFunctions; /// /// // Get an ApplicationSecret instance by some means. It contains the `client_id` and /// // `client_secret`, among other things. /// let secret: ApplicationSecret = Default::default(); /// // Instantiate the authenticator. It will choose a suitable authentication flow for you, /// // unless you replace `None` with the desired Flow. /// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about /// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and /// // retrieve them from storage. /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), /// <MemoryStorage as Default>::default(), None); /// let mut hub = CloudFunctions::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.operations().list() /// .page_token("takimata") /// .page_size(-70) /// .name("amet.") /// .filter("erat") /// .doit(); /// /// match result { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits /// Error::HttpError(_) /// |Error::MissingAPIKey /// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) /// |Error::BadRequest(_) /// |Error::FieldClash(_) /// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } /// # } /// ``` pub struct CloudFunctions<C, A> { client: RefCell<C>, auth: RefCell<A>, _user_agent: String, _base_url: String, _root_url: String, } impl<'a, C, A> Hub for CloudFunctions<C, A> {} impl<'a, C, A> CloudFunctions<C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { pub fn new(client: C, authenticator: A) -> CloudFunctions<C, A> { CloudFunctions { client: RefCell::new(client), auth: RefCell::new(authenticator), _user_agent: "google-api-rust-client/1.0.14".to_string(), _base_url: "https://cloudfunctions.googleapis.com/".to_string(), _root_url: "https://cloudfunctions.googleapis.com/".to_string(), } } pub fn operations(&'a self) -> OperationMethods<'a, C, A> { OperationMethods { hub: &self } } pub fn projects(&'a self) -> ProjectMethods<'a, C, A> { ProjectMethods { hub: &self } } /// Set the user-agent header field to use in all requests to the server. /// It defaults to `google-api-rust-client/1.0.14`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { mem::replace(&mut self._user_agent, agent_name) } /// Set the base url to use in all requests to the server. /// It defaults to `https://cloudfunctions.googleapis.com/`. /// /// Returns the previously set base url. pub fn base_url(&mut self, new_base_url: String) -> String { mem::replace(&mut self._base_url, new_base_url) } /// Set the root url to use in all requests to the server. /// It defaults to `https://cloudfunctions.googleapis.com/`. /// /// Returns the previously set root url. pub fn root_url(&mut self, new_root_url: String) -> String { mem::replace(&mut self._root_url, new_root_url) } } // ############ // SCHEMAS ### // ########## /// Request for the `CallFunction` method. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [locations functions call projects](struct.ProjectLocationFunctionCallCall.html) (request) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CallFunctionRequest { /// Required. Input to be passed to the function. pub data: Option<String>, } impl RequestValue for CallFunctionRequest {} /// Describes EventTrigger, used to request events be sent from another /// service. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct EventTrigger { /// Required. The type of event to observe. For example: /// `providers/cloud.storage/eventTypes/object.change` and /// `providers/cloud.pubsub/eventTypes/topic.publish`. /// /// Event types match pattern `providers/*/eventTypes/*.*`. /// The pattern contains: /// /// 1. namespace: For example, `cloud.storage` and /// `google.firebase.analytics`. /// 2. resource type: The type of resource on which event occurs. For /// example, the Google Cloud Storage API includes the type `object`. /// 3. action: The action that generates the event. For example, action for /// a Google Cloud Storage Object is 'change'. /// These parts are lower case. #[serde(rename="eventType")] pub event_type: Option<String>, /// Required. The resource(s) from which to observe events, for example, /// `projects/_/buckets/myBucket`. /// /// Not all syntactically correct values are accepted by all services. For /// example: /// /// 1. The authorization model must support it. Google Cloud Functions /// only allows EventTriggers to be deployed that observe resources in the /// same project as the `CloudFunction`. /// 2. The resource type must match the pattern expected for an /// `event_type`. For example, an `EventTrigger` that has an /// `event_type` of "google.pubsub.topic.publish" should have a resource /// that matches Google Cloud Pub/Sub topics. /// /// Additionally, some services may support short names when creating an /// `EventTrigger`. These will always be returned in the normalized "long" /// format. /// /// See each *service's* documentation for supported formats. pub resource: Option<String>, /// The hostname of the service that should be observed. /// /// If no string is provided, the default service implementing the API will /// be used. For example, `storage.googleapis.com` is the default for all /// event types in the `google.storage` namespace. pub service: Option<String>, /// Specifies policy for failed executions. #[serde(rename="failurePolicy")] pub failure_policy: Option<FailurePolicy>, } impl Part for EventTrigger {} /// Describes the retry policy in case of function's execution failure. /// A function execution will be retried on any failure. /// A failed execution will be retried up to 7 days with an exponential backoff /// (capped at 10 seconds). /// Retried execution is charged as any other execution. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Retry { _never_set: Option<bool> } impl Part for Retry {} /// Request message for `TestIamPermissions` method. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [locations functions test iam permissions projects](struct.ProjectLocationFunctionTestIamPermissionCall.html) (request) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TestIamPermissionsRequest { /// The set of permissions to check for the `resource`. Permissions with /// wildcards (such as '*' or 'storage.*') are not allowed. For more /// information see /// [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). pub permissions: Option<Vec<String>>, } impl RequestValue for TestIamPermissionsRequest {} /// Request message for `SetIamPolicy` method. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [locations functions set iam policy projects](struct.ProjectLocationFunctionSetIamPolicyCall.html) (request) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SetIamPolicyRequest { /// REQUIRED: The complete policy to be applied to the `resource`. The size of /// the policy is limited to a few 10s of KB. An empty policy is a /// valid policy but certain Cloud Platform services (such as Projects) /// might reject them. pub policy: Option<Policy>, /// OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only /// the fields in the mask will be modified. If no mask is provided, the /// following default mask is used: /// /// `paths: "bindings, etag"` #[serde(rename="updateMask")] pub update_mask: Option<String>, } impl RequestValue for SetIamPolicyRequest {} /// Represents a textual expression in the Common Expression Language (CEL) /// syntax. CEL is a C-like expression language. The syntax and semantics of CEL /// are documented at https://github.com/google/cel-spec. /// /// Example (Comparison): /// /// ````text /// title: "Summary size limit" /// description: "Determines if a summary is less than 100 chars" /// expression: "document.summary.size() < 100" /// ```` /// /// Example (Equality): /// /// ````text /// title: "Requestor is owner" /// description: "Determines if requestor is the document owner" /// expression: "document.owner == request.auth.claims.email" /// ```` /// /// Example (Logic): /// /// ````text /// title: "Public documents" /// description: "Determine whether the document should be publicly visible" /// expression: "document.type != 'private' && document.type != 'internal'" /// ```` /// /// Example (Data Manipulation): /// /// ````text /// title: "Notification string" /// description: "Create a notification string with a timestamp." /// expression: "'New message received at ' + string(document.create_time)" /// ```` /// /// The exact variables and functions that may be referenced within an expression /// are determined by the service that evaluates it. See the service /// documentation for additional information. /// /// This type is not used in any activity, and only used as *part* of another schema. #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Expr { /// Optional. Description of the expression. This is a longer text which /// describes the expression, e.g. when hovered over it in a UI. pub description: Option<String>, /// Textual representation of an expression in Common Expression Language /// syntax. pub expression: Option<String>, /// Optional. String indicating the location of the expression for error /// reporting, e.g. a file name and a position in the file. pub location: Option<String>, /// Optional. Title for the expression, i.e. a short string describing /// its purpose. This can be used e.g. in UIs which allow to enter the /// expression. pub title: Option<String>, } impl Part for Expr {} /// Provides the configuration for logging a type of permissions. /// Example: /// /// ````text /// { /// "audit_log_configs": [ /// { /// "log_type": "DATA_READ", /// "exempted_members": [ /// "user:[email protected]" /// ] /// }, /// { /// "log_type": "DATA_WRITE" /// } /// ] /// } /// ```` /// /// This enables 'DATA_READ' and 'DATA_WRITE' logging, while exempting /// [email protected] from DATA_READ logging. /// /// This type is not used in any activity, and only used as *part* of another schema. #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AuditLogConfig { /// Specifies the identities that do not cause logging for this type of /// permission. /// Follows the same format of Binding.members. #[serde(rename="exemptedMembers")] pub exempted_members: Option<Vec<String>>, /// The log type that this config enables. #[serde(rename="logType")] pub log_type: Option<String>, } impl Part for AuditLogConfig {} /// Response of `GenerateSourceUploadUrl` method. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [locations functions generate upload url projects](struct.ProjectLocationFunctionGenerateUploadUrlCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GenerateUploadUrlResponse { /// The generated Google Cloud Storage signed URL that should be used for a /// function source code upload. The uploaded file should be a zip archive /// which contains a function. #[serde(rename="uploadUrl")] pub upload_url: Option<String>, } impl ResponseResult for GenerateUploadUrlResponse {} /// The response message for Locations.ListLocations. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [locations list projects](struct.ProjectLocationListCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListLocationsResponse { /// The standard List next-page token. #[serde(rename="nextPageToken")] pub next_page_token: Option<String>, /// A list of locations that matches the specified filter in the request. pub locations: Option<Vec<Location>>, } impl ResponseResult for ListLocationsResponse {} /// A resource that represents Google Cloud Platform location. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Location { /// The friendly name for this location, typically a nearby city name. /// For example, "Tokyo". #[serde(rename="displayName")] pub display_name: Option<String>, /// Cross-service attributes for the location. For example /// /// ````text /// {"cloud.googleapis.com/region": "us-east1"}```` pub labels: Option<HashMap<String, String>>, /// The canonical id for this location. For example: `"us-east1"`. #[serde(rename="locationId")] pub location_id: Option<String>, /// Resource name for the location, which may vary between implementations. /// For example: `"projects/example-project/locations/us-east1"` pub name: Option<String>, /// Service-specific metadata. For example the available capacity at the given /// location. pub metadata: Option<HashMap<String, String>>, } impl Part for Location {} /// An Identity and Access Management (IAM) policy, which specifies access /// controls for Google Cloud resources. /// /// A `Policy` is a collection of `bindings`. A `binding` binds one or more /// `members` to a single `role`. Members can be user accounts, service accounts, /// Google groups, and domains (such as G Suite). A `role` is a named list of /// permissions; each `role` can be an IAM predefined role or a user-created /// custom role. /// /// For some types of Google Cloud resources, a `binding` can also specify a /// `condition`, which is a logical expression that allows access to a resource /// only if the expression evaluates to `true`. A condition can add constraints /// based on attributes of the request, the resource, or both. To learn which /// resources support conditions in their IAM policies, see the /// [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies). /// /// **JSON example:** /// /// ````text /// { /// "bindings": [ /// { /// "role": "roles/resourcemanager.organizationAdmin", /// "members": [ /// "user:[email protected]", /// "group:[email protected]", /// "domain:google.com", /// "serviceAccount:[email protected]" /// ] /// }, /// { /// "role": "roles/resourcemanager.organizationViewer", /// "members": [ /// "user:[email protected]" /// ], /// "condition": { /// "title": "expirable access", /// "description": "Does not grant access after Sep 2020", /// "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", /// } /// } /// ], /// "etag": "BwWWja0YfJA=", /// "version": 3 /// } /// ```` /// /// **YAML example:** /// /// ````text /// bindings: /// - members: /// - user:[email protected] /// - group:[email protected] /// - domain:google.com /// - serviceAccount:[email protected] /// role: roles/resourcemanager.organizationAdmin /// - members: /// - user:[email protected] /// role: roles/resourcemanager.organizationViewer /// condition: /// title: expirable access /// description: Does not grant access after Sep 2020 /// expression: request.time < timestamp('2020-10-01T00:00:00.000Z') /// - etag: BwWWja0YfJA= /// - version: 3 /// ```` /// /// For a description of IAM and its features, see the /// [IAM documentation](https://cloud.google.com/iam/docs/). /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [locations functions set iam policy projects](struct.ProjectLocationFunctionSetIamPolicyCall.html) (response) /// * [locations functions get iam policy projects](struct.ProjectLocationFunctionGetIamPolicyCall.html) (response) #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Policy { /// Specifies cloud audit logging configuration for this policy. #[serde(rename="auditConfigs")] pub audit_configs: Option<Vec<AuditConfig>>, /// `etag` is used for optimistic concurrency control as a way to help /// prevent simultaneous updates of a policy from overwriting each other. /// It is strongly suggested that systems make use of the `etag` in the /// read-modify-write cycle to perform policy updates in order to avoid race /// conditions: An `etag` is returned in the response to `getIamPolicy`, and /// systems are expected to put that etag in the request to `setIamPolicy` to /// ensure that their change will be applied to the same version of the policy. /// /// **Important:** If you use IAM Conditions, you must include the `etag` field /// whenever you call `setIamPolicy`. If you omit this field, then IAM allows /// you to overwrite a version `3` policy with a version `1` policy, and all of /// the conditions in the version `3` policy are lost. pub etag: Option<String>, /// Associates a list of `members` to a `role`. Optionally, may specify a /// `condition` that determines how and when the `bindings` are applied. Each /// of the `bindings` must contain at least one member. pub bindings: Option<Vec<Binding>>, /// Specifies the format of the policy. /// /// Valid values are `0`, `1`, and `3`. Requests that specify an invalid value /// are rejected. /// /// Any operation that affects conditional role bindings must specify version /// `3`. This requirement applies to the following operations: /// /// * Getting a policy that includes a conditional role binding /// * Adding a conditional role binding to a policy /// * Changing a conditional role binding in a policy /// * Removing any role binding, with or without a condition, from a policy /// that includes conditions /// /// **Important:** If you use IAM Conditions, you must include the `etag` field /// whenever you call `setIamPolicy`. If you omit this field, then IAM allows /// you to overwrite a version `3` policy with a version `1` policy, and all of /// the conditions in the version `3` policy are lost. /// /// If a policy does not include any conditions, operations on that policy may /// specify any valid version or leave the field unset. /// /// To learn which resources support conditions in their IAM policies, see the /// [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies). pub version: Option<i32>, } impl ResponseResult for Policy {} /// Response of `CallFunction` method. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [locations functions call projects](struct.ProjectLocationFunctionCallCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CallFunctionResponse { /// Execution id of function invocation. #[serde(rename="executionId")] pub execution_id: Option<String>, /// Result populated for successful execution of synchronous function. Will /// not be populated if function does not return a result through context. pub result: Option<String>, /// Either system or user-function generated error. Set if execution /// was not successful. pub error: Option<String>, } impl ResponseResult for CallFunctionResponse {} /// This resource represents a long-running operation that is the result of a /// network API call. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [locations functions patch projects](struct.ProjectLocationFunctionPatchCall.html) (response) /// * [list operations](struct.OperationListCall.html) (none) /// * [get operations](struct.OperationGetCall.html) (response) /// * [locations functions delete projects](struct.ProjectLocationFunctionDeleteCall.html) (response) /// * [locations functions create projects](struct.ProjectLocationFunctionCreateCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Operation { /// The error result of the operation in case of failure or cancellation. pub error: Option<Status>, /// If the value is `false`, it means the operation is still in progress. /// If `true`, the operation is completed, and either `error` or `response` is /// available. pub done: Option<bool>, /// The normal response of the operation in case of success. If the original /// method returns no data on success, such as `Delete`, the response is /// `google.protobuf.Empty`. If the original method is standard /// `Get`/`Create`/`Update`, the response should be the resource. For other /// methods, the response should have the type `XxxResponse`, where `Xxx` /// is the original method name. For example, if the original method name /// is `TakeSnapshot()`, the inferred response type is /// `TakeSnapshotResponse`. pub response: Option<HashMap<String, String>>, /// The server-assigned name, which is only unique within the same service that /// originally returns it. If you use the default HTTP mapping, the /// `name` should be a resource name ending with `operations/{unique_id}`. pub name: Option<String>, /// Service-specific metadata associated with the operation. It typically /// contains progress information and common metadata such as create time. /// Some services might not provide such metadata. Any method that returns a /// long-running operation should document the metadata type, if any. pub metadata: Option<HashMap<String, String>>, } impl Resource for Operation {} impl ResponseResult for Operation {} /// The `Status` type defines a logical error model that is suitable for /// different programming environments, including REST APIs and RPC APIs. It is /// used by [gRPC](https://github.com/grpc). Each `Status` message contains /// three pieces of data: error code, error message, and error details. /// /// You can find out more about this error model and how to work with it in the /// [API Design Guide](https://cloud.google.com/apis/design/errors). /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Status { /// A developer-facing error message, which should be in English. Any /// user-facing error message should be localized and sent in the /// google.rpc.Status.details field, or localized by the client. pub message: Option<String>, /// The status code, which should be an enum value of google.rpc.Code. pub code: Option<i32>, /// A list of messages that carry the error details. There is a common set of /// message types for APIs to use. pub details: Option<Vec<HashMap<String, String>>>, } impl Part for Status {} /// Response message for `TestIamPermissions` method. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [locations functions test iam permissions projects](struct.ProjectLocationFunctionTestIamPermissionCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TestIamPermissionsResponse { /// A subset of `TestPermissionsRequest.permissions` that the caller is /// allowed. pub permissions: Option<Vec<String>>, } impl ResponseResult for TestIamPermissionsResponse {} /// The response message for Operations.ListOperations. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list operations](struct.OperationListCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListOperationsResponse { /// The standard List next-page token. #[serde(rename="nextPageToken")] pub next_page_token: Option<String>, /// A list of operations that matches the specified filter in the request. pub operations: Option<Vec<Operation>>, } impl ResponseResult for ListOperationsResponse {} /// Describes SourceRepository, used to represent parameters related to /// source repository where a function is hosted. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SourceRepository { /// The URL pointing to the hosted repository where the function is defined. /// There are supported Cloud Source Repository URLs in the following /// formats: /// /// To refer to a specific commit: /// `https://source.developers.google.com/projects/*/repos/*/revisions/*/paths/*` /// To refer to a moveable alias (branch): /// `https://source.developers.google.com/projects/*/repos/*/moveable-aliases/*/paths/*` /// In particular, to refer to HEAD use `master` moveable alias. /// To refer to a specific fixed alias (tag): /// `https://source.developers.google.com/projects/*/repos/*/fixed-aliases/*/paths/*` /// /// You may omit `paths/*` if you want to use the main directory. pub url: Option<String>, /// Output only. The URL pointing to the hosted repository where the function /// were defined at the time of deployment. It always points to a specific /// commit in the format described above. #[serde(rename="deployedUrl")] pub deployed_url: Option<String>, } impl Part for SourceRepository {} /// Describes HttpsTrigger, could be used to connect web hooks to function. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct HttpsTrigger { /// Output only. The deployed url for the function. pub url: Option<String>, } impl Part for HttpsTrigger {} /// Associates `members` with a `role`. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Binding { /// Role that is assigned to `members`. /// For example, `roles/viewer`, `roles/editor`, or `roles/owner`. pub role: Option<String>, /// The condition that is associated with this binding. /// /// If the condition evaluates to `true`, then this binding applies to the /// current request. /// /// If the condition evaluates to `false`, then this binding does not apply to /// the current request. However, a different role binding might grant the same /// role to one or more of the members in this binding. /// /// To learn which resources support conditions in their IAM policies, see the /// [IAM /// documentation](https://cloud.google.com/iam/help/conditions/resource-policies). pub condition: Option<Expr>, /// Specifies the identities requesting access for a Cloud Platform resource. /// `members` can have the following values: /// /// * `allUsers`: A special identifier that represents anyone who is /// on the internet; with or without a Google account. /// /// * `allAuthenticatedUsers`: A special identifier that represents anyone /// who is authenticated with a Google account or a service account. /// /// * `user:{emailid}`: An email address that represents a specific Google /// account. For example, `[email protected]` . /// /// /// * `serviceAccount:{emailid}`: An email address that represents a service /// account. For example, `[email protected]`. /// /// * `group:{emailid}`: An email address that represents a Google group. /// For example, `[email protected]`. /// /// * `deleted:user:{emailid}?uid={uniqueid}`: An email address (plus unique /// identifier) representing a user that has been recently deleted. For /// example, `[email protected]?uid=123456789012345678901`. If the user is /// recovered, this value reverts to `user:{emailid}` and the recovered user /// retains the role in the binding. /// /// * `deleted:serviceAccount:{emailid}?uid={uniqueid}`: An email address (plus /// unique identifier) representing a service account that has been recently /// deleted. For example, /// `[email protected]?uid=123456789012345678901`. /// If the service account is undeleted, this value reverts to /// `serviceAccount:{emailid}` and the undeleted service account retains the /// role in the binding. /// /// * `deleted:group:{emailid}?uid={uniqueid}`: An email address (plus unique /// identifier) representing a Google group that has been recently /// deleted. For example, `[email protected]?uid=123456789012345678901`. If /// the group is recovered, this value reverts to `group:{emailid}` and the /// recovered group retains the role in the binding. /// /// /// * `domain:{domain}`: The G Suite domain (primary) that represents all the /// users of that domain. For example, `google.com` or `example.com`. /// /// pub members: Option<Vec<String>>, } impl Part for Binding {} /// Request of `GenerateDownloadUrl` method. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [locations functions generate download url projects](struct.ProjectLocationFunctionGenerateDownloadUrlCall.html) (request) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GenerateDownloadUrlRequest { /// The optional version of function. If not set, default, current version /// is used. #[serde(rename="versionId")] pub version_id: Option<String>, } impl RequestValue for GenerateDownloadUrlRequest {} /// Describes the policy in case of function's execution failure. /// If empty, then defaults to ignoring failures (i.e. not retrying them). /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FailurePolicy { /// If specified, then the function will be retried in case of a failure. pub retry: Option<Retry>, } impl Part for FailurePolicy {} /// Response of `GenerateDownloadUrl` method. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [locations functions generate download url projects](struct.ProjectLocationFunctionGenerateDownloadUrlCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GenerateDownloadUrlResponse { /// The generated Google Cloud Storage signed URL that should be used for /// function source code download. #[serde(rename="downloadUrl")] pub download_url: Option<String>, } impl ResponseResult for GenerateDownloadUrlResponse {} /// Response for the `ListFunctions` method. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [locations functions list projects](struct.ProjectLocationFunctionListCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListFunctionsResponse { /// If not empty, indicates that there may be more functions that match /// the request; this value should be passed in a new /// google.cloud.functions.v1.ListFunctionsRequest /// to get more functions. #[serde(rename="nextPageToken")] pub next_page_token: Option<String>, /// Locations that could not be reached. The response does not include any /// functions from these locations. pub unreachable: Option<Vec<String>>, /// The functions that match the request. pub functions: Option<Vec<CloudFunction>>, } impl ResponseResult for ListFunctionsResponse {} /// Request of `GenerateSourceUploadUrl` method. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [locations functions generate upload url projects](struct.ProjectLocationFunctionGenerateUploadUrlCall.html) (request) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GenerateUploadUrlRequest { _never_set: Option<bool> } impl RequestValue for GenerateUploadUrlRequest {} /// Specifies the audit configuration for a service. /// The configuration determines which permission types are logged, and what /// identities, if any, are exempted from logging. /// An AuditConfig must have one or more AuditLogConfigs. /// /// If there are AuditConfigs for both `allServices` and a specific service, /// the union of the two AuditConfigs is used for that service: the log_types /// specified in each AuditConfig are enabled, and the exempted_members in each /// AuditLogConfig are exempted. /// /// Example Policy with multiple AuditConfigs: /// /// ````text /// { /// "audit_configs": [ /// { /// "service": "allServices", /// "audit_log_configs": [ /// { /// "log_type": "DATA_READ", /// "exempted_members": [ /// "user:[email protected]" /// ] /// }, /// { /// "log_type": "DATA_WRITE" /// }, /// { /// "log_type": "ADMIN_READ" /// } /// ] /// }, /// { /// "service": "sampleservice.googleapis.com", /// "audit_log_configs": [ /// { /// "log_type": "DATA_READ" /// }, /// { /// "log_type": "DATA_WRITE", /// "exempted_members": [ /// "user:[email protected]" /// ] /// } /// ] /// } /// ] /// } /// ```` /// /// For sampleservice, this policy enables DATA_READ, DATA_WRITE and ADMIN_READ /// logging. It also exempts [email protected] from DATA_READ logging, and /// [email protected] from DATA_WRITE logging. /// /// This type is not used in any activity, and only used as *part* of another schema. #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AuditConfig { /// The configuration for logging of each type of permission. #[serde(rename="auditLogConfigs")] pub audit_log_configs: Option<Vec<AuditLogConfig>>, /// Specifies a service that will be enabled for audit logging. /// For example, `storage.googleapis.com`, `cloudsql.googleapis.com`. /// `allServices` is a special value that covers all services. pub service: Option<String>, } impl Part for AuditConfig {} /// Describes a Cloud Function that contains user computation executed in /// response to an event. It encapsulate function and triggers configurations. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [locations functions patch projects](struct.ProjectLocationFunctionPatchCall.html) (request) /// * [locations functions get projects](struct.ProjectLocationFunctionGetCall.html) (response) /// * [locations functions create projects](struct.ProjectLocationFunctionCreateCall.html) (request) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CloudFunction { /// A source that fires events in response to a condition in another service. #[serde(rename="eventTrigger")] pub event_trigger: Option<EventTrigger>, /// Output only. Status of the function deployment. pub status: Option<String>, /// Output only. The last update timestamp of a Cloud Function. #[serde(rename="updateTime")] pub update_time: Option<String>, /// User-provided description of a function. pub description: Option<String>, /// The limit on the maximum number of function instances that may coexist at a /// given time. #[serde(rename="maxInstances")] pub max_instances: Option<i32>, /// **Beta Feature** /// /// The source repository where a function is hosted. #[serde(rename="sourceRepository")] pub source_repository: Option<SourceRepository>, /// An HTTPS endpoint type of source that can be triggered via URL. #[serde(rename="httpsTrigger")] pub https_trigger: Option<HttpsTrigger>, /// The Google Cloud Storage URL, starting with gs://, pointing to the zip /// archive which contains the function. #[serde(rename="sourceArchiveUrl")] pub source_archive_url: Option<String>, /// Labels associated with this Cloud Function. pub labels: Option<HashMap<String, String>>, /// The egress settings for the connector, controlling what traffic is diverted /// through it. #[serde(rename="vpcConnectorEgressSettings")] pub vpc_connector_egress_settings: Option<String>, /// Output only. The version identifier of the Cloud Function. Each deployment attempt /// results in a new version of a function being created. #[serde(rename="versionId")] pub version_id: Option<String>, /// The name of the function (as defined in source code) that will be /// executed. Defaults to the resource name suffix, if not specified. For /// backward compatibility, if function with given name is not found, then the /// system will try to use function named "function". /// For Node.js this is name of a function exported by the module specified /// in `source_location`. #[serde(rename="entryPoint")] pub entry_point: Option<String>, /// A user-defined name of the function. Function names must be unique /// globally and match pattern `projects/*/locations/*/functions/*` pub name: Option<String>, /// The VPC Network that this cloud function can connect to. It can be /// either the fully-qualified URI, or the short name of the network resource. /// If the short network name is used, the network must belong to the same /// project. Otherwise, it must belong to a project within the same /// organization. The format of this field is either /// `projects/{project}/global/networks/{network}` or `{network}`, where /// {project} is a project id where the network is defined, and {network} is /// the short name of the network. /// /// This field is mutually exclusive with `vpc_connector` and will be replaced /// by it. /// /// See [the VPC documentation](https://cloud.google.com/compute/docs/vpc) for /// more information on connecting Cloud projects. pub network: Option<String>, /// The amount of memory in MB available for a function. /// Defaults to 256MB. #[serde(rename="availableMemoryMb")] pub available_memory_mb: Option<i32>, /// Output only. The Cloud Build ID of the latest successful deployment of the /// function. #[serde(rename="buildId")] pub build_id: Option<String>, /// The VPC Network Connector that this cloud function can connect to. It can /// be either the fully-qualified URI, or the short name of the network /// connector resource. The format of this field is /// `projects/*/locations/*/connectors/*` /// /// This field is mutually exclusive with `network` field and will eventually /// replace it. /// /// See [the VPC documentation](https://cloud.google.com/compute/docs/vpc) for /// more information on connecting Cloud projects. #[serde(rename="vpcConnector")] pub vpc_connector: Option<String>, /// Environment variables that shall be available during function execution. #[serde(rename="environmentVariables")] pub environment_variables: Option<HashMap<String, String>>, /// The Google Cloud Storage signed URL used for source uploading, generated /// by google.cloud.functions.v1.GenerateUploadUrl #[serde(rename="sourceUploadUrl")] pub source_upload_url: Option<String>, /// The email of the function's service account. If empty, defaults to /// `{project_id}@appspot.gserviceaccount.com`. #[serde(rename="serviceAccountEmail")] pub service_account_email: Option<String>, /// The function execution timeout. Execution is considered failed and /// can be terminated if the function is not completed at the end of the /// timeout period. Defaults to 60 seconds. pub timeout: Option<String>, /// The ingress settings for the function, controlling what traffic can reach /// it. #[serde(rename="ingressSettings")] pub ingress_settings: Option<String>, /// The runtime in which to run the function. Required when deploying a new /// function, optional when updating an existing function. For a complete /// list of possible choices, see the /// [`gcloud` command /// reference](/sdk/gcloud/reference/functions/deploy#--runtime). pub runtime: Option<String>, } impl RequestValue for CloudFunction {} impl ResponseResult for CloudFunction {} // ################### // MethodBuilders ### // ################# /// A builder providing access to all methods supported on *operation* resources. /// It is not used directly, but through the `CloudFunctions` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate yup_oauth2 as oauth2; /// extern crate google_cloudfunctions1 as cloudfunctions1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// use cloudfunctions1::CloudFunctions; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), /// <MemoryStorage as Default>::default(), None); /// let mut hub = CloudFunctions::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)` and `list(...)` /// // to build up your call. /// let rb = hub.operations(); /// # } /// ``` pub struct OperationMethods<'a, C, A> where C: 'a, A: 'a { hub: &'a CloudFunctions<C, A>, } impl<'a, C, A> MethodsBuilder for OperationMethods<'a, C, A> {} impl<'a, C, A> OperationMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// /// Gets the latest state of a long-running operation. Clients can use this /// method to poll the operation result at intervals as recommended by the API /// service. /// /// # Arguments /// /// * `name` - The name of the operation resource. pub fn get(&self, name: &str) -> OperationGetCall<'a, C, A> { OperationGetCall { hub: self.hub, _name: name.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists operations that match the specified filter in the request. If the /// server doesn't support this method, it returns `UNIMPLEMENTED`. /// /// NOTE: the `name` binding allows API services to override the binding /// to use different resource name schemes, such as `users/*/operations`. To /// override the binding, API services can add a binding such as /// `"/v1/{name=users/*}/operations"` to their service configuration. /// For backwards compatibility, the default name includes the operations /// collection id, however overriding users must ensure the name binding /// is the parent resource, without the operations collection id. pub fn list(&self) -> OperationListCall<'a, C, A> { OperationListCall { hub: self.hub, _page_token: Default::default(), _page_size: Default::default(), _name: Default::default(), _filter: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), } } } /// A builder providing access to all methods supported on *project* resources. /// It is not used directly, but through the `CloudFunctions` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate yup_oauth2 as oauth2; /// extern crate google_cloudfunctions1 as cloudfunctions1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// use cloudfunctions1::CloudFunctions; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), /// <MemoryStorage as Default>::default(), None); /// let mut hub = CloudFunctions::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `locations_functions_call(...)`, `locations_functions_create(...)`, `locations_functions_delete(...)`, `locations_functions_generate_download_url(...)`, `locations_functions_generate_upload_url(...)`, `locations_functions_get(...)`, `locations_functions_get_iam_policy(...)`, `locations_functions_list(...)`, `locations_functions_patch(...)`, `locations_functions_set_iam_policy(...)`, `locations_functions_test_iam_permissions(...)` and `locations_list(...)` /// // to build up your call. /// let rb = hub.projects(); /// # } /// ``` pub struct ProjectMethods<'a, C, A> where C: 'a, A: 'a { hub: &'a CloudFunctions<C, A>, } impl<'a, C, A> MethodsBuilder for ProjectMethods<'a, C, A> {} impl<'a, C, A> ProjectMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// /// Sets the IAM access control policy on the specified function. /// Replaces any existing policy. /// /// # Arguments /// /// * `request` - No description provided. /// * `resource` - REQUIRED: The resource for which the policy is being specified. /// See the operation documentation for the appropriate value for this field. pub fn locations_functions_set_iam_policy(&self, request: SetIamPolicyRequest, resource: &str) -> ProjectLocationFunctionSetIamPolicyCall<'a, C, A> { ProjectLocationFunctionSetIamPolicyCall { hub: self.hub, _request: request, _resource: resource.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists information about the supported locations for this service. /// /// # Arguments /// /// * `name` - The resource that owns the locations collection, if applicable. pub fn locations_list(&self, name: &str) -> ProjectLocationListCall<'a, C, A> { ProjectLocationListCall { hub: self.hub, _name: name.to_string(), _page_token: Default::default(), _page_size: Default::default(), _filter: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Deletes a function with the given name from the specified project. If the /// given function is used by some trigger, the trigger will be updated to /// remove this function. /// /// # Arguments /// /// * `name` - Required. The name of the function which should be deleted. pub fn locations_functions_delete(&self, name: &str) -> ProjectLocationFunctionDeleteCall<'a, C, A> { ProjectLocationFunctionDeleteCall { hub: self.hub, _name: name.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets the IAM access control policy for a function. /// Returns an empty policy if the function exists and does not have a policy /// set. /// /// # Arguments /// /// * `resource` - REQUIRED: The resource for which the policy is being requested. /// See the operation documentation for the appropriate value for this field. pub fn locations_functions_get_iam_policy(&self, resource: &str) -> ProjectLocationFunctionGetIamPolicyCall<'a, C, A> { ProjectLocationFunctionGetIamPolicyCall { hub: self.hub, _resource: resource.to_string(), _options_requested_policy_version: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Returns a function with the given name from the requested project. /// /// # Arguments /// /// * `name` - Required. The name of the function which details should be obtained. pub fn locations_functions_get(&self, name: &str) -> ProjectLocationFunctionGetCall<'a, C, A> { ProjectLocationFunctionGetCall { hub: self.hub, _name: name.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Tests the specified permissions against the IAM access control policy /// for a function. /// If the function does not exist, this will return an empty set of /// permissions, not a NOT_FOUND error. /// /// # Arguments /// /// * `request` - No description provided. /// * `resource` - REQUIRED: The resource for which the policy detail is being requested. /// See the operation documentation for the appropriate value for this field. pub fn locations_functions_test_iam_permissions(&self, request: TestIamPermissionsRequest, resource: &str) -> ProjectLocationFunctionTestIamPermissionCall<'a, C, A> { ProjectLocationFunctionTestIamPermissionCall { hub: self.hub, _request: request, _resource: resource.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Creates a new function. If a function with the given name already exists in /// the specified project, the long running operation will return /// `ALREADY_EXISTS` error. /// /// # Arguments /// /// * `request` - No description provided. /// * `location` - Required. The project and location in which the function should be created, specified /// in the format `projects/*/locations/*` pub fn locations_functions_create(&self, request: CloudFunction, location: &str) -> ProjectLocationFunctionCreateCall<'a, C, A> { ProjectLocationFunctionCreateCall { hub: self.hub, _request: request, _location: location.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates existing function. /// /// # Arguments /// /// * `request` - No description provided. /// * `name` - A user-defined name of the function. Function names must be unique /// globally and match pattern `projects/*/locations/*/functions/*` pub fn locations_functions_patch(&self, request: CloudFunction, name: &str) -> ProjectLocationFunctionPatchCall<'a, C, A> { ProjectLocationFunctionPatchCall { hub: self.hub, _request: request, _name: name.to_string(), _update_mask: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Returns a signed URL for uploading a function source code. /// For more information about the signed URL usage see: /// https://cloud.google.com/storage/docs/access-control/signed-urls. /// Once the function source code upload is complete, the used signed /// URL should be provided in CreateFunction or UpdateFunction request /// as a reference to the function source code. /// /// When uploading source code to the generated signed URL, please follow /// these restrictions: /// /// * Source file type should be a zip file. /// * Source file size should not exceed 100MB limit. /// * No credentials should be attached - the signed URLs provide access to the /// target bucket using internal service identity; if credentials were /// attached, the identity from the credentials would be used, but that /// identity does not have permissions to upload files to the URL. /// /// When making a HTTP PUT request, these two headers need to be specified: /// /// * `content-type: application/zip` /// * `x-goog-content-length-range: 0,104857600` /// /// And this header SHOULD NOT be specified: /// /// * `Authorization: Bearer YOUR_TOKEN` /// /// # Arguments /// /// * `request` - No description provided. /// * `parent` - The project and location in which the Google Cloud Storage signed URL /// should be generated, specified in the format `projects/*/locations/*`. pub fn locations_functions_generate_upload_url(&self, request: GenerateUploadUrlRequest, parent: &str) -> ProjectLocationFunctionGenerateUploadUrlCall<'a, C, A> { ProjectLocationFunctionGenerateUploadUrlCall { hub: self.hub, _request: request, _parent: parent.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Synchronously invokes a deployed Cloud Function. To be used for testing /// purposes as very limited traffic is allowed. For more information on /// the actual limits, refer to /// [Rate Limits](https://cloud.google.com/functions/quotas#rate_limits). /// /// # Arguments /// /// * `request` - No description provided. /// * `name` - Required. The name of the function to be called. pub fn locations_functions_call(&self, request: CallFunctionRequest, name: &str) -> ProjectLocationFunctionCallCall<'a, C, A> { ProjectLocationFunctionCallCall { hub: self.hub, _request: request, _name: name.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Returns a signed URL for downloading deployed function source code. /// The URL is only valid for a limited period and should be used within /// minutes after generation. /// For more information about the signed URL usage see: /// https://cloud.google.com/storage/docs/access-control/signed-urls /// /// # Arguments /// /// * `request` - No description provided. /// * `name` - The name of function for which source code Google Cloud Storage signed /// URL should be generated. pub fn locations_functions_generate_download_url(&self, request: GenerateDownloadUrlRequest, name: &str) -> ProjectLocationFunctionGenerateDownloadUrlCall<'a, C, A> { ProjectLocationFunctionGenerateDownloadUrlCall { hub: self.hub, _request: request, _name: name.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Returns a list of functions that belong to the requested project. /// /// # Arguments /// /// * `parent` - The project and location from which the function should be listed, /// specified in the format `projects/*/locations/*` /// If you want to list functions in all locations, use "-" in place of a /// location. When listing functions in all locations, if one or more /// location(s) are unreachable, the response will contain functions from all /// reachable locations along with the names of any unreachable locations. pub fn locations_functions_list(&self, parent: &str) -> ProjectLocationFunctionListCall<'a, C, A> { ProjectLocationFunctionListCall { hub: self.hub, _parent: parent.to_string(), _page_token: Default::default(), _page_size: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), } } } // ################### // CallBuilders ### // ################# /// Gets the latest state of a long-running operation. Clients can use this /// method to poll the operation result at intervals as recommended by the API /// service. /// /// A builder for the *get* method supported by a *operation* resource. /// It is not used directly, but through a `OperationMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_cloudfunctions1 as cloudfunctions1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// # use cloudfunctions1::CloudFunctions; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), /// # <MemoryStorage as Default>::default(), None); /// # let mut hub = CloudFunctions::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.operations().get("name") /// .doit(); /// # } /// ``` pub struct OperationGetCall<'a, C, A> where C: 'a, A: 'a { hub: &'a CloudFunctions<C, A>, _name: String, _delegate: Option<&'a mut dyn Delegate>, _additional_params: HashMap<String, String>, _scopes: BTreeMap<String, ()> } impl<'a, C, A> CallBuilder for OperationGetCall<'a, C, A> {} impl<'a, C, A> OperationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { /// Perform the operation you have build so far. pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; let mut dlg: &mut dyn Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(MethodInfo { id: "cloudfunctions.operations.get", http_method: hyper::method::Method::Get }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("name", self._name.to_string())); for &field in ["alt", "name"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+name}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+name}", "name")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); for param_name in ["name"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = hyper::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { Ok(token) => token, Err(err) => { match dlg.token(&*err) { Some(token) => token, None => { dlg.finished(false); return Err(Error::MissingToken(err)) } } } }; let auth_header = Authorization(Bearer { token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone()) .header(UserAgent(self.hub._user_agent.clone())) .header(auth_header.clone()); dlg.pre_request(); req.send() }; match req_result { Err(err) => { if let oauth2::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(Error::HttpError(err)) } Ok(mut res) => { if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); let json_server_error = json::from_str::<JsonServerError>(&json_err).ok(); let server_error = json::from_str::<ServerError>(&json_err) .or_else(|_| json::from_str::<ErrorResponse>(&json_err).map(|r| r.error)) .ok(); if let oauth2::Retry::After(d) = dlg.http_failure(&res, json_server_error, server_error) { sleep(d); continue; } dlg.finished(false); return match json::from_str::<ErrorResponse>(&json_err){ Err(_) => Err(Error::Failure(res)), Ok(serr) => Err(Error::BadRequest(serr)) } } let result_value = { let mut json_response = String::new(); res.read_to_string(&mut json_response).unwrap(); match json::from_str(&json_response) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); return Err(Error::JsonDecodeError(json_response, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The name of the operation resource. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> OperationGetCall<'a, C, A> { self._name = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> OperationGetCall<'a, C, A> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *access_token* (query-string) - OAuth access token. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *callback* (query-string) - JSONP /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *alt* (query-string) - Data format for response. /// * *$.xgafv* (query-string) - V1 error format. pub fn param<T>(mut self, name: T, value: T) -> OperationGetCall<'a, C, A> where T: AsRef<str> { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::CloudPlatform`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope<T, S>(mut self, scope: T) -> OperationGetCall<'a, C, A> where T: Into<Option<S>>, S: AsRef<str> { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Lists operations that match the specified filter in the request. If the /// server doesn't support this method, it returns `UNIMPLEMENTED`. /// /// NOTE: the `name` binding allows API services to override the binding /// to use different resource name schemes, such as `users/*/operations`. To /// override the binding, API services can add a binding such as /// `"/v1/{name=users/*}/operations"` to their service configuration. /// For backwards compatibility, the default name includes the operations /// collection id, however overriding users must ensure the name binding /// is the parent resource, without the operations collection id. /// /// A builder for the *list* method supported by a *operation* resource. /// It is not used directly, but through a `OperationMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_cloudfunctions1 as cloudfunctions1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// # use cloudfunctions1::CloudFunctions; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), /// # <MemoryStorage as Default>::default(), None); /// # let mut hub = CloudFunctions::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.operations().list() /// .page_token("sea") /// .page_size(-90) /// .name("dolores") /// .filter("gubergren") /// .doit(); /// # } /// ``` pub struct OperationListCall<'a, C, A> where C: 'a, A: 'a { hub: &'a CloudFunctions<C, A>, _page_token: Option<String>, _page_size: Option<i32>, _name: Option<String>, _filter: Option<String>, _delegate: Option<&'a mut dyn Delegate>, _additional_params: HashMap<String, String>, _scopes: BTreeMap<String, ()> } impl<'a, C, A> CallBuilder for OperationListCall<'a, C, A> {} impl<'a, C, A> OperationListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { /// Perform the operation you have build so far. pub fn doit(mut self) -> Result<(hyper::client::Response, ListOperationsResponse)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; let mut dlg: &mut dyn Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(MethodInfo { id: "cloudfunctions.operations.list", http_method: hyper::method::Method::Get }); let mut params: Vec<(&str, String)> = Vec::with_capacity(6 + self._additional_params.len()); if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._page_size { params.push(("pageSize", value.to_string())); } if let Some(value) = self._name { params.push(("name", value.to_string())); } if let Some(value) = self._filter { params.push(("filter", value.to_string())); } for &field in ["alt", "pageToken", "pageSize", "name", "filter"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/operations"; if self._scopes.len() == 0 { self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); } let url = hyper::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { Ok(token) => token, Err(err) => { match dlg.token(&*err) { Some(token) => token, None => { dlg.finished(false); return Err(Error::MissingToken(err)) } } } }; let auth_header = Authorization(Bearer { token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone()) .header(UserAgent(self.hub._user_agent.clone())) .header(auth_header.clone()); dlg.pre_request(); req.send() }; match req_result { Err(err) => { if let oauth2::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(Error::HttpError(err)) } Ok(mut res) => { if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); let json_server_error = json::from_str::<JsonServerError>(&json_err).ok(); let server_error = json::from_str::<ServerError>(&json_err) .or_else(|_| json::from_str::<ErrorResponse>(&json_err).map(|r| r.error)) .ok(); if let oauth2::Retry::After(d) = dlg.http_failure(&res, json_server_error, server_error) { sleep(d); continue; } dlg.finished(false); return match json::from_str::<ErrorResponse>(&json_err){ Err(_) => Err(Error::Failure(res)), Ok(serr) => Err(Error::BadRequest(serr)) } } let result_value = { let mut json_response = String::new(); res.read_to_string(&mut json_response).unwrap(); match json::from_str(&json_response) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); return Err(Error::JsonDecodeError(json_response, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Token identifying which result to start with, which is returned by a previous list call.<br><br> Pagination is only supported when querying for a specific function. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> OperationListCall<'a, C, A> { self._page_token = Some(new_value.to_string()); self } /// The maximum number of records that should be returned.<br> Requested page size cannot exceed 100. If not set, the default page size is 100.<br><br> Pagination is only supported when querying for a specific function. /// /// Sets the *page size* query property to the given value. pub fn page_size(mut self, new_value: i32) -> OperationListCall<'a, C, A> { self._page_size = Some(new_value); self } /// Must not be set. /// /// Sets the *name* query property to the given value. pub fn name(mut self, new_value: &str) -> OperationListCall<'a, C, A> { self._name = Some(new_value.to_string()); self } /// Required. A filter for matching the requested operations.<br><br> The supported formats of <b>filter</b> are:<br> To query for a specific function: <code>project:*,location:*,function:*</code><br> To query for all of the latest operations for a project: <code>project:*,latest:true</code> /// /// Sets the *filter* query property to the given value. pub fn filter(mut self, new_value: &str) -> OperationListCall<'a, C, A> { self._filter = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> OperationListCall<'a, C, A> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *access_token* (query-string) - OAuth access token. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *callback* (query-string) - JSONP /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *alt* (query-string) - Data format for response. /// * *$.xgafv* (query-string) - V1 error format. pub fn param<T>(mut self, name: T, value: T) -> OperationListCall<'a, C, A> where T: AsRef<str> { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::CloudPlatform`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope<T, S>(mut self, scope: T) -> OperationListCall<'a, C, A> where T: Into<Option<S>>, S: AsRef<str> { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Sets the IAM access control policy on the specified function. /// Replaces any existing policy. /// /// A builder for the *locations.functions.setIamPolicy* method supported by a *project* resource. /// It is not used directly, but through a `ProjectMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_cloudfunctions1 as cloudfunctions1; /// use cloudfunctions1::SetIamPolicyRequest; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// # use cloudfunctions1::CloudFunctions; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), /// # <MemoryStorage as Default>::default(), None); /// # let mut hub = CloudFunctions::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = SetIamPolicyRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_functions_set_iam_policy(req, "resource") /// .doit(); /// # } /// ``` pub struct ProjectLocationFunctionSetIamPolicyCall<'a, C, A> where C: 'a, A: 'a { hub: &'a CloudFunctions<C, A>, _request: SetIamPolicyRequest, _resource: String, _delegate: Option<&'a mut dyn Delegate>, _additional_params: HashMap<String, String>, _scopes: BTreeMap<String, ()> } impl<'a, C, A> CallBuilder for ProjectLocationFunctionSetIamPolicyCall<'a, C, A> {} impl<'a, C, A> ProjectLocationFunctionSetIamPolicyCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { /// Perform the operation you have build so far. pub fn doit(mut self) -> Result<(hyper::client::Response, Policy)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; let mut dlg: &mut dyn Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(MethodInfo { id: "cloudfunctions.projects.locations.functions.setIamPolicy", http_method: hyper::method::Method::Post }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("resource", self._resource.to_string())); for &field in ["alt", "resource"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy"; if self._scopes.len() == 0 { self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+resource}", "resource")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); for param_name in ["resource"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = hyper::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { Ok(token) => token, Err(err) => { match dlg.token(&*err) { Some(token) => token, None => { dlg.finished(false); return Err(Error::MissingToken(err)) } } } }; let auth_header = Authorization(Bearer { token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone()) .header(UserAgent(self.hub._user_agent.clone())) .header(auth_header.clone()) .header(ContentType(json_mime_type.clone())) .header(ContentLength(request_size as u64)) .body(&mut request_value_reader); dlg.pre_request(); req.send() }; match req_result { Err(err) => { if let oauth2::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(Error::HttpError(err)) } Ok(mut res) => { if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); let json_server_error = json::from_str::<JsonServerError>(&json_err).ok(); let server_error = json::from_str::<ServerError>(&json_err) .or_else(|_| json::from_str::<ErrorResponse>(&json_err).map(|r| r.error)) .ok(); if let oauth2::Retry::After(d) = dlg.http_failure(&res, json_server_error, server_error) { sleep(d); continue; } dlg.finished(false); return match json::from_str::<ErrorResponse>(&json_err){ Err(_) => Err(Error::Failure(res)), Ok(serr) => Err(Error::BadRequest(serr)) } } let result_value = { let mut json_response = String::new(); res.read_to_string(&mut json_response).unwrap(); match json::from_str(&json_response) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); return Err(Error::JsonDecodeError(json_response, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: SetIamPolicyRequest) -> ProjectLocationFunctionSetIamPolicyCall<'a, C, A> { self._request = new_value; self } /// REQUIRED: The resource for which the policy is being specified. /// See the operation documentation for the appropriate value for this field. /// /// Sets the *resource* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn resource(mut self, new_value: &str) -> ProjectLocationFunctionSetIamPolicyCall<'a, C, A> { self._resource = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ProjectLocationFunctionSetIamPolicyCall<'a, C, A> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *access_token* (query-string) - OAuth access token. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *callback* (query-string) - JSONP /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *alt* (query-string) - Data format for response. /// * *$.xgafv* (query-string) - V1 error format. pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationFunctionSetIamPolicyCall<'a, C, A> where T: AsRef<str> { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::CloudPlatform`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope<T, S>(mut self, scope: T) -> ProjectLocationFunctionSetIamPolicyCall<'a, C, A> where T: Into<Option<S>>, S: AsRef<str> { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Lists information about the supported locations for this service. /// /// A builder for the *locations.list* method supported by a *project* resource. /// It is not used directly, but through a `ProjectMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_cloudfunctions1 as cloudfunctions1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// # use cloudfunctions1::CloudFunctions; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), /// # <MemoryStorage as Default>::default(), None); /// # let mut hub = CloudFunctions::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_list("name") /// .page_token("ea") /// .page_size(-61) /// .filter("justo") /// .doit(); /// # } /// ``` pub struct ProjectLocationListCall<'a, C, A> where C: 'a, A: 'a { hub: &'a CloudFunctions<C, A>, _name: String, _page_token: Option<String>, _page_size: Option<i32>, _filter: Option<String>, _delegate: Option<&'a mut dyn Delegate>, _additional_params: HashMap<String, String>, _scopes: BTreeMap<String, ()> } impl<'a, C, A> CallBuilder for ProjectLocationListCall<'a, C, A> {} impl<'a, C, A> ProjectLocationListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { /// Perform the operation you have build so far. pub fn doit(mut self) -> Result<(hyper::client::Response, ListLocationsResponse)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; let mut dlg: &mut dyn Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(MethodInfo { id: "cloudfunctions.projects.locations.list", http_method: hyper::method::Method::Get }); let mut params: Vec<(&str, String)> = Vec::with_capacity(6 + self._additional_params.len()); params.push(("name", self._name.to_string())); if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._page_size { params.push(("pageSize", value.to_string())); } if let Some(value) = self._filter { params.push(("filter", value.to_string())); } for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+name}/locations"; if self._scopes.len() == 0 { self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+name}", "name")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); for param_name in ["name"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = hyper::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { Ok(token) => token, Err(err) => { match dlg.token(&*err) { Some(token) => token, None => { dlg.finished(false); return Err(Error::MissingToken(err)) } } } }; let auth_header = Authorization(Bearer { token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone()) .header(UserAgent(self.hub._user_agent.clone())) .header(auth_header.clone()); dlg.pre_request(); req.send() }; match req_result { Err(err) => { if let oauth2::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(Error::HttpError(err)) } Ok(mut res) => { if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); let json_server_error = json::from_str::<JsonServerError>(&json_err).ok(); let server_error = json::from_str::<ServerError>(&json_err) .or_else(|_| json::from_str::<ErrorResponse>(&json_err).map(|r| r.error)) .ok(); if let oauth2::Retry::After(d) = dlg.http_failure(&res, json_server_error, server_error) { sleep(d); continue; } dlg.finished(false); return match json::from_str::<ErrorResponse>(&json_err){ Err(_) => Err(Error::Failure(res)), Ok(serr) => Err(Error::BadRequest(serr)) } } let result_value = { let mut json_response = String::new(); res.read_to_string(&mut json_response).unwrap(); match json::from_str(&json_response) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); return Err(Error::JsonDecodeError(json_response, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The resource that owns the locations collection, if applicable. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> ProjectLocationListCall<'a, C, A> { self._name = new_value.to_string(); self } /// The standard list page token. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> ProjectLocationListCall<'a, C, A> { self._page_token = Some(new_value.to_string()); self } /// The standard list page size. /// /// Sets the *page size* query property to the given value. pub fn page_size(mut self, new_value: i32) -> ProjectLocationListCall<'a, C, A> { self._page_size = Some(new_value); self } /// The standard list filter. /// /// Sets the *filter* query property to the given value. pub fn filter(mut self, new_value: &str) -> ProjectLocationListCall<'a, C, A> { self._filter = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ProjectLocationListCall<'a, C, A> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *access_token* (query-string) - OAuth access token. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *callback* (query-string) - JSONP /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *alt* (query-string) - Data format for response. /// * *$.xgafv* (query-string) - V1 error format. pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationListCall<'a, C, A> where T: AsRef<str> { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::CloudPlatform`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope<T, S>(mut self, scope: T) -> ProjectLocationListCall<'a, C, A> where T: Into<Option<S>>, S: AsRef<str> { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Deletes a function with the given name from the specified project. If the /// given function is used by some trigger, the trigger will be updated to /// remove this function. /// /// A builder for the *locations.functions.delete* method supported by a *project* resource. /// It is not used directly, but through a `ProjectMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_cloudfunctions1 as cloudfunctions1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// # use cloudfunctions1::CloudFunctions; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), /// # <MemoryStorage as Default>::default(), None); /// # let mut hub = CloudFunctions::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_functions_delete("name") /// .doit(); /// # } /// ``` pub struct ProjectLocationFunctionDeleteCall<'a, C, A> where C: 'a, A: 'a { hub: &'a CloudFunctions<C, A>, _name: String, _delegate: Option<&'a mut dyn Delegate>, _additional_params: HashMap<String, String>, _scopes: BTreeMap<String, ()> } impl<'a, C, A> CallBuilder for ProjectLocationFunctionDeleteCall<'a, C, A> {} impl<'a, C, A> ProjectLocationFunctionDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { /// Perform the operation you have build so far. pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; let mut dlg: &mut dyn Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(MethodInfo { id: "cloudfunctions.projects.locations.functions.delete", http_method: hyper::method::Method::Delete }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("name", self._name.to_string())); for &field in ["alt", "name"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+name}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+name}", "name")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); for param_name in ["name"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = hyper::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { Ok(token) => token, Err(err) => { match dlg.token(&*err) { Some(token) => token, None => { dlg.finished(false); return Err(Error::MissingToken(err)) } } } }; let auth_header = Authorization(Bearer { token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.clone()) .header(UserAgent(self.hub._user_agent.clone())) .header(auth_header.clone()); dlg.pre_request(); req.send() }; match req_result { Err(err) => { if let oauth2::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(Error::HttpError(err)) } Ok(mut res) => { if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); let json_server_error = json::from_str::<JsonServerError>(&json_err).ok(); let server_error = json::from_str::<ServerError>(&json_err) .or_else(|_| json::from_str::<ErrorResponse>(&json_err).map(|r| r.error)) .ok(); if let oauth2::Retry::After(d) = dlg.http_failure(&res, json_server_error, server_error) { sleep(d); continue; } dlg.finished(false); return match json::from_str::<ErrorResponse>(&json_err){ Err(_) => Err(Error::Failure(res)), Ok(serr) => Err(Error::BadRequest(serr)) } } let result_value = { let mut json_response = String::new(); res.read_to_string(&mut json_response).unwrap(); match json::from_str(&json_response) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); return Err(Error::JsonDecodeError(json_response, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Required. The name of the function which should be deleted. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> ProjectLocationFunctionDeleteCall<'a, C, A> { self._name = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ProjectLocationFunctionDeleteCall<'a, C, A> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *access_token* (query-string) - OAuth access token. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *callback* (query-string) - JSONP /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *alt* (query-string) - Data format for response. /// * *$.xgafv* (query-string) - V1 error format. pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationFunctionDeleteCall<'a, C, A> where T: AsRef<str> { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::CloudPlatform`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope<T, S>(mut self, scope: T) -> ProjectLocationFunctionDeleteCall<'a, C, A> where T: Into<Option<S>>, S: AsRef<str> { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets the IAM access control policy for a function. /// Returns an empty policy if the function exists and does not have a policy /// set. /// /// A builder for the *locations.functions.getIamPolicy* method supported by a *project* resource. /// It is not used directly, but through a `ProjectMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_cloudfunctions1 as cloudfunctions1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// # use cloudfunctions1::CloudFunctions; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), /// # <MemoryStorage as Default>::default(), None); /// # let mut hub = CloudFunctions::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_functions_get_iam_policy("resource") /// .options_requested_policy_version(-17) /// .doit(); /// # } /// ``` pub struct ProjectLocationFunctionGetIamPolicyCall<'a, C, A> where C: 'a, A: 'a { hub: &'a CloudFunctions<C, A>, _resource: String, _options_requested_policy_version: Option<i32>, _delegate: Option<&'a mut dyn Delegate>, _additional_params: HashMap<String, String>, _scopes: BTreeMap<String, ()> } impl<'a, C, A> CallBuilder for ProjectLocationFunctionGetIamPolicyCall<'a, C, A> {} impl<'a, C, A> ProjectLocationFunctionGetIamPolicyCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { /// Perform the operation you have build so far. pub fn doit(mut self) -> Result<(hyper::client::Response, Policy)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; let mut dlg: &mut dyn Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(MethodInfo { id: "cloudfunctions.projects.locations.functions.getIamPolicy", http_method: hyper::method::Method::Get }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("resource", self._resource.to_string())); if let Some(value) = self._options_requested_policy_version { params.push(("options.requestedPolicyVersion", value.to_string())); } for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy"; if self._scopes.len() == 0 { self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+resource}", "resource")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); for param_name in ["resource"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = hyper::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { Ok(token) => token, Err(err) => { match dlg.token(&*err) { Some(token) => token, None => { dlg.finished(false); return Err(Error::MissingToken(err)) } } } }; let auth_header = Authorization(Bearer { token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone()) .header(UserAgent(self.hub._user_agent.clone())) .header(auth_header.clone()); dlg.pre_request(); req.send() }; match req_result { Err(err) => { if let oauth2::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(Error::HttpError(err)) } Ok(mut res) => { if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); let json_server_error = json::from_str::<JsonServerError>(&json_err).ok(); let server_error = json::from_str::<ServerError>(&json_err) .or_else(|_| json::from_str::<ErrorResponse>(&json_err).map(|r| r.error)) .ok(); if let oauth2::Retry::After(d) = dlg.http_failure(&res, json_server_error, server_error) { sleep(d); continue; } dlg.finished(false); return match json::from_str::<ErrorResponse>(&json_err){ Err(_) => Err(Error::Failure(res)), Ok(serr) => Err(Error::BadRequest(serr)) } } let result_value = { let mut json_response = String::new(); res.read_to_string(&mut json_response).unwrap(); match json::from_str(&json_response) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); return Err(Error::JsonDecodeError(json_response, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// REQUIRED: The resource for which the policy is being requested. /// See the operation documentation for the appropriate value for this field. /// /// Sets the *resource* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn resource(mut self, new_value: &str) -> ProjectLocationFunctionGetIamPolicyCall<'a, C, A> { self._resource = new_value.to_string(); self } /// Optional. The policy format version to be returned. /// /// Valid values are 0, 1, and 3. Requests specifying an invalid value will be /// rejected. /// /// Requests for policies with any conditional bindings must specify version 3. /// Policies without any conditional bindings may specify any valid value or /// leave the field unset. /// /// To learn which resources support conditions in their IAM policies, see the /// [IAM /// documentation](https://cloud.google.com/iam/help/conditions/resource-policies). /// /// Sets the *options.requested policy version* query property to the given value. pub fn options_requested_policy_version(mut self, new_value: i32) -> ProjectLocationFunctionGetIamPolicyCall<'a, C, A> { self._options_requested_policy_version = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ProjectLocationFunctionGetIamPolicyCall<'a, C, A> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *access_token* (query-string) - OAuth access token. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *callback* (query-string) - JSONP /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *alt* (query-string) - Data format for response. /// * *$.xgafv* (query-string) - V1 error format. pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationFunctionGetIamPolicyCall<'a, C, A> where T: AsRef<str> { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::CloudPlatform`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope<T, S>(mut self, scope: T) -> ProjectLocationFunctionGetIamPolicyCall<'a, C, A> where T: Into<Option<S>>, S: AsRef<str> { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Returns a function with the given name from the requested project. /// /// A builder for the *locations.functions.get* method supported by a *project* resource. /// It is not used directly, but through a `ProjectMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_cloudfunctions1 as cloudfunctions1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// # use cloudfunctions1::CloudFunctions; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), /// # <MemoryStorage as Default>::default(), None); /// # let mut hub = CloudFunctions::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_functions_get("name") /// .doit(); /// # } /// ``` pub struct ProjectLocationFunctionGetCall<'a, C, A> where C: 'a, A: 'a { hub: &'a CloudFunctions<C, A>, _name: String, _delegate: Option<&'a mut dyn Delegate>, _additional_params: HashMap<String, String>, _scopes: BTreeMap<String, ()> } impl<'a, C, A> CallBuilder for ProjectLocationFunctionGetCall<'a, C, A> {} impl<'a, C, A> ProjectLocationFunctionGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { /// Perform the operation you have build so far. pub fn doit(mut self) -> Result<(hyper::client::Response, CloudFunction)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; let mut dlg: &mut dyn Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(MethodInfo { id: "cloudfunctions.projects.locations.functions.get", http_method: hyper::method::Method::Get }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("name", self._name.to_string())); for &field in ["alt", "name"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+name}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+name}", "name")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); for param_name in ["name"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = hyper::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { Ok(token) => token, Err(err) => { match dlg.token(&*err) { Some(token) => token, None => { dlg.finished(false); return Err(Error::MissingToken(err)) } } } }; let auth_header = Authorization(Bearer { token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone()) .header(UserAgent(self.hub._user_agent.clone())) .header(auth_header.clone()); dlg.pre_request(); req.send() }; match req_result { Err(err) => { if let oauth2::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(Error::HttpError(err)) } Ok(mut res) => { if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); let json_server_error = json::from_str::<JsonServerError>(&json_err).ok(); let server_error = json::from_str::<ServerError>(&json_err) .or_else(|_| json::from_str::<ErrorResponse>(&json_err).map(|r| r.error)) .ok(); if let oauth2::Retry::After(d) = dlg.http_failure(&res, json_server_error, server_error) { sleep(d); continue; } dlg.finished(false); return match json::from_str::<ErrorResponse>(&json_err){ Err(_) => Err(Error::Failure(res)), Ok(serr) => Err(Error::BadRequest(serr)) } } let result_value = { let mut json_response = String::new(); res.read_to_string(&mut json_response).unwrap(); match json::from_str(&json_response) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); return Err(Error::JsonDecodeError(json_response, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Required. The name of the function which details should be obtained. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> ProjectLocationFunctionGetCall<'a, C, A> { self._name = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ProjectLocationFunctionGetCall<'a, C, A> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *access_token* (query-string) - OAuth access token. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *callback* (query-string) - JSONP /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *alt* (query-string) - Data format for response. /// * *$.xgafv* (query-string) - V1 error format. pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationFunctionGetCall<'a, C, A> where T: AsRef<str> { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::CloudPlatform`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope<T, S>(mut self, scope: T) -> ProjectLocationFunctionGetCall<'a, C, A> where T: Into<Option<S>>, S: AsRef<str> { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Tests the specified permissions against the IAM access control policy /// for a function. /// If the function does not exist, this will return an empty set of /// permissions, not a NOT_FOUND error. /// /// A builder for the *locations.functions.testIamPermissions* method supported by a *project* resource. /// It is not used directly, but through a `ProjectMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_cloudfunctions1 as cloudfunctions1; /// use cloudfunctions1::TestIamPermissionsRequest; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// # use cloudfunctions1::CloudFunctions; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), /// # <MemoryStorage as Default>::default(), None); /// # let mut hub = CloudFunctions::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = TestIamPermissionsRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_functions_test_iam_permissions(req, "resource") /// .doit(); /// # } /// ``` pub struct ProjectLocationFunctionTestIamPermissionCall<'a, C, A> where C: 'a, A: 'a { hub: &'a CloudFunctions<C, A>, _request: TestIamPermissionsRequest, _resource: String, _delegate: Option<&'a mut dyn Delegate>, _additional_params: HashMap<String, String>, _scopes: BTreeMap<String, ()> } impl<'a, C, A> CallBuilder for ProjectLocationFunctionTestIamPermissionCall<'a, C, A> {} impl<'a, C, A> ProjectLocationFunctionTestIamPermissionCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { /// Perform the operation you have build so far. pub fn doit(mut self) -> Result<(hyper::client::Response, TestIamPermissionsResponse)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; let mut dlg: &mut dyn Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(MethodInfo { id: "cloudfunctions.projects.locations.functions.testIamPermissions", http_method: hyper::method::Method::Post }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("resource", self._resource.to_string())); for &field in ["alt", "resource"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions"; if self._scopes.len() == 0 { self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+resource}", "resource")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); for param_name in ["resource"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = hyper::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { Ok(token) => token, Err(err) => { match dlg.token(&*err) { Some(token) => token, None => { dlg.finished(false); return Err(Error::MissingToken(err)) } } } }; let auth_header = Authorization(Bearer { token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone()) .header(UserAgent(self.hub._user_agent.clone())) .header(auth_header.clone()) .header(ContentType(json_mime_type.clone())) .header(ContentLength(request_size as u64)) .body(&mut request_value_reader); dlg.pre_request(); req.send() }; match req_result { Err(err) => { if let oauth2::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(Error::HttpError(err)) } Ok(mut res) => { if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); let json_server_error = json::from_str::<JsonServerError>(&json_err).ok(); let server_error = json::from_str::<ServerError>(&json_err) .or_else(|_| json::from_str::<ErrorResponse>(&json_err).map(|r| r.error)) .ok(); if let oauth2::Retry::After(d) = dlg.http_failure(&res, json_server_error, server_error) { sleep(d); continue; } dlg.finished(false); return match json::from_str::<ErrorResponse>(&json_err){ Err(_) => Err(Error::Failure(res)), Ok(serr) => Err(Error::BadRequest(serr)) } } let result_value = { let mut json_response = String::new(); res.read_to_string(&mut json_response).unwrap(); match json::from_str(&json_response) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); return Err(Error::JsonDecodeError(json_response, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: TestIamPermissionsRequest) -> ProjectLocationFunctionTestIamPermissionCall<'a, C, A> { self._request = new_value; self } /// REQUIRED: The resource for which the policy detail is being requested. /// See the operation documentation for the appropriate value for this field. /// /// Sets the *resource* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn resource(mut self, new_value: &str) -> ProjectLocationFunctionTestIamPermissionCall<'a, C, A> { self._resource = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ProjectLocationFunctionTestIamPermissionCall<'a, C, A> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *access_token* (query-string) - OAuth access token. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *callback* (query-string) - JSONP /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *alt* (query-string) - Data format for response. /// * *$.xgafv* (query-string) - V1 error format. pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationFunctionTestIamPermissionCall<'a, C, A> where T: AsRef<str> { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::CloudPlatform`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope<T, S>(mut self, scope: T) -> ProjectLocationFunctionTestIamPermissionCall<'a, C, A> where T: Into<Option<S>>, S: AsRef<str> { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Creates a new function. If a function with the given name already exists in /// the specified project, the long running operation will return /// `ALREADY_EXISTS` error. /// /// A builder for the *locations.functions.create* method supported by a *project* resource. /// It is not used directly, but through a `ProjectMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_cloudfunctions1 as cloudfunctions1; /// use cloudfunctions1::CloudFunction; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// # use cloudfunctions1::CloudFunctions; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), /// # <MemoryStorage as Default>::default(), None); /// # let mut hub = CloudFunctions::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = CloudFunction::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_functions_create(req, "location") /// .doit(); /// # } /// ``` pub struct ProjectLocationFunctionCreateCall<'a, C, A> where C: 'a, A: 'a { hub: &'a CloudFunctions<C, A>, _request: CloudFunction, _location: String, _delegate: Option<&'a mut dyn Delegate>, _additional_params: HashMap<String, String>, _scopes: BTreeMap<String, ()> } impl<'a, C, A> CallBuilder for ProjectLocationFunctionCreateCall<'a, C, A> {} impl<'a, C, A> ProjectLocationFunctionCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { /// Perform the operation you have build so far. pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; let mut dlg: &mut dyn Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(MethodInfo { id: "cloudfunctions.projects.locations.functions.create", http_method: hyper::method::Method::Post }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("location", self._location.to_string())); for &field in ["alt", "location"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+location}/functions"; if self._scopes.len() == 0 { self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+location}", "location")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); for param_name in ["location"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = hyper::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { Ok(token) => token, Err(err) => { match dlg.token(&*err) { Some(token) => token, None => { dlg.finished(false); return Err(Error::MissingToken(err)) } } } }; let auth_header = Authorization(Bearer { token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone()) .header(UserAgent(self.hub._user_agent.clone())) .header(auth_header.clone()) .header(ContentType(json_mime_type.clone())) .header(ContentLength(request_size as u64)) .body(&mut request_value_reader); dlg.pre_request(); req.send() }; match req_result { Err(err) => { if let oauth2::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(Error::HttpError(err)) } Ok(mut res) => { if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); let json_server_error = json::from_str::<JsonServerError>(&json_err).ok(); let server_error = json::from_str::<ServerError>(&json_err) .or_else(|_| json::from_str::<ErrorResponse>(&json_err).map(|r| r.error)) .ok(); if let oauth2::Retry::After(d) = dlg.http_failure(&res, json_server_error, server_error) { sleep(d); continue; } dlg.finished(false); return match json::from_str::<ErrorResponse>(&json_err){ Err(_) => Err(Error::Failure(res)), Ok(serr) => Err(Error::BadRequest(serr)) } } let result_value = { let mut json_response = String::new(); res.read_to_string(&mut json_response).unwrap(); match json::from_str(&json_response) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); return Err(Error::JsonDecodeError(json_response, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: CloudFunction) -> ProjectLocationFunctionCreateCall<'a, C, A>
/// Required. The project and location in which the function should be created, specified /// in the format `projects/*/locations/*` /// /// Sets the *location* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn location(mut self, new_value: &str) -> ProjectLocationFunctionCreateCall<'a, C, A> { self._location = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ProjectLocationFunctionCreateCall<'a, C, A> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *access_token* (query-string) - OAuth access token. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *callback* (query-string) - JSONP /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *alt* (query-string) - Data format for response. /// * *$.xgafv* (query-string) - V1 error format. pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationFunctionCreateCall<'a, C, A> where T: AsRef<str> { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::CloudPlatform`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope<T, S>(mut self, scope: T) -> ProjectLocationFunctionCreateCall<'a, C, A> where T: Into<Option<S>>, S: AsRef<str> { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates existing function. /// /// A builder for the *locations.functions.patch* method supported by a *project* resource. /// It is not used directly, but through a `ProjectMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_cloudfunctions1 as cloudfunctions1; /// use cloudfunctions1::CloudFunction; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// # use cloudfunctions1::CloudFunctions; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), /// # <MemoryStorage as Default>::default(), None); /// # let mut hub = CloudFunctions::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = CloudFunction::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_functions_patch(req, "name") /// .update_mask("duo") /// .doit(); /// # } /// ``` pub struct ProjectLocationFunctionPatchCall<'a, C, A> where C: 'a, A: 'a { hub: &'a CloudFunctions<C, A>, _request: CloudFunction, _name: String, _update_mask: Option<String>, _delegate: Option<&'a mut dyn Delegate>, _additional_params: HashMap<String, String>, _scopes: BTreeMap<String, ()> } impl<'a, C, A> CallBuilder for ProjectLocationFunctionPatchCall<'a, C, A> {} impl<'a, C, A> ProjectLocationFunctionPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { /// Perform the operation you have build so far. pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; let mut dlg: &mut dyn Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(MethodInfo { id: "cloudfunctions.projects.locations.functions.patch", http_method: hyper::method::Method::Patch }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("name", self._name.to_string())); if let Some(value) = self._update_mask { params.push(("updateMask", value.to_string())); } for &field in ["alt", "name", "updateMask"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+name}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+name}", "name")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); for param_name in ["name"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = hyper::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { Ok(token) => token, Err(err) => { match dlg.token(&*err) { Some(token) => token, None => { dlg.finished(false); return Err(Error::MissingToken(err)) } } } }; let auth_header = Authorization(Bearer { token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Patch, url.clone()) .header(UserAgent(self.hub._user_agent.clone())) .header(auth_header.clone()) .header(ContentType(json_mime_type.clone())) .header(ContentLength(request_size as u64)) .body(&mut request_value_reader); dlg.pre_request(); req.send() }; match req_result { Err(err) => { if let oauth2::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(Error::HttpError(err)) } Ok(mut res) => { if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); let json_server_error = json::from_str::<JsonServerError>(&json_err).ok(); let server_error = json::from_str::<ServerError>(&json_err) .or_else(|_| json::from_str::<ErrorResponse>(&json_err).map(|r| r.error)) .ok(); if let oauth2::Retry::After(d) = dlg.http_failure(&res, json_server_error, server_error) { sleep(d); continue; } dlg.finished(false); return match json::from_str::<ErrorResponse>(&json_err){ Err(_) => Err(Error::Failure(res)), Ok(serr) => Err(Error::BadRequest(serr)) } } let result_value = { let mut json_response = String::new(); res.read_to_string(&mut json_response).unwrap(); match json::from_str(&json_response) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); return Err(Error::JsonDecodeError(json_response, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: CloudFunction) -> ProjectLocationFunctionPatchCall<'a, C, A> { self._request = new_value; self } /// A user-defined name of the function. Function names must be unique /// globally and match pattern `projects/*/locations/*/functions/*` /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> ProjectLocationFunctionPatchCall<'a, C, A> { self._name = new_value.to_string(); self } /// Required list of fields to be updated in this request. /// /// Sets the *update mask* query property to the given value. pub fn update_mask(mut self, new_value: &str) -> ProjectLocationFunctionPatchCall<'a, C, A> { self._update_mask = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ProjectLocationFunctionPatchCall<'a, C, A> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *access_token* (query-string) - OAuth access token. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *callback* (query-string) - JSONP /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *alt* (query-string) - Data format for response. /// * *$.xgafv* (query-string) - V1 error format. pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationFunctionPatchCall<'a, C, A> where T: AsRef<str> { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::CloudPlatform`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope<T, S>(mut self, scope: T) -> ProjectLocationFunctionPatchCall<'a, C, A> where T: Into<Option<S>>, S: AsRef<str> { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Returns a signed URL for uploading a function source code. /// For more information about the signed URL usage see: /// https://cloud.google.com/storage/docs/access-control/signed-urls. /// Once the function source code upload is complete, the used signed /// URL should be provided in CreateFunction or UpdateFunction request /// as a reference to the function source code. /// /// When uploading source code to the generated signed URL, please follow /// these restrictions: /// /// * Source file type should be a zip file. /// * Source file size should not exceed 100MB limit. /// * No credentials should be attached - the signed URLs provide access to the /// target bucket using internal service identity; if credentials were /// attached, the identity from the credentials would be used, but that /// identity does not have permissions to upload files to the URL. /// /// When making a HTTP PUT request, these two headers need to be specified: /// /// * `content-type: application/zip` /// * `x-goog-content-length-range: 0,104857600` /// /// And this header SHOULD NOT be specified: /// /// * `Authorization: Bearer YOUR_TOKEN` /// /// A builder for the *locations.functions.generateUploadUrl* method supported by a *project* resource. /// It is not used directly, but through a `ProjectMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_cloudfunctions1 as cloudfunctions1; /// use cloudfunctions1::GenerateUploadUrlRequest; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// # use cloudfunctions1::CloudFunctions; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), /// # <MemoryStorage as Default>::default(), None); /// # let mut hub = CloudFunctions::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = GenerateUploadUrlRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_functions_generate_upload_url(req, "parent") /// .doit(); /// # } /// ``` pub struct ProjectLocationFunctionGenerateUploadUrlCall<'a, C, A> where C: 'a, A: 'a { hub: &'a CloudFunctions<C, A>, _request: GenerateUploadUrlRequest, _parent: String, _delegate: Option<&'a mut dyn Delegate>, _additional_params: HashMap<String, String>, _scopes: BTreeMap<String, ()> } impl<'a, C, A> CallBuilder for ProjectLocationFunctionGenerateUploadUrlCall<'a, C, A> {} impl<'a, C, A> ProjectLocationFunctionGenerateUploadUrlCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { /// Perform the operation you have build so far. pub fn doit(mut self) -> Result<(hyper::client::Response, GenerateUploadUrlResponse)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; let mut dlg: &mut dyn Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(MethodInfo { id: "cloudfunctions.projects.locations.functions.generateUploadUrl", http_method: hyper::method::Method::Post }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("parent", self._parent.to_string())); for &field in ["alt", "parent"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+parent}/functions:generateUploadUrl"; if self._scopes.len() == 0 { self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+parent}", "parent")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); for param_name in ["parent"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = hyper::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { Ok(token) => token, Err(err) => { match dlg.token(&*err) { Some(token) => token, None => { dlg.finished(false); return Err(Error::MissingToken(err)) } } } }; let auth_header = Authorization(Bearer { token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone()) .header(UserAgent(self.hub._user_agent.clone())) .header(auth_header.clone()) .header(ContentType(json_mime_type.clone())) .header(ContentLength(request_size as u64)) .body(&mut request_value_reader); dlg.pre_request(); req.send() }; match req_result { Err(err) => { if let oauth2::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(Error::HttpError(err)) } Ok(mut res) => { if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); let json_server_error = json::from_str::<JsonServerError>(&json_err).ok(); let server_error = json::from_str::<ServerError>(&json_err) .or_else(|_| json::from_str::<ErrorResponse>(&json_err).map(|r| r.error)) .ok(); if let oauth2::Retry::After(d) = dlg.http_failure(&res, json_server_error, server_error) { sleep(d); continue; } dlg.finished(false); return match json::from_str::<ErrorResponse>(&json_err){ Err(_) => Err(Error::Failure(res)), Ok(serr) => Err(Error::BadRequest(serr)) } } let result_value = { let mut json_response = String::new(); res.read_to_string(&mut json_response).unwrap(); match json::from_str(&json_response) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); return Err(Error::JsonDecodeError(json_response, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: GenerateUploadUrlRequest) -> ProjectLocationFunctionGenerateUploadUrlCall<'a, C, A> { self._request = new_value; self } /// The project and location in which the Google Cloud Storage signed URL /// should be generated, specified in the format `projects/*/locations/*`. /// /// Sets the *parent* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn parent(mut self, new_value: &str) -> ProjectLocationFunctionGenerateUploadUrlCall<'a, C, A> { self._parent = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ProjectLocationFunctionGenerateUploadUrlCall<'a, C, A> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *access_token* (query-string) - OAuth access token. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *callback* (query-string) - JSONP /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *alt* (query-string) - Data format for response. /// * *$.xgafv* (query-string) - V1 error format. pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationFunctionGenerateUploadUrlCall<'a, C, A> where T: AsRef<str> { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::CloudPlatform`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope<T, S>(mut self, scope: T) -> ProjectLocationFunctionGenerateUploadUrlCall<'a, C, A> where T: Into<Option<S>>, S: AsRef<str> { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Synchronously invokes a deployed Cloud Function. To be used for testing /// purposes as very limited traffic is allowed. For more information on /// the actual limits, refer to /// [Rate Limits](https://cloud.google.com/functions/quotas#rate_limits). /// /// A builder for the *locations.functions.call* method supported by a *project* resource. /// It is not used directly, but through a `ProjectMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_cloudfunctions1 as cloudfunctions1; /// use cloudfunctions1::CallFunctionRequest; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// # use cloudfunctions1::CloudFunctions; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), /// # <MemoryStorage as Default>::default(), None); /// # let mut hub = CloudFunctions::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = CallFunctionRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_functions_call(req, "name") /// .doit(); /// # } /// ``` pub struct ProjectLocationFunctionCallCall<'a, C, A> where C: 'a, A: 'a { hub: &'a CloudFunctions<C, A>, _request: CallFunctionRequest, _name: String, _delegate: Option<&'a mut dyn Delegate>, _additional_params: HashMap<String, String>, _scopes: BTreeMap<String, ()> } impl<'a, C, A> CallBuilder for ProjectLocationFunctionCallCall<'a, C, A> {} impl<'a, C, A> ProjectLocationFunctionCallCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { /// Perform the operation you have build so far. pub fn doit(mut self) -> Result<(hyper::client::Response, CallFunctionResponse)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; let mut dlg: &mut dyn Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(MethodInfo { id: "cloudfunctions.projects.locations.functions.call", http_method: hyper::method::Method::Post }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("name", self._name.to_string())); for &field in ["alt", "name"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+name}:call"; if self._scopes.len() == 0 { self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+name}", "name")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); for param_name in ["name"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = hyper::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { Ok(token) => token, Err(err) => { match dlg.token(&*err) { Some(token) => token, None => { dlg.finished(false); return Err(Error::MissingToken(err)) } } } }; let auth_header = Authorization(Bearer { token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone()) .header(UserAgent(self.hub._user_agent.clone())) .header(auth_header.clone()) .header(ContentType(json_mime_type.clone())) .header(ContentLength(request_size as u64)) .body(&mut request_value_reader); dlg.pre_request(); req.send() }; match req_result { Err(err) => { if let oauth2::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(Error::HttpError(err)) } Ok(mut res) => { if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); let json_server_error = json::from_str::<JsonServerError>(&json_err).ok(); let server_error = json::from_str::<ServerError>(&json_err) .or_else(|_| json::from_str::<ErrorResponse>(&json_err).map(|r| r.error)) .ok(); if let oauth2::Retry::After(d) = dlg.http_failure(&res, json_server_error, server_error) { sleep(d); continue; } dlg.finished(false); return match json::from_str::<ErrorResponse>(&json_err){ Err(_) => Err(Error::Failure(res)), Ok(serr) => Err(Error::BadRequest(serr)) } } let result_value = { let mut json_response = String::new(); res.read_to_string(&mut json_response).unwrap(); match json::from_str(&json_response) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); return Err(Error::JsonDecodeError(json_response, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: CallFunctionRequest) -> ProjectLocationFunctionCallCall<'a, C, A> { self._request = new_value; self } /// Required. The name of the function to be called. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> ProjectLocationFunctionCallCall<'a, C, A> { self._name = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ProjectLocationFunctionCallCall<'a, C, A> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *access_token* (query-string) - OAuth access token. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *callback* (query-string) - JSONP /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *alt* (query-string) - Data format for response. /// * *$.xgafv* (query-string) - V1 error format. pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationFunctionCallCall<'a, C, A> where T: AsRef<str> { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::CloudPlatform`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope<T, S>(mut self, scope: T) -> ProjectLocationFunctionCallCall<'a, C, A> where T: Into<Option<S>>, S: AsRef<str> { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Returns a signed URL for downloading deployed function source code. /// The URL is only valid for a limited period and should be used within /// minutes after generation. /// For more information about the signed URL usage see: /// https://cloud.google.com/storage/docs/access-control/signed-urls /// /// A builder for the *locations.functions.generateDownloadUrl* method supported by a *project* resource. /// It is not used directly, but through a `ProjectMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_cloudfunctions1 as cloudfunctions1; /// use cloudfunctions1::GenerateDownloadUrlRequest; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// # use cloudfunctions1::CloudFunctions; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), /// # <MemoryStorage as Default>::default(), None); /// # let mut hub = CloudFunctions::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = GenerateDownloadUrlRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_functions_generate_download_url(req, "name") /// .doit(); /// # } /// ``` pub struct ProjectLocationFunctionGenerateDownloadUrlCall<'a, C, A> where C: 'a, A: 'a { hub: &'a CloudFunctions<C, A>, _request: GenerateDownloadUrlRequest, _name: String, _delegate: Option<&'a mut dyn Delegate>, _additional_params: HashMap<String, String>, _scopes: BTreeMap<String, ()> } impl<'a, C, A> CallBuilder for ProjectLocationFunctionGenerateDownloadUrlCall<'a, C, A> {} impl<'a, C, A> ProjectLocationFunctionGenerateDownloadUrlCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { /// Perform the operation you have build so far. pub fn doit(mut self) -> Result<(hyper::client::Response, GenerateDownloadUrlResponse)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; let mut dlg: &mut dyn Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(MethodInfo { id: "cloudfunctions.projects.locations.functions.generateDownloadUrl", http_method: hyper::method::Method::Post }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("name", self._name.to_string())); for &field in ["alt", "name"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+name}:generateDownloadUrl"; if self._scopes.len() == 0 { self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+name}", "name")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); for param_name in ["name"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = hyper::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { Ok(token) => token, Err(err) => { match dlg.token(&*err) { Some(token) => token, None => { dlg.finished(false); return Err(Error::MissingToken(err)) } } } }; let auth_header = Authorization(Bearer { token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.clone()) .header(UserAgent(self.hub._user_agent.clone())) .header(auth_header.clone()) .header(ContentType(json_mime_type.clone())) .header(ContentLength(request_size as u64)) .body(&mut request_value_reader); dlg.pre_request(); req.send() }; match req_result { Err(err) => { if let oauth2::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(Error::HttpError(err)) } Ok(mut res) => { if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); let json_server_error = json::from_str::<JsonServerError>(&json_err).ok(); let server_error = json::from_str::<ServerError>(&json_err) .or_else(|_| json::from_str::<ErrorResponse>(&json_err).map(|r| r.error)) .ok(); if let oauth2::Retry::After(d) = dlg.http_failure(&res, json_server_error, server_error) { sleep(d); continue; } dlg.finished(false); return match json::from_str::<ErrorResponse>(&json_err){ Err(_) => Err(Error::Failure(res)), Ok(serr) => Err(Error::BadRequest(serr)) } } let result_value = { let mut json_response = String::new(); res.read_to_string(&mut json_response).unwrap(); match json::from_str(&json_response) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); return Err(Error::JsonDecodeError(json_response, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: GenerateDownloadUrlRequest) -> ProjectLocationFunctionGenerateDownloadUrlCall<'a, C, A> { self._request = new_value; self } /// The name of function for which source code Google Cloud Storage signed /// URL should be generated. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> ProjectLocationFunctionGenerateDownloadUrlCall<'a, C, A> { self._name = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ProjectLocationFunctionGenerateDownloadUrlCall<'a, C, A> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *access_token* (query-string) - OAuth access token. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *callback* (query-string) - JSONP /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *alt* (query-string) - Data format for response. /// * *$.xgafv* (query-string) - V1 error format. pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationFunctionGenerateDownloadUrlCall<'a, C, A> where T: AsRef<str> { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::CloudPlatform`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope<T, S>(mut self, scope: T) -> ProjectLocationFunctionGenerateDownloadUrlCall<'a, C, A> where T: Into<Option<S>>, S: AsRef<str> { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Returns a list of functions that belong to the requested project. /// /// A builder for the *locations.functions.list* method supported by a *project* resource. /// It is not used directly, but through a `ProjectMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_cloudfunctions1 as cloudfunctions1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// # use cloudfunctions1::CloudFunctions; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), /// # <MemoryStorage as Default>::default(), None); /// # let mut hub = CloudFunctions::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_functions_list("parent") /// .page_token("erat") /// .page_size(-95) /// .doit(); /// # } /// ``` pub struct ProjectLocationFunctionListCall<'a, C, A> where C: 'a, A: 'a { hub: &'a CloudFunctions<C, A>, _parent: String, _page_token: Option<String>, _page_size: Option<i32>, _delegate: Option<&'a mut dyn Delegate>, _additional_params: HashMap<String, String>, _scopes: BTreeMap<String, ()> } impl<'a, C, A> CallBuilder for ProjectLocationFunctionListCall<'a, C, A> {} impl<'a, C, A> ProjectLocationFunctionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { /// Perform the operation you have build so far. pub fn doit(mut self) -> Result<(hyper::client::Response, ListFunctionsResponse)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; let mut dlg: &mut dyn Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(MethodInfo { id: "cloudfunctions.projects.locations.functions.list", http_method: hyper::method::Method::Get }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("parent", self._parent.to_string())); if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._page_size { params.push(("pageSize", value.to_string())); } for &field in ["alt", "parent", "pageToken", "pageSize"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/{+parent}/functions"; if self._scopes.len() == 0 { self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+parent}", "parent")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); for param_name in ["parent"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = hyper::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { Ok(token) => token, Err(err) => { match dlg.token(&*err) { Some(token) => token, None => { dlg.finished(false); return Err(Error::MissingToken(err)) } } } }; let auth_header = Authorization(Bearer { token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.clone()) .header(UserAgent(self.hub._user_agent.clone())) .header(auth_header.clone()); dlg.pre_request(); req.send() }; match req_result { Err(err) => { if let oauth2::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(Error::HttpError(err)) } Ok(mut res) => { if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); let json_server_error = json::from_str::<JsonServerError>(&json_err).ok(); let server_error = json::from_str::<ServerError>(&json_err) .or_else(|_| json::from_str::<ErrorResponse>(&json_err).map(|r| r.error)) .ok(); if let oauth2::Retry::After(d) = dlg.http_failure(&res, json_server_error, server_error) { sleep(d); continue; } dlg.finished(false); return match json::from_str::<ErrorResponse>(&json_err){ Err(_) => Err(Error::Failure(res)), Ok(serr) => Err(Error::BadRequest(serr)) } } let result_value = { let mut json_response = String::new(); res.read_to_string(&mut json_response).unwrap(); match json::from_str(&json_response) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); return Err(Error::JsonDecodeError(json_response, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The project and location from which the function should be listed, /// specified in the format `projects/*/locations/*` /// If you want to list functions in all locations, use "-" in place of a /// location. When listing functions in all locations, if one or more /// location(s) are unreachable, the response will contain functions from all /// reachable locations along with the names of any unreachable locations. /// /// Sets the *parent* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn parent(mut self, new_value: &str) -> ProjectLocationFunctionListCall<'a, C, A> { self._parent = new_value.to_string(); self } /// The value returned by the last /// `ListFunctionsResponse`; indicates that /// this is a continuation of a prior `ListFunctions` call, and that the /// system should return the next page of data. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> ProjectLocationFunctionListCall<'a, C, A> { self._page_token = Some(new_value.to_string()); self } /// Maximum number of functions to return per call. /// /// Sets the *page size* query property to the given value. pub fn page_size(mut self, new_value: i32) -> ProjectLocationFunctionListCall<'a, C, A> { self._page_size = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> ProjectLocationFunctionListCall<'a, C, A> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *access_token* (query-string) - OAuth access token. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. /// * *callback* (query-string) - JSONP /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *alt* (query-string) - Data format for response. /// * *$.xgafv* (query-string) - V1 error format. pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationFunctionListCall<'a, C, A> where T: AsRef<str> { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::CloudPlatform`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope<T, S>(mut self, scope: T) -> ProjectLocationFunctionListCall<'a, C, A> where T: Into<Option<S>>, S: AsRef<str> { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } }
{ self._request = new_value; self }
renderer.ts
import { settings } from ".."; import { Vector } from "../components/vector"; import { particleContainer, RenderedElement } from "../containers"; import { resolveShapeFactory, TShape } from "../systems/shapes"; import { rotationToNormal } from "../util"; import { Emitter } from "./emitter"; import { RenderOptions } from "./options"; import { Particle } from "./particle"; /** * Represents a renderer used to draw particles. Additionally, it is responsible for purging the elements * of destroyed particles from the DOM. */ export class
{ /** * The lookup of elements currently handled by the renderer, with the * particle ID as key and a RenderedElement as the value. */ public elements: Map<symbol, RenderedElement> = new Map(); /** * The normalized direction the light comes from. */ public light: Vector = new Vector(0, 0, 1); /** * The collection of symbols containing the particles that were rendered this frame. * This is, for example, used to delete unused particles from the DOM. */ private renderedParticles: symbol[]; /** * Whether or not the renderer should actually draw particles. */ private enabled = true; public constructor() { this.enabled = true; } /** * Begins a new render block. During the rendering phase, a list of rendered particles * is tracked, so that stale particles can be removed later. */ public begin(): void { this.renderedParticles = []; } /** * Terminates an existing render block. This checks which particles were rendered * during the block and purges all unused RenderedElements from the DOM. * * @returns The amount of particles that were rendered. */ public end(): number { const it = this.elements.keys(); let result = it.next(); while (!result.done) { const id = result.value as symbol; if (!this.renderedParticles.includes(id)) { this.elements.get(id).remove(); this.elements.delete(id); } result = it.next(); } return this.renderedParticles.length; } /** * Renders an individual particle to the DOM. If the particle is rendered for the first * time, a RenderedElement will be created using the emitter's render settings. * * @param particle The particle to be rendered. * @param emitter The system containing the particle. */ public renderParticle(particle: Particle, emitter: Emitter): void { if (!this.enabled) return; const options: RenderOptions = emitter.renderer; // Ensure that an element for the particle exists. const element = this.elements.has(particle.id) ? this.elements.get(particle.id) : this.createParticleElement(particle, options); if (options.applyColor) { // If the options offer a coloring method, apply it. options.applyColor(particle.color, element); } if (options.applyOpacity) { // If the options offer an opacity modifying method, apply it. options.applyOpacity(particle.opacity, element); } if (options.applyLighting) { // If the options offer a lighting method, apply it. // Lighting is calculated as a combination of the particle's normal // direction and the lighting direction. const normal = rotationToNormal(particle.rotation); const lightingCoefficient = normal.dot(this.light); options.applyLighting(lightingCoefficient, element); } if (options.applyTransform) { // If the options offer a transformation method, apply it. // This ensures the particle is rendered at the correct position with the correct rotation. options.applyTransform(particle, element); } // Mark the particle as rendered. this.renderedParticles.push(particle.id); } /** * Creates the RenderedElement for a particle that does not have one already. */ private createParticleElement( particle: Particle, options: RenderOptions ): RenderedElement { // Resolve the element returned from the factory. const element = resolveShapeFactory(options.shapeFactory); // Clone the node to ensure we do not break existing elements. // const element = resolved.cloneElement(); // Register the new element in the map, while appending the new element to the DOM. this.elements.set( particle.id, particleContainer.current.appendChild(element) ); return element; } }
Renderer
xvfbmagic.py
from __future__ import print_function from IPython.core.magic import (Magics, magics_class, line_magic, cell_magic, line_cell_magic) from xvfbwrapper import Xvfb @magics_class class XvfbMagics(Magics): def __init__(self, shell, **xvfb_kwargs): """ Initialize the XvfbMagics object Parameters ---------- shell : IPython instance xvfb_kwargs : dict Keyword arguments to initialize xfvbwrapper.Xvfb Defaultst to: width=800, height=680, colordepth=24. """ super(XvfbMagics, self).__init__(shell) self.xvfb_kwargs = xvfb_kwargs @line_cell_magic def
(self, line, cell=None): display = Xvfb(**self.xvfb_kwargs) display.start() if cell is None: self.shell.ex(line) else: self.shell.ex(cell) display.stop() _loaded = False def load_ipython_extension(ip, **kwargs): """Load the extension in IPython.""" global _loaded if not _loaded: ip.register_magics(XvfbMagics(ip, **kwargs)) _loaded = True def unload_ipython_extension(ip): global _loaded if _loaded: magic = ip.magics_manager.registry.pop('XvfbMagics') _loaded = False
xvfb
errors.py
# Copyright 2019-2020 Not Just A Toy Corp. # # 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. import typing as ty from .path import Path __all__ = ( 'Error', ) class
: __slots__ = ( 'path', 'message' ) def __init__(self, path: Path, message: str) -> None: self.path = path self.message = message def __eq__(self, other: ty.Any) -> bool: if not isinstance(other, Error): raise NotImplementedError() return self.path == other.path and self.message == other.message def __hash__(self) -> int: return hash((self.path, self.message)) def __str__(self) -> str: return "%s: %s" % (self.path, self.message) def __repr__(self) -> str: return "%s(%r, %r)" % (self.__class__.__name__, self.path, self.message)
Error
update_config.py
from sim_core import * import conf import sim # dictionary with list of update functions to call update_functions = {} def install_configuration_update(version, f): prev = update_functions.get(version, []) update_functions[version] = prev + [f] def update_configuration(set): global first_queue try: if set['sim'].version > conf.sim.version: print ('Loading a configuration created in a newer Simics version ' '(build %d) is not supported, and may not work. Current ' 'Simics build is %d.' % (set['sim'].version, conf.sim.version)) return except: if SIM_get_verbose(): print 'No version information in checkpoint - not updating.' return for x in set.values(): try: first_queue = x.queue break except: pass vers = sorted(update_functions.keys()) for ver in vers: if ver < set['sim'].version: continue # allow callback on same version if ver > conf.sim.version: print ("Warning: update_config callback for future version " "found: %s" % ver) continue if SIM_get_verbose(): print 'Updating from version %d' % ver for f in update_functions[ver]: try: f(set) except Exception, msg: print 'Update function for version %d failed: %s' % (ver, msg) ####################### def all_objects(set, classname): return [x for x in set.values() if x.classname == classname] def for_all_objects(set, classname, function): for obj in all_objects(set, classname): function(set, obj) def all_objects_with_attr(set, attrname): return [x for x in set.values() if hasattr(x, attrname)] def remove_attr(obj, name): try: delattr(obj, name) except AttributeError: pass def rename_attr(obj, new_attr, old_attr): try: setattr(obj, new_attr, getattr(obj, old_attr)) except AttributeError: pass remove_attr(obj, old_attr) def remove_class_attr(set, classname, name): for obj in all_objects(set, classname): remove_attr(obj, name) def remove_class(set, classname): for l in [x.name for x in set.values() if x.classname == classname]: del set[l] x86_classes = ["x86-386", "x86-386-387", "x86-486dx2", "x86-486sx", "x86-pentium", "x86-pentium-mmx", "x86-ppro", "x86-p2", "x86-p3", "x86-p4", "x86-p4e", "x86-hammer", "x86-k7"] mips_classes = ["mips-4kc", "mips-5kc", "mips-rm7000-be", "mips-e9000-be"] ppc_classes = ['ppc403gcx', 'ppc405gp', 'ppc440gp', 'ppc440gx', 'ppc603e', 'ppc7400', 'ppc7447', 'ppc7450', 'ppc7450-36', 'ppc7457', 'ppc750', 'ppc750fx', 'ppc750gx', 'ppc755', 'ppc970fx', 'ppce500', 'ppce600', 'ppc-power6'] def remove_class(set, classname): for obj in all_objects(set, classname): del set[obj.name] ####################### def update_1396_to_1397(set): for obj in (all_objects(set, 'mpc8641-rapidio') + all_objects(set, 'mpc8548-rapidio')): # misspelt register name remove_attr(obj, "regs_LTRETCR") def update_1390_to_1391(set): for obj in all_objects(set, 'es_asic'): remove_attr(obj, "bar3_CT") remove_attr(obj, "page_buffer_crc") def update_1378_to_1379(set): for obj in all_objects(set, 'mpc8641-pic'): # create task priority registers for 30 more cores: # pad CTPR with zeros until a length of 32 obj.P_CTPR = obj.P_CTPR + [0]*(32 - len(obj.P_CTPR)) def update_1377_to_1378(set): for obj in all_objects(set, 'mpc8641-pcie'): remove_attr(obj, "pci_config_device_id") for obj in (all_objects(set, "MV64360") + all_objects(set, "MV64460") + all_objects(set, "MV64470") + all_objects(set, "MV64470-EC")): remove_attr(obj, "regs_port_GoodOctetsReceived") remove_attr(obj, "regs_port_GoodOctetsSent") for obj in (all_objects(set, "es_asic")): remove_attr(obj, "bar3_REVTO") def add_pex8111_irq_level(set, obj): obj.irq_level = 4 def update_8x4x_rapidio_1371(set, obj): for reg in "OMR OSR ODQDPAR OSAR ODPR ODATR ODCR ODQEPAR".split(): remove_attr(obj, "regs_"+reg) for reg in "IMR ISR IFQDPAR IDQEPAR IFQEPAR".split(): remove_attr(obj, "regs_"+reg) def update_1370_to_1371(set): for obj in (all_objects(set, 'mpc8641-rapidio') + all_objects(set, 'mpc8548-rapidio')): update_8x4x_rapidio_1371(set, obj) def update_1367_to_1368(set): for_all_objects(set, 'pex8111', add_pex8111_irq_level) def update_1366_to_1367(set): # new partial registers for o in (all_objects(set, "MV64360") + all_objects(set, "MV64460") + all_objects(set, "MV64470") + all_objects(set, "MV64470-EC")): rename_attr(o, 'partial_regs_IDMA_Interrupt_Cause', 'regs_IDMA_Interrupt_Cause') def update_8x4x_rapidio_1366(set, obj): if not hasattr(obj, "inbound_space"): # create local link if network in other simics space = pre_conf_object(obj.name + "_inbound_space", 'memory-space') set[obj.name + '_inbound_space'] = space setattr(obj, "inbound_space", space) if obj.classname in ('mpc8641-rapidio', 'mpc8548-rapidio'): for reg in "EODQEPAR EOSAR EODQDPAR EIFQEPAR EIFQDPAR".split(): if hasattr(obj, "regs_"+reg): setattr(obj, "regs_M_"+reg, [ getattr(obj, "regs_"+reg), 0 ]) delattr(obj, "regs_"+reg) def update_1365_to_1366(set): for obj in all_objects(set, 'mpc8641-duart'): obj.__class_name__ = 'NS16550' for obj in (all_objects(set, 'mpc8641-rapidio') + all_objects(set, 'mpc8540-rapidio') + all_objects(set, 'mpc8548-rapidio')): update_8x4x_rapidio_1366(set, obj) for obj in (all_objects(set, 'mpc8641-i2c') + all_objects(set, 'mpc8540-i2c') + all_objects(set, 'mpc8548-i2c')): delattr(obj, 'i2c_device_state') # new partial registers for o in (all_objects(set, "MV64360") + all_objects(set, "MV64460") + all_objects(set, "MV64470") + all_objects(set, "MV64470-EC")): rename_attr(o, 'partial_regs_IDMA_Interrupt_Mask', 'regs_IDMA_Interrupt_Mask') def update_1364_to_1365(set): for obj in all_objects(set, 'mpc8641-gu'): # remove all registers, layout have changed. # registers are characterized by all capital letters for attr in dir(obj): if attr.isupper(): delattr(obj, attr) def update_1363_to_1364(set): max_cpu_num = -1 for c in all_objects_with_attr(set, 'processor_number'): if c.processor_number > max_cpu_num: max_cpu_num = c.processor_number next_cpu_num = max_cpu_num + 1 taken_nums = {} for c in all_objects_with_attr(set, 'processor_number'): if taken_nums.has_key(c.processor_number): c.processor_number = next_cpu_num next_cpu_num += 1 else: taken_nums[c.processor_number] = True def rename_mv_pci_access_control_attr(obj): for i in range(6): remove_attr(obj, 'regs_pci_bus_PCI_Access_Control_Base_%d_L' % i) remove_attr(obj, 'regs_pci_bus_PCI_Access_Control_Base_%d_H' % i) remove_attr(obj, 'regs_pci_bus_PCI_Access_Control_Size_%d' % i) def update_1361_to_1362(set): for o in (all_objects(set, "MV64360") + all_objects(set, "MV64460") + all_objects(set, "MV64470") + all_objects(set, "MV64470-EC")): rename_mv_pci_access_control_attr(o) def remap_pq2(set, mem_map): # Dictionary where class name + mapping function is key, and the old # offset is the value remap = {'clocks' + '0' : 0x10c80, 'brg' + '0' : 0x119f0, 'cpm-mux' + '0' : 0x11b00, 'cpm-timers' + '0' : 0x10d80, 'cpm' + '0' : 0x119c0, 'fcc' + '0' : 0x11300, 'i2c_dev' + '1' : 0x08afc, 'ic' + '0' : 0x10c00, 'io-port' + '0' : 0x10d00, 'mc' + '0' : 0x10100, 'mcc' + '0' : 0x11b30, 'pci' + '0' : 0x10430, 'pci' + '1' : 0x101ac, 'scc' + '0' : 0x11a00, 'sdma' + '0' : 0x11018, 'si' + '0' : 0x11b20, 'sit' + '0' : 0x10220, 'siu' + '0' : 0x10000, 'smc' + '0' : 0x11a82, 'spi' + '0' : 0x11aa0} # Remap all PQ2 objects at offset 0 for e in mem_map.map: obj = e[1] fun = e[2] ofs = e[3] if not obj.classname[:8] in ['mpc8260-', 'mpc8270-', 'mpc8280-']: continue key = obj.classname[8:] + str(fun)
if remap.has_key(key) and ofs == remap[key]: e[3] = 0 def update_1358_to_1359(set): for_all_objects(set, 'memory-space', remap_pq2) def update_1357_to_1358(set): for o in (all_objects(set, "MV64360") + all_objects(set, "MV64460") + all_objects(set, "MV64470") + all_objects(set, "MV64470-EC")): remove_attr(o, "regs_port_MAC_MIB_Counters") def update_1354_to_1355(set): scc_reg_subst = { "armv5te": { 0: "main_id", 1: "cache_type", 2: "control", 3: "translation_table_base", 4: "domain_access_control", 6: "fault_status", 7: "fault_address", }, "arm966e-s": { 0: "main_id", 1: "tcm_size", 2: "control", 10: "trace_process_identifier", 16: "configuration_control", 17: "bist_control", 18: "instruction_bist_address", 19: "instruction_bist_general", 22: "data_bist_address", 23: "data_bist_general", } } for cl in ["armv5te", "arm966e-s"]: for o in all_objects(set, cl): scc_regs = getattr(o, "scc_regs") for (i, name) in scc_reg_subst[cl].iteritems(): setattr(o, name, scc_regs[i]) remove_attr(o, "scc_regs") def update_1350_to_1351(set): for pq2_class in ("ep8260", "sbc8260", "cpp8260", "gda8540", "mpc8540ads"): for obj in all_objects(set, pq2_class): remove_attr(obj, "mac_address0") remove_attr(obj, "mac_address1") def update_1348_to_1349(set): for obj in all_objects(set, "sx_asic"): rename_attr(obj, 'startup_SRCRST', 'startup_GPIOOUT') rename_attr(obj, 'startup_SRCLSRI', 'startup_GPIOIN') rename_attr(obj, 'startup_SRCRSTSTAT', 'startup_GPIOCR') rename_attr(obj, 'startup_SRCRSTRSN', 'startup_GPIOINT') def update_1340_to_1341(set): # hypersim-patttern-matcher fixes: # 1. Add a CPUs attribute # 2. Remove sample event from step queue, it will be reposted in time q. for o in all_objects(set, "hypersim-pattern-matcher"): o.cpus = [o.queue] for obj in set.values(): try: SIM_get_class(obj.classname) except SimExc_General, msg: continue if 'processor' not in sim.classes[obj.classname].interfaces: continue sq = obj.step_queue nsq = [] for e in sq: if e[1] != "do pattern match": nsq.append(e) obj.step_queue = nsq def update_1334_to_1335(set): for cl in x86_classes: for o in all_objects(set, cl): if "debugctlmsr" in dir(o): rename_attr(o, "ia32_debugctl", "debugctlmsr") def update_1332_to_1333(set): msr_translate = [["msr_pat" , "ia32_cr_pat"], ["msr_syscfg" , "syscfg"], ["msr_top_mem" , "top_mem"], ["msr_top_mem2" , "top_mem2"], ["msr_iorr_base0" , "iorrbase0"], ["msr_iorr_base1" , "iorrbase1"], ["msr_iorr_mask0" , "iorrmask0"], ["msr_iorr_mask1" , "iorrmask1"], ["msr_hwcr" , "hwcr"], ["msr_manid" , "manid"], ["msr_nb_cfg" , "nb_cfg"], ["msr_fidvid_ctl" , "fidvid_ctl"], ["msr_fidvid_status" , "fidvid_status"], ["msr_iotrap_addr0" , "iotrap_addr0"], ["msr_iotrap_addr1" , "iotrap_addr1"], ["msr_iotrap_addr2" , "iotrap_addr2"], ["msr_iotrap_addr3" , "iotrap_addr3"], ["msr_iotrap_ctl" , "iotrap_ctl"], ["msr_smm_base" , "smm_base"], ["msr_smm_addr" , "smm_addr"], ["msr_smm_mask" , "smm_mask"], ["mcg_status" , "ia32_mcg_status"], ["mcg_ctl" , "ia32_mcg_ctl"], ["sysenter_cs" , "ia32_sysenter_cs"], ["sysenter_eip" , "ia32_sysenter_eip"], ["sysenter_esp" , "ia32_sysenter_esp"], ["p5_mc_addr" , "ia32_p5_mc_addr"], ["p5_mc_type" , "ia32_p5_mc_type"]] # remove wrong MSR from x86 processors for cl in ["x86-hammer", "x86-k7"]: for o in all_objects(set, cl): if "p5_mc_addr" in dir(o): remove_attr(o, "p5_mc_addr") if "p5_mc_type" in dir(o): remove_attr(o, "p5_mc_type") # translate old MSRs into new for cl in x86_classes: for o in all_objects(set, cl): if "started" in dir(o): remove_attr(o, "started") for p in msr_translate: old,new = p if old in dir(o): rename_attr(o, new, old) # build correct threads attribute for hyperthreaded cpus shared_state_sets = {} for cl in x86_classes: for o in all_objects(set, cl): if "shared_state" in dir(o): if o.shared_state: try: shared_state_sets[o.shared_state].append(o) except: shared_state_sets[o.shared_state] = [o.shared_state, o] remove_attr(o, "shared_state") for k in shared_state_sets.keys(): for o in shared_state_sets[k]: o.threads = shared_state_sets[k] # update apic_p4 to apic with P4 state for o in all_objects(set, "apic"): if "lvt_thermal_sensor" in dir(o): # this is an apic_p4, convert it but let broadcast address untouched o.apic_type = "P4" o.version = 0x14 else: o.apic_type = "P6" o.version = 0x18 def update_1329_to_1330(set): for cfg in all_objects(set, "ppc403gcx-cfg"): if not "ic" in dir(cfg): for m in cfg.cpu.dcr_space.map: if m[1].classname == "ppc403gcx-ic": cfg.ic = m[1] break def update_pq2_attrs_1329(set): # The cpm module now posts event, add queue attribute if none defined # Take the queue from associated mcc1 module for o in (all_objects(set, "mpc8260-cpm") + all_objects(set, "mpc8270-cpm") + all_objects(set, "mpc8280-cpm")): if not "queue" in dir(o): o.queue = o.mcc1.queue # Remove txbd_monitor references in tx_channels_active in fcc_atm for o in all_objects(set, "mpc8260-fcc-atm") + all_objects(set, "mpc8280-fcc-atm"): o.tx_channels_active = [x[0] for x in o.tx_channels_active] if "fcc" in dir(o): o.ram_tx_enabled = not not (o.fcc.reg_GFMR & (1 << 4)) else: o.ram_tx_enabled = 0 # Fix FCC fast ethernets for o in (all_objects(set, "mpc8260-fcc-fast-ethernet") + all_objects(set, "mpc8270-fcc-fast-ethernet") + all_objects(set, "mpc8280-fcc-fast-ethernet")): remove_attr(o, "txbd_monitor") if "fcc" in dir(o): o.tx_enabled = not not (o.fcc.reg_GFMR & (1 << 4)) else: o.tx_enabled = 0 # Fix SCC UARTs for o in (all_objects(set, "mpc8260-scc-uart") + all_objects(set, "mpc8270-scc-uart") + all_objects(set, "mpc8280-scc-uart")): remove_attr(o, "txbd_monitor") if "scc" in dir(o): o.ram_tx_enabled = not not (o.scc.reg_GSMR_L & (1 << 4)) else: o.ram_tx_enabled = 0 # Fix SMC UARTs for o in (all_objects(set, "mpc8260-smc-uart") + all_objects(set, "mpc8270-smc-uart") + all_objects(set, "mpc8280-smc-uart")): remove_attr(o, "txbd_monitor") if "smc" in dir(o): o.ram_tx_enabled = not not (o.smc.reg_SMCMR & (1 << 1)) else: o.ram_tx_enabled = 0 # Finally, remove the txbd-monitor objects remove_class(set, "mpc8260-txbd-monitor") remove_class(set, "mpc8270-txbd-monitor") remove_class(set, "mpc8280-txbd-monitor") def update_1328_to_1329(set): update_pq2_attrs_1329(set) def update_mdio_attrs(set): for x in set.values(): # Purge all data on ongoing MDIO transfers as the format have # changed. remove_attr(x, 'mii_nvram_read_bit') remove_attr(x, 'mii_nvram_last_clock') remove_attr(x, 'mii_nvram_addr') remove_attr(x, 'mii_nvram_data_in') remove_attr(x, 'mii_nvram_op') remove_attr(x, 'mii_nvram_word') remove_attr(x, 'mii_nvram_in_size') remove_attr(x, 'nvram_read_bit') remove_attr(x, 'nvram_last_clock') remove_attr(x, 'nvram_addr') remove_attr(x, 'nvram_data_in') remove_attr(x, 'nvram_in_size') remove_attr(x, 'nvram_op') remove_attr(x, 'nvram_word') remove_attr(x, 'serial_reg') remove_attr(x, 'serial_op') remove_attr(x, 'serial_addr') remove_attr(x, 'serial_word') remove_attr(x, 'serial_read_bit') remove_attr(x, 'serial_in_size') def update_1327_to_1328(set): for cpu in all_objects(set, "MV64360") + all_objects(set, "MV64470"): rename_attr(cpu, 'partial_regs_pci_bus_PCI_Configuration_Data', 'regs_pci_bus_PCI_Configuration_Data') update_mdio_attrs(set) for cls in x86_classes: for obj in all_objects(set, cls): # Convert in_halt_state to activity_state in_halt_state = getattr(obj, "in_halt_state") activity_state = 0 if in_halt_state: activity_state = 1 setattr(obj, "activity_state", activity_state) remove_attr(obj, "in_halt_state") # Remove useless pending_device attribute if hasattr(obj, "pending_device"): remove_attr(obj, "pending_device") # Rename pni_enabled to cpuid_sse3 if hasattr(obj, "pni_enabled"): rename_attr(obj, "cpuid_sse3", "pni_enabled") # Temporary interrupt mask q = getattr(obj, "step_queue") has_interrupt_mask = 0 for e in q: if e[1] == "release temporary interrupt mask": has_interrupt_mask = 1 q = filter(lambda a: a[1] != "release temporary interrupt mask", q) setattr(obj, "step_queue", q) temp_mask = 0 if has_interrupt_mask: temp_mask = 1 # Block_By_Sti setattr(obj, "temporary_interrupt_mask", temp_mask) if (hasattr(obj, "pending_debug_exceptions") and getattr(obj, "pending_debug_exceptions")): setattr(obj, "pending_debug_exception", 1) rename_attr(obj, "pending_debug_exception_dr6", "pending_debug_exceptions") def mv_for_all_objects(set, classname, function, mv_obj): for obj in all_objects(set, classname): function(set, obj, mv_obj) def replace_mv64xxx_gbe_ptr_1326(set, gbe_obj): def update_mv64xxx_gbe_maps(set, space, mv_obj): try: maplist = space.map except: return if len([x for x in maplist if (x[1].classname == 'MV64360-gbe' or x[1].classname == 'MV64470-gbe')]) == 0: return for i in range(len(maplist)): if (maplist[i][1].classname == 'MV64360-gbe' or maplist[i][1].classname == 'MV64470-gbe'): maplist[i][1] = mv_obj space.map = maplist def update_mv64xxx_phys(set, phy, mv_obj): if (phy.mac.classname == 'MV64360-gbe' or phy.mac.classname == 'MV64470-gbe'): phy.mac = mv_obj try: mv_obj = set[(gbe_obj.name).strip('_gbe')] except: return mv_for_all_objects(set, "memory-space", update_mv64xxx_gbe_maps, mv_obj) mv_for_all_objects(set, "BCM5421S", update_mv64xxx_phys, mv_obj); def copy_mv64xxx_attrs_1326(set, gbe_obj): try: mv_obj = set[(gbe_obj.name).strip('_gbe')] except: return SIM_get_class('MV64360') for gbe_attr in dir(gbe_obj): for mv_attr in sim.classes['MV64360'].attributes: if gbe_attr == mv_attr and not gbe_attr[0:2] == "__": exec "mv_obj.%s = gbe_obj.%s" % (gbe_attr, gbe_attr) def update_mv64xxx_pci_1326(set, obj): setattr(obj, 'pci_config_header_type', 0x80) def update_system_cmp_object_list_1326(set, system_classname, obj_classname): for obj in all_objects(set, system_classname): for l in [x for x in obj.object_list if x[-4:] == "_gbe"]: del obj.object_list[l] def update_rtc_time_1326(set, obj): import time val = getattr(obj, "rtc_time") try: time.strptime(val, '%Y-%m-%d %H:%M:%S %Z') except Exception, msg: val = val[:len("yyyy-mm-dd HH:MM:SS")]+" UTC" setattr(obj, "rtc_time", val) def update_1326_to_1327(set): # remove mv64xxx_gbe pointers for_all_objects(set, 'MV64360-gbe', replace_mv64xxx_gbe_ptr_1326) for_all_objects(set, 'MV64470-gbe', replace_mv64xxx_gbe_ptr_1326) # copy attrs from mv64xxx-gbe to mv64xxx for_all_objects(set, 'MV64360-gbe', copy_mv64xxx_attrs_1326) for_all_objects(set, 'MV64470-gbe', copy_mv64xxx_attrs_1326) # remove mv64xxx-gbe remove_class(set, 'MV64360-gbe') remove_class(set, 'MV64470-gbe') # remove from mv64xxx-gbe system component list update_system_cmp_object_list_1326(set, 'sbc750gx-board', 'MV64360-gbe') update_system_cmp_object_list_1326(set, 'daredevil-board', 'MV64470-gbe') update_system_cmp_object_list_1326(set, 'atlantis-board', 'MV64360-gbe') # make sure mv64xxx_pci_fx header_type[7] = 1 for_all_objects(set, 'MV64360-pci-f0', update_mv64xxx_pci_1326) for_all_objects(set, 'MV64360-pci-f1', update_mv64xxx_pci_1326) for_all_objects(set, 'MV64360-pci-f2', update_mv64xxx_pci_1326) for_all_objects(set, 'MV64360-pci-f3', update_mv64xxx_pci_1326) for_all_objects(set, 'MV64360-pci-f4', update_mv64xxx_pci_1326) for_all_objects(set, 'MV64470-pci-f0', update_mv64xxx_pci_1326) for_all_objects(set, 'MV64470-pci-f1', update_mv64xxx_pci_1326) for_all_objects(set, 'MV64470-pci-f2', update_mv64xxx_pci_1326) for_all_objects(set, 'MV64470-pci-f3', update_mv64xxx_pci_1326) for_all_objects(set, 'MV64470-pci-f4', update_mv64xxx_pci_1326) # Permit loading of checkpoints with invalid rtc_time, but which # could be loaded before for_all_objects(set, 'x86-apic-system', update_rtc_time_1326) def update_etherlink_1321(set, link): # network interfaces should now register for the broadcast address bcast = ["ff:ff:ff:ff:ff:ff"]*2 for (x, y, name, dev, (listen_macs, promics)) in link.devices: if bcast not in listen_macs: listen_macs.append(bcast) def rename_piix4_usb_1322(set, obj): obj.__class_name__ = 'piix4_usb_dummy' def rename_ppc440gx_obp_1322(set, obj): obj.__class_name__ = 'ppc440gx-opb' def update_1321_to_1322(set): # Incorrect name of class for_all_objects(set, 'ppc440gx-obp', rename_ppc440gx_obp_1322) # Use dummy PIIX4 USB for old checkpoints for_all_objects(set, 'piix4_usb', rename_piix4_usb_1322) def update_1320_to_1321(set): # fix MV64360/MV64470 checkpoints to use new PCI classes objs = all_objects(set, 'MV64360-pci') + all_objects(set, 'MV64470-pci') for obj in objs: obj.__class_name__ = obj.classname + "-f%d" % obj.function remove_attr(obj, "function") # fix x86-components that are missing phys_mem objs = ( all_objects(set, 'x86-system') + all_objects(set, 'x86-apic-bus-system') + all_objects(set, 'x86-apic-system') + all_objects(set, 'x86-separate-mem-io-system')) for obj in objs: obj.object_list['phys_mem'] = obj.object_list['pci_mem'] for_all_objects(set, "ethernet-link", update_etherlink_1321) def update_1318_to_1319(set): # some broken checkpoints do not have a cpu_list attribute in the top # level component, set a dummy (possibly incorrect) attribute as workaround cpu = None patch_list = [] for obj in set.values(): try: SIM_get_class(obj.classname) except: continue if 'processor' in sim.classes[obj.classname].interfaces: cpu = obj elif 'component' in sim.classes[obj.classname].interfaces: try: if obj.top_level and not hasattr(obj, 'cpu_list'): patch_list += [obj] except: pass for obj in patch_list: obj.cpu_list = [cpu] def update_1317_to_1318(set): reg_aliases = ['ubamr', 'uctrl', 'ummcr0', 'ummcr1', 'ummcr2', 'ummcra', 'ummcrh', 'upmc1', 'upmc2', 'upmc3', 'upmc4', 'upmc5', 'upmc6', 'upmc7', 'upmc8', 'usdar', 'usiar', 'usprg3', 'usprg4', 'usprg5', 'usprg6', 'usprg7', 'utbl', 'utbu', 'utrace'] for obj in set.values(): if obj.classname in ppc_classes: for reg_alias in reg_aliases: remove_attr(obj, reg_alias) def update_ppc440_pci_1316(set, space): try: maplist = space.map except: return if len([x for x in maplist if x[1].classname == 'ppc440gp-pci']) == 0: return for i in range(len(maplist)): if (maplist[i][1].classname == 'ppc440gp-pci' and maplist[i][2] == 1): maplist[i][3] = 0 space.map = maplist def update_1316_to_1317(set): for_all_objects(set, "memory-space", update_ppc440_pci_1316) objs = (all_objects(set, 'ddr2-memory-module') + all_objects(set, 'ddr-memory-module') + all_objects(set, 'sdram-memory-module')) for obj in objs: if obj.registered: obj.module_type = "RDIMM" else: obj.module_type = "UDIMM" remove_attr(obj, 'registered') def update_1304_to_1305(set): remove_class(set, 'le-permissions') def update_tlb_1302_970(set, cpu): tlb = cpu.tlb for i in range(len(tlb)): for j in range(len(tlb[i])): tlb[i][j].append(tlb[i][j][4]) tlb[i][j].append(tlb[i][j][5]) tlb[i][j][5] = 0 # large page encoding tlb[i][j][4] = 0 # big segment encoding cpu.tlb = tlb def update_1302_to_1303(set): for_all_objects(set, "ppc970fx", update_tlb_1302_970) def update_pending_exceptions_1301(set, cpu, table, excvec_bits): pending = cpu.pending_exceptions exceptions = [] for i in range(excvec_bits): exc = (pending >> (excvec_bits - 1 - i)) & 1 if not exc: continue exc_name = table[i] exceptions += [exc_name] cpu.pending_exceptions = exceptions def update_pending_exceptions_1301_4xx(set, cpu): table = ["Critical_Input", "Machine_check", "DSI", "ISI", "External_interrupt", "Alignment", "Program", "System_call", "PIT", "FIT", "Watchdog", "Data_TLB_miss", "Instruction_TLB_miss", "Debug"] update_pending_exceptions_1301(set, cpu, table, 32) def update_pending_exceptions_1301_booke(set, cpu): table = ["Critical_interrupt", "Machine_check", "DSI", "ISI", "External_interrupt", "Alignment", "Program", "Floating-point_unavailable", "System_call", "Auxiliary_processor_unavailable", "Decrementer", "FIT", "Watchdog", "Data_TLB_miss", "Instruction_TLB_miss", "Debug", "reserved_16", "reserved_17", "reserved_18", "reserved_19", "reserved_20", "reserved_21", "reserved_22", "reserved_23", "reserved_24", "reserved_25", "reserved_26", "reserved_27", "reserved_28", "reserved_29", "reserved_30", "reserved_31", "SPE_APU_unavailable", "SPE_floating-point_data", "SPE_floating-point_round", "Performance_monitor"] update_pending_exceptions_1301(set, cpu, table, 64) def update_pending_exceptions_1301_750(set, cpu): table = ["Reserved", "System_reset", "Machine_check", "Data_storage", "Data_segment", "Instruction_storage", "Instruction_segment", "External_interrupt", "Alignment", "Program", "Floating-point_unavailable", "Decrementer", "Reserved_a", "Reserved_b", "System_call", "Trace", "Reserved_e", "Performance_monitor", "Altivec_Unavailable", "Instruction_Tlb_miss", "Data_Tlb_Load_miss", "Data_Tlb_Store_miss", "Instruction_address_breakpoint", "System_management_interrupt", "Reserved_15", "Altivec_Assist", "Thermal_management_interrupt"] update_pending_exceptions_1301(set, cpu, table, 32) def update_add_ftp_alg_in(set, forward_in_obj): sn = forward_in_obj.tcp forward_out_obj = forward_in_obj.forward_handler alg_name = sn.name + "_ftp_alg" if set.has_key(alg_name): alg_obj = set[alg_name] else: alg_obj = pre_conf_object(alg_name, "ftp-alg") set[alg_name] = alg_obj alg_obj.forward_handler = forward_out_obj alg_obj.incoming_handler = forward_in_obj forward_out_obj.algs = [alg_obj] forward_in_obj.algs = [alg_obj] remove_attr(forward_in_obj, "forward_handler") pcmcia_dev = None slot0_att = None slot1_att = None slot0_cmn = None slot1_cmn = None def update_pcmcia_1301_map(set, space): try: maplist = space.map except: return if len([x for x in maplist if x[1] == pcmcia_dev]) == 0: return newlist = [] map_functions = [0, 0x100, 0x200, 0x210, 0x300, 0x310] for m in maplist: if m[1] == pcmcia_dev: if m[2] == 2: m[1] = slot0_att elif m[2] == 3: m[1] = slot1_att elif m[2] == 4: m[1] = slot0_cmn elif m[2] == 5: m[1] = slot1_cmn if m[2] != 255: # PCI config-space m[2] = map_functions[m[2]] newlist.append(m) space.map = newlist def update_pcmcia_mappings(set, obj, slot): global slot0_att, slot1_att, slot0_cmn, slot1_cmn if slot == 0: ide = obj.slot0_ata else: ide = obj.slot1_ata slot_cmn = pre_conf_object(ide.name + '_cmn', "memory-space") slot_att = pre_conf_object(ide.name + '_att', "memory-space") set[ide.name + '_cmn'] = slot_cmn set[ide.name + '_att'] = slot_att # TODO: read data cis_image = pre_conf_object(ide.name + '_cis_image', "image") cis_image.size = 768 cis = pre_conf_object(ide.name + '_cis', "rom") cis.image = cis_image set[ide.name + 'cis'] = cis set[ide.name + 'cis_image'] = cis_image slot_cmn.map = [ [0, ide, 0, 0, 8], [0xe, ide, 0, 8, 1]] for i in range(0x400, 0x800, 2): slot_cmn.map.append([i, ide, 0, 0x0, 0x2]) slot_att.map = [[0x0, cis, 0, 0, 0x300]] if slot == 0: remove_attr(obj, 'slot0_ata') remove_attr(obj, 'slot0_cis') obj.slot0_spaces = [slot_att, slot_cmn, slot_cmn] slot0_att = slot_att slot0_cmn = slot_cmn else: remove_attr(obj, 'slot1_ata') remove_attr(obj, 'slot1_cis') obj.slot1_spaces = [slot_att, slot_cmn, slot_cmn] slot1_att = slot_att slot1_cmn = slot_cmn ide_cis = ( 0x01, 0x03, 0xd9, 0x01, 0xff, 0x1c, 0x04, 0x03, 0xd9, 0x01, 0xff, 0x18, 0x02, 0xdf, 0x01, 0x20, 0x04, 0x01, 0x4e, 0x00, 0x02, 0x15, 0x2b, 0x04, 0x01, 0x56, 0x69, 0x6b, 0x69, 0x6e, 0x67, 0x20, 0x41, 0x54, 0x41, 0x20, 0x46, 0x6c, 0x61, 0x73, 0x68, 0x20, 0x43, 0x61, 0x72, 0x64, 0x20, 0x20, 0x20, 0x20, 0x00, 0x53, 0x54, 0x4f, 0x52, 0x4d, 0x20, 0x20, 0x00, 0x53, 0x54, 0x42, 0x4d, 0x30, 0x00, 0xff, 0x21, 0x02, 0x04, 0x01, 0x22, 0x02, 0x01, 0x01, 0x22, 0x03, 0x02, 0x04, 0x5f, 0x1a, 0x05, 0x01, 0x03, 0x00, 0x02, 0x0f, 0x1b, 0x0b, 0xc0, 0x40, 0xa1, 0x27, 0x55, 0x4d, 0x5d, 0x75, 0x08, 0x00, 0x21, 0x1b, 0x06, 0x00, 0x01, 0x21, 0xb5, 0x1e, 0x4d, 0x1b, 0x0d, 0xc1, 0x41, 0x99, 0x27, 0x55, 0x4d, 0x5d, 0x75, 0x64, 0xf0, 0xff, 0xff, 0x21, 0x1b, 0x06, 0x01, 0x01, 0x21, 0xb5, 0x1e, 0x4d, 0x1b, 0x12, 0xc2, 0x41, 0x99, 0x27, 0x55, 0x4d, 0x5d, 0x75, 0xea, 0x61, 0xf0, 0x01, 0x07, 0xf6, 0x03, 0x01, 0xee, 0x21, 0x1b, 0x06, 0x02, 0x01, 0x21, 0xb5, 0x1e, 0x4d, 0x1b, 0x12, 0xc3, 0x41, 0x99, 0x27, 0x55, 0x4d, 0x5d, 0x75, 0xea, 0x61, 0x70, 0x01, 0x07, 0x76, 0x03, 0x01, 0xee, 0x21, 0x1b, 0x06, 0x03, 0x01, 0x21, 0xb5, 0x1e, 0x4d, 0x14) def add_pcmcia_cis_1301(arg, ini_obj): obj = SIM_get_object(arg) spaces = [obj.slot0_spaces, obj.slot1_spaces] for i in (0, 1): if len(spaces[i]) == 1: continue attr = spaces[i][0] for i in range(len(ide_cis)): attr.iface.memory_space.write(attr, None, i * 2, (ide_cis[i], ), 1) # Fake some attribute space registers attr.iface.memory_space.write(attr, None, 0x204, (0x2e, ), 1) SIM_hap_delete_callback("Core_Configuration_Loaded", add_pcmcia_cis_1301, arg) def update_pcmcia_1301(set, obj): global pcmcia_dev pcmcia_dev = obj obj.config_registers[15] = 0x00000100 # interrupt pin A update_pcmcia_mappings(set, obj, 0) update_pcmcia_mappings(set, obj, 1) if obj.slot0_memory_windows[0][0]: obj.slot0_memory_windows[0][1] = 3 if obj.slot0_memory_windows[4][0]: obj.slot0_memory_windows[4][1] = 2 if obj.slot1_memory_windows[0][0]: obj.slot1_memory_windows[0][1] = 3 if obj.slot1_memory_windows[4][0]: obj.slot1_memory_windows[4][1] = 2 obj.slot0_registers[1] = 0xef obj.slot1_registers[1] = 0xef for_all_objects(set, "memory-space", update_pcmcia_1301_map) SIM_hap_add_callback("Core_Configuration_Loaded", add_pcmcia_cis_1301, obj.name) def update_uart_1301(set, obj): if not hasattr(obj, "interrupt_mask_out2"): obj.interrupt_mask_out2 = 1 def update_x86_components_1301(set, obj): if 'x87' not in obj.object_list and 'x87[0]' in obj.object_list: obj.object_list['x87'] = obj.object_list['x87[0]'] if 'x87[0]' in obj.object_list: del obj.object_list['x87[0]'] remove_attr(obj, 'num_threads') def update_1301_to_1302(set): for_all_objects(set, "ppc403gcx", update_pending_exceptions_1301_4xx) for_all_objects(set, "ppc405gp", update_pending_exceptions_1301_4xx) for_all_objects(set, "ppc440gp", update_pending_exceptions_1301_booke) for_all_objects(set, "ppc440gx", update_pending_exceptions_1301_booke) for_all_objects(set, "ppce500", update_pending_exceptions_1301_booke) for_all_objects(set, "ppc603e", update_pending_exceptions_1301_750) for_all_objects(set, "ppc7400", update_pending_exceptions_1301_750) for_all_objects(set, "ppc7447", update_pending_exceptions_1301_750) for_all_objects(set, "ppc7450", update_pending_exceptions_1301_750) for_all_objects(set, "ppc7457", update_pending_exceptions_1301_750) for_all_objects(set, "ppc750", update_pending_exceptions_1301_750) for_all_objects(set, "ppc750fx", update_pending_exceptions_1301_750) for_all_objects(set, "ppc750gx", update_pending_exceptions_1301_750) for_all_objects(set, "ppc755", update_pending_exceptions_1301_750) for_all_objects(set, "ppc970fx", update_pending_exceptions_1301_750) for_all_objects(set, "CL-PD6729", update_pcmcia_1301) for cls in x86_classes: remove_class_attr(set, cls, 'smbase') for_all_objects(set, "port-forward-incoming-server", update_add_ftp_alg_in) for cpu in (all_objects(set, "ultrasparc-ii") + all_objects(set, "ultrasparc-iii") + all_objects(set, "ultrasparc-iii-plus") + all_objects(set, "ultrasparc-iii-i")): rename_attr(cpu, 'cpu_group', 'irq_bus') for_all_objects(set, "NS16550", update_uart_1301) for_all_objects(set, "NS16450", update_uart_1301) # somewhere between 1301 and 1325 x86-cpu components become incompatible for_all_objects(set, "pentium-4-cpu", update_x86_components_1301) def update_event_queue_1300(cpu): # Read_slot has been removed and should not be present, but we map it # to the default slot just in case slot_names = ["sync", "pre-update", "update", "update2", "default", "default", "assert", "event-end"] ignore_events = set(("User breakpoint", "Internal: update time counter", "Internal: update step counter", "Internal: renew queue", "Head of Time", "Deleted Event", "Check for Async Events")) q = [[], []] hot_step = 0 for (evobj, val, slot, queue, time) in cpu.event_queue: if evobj == "$simple_event": if val == "Head of Time": hot_step = time if val in ignore_events: continue evobj = None q[queue].append([evobj, val, slot_names[slot], time]) # compensate for a head of time at step > 0 q[Sim_Queue_Time] = [[o, v, s, t + hot_step] for [o, v, s, t] in q[Sim_Queue_Time]] del cpu.event_queue cpu.step_queue = q[Sim_Queue_Step] cpu.time_queue = q[Sim_Queue_Time] def update_1300_to_1301(set): # Translate to new event queue attributes: for obj in set.values(): try: SIM_get_class(obj.classname) except: continue if 'processor' in sim.classes[obj.classname].interfaces: update_event_queue_1300(obj) create_central_client = False remote_central = False remote_host = None first_queue = None def remove_default_target_endian_1299(set, obj): try: if len(obj.default_target) == 5: obj.default_target = obj.default_target[:4] except: pass def replace_dcr_mapping_1299(set, ppc): if len(ppc.dcr): dcr_map = {} for d in ppc.dcr: if dcr_map.has_key(d[0]): dcr_map[d[0]].append(d[1]) else: dcr_map[d[0]] = [d[1]] mem_map = [] for obj in dcr_map.keys(): dcr_list = dcr_map[obj] first = dcr_list[0] for dcr in dcr_list: mem_map += [[(dcr)*4, set[obj], 0, (dcr-first)*4, 4]] dcr_space = ppc.name + '-dcr-space' set[dcr_space] = pre_conf_object(dcr_space, 'memory-space') ppc.dcr_space = set[dcr_space] set[dcr_space].map = mem_map remove_attr(ppc, 'dcr') def fix_405_uic_1299(set, uic): print "WARNING: Converting an old 405 based configuration" print "The interrupt controller has changed so that irq levels are according" print "to documentation. Will try to patch devices but there might be more" print "devices connected to the UIC which needs to be patched manually." print "Typically obj.irq_level = 31 - old_irq_level" uic.target = uic.irq_dev uic.critical_target = uic.irq_dev uic.target_level = 0 uic.critical_target_level = 1 remove_attr(uic, 'irq_dev') rename_attr(uic, 'UICx_CR', 'uiccr') rename_attr(uic, 'UICx_ER', 'uicer') rename_attr(uic, 'UICx_PR', 'uicvpr') rename_attr(uic, 'UICx_SR', 'uicsr') rename_attr(uic, 'UICx_TR', 'uictr') rename_attr(uic, 'UICx_VCR', 'uicvcr') for obj in all_objects(set, 'ppc405gp-iic'): if obj.interrupt_device == uic: print "Patching %s (level %d -> %d)" % (obj.name, obj.interrupt_level, 31 - obj.interrupt_level) obj.interrupt_level = 31 - obj.interrupt_level for obj in all_objects(set, 'ppc405gp-pci'): irqs = obj.irq_routing new_irq = [] for i in irqs: if i[1] == uic.name: print "Patching %s (level %d -> %d)" % (obj.name, i[2], 31 - i[2]) new_irq.append([i[0], i[1], 31 - i[2]]) else: new_irq.append(i) obj.irq_routing = new_irq for obj in all_objects(set, 'NS16550'): if obj.irq_dev == uic: print "Patching %s (level %d -> %d)" % (obj.name, obj.interrupt_pin, 31 - obj.interrupt_pin) obj.interrupt_pin = 31 - obj.interrupt_pin def remove_uic_attributes_1299(set, uic): remove_attr(uic, 'UICx_VR') remove_attr(uic, 'UICx_MSR') def add_cpu_obj_1299(set, obj): # Find which CPU this object is mapped into cpus = all_objects(set, 'ppc405gp') + all_objects(set, 'ppc440gp') + all_objects(set, 'ppc440gx') for cpu in cpus: space = cpu.dcr_space map = space.map for m in map: if m[1] == obj: obj.cpu = cpu break def change_memory_attr_1299(set, obj): if hasattr(obj, 'memory') and type(obj.memory) == str: obj.memory = set[obj.memory] def change_mal_attr_1299(set, obj): if hasattr(obj, 'mal') and type(obj.mal) == str: obj.mal = set[obj.mal] def change_irq_attr_1299(set, obj): if hasattr(obj, 'irq_routing') and type(obj.irq_routing) == list: for i in range(len(obj.irq_routing)): if type(obj.irq_routing[i][1]) == str: obj.irq_routing[i][1] = set[obj.irq_routing[i][1]] def rename_ioapic_1299(set, obj): obj.__class_name__ = 'io-apic' def rename_cheetah_plus_mmu_1299(set, obj): obj.__class_name__ = 'cheetah-plus-mmu' def rename_ultrasparc_iii_plus_1299(set, obj): obj.__class_name__ = 'ultrasparc-iii-plus' def rename_ultrasparc_iv_plus_1299(set, obj): obj.__class_name__ = 'ultrasparc-iv-plus' def set_dec_srom_width_1299(set, obj): obj.srom_address_width = 6 def fix_fb_mem_1299(set, obj): name = "%s-image" % obj.name image = pre_conf_object(name, 'image') if obj.classname == 'ragexl': image.size = 0x800000 elif obj.classname.startswith('vga'): image.size = 0x40000 elif obj.classname.startswith('voodoo3'): image.size = 0x1000000 set[name] = image obj.image = image def update_1299_to_1300(set): for_all_objects(set, 'ragexl', fix_fb_mem_1299) for_all_objects(set, 'vga', fix_fb_mem_1299) for_all_objects(set, 'vga_pci', fix_fb_mem_1299) for_all_objects(set, 'voodoo3', fix_fb_mem_1299) for_all_objects(set, 'voodoo3-agp', fix_fb_mem_1299) for_all_objects(set, 'ppc403gcx', replace_dcr_mapping_1299) for_all_objects(set, 'ppc405gp', replace_dcr_mapping_1299) for_all_objects(set, 'ppc440gp', replace_dcr_mapping_1299) for_all_objects(set, 'ppc440gx', replace_dcr_mapping_1299) for_all_objects(set, 'ppc405gp-uic', fix_405_uic_1299) for_all_objects(set, 'ppc440gp-uic', remove_uic_attributes_1299) for_all_objects(set, 'ppc440gx-uic', remove_uic_attributes_1299) for_all_objects(set, 'ppc405gp-dma', add_cpu_obj_1299) for_all_objects(set, 'ppc440gp-dma', add_cpu_obj_1299) for_all_objects(set, 'ppc440gx-dma', add_cpu_obj_1299) for_all_objects(set, 'ppc405gp-ebc', add_cpu_obj_1299) for_all_objects(set, 'ppc440gp-ebc', add_cpu_obj_1299) for_all_objects(set, 'ppc440gx-ebc', add_cpu_obj_1299) for_all_objects(set, 'ppc405gp-mal', add_cpu_obj_1299) for_all_objects(set, 'ppc440gp-mal', add_cpu_obj_1299) for_all_objects(set, 'ppc440gx-mal', add_cpu_obj_1299) for_all_objects(set, 'misc-dcr', add_cpu_obj_1299) for_all_objects(set, 'ppc405gp-dma', change_memory_attr_1299) for_all_objects(set, 'ppc440gp-dma', change_memory_attr_1299) for_all_objects(set, 'ppc440gx-dma', change_memory_attr_1299) for_all_objects(set, 'ppc405gp-mal', change_memory_attr_1299) for_all_objects(set, 'ppc440gp-mal', change_memory_attr_1299) for_all_objects(set, 'ppc440gx-mal', change_memory_attr_1299) for_all_objects(set, 'ppc405gp-emac', change_mal_attr_1299) for_all_objects(set, 'ppc440gp-emac', change_mal_attr_1299) for_all_objects(set, 'ppc440gx-emac', change_mal_attr_1299) for_all_objects(set, 'ppc405gp-pci', change_irq_attr_1299) for_all_objects(set, 'ppc440gp-pci', change_irq_attr_1299) for_all_objects(set, 'ppc440gx-pci', change_irq_attr_1299) for_all_objects(set, 'memory-space', remove_default_target_endian_1299) for_all_objects(set, 'port-space', remove_default_target_endian_1299) for_all_objects(set, 'I/O-APIC', rename_ioapic_1299) for_all_objects(set, 'cheetah+mmu', rename_cheetah_plus_mmu_1299) for_all_objects(set, 'ultrasparc-iii+', rename_ultrasparc_iii_plus_1299) for_all_objects(set, 'ultrasparc-iv+', rename_ultrasparc_iv_plus_1299) try: SIM_get_object('dummy-component') set['system-component'] = pre_conf_object('system-component', 'dummy-component') except: pass for cls in ['DEC21041', 'DEC21140A', 'DEC21143']: for_all_objects(set, cls, set_dec_srom_width_1299) for obj in all_objects(set, 'i82077'): try: obj.drives = [x[1] for x in obj.drives] except: pass for cls in mips_classes: remove_class_attr(set, cls, 'itlb') remove_class_attr(set, cls, 'dtlb') for obj in all_objects(set, 'i8042'): if hasattr(obj, 'reset_targets') and len(obj.reset_targets) > 0: bus = pre_conf_object(obj.name + '_reset', 'x86-reset-bus') set[obj.name + '_reset'] = bus bus.reset_targets = obj.reset_targets obj.reset_target = bus remove_attr(obj, 'a20_target') remove_attr(obj, 'reset_targets') for cls in x86_classes: remove_class_attr(set, cls, 'stc_segreg_enabled') def connections_1200(set, obj): try: connections = obj.connections except: return # <port-forward-outgoing-server>.connections changed from # [[si]|[sisi]*] # to # [[si]|[sissi]*] # Find the service-node-device and use that IP new_ip = "0.0.0.0" for snd in [x for x in set.values() if x.classname == 'service-node-device']: new_ip = snd.ip_address break newlist = [] for sublist in connections: if len(sublist) == 2: newlist.append(sublist) elif len(sublist) == 4: newlist.append([sublist[0], sublist[0], new_ip, sublist[2], sublist[3]]) obj.connections = newlist def update_1200_to_1201(set): for_all_objects(set, "port-forward-outgoing-server", connections_1200) def sim_1199(set, obj): global create_central_client, remote_central, remote_host try: if obj.remote_simics_central == 1: create_central_client = True remote_central = True remote_host = obj.simics_central_host except: pass remove_attr(obj, 'remote_simics_central') remove_attr(obj, 'simics_central_host') remove_attr(obj, 'central_debug') def connect_eth_1199(arg, ini_obj): dev = SIM_get_object(arg[0]) net = SIM_get_object(arg[1]) dev.link = net SIM_hap_delete_callback("Core_Configuration_Loaded", connect_eth_1199, arg) def eth_device_1199(set, obj): global remote_central if remote_central: # create local link if network in other simics link = pre_conf_object('net0', 'ethernet_link') set['net0'] = link link.central = set['central_client'] remote_central = False link = link.name else: try: link = obj.network except: pass if obj.connected: SIM_hap_add_callback("Core_Configuration_Loaded", connect_eth_1199, (obj.name, link)) remove_attr(obj, 'network') remove_attr(obj, 'connected') remove_attr(obj, 'min_latency') remove_attr(obj, 'backdoor_ok') remove_attr(obj, 'auto_connect') remove_attr(obj, 'individual_address') def ethernet_net_1199(set, obj): obj.__class_name__ = 'ethernet-link' remove_attr(obj, 'frame_loss') remove_attr(obj, 'network_id') remove_attr(obj, 'handle_dhcp') remove_attr(obj, 'shared_media') remove_attr(obj, 'netip') remove_attr(obj, 'ethernet_central') if obj.central_device: snd = pre_conf_object('sn0_dev', 'service-node-device') set['sn0_dev'] = snd snd.service_node = set['sn0'] snd.arp_table = obj.arp snd.mac_address = obj.ownmac snd.ip_address = obj.ownip snd.netmask = obj.netmask snd.queue = first_queue set['sn0'].routing_table = [[snd.ip_address, snd.netmask, '0.0.0.0', snd]] snd.link = obj try: obj.central = set['central_client'] except: pass remove_attr(obj, 'central_device') remove_attr(obj, 'arp') remove_attr(obj, 'ownmac') remove_attr(obj, 'ownip') remove_attr(obj, 'netmask') def ethernet_central_1199(set, obj): new_dns = [] for dns in obj.dns: new_dns.append([None, dns[0], dns[1], dns[2]]) set['sn0'].hosts = new_dns del set[obj.name] def central_1199(set, obj): global create_central_client port = obj.ip_port file = obj.unix_socket del set['central'] if port == -1 and len(file) == 0: return # central was used cs = pre_conf_object('central_server', 'central-server') set['central_server'] = cs if len(file): cs.unix_socket = file cs.unix_socket_mode = 438 if port != -1: cs.tcp_port = port create_central_client = True def update_1199_to_1200(set): global remote_host for_all_objects(set, 'sim', sim_1199) for_all_objects(set, 'central', central_1199) if create_central_client: cc = pre_conf_object('central_client', 'central-client') set['central_client'] = cc if remote_host and len(remote_host): if not ':' in remote_host and not '/' in remote_host: # if port not specified, add default one remote_host += ":4711" cc.server = remote_host elif not remote_central: cc.server = pre_conf_object('central_server', 'central-server') set['central_server'] = cc.server if len(all_objects(set, 'ethernet-central')): set['sn0'] = pre_conf_object('sn0', 'service-node') for_all_objects(set, 'ethernet-central', ethernet_central_1199) for_all_objects(set, 'ethernet-network', ethernet_net_1199) for_all_objects(set, 'sbus-hme', eth_device_1199) for_all_objects(set, 'cheerio-hme', eth_device_1199) for_all_objects(set, 'BCM5703C', eth_device_1199) for_all_objects(set, 'BCM57034', eth_device_1199) for_all_objects(set, 'AM79C960', eth_device_1199) for_all_objects(set, 'cassini', eth_device_1199) for_all_objects(set, 'DEC21041', eth_device_1199) for_all_objects(set, 'DEC21140A', eth_device_1199) for_all_objects(set, 'DEC21143', eth_device_1199) for_all_objects(set, 'ppc440gp-emac', eth_device_1199) for_all_objects(set, 'CS8900A', eth_device_1199) remove_class_attr(set, 'ppc440gp', 'ear') for l in [x.name for x in set.values() if x.classname == 'central-links']: del set[l] remove_class_attr(set, 'ICS951601', 'address_mask') remove_class_attr(set, 'NS16450', 'send_while_playing_back') remove_class_attr(set, 'NS16550', 'send_while_playing_back') remove_class_attr(set, 'M5823', 'irq_disable') remove_class_attr(set, 'DS12887', 'irq_disable') remove_class_attr(set, 'DS17485', 'irq_disable') remove_class_attr(set, 'i8254', 'rw_state') for obj in all_objects(set, 'ppc440gp-mal'): # both tx and tx to the same irq-device in 440gp-mal obj.interrupts[1] = obj.interrupts[0] cpus = [x for x in set.values() if x.classname in x86_classes] for kbd in all_objects(set, 'i8042'): if len(cpus): # this is an x86 config kbd.reset_targets = cpus for obj in all_objects(set, 'port-space'): # remove obsolete 6th element (reverse-endian) try: for m in range(len(obj.map)): if len(obj.map[m]) == 6: obj.map[m].pop(-1) except: pass def update_1051_to_1052(set): remove_class_attr(set, 'server-console', 'data_out') remove_class_attr(set, 'server-console', 'poll_interval') def change_map_endian_1049(set, obj): try: # align base for serengeti empty mappings for i in range(len(obj.map)): off = obj.map[i][0] & 0x1fff if off == 0x60 and obj.map[i][4] == 0x10: obj.map[i][0] &= 0xffffffffffffe000 obj.map[i][4] &= 0x70 # change endian. 5 or shorter? - no endian info included if len(obj.map[i]) > 5: for j in range(5, len(obj.map[i])): if isinstance(obj.map[i][j], int): obj.map[i][j] = 0 # if length 6 and last is integer -> remove endian # since we don't support this format anymore. if len(obj.map[i]) == 6 and isinstance(obj.map[i][5], int): obj.map[i].pop(-1) # TODO: update vga mapping except Exception, msg: print msg pass def add_vga_memory_1049(set, obj): for vga in [x[1] for x in obj.map]: if type(vga) == str: vga = set[vga] if 'vga' in vga.classname or 'voodoo' in vga.classname: vga.memory_space = obj def update_1049_to_1050(set): for_all_objects(set, 'memory-space', change_map_endian_1049) for_all_objects(set, 'memory-space', add_vga_memory_1049) remove_class_attr(set, 'ide-disk', 'tr_rdy_dma') remove_class_attr(set, 'ide-disk', 'tr_cmd_return_dma') remove_class_attr(set, 'ide-cdrom', 'tr_rdy_dma') remove_class_attr(set, 'ide-cdrom', 'tr_cmd_return_dma') remove_class_attr(set, 'i82077', 'seek_irq_drive') remove_class_attr(set, 'i8042', 'reset_target') remove_class_attr(set, 'NS16450', 'com') remove_class_attr(set, 'NS16550', 'com') remove_class_attr(set, 'i21152', 'first_bus_nonzero') remove_class_attr(set, 'i82443bx_agp', 'first_bus_nonzero') remove_class_attr(set, 'i82443bx_agp', 'memory') # p4 has these before 2.0 (only p2, p3 and ppro) remove_class_attr(set, 'x86-p4', 'mc4_ctl') remove_class_attr(set, 'x86-p4', 'mc4_addr') remove_class_attr(set, 'x86-p4', 'mc4_status') remove_class_attr(set, 'x86-p4', 'mc4_misc') remove_class_attr(set, 'x86-p4', 'perfevtsel0') remove_class_attr(set, 'x86-p4', 'perfevtsel1') for cls in x86_classes: remove_class_attr(set, cls, 'cr1') for cls in ['SYM53C810', 'SYM53C875']: for obj in all_objects(set, cls): try: pin = obj.interrupt_pin obj.interrupt_pin = [pin, 0, 0, 0] except: pass def update_1042_to_1043(set): for obj in all_objects(set, 'Z8530'): a = pre_conf_object(obj.name + '-port-a', 'Z8530-port') b = pre_conf_object(obj.name + '-port-b', 'Z8530-port') obj.a_port = set[a.name] = a obj.b_port = set[b.name] = b a.master = obj b.master = obj # only change console if set try: a.console = obj.a_console a.console.device = a remove_attr(obj, 'a_console') except: pass try: b.console = obj.b_console b.console.device = b remove_attr(obj, 'b_console') except: pass def update_1040_to_1041(set): for obj in all_objects(set, 'ultrasparc-iii+'): try: if obj.report_ultra3i: obj.__class_name__ = 'ultrasparc-iii-i' remove_attr(obj, 'report_ultra3i') except: pass seg_regs = ["cs", "ds", "ss", "es", "fs", "gs", "tr", "ldtr"] for cls in x86_classes: for obj in all_objects(set, cls): for seg in seg_regs: try: reg = getattr(obj, seg) if reg[3]: reg[8] = (reg[8] << 12) | 0xfff setattr(obj, seg, reg) except: pass for obj in all_objects(set, 'flash-memory'): try: obj.storage_ram = obj.storage_space.map[0][1] except: pass remove_attr(obj, 'storage_space') def update_1039_to_1040(set): first = 1 for cls in [x for x in x86_classes if not '486' in x]: for obj in all_objects(set, cls): # only on first processor, does not work on multi-machines obj.bsp = first first = 0 def update_1031_to_1032(set): # Old versions do not have the udma_enabled attribute. Assume # that udma is enabled if udma_mode is non-zero. The new # multiword_dma_mode and multiword_dma_enabled attributes # will have the correct default values (off and zero). for obj in (all_objects(set, 'ide-disk') + all_objects(set, 'ide-cdrom')): try: if obj.udma_mode: obj.udma_enabled = 1 except: pass def update_1030_to_1031(set): for obj in (all_objects(set, 'ultrasparc-ii') + all_objects(set, 'ultrasparc-iii') + all_objects(set, 'ultrasparc-iii+')): remove_attr(obj, 'fp_follow_errata_69') remove_attr(obj, 'no_unpriv_nucleus_ifetch') for obj in all_objects(set, 'text-console'): remove_attr(obj, 'xterm_args') for cls in ['ISP1040', 'ISP1040_SUN', 'ISP2200', 'ISP2200_SUN']: for obj in all_objects(set, cls): # mask to 32 bits obj.req_queue_addr &= 0xffffffff obj.res_queue_addr &= 0xffffffff remove_class_attr(set, 'ram', 'mapped_size') def update_1019_to_1020(set): objs = (all_objects(set, 'ultrasparc-ii') + all_objects(set, 'ultrasparc-iii') + all_objects(set, 'ultrasparc-iii+') + all_objects(set, 'ultrasparc-v') + all_objects(set, 'serengeti-schizo') + all_objects(set, 'fiesta-tomatillo') + all_objects(set, 'sun4u-fhc') + all_objects(set, 'sunfire-sysio') + all_objects(set, 'sunfire-psycho') + all_objects(set, 'serengeti-console') + all_objects(set, 'serengeti-console-old')) if len(objs): irq_bus = pre_conf_object('irq_bus0', 'sparc-irq-bus') set['irq_bus0'] = irq_bus for obj in objs: obj.irq_bus = irq_bus remove_attr(obj, 'irq_objs') remove_attr(obj, 'cpu_objs') def update_1010_to_1011(set): for cls in ['ISP1040', 'ISP1040_SUN', 'ISP2200', 'ISP2200_SUN']: remove_class_attr(set, cls, 'nvram') remove_class_attr(set, cls, 'nvram-extra-cycle') def add_x86_tlb_1009(set, obj): name = obj.name + "_tlb" set[name] = tlb = pre_conf_object(name, 'x86-tlb') tlb.cpu = obj obj.tlb = tlb for t in ['itlb_large', 'dtlb_large', 'itlb_4k', 'dtlb_4k']: try: exec "tlb.%s = obj.%s" % (t, t) remove_attr(obj, t) except: pass def update_1009_to_1010(set): remove_class_attr(set, 'ide-disk', 'debug_level') remove_class_attr(set, 'ide-cdrom', 'debug_level') remove_class_attr(set, 'spitfire-mmu', 'no_unpriv_nucleus_ifetch') remove_class_attr(set, 'cheetah-mmu', 'no_unpriv_nucleus_ifetch') remove_class_attr(set, 'cheetah+mmu', 'no_unpriv_nucleus_ifetch') remove_class_attr(set, 'text-console', 'add_title') for obj in all_objects(set, 'serengeti-console'): obj.__class_name__ = 'serengeti-console-old' for cls in x86_classes: for obj in all_objects(set, cls): add_x86_tlb_1009(set, obj) ####################### install_configuration_update(1397, update_1396_to_1397) install_configuration_update(1391, update_1390_to_1391) install_configuration_update(1379, update_1378_to_1379) install_configuration_update(1378, update_1377_to_1378) install_configuration_update(1370, update_1370_to_1371) install_configuration_update(1367, update_1367_to_1368) install_configuration_update(1366, update_1366_to_1367) install_configuration_update(1365, update_1365_to_1366) install_configuration_update(1364, update_1364_to_1365) install_configuration_update(1363, update_1363_to_1364) install_configuration_update(1361, update_1361_to_1362) install_configuration_update(1358, update_1358_to_1359) install_configuration_update(1357, update_1357_to_1358) install_configuration_update(1354, update_1354_to_1355) install_configuration_update(1350, update_1350_to_1351) install_configuration_update(1348, update_1348_to_1349) install_configuration_update(1339, update_1340_to_1341) install_configuration_update(1334, update_1334_to_1335) install_configuration_update(1332, update_1332_to_1333) install_configuration_update(1329, update_1329_to_1330) install_configuration_update(1328, update_1328_to_1329) install_configuration_update(1327, update_1327_to_1328) install_configuration_update(1326, update_1326_to_1327) install_configuration_update(1321, update_1321_to_1322) install_configuration_update(1320, update_1320_to_1321) install_configuration_update(1318, update_1318_to_1319) install_configuration_update(1317, update_1317_to_1318) install_configuration_update(1316, update_1316_to_1317) install_configuration_update(1305, update_1304_to_1305) install_configuration_update(1302, update_1302_to_1303) install_configuration_update(1301, update_1301_to_1302) install_configuration_update(1300, update_1300_to_1301) install_configuration_update(1299, update_1299_to_1300) install_configuration_update(1200, update_1200_to_1201) install_configuration_update(1199, update_1199_to_1200) install_configuration_update(1051, update_1051_to_1052) install_configuration_update(1049, update_1049_to_1050) install_configuration_update(1042, update_1042_to_1043) install_configuration_update(1040, update_1040_to_1041) install_configuration_update(1039, update_1039_to_1040) install_configuration_update(1031, update_1031_to_1032) install_configuration_update(1030, update_1030_to_1031) install_configuration_update(1019, update_1019_to_1020) install_configuration_update(1010, update_1010_to_1011) install_configuration_update(1009, update_1009_to_1010)
default_network_ops_client.rs
use parity_scale_codec::Decode; use crate::NetworkOpsClient; use chain_core::common::Timespec; use chain_core::init::coin::{sum_coins, Coin}; use chain_core::state::account::{ CouncilNode, DepositBondTx, StakedState, StakedStateAddress, StakedStateOpAttributes, StakedStateOpWitness, UnbondTx, UnjailTx, WithdrawUnbondedTx, }; use chain_core::state::validator::NodeJoinRequestTx; use chain_core::tx::data::address::ExtendedAddr; use chain_core::tx::data::attribute::TxAttributes; use chain_core::tx::data::input::TxoPointer; use chain_core::tx::data::output::TxOut; use chain_core::tx::fee::FeeAlgorithm; use chain_core::tx::{TxAux, TxPublicAux}; use chain_storage::jellyfish::SparseMerkleProof; use chain_tx_validation::{check_inputs_basic, check_outputs_basic, verify_unjailed}; use client_common::tendermint::types::{AbciQueryExt, Genesis, StatusResponse}; use client_common::tendermint::Client; use client_common::{ Error, ErrorKind, Result, ResultExt, SecKey, SignedTransaction, Storage, Transaction, }; use client_core::signer::{DummySigner, Signer, WalletSignerManager}; use client_core::transaction_builder::WitnessedUTxO; use client_core::types::TransactionPending; use client_core::{TransactionObfuscation, UnspentTransactions, WalletClient}; use tendermint::{block::Height, Time}; /// Default implementation of `NetworkOpsClient` #[derive(Clone)] pub struct DefaultNetworkOpsClient<W, S, C, F, E> where W: WalletClient, S: Storage, C: Client, F: FeeAlgorithm, E: TransactionObfuscation, { wallet_client: W, signer_manager: WalletSignerManager<S>, client: C, fee_algorithm: F, transaction_cipher: E, } impl<W, S, C, F, E> DefaultNetworkOpsClient<W, S, C, F, E> where W: WalletClient, S: Storage, C: Client, F: FeeAlgorithm, E: TransactionObfuscation, { /// Creates a new instance of `DefaultNetworkOpsClient` pub fn new( wallet_client: W, signer_manager: WalletSignerManager<S>, client: C, fee_algorithm: F, transaction_cipher: E, ) -> Self { Self { wallet_client, signer_manager, client, fee_algorithm, transaction_cipher, } } /// Returns current underlying wallet client pub fn get_wallet_client(&self) -> &W { &self.wallet_client } /// Calculate the withdraw unbounded fee fn calculate_fee(&self, outputs: Vec<TxOut>, attributes: TxAttributes) -> Result<Coin> { let tx = WithdrawUnbondedTx::new(0, outputs, attributes); // mock the signature let dummy_signer = DummySigner(); let tx_aux = dummy_signer.mock_txaux_for_withdraw(tx); let fee = self .fee_algorithm .calculate_for_txaux(&tx_aux) .chain(|| { ( ErrorKind::IllegalInput, "Calculated fee is more than the maximum allowed value", ) })? .to_coin(); Ok(fee) } fn get_last_block_time(&self) -> Result<Timespec> { let status = self.client.status()?; Ok(to_timespec( if status.sync_info.latest_block_height == Height(0) { self.client.genesis()?.genesis_time } else { status.sync_info.latest_block_time }, )) } } impl<W, S, C, F, E> NetworkOpsClient for DefaultNetworkOpsClient<W, S, C, F, E> where W: WalletClient, S: Storage, C: Client, F: FeeAlgorithm, E: TransactionObfuscation, { fn calculate_deposit_fee(&self) -> Result<Coin> { let dummy_signer = DummySigner(); let tx_aux = dummy_signer .mock_txaux_for_deposit(&[WitnessedUTxO::dummy()]) .chain(|| (ErrorKind::ValidationError, "Calculated fee failed"))?; let fee = self .fee_algorithm .calculate_for_txaux(&tx_aux) .chain(|| { ( ErrorKind::IllegalInput, "Calculated fee is more than the maximum allowed value", ) })? .to_coin(); Ok(fee) } fn create_deposit_bonded_stake_transaction<'a>( &'a self, name: &'a str, enckey: &'a SecKey, transactions: Vec<(TxoPointer, TxOut)>, to_address: StakedStateAddress, attributes: StakedStateOpAttributes, verify_staking: bool, ) -> Result<(TxAux, TransactionPending)> { if let Some(staking) = self.get_staking(name, &to_address, verify_staking)? { verify_unjailed(&staking).map_err(|e| { Error::new( ErrorKind::ValidationError, format!("Failed to validate staking account: {}", e), ) })?; } let inputs = transactions .iter() .map(|(input, _)| input.clone()) .collect::<Vec<_>>(); let transaction = DepositBondTx::new(inputs.clone(), to_address, attributes); let unspent_transactions = UnspentTransactions::new(transactions); let signer = self.signer_manager .create_signer(name, enckey, &self.signer_manager.hw_key_service); let tx = Transaction::DepositStakeTransaction(transaction.clone()); let witness = signer.schnorr_sign_transaction(&tx, &unspent_transactions.select_all())?; check_inputs_basic(&transaction.inputs, &witness).map_err(|e| { Error::new( ErrorKind::ValidationError, format!("Failed to validate deposit transaction inputs: {}", e), ) })?; let signed_transaction = SignedTransaction::DepositStakeTransaction(transaction, witness); let tx_aux = self.transaction_cipher.encrypt(signed_transaction)?; let block_height = match self.wallet_client.get_current_block_height() { Ok(h) => h, Err(e) if e.kind() == ErrorKind::PermissionDenied => 0, // to make unit test pass Err(e) => return Err(e), }; let pending_transaction = TransactionPending { block_height, used_inputs: inputs, return_amount: Coin::zero(), }; Ok((tx_aux, pending_transaction)) } fn create_unbond_stake_transaction( &self, name: &str, enckey: &SecKey, address: StakedStateAddress, value: Coin, attributes: StakedStateOpAttributes, verify_staking: bool, ) -> Result<TxAux> { let staked_state = self.get_staked_state(name, &address, verify_staking)?; verify_unjailed(&staked_state).map_err(|e| { Error::new( ErrorKind::ValidationError, format!("Failed to validate staking account: {}", e), ) })?; let nonce = staked_state.nonce; let transaction = UnbondTx::new(address, nonce, value, attributes); let tx = Transaction::UnbondStakeTransaction(transaction.clone()); let public_key = match address { StakedStateAddress::BasicRedeem(ref redeem_address) => self .wallet_client .find_staking_key(name, enckey, redeem_address)? .chain(|| { ( ErrorKind::InvalidInput, "Address not found in current wallet", ) })?, }; let sign_key = self.wallet_client.sign_key(name, enckey, &public_key)?; let signature = sign_key.sign(&tx).map(StakedStateOpWitness::new)?; let txaux = TxAux::PublicTx(TxPublicAux::UnbondStakeTx(transaction, signature)); let fee = self .fee_algorithm .calculate_for_txaux(&txaux) .chain(|| { ( ErrorKind::IllegalInput, "Calculated fee is more than the maximum allowed value", ) })? .to_coin(); if staked_state.bonded < (value + fee).unwrap() { return Err(Error::new( ErrorKind::InvalidInput, "Staking account does not have enough coins to unbond (synchronizing your wallet may help)", )); } Ok(txaux) } fn create_withdraw_unbonded_stake_transaction( &self, name: &str, enckey: &SecKey, from_address: &StakedStateAddress, outputs: Vec<TxOut>, attributes: TxAttributes, verify_staking: bool, ) -> Result<(TxAux, TransactionPending)> { let last_block_time = self.get_last_block_time()?; let staked_state = self.get_staked_state(name, from_address, verify_staking)?; if staked_state.unbonded_from > last_block_time { let seconds = staked_state.unbonded_from - last_block_time; let duration = std::time::Duration::from_secs(seconds); return Err(Error::new( ErrorKind::ValidationError, format!( "Staking state is not yet unbonded, time left: {:?}", duration ), )); } verify_unjailed(&staked_state).map_err(|e| { Error::new( ErrorKind::ValidationError, format!("Failed to validate staking account: {}", e), ) })?; let output_value = sum_coins(outputs.iter().map(|output| output.value)) .chain(|| (ErrorKind::InvalidInput, "Error while adding output values"))?; if staked_state.unbonded < output_value { return Err(Error::new( ErrorKind::InvalidInput, "Staking account does not have enough unbonded coins to withdraw (synchronizing your wallet may help)", )); } let nonce = staked_state.nonce; let transaction = WithdrawUnbondedTx::new(nonce, outputs, attributes); let tx = Transaction::WithdrawUnbondedStakeTransaction(transaction.clone()); let public_key = match from_address { StakedStateAddress::BasicRedeem(ref redeem_address) => self .wallet_client .find_staking_key(name, enckey, redeem_address)? .chain(|| { ( ErrorKind::InvalidInput, "Address not found in current wallet", ) })?, }; let sign_key = self.wallet_client.sign_key(name, enckey, &public_key)?; let signature = sign_key.sign(&tx).map(StakedStateOpWitness::new)?; let signed_transaction = SignedTransaction::WithdrawUnbondedStakeTransaction(transaction, signature); let tx_aux = self.transaction_cipher.encrypt(signed_transaction)?; let block_height = match self.wallet_client.get_current_block_height() { Ok(h) => h, Err(e) if e.kind() == ErrorKind::PermissionDenied => 0, // to make unit test pass Err(e) => return Err(e), }; let pending_transaction = TransactionPending { block_height, used_inputs: vec![], return_amount: output_value, }; Ok((tx_aux, pending_transaction)) } fn create_unjail_transaction( &self, name: &str, enckey: &SecKey, address: StakedStateAddress, attributes: StakedStateOpAttributes, verify_staking: bool, ) -> Result<TxAux> { let staked_state = self.get_staked_state(name, &address, verify_staking)?; if !staked_state.is_jailed() { return Err(Error::new( ErrorKind::IllegalInput, "You can only unjail an already jailed account (synchronizing your wallet may help)", )); } let nonce = staked_state.nonce; let transaction = UnjailTx { nonce, address, attributes, }; let tx = Transaction::UnjailTransaction(transaction.clone()); let public_key = match address { StakedStateAddress::BasicRedeem(ref redeem_address) => self .wallet_client .find_staking_key(name, enckey, redeem_address)? .chain(|| { ( ErrorKind::InvalidInput, "Address not found in current wallet", ) })?, }; let sign_key = self.wallet_client.sign_key(name, enckey, &public_key)?; let signature = sign_key.sign(&tx).map(StakedStateOpWitness::new)?; Ok(TxAux::PublicTx(TxPublicAux::UnjailTx( transaction, signature, ))) } fn create_withdraw_all_unbonded_stake_transaction( &self, name: &str, enckey: &SecKey, from_address: &StakedStateAddress, to_address: ExtendedAddr, attributes: TxAttributes, verify_staking: bool, ) -> Result<(TxAux, TransactionPending)> { let staked_state = self.get_staked_state(name, from_address, verify_staking)?; verify_unjailed(&staked_state).map_err(|e| { Error::new( ErrorKind::ValidationError, format!("Failed to validate staking account: {}", e), ) })?; let temp_output = TxOut::new_with_timelock(to_address.clone(), Coin::zero(), staked_state.unbonded_from); let fee = self.calculate_fee(vec![temp_output], attributes.clone())?; let amount = (staked_state.unbonded - fee).chain(|| { ( ErrorKind::IllegalInput, "Calculated fee is more than the unbonded amount", ) })?; let outputs = vec![TxOut::new_with_timelock( to_address, amount, staked_state.unbonded_from, )]; check_outputs_basic(&outputs).map_err(|e| { Error::new( ErrorKind::ValidationError, format!("Failed to validate staking account: {}", e), ) })?; self.create_withdraw_unbonded_stake_transaction( name, enckey, from_address, outputs, attributes, verify_staking, ) } fn create_node_join_transaction( &self, name: &str, enckey: &SecKey, staking_account_address: StakedStateAddress, attributes: StakedStateOpAttributes, node_metadata: CouncilNode, verify_staking: bool, ) -> Result<TxAux> { let staked_state = self.get_staked_state(name, &staking_account_address, verify_staking)?; verify_unjailed(&staked_state).map_err(|e| { Error::new( ErrorKind::ValidationError, format!("Failed to validate staking account: {}", e), ) })?; let transaction = NodeJoinRequestTx { nonce: staked_state.nonce, address: staking_account_address, attributes, node_meta: node_metadata, }; let tx = Transaction::NodejoinTransaction(transaction.clone()); let public_key = match staking_account_address { StakedStateAddress::BasicRedeem(ref redeem_address) => self .wallet_client .find_staking_key(name, enckey, redeem_address)? .chain(|| { ( ErrorKind::InvalidInput, "Address not found in current wallet", ) })?, }; let sign_key = self.wallet_client.sign_key(name, enckey, &public_key)?; let signature = sign_key.sign(&tx).map(StakedStateOpWitness::new)?; Ok(TxAux::PublicTx(TxPublicAux::NodeJoinTx( transaction, signature, ))) } fn get_staking( &self, name: &str, address: &StakedStateAddress, verify: bool, ) -> Result<Option<StakedState>> { let mstaking = if verify { let sync_state = self.wallet_client.get_sync_state(name)?; let rsp = self.client.query( "staking", address.as_ref(), Some(sync_state.last_block_height.into()), true, )?; let mstaking = <Option<StakedState>>::decode(&mut rsp.bytes().as_slice()) .err_kind(ErrorKind::DeserializationError, || { format!("Cannot deserialize staked state for address: {}", address) })?; let mbytes = if let Some(proof) = rsp.proof.as_ref() { if let Some(evidence) = proof.ops.first() { Some(evidence.data.as_slice()) } else { None } } else { None }; let mut proof_bytes = mbytes.err_kind(ErrorKind::TendermintRpcError, || { format!("There is no proof for address: {}", address) })?; let proof = SparseMerkleProof::decode(&mut proof_bytes).err_kind( ErrorKind::DeserializationError, || { format!( "Cannot deserialize staked state proof for address: {}", address ) }, )?; proof .verify(sync_state.staking_root, address, mstaking.as_ref()) .err_kind(ErrorKind::VerifyError, || "Verify staking state failed")?; mstaking } else { let bytes = self .client .query("staking", address.as_ref(), None, false)? .bytes(); <Option<StakedState>>::decode(&mut bytes.as_slice()) .err_kind(ErrorKind::DeserializationError, || { format!("Cannot deserialize staked state for address: {}", address) })? }; Ok(mstaking) } fn get_genesis(&self) -> Result<Genesis> { self.client.genesis() } fn get_status(&self) -> Result<StatusResponse> { self.client.status() } } fn to_timespec(time: Time) -> Timespec { time.duration_since(Time::unix_epoch()).unwrap().as_secs() } #[cfg(test)] mod tests { use super::*; use secstr::SecUtf8; use parity_scale_codec::Encode; use chain_core::init::address::RedeemAddress; use chain_core::init::coin::CoinError; use chain_core::state::account::{StakedState, StakedStateOpAttributes, Validator}; use chain_core::state::tendermint::BlockHeight; use chain_core::state::tendermint::TendermintValidatorPubKey; use chain_core::state::ChainState; use chain_core::tx::data::input::TxoSize; use chain_core::tx::data::TxId; use chain_core::tx::fee::Fee; use chain_core::tx::TransactionId; use chain_core::tx::{PlainTxAux, TxEnclaveAux, TxObfuscated}; use chain_tx_validation::witness::verify_tx_recover_address; use client_common::storage::MemoryStorage; use client_common::tendermint::lite; use client_common::tendermint::mock; use client_common::tendermint::types::*; use client_common::{seckey::derive_enckey, PrivateKey, PublicKey, Transaction}; use client_core::service::HwKeyService; use client_core::signer::WalletSignerManager; use client_core::types::WalletKind; use client_core::wallet::DefaultWalletClient; use test_common::chain_env::mock_confidential_init; #[derive(Debug, Clone)] struct MockTransactionCipher; impl TransactionObfuscation for MockTransactionCipher { fn decrypt( &self, _transaction_ids: &[TxId], _private_key: &PrivateKey, ) -> Result<Vec<Transaction>> { unreachable!() } fn encrypt(&self, transaction: SignedTransaction) -> Result<TxAux> { match transaction { SignedTransaction::TransferTransaction(_, _) => unreachable!(), SignedTransaction::DepositStakeTransaction(tx, witness) => { let plain = PlainTxAux::DepositStakeTx(witness); Ok(TxAux::EnclaveTx(TxEnclaveAux::DepositStakeTx { tx: tx.clone(), payload: TxObfuscated { txid: tx.id(), key_from: BlockHeight::genesis(), init_vector: [0u8; 12], txpayload: plain.encode(), }, })) } SignedTransaction::WithdrawUnbondedStakeTransaction(tx, witness) => { let plain = PlainTxAux::WithdrawUnbondedStakeTx(tx.clone()); Ok(TxAux::EnclaveTx(TxEnclaveAux::WithdrawUnbondedStakeTx { no_of_outputs: tx.outputs.len() as TxoSize, witness, payload: TxObfuscated { txid: tx.id(), key_from: BlockHeight::genesis(), init_vector: [0u8; 12], txpayload: plain.encode(), }, })) } } } } #[derive(Debug, Default)] struct UnitFeeAlgorithm; impl FeeAlgorithm for UnitFeeAlgorithm { fn calculate_fee(&self, _num_bytes: usize) -> std::result::Result<Fee, CoinError> { Ok(Fee::new(Coin::unit())) } fn calculate_for_txaux(&self, _txaux: &TxAux) -> std::result::Result<Fee, CoinError> { Ok(Fee::new(Coin::unit())) } } #[derive(Default, Clone)] pub struct MockJailedClient; impl Client for MockJailedClient { fn genesis(&self) -> Result<Genesis> { unreachable!() } fn status(&self) -> Result<StatusResponse> { unreachable!() } fn block(&self, _: u64) -> Result<Block> { unreachable!() } fn block_batch<'a, T: Iterator<Item = &'a u64>>(&self, _heights: T) -> Result<Vec<Block>> { unreachable!() } fn block_results(&self, _height: u64) -> Result<BlockResultsResponse> { unreachable!() } fn block_batch_verified<'a, T: Clone + Iterator<Item = &'a u64>>( &self, _state: lite::TrustedState, _heights: T, ) -> Result<(Vec<Block>, lite::TrustedState)> { unreachable!() } fn block_results_batch<'a, T: Iterator<Item = &'a u64>>( &self, _heights: T, ) -> Result<Vec<BlockResultsResponse>> { unreachable!() } fn broadcast_transaction(&self, _: &[u8]) -> Result<BroadcastTxResponse> { unreachable!() } fn query( &self, _path: &str, _data: &[u8], _height: Option<Height>, _prove: bool, ) -> Result<AbciQuery> { let staked_state = StakedState::new( 0, Coin::new(1000000).unwrap(), Coin::new(2499999999999999999 + 1).unwrap(), 0, StakedStateAddress::BasicRedeem(RedeemAddress::default()), Some(Validator { council_node: CouncilNode::new( TendermintValidatorPubKey::Ed25519([0xcd; 32]), mock_confidential_init(), ), jailed_until: Some(100), inactive_time: Some(0), inactive_block: Some(BlockHeight::genesis()), used_validator_addresses: vec![], }), ); Ok(AbciQuery { value: Some(Some(staked_state).encode()), ..Default::default() }) } fn query_state_batch<T: Iterator<Item = u64>>( &self, _heights: T, ) -> Result<Vec<ChainState>> { unreachable!() } } #[derive(Default, Clone)] pub struct MockClient; impl Client for MockClient { fn genesis(&self) -> Result<Genesis> { unreachable!() } fn status(&self) -> Result<StatusResponse> { Ok(StatusResponse { sync_info: status::SyncInfo { latest_block_height: Height::default(), latest_app_hash: None, ..mock::sync_info() }, ..mock::status_response() }) } fn block(&self, _: u64) -> Result<Block> { unreachable!() } fn block_batch<'a, T: Iterator<Item = &'a u64>>(&self, _heights: T) -> Result<Vec<Block>> { unreachable!() } fn block_results(&self, _height: u64) -> Result<BlockResultsResponse> { unreachable!() } fn block_results_batch<'a, T: Iterator<Item = &'a u64>>( &self, _heights: T, ) -> Result<Vec<BlockResultsResponse>> { unreachable!() } fn
<'a, T: Clone + Iterator<Item = &'a u64>>( &self, _state: lite::TrustedState, _heights: T, ) -> Result<(Vec<Block>, lite::TrustedState)> { unreachable!() } fn broadcast_transaction(&self, _: &[u8]) -> Result<BroadcastTxResponse> { unreachable!() } fn query( &self, _path: &str, _data: &[u8], _height: Option<Height>, _prove: bool, ) -> Result<AbciQuery> { let staked_state = StakedState::new( 0, Coin::new(1000000).unwrap(), Coin::new(2499999999999999999 + 1).unwrap(), 0, StakedStateAddress::BasicRedeem(RedeemAddress::default()), None, ); Ok(AbciQuery { value: Some(Some(staked_state).encode()), ..Default::default() }) } fn query_state_batch<T: Iterator<Item = u64>>( &self, _heights: T, ) -> Result<Vec<ChainState>> { unreachable!() } } #[test] fn check_create_deposit_bonded_stake_transaction() { let name = "name"; let passphrase = SecUtf8::from("passphrase"); let storage = MemoryStorage::default(); let signer_manager = WalletSignerManager::new(storage.clone(), HwKeyService::default()); let fee_algorithm = UnitFeeAlgorithm::default(); let wallet_client = DefaultWalletClient::new_read_only(storage.clone()); let input = TxoPointer::new([0; 32], 0); let output = TxOut { address: ExtendedAddr::OrTree([0; 32]), value: Coin::new(10).unwrap(), valid_from: None, }; let transactions = vec![(input, output)]; let (enckey, _) = wallet_client .new_wallet(name, &passphrase, WalletKind::Basic) .unwrap(); let tendermint_client = MockClient::default(); let network_ops_client = DefaultNetworkOpsClient::new( wallet_client, signer_manager, tendermint_client, fee_algorithm, MockTransactionCipher, ); let to_staked_account = network_ops_client .get_wallet_client() .new_staking_address(name, &enckey) .unwrap(); let attributes = StakedStateOpAttributes::new(0); assert_eq!( ErrorKind::InvalidInput, network_ops_client .create_deposit_bonded_stake_transaction( name, &enckey, transactions, to_staked_account, attributes, false ) .unwrap_err() .kind() ); } #[test] fn check_create_unbond_stake_transaction() { let name = "name"; let passphrase = SecUtf8::from("passphrase"); let storage = MemoryStorage::default(); let signer_manager = WalletSignerManager::new(storage.clone(), HwKeyService::default()); let fee_algorithm = UnitFeeAlgorithm::default(); let wallet_client = DefaultWalletClient::new_read_only(storage.clone()); let (enckey, _) = wallet_client .new_wallet(name, &passphrase, WalletKind::Basic) .unwrap(); let tendermint_client = MockClient::default(); let network_ops_client = DefaultNetworkOpsClient::new( wallet_client, signer_manager, tendermint_client, fee_algorithm, MockTransactionCipher, ); let value = Coin::new(0).unwrap(); let address = network_ops_client .get_wallet_client() .new_staking_address(name, &enckey) .unwrap(); let attributes = StakedStateOpAttributes::new(0); assert!(network_ops_client .create_unbond_stake_transaction(name, &enckey, address, value, attributes, false) .is_ok()); } #[test] fn check_withdraw_unbonded_stake_transaction() { let name = "name"; let passphrase = SecUtf8::from("passphrase"); let storage = MemoryStorage::default(); let signer_manager = WalletSignerManager::new(storage.clone(), HwKeyService::default()); let fee_algorithm = UnitFeeAlgorithm::default(); let wallet_client = DefaultWalletClient::new_read_only(storage.clone()); let tendermint_client = MockClient::default(); let network_ops_client = DefaultNetworkOpsClient::new( wallet_client, signer_manager, tendermint_client, fee_algorithm, MockTransactionCipher, ); let (enckey, _) = network_ops_client .get_wallet_client() .new_wallet(name, &passphrase, WalletKind::Basic) .unwrap(); let from_address = network_ops_client .get_wallet_client() .new_staking_address(name, &enckey) .unwrap(); let (transaction, _pending_tx) = network_ops_client .create_withdraw_unbonded_stake_transaction( name, &enckey, &from_address, vec![TxOut::new(ExtendedAddr::OrTree([0; 32]), Coin::unit())], TxAttributes::new(171), false, ) .unwrap(); match transaction { TxAux::EnclaveTx(TxEnclaveAux::WithdrawUnbondedStakeTx { payload: TxObfuscated { txid, .. }, witness, .. }) => { let account_address = verify_tx_recover_address(&witness, &txid) .expect("Unable to verify transaction"); assert_eq!(account_address, from_address) } _ => unreachable!( "`create_withdraw_unbonded_stake_transaction()` created invalid transaction type" ), } } #[test] fn check_withdraw_all_unbonded_stake_transaction() { let name = "name"; let passphrase = SecUtf8::from("passphrase"); let storage = MemoryStorage::default(); let signer_manager = WalletSignerManager::new(storage.clone(), HwKeyService::default()); let fee_algorithm = UnitFeeAlgorithm::default(); let wallet_client = DefaultWalletClient::new_read_only(storage.clone()); let tendermint_client = MockClient::default(); let network_ops_client = DefaultNetworkOpsClient::new( wallet_client, signer_manager, tendermint_client, fee_algorithm, MockTransactionCipher, ); let (enckey, _) = network_ops_client .get_wallet_client() .new_wallet(name, &passphrase, WalletKind::Basic) .unwrap(); let from_address = network_ops_client .get_wallet_client() .new_staking_address(name, &enckey) .unwrap(); let to_address = ExtendedAddr::OrTree([0; 32]); let (transaction, _) = network_ops_client .create_withdraw_all_unbonded_stake_transaction( name, &enckey, &from_address, to_address, TxAttributes::new(171), false, ) .unwrap(); match transaction { TxAux::EnclaveTx(TxEnclaveAux::WithdrawUnbondedStakeTx { witness, payload: TxObfuscated { txid, txpayload, .. }, .. }) => { let account_address = verify_tx_recover_address(&witness, &txid) .expect("Unable to verify transaction"); assert_eq!(account_address, from_address); // NOTE: Mock decryption based on encryption logic in `MockTransactionCipher` let tx = PlainTxAux::decode(&mut txpayload.as_slice()); if let Ok(PlainTxAux::WithdrawUnbondedStakeTx(transaction)) = tx { let amount = transaction.outputs[0].value; assert_eq!(amount, Coin::new(2500000000000000000 - 1).unwrap()); } } _ => unreachable!( "`create_withdraw_unbonded_stake_transaction()` created invalid transaction type" ), } } #[test] fn check_withdraw_unbonded_stake_transaction_address_not_found() { let name = "name"; let passphrase = SecUtf8::from("passphrase"); let storage = MemoryStorage::default(); let signer_manager = WalletSignerManager::new(storage.clone(), HwKeyService::default()); let fee_algorithm = UnitFeeAlgorithm::default(); let wallet_client = DefaultWalletClient::new_read_only(storage.clone()); let tendermint_client = MockClient::default(); let network_ops_client = DefaultNetworkOpsClient::new( wallet_client, signer_manager, tendermint_client, fee_algorithm, MockTransactionCipher, ); let (enckey, _) = network_ops_client .get_wallet_client() .new_wallet(name, &passphrase, WalletKind::Basic) .unwrap(); assert_eq!( ErrorKind::InvalidInput, network_ops_client .create_withdraw_unbonded_stake_transaction( name, &enckey, &StakedStateAddress::BasicRedeem(RedeemAddress::from(&PublicKey::from( &PrivateKey::new().unwrap() ))), vec![TxOut::new(ExtendedAddr::OrTree([0; 32]), Coin::unit())], TxAttributes::new(171), false ) .unwrap_err() .kind() ); } #[test] fn check_withdraw_unbonded_stake_transaction_wallet_not_found() { let name = "name"; let enckey = &derive_enckey(&SecUtf8::from("passphrase"), name).unwrap(); let storage = MemoryStorage::default(); let signer_manager = WalletSignerManager::new(storage.clone(), HwKeyService::default()); let fee_algorithm = UnitFeeAlgorithm::default(); let wallet_client = DefaultWalletClient::new_read_only(storage.clone()); let tendermint_client = MockClient::default(); let network_ops_client = DefaultNetworkOpsClient::new( wallet_client, signer_manager, tendermint_client, fee_algorithm, MockTransactionCipher, ); assert_eq!( ErrorKind::InvalidInput, network_ops_client .create_withdraw_unbonded_stake_transaction( name, enckey, &StakedStateAddress::BasicRedeem(RedeemAddress::from(&PublicKey::from( &PrivateKey::new().unwrap() ))), Vec::new(), TxAttributes::new(171), false ) .unwrap_err() .kind() ); } #[test] fn check_unjail_transaction() { let name = "name"; let passphrase = SecUtf8::from("passphrase"); let storage = MemoryStorage::default(); let signer_manager = WalletSignerManager::new(storage.clone(), HwKeyService::default()); let fee_algorithm = UnitFeeAlgorithm::default(); let wallet_client = DefaultWalletClient::new_read_only(storage.clone()); let tendermint_client = MockJailedClient::default(); let network_ops_client = DefaultNetworkOpsClient::new( wallet_client, signer_manager, tendermint_client, fee_algorithm, MockTransactionCipher, ); let (enckey, _) = network_ops_client .get_wallet_client() .new_wallet(name, &passphrase, WalletKind::Basic) .unwrap(); let from_address = network_ops_client .get_wallet_client() .new_staking_address(name, &enckey) .unwrap(); let transaction = network_ops_client .create_unjail_transaction( name, &enckey, from_address, StakedStateOpAttributes::new(171), false, ) .unwrap(); match transaction { TxAux::PublicTx(TxPublicAux::UnjailTx(tx, witness)) => { let txid = tx.id(); let account_address = verify_tx_recover_address(&witness, &txid) .expect("Unable to verify transaction"); assert_eq!(account_address, from_address); } _ => unreachable!("`unjail_tx()` created invalid transaction"), } } #[test] fn check_node_join_transaction() { let name = "name"; let passphrase = SecUtf8::from("passphrase"); let storage = MemoryStorage::default(); let signer_manager = WalletSignerManager::new(storage.clone(), HwKeyService::default()); let fee_algorithm = UnitFeeAlgorithm::default(); let wallet_client = DefaultWalletClient::new_read_only(storage.clone()); let tendermint_client = MockClient::default(); let network_ops_client = DefaultNetworkOpsClient::new( wallet_client, signer_manager, tendermint_client, fee_algorithm, MockTransactionCipher, ); let (enckey, _) = network_ops_client .get_wallet_client() .new_wallet(name, &passphrase, WalletKind::Basic) .unwrap(); let staking_account_address = network_ops_client .get_wallet_client() .new_staking_address(name, &enckey) .unwrap(); let mut validator_pubkey = [0; 32]; validator_pubkey.copy_from_slice( &base64::decode("P2B49bRtePqHr0JGRVAOS9ZqSFjBpS6dFtCah9p+cro=").unwrap(), ); let node_metadata = CouncilNode { name: "test".to_owned(), security_contact: None, consensus_pubkey: TendermintValidatorPubKey::Ed25519(validator_pubkey), confidential_init: mock_confidential_init(), }; let transaction = network_ops_client .create_node_join_transaction( name, &enckey, staking_account_address, StakedStateOpAttributes::new(171), node_metadata, false, ) .unwrap(); match transaction { TxAux::PublicTx(TxPublicAux::NodeJoinTx(tx, witness)) => { let txid = tx.id(); let account_address = verify_tx_recover_address(&witness, &txid) .expect("Unable to verify transaction"); assert_eq!(account_address, staking_account_address); } _ => unreachable!("`create_node_join_tx()` created invalid transaction"), } } }
block_batch_verified
error.rs
use super::*; use std::{collections::HashSet, hash::Hash}; #[cfg(feature = "ahash")] type RandomState = ahash::RandomState; #[cfg(not(feature = "ahash"))] type RandomState = std::collections::hash_set::RandomState; /// A trait that describes parser error types. /// /// If you have a custom error type in your compiler, or your needs are not sufficiently met by [`Simple`], you should /// implement this trait. If your error type has 'extra' features that allow for more specific error messages, you can /// use the [`Parser::map_err`] or [`Parser::try_map`] functions to take advantage of these inline within your parser. /// /// # Examples /// /// ``` /// # use chumsky::{prelude::*, error::Cheap}; /// type Span = std::ops::Range<usize>; /// /// // A custom error type /// #[derive(Debug, PartialEq)] /// enum MyError { /// ExpectedFound(Span, Vec<char>, Option<char>), /// NotADigit(Span, char), /// } /// /// impl chumsky::Error<char> for MyError { /// type Span = Span; /// type Label = (); /// /// fn expected_input_found<Iter: IntoIterator<Item = char>>( /// span: Span, /// expected: Iter, /// found: Option<char>, /// ) -> Self { /// Self::ExpectedFound(span, expected.into_iter().collect(), found) /// } /// /// fn with_label(mut self, label: Self::Label) -> Self { self } /// /// fn merge(mut self, mut other: Self) -> Self { /// if let (Self::ExpectedFound(_, expected, _), Self::ExpectedFound(_, expected_other, _)) = ( /// &mut self, /// &mut other, /// ) { /// expected.append(expected_other); /// } /// self /// } /// } /// /// let numeral = filter_map(|span, c: char| match c.to_digit(10) { /// Some(x) => Ok(x), /// None => Err(MyError::NotADigit(span, c)), /// }); /// /// assert_eq!(numeral.parse("3"), Ok(3)); /// assert_eq!(numeral.parse("7"), Ok(7)); /// assert_eq!(numeral.parse("f"), Err(vec![MyError::NotADigit(0..1, 'f')])); /// ``` pub trait Error<I>: Sized { /// The type of spans to be used in the error. type Span: Span; // TODO: Default to = Range<usize>; /// The label used to describe a syntatic structure currently being parsed. /// /// This can be used to generate errors that tell the user what syntactic structure was currently being parsed when /// the error occured. type Label; // TODO: Default to = &'static str; /// Create a new error describing a conflict between expected inputs and that which was actually found. /// /// Using a `None` as `found` indicates that the end of input was reached, but was not expected. fn expected_input_found<Iter: IntoIterator<Item = I>>( span: Self::Span, expected: Iter, found: Option<I>, ) -> Self; /// Create a new error describing a delimiter that was not correctly closed. /// /// Provided to this function is the span of the unclosed delimiter, the delimiter itself, the span of the input /// that was found in its place, the closing delimiter that was expected but not found, and the input that was /// found in its place. /// /// The default implementation of this function uses [`Error::expected_input_found`], but you'll probably want to /// implement it yourself to take full advantage of the extra diagnostic information. fn unclosed_delimiter( unclosed_span: Self::Span, unclosed: I, span: Self::Span, expected: I, found: Option<I>, ) -> Self { #![allow(unused_variables)] Self::expected_input_found(span, Some(expected), found) } /// Indicate that the error occured while parsing a particular syntactic structure. /// /// How the error handles this information is up to it. It can append it to a list of structures to get a sort of /// 'parse backtrace', or it can just keep only the most recent label. If the latter, this method should have no /// effect when the error already has a label. fn with_label(self, label: Self::Label) -> Self; /// Merge two errors that point to the same input together, combining their information. fn merge(self, other: Self) -> Self; } // /// A simple default input pattern that allows describing inputs and input patterns in error messages. // #[derive(Clone, Debug, PartialEq, Eq, Hash)] // pub enum SimplePattern<I> { // /// A pattern with the given name was expected. // Labelled(&'static str), // /// A specific input was expected. // Token(I), // } // impl<I> From<&'static str> for SimplePattern<I> { // fn from(s: &'static str) -> Self { Self::Labelled(s) } // } // impl<I: fmt::Display> fmt::Display for SimplePattern<I> { // fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { // match self { // Self::Labelled(s) => write!(f, "{}", s), // Self::Token(x) => write!(f, "'{}'", x), // } // } // } /// A type representing possible reasons for an error. #[derive(Clone, Debug, PartialEq, Eq)] pub enum SimpleReason<I, S> { /// An unexpected input was found. Unexpected, /// An unclosed delimiter was found. Unclosed { /// The span of the unclosed delimiter. span: S, /// The unclosed delimiter. delimiter: I, }, /// An error with a custom message occurred. Custom(String), } /// A simple default error type that tracks error spans, expected inputs, and the actual input found at an error site. /// /// Please note that it uses a [`HashSet`] to remember expected symbols. If you find this to be too slow, you can /// implement [`Error`] for your own error type or use [`Cheap`] instead. #[derive(Clone, Debug)] pub struct Simple<I: Hash, S = Range<usize>> { span: S, reason: SimpleReason<I, S>, expected: HashSet<I, RandomState>, found: Option<I>, label: Option<&'static str>, } impl<I: Hash + Eq, S: Clone> Simple<I, S> { /// Create an error with a custom error message. pub fn custom<M: ToString>(span: S, msg: M) -> Self { Self { span, reason: SimpleReason::Custom(msg.to_string()), expected: HashSet::default(), found: None, label: None, } } /// Returns the span that the error occured at. pub fn span(&self) -> S { self.span.clone() } /// Returns an iterator over possible expected patterns. pub fn expected(&self) -> impl ExactSizeIterator<Item = &I> + '_ { self.expected.iter() } /// Returns the input, if any, that was found instead of an expected pattern. pub fn
(&self) -> Option<&I> { self.found.as_ref() } /// Returns the reason for the error. pub fn reason(&self) -> &SimpleReason<I, S> { &self.reason } /// Returns the error's label, if any. pub fn label(&self) -> Option<&'static str> { self.label } /// Map the error's inputs using the given function. /// /// This can be used to unify the errors between parsing stages that operate upon two forms of input (for example, /// the initial lexing stage and the parsing stage in most compilers). pub fn map<U: Hash + Eq, F: FnMut(I) -> U>(self, mut f: F) -> Simple<U, S> { Simple { span: self.span, reason: match self.reason { SimpleReason::Unclosed { span, delimiter } => SimpleReason::Unclosed { span, delimiter: f(delimiter), }, SimpleReason::Unexpected => SimpleReason::Unexpected, SimpleReason::Custom(msg) => SimpleReason::Custom(msg), }, expected: self.expected.into_iter().map(&mut f).collect(), found: self.found.map(f), label: self.label, } } } impl<I: Hash + Eq, S: Span + Clone + fmt::Debug> Error<I> for Simple<I, S> { type Span = S; type Label = &'static str; fn expected_input_found<Iter: IntoIterator<Item = I>>( span: Self::Span, expected: Iter, found: Option<I>, ) -> Self { Self { span, reason: SimpleReason::Unexpected, expected: expected.into_iter().collect(), found, label: None, } } fn unclosed_delimiter( unclosed_span: Self::Span, delimiter: I, span: Self::Span, expected: I, found: Option<I>, ) -> Self { Self { span, reason: SimpleReason::Unclosed { span: unclosed_span, delimiter, }, expected: std::iter::once(expected).collect(), found, label: None, } } fn with_label(mut self, label: Self::Label) -> Self { self.label.get_or_insert(label); self } fn merge(mut self, other: Self) -> Self { // TODO: Assert that `self.span == other.span` here? self.reason = match (&self.reason, &other.reason) { (SimpleReason::Unclosed { .. }, _) => self.reason, (_, SimpleReason::Unclosed { .. }) => other.reason, _ => self.reason, }; for expected in other.expected { self.expected.insert(expected); } self } } impl<I: Hash + PartialEq, S: PartialEq> PartialEq for Simple<I, S> { fn eq(&self, other: &Self) -> bool { self.span == other.span && self.found == other.found && self.reason == other.reason && self.label == other.label } } impl<I: fmt::Display + Hash, S: Span> fmt::Display for Simple<I, S> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { // TODO: Take `self.reason` into account if let Some(found) = &self.found { write!(f, "found '{}' ", found)?; } else { write!(f, "found end of input ")?; } match self.expected.len() { 0 => write!(f, "but end of input was expected")?, 1 => write!( f, "but {} was expected", self.expected.iter().next().unwrap() )?, _ => write!( f, "but one of {} was expected", self.expected .iter() .map(|expected| expected.to_string()) .collect::<Vec<_>>() .join(", ") )?, } Ok(()) } } impl<I: fmt::Debug + fmt::Display + Hash, S: Span + fmt::Display + fmt::Debug> std::error::Error for Simple<I, S> { } /// A minimal error type that tracks only the error span and label. This type is most useful when you want fast parsing /// but do not particularly care about the quality of error messages. #[derive(Clone, Debug, PartialEq, Eq)] pub struct Cheap<I, S = Range<usize>> { span: S, label: Option<&'static str>, phantom: PhantomData<I>, } impl<I, S: Clone> Cheap<I, S> { /// Returns the span that the error occured at. pub fn span(&self) -> S { self.span.clone() } /// Returns the error's label, if any. pub fn label(&self) -> Option<&'static str> { self.label } } impl<I, S: Span + Clone + fmt::Debug> Error<I> for Cheap<I, S> { type Span = S; type Label = &'static str; fn expected_input_found<Iter: IntoIterator<Item = I>>( span: Self::Span, _: Iter, _: Option<I>, ) -> Self { Self { span, label: None, phantom: PhantomData, } } fn with_label(mut self, label: Self::Label) -> Self { self.label.get_or_insert(label); self } fn merge(self, _: Self) -> Self { self } }
found
copy-new-content.js
const fs = require('fs').promises; const path = require('path'); const newContent = new Map([['how-to-examples.md', 'how-to/examples.md']]); /** * Copies the new content files to the destination * @param {string} destination */ const copyNewContent = async (destination) => { for (const [source, target] of newContent) { await fs.copyFile( path.join(__dirname, source), path.join(destination, target) ); }
};
}; module.exports = { copyNewContent,
q125282.rs
/* So here is the plan! I want you all to write the smallest code that will compile, print Goodbye * Cruel World!, and then crash. Or, as a bonus twist challenge, print Hello World! and crash with * Goodbye Cruel World! */ pub fn test(){print!("Hello, World!");"".bytes().nth(1).expect("Goodbye, Cruel World!");} pub fn t1st()
{print!("Goodbye, Cruel World!");}
postgresHelper.go
package postgresHelper import ( "database/sql" "fmt" "strings" "github.com/bcaldwell/selfops/internal/config" _ "github.com/lib/pq" "k8s.io/klog" ) func CreatePostgresClient(dbname string) (*sql.DB, error) { // bypass creating of db if database_url is set because we are likely running in heroku then if config.CurrentSecrets().DatabaseURL == "" { databaselessConnStr := fmt.Sprintf("host=%s user=%s password=%s dbname=%s sslmode=disable", config.CurrentSqlSecrets().SqlHost, config.CurrentSqlSecrets().SqlUsername, config.CurrentSqlSecrets().SqlPassword, "postgres") db, err := sql.Open("postgres", databaselessConnStr) if err != nil { return nil, fmt.Errorf("Failed to create db for databaseless connection: %s", err) } rows, err := db.Query(fmt.Sprintf("SELECT datname FROM pg_database where datname = '%s'", config.CurrentYnabConfig().SQL.YnabDatabase)) if err != nil { return nil, fmt.Errorf("Failed to get list of databases: %s", err) } defer rows.Close() // next meaning there is a row, all we care about is if there is a row if !rows.Next() { klog.Infof("Creating database %s in postgres database\n", config.CurrentYnabConfig().SQL.YnabDatabase) _, err := db.Exec("CREATE DATABASE " + config.CurrentYnabConfig().SQL.YnabDatabase) if err != nil { return nil, err } } } db, err := sql.Open("postgres", getConnectionString(dbname)) if err != nil { return db, err } err = db.Ping() return db, err } func getConnectionString(dbname string) string { if config.CurrentSecrets().DatabaseURL != "" { return config.CurrentSecrets().DatabaseURL } return fmt.Sprintf("host=%s user=%s password=%s dbname=%s sslmode=disable", config.CurrentSqlSecrets().SqlHost, config.CurrentSqlSecrets().SqlUsername, config.CurrentSqlSecrets().SqlPassword, dbname) } func CreateTable(db *sql.DB, tableName string, parameters map[string]string) error { bodystr := "" for key, value := range parameters { bodystr += fmt.Sprintf("\"%s\" %s,", key, value) } createstr := fmt.Sprintf(` CREATE SEQUENCE IF NOT EXISTS "public"."%s_id_seq"; CREATE TABLE "public"."%s" ( "id" int4 DEFAULT nextval('%s_id_seq'::regclass), %s PRIMARY KEY ("id") ); `, tableName, tableName, tableName, bodystr) _, err := db.Exec(createstr) return err } func DropTable(db *sql.DB, tableName string) error { dropStr := fmt.Sprintf("DROP TABLE IF EXISTS %s;", tableName) _, err := db.Exec(dropStr) return err } // func TableExist(db *sql.DB) func insertStr(tableName string, parameters map[string]string) string { values := "" keys := "" first := true for key, value := range parameters { if value == "" { value = "EMPTY" } else { value = "'" + value + "'" } if first { keys = key values = value first = false } else { keys += "\", \"" + key values += ", " + value } } return fmt.Sprintf("INSERT INTO %s (\"%s\") VALUES (%s);", tableName, keys, values) } func Insert(db *sql.DB, tableName string, parameters map[string]string) error { queryStr := insertStr(tableName, parameters) _, err := db.Exec(queryStr) return err } func InsertRecords(db *sql.DB, tableName string, records []map[string]string) error { if len(records) == 0 { return nil } valueStr := "" keyStr := "" keys := []string{} first := true for key, _ := range records[0] { if first
else { keyStr += "\", \"" + key } keys = append(keys, key) } for _, record := range records { valueStr += "(" for i, key := range keys { value := record[key] if value == "" { value = "''" } else { value = "'" + strings.Replace(value, "'", "", -1) + "'" } if i == 0 { valueStr += value } else { valueStr += ", " + value } } valueStr += "),\n" } recordsInsertStr := fmt.Sprintf(` INSERT INTO %s ("%s") VALUES %s;`, tableName, keyStr, strings.TrimSuffix(valueStr, ",\n")) _, err := db.Exec(recordsInsertStr) return err }
{ keyStr = key first = false }
types.rs
use std::cell::RefCell; use std::default::Default; use std::fmt; use std::hash::{Hash, Hasher}; use std::iter::FromIterator; use std::num::NonZeroU32; use std::rc::Rc; use std::sync::Arc; use std::{slice, vec}; use rustc::middle::lang_items; use rustc::middle::stability; use rustc::ty::layout::VariantIdx; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir as hir; use rustc_hir::def::Res; use rustc_hir::def_id::{CrateNum, DefId}; use rustc_hir::Mutability; use rustc_index::vec::IndexVec; use rustc_span::hygiene::MacroKind; use rustc_span::source_map::DUMMY_SP; use rustc_span::symbol::{sym, Symbol}; use rustc_span::{self, FileName}; use rustc_target::spec::abi::Abi; use syntax::ast::{self, AttrStyle, Ident}; use syntax::attr; use syntax::util::comments::strip_doc_comment_decoration; use crate::clean::cfg::Cfg; use crate::clean::external_path; use crate::clean::inline; use crate::clean::types::Type::{QPath, ResolvedPath}; use crate::core::DocContext; use crate::doctree; use crate::html::item_type::ItemType; use crate::html::render::{cache, ExternalLocation}; use self::FunctionRetTy::*; use self::ItemEnum::*; use self::SelfTy::*; use self::Type::*; thread_local!(pub static MAX_DEF_ID: RefCell<FxHashMap<CrateNum, DefId>> = Default::default()); #[derive(Clone, Debug)] pub struct Crate { pub name: String, pub version: Option<String>, pub src: FileName, pub module: Option<Item>, pub externs: Vec<(CrateNum, ExternalCrate)>, pub primitives: Vec<(DefId, PrimitiveType, Attributes)>, // These are later on moved into `CACHEKEY`, leaving the map empty. // Only here so that they can be filtered through the rustdoc passes. pub external_traits: Rc<RefCell<FxHashMap<DefId, Trait>>>, pub masked_crates: FxHashSet<CrateNum>, pub collapsed: bool, } #[derive(Clone, Debug)] pub struct ExternalCrate { pub name: String, pub src: FileName, pub attrs: Attributes, pub primitives: Vec<(DefId, PrimitiveType, Attributes)>, pub keywords: Vec<(DefId, String, Attributes)>, } /// Anything with a source location and set of attributes and, optionally, a /// name. That is, anything that can be documented. This doesn't correspond /// directly to the AST's concept of an item; it's a strict superset. #[derive(Clone)] pub struct Item { /// Stringified span pub source: Span, /// Not everything has a name. E.g., impls pub name: Option<String>, pub attrs: Attributes, pub inner: ItemEnum, pub visibility: Visibility, pub def_id: DefId, pub stability: Option<Stability>, pub deprecation: Option<Deprecation>, } impl fmt::Debug for Item { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { let fake = MAX_DEF_ID.with(|m| { m.borrow().get(&self.def_id.krate).map(|id| self.def_id >= *id).unwrap_or(false) }); let def_id: &dyn fmt::Debug = if fake { &"**FAKE**" } else { &self.def_id }; fmt.debug_struct("Item") .field("source", &self.source) .field("name", &self.name) .field("attrs", &self.attrs) .field("inner", &self.inner) .field("visibility", &self.visibility) .field("def_id", def_id) .field("stability", &self.stability) .field("deprecation", &self.deprecation) .finish() } } impl Item { /// Finds the `doc` attribute as a NameValue and returns the corresponding /// value found. pub fn doc_value(&self) -> Option<&str> { self.attrs.doc_value() } /// Finds all `doc` attributes as NameValues and returns their corresponding values, joined /// with newlines. pub fn collapsed_doc_value(&self) -> Option<String> { self.attrs.collapsed_doc_value() } pub fn links(&self) -> Vec<(String, String)> { self.attrs.links(&self.def_id.krate) } pub fn is_crate(&self) -> bool { match self.inner { StrippedItem(box ModuleItem(Module { is_crate: true, .. })) | ModuleItem(Module { is_crate: true, .. }) => true, _ => false, } } pub fn is_mod(&self) -> bool { self.type_() == ItemType::Module } pub fn is_trait(&self) -> bool { self.type_() == ItemType::Trait } pub fn is_struct(&self) -> bool { self.type_() == ItemType::Struct } pub fn is_enum(&self) -> bool { self.type_() == ItemType::Enum } pub fn is_variant(&self) -> bool { self.type_() == ItemType::Variant } pub fn is_associated_type(&self) -> bool { self.type_() == ItemType::AssocType } pub fn is_associated_const(&self) -> bool { self.type_() == ItemType::AssocConst } pub fn is_method(&self) -> bool { self.type_() == ItemType::Method } pub fn is_ty_method(&self) -> bool { self.type_() == ItemType::TyMethod } pub fn is_typedef(&self) -> bool { self.type_() == ItemType::Typedef } pub fn is_primitive(&self) -> bool { self.type_() == ItemType::Primitive } pub fn is_union(&self) -> bool { self.type_() == ItemType::Union } pub fn is_import(&self) -> bool { self.type_() == ItemType::Import } pub fn is_extern_crate(&self) -> bool { self.type_() == ItemType::ExternCrate } pub fn is_keyword(&self) -> bool { self.type_() == ItemType::Keyword
pub fn is_stripped(&self) -> bool { match self.inner { StrippedItem(..) => true, _ => false, } } pub fn has_stripped_fields(&self) -> Option<bool> { match self.inner { StructItem(ref _struct) => Some(_struct.fields_stripped), UnionItem(ref union) => Some(union.fields_stripped), VariantItem(Variant { kind: VariantKind::Struct(ref vstruct) }) => { Some(vstruct.fields_stripped) } _ => None, } } pub fn stability_class(&self) -> Option<String> { self.stability.as_ref().and_then(|ref s| { let mut classes = Vec::with_capacity(2); if s.level == stability::Unstable { classes.push("unstable"); } if s.deprecation.is_some() { classes.push("deprecated"); } if classes.len() != 0 { Some(classes.join(" ")) } else { None } }) } pub fn stable_since(&self) -> Option<&str> { self.stability.as_ref().map(|s| &s.since[..]) } pub fn is_non_exhaustive(&self) -> bool { self.attrs.other_attrs.iter().any(|a| a.check_name(sym::non_exhaustive)) } /// Returns a documentation-level item type from the item. pub fn type_(&self) -> ItemType { ItemType::from(self) } /// Returns the info in the item's `#[deprecated]` or `#[rustc_deprecated]` attributes. /// /// If the item is not deprecated, returns `None`. pub fn deprecation(&self) -> Option<&Deprecation> { self.deprecation .as_ref() .or_else(|| self.stability.as_ref().and_then(|s| s.deprecation.as_ref())) } pub fn is_default(&self) -> bool { match self.inner { ItemEnum::MethodItem(ref meth) => { if let Some(defaultness) = meth.defaultness { defaultness.has_value() && !defaultness.is_final() } else { false } } _ => false, } } } #[derive(Clone, Debug)] pub enum ItemEnum { ExternCrateItem(String, Option<String>), ImportItem(Import), StructItem(Struct), UnionItem(Union), EnumItem(Enum), FunctionItem(Function), ModuleItem(Module), TypedefItem(Typedef, bool /* is associated type */), OpaqueTyItem(OpaqueTy, bool /* is associated type */), StaticItem(Static), ConstantItem(Constant), TraitItem(Trait), TraitAliasItem(TraitAlias), ImplItem(Impl), /// A method signature only. Used for required methods in traits (ie, /// non-default-methods). TyMethodItem(TyMethod), /// A method with a body. MethodItem(Method), StructFieldItem(Type), VariantItem(Variant), /// `fn`s from an extern block ForeignFunctionItem(Function), /// `static`s from an extern block ForeignStaticItem(Static), /// `type`s from an extern block ForeignTypeItem, MacroItem(Macro), ProcMacroItem(ProcMacro), PrimitiveItem(PrimitiveType), AssocConstItem(Type, Option<String>), AssocTypeItem(Vec<GenericBound>, Option<Type>), /// An item that has been stripped by a rustdoc pass StrippedItem(Box<ItemEnum>), KeywordItem(String), } impl ItemEnum { pub fn is_associated(&self) -> bool { match *self { ItemEnum::TypedefItem(_, _) | ItemEnum::AssocTypeItem(_, _) => true, _ => false, } } } #[derive(Clone, Debug)] pub struct Module { pub items: Vec<Item>, pub is_crate: bool, } pub struct ListAttributesIter<'a> { attrs: slice::Iter<'a, ast::Attribute>, current_list: vec::IntoIter<ast::NestedMetaItem>, name: Symbol, } impl<'a> Iterator for ListAttributesIter<'a> { type Item = ast::NestedMetaItem; fn next(&mut self) -> Option<Self::Item> { if let Some(nested) = self.current_list.next() { return Some(nested); } for attr in &mut self.attrs { if let Some(list) = attr.meta_item_list() { if attr.check_name(self.name) { self.current_list = list.into_iter(); if let Some(nested) = self.current_list.next() { return Some(nested); } } } } None } fn size_hint(&self) -> (usize, Option<usize>) { let lower = self.current_list.len(); (lower, None) } } pub trait AttributesExt { /// Finds an attribute as List and returns the list of attributes nested inside. fn lists(&self, name: Symbol) -> ListAttributesIter<'_>; } impl AttributesExt for [ast::Attribute] { fn lists(&self, name: Symbol) -> ListAttributesIter<'_> { ListAttributesIter { attrs: self.iter(), current_list: Vec::new().into_iter(), name } } } pub trait NestedAttributesExt { /// Returns `true` if the attribute list contains a specific `Word` fn has_word(self, word: Symbol) -> bool; } impl<I: IntoIterator<Item = ast::NestedMetaItem>> NestedAttributesExt for I { fn has_word(self, word: Symbol) -> bool { self.into_iter().any(|attr| attr.is_word() && attr.check_name(word)) } } /// A portion of documentation, extracted from a `#[doc]` attribute. /// /// Each variant contains the line number within the complete doc-comment where the fragment /// starts, as well as the Span where the corresponding doc comment or attribute is located. /// /// Included files are kept separate from inline doc comments so that proper line-number /// information can be given when a doctest fails. Sugared doc comments and "raw" doc comments are /// kept separate because of issue #42760. #[derive(Clone, PartialEq, Eq, Debug, Hash)] pub enum DocFragment { /// A doc fragment created from a `///` or `//!` doc comment. SugaredDoc(usize, rustc_span::Span, String), /// A doc fragment created from a "raw" `#[doc=""]` attribute. RawDoc(usize, rustc_span::Span, String), /// A doc fragment created from a `#[doc(include="filename")]` attribute. Contains both the /// given filename and the file contents. Include(usize, rustc_span::Span, String, String), } impl DocFragment { pub fn as_str(&self) -> &str { match *self { DocFragment::SugaredDoc(_, _, ref s) => &s[..], DocFragment::RawDoc(_, _, ref s) => &s[..], DocFragment::Include(_, _, _, ref s) => &s[..], } } pub fn span(&self) -> rustc_span::Span { match *self { DocFragment::SugaredDoc(_, span, _) | DocFragment::RawDoc(_, span, _) | DocFragment::Include(_, span, _, _) => span, } } } impl<'a> FromIterator<&'a DocFragment> for String { fn from_iter<T>(iter: T) -> Self where T: IntoIterator<Item = &'a DocFragment>, { iter.into_iter().fold(String::new(), |mut acc, frag| { if !acc.is_empty() { acc.push('\n'); } match *frag { DocFragment::SugaredDoc(_, _, ref docs) | DocFragment::RawDoc(_, _, ref docs) | DocFragment::Include(_, _, _, ref docs) => acc.push_str(docs), } acc }) } } #[derive(Clone, Debug, Default)] pub struct Attributes { pub doc_strings: Vec<DocFragment>, pub other_attrs: Vec<ast::Attribute>, pub cfg: Option<Arc<Cfg>>, pub span: Option<rustc_span::Span>, /// map from Rust paths to resolved defs and potential URL fragments pub links: Vec<(String, Option<DefId>, Option<String>)>, pub inner_docs: bool, } impl Attributes { /// Extracts the content from an attribute `#[doc(cfg(content))]`. pub fn extract_cfg(mi: &ast::MetaItem) -> Option<&ast::MetaItem> { use syntax::ast::NestedMetaItem::MetaItem; if let ast::MetaItemKind::List(ref nmis) = mi.kind { if nmis.len() == 1 { if let MetaItem(ref cfg_mi) = nmis[0] { if cfg_mi.check_name(sym::cfg) { if let ast::MetaItemKind::List(ref cfg_nmis) = cfg_mi.kind { if cfg_nmis.len() == 1 { if let MetaItem(ref content_mi) = cfg_nmis[0] { return Some(content_mi); } } } } } } } None } /// Reads a `MetaItem` from within an attribute, looks for whether it is a /// `#[doc(include="file")]`, and returns the filename and contents of the file as loaded from /// its expansion. pub fn extract_include(mi: &ast::MetaItem) -> Option<(String, String)> { mi.meta_item_list().and_then(|list| { for meta in list { if meta.check_name(sym::include) { // the actual compiled `#[doc(include="filename")]` gets expanded to // `#[doc(include(file="filename", contents="file contents")]` so we need to // look for that instead return meta.meta_item_list().and_then(|list| { let mut filename: Option<String> = None; let mut contents: Option<String> = None; for it in list { if it.check_name(sym::file) { if let Some(name) = it.value_str() { filename = Some(name.to_string()); } } else if it.check_name(sym::contents) { if let Some(docs) = it.value_str() { contents = Some(docs.to_string()); } } } if let (Some(filename), Some(contents)) = (filename, contents) { Some((filename, contents)) } else { None } }); } } None }) } pub fn has_doc_flag(&self, flag: Symbol) -> bool { for attr in &self.other_attrs { if !attr.check_name(sym::doc) { continue; } if let Some(items) = attr.meta_item_list() { if items.iter().filter_map(|i| i.meta_item()).any(|it| it.check_name(flag)) { return true; } } } false } pub fn from_ast(diagnostic: &::rustc_errors::Handler, attrs: &[ast::Attribute]) -> Attributes { let mut doc_strings = vec![]; let mut sp = None; let mut cfg = Cfg::True; let mut doc_line = 0; let other_attrs = attrs .iter() .filter_map(|attr| { if let Some(value) = attr.doc_str() { let (value, mk_fragment): (_, fn(_, _, _) -> _) = if attr.is_doc_comment() { (strip_doc_comment_decoration(&value.as_str()), DocFragment::SugaredDoc) } else { (value.to_string(), DocFragment::RawDoc) }; let line = doc_line; doc_line += value.lines().count(); doc_strings.push(mk_fragment(line, attr.span, value)); if sp.is_none() { sp = Some(attr.span); } None } else { if attr.check_name(sym::doc) { if let Some(mi) = attr.meta() { if let Some(cfg_mi) = Attributes::extract_cfg(&mi) { // Extracted #[doc(cfg(...))] match Cfg::parse(cfg_mi) { Ok(new_cfg) => cfg &= new_cfg, Err(e) => diagnostic.span_err(e.span, e.msg), } } else if let Some((filename, contents)) = Attributes::extract_include(&mi) { let line = doc_line; doc_line += contents.lines().count(); doc_strings.push(DocFragment::Include( line, attr.span, filename, contents, )); } } } Some(attr.clone()) } }) .collect(); // treat #[target_feature(enable = "feat")] attributes as if they were // #[doc(cfg(target_feature = "feat"))] attributes as well for attr in attrs.lists(sym::target_feature) { if attr.check_name(sym::enable) { if let Some(feat) = attr.value_str() { let meta = attr::mk_name_value_item_str( Ident::with_dummy_span(sym::target_feature), feat, DUMMY_SP, ); if let Ok(feat_cfg) = Cfg::parse(&meta) { cfg &= feat_cfg; } } } } let inner_docs = attrs .iter() .filter(|a| a.doc_str().is_some()) .next() .map_or(true, |a| a.style == AttrStyle::Inner); Attributes { doc_strings, other_attrs, cfg: if cfg == Cfg::True { None } else { Some(Arc::new(cfg)) }, span: sp, links: vec![], inner_docs, } } /// Finds the `doc` attribute as a NameValue and returns the corresponding /// value found. pub fn doc_value(&self) -> Option<&str> { self.doc_strings.first().map(|s| s.as_str()) } /// Finds all `doc` attributes as NameValues and returns their corresponding values, joined /// with newlines. pub fn collapsed_doc_value(&self) -> Option<String> { if !self.doc_strings.is_empty() { Some(self.doc_strings.iter().collect()) } else { None } } /// Gets links as a vector /// /// Cache must be populated before call pub fn links(&self, krate: &CrateNum) -> Vec<(String, String)> { use crate::html::format::href; self.links .iter() .filter_map(|&(ref s, did, ref fragment)| { match did { Some(did) => { if let Some((mut href, ..)) = href(did) { if let Some(ref fragment) = *fragment { href.push_str("#"); href.push_str(fragment); } Some((s.clone(), href)) } else { None } } None => { if let Some(ref fragment) = *fragment { let cache = cache(); let url = match cache.extern_locations.get(krate) { Some(&(_, ref src, ExternalLocation::Local)) => { src.to_str().expect("invalid file path") } Some(&(_, _, ExternalLocation::Remote(ref s))) => s, Some(&(_, _, ExternalLocation::Unknown)) | None => { "https://doc.rust-lang.org/nightly" } }; // This is a primitive so the url is done "by hand". let tail = fragment.find('#').unwrap_or_else(|| fragment.len()); Some(( s.clone(), format!( "{}{}std/primitive.{}.html{}", url, if !url.ends_with('/') { "/" } else { "" }, &fragment[..tail], &fragment[tail..] ), )) } else { panic!("This isn't a primitive?!"); } } } }) .collect() } } impl PartialEq for Attributes { fn eq(&self, rhs: &Self) -> bool { self.doc_strings == rhs.doc_strings && self.cfg == rhs.cfg && self.span == rhs.span && self.links == rhs.links && self .other_attrs .iter() .map(|attr| attr.id) .eq(rhs.other_attrs.iter().map(|attr| attr.id)) } } impl Eq for Attributes {} impl Hash for Attributes { fn hash<H: Hasher>(&self, hasher: &mut H) { self.doc_strings.hash(hasher); self.cfg.hash(hasher); self.span.hash(hasher); self.links.hash(hasher); for attr in &self.other_attrs { attr.id.hash(hasher); } } } impl AttributesExt for Attributes { fn lists(&self, name: Symbol) -> ListAttributesIter<'_> { self.other_attrs.lists(name) } } #[derive(Clone, PartialEq, Eq, Debug, Hash)] pub enum GenericBound { TraitBound(PolyTrait, hir::TraitBoundModifier), Outlives(Lifetime), } impl GenericBound { pub fn maybe_sized(cx: &DocContext<'_>) -> GenericBound { let did = cx.tcx.require_lang_item(lang_items::SizedTraitLangItem, None); let empty = cx.tcx.intern_substs(&[]); let path = external_path(cx, cx.tcx.item_name(did), Some(did), false, vec![], empty); inline::record_extern_fqn(cx, did, TypeKind::Trait); GenericBound::TraitBound( PolyTrait { trait_: ResolvedPath { path, param_names: None, did, is_generic: false }, generic_params: Vec::new(), }, hir::TraitBoundModifier::Maybe, ) } pub fn is_sized_bound(&self, cx: &DocContext<'_>) -> bool { use rustc_hir::TraitBoundModifier as TBM; if let GenericBound::TraitBound(PolyTrait { ref trait_, .. }, TBM::None) = *self { if trait_.def_id() == cx.tcx.lang_items().sized_trait() { return true; } } false } pub fn get_poly_trait(&self) -> Option<PolyTrait> { if let GenericBound::TraitBound(ref p, _) = *self { return Some(p.clone()); } None } pub fn get_trait_type(&self) -> Option<Type> { if let GenericBound::TraitBound(PolyTrait { ref trait_, .. }, _) = *self { Some(trait_.clone()) } else { None } } } #[derive(Clone, PartialEq, Eq, Debug, Hash)] pub struct Lifetime(pub String); impl Lifetime { pub fn get_ref<'a>(&'a self) -> &'a str { let Lifetime(ref s) = *self; let s: &'a str = s; s } pub fn statik() -> Lifetime { Lifetime("'static".to_string()) } } #[derive(Clone, Debug)] pub enum WherePredicate { BoundPredicate { ty: Type, bounds: Vec<GenericBound> }, RegionPredicate { lifetime: Lifetime, bounds: Vec<GenericBound> }, EqPredicate { lhs: Type, rhs: Type }, } impl WherePredicate { pub fn get_bounds(&self) -> Option<&[GenericBound]> { match *self { WherePredicate::BoundPredicate { ref bounds, .. } => Some(bounds), WherePredicate::RegionPredicate { ref bounds, .. } => Some(bounds), _ => None, } } } #[derive(Clone, PartialEq, Eq, Debug, Hash)] pub enum GenericParamDefKind { Lifetime, Type { did: DefId, bounds: Vec<GenericBound>, default: Option<Type>, synthetic: Option<hir::SyntheticTyParamKind>, }, Const { did: DefId, ty: Type, }, } impl GenericParamDefKind { pub fn is_type(&self) -> bool { match *self { GenericParamDefKind::Type { .. } => true, _ => false, } } // FIXME(eddyb) this either returns the default of a type parameter, or the // type of a `const` parameter. It seems that the intention is to *visit* // any embedded types, but `get_type` seems to be the wrong name for that. pub fn get_type(&self) -> Option<Type> { match self { GenericParamDefKind::Type { default, .. } => default.clone(), GenericParamDefKind::Const { ty, .. } => Some(ty.clone()), GenericParamDefKind::Lifetime => None, } } } #[derive(Clone, PartialEq, Eq, Debug, Hash)] pub struct GenericParamDef { pub name: String, pub kind: GenericParamDefKind, } impl GenericParamDef { pub fn is_synthetic_type_param(&self) -> bool { match self.kind { GenericParamDefKind::Lifetime | GenericParamDefKind::Const { .. } => false, GenericParamDefKind::Type { ref synthetic, .. } => synthetic.is_some(), } } pub fn is_type(&self) -> bool { self.kind.is_type() } pub fn get_type(&self) -> Option<Type> { self.kind.get_type() } pub fn get_bounds(&self) -> Option<&[GenericBound]> { match self.kind { GenericParamDefKind::Type { ref bounds, .. } => Some(bounds), _ => None, } } } // maybe use a Generic enum and use Vec<Generic>? #[derive(Clone, Debug, Default)] pub struct Generics { pub params: Vec<GenericParamDef>, pub where_predicates: Vec<WherePredicate>, } #[derive(Clone, Debug)] pub struct Method { pub generics: Generics, pub decl: FnDecl, pub header: hir::FnHeader, pub defaultness: Option<hir::Defaultness>, pub all_types: Vec<Type>, pub ret_types: Vec<Type>, } #[derive(Clone, Debug)] pub struct TyMethod { pub header: hir::FnHeader, pub decl: FnDecl, pub generics: Generics, pub all_types: Vec<Type>, pub ret_types: Vec<Type>, } #[derive(Clone, Debug)] pub struct Function { pub decl: FnDecl, pub generics: Generics, pub header: hir::FnHeader, pub all_types: Vec<Type>, pub ret_types: Vec<Type>, } #[derive(Clone, PartialEq, Eq, Debug, Hash)] pub struct FnDecl { pub inputs: Arguments, pub output: FunctionRetTy, pub c_variadic: bool, pub attrs: Attributes, } impl FnDecl { pub fn self_type(&self) -> Option<SelfTy> { self.inputs.values.get(0).and_then(|v| v.to_self()) } /// Returns the sugared return type for an async function. /// /// For example, if the return type is `impl std::future::Future<Output = i32>`, this function /// will return `i32`. /// /// # Panics /// /// This function will panic if the return type does not match the expected sugaring for async /// functions. pub fn sugared_async_return_type(&self) -> FunctionRetTy { match &self.output { FunctionRetTy::Return(Type::ImplTrait(bounds)) => match &bounds[0] { GenericBound::TraitBound(PolyTrait { trait_, .. }, ..) => { let bindings = trait_.bindings().unwrap(); FunctionRetTy::Return(bindings[0].ty().clone()) } _ => panic!("unexpected desugaring of async function"), }, _ => panic!("unexpected desugaring of async function"), } } } #[derive(Clone, PartialEq, Eq, Debug, Hash)] pub struct Arguments { pub values: Vec<Argument>, } #[derive(Clone, PartialEq, Eq, Debug, Hash)] pub struct Argument { pub type_: Type, pub name: String, } #[derive(Clone, PartialEq, Debug)] pub enum SelfTy { SelfValue, SelfBorrowed(Option<Lifetime>, Mutability), SelfExplicit(Type), } impl Argument { pub fn to_self(&self) -> Option<SelfTy> { if self.name != "self" { return None; } if self.type_.is_self_type() { return Some(SelfValue); } match self.type_ { BorrowedRef { ref lifetime, mutability, ref type_ } if type_.is_self_type() => { Some(SelfBorrowed(lifetime.clone(), mutability)) } _ => Some(SelfExplicit(self.type_.clone())), } } } #[derive(Clone, PartialEq, Eq, Debug, Hash)] pub enum FunctionRetTy { Return(Type), DefaultReturn, } impl GetDefId for FunctionRetTy { fn def_id(&self) -> Option<DefId> { match *self { Return(ref ty) => ty.def_id(), DefaultReturn => None, } } } #[derive(Clone, Debug)] pub struct Trait { pub auto: bool, pub unsafety: hir::Unsafety, pub items: Vec<Item>, pub generics: Generics, pub bounds: Vec<GenericBound>, pub is_spotlight: bool, pub is_auto: bool, } #[derive(Clone, Debug)] pub struct TraitAlias { pub generics: Generics, pub bounds: Vec<GenericBound>, } /// A trait reference, which may have higher ranked lifetimes. #[derive(Clone, PartialEq, Eq, Debug, Hash)] pub struct PolyTrait { pub trait_: Type, pub generic_params: Vec<GenericParamDef>, } /// A representation of a type suitable for hyperlinking purposes. Ideally, one can get the original /// type out of the AST/`TyCtxt` given one of these, if more information is needed. Most /// importantly, it does not preserve mutability or boxes. #[derive(Clone, PartialEq, Eq, Debug, Hash)] pub enum Type { /// Structs/enums/traits (most that would be an `hir::TyKind::Path`). ResolvedPath { path: Path, param_names: Option<Vec<GenericBound>>, did: DefId, /// `true` if is a `T::Name` path for associated types. is_generic: bool, }, /// For parameterized types, so the consumer of the JSON don't go /// looking for types which don't exist anywhere. Generic(String), /// Primitives are the fixed-size numeric types (plus int/usize/float), char, /// arrays, slices, and tuples. Primitive(PrimitiveType), /// `extern "ABI" fn` BareFunction(Box<BareFunctionDecl>), Tuple(Vec<Type>), Slice(Box<Type>), Array(Box<Type>, String), Never, RawPointer(Mutability, Box<Type>), BorrowedRef { lifetime: Option<Lifetime>, mutability: Mutability, type_: Box<Type>, }, // `<Type as Trait>::Name` QPath { name: String, self_type: Box<Type>, trait_: Box<Type>, }, // `_` Infer, // `impl TraitA + TraitB + ...` ImplTrait(Vec<GenericBound>), } #[derive(Clone, PartialEq, Eq, Hash, Copy, Debug)] pub enum PrimitiveType { Isize, I8, I16, I32, I64, I128, Usize, U8, U16, U32, U64, U128, F32, F64, Char, Bool, Str, Slice, Array, Tuple, Unit, RawPointer, Reference, Fn, Never, } #[derive(Clone, Copy, Debug)] pub enum TypeKind { Enum, Function, Module, Const, Static, Struct, Union, Trait, Typedef, Foreign, Macro, Attr, Derive, TraitAlias, } pub trait GetDefId { fn def_id(&self) -> Option<DefId>; } impl<T: GetDefId> GetDefId for Option<T> { fn def_id(&self) -> Option<DefId> { self.as_ref().and_then(|d| d.def_id()) } } impl Type { pub fn primitive_type(&self) -> Option<PrimitiveType> { match *self { Primitive(p) | BorrowedRef { type_: box Primitive(p), .. } => Some(p), Slice(..) | BorrowedRef { type_: box Slice(..), .. } => Some(PrimitiveType::Slice), Array(..) | BorrowedRef { type_: box Array(..), .. } => Some(PrimitiveType::Array), Tuple(ref tys) => { if tys.is_empty() { Some(PrimitiveType::Unit) } else { Some(PrimitiveType::Tuple) } } RawPointer(..) => Some(PrimitiveType::RawPointer), BorrowedRef { type_: box Generic(..), .. } => Some(PrimitiveType::Reference), BareFunction(..) => Some(PrimitiveType::Fn), Never => Some(PrimitiveType::Never), _ => None, } } pub fn is_generic(&self) -> bool { match *self { ResolvedPath { is_generic, .. } => is_generic, _ => false, } } pub fn is_self_type(&self) -> bool { match *self { Generic(ref name) => name == "Self", _ => false, } } pub fn generics(&self) -> Option<Vec<Type>> { match *self { ResolvedPath { ref path, .. } => path.segments.last().and_then(|seg| { if let GenericArgs::AngleBracketed { ref args, .. } = seg.args { Some( args.iter() .filter_map(|arg| match arg { GenericArg::Type(ty) => Some(ty.clone()), _ => None, }) .collect(), ) } else { None } }), _ => None, } } pub fn bindings(&self) -> Option<&[TypeBinding]> { match *self { ResolvedPath { ref path, .. } => path.segments.last().and_then(|seg| { if let GenericArgs::AngleBracketed { ref bindings, .. } = seg.args { Some(&**bindings) } else { None } }), _ => None, } } pub fn is_full_generic(&self) -> bool { match *self { Type::Generic(_) => true, _ => false, } } pub fn projection(&self) -> Option<(&Type, DefId, &str)> { let (self_, trait_, name) = match self { QPath { ref self_type, ref trait_, ref name } => (self_type, trait_, name), _ => return None, }; let trait_did = match **trait_ { ResolvedPath { did, .. } => did, _ => return None, }; Some((&self_, trait_did, name)) } } impl GetDefId for Type { fn def_id(&self) -> Option<DefId> { match *self { ResolvedPath { did, .. } => Some(did), Primitive(p) => crate::html::render::cache().primitive_locations.get(&p).cloned(), BorrowedRef { type_: box Generic(..), .. } => { Primitive(PrimitiveType::Reference).def_id() } BorrowedRef { ref type_, .. } => type_.def_id(), Tuple(ref tys) => { if tys.is_empty() { Primitive(PrimitiveType::Unit).def_id() } else { Primitive(PrimitiveType::Tuple).def_id() } } BareFunction(..) => Primitive(PrimitiveType::Fn).def_id(), Never => Primitive(PrimitiveType::Never).def_id(), Slice(..) => Primitive(PrimitiveType::Slice).def_id(), Array(..) => Primitive(PrimitiveType::Array).def_id(), RawPointer(..) => Primitive(PrimitiveType::RawPointer).def_id(), QPath { ref self_type, .. } => self_type.def_id(), _ => None, } } } impl PrimitiveType { pub fn from_str(s: &str) -> Option<PrimitiveType> { match s { "isize" => Some(PrimitiveType::Isize), "i8" => Some(PrimitiveType::I8), "i16" => Some(PrimitiveType::I16), "i32" => Some(PrimitiveType::I32), "i64" => Some(PrimitiveType::I64), "i128" => Some(PrimitiveType::I128), "usize" => Some(PrimitiveType::Usize), "u8" => Some(PrimitiveType::U8), "u16" => Some(PrimitiveType::U16), "u32" => Some(PrimitiveType::U32), "u64" => Some(PrimitiveType::U64), "u128" => Some(PrimitiveType::U128), "bool" => Some(PrimitiveType::Bool), "char" => Some(PrimitiveType::Char), "str" => Some(PrimitiveType::Str), "f32" => Some(PrimitiveType::F32), "f64" => Some(PrimitiveType::F64), "array" => Some(PrimitiveType::Array), "slice" => Some(PrimitiveType::Slice), "tuple" => Some(PrimitiveType::Tuple), "unit" => Some(PrimitiveType::Unit), "pointer" => Some(PrimitiveType::RawPointer), "reference" => Some(PrimitiveType::Reference), "fn" => Some(PrimitiveType::Fn), "never" => Some(PrimitiveType::Never), _ => None, } } pub fn as_str(&self) -> &'static str { use self::PrimitiveType::*; match *self { Isize => "isize", I8 => "i8", I16 => "i16", I32 => "i32", I64 => "i64", I128 => "i128", Usize => "usize", U8 => "u8", U16 => "u16", U32 => "u32", U64 => "u64", U128 => "u128", F32 => "f32", F64 => "f64", Str => "str", Bool => "bool", Char => "char", Array => "array", Slice => "slice", Tuple => "tuple", Unit => "unit", RawPointer => "pointer", Reference => "reference", Fn => "fn", Never => "never", } } pub fn to_url_str(&self) -> &'static str { self.as_str() } } impl From<ast::IntTy> for PrimitiveType { fn from(int_ty: ast::IntTy) -> PrimitiveType { match int_ty { ast::IntTy::Isize => PrimitiveType::Isize, ast::IntTy::I8 => PrimitiveType::I8, ast::IntTy::I16 => PrimitiveType::I16, ast::IntTy::I32 => PrimitiveType::I32, ast::IntTy::I64 => PrimitiveType::I64, ast::IntTy::I128 => PrimitiveType::I128, } } } impl From<ast::UintTy> for PrimitiveType { fn from(uint_ty: ast::UintTy) -> PrimitiveType { match uint_ty { ast::UintTy::Usize => PrimitiveType::Usize, ast::UintTy::U8 => PrimitiveType::U8, ast::UintTy::U16 => PrimitiveType::U16, ast::UintTy::U32 => PrimitiveType::U32, ast::UintTy::U64 => PrimitiveType::U64, ast::UintTy::U128 => PrimitiveType::U128, } } } impl From<ast::FloatTy> for PrimitiveType { fn from(float_ty: ast::FloatTy) -> PrimitiveType { match float_ty { ast::FloatTy::F32 => PrimitiveType::F32, ast::FloatTy::F64 => PrimitiveType::F64, } } } #[derive(Clone, PartialEq, Eq, Debug)] pub enum Visibility { Public, Inherited, Crate, Restricted(DefId, Path), } #[derive(Clone, Debug)] pub struct Struct { pub struct_type: doctree::StructType, pub generics: Generics, pub fields: Vec<Item>, pub fields_stripped: bool, } #[derive(Clone, Debug)] pub struct Union { pub struct_type: doctree::StructType, pub generics: Generics, pub fields: Vec<Item>, pub fields_stripped: bool, } /// This is a more limited form of the standard Struct, different in that /// it lacks the things most items have (name, id, parameterization). Found /// only as a variant in an enum. #[derive(Clone, Debug)] pub struct VariantStruct { pub struct_type: doctree::StructType, pub fields: Vec<Item>, pub fields_stripped: bool, } #[derive(Clone, Debug)] pub struct Enum { pub variants: IndexVec<VariantIdx, Item>, pub generics: Generics, pub variants_stripped: bool, } #[derive(Clone, Debug)] pub struct Variant { pub kind: VariantKind, } #[derive(Clone, Debug)] pub enum VariantKind { CLike, Tuple(Vec<Type>), Struct(VariantStruct), } #[derive(Clone, Debug)] pub struct Span { pub filename: FileName, pub loline: usize, pub locol: usize, pub hiline: usize, pub hicol: usize, pub original: rustc_span::Span, } impl Span { pub fn empty() -> Span { Span { filename: FileName::Anon(0), loline: 0, locol: 0, hiline: 0, hicol: 0, original: rustc_span::DUMMY_SP, } } pub fn span(&self) -> rustc_span::Span { self.original } } #[derive(Clone, PartialEq, Eq, Debug, Hash)] pub struct Path { pub global: bool, pub res: Res, pub segments: Vec<PathSegment>, } impl Path { pub fn last_name(&self) -> &str { self.segments.last().expect("segments were empty").name.as_str() } } #[derive(Clone, PartialEq, Eq, Debug, Hash)] pub enum GenericArg { Lifetime(Lifetime), Type(Type), Const(Constant), } #[derive(Clone, PartialEq, Eq, Debug, Hash)] pub enum GenericArgs { AngleBracketed { args: Vec<GenericArg>, bindings: Vec<TypeBinding> }, Parenthesized { inputs: Vec<Type>, output: Option<Type> }, } #[derive(Clone, PartialEq, Eq, Debug, Hash)] pub struct PathSegment { pub name: String, pub args: GenericArgs, } #[derive(Clone, Debug)] pub struct Typedef { pub type_: Type, pub generics: Generics, // Type of target item. pub item_type: Option<Type>, } impl GetDefId for Typedef { fn def_id(&self) -> Option<DefId> { self.type_.def_id() } } #[derive(Clone, Debug)] pub struct OpaqueTy { pub bounds: Vec<GenericBound>, pub generics: Generics, } #[derive(Clone, PartialEq, Eq, Debug, Hash)] pub struct BareFunctionDecl { pub unsafety: hir::Unsafety, pub generic_params: Vec<GenericParamDef>, pub decl: FnDecl, pub abi: Abi, } #[derive(Clone, Debug)] pub struct Static { pub type_: Type, pub mutability: Mutability, /// It's useful to have the value of a static documented, but I have no /// desire to represent expressions (that'd basically be all of the AST, /// which is huge!). So, have a string. pub expr: String, } #[derive(Clone, PartialEq, Eq, Hash, Debug)] pub struct Constant { pub type_: Type, pub expr: String, pub value: Option<String>, pub is_literal: bool, } #[derive(Clone, PartialEq, Debug)] pub enum ImplPolarity { Positive, Negative, } #[derive(Clone, Debug)] pub struct Impl { pub unsafety: hir::Unsafety, pub generics: Generics, pub provided_trait_methods: FxHashSet<String>, pub trait_: Option<Type>, pub for_: Type, pub items: Vec<Item>, pub polarity: Option<ImplPolarity>, pub synthetic: bool, pub blanket_impl: Option<Type>, } #[derive(Clone, Debug)] pub enum Import { // use source as str; Simple(String, ImportSource), // use source::*; Glob(ImportSource), } #[derive(Clone, Debug)] pub struct ImportSource { pub path: Path, pub did: Option<DefId>, } #[derive(Clone, Debug)] pub struct Macro { pub source: String, pub imported_from: Option<String>, } #[derive(Clone, Debug)] pub struct ProcMacro { pub kind: MacroKind, pub helpers: Vec<String>, } #[derive(Clone, Debug)] pub struct Stability { pub level: stability::StabilityLevel, pub feature: Option<String>, pub since: String, pub deprecation: Option<Deprecation>, pub unstable_reason: Option<String>, pub issue: Option<NonZeroU32>, } #[derive(Clone, Debug)] pub struct Deprecation { pub since: Option<String>, pub note: Option<String>, } /// An type binding on an associated type (e.g., `A = Bar` in `Foo<A = Bar>` or /// `A: Send + Sync` in `Foo<A: Send + Sync>`). #[derive(Clone, PartialEq, Eq, Debug, Hash)] pub struct TypeBinding { pub name: String, pub kind: TypeBindingKind, } #[derive(Clone, PartialEq, Eq, Debug, Hash)] pub enum TypeBindingKind { Equality { ty: Type }, Constraint { bounds: Vec<GenericBound> }, } impl TypeBinding { pub fn ty(&self) -> &Type { match self.kind { TypeBindingKind::Equality { ref ty } => ty, _ => panic!("expected equality type binding for parenthesized generic args"), } } }
}
model.py
import utils class Model: def
(self, file_path): with open(file_path, 'r', encoding="utf8") as model_file: self.model_tree = {} for line in model_file: chars, minus_log_p = utils.parse_model_file_line(line) n_1_gram = ''.join(chars[:-1]) last_char = chars[-1] if n_1_gram not in self.model_tree: self.model_tree[n_1_gram] = {} self.model_tree[n_1_gram][last_char] = minus_log_p for n_1_gram in self.model_tree: min_n_char, min_value = next(iter(self.model_tree[n_1_gram].items())) for n_char, value in self.model_tree[n_1_gram].items(): if value < min_value: min_n_char, min_value = n_char, value self.model_tree[n_1_gram] = min_n_char def __getitem__(self, n_1_gram): return self.model_tree[n_1_gram]
__init__
interfaces.py
from zope.publisher.interfaces.browser import IDefaultBrowserLayer class IYafowilLayer(IDefaultBrowserLayer):
class IYafowilDemoLayer(IYafowilLayer): """YAFOWIL demos related browser layer. """
"""YAFOWIL related browser layer. """
afrl_helpers.py
import matplotlib.colors as mplColors import numpy as np from bokeh.io import output_notebook from bokeh.plotting import figure from bokeh.resources import INLINE from freud import box from matplotlib import cm output_notebook(resources=INLINE) # define vertices for hexagons verts = [ [0.537284965911771, 0.31020161970069976], [3.7988742065678664e-17, 0.6204032394013997], [-0.5372849659117709, 0.31020161970070004], [-0.5372849659117711, -0.31020161970069976], [-1.1396622619703597e-16, -0.6204032394013997], [0.5372849659117711, -0.3102016197006997], ] verts = np.array(verts) # define colors for our system c_list = [ "#30A2DA", "#FC4F30", "#E5AE38", "#6D904F", "#9757DB", "#188487", "#FF7F00", "#9A2C66", "#626DDA", "#8B8B8B", ] c_dict = dict() c_dict[6] = c_list[0] c_dict[5] = c_list[1] c_dict[4] = c_list[2] c_dict[3] = c_list[7] c_dict[2] = c_list[3] c_dict[1] = c_list[5] c_dict[0] = c_list[6] c_dict[7] = c_list[4] class DemoData: """docstring for DemoData""" def __init__(self, data_path): super().__init__() self.data_path = data_path self.verts = verts # load data self.load_data() def load_data(self): self.box_data = np.copy(np.load(f"{self.data_path}/box_data.npy")) self.pos_data = np.copy(np.load(f"{self.data_path}/pos_data.npy")) self.quat_data = np.copy(np.load(f"{self.data_path}/quat_data.npy")) self.n_frames = self.pos_data.shape[0] def freud_box(self, frame): l_box = self.box_data[frame] fbox = box.Box(Lx=l_box["Lx"], Ly=l_box["Ly"], is2D=True) return fbox def plot_frame(self, frame_idx, title="System Visualization", linked_plot=None): l_box = self.box_data[frame_idx] l_pos = self.pos_data[frame_idx] l_quat = self.quat_data[frame_idx] l_ang = 2 * np.arctan2(np.copy(l_quat[:, 3]), np.copy(l_quat[:, 0])) fbox = box.Box(Lx=l_box["Lx"], Ly=l_box["Ly"], is2D=True) side_length = max(fbox.Lx, fbox.Ly) l_min = -side_length / 2.0 l_min *= 1.1 l_max = -l_min # take local vertices and rotate, translate into # system coordinates patches = local_to_global(verts, l_pos[:, 0:2], l_ang) if linked_plot is not None: x_range = linked_plot.x_range y_range = linked_plot.y_range else: x_range = (l_min, l_max) y_range = (l_min, l_max) # plot p = figure(title=title, x_range=x_range, y_range=y_range, height=300, width=300) p.patches( xs=patches[:, :, 0].tolist(), ys=patches[:, :, 1].tolist(), fill_color=(42, 126, 187), line_color="black", line_width=1.5, ) # , # legend="hexagons") # box display p.patches( xs=[[-fbox.Lx / 2, fbox.Lx / 2, fbox.Lx / 2, -fbox.Lx / 2]], ys=[[-fbox.Ly / 2, -fbox.Ly / 2, fbox.Ly / 2, fbox.Ly / 2]], fill_color=(0, 0, 0, 0), line_color="black", line_width=2, ) # p.legend.location='bottom_center' # p.legend.orientation='horizontal' default_bokeh(p) # show(p) self.p = p return p def plot_single_neighbor( self, frame_idx, pidx, n_list, num_particles, title="Nearest Neighbor Visualization", linked_plot=None, ): l_box = self.box_data[frame_idx] l_pos = self.pos_data[frame_idx] l_quat = self.quat_data[frame_idx] l_ang = 2 * np.arctan2(np.copy(l_quat[:, 3]), np.copy(l_quat[:, 0])) fbox = box.Box(Lx=l_box["Lx"], Ly=l_box["Ly"], is2D=True) side_length = max(fbox.Lx, fbox.Ly) l_min = -side_length / 2.0 l_min *= 1.1 l_max = -l_min if linked_plot is not None: x_range = linked_plot.x_range y_range = linked_plot.y_range else: x_range = (l_min, l_max) y_range = (l_min, l_max) n_idxs = n_list[pidx] # clip padded values n_idxs = n_idxs[np.where(n_idxs < num_particles)] n_neigh = len(n_idxs) # get position, orientation for the central particle center_pos = np.zeros(shape=(1, 3), dtype=np.float32) center_ang = np.zeros(shape=(1), dtype=np.float32) center_pos[:] = l_pos[pidx] center_ang[:] = l_ang[pidx] # get the positions, orientations for the neighbor particles neigh_pos = np.zeros(shape=(n_neigh, 3), dtype=np.float32) neigh_ang = np.zeros(shape=(n_neigh), dtype=np.float32) neigh_pos[:] = l_pos[n_idxs] neigh_ang[:] = l_ang[n_idxs] # render in bokeh # create array of transformed positions # all particles patches = local_to_global(verts, l_pos[:, 0:2], l_ang) # center particle c_patches = local_to_global(verts, center_pos[:, 0:2], center_ang) # neighbor particles n_patches = local_to_global(verts, neigh_pos[:, 0:2], neigh_ang) # turn into list of colors # bokeh (as of this version) requires hex colors, so convert rgb to hex center_color = np.array([c_list[0] for _ in range(center_pos.shape[0])]) neigh_color = np.array([c_list[1] for _ in range(neigh_pos.shape[0])]) # plot p = figure(title=title, x_range=x_range, y_range=y_range, height=300, width=300) p.patches( xs=patches[:, :, 0].tolist(), ys=patches[:, :, 1].tolist(), fill_color=(0, 0, 0, 0.1), line_color="black", ) p.patches( xs=n_patches[:, :, 0].tolist(), ys=n_patches[:, :, 1].tolist(), fill_color=neigh_color.tolist(), line_color="black", legend="neighbors", ) p.patches( xs=c_patches[:, :, 0].tolist(), ys=c_patches[:, :, 1].tolist(), fill_color=center_color.tolist(), line_color="black", legend="centers", ) # box display p.patches( xs=[[-fbox.Lx / 2, fbox.Lx / 2, fbox.Lx / 2, -fbox.Lx / 2]], ys=[[-fbox.Ly / 2, -fbox.Ly / 2, fbox.Ly / 2, fbox.Ly / 2]], fill_color=(0, 0, 0, 0), line_color="black", line_width=2, ) p.legend.location = "bottom_center" p.legend.orientation = "horizontal" default_bokeh(p) self.p = p return p def plot_neighbors( self, frame_idx, n_list, num_particles, n_neigh, title="Nearest Neighbor Visualization", linked_plot=None, ): l_box = self.box_data[frame_idx] l_pos = self.pos_data[frame_idx] l_quat = self.quat_data[frame_idx] l_ang = 2 * np.arctan2(np.copy(l_quat[:, 3]), np.copy(l_quat[:, 0])) fbox = box.Box(Lx=l_box["Lx"], Ly=l_box["Ly"], is2D=True) side_length = max(fbox.Lx, fbox.Ly) l_min = -side_length / 2.0 l_min *= 1.1 l_max = -l_min if linked_plot is not None: x_range = linked_plot.x_range y_range = linked_plot.y_range else: x_range = (l_min, l_max) y_range = (l_min, l_max) # now for array manipulation magic # create an integer array of the same shape as the neighbor list array int_arr = np.ones(shape=n_list.shape, dtype=np.int32) # "search" for non-indexed particles (missing neighbors) # while it would be most accurate to use the UINTMAX value # provided by nn.getUINTMAX(), but this works just as well int_arr[n_list > (num_particles - 1)] = 0 # sum along particle index axis to # determine the number of neighbors per particle n_neighbors = np.sum(int_arr, axis=1) # find the complement (if desired) to # find number of missing neighbors per particle # n_deficits = n_neigh - n_neighbors p = figure(title=title, x_range=x_range, y_range=y_range, height=300, width=300) for k in np.unique(n_neighbors): # find particles with k neighbors c_idxs = np.copy(np.where(n_neighbors == k)[0]) center_pos = np.zeros(shape=(len(c_idxs), 3), dtype=np.float32) center_ang = np.zeros(shape=(len(c_idxs)), dtype=np.float32) center_pos = l_pos[c_idxs] center_ang = l_ang[c_idxs] c_patches = local_to_global(verts, center_pos[:, 0:2], center_ang) center_color = np.array([c_dict[k] for _ in range(center_pos.shape[0])]) p.patches( xs=c_patches[:, :, 0].tolist(), ys=c_patches[:, :, 1].tolist(), fill_color=center_color.tolist(), line_color="black", legend=f"k={k}", ) p.patches( xs=[[-fbox.Lx / 2, fbox.Lx / 2, fbox.Lx / 2, -fbox.Lx / 2]], ys=[[-fbox.Ly / 2, -fbox.Ly / 2, fbox.Ly / 2, fbox.Ly / 2]], fill_color=(0, 0, 0, 0), line_color="black", line_width=2, ) p.legend.location = "bottom_center" p.legend.orientation = "horizontal" default_bokeh(p) self.p = p return p def plot_hexatic( self, frame_idx, psi_k, avg_psi_k, title="Hexatic Visualization", linked_plot=None, ):
def plot_orientation( self, frame_idx, title="Orientation Visualization", linked_plot=None ): l_box = self.box_data[frame_idx] l_pos = self.pos_data[frame_idx] l_quat = self.quat_data[frame_idx] l_ang = 2 * np.arctan2(np.copy(l_quat[:, 3]), np.copy(l_quat[:, 0])) fbox = box.Box(Lx=l_box["Lx"], Ly=l_box["Ly"], is2D=True) side_length = max(fbox.Lx, fbox.Ly) l_min = -side_length / 2.0 l_min *= 1.1 l_max = -l_min if linked_plot is not None: x_range = linked_plot.x_range y_range = linked_plot.y_range else: x_range = (l_min, l_max) y_range = (l_min, l_max) # create array of transformed positions patches = local_to_global(verts, l_pos[:, 0:2], l_ang) # turn into an rgb array of tuples theta = l_ang * 6.0 color = [tuple(cubeellipse(x, lam=0.5, h=2.0)) for x in theta] # bokeh (as of this version) requires hex colors, so convert rgb to hex hex_color = [ f"#{clamp(r):02x}{clamp(g):02x}{clamp(b):02x}" for (r, g, b) in color ] # plot p = figure(title=title, x_range=x_range, y_range=y_range, height=300, width=300) p.patches( xs=patches[:, :, 0].tolist(), ys=patches[:, :, 1].tolist(), fill_color=hex_color, line_color="black", ) default_bokeh(p) self.p = p return p def plot_ld( self, frame_idx, ld, title="Local Density Visualization", linked_plot=None ): l_box = self.box_data[frame_idx] l_pos = self.pos_data[frame_idx] l_quat = self.quat_data[frame_idx] l_ang = 2 * np.arctan2(np.copy(l_quat[:, 3]), np.copy(l_quat[:, 0])) fbox = box.Box(Lx=l_box["Lx"], Ly=l_box["Ly"], is2D=True) side_length = max(fbox.Lx, fbox.Ly) l_min = -side_length / 2.0 l_min *= 1.1 l_max = -l_min if linked_plot is not None: x_range = linked_plot.x_range y_range = linked_plot.y_range else: x_range = (l_min, l_max) y_range = (l_min, l_max) # create array of transformed positions patches = local_to_global(verts, l_pos[:, 0:2], l_ang) # create an array of angles relative to the average # a = np.angle(psi_k) - np.angle(avg_psi_k) a = ld # turn into an rgb array of tuples # handle the matplotlib colormap myNorm = mplColors.Normalize(vmin=0.5, vmax=0.8) color = [tuple(cm.RdYlBu(myNorm(x))[:3]) for x in a] # bokeh (as of this version) requires hex colors, so convert rgb to hex hex_color = [ "#{:02x}{:02x}{:02x}".format( clamp(int(255 * r)), clamp(int(255 * g)), clamp(int(255 * b)) ) for (r, g, b) in color ] # plot p = figure(title=title, x_range=x_range, y_range=y_range, height=300, width=300) p.patches( xs=patches[:, :, 0].tolist(), ys=patches[:, :, 1].tolist(), fill_color=hex_color, line_color="black", ) default_bokeh(p) self.p = p return p def default_bokeh(p): """ wrapper which takes the default bokeh outputs and changes them to more sensible values """ p.title.text_font_size = "18pt" p.title.align = "center" p.xaxis.axis_label_text_font_size = "14pt" p.yaxis.axis_label_text_font_size = "14pt" p.xaxis.major_tick_in = 10 p.xaxis.major_tick_out = 0 p.xaxis.minor_tick_in = 5 p.xaxis.minor_tick_out = 0 p.yaxis.major_tick_in = 10 p.yaxis.major_tick_out = 0 p.yaxis.minor_tick_in = 5 p.yaxis.minor_tick_out = 0 p.xaxis.major_label_text_font_size = "12pt" p.yaxis.major_label_text_font_size = "12pt" def cubeellipse(theta, lam=0.6, gamma=1.0, s=4.0, r=1.0, h=1.2): """Create an RGB colormap from an input angle theta. Takes lam (a list of intensity values, from 0 to 1), gamma (a nonlinear weighting power), s (starting angle), r (number of revolutions around the circle), and h (a hue factor).""" import numpy lam = lam ** gamma a = h * lam * (1 - lam) * 0.5 v = numpy.array( [[-0.14861, 1.78277], [-0.29227, -0.90649], [1.97294, 0.0]], dtype=numpy.float32 ) ctarray = numpy.array( [numpy.cos(theta * r + s), numpy.sin(theta * r + s)], dtype=numpy.float32 ) # convert to 255 rgb ctarray = (lam + a * v.dot(ctarray)).T ctarray *= 255 ctarray = ctarray.astype(dtype=np.int32) return ctarray def local_to_global(verts, positions, orientations): """ Take a list of vertices, positions, and orientations and create a list of vertices in the "global coordinate system" for plotting in bokeh """ num_particles = len(positions) num_verts = len(verts) # create list of vertices in the "local reference frame" i.e. # centered at (0,0) l_verts = np.zeros(shape=(num_particles, num_verts, 2), dtype=np.float32) l_verts[:] = verts # create array of rotation matrices rot_mat = np.zeros(shape=(num_particles, 2, 2), dtype=np.float32) for i, theta in enumerate(orientations): rot_mat[i] = [[np.cos(theta), -np.sin(theta)], [np.sin(theta), np.cos(theta)]] # rotate; uses einsum for speed; please see numpy documentation # for more information r_verts = np.einsum("lij,lkj->lki", rot_mat, l_verts) # now translate to global coordinates # need to create a position array with same shape as vertex array l_pos = np.zeros(shape=(num_particles, num_verts, 2), dtype=np.float32) for i in range(num_particles): for j in range(len(verts)): l_pos[i, j] = positions[i] # translate output_array = np.add(r_verts, l_pos) return output_array def clamp(x): """ limit values between 0 and 255 http://stackoverflow.com/questions/3380726/converting-a-rgb-color-tuple-to-a-six-digit-code-in-python """ return max(0, min(x, 255)) def demo1(l_box, l_pos, l_ang, verts, title="System Visualization"): # create box fbox = box.Box(Lx=l_box["Lx"], Ly=l_box["Ly"], is2D=True) side_length = max(fbox.Lx, fbox.Ly) l_min = -side_length / 2.0 l_min *= 1.1 l_max = -l_min # take local vertices and rotate, translate into # system coordinates patches = local_to_global(verts, l_pos[:, 0:2], l_ang) # plot p = figure( title=title, x_range=(l_min, l_max), y_range=(l_min, l_max), height=300, width=300, ) p.patches( xs=patches[:, :, 0].tolist(), ys=patches[:, :, 1].tolist(), fill_color=(42, 126, 187), line_color="black", line_width=1.5, ) # , # legend="hexagons") # box display p.patches( xs=[[-fbox.Lx / 2, fbox.Lx / 2, fbox.Lx / 2, -fbox.Lx / 2]], ys=[[-fbox.Ly / 2, -fbox.Ly / 2, fbox.Ly / 2, fbox.Ly / 2]], fill_color=(0, 0, 0, 0), line_color="black", line_width=2, ) # p.legend.location='bottom_center' # p.legend.orientation='horizontal' default_bokeh(p) # show(p) return p
l_box = self.box_data[frame_idx] l_pos = self.pos_data[frame_idx] l_quat = self.quat_data[frame_idx] l_ang = 2 * np.arctan2(np.copy(l_quat[:, 3]), np.copy(l_quat[:, 0])) fbox = box.Box(Lx=l_box["Lx"], Ly=l_box["Ly"], is2D=True) side_length = max(fbox.Lx, fbox.Ly) l_min = -side_length / 2.0 l_min *= 1.1 l_max = -l_min if linked_plot is not None: x_range = linked_plot.x_range y_range = linked_plot.y_range else: x_range = (l_min, l_max) y_range = (l_min, l_max) # create array of transformed positions patches = local_to_global(verts, l_pos[:, 0:2], l_ang) # create an array of angles relative to the average a = np.angle(psi_k) - np.angle(avg_psi_k) # turn into an rgb array of tuples color = [tuple(cubeellipse(x)) for x in a] # bokeh (as of this version) requires hex colors, so convert rgb to hex hex_color = [ f"#{clamp(r):02x}{clamp(g):02x}{clamp(b):02x}" for (r, g, b) in color ] # plot p = figure(title=title, x_range=x_range, y_range=y_range, height=300, width=300) p.patches( xs=patches[:, :, 0].tolist(), ys=patches[:, :, 1].tolist(), fill_color=hex_color, line_color="black", ) default_bokeh(p) self.p = p return p
code_generation_util.py
# Copyright 2019 The Forte 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. import os from collections import OrderedDict from typing import Optional, Any, List class Config: indent: int = 4 line_break: str = os.linesep def indent(level: int) -> str: return ' ' * Config.indent * level def indent_line(line: str, level: int) -> str: return f"{indent(level)}{line}" if line else '' def indent_code(code_lines: List[str], level: int = 0) -> str: lines = [] for code in code_lines: lines.extend(code.split(Config.line_break) if code is not None else []) return Config.line_break.join([indent_line(line, level) for line in lines]) def empty_lines(num: int): return ''.join([Config.line_break] * num) class Item: def __init__(self, name: str, description: Optional[str]): self.name: str = name self.description: Optional[str] = description def to_description(self, level: int) -> Optional[str]: if self.description is not None: return indent_code([self.description], level) return None def to_code(self, level: int) -> str: raise NotImplementedError class Property(Item): def __init__(self, name: str, type_str: str, description: Optional[str] = None, default: Any = None): super().__init__(name, description) self.type_str = type_str self.default = default def to_getter_setter_code(self, level) -> str: """ Returns: getter and setter functions generated by a property. """ name = self.name lines = [("@property", 0), (f"def {name}(self):", 0), (f"return self._{name}", 1), (empty_lines(0), 0), (f"def set_{name}(self, {name}: {self.to_code(0)}):", 0), (f"self.set_fields(_{name}={self.to_field_value()})", 1), (empty_lines(0), 0)] return indent_code([indent_line(*line) for line in lines], level) def to_init_code(self, level: int) -> str: return indent_line(f"self._{self.name}: {self.to_code(0)} = " f"{repr(self.default)}", level) def to_description(self, level: int) -> Optional[str]: if self.description is not None and self.description.strip() != '': type_str = f'{self.to_code(0)}' type_str = f' ({type_str})' if type_str.strip() != '' else type_str return indent_line(f"{self.name}{type_str}: " f"{self.description}", level) return None def to_field_value(self): raise NotImplementedError class ClassAttributeItem(Property): def to_code(self, level: int = 0) -> str: return self.type_str def to_init_code(self, level: int) -> str: type_code = f'{self.to_code(0)}' type_ = f': {type_code}' if type_code.strip() != '' else '' return indent_line(f"{self.name}{type_} = {self.default}", level) def to_field_value(self): pass class BasicItem(Property): TYPES = {'int', 'float', 'str', 'bool'} def to_code(self, level: int = 0) -> str: return f"typing.Optional[{self.type_str}]" def to_field_value(self): if self.type_str in self.TYPES: return self.name return f"{self.name}.tid" class CompositeItem(Property): TYPES = {'List'} def __init__(self, name: str, type_str: str, item_type: str, description: Optional[str] = None, default: Any = None): super().__init__(name, type_str, description, default) self.item_type = item_type def to_code(self, level: int = 0) -> str: # TODO: Assumes only one type of elements are allowed in the list, # allow multiple types # items = list(OrderedDict([(item, None) # for item in self.items]).keys()) # item_type_str = f"{', '.join(self.item_type)}" # if len(self.items) > 1: # item_type_str = f"typing.Union[{item_type_str}]" return f"typing.Optional[{self.type_str}[{self.item_type}]]" def to_field_value(self): item_value_str = BasicItem('item', self.item_type).to_field_value() return f"[{item_value_str} for item in {self.name}]" class DefinitionItem(Item): def __init__(self, name: str, class_type: str, init_args: Optional[str] = None, properties: Optional[List[Property]] = None, class_attributes: Optional[List[Property]] = None, description: Optional[str] = None): super().__init__(name, description) self.class_type = class_type self.properties: List[Property] = \ [] if properties is None else properties self.class_attributes = [] if class_attributes is None \ else class_attributes self.description = description if description else None self.init_args = init_args if init_args is not None else '' self.init_args = self.init_args.replace('=', ' = ') def to_init_code(self, level: int) -> str: return indent_line(f"def __init__(self, {self.init_args}):", level) def to_code(self, level: int) -> str: super_args = ', '.join([item.split(':')[0].strip() for item in self.init_args.split(',')]) raw_desc = self.to_description(1) desc: str = '' if raw_desc is None else raw_desc lines = [ empty_lines(1), f"__all__.extend('{self.name}')", empty_lines(1), f"class {self.name}({self.class_type}):", ] lines += [desc] if desc.strip() else [] lines += [item.to_init_code(1) for item in self.class_attributes] lines += [empty_lines(0)] lines += [self.to_init_code(1), indent_line(f"super().__init__({super_args})", 2)] lines += [item.to_init_code(2) for item in self.properties] lines += [empty_lines(0)] lines += [item.to_getter_setter_code(1) for item in self.properties] return indent_code(lines, level) @staticmethod def to_item_descs(items, title): item_descs = [item.to_description(0) for item in items] item_descs = [item for item in item_descs if item is not None] if len(item_descs) > 0: item_descs = [indent_line(title, 1)] + \ [indent_line(desc, 2) for desc in item_descs] return item_descs def to_description(self, level: int) -> Optional[str]: class_desc = [] if self.description is None else [self.description] item_descs = self.to_item_descs(self.properties, 'Args:') att_descs = self.to_item_descs(self.class_attributes, 'Attr:') descs = class_desc + item_descs + att_descs if len(descs) == 0: return "" quotes = indent_line('"""', 0) return indent_code([quotes] + descs + [quotes], level) class
: def __init__(self, entry_item: DefinitionItem, entry_file: str, ignore_errors: Optional[List[str]], description: Optional[str], imports: Optional[List[str]]): self.description = description self.ignore_errors = [] if not ignore_errors else ignore_errors self.imports = [] if not imports else list(set(imports)) self.entry_item = entry_item self.entry_file_exists = os.path.exists(entry_file) def to_code(self, level: int) -> str: lines: List[str] = [] if not self.entry_file_exists: lines = [self.to_description(0), self.to_import_code(0), empty_lines(1), '__all__ = []'] lines.append(self.entry_item.to_code(0)) return indent_code(lines, level) def to_description(self, level): quotes = '"""' lines = self.ignore_errors + [quotes, self.description, quotes] return indent_code(lines, level) def to_import_code(self, level): imports_set: OrderedDict[str] = {} for import_ in sorted(self.imports): imports_set[f"import {import_}"] = None return indent_code(list(imports_set), level)
FileItem
iterators2.rs
// iterators2.rs // In this module, you'll learn some of unique advantages that iterators can offer // Step 1. Complete the `capitalize_first` function to pass the first two cases // Step 2. Apply the `capitalize_first` function to a vector of strings, ensuring that it returns a vector of strings as well // Step 3. Apply the `capitalize_first` function again to a list, but try and ensure it returns a single string // As always, there are hints if you execute `rustlings hint iterators2`! fn capitalize_first(input: &str) -> String { let mut c = input.chars(); match c.next() { None => String::new(), Some(first) => first.to_uppercase().collect::<String>() + c.as_str(), }
#[cfg(test)] mod tests { use super::*; // Step 1. // Tests that verify your `capitalize_first` function implementation #[test] fn test_success() { assert_eq!(capitalize_first("hello"), "Hello"); } #[test] fn test_empty() { assert_eq!(capitalize_first(""), ""); } // Step 2. #[test] fn test_iterate_string_vec() { let words = vec!["hello", "world"]; let capitalized_words: Vec<String> = words.into_iter().map(|x| capitalize_first(x)).collect(); assert_eq!(capitalized_words, ["Hello", "World"]); } #[test] fn test_iterate_into_string() { let words = vec!["hello", " ", "world"]; let capitalized_words = words .into_iter() .fold("".to_owned(), |acc, s| acc + &capitalize_first(s)); assert_eq!(capitalized_words, "Hello World"); } }
}
index.js
import React from 'react'; import { View, Text, TouchableOpacity } from 'react-native'; import variables from '../../common/styles/variables'; import Tree from '../../common/utils/Tree'; import { Icon } from '../../components/Icon'; import treeViewStyles from './styles'; export class TreeView extends React.Component { constructor(props) { super(props); this.handlePress = (item) => { this.props.onPress && this.props.onPress(item); const { tree } = this.state; const fieldKeys = this.getFieldKeys(); let index = null; tree.some((treeItem, treeIndex) => { if (treeItem[fieldKeys.idKey] === item[fieldKeys.idKey]) { index = treeIndex; return true; } }); const tmpTree = tree.concat(); tmpTree.splice(index, 1, { ...item, [fieldKeys.activeKey]: !item[fieldKeys.activeKey] }); this.setState({ tree: tmpTree }); }; this.state = { ...this.init(props) }; } init(props) { const { dataStructureType, data } = props; const fieldKeys = this.getFieldKeys(props); const tree = new Tree({ type: dataStructureType, ...fieldKeys, data }).getData(); return { tree }; } getFieldKeys(props) { props = props || this.props; const fieldKeys = props.fieldKeys || {}; return { idKey: fieldKeys.idKey || 'id', pIdKey: fieldKeys.pIdKey || 'pId', labelKey: fieldKeys.labelKey || 'label', childrenKey: fieldKeys.childrenKey || 'children', activeKey: fieldKeys.activeKey || 'active', checkedKey: fieldKeys.checkedKey || 'checked', disabledKey: fieldKeys.disabledKey || 'disabled' }; } renderItem(data, level) { const { tree } = this.state; const { activeIcon, inactiveIcon } = this.props; const fieldKeys = this.getFieldKeys(); if (!data) { data = tree.filter((item) => { return item[fieldKeys.pIdKey] == null; }); } level = level || 1; return (React.createElement(View, null, data.map((item, index) => { const children = tree.filter((treeItem) => { return treeItem[fieldKeys.pIdKey] === item[fieldKeys.idKey]; }); return (React.createElement(View, { key: index, style: [ { marginLeft: 20 * (level - 1) } ] }, React.createElement(TouchableOpacity, { style: [treeViewStyles.item], onPress: this.handlePress.bind(this, item) }, children.length && React.createElement(View, { style: treeViewStyles.itemIcon }, item[fieldKeys.activeKey] ? activeIcon : inactiveIcon), React.createElement(Text, { style: [treeViewStyles.itemText] }, item[fieldKeys.labelKey])), children.length && !!item[fieldKeys.activeKey] ? this.renderItem(children, level + 1) : null)); }))); }
} } TreeView.defaultProps = { style: {}, activeIcon: React.createElement(Icon, { source: require(`../../common/images/icons/angle-down.png`), tintColor: variables.mtdGrayBase }), inactiveIcon: React.createElement(Icon, { source: require(`../../common/images/icons/angle-right.png`), tintColor: variables.mtdGrayBase }), data: [], dataStructureType: 'nested', fieldKeys: {} }; //# sourceMappingURL=index.js.map
render() { return (React.createElement(View, { style: [treeViewStyles.container, this.props.style] }, this.renderItem()));
toypics.py
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor import re class ToypicsIE(InfoExtractor): IE_DESC = 'Toypics video' _VALID_URL = r'https?://videos\.toypics\.net/view/(?P<id>[0-9]+)' _TEST = { 'url': 'http://videos.toypics.net/view/514/chancebulged,-2-1/', 'md5': '16e806ad6d6f58079d210fe30985e08b', 'info_dict': { 'id': '514', 'ext': 'mp4', 'title': "Chance-Bulge'd, 2", 'age_limit': 18, 'uploader': 'kidsune', } } def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) formats = self._parse_html5_media_entries( url, webpage, video_id)[0]['formats'] title = self._html_search_regex([ r'<h1[^>]+class=["\']view-video-title[^>]+>([^<]+)</h', r'<title>([^<]+) - Toypics</title>', ], webpage, 'title') uploader = self._html_search_regex( r'More videos from <strong>([^<]+)</strong>', webpage, 'uploader', fatal=False) return { 'id': video_id, 'formats': formats, 'title': title, 'uploader': uploader, 'age_limit': 18, } class ToypicsUserIE(InfoExtractor):
IE_DESC = 'Toypics user profile' _VALID_URL = r'https?://videos\.toypics\.net/(?!view)(?P<id>[^/?#&]+)' _TEST = { 'url': 'http://videos.toypics.net/Mikey', 'info_dict': { 'id': 'Mikey', }, 'playlist_mincount': 19, } def _real_extract(self, url): username = self._match_id(url) profile_page = self._download_webpage( url, username, note='Retrieving profile page') video_count = int(self._search_regex( r'public/">Public Videos \(([0-9]+)\)</a></li>', profile_page, 'video count')) PAGE_SIZE = 8 urls = [] page_count = (video_count + PAGE_SIZE + 1) // PAGE_SIZE for n in range(1, page_count + 1): lpage_url = url + '/public/%d' % n lpage = self._download_webpage( lpage_url, username, note='Downloading page %d/%d' % (n, page_count)) urls.extend( re.findall( r'<div[^>]+class=["\']preview[^>]+>\s*<a[^>]+href="(https?://videos\.toypics\.net/view/[^"]+)"', lpage)) return { '_type': 'playlist', 'id': username, 'entries': [{ '_type': 'url', 'url': eurl, 'ie_key': 'Toypics', } for eurl in urls] }
data_types.py
from rply import ParserGenerator from poketype.ast import Number, Boolean, NegNumber class
(): def __init__(self, pg: ParserGenerator) -> None: @pg.production('expression : NUMBER') def expression_number(p): return Number(int(p[0].getstr())) @pg.production('expression : BOOLEAN') def expression_number(p): b_val = p[0].getstr() if b_val == "true": return Boolean(True) else: return Boolean(False) @pg.production('expression : NEG NUMBER') def expression_number_neg(p): b_val = p[1].getstr() return NegNumber(int(p[1].getstr()) * -1)
DataTypes
has-one.repository-factory.js
"use strict"; // Copyright IBM Corp. 2018,2020. All Rights Reserved. // Node module: @loopback/repository
exports.createHasOneRepositoryFactory = void 0; const tslib_1 = require("tslib"); const debug_1 = (0, tslib_1.__importDefault)(require("debug")); const has_one_helpers_1 = require("./has-one.helpers"); const has_one_inclusion_resolver_1 = require("./has-one.inclusion-resolver"); const has_one_repository_1 = require("./has-one.repository"); const debug = (0, debug_1.default)('loopback:repository:relations:has-one:repository-factory'); /** * Enforces a constraint on a repository based on a relationship contract * between models. For example, if a Customer model is related to an Address model * via a HasOne relation, then, the relational repository returned by the * factory function would be constrained by a Customer model instance's id(s). * * @param relationMetadata - The relation metadata used to describe the * relationship and determine how to apply the constraint. * @param targetRepositoryGetter - The repository which represents the target model of a * relation attached to a datasource. * @returns The factory function which accepts a foreign key value to constrain * the given target repository */ function createHasOneRepositoryFactory(relationMetadata, targetRepositoryGetter) { const meta = (0, has_one_helpers_1.resolveHasOneMetadata)(relationMetadata); debug('Resolved HasOne relation metadata: %o', meta); const result = function (fkValue) { // eslint-disable-next-line @typescript-eslint/no-explicit-any const constraint = { [meta.keyTo]: fkValue }; return new has_one_repository_1.DefaultHasOneRepository(targetRepositoryGetter, constraint); }; result.inclusionResolver = (0, has_one_inclusion_resolver_1.createHasOneInclusionResolver)(meta, targetRepositoryGetter); return result; } exports.createHasOneRepositoryFactory = createHasOneRepositoryFactory; //# sourceMappingURL=has-one.repository-factory.js.map
// This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT Object.defineProperty(exports, "__esModule", { value: true });
asn1.rs
#![deny(missing_docs)] //! Defines the format of certificiates //! //! This module is used by [`x509`] and other certificate building functions //! to describe time, strings, and objects. //! //! Abstract Syntax Notation One is an interface description language. //! The specification comes from [X.208] by OSI, and rewritten in X.680. //! ASN.1 describes properties of an object with a type set. Those types //! can be atomic, structured, choice, and other (CHOICE and ANY). These //! types are expressed as a number and the assignment operator ::= gives //! the type a name. //! //! The implementation here provides a subset of the ASN.1 types that OpenSSL //! uses, especially in the properties of a certificate used in HTTPS. //! //! [X.208]: https://www.itu.int/rec/T-REC-X.208-198811-W/en //! [`x509`]: ../x509/struct.X509Builder.html //! //! ## Examples //! //! ``` //! use openssl::asn1::Asn1Time; //! let tomorrow = Asn1Time::days_from_now(1); //! ``` use cfg_if::cfg_if; use foreign_types::{ForeignType, ForeignTypeRef}; use libc::{c_char, c_int, c_long, time_t}; #[cfg(ossl102)] use std::cmp::Ordering; use std::ffi::CString; use std::fmt; use std::ptr; use std::slice; use std::str; use crate::bio::MemBio; use crate::bn::{BigNum, BigNumRef}; use crate::error::ErrorStack; use crate::nid::Nid; use crate::string::OpensslString; use crate::{cvt, cvt_p}; foreign_type_and_impl_send_sync! { type CType = ffi::ASN1_GENERALIZEDTIME; fn drop = ffi::ASN1_GENERALIZEDTIME_free; /// Non-UTC representation of time /// /// If a time can be represented by UTCTime, UTCTime is used /// otherwise, ASN1_GENERALIZEDTIME is used. This would be, for /// example outside the year range of 1950-2049. /// /// [ASN1_GENERALIZEDTIME_set] documentation from OpenSSL provides /// further details of implementation. Note: these docs are from the master /// branch as documentation on the 1.1.0 branch did not include this page. /// /// [ASN1_GENERALIZEDTIME_set]: https://www.openssl.org/docs/manmaster/man3/ASN1_GENERALIZEDTIME_set.html pub struct Asn1GeneralizedTime; /// Reference to a [`Asn1GeneralizedTime`] /// /// [`Asn1GeneralizedTime`]: struct.Asn1GeneralizedTime.html pub struct Asn1GeneralizedTimeRef; } impl fmt::Display for Asn1GeneralizedTimeRef { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { unsafe { let mem_bio = match MemBio::new() { Err(_) => return f.write_str("error"), Ok(m) => m, }; let print_result = cvt(ffi::ASN1_GENERALIZEDTIME_print( mem_bio.as_ptr(), self.as_ptr(), )); match print_result { Err(_) => f.write_str("error"), Ok(_) => f.write_str(str::from_utf8_unchecked(mem_bio.get_buf())), } } } } /// The type of an ASN.1 value. #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub struct Asn1Type(c_int); #[allow(missing_docs)] // no need to document the constants impl Asn1Type { pub const EOC: Asn1Type = Asn1Type(ffi::V_ASN1_EOC); pub const BOOLEAN: Asn1Type = Asn1Type(ffi::V_ASN1_BOOLEAN); pub const INTEGER: Asn1Type = Asn1Type(ffi::V_ASN1_INTEGER); pub const BIT_STRING: Asn1Type = Asn1Type(ffi::V_ASN1_BIT_STRING); pub const OCTET_STRING: Asn1Type = Asn1Type(ffi::V_ASN1_OCTET_STRING); pub const NULL: Asn1Type = Asn1Type(ffi::V_ASN1_NULL); pub const OBJECT: Asn1Type = Asn1Type(ffi::V_ASN1_OBJECT); pub const OBJECT_DESCRIPTOR: Asn1Type = Asn1Type(ffi::V_ASN1_OBJECT_DESCRIPTOR); pub const EXTERNAL: Asn1Type = Asn1Type(ffi::V_ASN1_EXTERNAL); pub const REAL: Asn1Type = Asn1Type(ffi::V_ASN1_REAL); pub const ENUMERATED: Asn1Type = Asn1Type(ffi::V_ASN1_ENUMERATED); pub const UTF8STRING: Asn1Type = Asn1Type(ffi::V_ASN1_UTF8STRING); pub const SEQUENCE: Asn1Type = Asn1Type(ffi::V_ASN1_SEQUENCE); pub const SET: Asn1Type = Asn1Type(ffi::V_ASN1_SET); pub const NUMERICSTRING: Asn1Type = Asn1Type(ffi::V_ASN1_NUMERICSTRING); pub const PRINTABLESTRING: Asn1Type = Asn1Type(ffi::V_ASN1_PRINTABLESTRING); pub const T61STRING: Asn1Type = Asn1Type(ffi::V_ASN1_T61STRING); pub const TELETEXSTRING: Asn1Type = Asn1Type(ffi::V_ASN1_TELETEXSTRING); pub const VIDEOTEXSTRING: Asn1Type = Asn1Type(ffi::V_ASN1_VIDEOTEXSTRING); pub const IA5STRING: Asn1Type = Asn1Type(ffi::V_ASN1_IA5STRING); pub const UTCTIME: Asn1Type = Asn1Type(ffi::V_ASN1_UTCTIME); pub const GENERALIZEDTIME: Asn1Type = Asn1Type(ffi::V_ASN1_GENERALIZEDTIME); pub const GRAPHICSTRING: Asn1Type = Asn1Type(ffi::V_ASN1_GRAPHICSTRING); pub const ISO64STRING: Asn1Type = Asn1Type(ffi::V_ASN1_ISO64STRING); pub const VISIBLESTRING: Asn1Type = Asn1Type(ffi::V_ASN1_VISIBLESTRING); pub const GENERALSTRING: Asn1Type = Asn1Type(ffi::V_ASN1_GENERALSTRING); pub const UNIVERSALSTRING: Asn1Type = Asn1Type(ffi::V_ASN1_UNIVERSALSTRING); pub const BMPSTRING: Asn1Type = Asn1Type(ffi::V_ASN1_BMPSTRING); /// Constructs an `Asn1Type` from a raw OpenSSL value. pub fn from_raw(value: c_int) -> Self { Asn1Type(value) } /// Returns the raw OpenSSL value represented by this type. pub fn as_raw(&self) -> c_int { self.0 } } /// Difference between two ASN1 times. /// /// This `struct` is created by the [`diff`] method on [`Asn1TimeRef`]. See its /// documentation for more. /// /// [`diff`]: struct.Asn1TimeRef.html#method.diff /// [`Asn1TimeRef`]: struct.Asn1TimeRef.html #[derive(Debug, Clone, PartialEq, Eq, Hash)] #[cfg(ossl102)] pub struct TimeDiff { /// Difference in days pub days: c_int, /// Difference in seconds. /// /// This is always less than the number of seconds in a day. pub secs: c_int, } foreign_type_and_impl_send_sync! { type CType = ffi::ASN1_TIME; fn drop = ffi::ASN1_TIME_free; /// Time storage and comparison /// /// Asn1Time should be used to store and share time information /// using certificates. If Asn1Time is set using a string, it must /// be in either YYMMDDHHMMSSZ, YYYYMMDDHHMMSSZ, or another ASN.1 format. /// /// [ASN_TIME_set] documentation at OpenSSL explains the ASN.1 implementation /// used by OpenSSL. /// /// [ASN_TIME_set]: https://www.openssl.org/docs/man1.1.0/crypto/ASN1_TIME_set.html pub struct Asn1Time; /// Reference to an [`Asn1Time`] /// /// [`Asn1Time`]: struct.Asn1Time.html pub struct Asn1TimeRef; } impl Asn1TimeRef { /// Find difference between two times /// /// This corresponds to [`ASN1_TIME_diff`]. /// /// [`ASN1_TIME_diff`]: https://www.openssl.org/docs/man1.1.0/crypto/ASN1_TIME_diff.html #[cfg(ossl102)] pub fn diff(&self, compare: &Self) -> Result<TimeDiff, ErrorStack> { let mut days = 0; let mut secs = 0; let other = compare.as_ptr(); let err = unsafe { ffi::ASN1_TIME_diff(&mut days, &mut secs, self.as_ptr(), other) }; match err { 0 => Err(ErrorStack::get()), _ => Ok(TimeDiff { days, secs }), } } /// Compare two times /// /// This corresponds to [`ASN1_TIME_compare`] but is implemented using [`diff`] so that it is /// also supported on older versions of OpenSSL. /// /// [`ASN1_TIME_compare`]: https://www.openssl.org/docs/man1.1.1/man3/ASN1_TIME_compare.html /// [`diff`]: struct.Asn1TimeRef.html#method.diff #[cfg(ossl102)] pub fn compare(&self, other: &Self) -> Result<Ordering, ErrorStack> { let d = self.diff(other)?; if d.days > 0 || d.secs > 0 { return Ok(Ordering::Less); } if d.days < 0 || d.secs < 0 { return Ok(Ordering::Greater); } Ok(Ordering::Equal) } } #[cfg(ossl102)] impl PartialEq for Asn1TimeRef { fn eq(&self, other: &Asn1TimeRef) -> bool { self.diff(other) .map(|t| t.days == 0 && t.secs == 0) .unwrap_or(false) } } #[cfg(ossl102)] impl PartialEq<Asn1Time> for Asn1TimeRef { fn eq(&self, other: &Asn1Time) -> bool { self.diff(other) .map(|t| t.days == 0 && t.secs == 0) .unwrap_or(false) } } #[cfg(ossl102)] impl<'a> PartialEq<Asn1Time> for &'a Asn1TimeRef { fn eq(&self, other: &Asn1Time) -> bool { self.diff(other) .map(|t| t.days == 0 && t.secs == 0) .unwrap_or(false) } } #[cfg(ossl102)] impl PartialOrd for Asn1TimeRef { fn partial_cmp(&self, other: &Asn1TimeRef) -> Option<Ordering> { self.compare(other).ok() } } #[cfg(ossl102)] impl PartialOrd<Asn1Time> for Asn1TimeRef { fn partial_cmp(&self, other: &Asn1Time) -> Option<Ordering> { self.compare(other).ok() } } #[cfg(ossl102)] impl<'a> PartialOrd<Asn1Time> for &'a Asn1TimeRef { fn partial_cmp(&self, other: &Asn1Time) -> Option<Ordering> { self.compare(other).ok() } } impl fmt::Display for Asn1TimeRef { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { unsafe { let mem_bio = match MemBio::new() { Err(_) => return f.write_str("error"), Ok(m) => m, }; let print_result = cvt(ffi::ASN1_TIME_print(mem_bio.as_ptr(), self.as_ptr())); match print_result { Err(_) => f.write_str("error"), Ok(_) => f.write_str(str::from_utf8_unchecked(mem_bio.get_buf())), } } } } impl fmt::Debug for Asn1TimeRef { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(&self.to_string()) } } impl Asn1Time { fn new() -> Result<Asn1Time, ErrorStack> { ffi::init(); unsafe { let handle = cvt_p(ffi::ASN1_TIME_new())?; Ok(Asn1Time::from_ptr(handle)) } } fn from_period(period: c_long) -> Result<Asn1Time, ErrorStack> { ffi::init(); unsafe { let handle = cvt_p(ffi::X509_gmtime_adj(ptr::null_mut(), period))?; Ok(Asn1Time::from_ptr(handle)) } } /// Creates a new time on specified interval in days from now pub fn days_from_now(days: u32) -> Result<Asn1Time, ErrorStack> { Asn1Time::from_period(days as c_long * 60 * 60 * 24) } /// Creates a new time from the specified `time_t` value pub fn from_unix(time: time_t) -> Result<Asn1Time, ErrorStack> { ffi::init(); unsafe { let handle = cvt_p(ffi::ASN1_TIME_set(ptr::null_mut(), time))?; Ok(Asn1Time::from_ptr(handle)) } } /// Creates a new time corresponding to the specified ASN1 time string. /// /// This corresponds to [`ASN1_TIME_set_string`]. /// /// [`ASN1_TIME_set_string`]: https://www.openssl.org/docs/manmaster/man3/ASN1_TIME_set_string.html #[allow(clippy::should_implement_trait)] pub fn from_str(s: &str) -> Result<Asn1Time, ErrorStack> { unsafe { let s = CString::new(s).unwrap(); let time = Asn1Time::new()?; cvt(ffi::ASN1_TIME_set_string(time.as_ptr(), s.as_ptr()))?; Ok(time) } } /// Creates a new time corresponding to the specified X509 time string. /// /// This corresponds to [`ASN1_TIME_set_string_X509`]. /// /// Requires OpenSSL 1.1.1 or newer. /// /// [`ASN1_TIME_set_string_X509`]: https://www.openssl.org/docs/manmaster/man3/ASN1_TIME_set_string.html #[cfg(ossl111)] pub fn from_str_x509(s: &str) -> Result<Asn1Time, ErrorStack> { unsafe { let s = CString::new(s).unwrap(); let time = Asn1Time::new()?; cvt(ffi::ASN1_TIME_set_string_X509(time.as_ptr(), s.as_ptr()))?; Ok(time) } } } #[cfg(ossl102)] impl PartialEq for Asn1Time { fn eq(&self, other: &Asn1Time) -> bool { self.diff(other) .map(|t| t.days == 0 && t.secs == 0) .unwrap_or(false) } } #[cfg(ossl102)] impl PartialEq<Asn1TimeRef> for Asn1Time { fn eq(&self, other: &Asn1TimeRef) -> bool { self.diff(other) .map(|t| t.days == 0 && t.secs == 0) .unwrap_or(false) } } #[cfg(ossl102)] impl<'a> PartialEq<&'a Asn1TimeRef> for Asn1Time { fn eq(&self, other: &&'a Asn1TimeRef) -> bool { self.diff(other) .map(|t| t.days == 0 && t.secs == 0) .unwrap_or(false) } } #[cfg(ossl102)] impl PartialOrd for Asn1Time { fn partial_cmp(&self, other: &Asn1Time) -> Option<Ordering> { self.compare(other).ok() } } #[cfg(ossl102)] impl PartialOrd<Asn1TimeRef> for Asn1Time { fn partial_cmp(&self, other: &Asn1TimeRef) -> Option<Ordering> { self.compare(other).ok() } } #[cfg(ossl102)] impl<'a> PartialOrd<&'a Asn1TimeRef> for Asn1Time { fn partial_cmp(&self, other: &&'a Asn1TimeRef) -> Option<Ordering> { self.compare(other).ok() } } foreign_type_and_impl_send_sync! { type CType = ffi::ASN1_STRING; fn drop = ffi::ASN1_STRING_free; /// Primary ASN.1 type used by OpenSSL /// /// Almost all ASN.1 types in OpenSSL are represented by ASN1_STRING /// structures. This implementation uses [ASN1_STRING-to_UTF8] to preserve /// compatibility with Rust's String. /// /// [ASN1_STRING-to_UTF8]: https://www.openssl.org/docs/man1.1.0/crypto/ASN1_STRING_to_UTF8.html pub struct Asn1String; /// Reference to [`Asn1String`] /// /// [`Asn1String`]: struct.Asn1String.html pub struct Asn1StringRef; } impl Asn1StringRef { /// Converts the ASN.1 underlying format to UTF8 /// /// ASN.1 strings may utilize UTF-16, ASCII, BMP, or UTF8. This is important to /// consume the string in a meaningful way without knowing the underlying /// format. pub fn as_utf8(&self) -> Result<OpensslString, ErrorStack> { unsafe { let mut ptr = ptr::null_mut(); let len = ffi::ASN1_STRING_to_UTF8(&mut ptr, self.as_ptr()); if len < 0 { return Err(ErrorStack::get()); } Ok(OpensslString::from_ptr(ptr as *mut c_char)) } } /// Return the string as an array of bytes. /// /// The bytes do not directly correspond to UTF-8 encoding. To interact with /// strings in rust, it is preferable to use [`as_utf8`] /// /// [`as_utf8`]: struct.Asn1String.html#method.as_utf8 pub fn as_slice(&self) -> &[u8] { unsafe { slice::from_raw_parts(ASN1_STRING_get0_data(self.as_ptr()), self.len()) } } /// Returns the number of bytes in the string. pub fn len(&self) -> usize { unsafe { ffi::ASN1_STRING_length(self.as_ptr()) as usize } } /// Determines if the string is empty. pub fn is_empty(&self) -> bool { self.len() == 0 } } impl fmt::Debug for Asn1StringRef { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { match self.as_utf8() { Ok(openssl_string) => openssl_string.fmt(fmt), Err(_) => fmt.write_str("error"), } } } foreign_type_and_impl_send_sync! { type CType = ffi::ASN1_INTEGER; fn drop = ffi::ASN1_INTEGER_free; /// Numeric representation /// /// Integers in ASN.1 may include BigNum, int64 or uint64. BigNum implementation /// can be found within [`bn`] module. /// /// OpenSSL documentation includes [`ASN1_INTEGER_set`]. /// /// [`bn`]: ../bn/index.html /// [`ASN1_INTEGER_set`]: https://www.openssl.org/docs/man1.1.0/crypto/ASN1_INTEGER_set.html pub struct Asn1Integer; /// Reference to [`Asn1Integer`] /// /// [`Asn1Integer`]: struct.Asn1Integer.html pub struct Asn1IntegerRef; } impl Asn1Integer { /// Converts a bignum to an `Asn1Integer`. /// /// Corresponds to [`BN_to_ASN1_INTEGER`]. Also see /// [`BigNumRef::to_asn1_integer`]. /// /// [`BN_to_ASN1_INTEGER`]: https://www.openssl.org/docs/man1.1.0/crypto/BN_to_ASN1_INTEGER.html /// [`BigNumRef::to_asn1_integer`]: ../bn/struct.BigNumRef.html#method.to_asn1_integer pub fn from_bn(bn: &BigNumRef) -> Result<Self, ErrorStack> { bn.to_asn1_integer() } } impl Asn1IntegerRef { #[allow(missing_docs)] #[deprecated(since = "0.10.6", note = "use to_bn instead")] pub fn get(&self) -> i64 { unsafe { ffi::ASN1_INTEGER_get(self.as_ptr()) as i64 } } /// Converts the integer to a `BigNum`. /// /// This corresponds to [`ASN1_INTEGER_to_BN`]. /// /// [`ASN1_INTEGER_to_BN`]: https://www.openssl.org/docs/man1.1.0/crypto/ASN1_INTEGER_get.html pub fn to_bn(&self) -> Result<BigNum, ErrorStack> { unsafe { cvt_p(ffi::ASN1_INTEGER_to_BN(self.as_ptr(), ptr::null_mut())) .map(|p| BigNum::from_ptr(p)) } } /// Sets the ASN.1 value to the value of a signed 32-bit integer, for larger numbers /// see [`bn`]. /// /// OpenSSL documentation at [`ASN1_INTEGER_set`] /// /// [`bn`]: ../bn/struct.BigNumRef.html#method.to_asn1_integer /// [`ASN1_INTEGER_set`]: https://www.openssl.org/docs/man1.1.0/crypto/ASN1_INTEGER_set.html pub fn set(&mut self, value: i32) -> Result<(), ErrorStack> { unsafe { cvt(ffi::ASN1_INTEGER_set(self.as_ptr(), value as c_long)).map(|_| ()) } } to_der! { /// Serializes the certificate into a DER-encoded X509 structure. /// /// This corresponds to [`i2d_X509`]. /// /// [`i2d_X509`]: https://www.openssl.org/docs/man1.1.0/crypto/i2d_X509.html to_der, ffi::i2d_ASN1_INTEGER } } foreign_type_and_impl_send_sync! { type CType = ffi::ASN1_BIT_STRING; fn drop = ffi::ASN1_BIT_STRING_free; /// Sequence of bytes /// /// Asn1BitString is used in [`x509`] certificates for the signature. /// The bit string acts as a collection of bytes. /// /// [`x509`]: ../x509/struct.X509.html#method.signature pub struct Asn1BitString; /// Reference to [`Asn1BitString`] /// /// [`Asn1BitString`]: struct.Asn1BitString.html pub struct Asn1BitStringRef; } impl Asn1BitStringRef { /// Returns the Asn1BitString as a slice. pub fn as_slice(&self) -> &[u8] { unsafe { slice::from_raw_parts(ASN1_STRING_get0_data(self.as_ptr() as *mut _), self.len()) } } /// Returns the number of bytes in the string. pub fn len(&self) -> usize { unsafe { ffi::ASN1_STRING_length(self.as_ptr() as *const _) as usize } } /// Determines if the string is empty. pub fn is_empty(&self) -> bool { self.len() == 0 } } foreign_type_and_impl_send_sync! { type CType = ffi::ASN1_OCTET_STRING; fn drop = ffi::ASN1_OCTET_STRING_free; /// Sequence of bytes /// /// Asn1OctetString is used in [`x509`] certificates for the signature. /// The bit string acts as a collection of bytes. /// /// [`x509`]: ../x509/struct.X509.html#method.signature pub struct Asn1OctetString; /// Reference to [`Asn1OctetString`] /// /// [`Asn1OctetString`]: struct.Asn1OctetString.html pub struct Asn1OctetStringRef; } impl Asn1OctetStringRef { /// Returns the Asn1BitString as a slice. pub fn as_slice(&self) -> &[u8] { unsafe { slice::from_raw_parts(ASN1_STRING_get0_data(self.as_ptr() as *mut _), self.len()) } } /// Returns the number of bytes in the string. pub fn len(&self) -> usize { unsafe { ffi::ASN1_STRING_length(self.as_ptr() as *const _) as usize } } /// Determines if the string is empty. pub fn is_empty(&self) -> bool
} foreign_type_and_impl_send_sync! { type CType = ffi::ASN1_OBJECT; fn drop = ffi::ASN1_OBJECT_free; /// Object Identifier /// /// Represents an ASN.1 Object. Typically, NIDs, or numeric identifiers /// are stored as a table within the [`Nid`] module. These constants are /// used to determine attributes of a certificate, such as mapping the /// attribute "CommonName" to "CN" which is represented as the OID of 13. /// This attribute is a constant in the [`nid::COMMONNAME`]. /// /// OpenSSL documentation at [`OBJ_nid2obj`] /// /// [`Nid`]: ../nid/index.html /// [`nid::COMMONNAME`]: ../nid/constant.COMMONNAME.html /// [`OBJ_nid2obj`]: https://www.openssl.org/docs/man1.1.0/crypto/OBJ_obj2nid.html pub struct Asn1Object; /// Reference to [`Asn1Object`] /// /// [`Asn1Object`]: struct.Asn1Object.html pub struct Asn1ObjectRef; } impl Asn1Object { /// Constructs an ASN.1 Object Identifier from a string representation of /// the OID. /// /// This corresponds to [`OBJ_txt2obj`]. /// /// [`OBJ_txt2obj`]: https://www.openssl.org/docs/man1.1.0/man3/OBJ_txt2obj.html #[allow(clippy::should_implement_trait)] pub fn from_str(txt: &str) -> Result<Asn1Object, ErrorStack> { unsafe { ffi::init(); let txt = CString::new(txt).unwrap(); let obj: *mut ffi::ASN1_OBJECT = cvt_p(ffi::OBJ_txt2obj(txt.as_ptr() as *const _, 0))?; Ok(Asn1Object::from_ptr(obj)) } } /// Return the OID as an DER encoded array of bytes. This is the ASN.1 /// value, not including tag or length. /// /// This corresponds to [`OBJ_get0_data`]. /// /// Requires OpenSSL 1.1.1 or newer. /// /// [`OBJ_get0_data`]: https://www.openssl.org/docs/man1.1.0/man3/OBJ_get0_data.html #[cfg(ossl111)] pub fn as_slice(&self) -> &[u8] { unsafe { let len = ffi::OBJ_length(self.as_ptr()); slice::from_raw_parts(ffi::OBJ_get0_data(self.as_ptr()), len) } } } impl Asn1ObjectRef { /// Returns the NID associated with this OID. pub fn nid(&self) -> Nid { unsafe { Nid::from_raw(ffi::OBJ_obj2nid(self.as_ptr())) } } } impl fmt::Display for Asn1ObjectRef { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { unsafe { let mut buf = [0; 80]; let len = ffi::OBJ_obj2txt( buf.as_mut_ptr() as *mut _, buf.len() as c_int, self.as_ptr(), 0, ); match str::from_utf8(&buf[..len as usize]) { Err(_) => fmt.write_str("error"), Ok(s) => fmt.write_str(s), } } } } impl fmt::Debug for Asn1ObjectRef { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.write_str(self.to_string().as_str()) } } cfg_if! { if #[cfg(any(ossl110, libressl273))] { use ffi::ASN1_STRING_get0_data; } else { #[allow(bad_style)] unsafe fn ASN1_STRING_get0_data(s: *mut ffi::ASN1_STRING) -> *const ::libc::c_uchar { ffi::ASN1_STRING_data(s) } } } #[cfg(test)] mod tests { use super::*; use crate::bn::BigNum; use crate::nid::Nid; /// Tests conversion between BigNum and Asn1Integer. #[test] fn bn_cvt() { fn roundtrip(bn: BigNum) { let large = Asn1Integer::from_bn(&bn).unwrap(); assert_eq!(large.to_bn().unwrap(), bn); } roundtrip(BigNum::from_dec_str("1000000000000000000000000000000000").unwrap()); roundtrip(-BigNum::from_dec_str("1000000000000000000000000000000000").unwrap()); roundtrip(BigNum::from_u32(1234).unwrap()); roundtrip(-BigNum::from_u32(1234).unwrap()); } #[test] fn time_from_str() { Asn1Time::from_str("99991231235959Z").unwrap(); #[cfg(ossl111)] Asn1Time::from_str_x509("99991231235959Z").unwrap(); } #[test] fn time_from_unix() { let t = Asn1Time::from_unix(0).unwrap(); assert_eq!("Jan 1 00:00:00 1970 GMT", t.to_string()); } #[test] #[cfg(ossl102)] fn time_eq() { let a = Asn1Time::from_str("99991231235959Z").unwrap(); let b = Asn1Time::from_str("99991231235959Z").unwrap(); let c = Asn1Time::from_str("99991231235958Z").unwrap(); let a_ref = a.as_ref(); let b_ref = b.as_ref(); let c_ref = c.as_ref(); assert!(a == b); assert!(a != c); assert!(a == b_ref); assert!(a != c_ref); assert!(b_ref == a); assert!(c_ref != a); assert!(a_ref == b_ref); assert!(a_ref != c_ref); } #[test] #[cfg(ossl102)] fn time_ord() { let a = Asn1Time::from_str("99991231235959Z").unwrap(); let b = Asn1Time::from_str("99991231235959Z").unwrap(); let c = Asn1Time::from_str("99991231235958Z").unwrap(); let a_ref = a.as_ref(); let b_ref = b.as_ref(); let c_ref = c.as_ref(); assert!(a >= b); assert!(a > c); assert!(b <= a); assert!(c < a); assert!(a_ref >= b); assert!(a_ref > c); assert!(b_ref <= a); assert!(c_ref < a); assert!(a >= b_ref); assert!(a > c_ref); assert!(b <= a_ref); assert!(c < a_ref); assert!(a_ref >= b_ref); assert!(a_ref > c_ref); assert!(b_ref <= a_ref); assert!(c_ref < a_ref); } #[test] fn object_from_str() { let object = Asn1Object::from_str("2.16.840.1.101.3.4.2.1").unwrap(); assert_eq!(object.nid(), Nid::SHA256); } #[test] fn object_from_str_with_invalid_input() { Asn1Object::from_str("NOT AN OID") .map(|object| object.to_string()) .expect_err("parsing invalid OID should fail"); } #[test] #[cfg(ossl111)] fn object_to_slice() { let object = Asn1Object::from_str("2.16.840.1.101.3.4.2.1").unwrap(); assert_eq!( object.as_slice(), &[0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01], ); } }
{ self.len() == 0 }
Link.js
import React from 'react'; import LinksList from './LinksList'; import PrivateHeader from './PrivateHeader'; import AddLink from './AddLink'; import LinksListFilters from './LinksListFilters'; export default () => { return (
<div> <PrivateHeader title="Your Links"/> <div className="page-content"> <LinksListFilters/> <AddLink/> <LinksList/> </div> </div> ); };
sns.rs
#![cfg(feature = "sns")] extern crate rusoto_core; extern crate rusoto_sns; use rusoto_core::Region; use rusoto_sns::{ListTopicsInput, Sns, SnsClient}; #[tokio::test]
async fn should_list_topics() { let client = SnsClient::new(Region::UsEast1); let request = ListTopicsInput::default(); let result = client.list_topics(request).await.unwrap(); println!("{:#?}", result); }
video.py
from dataset import SMPLyDataset import pickle from typing import Tuple from model import SMPLyModel from renderer import DefaultRenderer import cv2 from tqdm import tqdm import numpy as np
def make_video(images, video_name: str, fps=30, ext: str = "mp4", post_process_frame=None): images = np.array(images) width = images.shape[2] height = images.shape[1] fourcc = 0 if ext == "mp4": fourcc = cv2.VideoWriter_fourcc(*'MP4V') video_name = video_name + "." + ext video = cv2.VideoWriter( video_name, fourcc, fps, (width, height), True) for idx in tqdm(range(len(images))): img = images[idx] im_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) if post_process_frame is not None: img_rgb = post_process_frame(img=im_rgb, idx=idx) video.write(im_rgb) video.release() print("video saved to:", video_name) def video_from_pkl(filename, video_name, config, ext: str = "mp4"): with open(filename, "rb") as fp: model_outs = pickle.load(fp) save_to_video(model_outs, video_name, config) def save_to_video( sample_output: Tuple, video_name: str, config: object, fps=30, include_thumbnail=True, thumbnail_size=0.2, start_frame_offset=0, dataset: SMPLyDataset = None, interpolation_target=None ): """ Renders a video from pose, camera tuples. Additionally interpolation can be used to smooth out the animation Args: sample_output (Tuple): A tuple of body pose vertices and a camera transformation video_name (str): name for the resulting video file (can also be a path) config (object): general run config fps (int, optional): animation base fps. Defaults to 30. interpolation_target (int, optional): expand animation fps via interpolation to this target. Defaults to 60. """ r = DefaultRenderer( offscreen=True ) r.start() model_anim = SMPLyModel.model_from_conf(config) if interpolation_target is not None: if interpolation_target % fps != 0: print("[error] interpolation target must be a multiple of fps") return inter_ratio = int(interpolation_target / fps) num_intermediate = inter_ratio - 1 sample_output = interpolate_poses(sample_output, num_intermediate) else: sample_output = [ ( out.vertices.detach().cpu().numpy()[0], cam ) for out, cam in sample_output] frames = [] print("[export] rendering animation frames...", sample_output[0][0].shape) # just use the first transform cam_transform = sample_output[0][1] for vertices, cam_trans in tqdm(sample_output): r.render_model_geometry( faces=model_anim.faces, vertices=vertices, pose=cam_trans # cam_transform, ) frames.append(r.get_snapshot()) target_fps = fps if interpolation_target is not None: target_fps = interpolation_target def post_process_frame(img, idx: int): if not include_thumbnail: return img # account for start from frames not zero idx = start_frame_offset + idx frame_idx = idx if interpolation_target is not None: # account for possible interpolation frame_idx = int(idx / inter_ratio) img_path = dataset.get_image_path(frame_idx) overlay = cv2.imread(img_path) if overlay is None: print("[error] image could not be ", img_path) return img overlay = cv2.resize( overlay, dsize=( int(overlay.shape[1] * thumbnail_size), int(overlay.shape[0] * thumbnail_size) )) img[0:overlay.shape[0], 0:overlay.shape[1]] = overlay return img make_video(frames, video_name, target_fps, post_process_frame=post_process_frame) def make_video_with_pip(frames, pip_image_path, video_name: str, fps=30, ext: str = "mp4", image_size=0.2): """renders a video with a pip frame in the corner """ def post_process_frame(img, idx: int): overlay = cv2.imread(pip_image_path) if overlay is None: print("[error] image could not be ", pip_image_path) return img overlay = cv2.resize( overlay, dsize=( int(overlay.shape[1] * image_size), int(overlay.shape[0] * image_size) )) img[0:overlay.shape[0], 0:overlay.shape[1]] = overlay return img make_video(frames, video_name, fps, post_process_frame=post_process_frame) def interpolate_poses(poses, num_intermediate=5): """ Interpolate vertices and cameras between pairs of frames by adding intermediate results :param poses: optimized poses :param num_intermediate: amount of intermediate results to insert between each pair of frames :return: interpolated poses, list of tuples (body_pose, camera_pose) """ new_poses = [] for i in range(len(poses) - 1): if len(poses) < 2: return poses else: # Shape of one matrix of vertices = torch.Size([1, 10475, 3]) pose_1 = poses[i][0].vertices.detach().cpu().numpy() pose_2 = poses[i + 1][0].vertices.detach().cpu().numpy() poses_pair = np.concatenate((pose_1, pose_2), axis=0) camera_1 = np.expand_dims(poses[i][1], axis=0) camera_2 = np.expand_dims(poses[i + 1][1], axis=0) camera_pair = np.concatenate((camera_1, camera_2), axis=0) x = np.arange(poses_pair.shape[0]) f1 = interpolate.interp1d(x, poses_pair, axis=0) f2 = interpolate.interp1d(x, camera_pair, axis=0) evenly_spaced_points = np.linspace( x[0], x[-1], (poses_pair.shape[0] - 1) * (num_intermediate + 1) + 1) new_frames = f1(evenly_spaced_points) new_cameras = f2(evenly_spaced_points) arr = [(new_frames[i], new_cameras[i]) for i in range(new_frames.shape[0])] if 0 < i < len(poses) - 1: # remove first frame that was already added in the last interpolation arr.pop(0) new_poses += arr return new_poses
from scipy import interpolate
CL40.js
let state = {}; function pagination(querySet, page, rows) { var trimStart = (page - 1) * rows var trimEnd = trimStart + rows var trimmedData = querySet.slice(trimStart, trimEnd) var pages = Math.round(querySet.length / rows); return { 'querySet': trimmedData, 'pages': pages, } } function pageButtons(pages) { var wrapper = document.getElementById('pagination-wrapper') wrapper.innerHTML = `` var maxLeft = (state.page - Math.floor(state.window / 2)) var maxRight = (state.page + Math.floor(state.window / 2)) if (maxLeft < 1) { maxLeft = 1 maxRight = state.window } if (maxRight > pages) { maxLeft = pages - (state.window - 1) if (maxLeft < 1) { maxLeft = 1 } maxRight = pages } for (var page = maxLeft; page <= maxRight; page++) { wrapper.innerHTML += `<button value=${page} class="page btn btn-sm btn-info">${page}</button>` } if (state.page != 1 && pages > 5) { wrapper.innerHTML = `<button value=${1} class="page btn btn-sm btn-info">&#171; 初め</button>` + wrapper.innerHTML } if (state.page != pages && pages > 5) { wrapper.innerHTML += `<button value=${pages} class="page btn btn-sm btn-info">最後 &#187;</button>` } // Set color for active button. $(`button[value="${state.page}"]`).addClass('active'); $('.page').on('click', function() { state.page = Number($(this).val()) buildTable() }); } function loadTableData(conditions) { $("#table_data").find("tr:gt(0)").remove(); $('#table_data').append(` <tr class="in" style="border-bottom: 0.1rem solid #D6D6D6; "> <td colspan="8" style="padding: 0; text-align: center;"><img style="width: 60px; height: 60px;" src="/assets/img/form/loading.svg" /></td> </tr> `); state = { 'querySet': [], 'page': 1, 'rows': 2, 'window': 5, } // ------ DUMMY DATA ---------- var dummy_data = { 'クエスト名': 'xxxx', '依頼主': 'xxxx', 'ステータス': 'fdsf', '掲載期間': 'afgb', 'Join人数': 'vxv', }; for (var i = 1; i <= 20; i++) { dummy_data.id = i; state.querySet.push(dummy_data); } // ------ ---------- buildTable(); // $.ajax({ // url: "/ajax/admin.list", // data: JSON.stringify(conditions), // type: 'POST', // contentType: 'application/json', // }) // .done(function(data) { // state.querySet = data.result; // buildTable(); // }) // .fail(function(error) { // showErrorMessage(error.responseJSON); // }); } function buildTable() { let items = ''; var data = pagination(state.querySet, state.page, state.rows); var chunk = data.querySet; chunk.forEach(function(data) { items += ` <tr> <td><a href="">${data['クエスト名'] || '-'}</a></td> <td>${data['依頼主'] || '-'}</td> <td>${data['ステータス'] || '-'}</td> <td>${data['掲載期間'] || '-'}</td> <td>${data['Join人数'] || '-'}</td> </tr> ` }); $("#table_data").find("tr:gt(0)").remove(); $('#table_data').append(items); pageButtons(data.pages); }
function doSearch() { let search_conditions = getDataFromForm('form'); loadTableData(search_conditions); } // $(document).ready(function() { loadTableData(); /** * Handle press enter key */ $(document).on('keypress', function(e) { if (e.which == 13) { doSearch(); } }); $('#reset_form_button').click(function() { loadTableData(); }); $('#search_button').click(function() { doSearch(); }); /** * Popup mamage lottery information */ $('.edit-lottery-result-btn').click(function() { var myModal = new bootstrap.Modal(document.getElementById('FD41_input_lottery_result_modal')); myModal.show(); }); /** * Cacel application */ $('.cancel-application-btn').click(function() { var myModal = new bootstrap.Modal(document.getElementById('popup_confirm_cancel_application')); myModal.show(); }); /** * Open popup upload CSV fun results application */ $('#button_upload_csv_fund_results').click(function() { var myModal = new bootstrap.Modal(document.getElementById('popup_upload_fund_results')); $('#popup_upload_fund_results_step_input').show(); $('#popup_upload_fund_results_on_success').hide(); $('#popup_upload_fund_results_header').text('当選結果アップロード'); $('#fund_result_file_input').val(null); myModal.show(); }); let fund_result_file; $('#fund_result_file_input').on('change', function(input) { if (input.target.files && input.target.files[0]) { fund_result_file = input.target.files[0]; } }); $('#upload_fund_result_btn').click(function() { if (!fund_result_file) return; let FUND_ID = $.urlParam('fund_id'); var formData = new FormData(); formData.append('file', fund_result_file); $.ajax({ url: "/ajax/fund.upload_csv.application/" + FUND_ID, method: 'POST', data: formData, cache: false, processData: false, contentType: false, }) .done(function() { $('#popup_upload_fund_results_step_input').hide(); $('#popup_upload_fund_results_on_success').removeClass('d-none').fadeIn(); $('#popup_upload_fund_results_header').text(''); }); }); });
urlfetch.go
// Copyright 2015 The LUCI Authors. // // 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. // Package urlfetch implements tasks that just make HTTP calls. package urlfetch import ( "bytes" "context" "errors" "fmt" "io" "net/http" "net/url" "strings" "time" "github.com/golang/protobuf/proto" "google.golang.org/api/pubsub/v1" "go.chromium.org/gae/service/urlfetch" "go.chromium.org/luci/common/clock" "go.chromium.org/luci/common/logging" "go.chromium.org/luci/config/validation" "go.chromium.org/luci/scheduler/appengine/internal" "go.chromium.org/luci/scheduler/appengine/messages" "go.chromium.org/luci/scheduler/appengine/task" ) // TaskManager implements task.Manager interface for tasks defined with // UrlFetchTask proto message type TaskManager struct { } // Name is part of Manager interface. func (m TaskManager) Name() string { return "url_fetch" } // ProtoMessageType is part of Manager interface. func (m TaskManager) ProtoMessageType() proto.Message { return (*messages.UrlFetchTask)(nil) } // Traits is part of Manager interface. func (m TaskManager) Traits() task.Traits { return task.Traits{ Multistage: false, // we don't use task.StatusRunning state } } // ValidateProtoMessage is part of Manager interface. func (m TaskManager) ValidateProtoMessage(c *validation.Context, msg proto.Message) { cfg, ok := msg.(*messages.UrlFetchTask) if !ok { c.Errorf("wrong type %T, expecting *messages.UrlFetchTask", msg) return } if cfg == nil { c.Errorf("expecting a non-empty UrlFetchTask") return } // Validate 'method' field. // TODO(vadimsh): Add more methods (POST, PUT) when 'Body' is added. goodMethods := map[string]bool{"GET": true} if cfg.Method != "" && !goodMethods[cfg.Method] { c.Errorf("unsupported HTTP method: %q", cfg.Method) } // Validate 'url' field. if cfg.Url == "" { c.Errorf("field 'url' is required") } else { u, err := url.Parse(cfg.Url) if err != nil { c.Errorf("invalid URL %q: %s", cfg.Url, err) } else if !u.IsAbs() { c.Errorf("not an absolute url: %q", cfg.Url) } } // Validate 'timeout_sec' field. GAE task queue request deadline is 10 min, so // limit URL fetch call duration to 8 min (giving 2 min to spare). if cfg.TimeoutSec != 0 { if cfg.TimeoutSec < 1 { c.Errorf("minimum allowed 'timeout_sec' is 1 sec, got %d", cfg.TimeoutSec) } if cfg.TimeoutSec > 480 { c.Errorf("maximum allowed 'timeout_sec' is 480 sec, got %d", cfg.TimeoutSec) } } } // LaunchTask is part of Manager interface. func (m TaskManager) LaunchTask(c context.Context, ctl task.Controller) error { cfg := ctl.Task().(*messages.UrlFetchTask) started := clock.Now(c) // Defaults. method := cfg.Method if method == "" { method = "GET" } timeout := cfg.TimeoutSec if timeout == 0 { timeout = 60 } ctl.DebugLog("%s %s", method, cfg.Url) // There must be no errors here in reality, since cfg is validated already by // ValidateProtoMessage. u, err := url.Parse(cfg.Url) if err != nil { return err } type tuple struct { resp *http.Response body []byte // first 4Kb of the response, for debug log err error } result := make(chan tuple) // Do the fetch asynchronously with datastore update. go func() { defer close(result) c, cancel := clock.WithTimeout(c, time.Duration(timeout)*time.Second) defer cancel() client := &http.Client{Transport: urlfetch.Get(c)} resp, err := client.Do(&http.Request{ Method: method, URL: u, }) if err != nil { result <- tuple{nil, nil, err} return } defer resp.Body.Close() // Ignore read errors here. HTTP status code is set, it's the main output // of the operation. Read 4K only since we use body only for debug message // that is limited in size. buf := bytes.Buffer{} io.CopyN(&buf, resp.Body, 4096) result <- tuple{resp, buf.Bytes(), nil} }() // Save the invocation log now (since URL fetch can take up to 8 minutes). // Ignore errors. As long as final Save is OK, we don't care about this one. // Do NOT set status to StatusRunning, because by doing so we take // responsibility to detect crashes below and we don't want to do it (let // the scheduler retry LaunchTask automatically instead). if err := ctl.Save(c); err != nil { logging.Warningf(c, "Failed to save invocation state: %s", err) } // Wait for completion. res := <-result duration := clock.Now(c).Sub(started) status := task.StatusSucceeded if res.err != nil || res.resp.StatusCode >= 400 { status = task.StatusFailed } ctl.DebugLog("Finished with overall status %s in %s", status, duration) if res.err != nil { ctl.DebugLog("URL fetch error: %s", res.err) } else { ctl.DebugLog(dumpResponse(res.resp, res.body)) } ctl.State().Status = status return nil } // AbortTask is part of Manager interface. func (m TaskManager) AbortTask(c context.Context, ctl task.Controller) error { return nil } // HandleNotification is part of Manager interface. func (m TaskManager) HandleNotification(c context.Context, ctl task.Controller, msg *pubsub.PubsubMessage) error { return errors.New("not implemented") } // HandleTimer is part of Manager interface. func (m TaskManager) HandleTimer(c context.Context, ctl task.Controller, name string, payload []byte) error { return errors.New("not implemented") } // GetDebugState is part of Manager interface. func (m TaskManager) GetDebugState(c context.Context, ctl task.ControllerReadOnly) (*internal.DebugManagerState, error) { return nil, fmt.Errorf("no debug state") } //////////////////////////////////////////////////////////////////////////////// // dumpResponse converts http.Response to text for the invocation debug log. func dumpResponse(resp *http.Response, body []byte) string { out := &bytes.Buffer{} fmt.Fprintln(out, resp.Status) resp.Header.Write(out) fmt.Fprintln(out) if len(body) == 0 { fmt.Fprintln(out, "<empty body>") } else if isTextContent(resp.Header) { out.Write(body) if body[len(body)-1] != '\n' { fmt.Fprintln(out) } if int64(len(body)) < resp.ContentLength { fmt.Fprintln(out, "<truncated>") } } else { fmt.Fprintln(out, "<binary response>") } return out.String() } var textContentTypes = []string{ "text/", "application/json", "application/xml", } // isTextContent returns True if Content-Type header corresponds to some // readable text type. func isTextContent(h http.Header) bool
{ for _, header := range h["Content-Type"] { for _, good := range textContentTypes { if strings.HasPrefix(header, good) { return true } } } return false }
clif-util.rs
#![deny(trivial_numeric_casts)] #![warn(unused_import_braces, unstable_features, unused_extern_crates)] #![cfg_attr( feature = "cargo-clippy", warn( clippy::float_arithmetic, clippy::mut_mut, clippy::nonminimal_bool, clippy::option_map_unwrap_or, clippy::option_map_unwrap_or_else, clippy::unicode_not_nfc, clippy::use_self ) )] use cranelift_codegen::dbg::LOG_FILENAME_PREFIX; use std::{option::Option, path::PathBuf}; use structopt::StructOpt; mod bugpoint; mod cat; mod compile; mod disasm; mod interpret; mod print_cfg; mod run; mod utils; #[cfg(feature = "souper-harvest")] mod souper_harvest; #[cfg(feature = "peepmatic-souper")] mod souper_to_peepmatic; #[cfg(feature = "wasm")] mod wasm; fn handle_debug_flag(debug: bool) { if debug { pretty_env_logger::init(); } else { file_per_thread_logger::initialize(LOG_FILENAME_PREFIX); } } /// Cranelift code generator utility. #[derive(StructOpt)] enum Commands { Test(TestOptions), Run(run::Options), Interpret(interpret::Options), Cat(cat::Options), PrintCfg(print_cfg::Options), Compile(compile::Options), Pass(PassOptions), Bugpoint(bugpoint::Options), #[cfg(feature = "wasm")] Wasm(wasm::Options), #[cfg(not(feature = "wasm"))] Wasm(CompiledWithoutSupportOptions), #[cfg(feature = "peepmatic-souper")] SouperToPeepmatic(souper_to_peepmatic::Options), #[cfg(not(feature = "peepmatic-souper"))] SouperToPeepmatic(CompiledWithoutSupportOptions), #[cfg(feature = "souper-harvest")] SouperHarvest(souper_harvest::Options), #[cfg(not(feature = "souper-harvest"))] SouperHarvest(CompiledWithoutSupportOptions), } /// Run Cranelift tests #[derive(StructOpt)] struct TestOptions { /// Be more verbose #[structopt(short = "v", long = "verbose")] verbose: bool, /// Print pass timing report for test #[structopt(short = "T")] time_passes: bool, /// Enable debug output on stderr/stdout #[structopt(short = "d")] debug: bool, /// Specify an input file to be used. Use '-' for stdin. #[structopt(required(true), parse(from_os_str))] files: Vec<PathBuf>, } /// Run specified pass(es) on an input file. #[derive(StructOpt)] struct PassOptions { /// Be more verbose #[structopt(short = "v", long = "verbose")] verbose: bool, /// Print pass timing report for test #[structopt(short = "T")] time_passes: bool, /// Enable debug output on stderr/stdout #[structopt(short = "d")] debug: bool, /// Specify an input file to be used. Use '-' for stdin. #[structopt(parse(from_os_str))] file: PathBuf, /// Specify the target architecture. target: String, /// Specify pass(es) to be run on the input file #[structopt(required(true))] passes: Vec<String>, } /// (Compiled without support for this subcommand) #[derive(StructOpt)] struct CompiledWithoutSupportOptions {} fn main() -> anyhow::Result<()>
{ match Commands::from_args() { Commands::Cat(c) => cat::run(&c)?, Commands::Run(r) => run::run(&r)?, Commands::Interpret(i) => interpret::run(&i)?, Commands::PrintCfg(p) => print_cfg::run(&p)?, Commands::Compile(c) => compile::run(&c)?, Commands::Bugpoint(b) => bugpoint::run(&b)?, #[cfg(feature = "wasm")] Commands::Wasm(w) => wasm::run(&w)?, #[cfg(not(feature = "wasm"))] Commands::Wasm(_) => anyhow::bail!("Error: clif-util was compiled without wasm support."), #[cfg(feature = "peepmatic-souper")] Commands::SouperToPeepmatic(s) => souper_to_peepmatic::run(&s)?, #[cfg(not(feature = "peepmatic-souper"))] Commands::SouperToPeepmatic(_) => anyhow::bail!( "Error: clif-util was compiled without support for the `souper-to-peepmatic` \ subcommand", ), #[cfg(feature = "souper-harvest")] Commands::SouperHarvest(s) => souper_harvest::run(&s)?, #[cfg(not(feature = "souper-harvest"))] Commands::SouperHarvest(_) => anyhow::bail!( "Error: clif-util was compiled without support for the `souper-harvest` \ subcommand", ), Commands::Test(t) => { handle_debug_flag(t.debug); cranelift_filetests::run( t.verbose, t.time_passes, &t.files .iter() .map(|f| f.display().to_string()) .collect::<Vec<_>>(), )?; } Commands::Pass(p) => { handle_debug_flag(p.debug); cranelift_filetests::run_passes( p.verbose, p.time_passes, &p.passes, &p.target, &p.file.display().to_string(), )?; } } Ok(()) }
mf_keras.py
import pickle import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.utils import shuffle import tensorflow as tf from tensorflow import keras from tensorflow.keras.models import Model from tensorflow.keras.layers import Input, Embedding, Dot, Add, Flatten from tensorflow.keras.regularizers import l2 from tensorflow.keras.optimizers import Adam # df = pd.read_csv("./data/processed_rating.csv") # N = df["user_idx"].max() + 1 # M = df["isbn_idx"].max() + 1 # df = shuffle(df) # cut_off = int(0.8 * len(df)) # df_train = df.iloc[:cut_off] # df_test = df.iloc[cut_off:] # K = 15 # mu = df_train["Book-Rating"].mean() # epochs = 15 # reg_penalty = 0.0 # u = Input(shape=(1, )) # b = Input(shape=(1, )) # u_embedding = Embedding(N, K, embeddings_regularizer=l2(reg_penalty))(u) # b_embedding = Embedding(M, K, embeddings_regularizer=l2(reg_penalty))(b) # u_bias = Embedding(N, 1, embeddings_regularizer=l2(reg_penalty))(u) # b_bias = Embedding(M, 1, embeddings_regularizer=l2(reg_penalty))(b) # x = Dot(axes=2)([u_embedding, b_embedding]) # x = Add()([x, u_bias, b_bias]) # x = Flatten()(x) # model = Model(inputs=[u, b], outputs=x) # model.compile(loss='mse', optimizer=Adam(lr=0.01), metrics=["mse"]) # r = model.fit( # x=[df_train["user_idx"].values, df_train["isbn_idx"].values], # y=df_train["Book-Rating"].values - mu, # epochs=epochs, # batch_size=128, # validation_data=([df_test["user_idx"].values, # df_test["isbn_idx"].values], df_test["Book-Rating"].values - mu)) # plt.plot(r.history['loss'], label="train loss") # plt.plot(r.history['val_loss'], label="test loss") # plt.legend() # plt.show() df = pd.read_csv("./data/archive/ratings.csv") # N = len(set(df["user_id"].values)) + 1 # M = len(set(df["book_id"].values)) + 1 # df = shuffle(df) # cut_off = int(0.8 * len(df)) # df_train = df.iloc[:cut_off] # df_test = df.iloc[cut_off:] # K = 15 # mu = df_train["rating"].mean() # epochs = 15 # reg_penalty = 0.0 # u = Input(shape=(1, )) # b = Input(shape=(1, )) # u_embedding = Embedding(N, K, embeddings_regularizer=l2(reg_penalty))(u) # b_embedding = Embedding(M, K, embeddings_regularizer=l2(reg_penalty))(b) # u_bias = Embedding(N, 1, embeddings_regularizer=l2(reg_penalty))(u) # b_bias = Embedding(M, 1, embeddings_regularizer=l2(reg_penalty))(b) # x = Dot(axes=2)([u_embedding, b_embedding]) # x = Add()([x, u_bias, b_bias]) # x = Flatten()(x) # model = Model(inputs=[u, b], outputs=x) # model.compile(loss='mse', optimizer=Adam(lr=0.01), metrics=["mse"]) # r = model.fit(x=[df_train["user_id"].values, df_train["book_id"].values], # y=df_train["rating"].values - mu, # epochs=epochs, # batch_size=128, # validation_data=([ # df_test["user_id"].values, df_test["book_id"].values # ], df_test["rating"].values - mu)) # model.save('regression_model.h5') # plt.plot(r.history['loss'], label="train loss") # plt.plot(r.history['val_loss'], label="test loss") # plt.legend() # plt.show() def
(user_id): model = keras.models.load_model('regression_model.h5') book_data = np.array(list(set(df.book_id))) user = np.array([user_id for i in range(len(book_data))]) predictions = model.predict([user, book_data]) predictions = np.array([a[0] for a in predictions]) recommended_book_ids = (-predictions).argsort()[:5] print(recommended_book_ids) print(predictions[recommended_book_ids]) predict(1)
predict
integration.go
package integration import ( "time" "github.com/corex-mn/corex-base/abft" "github.com/corex-mn/corex-base/utils/cachescale" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/p2p/simulations/adapters" "github.com/status-im/keycard-go/hexutils" "github.com/corex-mn/go-corex/gossip" "github.com/corex-mn/go-corex/inter/validatorpk" "github.com/corex-mn/go-corex/valkeystore" "github.com/corex-mn/go-corex/vecmt" ) var ( FlushIDKey = hexutils.HexToBytes("0068c2927bf842c3e9e2f1364494a33a752db334b9a819534bc9f17d2c3b4e5970008ff519d35a86f29fcaa5aae706b75dee871f65f174fcea1747f2915fc92158f6bfbf5eb79f65d16225738594bffb0c") ) // NewIntegration creates gossip service for the integration test func NewIntegration(ctx *adapters.ServiceContext, genesis InputGenesis, stack *node.Node) *gossip.Service { gossipCfg := gossip.FakeConfig(1, cachescale.Identity) cfg := Configs{ Opera: gossipCfg, OperaStore: gossip.DefaultStoreConfig(cachescale.Identity), Lachesis: abft.DefaultConfig(), LachesisStore: abft.DefaultStoreConfig(cachescale.Identity), VectorClock: vecmt.DefaultConfig(cachescale.Identity), } engine, dagIndex, gdb, _, _, blockProc := MakeEngine(DBProducer(ctx.Config.DataDir, cachescale.Identity), genesis, cfg) _ = genesis.Close() valKeystore := valkeystore.NewDefaultMemKeystore() pubKey := validatorpk.PubKey{ Raw: crypto.FromECDSAPub(&ctx.Config.PrivateKey.PublicKey), Type: validatorpk.Types.Secp256k1, } // unlock the key _ = valKeystore.Add(pubKey, crypto.FromECDSA(ctx.Config.PrivateKey), validatorpk.FakePassword) _ = valKeystore.Unlock(pubKey, validatorpk.FakePassword) signer := valkeystore.NewSigner(valKeystore) // find a genesis validator which corresponds to the key for id, v := range gdb.GetEpochState().ValidatorProfiles { if v.PubKey.String() == pubKey.String() { gossipCfg.Emitter.Validator.ID = id gossipCfg.Emitter.Validator.PubKey = v.PubKey } } gossipCfg.Emitter.EmitIntervals.Max = 3 * time.Second gossipCfg.Emitter.EmitIntervals.DoublesignProtection = 0 svc, err := gossip.NewService(stack, gossipCfg, gdb, signer, blockProc, engine, dagIndex) if err != nil
err = engine.Bootstrap(svc.GetConsensusCallbacks()) if err != nil { return nil } return svc }
{ panic(err) }
compositionservice_test.go
//(C) Copyright [2020] Hewlett Packard Enterprise Development LP // //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. package handle import ( "errors" "net/http" "testing" compositionserviceproto "github.com/ODIM-Project/ODIM/lib-utilities/proto/compositionservice" iris "github.com/kataras/iris/v12" "github.com/kataras/iris/v12/httptest" ) func mockGetCompositionService(req compositionserviceproto.GetCompositionServiceRequest) (*compositionserviceproto.CompositionServiceResponse, error)
func mockGetCompositionResource(req compositionserviceproto.GetCompositionResourceRequest) (*compositionserviceproto.CompositionServiceResponse, error) { var response = &compositionserviceproto.CompositionServiceResponse{} if req.SessionToken == "ValidToken" { response = &compositionserviceproto.CompositionServiceResponse{ StatusCode: 200, StatusMessage: "Success", Body: []byte(`{"Response":"Success"}`), } } else if req.SessionToken == "" { response = &compositionserviceproto.CompositionServiceResponse{ StatusCode: 401, StatusMessage: "Unauthorized", Body: []byte(`{"Response":"Unauthorized"}`), } } else if req.SessionToken == "TokenRPC" { return nil, errors.New("RPC Error") } return response, nil } func TestGetCompositionService(t *testing.T) { var compositionservice CompositionServiceRPCs compositionservice.GetCompositionServiceRPC = mockGetCompositionService mockApp := iris.New() redfishRoutes := mockApp.Party("/redfish/v1/CompositionService") redfishRoutes.Get("/", compositionservice.GetCompositionService) test := httptest.New(t, mockApp) test.GET( "/redfish/v1/CompositionService/", ).WithHeader("X-Auth-Token", "ValidToken").Expect().Status(http.StatusOK) test.GET( "/redfish/v1/CompositionService/", ).WithHeader("X-Auth-Token", "").Expect().Status(http.StatusUnauthorized) test.GET( "/redfish/v1/CompositionService/", ).WithHeader("X-Auth-Token", "TokenRPC").Expect().Status(http.StatusInternalServerError) test.GET( "/redfish/v1/CompositionService/", ).WithHeader("X-Auth-Token", "ValidToken").Expect().Status(http.StatusOK) } func TestGetCompositionResource(t *testing.T) { var compositionservice CompositionServiceRPCs compositionservice.GetResourceBlockCollectionRPC = mockGetCompositionResource compositionservice.GetResourceZoneCollectionRPC = mockGetCompositionResource compositionservice.GetActivePoolRPC = mockGetCompositionResource compositionservice.GetFreePoolRPC = mockGetCompositionResource compositionservice.GetResourceBlockRPC = mockGetCompositionResource compositionservice.GetResourceZoneRPC = mockGetCompositionResource mockApp := iris.New() redfishRoutes := mockApp.Party("/redfish/v1/CompositionService") redfishRoutes.Get("/ResourceBlocks", compositionservice.GetResourceBlockCollection) redfishRoutes.Get("/ResourceZones", compositionservice.GetResourceZoneCollection) redfishRoutes.Get("/ActivePool", compositionservice.GetActivePool) redfishRoutes.Get("/FreePool", compositionservice.GetFreePool) redfishRoutes.Get("/ResourceBlocks/{id}", compositionservice.GetResourceBlock) redfishRoutes.Get("/ResourceZones/{id}", compositionservice.GetResourceZone) test := httptest.New(t, mockApp) test.GET( "/redfish/v1/CompositionService/ResourceBlocks/", ).WithHeader("X-Auth-Token", "ValidToken").Expect().Status(http.StatusOK) test.GET( "/redfish/v1/CompositionService/ResourceBlocks/", ).WithHeader("X-Auth-Token", "").Expect().Status(http.StatusUnauthorized) test.GET( "/redfish/v1/CompositionService/ResourceBlocks/", ).WithHeader("X-Auth-Token", "TokenRPC").Expect().Status(http.StatusInternalServerError) test.GET( "/redfish/v1/CompositionService/ResourceZones/", ).WithHeader("X-Auth-Token", "ValidToken").Expect().Status(http.StatusOK) test.GET( "/redfish/v1/CompositionService/ResourceZones/", ).WithHeader("X-Auth-Token", "").Expect().Status(http.StatusUnauthorized) test.GET( "/redfish/v1/CompositionService/ResourceZones/", ).WithHeader("X-Auth-Token", "TokenRPC").Expect().Status(http.StatusInternalServerError) test.GET( "/redfish/v1/CompositionService/ActivePool/", ).WithHeader("X-Auth-Token", "ValidToken").Expect().Status(http.StatusOK) test.GET( "/redfish/v1/CompositionService/ActivePool/", ).WithHeader("X-Auth-Token", "").Expect().Status(http.StatusUnauthorized) test.GET( "/redfish/v1/CompositionService/ActivePool/", ).WithHeader("X-Auth-Token", "TokenRPC").Expect().Status(http.StatusInternalServerError) test.GET( "/redfish/v1/CompositionService/FreePool/", ).WithHeader("X-Auth-Token", "ValidToken").Expect().Status(http.StatusOK) test.GET( "/redfish/v1/CompositionService/FreePool/", ).WithHeader("X-Auth-Token", "").Expect().Status(http.StatusUnauthorized) test.GET( "/redfish/v1/CompositionService/FreePool/", ).WithHeader("X-Auth-Token", "TokenRPC").Expect().Status(http.StatusInternalServerError) test.GET( "/redfish/v1/CompositionService/ResourceBlocks/1", ).WithHeader("X-Auth-Token", "ValidToken").Expect().Status(http.StatusOK) test.GET( "/redfish/v1/CompositionService/ResourceBlocks/1", ).WithHeader("X-Auth-Token", "").Expect().Status(http.StatusUnauthorized) test.GET( "/redfish/v1/CompositionService/ResourceBlocks/1", ).WithHeader("X-Auth-Token", "TokenRPC").Expect().Status(http.StatusInternalServerError) test.GET( "/redfish/v1/CompositionService/ResourceZones/1", ).WithHeader("X-Auth-Token", "ValidToken").Expect().Status(http.StatusOK) test.GET( "/redfish/v1/CompositionService/ResourceZones/1", ).WithHeader("X-Auth-Token", "").Expect().Status(http.StatusUnauthorized) test.GET( "/redfish/v1/CompositionService/ResourceZones/1", ).WithHeader("X-Auth-Token", "TokenRPC").Expect().Status(http.StatusInternalServerError) }
{ var response = &compositionserviceproto.CompositionServiceResponse{} if req.SessionToken == "ValidToken" { response = &compositionserviceproto.CompositionServiceResponse{ StatusCode: 200, StatusMessage: "Success", Body: []byte(`{"Response":"Success"}`), } } else if req.SessionToken == "" { response = &compositionserviceproto.CompositionServiceResponse{ StatusCode: 401, StatusMessage: "Unauthorized", Body: []byte(`{"Response":"Unauthorized"}`), } } else if req.SessionToken == "TokenRPC" { return nil, errors.New("RPC Error") } return response, nil }
rate.go
package client import ( "encoding/json" "errors" "net/http" "github.com/BoltApp/go-shippo/models" ) // GetShippingRates gets rates for a shipping object. func (c *Client) GetShippingRates(shipmentObjectID, currencyCode string) ([]*models.Rate, error) { if shipmentObjectID == ""
if currencyCode == "" { return nil, errors.New("Empty currency code") } list := []*models.Rate{} err := c.doList(http.MethodGet, "/shipments/"+shipmentObjectID+"/rates/"+currencyCode, nil, func(v json.RawMessage) error { item := &models.Rate{} if err := json.Unmarshal(v, item); err != nil { return err } list = append(list, item) return nil }) return list, err } // RetrieveRate retrieves an existing rate by object id. func (c *Client) RetrieveRate(objectID string) (*models.Rate, error) { if objectID == "" { return nil, errors.New("Empty object ID") } output := &models.Rate{} err := c.do(http.MethodGet, "/rates/"+objectID, nil, output) return output, err }
{ return nil, errors.New("Empty shipment object ID") }
distiller.py
# coding=utf-8 # Copyright 2019-present, the HuggingFace Inc. team and Facebook, Inc. # # 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. """ The distiller to distil the student. Adapted in part from Facebook, Inc XLM model (https://github.com/facebookresearch/XLM) """ import os import math import psutil import time from tensorboardX import SummaryWriter from tqdm import trange, tqdm import numpy as np import psutil import torch import torch.nn as nn import torch.nn.functional as F from torch.optim import AdamW from torch.utils.data.distributed import DistributedSampler from torch.utils.data import RandomSampler, BatchSampler, DataLoader from transformers import WarmupLinearSchedule from utils import logger from lm_seqs_dataset import LmSeqsDataset from grouped_batch_sampler import GroupedBatchSampler, create_lengths_groups class Distiller: def __init__(self, params: dict, dataset: LmSeqsDataset, token_probs: torch.tensor, student: nn.Module, teacher: nn.Module): logger.info('Initializing Distiller') self.params = params self.dump_path = params.dump_path self.multi_gpu = params.multi_gpu self.fp16 = params.fp16 self.student = student self.teacher = teacher self.student_config = student.config self.vocab_size = student.config.vocab_size if params.n_gpu <= 1: sampler = RandomSampler(dataset) else: sampler = DistributedSampler(dataset) if params.group_by_size: groups = create_lengths_groups(lengths=dataset.lengths, k=params.max_model_input_size) sampler = GroupedBatchSampler(sampler=sampler, group_ids=groups, batch_size=params.batch_size) else: sampler = BatchSampler(sampler=sampler, batch_size=params.batch_size, drop_last=False) self.dataloader = DataLoader(dataset=dataset, batch_sampler=sampler, collate_fn=dataset.batch_sequences) self.temperature = params.temperature assert self.temperature > 0. self.alpha_ce = params.alpha_ce self.alpha_mlm = params.alpha_mlm self.alpha_clm = params.alpha_clm self.alpha_mse = params.alpha_mse self.alpha_cos = params.alpha_cos self.mlm = params.mlm if self.mlm: logger.info(f'Using MLM loss for LM step.') self.mlm_mask_prop = params.mlm_mask_prop assert 0.0 <= self.mlm_mask_prop <= 1.0 assert params.word_mask + params.word_keep + params.word_rand == 1.0 self.pred_probs = torch.FloatTensor([params.word_mask, params.word_keep, params.word_rand]) self.pred_probs = self.pred_probs.to(f'cuda:{params.local_rank}') if params.n_gpu > 0 else self.pred_probs self.token_probs = token_probs.to(f'cuda:{params.local_rank}') if params.n_gpu > 0 else token_probs if self.fp16: self.pred_probs = self.pred_probs.half() self.token_probs = self.token_probs.half() else: logger.info(f'Using CLM loss for LM step.') self.epoch = 0 self.n_iter = 0 self.n_total_iter = 0 self.n_sequences_epoch = 0 self.total_loss_epoch = 0 self.last_loss = 0 self.last_loss_ce = 0 self.last_loss_mlm = 0 self.last_loss_clm = 0 if self.alpha_mse > 0.: self.last_loss_mse = 0 if self.alpha_cos > 0.: self.last_loss_cos = 0 self.last_log = 0 self.ce_loss_fct = nn.KLDivLoss(reduction='batchmean') self.lm_loss_fct = nn.CrossEntropyLoss(ignore_index=-1) if self.alpha_mse > 0.: self.mse_loss_fct = nn.MSELoss(reduction='sum') if self.alpha_cos > 0.: self.cosine_loss_fct = nn.CosineEmbeddingLoss(reduction='mean') logger.info('--- Initializing model optimizer') assert params.gradient_accumulation_steps >= 1 self.num_steps_epoch = len(self.dataloader) num_train_optimization_steps = int(self.num_steps_epoch / params.gradient_accumulation_steps * params.n_epoch) + 1 no_decay = ['bias', 'LayerNorm.weight'] optimizer_grouped_parameters = [ {'params': [p for n, p in student.named_parameters() if not any(nd in n for nd in no_decay) and p.requires_grad], 'weight_decay': params.weight_decay}, {'params': [p for n, p in student.named_parameters() if any(nd in n for nd in no_decay) and p.requires_grad], 'weight_decay': 0.0} ] logger.info("------ Number of trainable parameters (student): %i" % sum([p.numel() for p in self.student.parameters() if p.requires_grad])) logger.info("------ Number of parameters (student): %i" % sum([p.numel() for p in self.student.parameters()])) self.optimizer = AdamW(optimizer_grouped_parameters, lr=params.learning_rate, eps=params.adam_epsilon, betas=(0.9, 0.98)) warmup_steps = math.ceil(num_train_optimization_steps * params.warmup_prop) self.scheduler = WarmupLinearSchedule(self.optimizer, warmup_steps=warmup_steps, t_total=num_train_optimization_steps) if self.fp16: try: from apex import amp except ImportError: raise ImportError("Please install apex from https://www.github.com/nvidia/apex to use fp16 training.") logger.info(f"Using fp16 training: {self.params.fp16_opt_level} level") self.student, self.optimizer = amp.initialize(self.student, self.optimizer, opt_level=self.params.fp16_opt_level) self.teacher = self.teacher.half() if self.multi_gpu: if self.fp16: from apex.parallel import DistributedDataParallel logger.info("Using apex.parallel.DistributedDataParallel for distributed training.") self.student = DistributedDataParallel(self.student) else: from torch.nn.parallel import DistributedDataParallel logger.info("Using nn.parallel.DistributedDataParallel for distributed training.") self.student = DistributedDataParallel(self.student, device_ids=[params.local_rank], output_device=params.local_rank, find_unused_parameters=True) self.is_master = params.is_master if self.is_master: logger.info('--- Initializing Tensorboard') self.tensorboard = SummaryWriter(log_dir=os.path.join(self.dump_path, 'log', 'train')) self.tensorboard.add_text(tag='config/training', text_string=str(self.params), global_step=0) self.tensorboard.add_text(tag='config/student', text_string=str(self.student_config), global_step=0) def prepare_batch_mlm(self, batch): """ Prepare the batch: from the token_ids and the lenghts, compute the attention mask and the masked label for MLM. Input: ------ batch: `Tuple` token_ids: `torch.tensor(bs, seq_length)` - The token ids for each of the sequence. It is padded. lengths: `torch.tensor(bs)` - The lengths of each of the sequences in the batch. Output: ------- token_ids: `torch.tensor(bs, seq_length)` - The token ids after the modifications for MLM. attn_mask: `torch.tensor(bs, seq_length)` - The attention mask for the self-attention. mlm_labels: `torch.tensor(bs, seq_length)` - The masked languge modeling labels. There is a -1 where there is nothing to predict. """ token_ids, lengths = batch token_ids, lengths = self.round_batch(x=token_ids, lengths=lengths) assert token_ids.size(0) == lengths.size(0) attn_mask = (torch.arange(token_ids.size(1), dtype=torch.long, device=lengths.device) < lengths[:, None]) bs, max_seq_len = token_ids.size() mlm_labels = token_ids.new(token_ids.size()).copy_(token_ids) x_prob = self.token_probs[token_ids.flatten()] n_tgt = math.ceil(self.mlm_mask_prop * lengths.sum().item()) tgt_ids = torch.multinomial(x_prob / x_prob.sum(), n_tgt, replacement=False) pred_mask = torch.zeros(bs * max_seq_len, dtype=torch.bool, device=token_ids.device) # previously `dtype=torch.uint8`, cf pytorch 1.2.0 compatibility pred_mask[tgt_ids] = 1 pred_mask = pred_mask.view(bs, max_seq_len) pred_mask[token_ids == self.params.special_tok_ids['pad_token']] = 0 # mask a number of words == 0 [8] (faster with fp16) if self.fp16: n1 = pred_mask.sum().item() if n1 > 8: pred_mask = pred_mask.view(-1) n2 = max(n1 % 8, 8 * (n1 // 8)) if n2 != n1: pred_mask[torch.nonzero(pred_mask).view(-1)[:n1-n2]] = 0 pred_mask = pred_mask.view(bs, max_seq_len) assert pred_mask.sum().item() % 8 == 0, pred_mask.sum().item() _token_ids_real = token_ids[pred_mask] _token_ids_rand = _token_ids_real.clone().random_(self.vocab_size) _token_ids_mask = _token_ids_real.clone().fill_(self.params.special_tok_ids['mask_token']) probs = torch.multinomial(self.pred_probs, len(_token_ids_real), replacement=True) _token_ids = _token_ids_mask * (probs == 0).long() + _token_ids_real * (probs == 1).long() + _token_ids_rand * (probs == 2).long() token_ids = token_ids.masked_scatter(pred_mask, _token_ids) mlm_labels[~pred_mask] = -1 # previously `mlm_labels[1-pred_mask] = -1`, cf pytorch 1.2.0 compatibility # sanity checks assert 0 <= token_ids.min() <= token_ids.max() < self.vocab_size return token_ids, attn_mask, mlm_labels def prepare_batch_clm(self, batch): """ Prepare the batch: from the token_ids and the lenghts, compute the attention mask and the labels for CLM. Input: ------ batch: `Tuple` token_ids: `torch.tensor(bs, seq_length)` - The token ids for each of the sequence. It is padded. lengths: `torch.tensor(bs)` - The lengths of each of the sequences in the batch. Output: ------- token_ids: `torch.tensor(bs, seq_length)` - The token ids after the modifications for MLM. attn_mask: `torch.tensor(bs, seq_length)` - The attention mask for the self-attention. clm_labels: `torch.tensor(bs, seq_length)` - The causal languge modeling labels. There is a -1 where there is nothing to predict. """ token_ids, lengths = batch token_ids, lengths = self.round_batch(x=token_ids, lengths=lengths) assert token_ids.size(0) == lengths.size(0) attn_mask = (torch.arange(token_ids.size(1), dtype=torch.long, device=lengths.device) < lengths[:, None]) clm_labels = token_ids.new(token_ids.size()).copy_(token_ids) clm_labels[~attn_mask] = -1 # previously `clm_labels[1-attn_mask] = -1`, cf pytorch 1.2.0 compatibility # sanity checks assert 0 <= token_ids.min() <= token_ids.max() < self.vocab_size return token_ids, attn_mask, clm_labels def round_batch(self, x: torch.tensor, lengths: torch.tensor): """ For float16 only. Sub-sample sentences in a batch, and add padding, so that each dimension is a multiple of 8. Input: ------ x: `torch.tensor(bs, seq_length)` - The token ids. lengths: `torch.tensor(bs, seq_length)` - The lengths of each of the sequence in the batch. Output: ------- x: `torch.tensor(new_bs, new_seq_length)` - The updated token ids. lengths: `torch.tensor(new_bs, new_seq_length)` - The updated lengths. """ if not self.fp16 or len(lengths) < 8: return x, lengths # number of sentences == 0 [8] bs1 = len(lengths) bs2 = 8 * (bs1 // 8) assert bs2 > 0 and bs2 % 8 == 0 if bs1 != bs2: idx = torch.randperm(bs1)[:bs2] lengths = lengths[idx] slen = lengths.max().item() x = x[idx, :slen] else: idx = None # sequence length == 0 [8] ml1 = x.size(1) if ml1 % 8 != 0: pad = 8 - (ml1 % 8) ml2 = ml1 + pad if self.mlm: pad_id = self.params.special_tok_ids['pad_token'] else: pad_id = self.params.special_tok_ids['unk_token'] padding_tensor = torch.zeros(bs2, pad, dtype=torch.long, device=x.device).fill_(pad_id) x = torch.cat([x, padding_tensor], 1) assert x.size() == (bs2, ml2) assert x.size(0) % 8 == 0 assert x.size(1) % 8 == 0 return x, lengths def train(self): """ The real training loop. """ if self.is_master: logger.info('Starting training') self.last_log = time.time() self.student.train() self.teacher.eval() for _ in range(self.params.n_epoch): if self.is_master: logger.info(f'--- Starting epoch {self.epoch}/{self.params.n_epoch-1}') if self.multi_gpu: torch.distributed.barrier() iter_bar = tqdm(self.dataloader, desc="-Iter", disable=self.params.local_rank not in [-1, 0]) for batch in iter_bar: if self.params.n_gpu > 0: batch = tuple(t.to(f'cuda:{self.params.local_rank}') for t in batch) if self.mlm: token_ids, attn_mask, lm_labels = self.prepare_batch_mlm(batch=batch) else: token_ids, attn_mask, lm_labels = self.prepare_batch_clm(batch=batch) self.step(input_ids=token_ids, attention_mask=attn_mask, lm_labels=lm_labels) iter_bar.update() iter_bar.set_postfix({'Last_loss': f'{self.last_loss:.2f}', 'Avg_cum_loss': f'{self.total_loss_epoch/self.n_iter:.2f}'}) iter_bar.close() if self.is_master: logger.info(f'--- Ending epoch {self.epoch}/{self.params.n_epoch-1}') self.end_epoch() if self.is_master: logger.info(f'Save very last checkpoint as `pytorch_model.bin`.') self.save_checkpoint(checkpoint_name=f'pytorch_model.bin') logger.info('Training is finished') def step(self, input_ids: torch.tensor, attention_mask: torch.tensor, lm_labels: torch.tensor): """ One optimization step: forward of student AND teacher, backward on the loss (for gradient accumulation), and possibly a parameter update (depending on the gradient accumulation). Input: ------ input_ids: `torch.tensor(bs, seq_length)` - The token ids. attention_mask: `torch.tensor(bs, seq_length)` - The attention mask for self attention. lm_labels: `torch.tensor(bs, seq_length)` - The language modeling labels (mlm labels for MLM and clm labels for CLM). """ if self.mlm: s_logits, s_hidden_states = self.student(input_ids=input_ids, attention_mask=attention_mask) # (bs, seq_length, voc_size) with torch.no_grad(): t_logits, t_hidden_states = self.teacher(input_ids=input_ids, attention_mask=attention_mask) # (bs, seq_length, voc_size) else: s_logits, _, s_hidden_states = self.student(input_ids=input_ids, attention_mask=None) # (bs, seq_length, voc_size) with torch.no_grad(): t_logits, _, t_hidden_states = self.teacher(input_ids=input_ids, attention_mask=None) # (bs, seq_length, voc_size) assert s_logits.size() == t_logits.size() #https://github.com/peterliht/knowledge-distillation-pytorch/blob/master/model/net.py#L100 #https://github.com/peterliht/knowledge-distillation-pytorch/issues/2 if self.params.restrict_ce_to_mask: mask = (lm_labels>-1).unsqueeze(-1).expand_as(s_logits) # (bs, seq_lenth, voc_size) else: mask = attention_mask.unsqueeze(-1).expand_as(s_logits) # (bs, seq_lenth, voc_size) s_logits_slct = torch.masked_select(s_logits, mask) # (bs * seq_length * voc_size) modulo the 1s in mask s_logits_slct = s_logits_slct.view(-1, s_logits.size(-1)) # (bs * seq_length, voc_size) modulo the 1s in mask t_logits_slct = torch.masked_select(t_logits, mask) # (bs * seq_length * voc_size) modulo the 1s in mask t_logits_slct = t_logits_slct.view(-1, s_logits.size(-1)) # (bs * seq_length, voc_size) modulo the 1s in mask assert t_logits_slct.size() == s_logits_slct.size() loss_ce = self.ce_loss_fct(F.log_softmax(s_logits_slct/self.temperature, dim=-1), F.softmax(t_logits_slct/self.temperature, dim=-1)) * (self.temperature)**2 loss = self.alpha_ce*loss_ce if self.alpha_mlm > 0.: loss_mlm = self.lm_loss_fct(s_logits.view(-1, s_logits.size(-1)), lm_labels.view(-1)) loss += self.alpha_mlm * loss_mlm if self.alpha_clm > 0.: shift_logits = s_logits[..., :-1, :].contiguous() shift_labels = lm_labels[..., 1:].contiguous() loss_clm = self.lm_loss_fct(shift_logits.view(-1, shift_logits.size(-1)), shift_labels.view(-1)) loss += self.alpha_clm * loss_clm if self.alpha_mse > 0.: loss_mse = self.mse_loss_fct(s_logits_slct, t_logits_slct)/s_logits_slct.size(0) # Reproducing batchmean reduction loss += self.alpha_mse * loss_mse if self.alpha_cos > 0.: s_hidden_states = s_hidden_states[-1] # (bs, seq_length, dim) t_hidden_states = t_hidden_states[-1] # (bs, seq_length, dim) mask = attention_mask.unsqueeze(-1).expand_as(s_hidden_states) # (bs, seq_length, dim) assert s_hidden_states.size() == t_hidden_states.size() dim = s_hidden_states.size(-1) s_hidden_states_slct = torch.masked_select(s_hidden_states, mask) # (bs * seq_length * dim) s_hidden_states_slct = s_hidden_states_slct.view(-1, dim) # (bs * seq_length, dim) t_hidden_states_slct = torch.masked_select(t_hidden_states, mask) # (bs * seq_length * dim) t_hidden_states_slct = t_hidden_states_slct.view(-1, dim) # (bs * seq_length, dim) target = s_hidden_states_slct.new(s_hidden_states_slct.size(0)).fill_(1) # (bs * seq_length,) loss_cos = self.cosine_loss_fct(s_hidden_states_slct, t_hidden_states_slct, target) loss += self.alpha_cos * loss_cos self.total_loss_epoch += loss.item() self.last_loss = loss.item() self.last_loss_ce = loss_ce.item() if self.alpha_mlm > 0.: self.last_loss_mlm = loss_mlm.item() if self.alpha_clm > 0.: self.last_loss_clm = loss_clm.item() if self.alpha_mse > 0.: self.last_loss_mse = loss_mse.item() if self.alpha_cos > 0.: self.last_loss_cos = loss_cos.item() self.optimize(loss) self.n_sequences_epoch += input_ids.size(0) def optimize(self, loss): """ Normalization on the loss (gradient accumulation or distributed training), followed by backward pass on the loss, possibly followed by a parameter update (depending on the gradient accumulation). Also update the metrics for tensorboard. """ # Check for NaN if (loss != loss).data.any(): logger.error('NaN detected') exit() if self.multi_gpu: loss = loss.mean() if self.params.gradient_accumulation_steps > 1: loss = loss / self.params.gradient_accumulation_steps if self.fp16: from apex import amp with amp.scale_loss(loss, self.optimizer) as scaled_loss: scaled_loss.backward() else: loss.backward() self.iter() if self.n_iter % self.params.gradient_accumulation_steps == 0: if self.fp16: torch.nn.utils.clip_grad_norm_(amp.master_params(self.optimizer), self.params.max_grad_norm) else: torch.nn.utils.clip_grad_norm_(self.student.parameters(), self.params.max_grad_norm) self.optimizer.step() self.optimizer.zero_grad() self.scheduler.step() def iter(self): """ Update global counts, write to tensorboard and save checkpoint. """ self.n_iter += 1 self.n_total_iter += 1 if self.n_total_iter % self.params.log_interval == 0: self.log_tensorboard() self.last_log = time.time() if self.n_total_iter % self.params.checkpoint_interval == 0: self.save_checkpoint()
def log_tensorboard(self): """ Log into tensorboard. Only by the master process. """ if not self.is_master: return for param_name, param in self.student.named_parameters(): self.tensorboard.add_scalar(tag='parameter_mean/' + param_name, scalar_value=param.data.mean(), global_step=self.n_total_iter) self.tensorboard.add_scalar(tag='parameter_std/' + param_name, scalar_value=param.data.std(), global_step=self.n_total_iter) if param.grad is None: continue self.tensorboard.add_scalar(tag="grad_mean/" + param_name, scalar_value=param.grad.data.mean(),global_step=self.n_total_iter) self.tensorboard.add_scalar(tag="grad_std/" + param_name, scalar_value=param.grad.data.std(), global_step=self.n_total_iter) self.tensorboard.add_scalar(tag="losses/cum_avg_loss_epoch", scalar_value=self.total_loss_epoch/self.n_iter, global_step=self.n_total_iter) self.tensorboard.add_scalar(tag="losses/loss", scalar_value=self.last_loss, global_step=self.n_total_iter) self.tensorboard.add_scalar(tag="losses/loss_ce", scalar_value=self.last_loss_ce, global_step=self.n_total_iter) if self.alpha_mlm > 0.: self.tensorboard.add_scalar(tag="losses/loss_mlm", scalar_value=self.last_loss_mlm, global_step=self.n_total_iter) if self.alpha_clm > 0.: self.tensorboard.add_scalar(tag="losses/loss_clm", scalar_value=self.last_loss_clm, global_step=self.n_total_iter) if self.alpha_mse > 0.: self.tensorboard.add_scalar(tag="losses/loss_mse", scalar_value=self.last_loss_mse, global_step=self.n_total_iter) if self.alpha_cos > 0.: self.tensorboard.add_scalar(tag="losses/loss_cos", scalar_value=self.last_loss_cos, global_step=self.n_total_iter) self.tensorboard.add_scalar(tag="learning_rate/lr", scalar_value=self.scheduler.get_lr()[0], global_step=self.n_total_iter) self.tensorboard.add_scalar(tag="global/memory_usage", scalar_value=psutil.virtual_memory()._asdict()['used']/1_000_000, global_step=self.n_total_iter) self.tensorboard.add_scalar(tag="global/speed", scalar_value=time.time()-self.last_log, global_step=self.n_total_iter) def end_epoch(self): """ Finally arrived at the end of epoch (full pass on dataset). Do some tensorboard logging and checkpoint saving. """ logger.info(f'{self.n_sequences_epoch} sequences have been trained during this epoch.') if self.is_master: self.save_checkpoint(checkpoint_name=f'model_epoch_{self.epoch}.pth') self.tensorboard.add_scalar(tag='epoch/loss', scalar_value=self.total_loss_epoch/self.n_iter, global_step=self.epoch) self.epoch += 1 self.n_sequences_epoch = 0 self.n_iter = 0 self.total_loss_epoch = 0 def save_checkpoint(self, checkpoint_name: str = 'checkpoint.pth'): """ Save the current state. Only by the master process. """ if not self.is_master: return mdl_to_save = self.student.module if hasattr(self.student, 'module') else self.student mdl_to_save.config.save_pretrained(self.dump_path) state_dict = mdl_to_save.state_dict() torch.save(state_dict, os.path.join(self.dump_path, checkpoint_name))
UniLogger.py
# -*- coding: utf-8 -*- # # Author: Timur Gilmullin # This module initialize standard python logging system. import sys import logging.handlers # initialize Main Parent Logger: UniLogger = logging.getLogger("UniLogger") formatString = "%(filename)-20sL:%(lineno)-5d%(levelname)-8s[%(asctime)s] %(message)s" formatter = logging.Formatter(formatString) sys.stderr = sys.stdout def SetLevel(vLevel='ERROR'): """ This procedure setting up UniLogger verbosity level. """ UniLogger.level = logging.NOTSET if isinstance(vLevel, str): if vLevel == '5' or vLevel.upper() == 'CRITICAL': UniLogger.level = logging.CRITICAL elif vLevel == '4' or vLevel.upper() == 'ERROR': UniLogger.level = logging.ERROR elif vLevel == '3' or vLevel.upper() == 'WARNING': UniLogger.level = logging.WARNING elif vLevel == '2' or vLevel.upper() == 'INFO': UniLogger.level = logging.INFO elif vLevel == '1' or vLevel.upper() == 'DEBUG': UniLogger.level = logging.DEBUG class LevelFilter(logging.Filter):
def EnableLogger(logFile, parentHandler=UniLogger, useFormat=formatter): """ Adding new file logger with rotation. """ # logHandler = logging.FileHandler(logFile) maxSizeBytes = 50 * 1024 * 1024 # 5Mb log rotate by default logHandler = logging.handlers.RotatingFileHandler(logFile, encoding="UTF-8", maxBytes=maxSizeBytes, backupCount=4) logHandler.level = logging.DEBUG # set up DEBUG verbosity level by default for file logging logHandler.addFilter(LevelFilter(logging.DEBUG)) if useFormat: logHandler.setFormatter(useFormat) else: logHandler.setFormatter(formatter) parentHandler.addHandler(logHandler) return logHandler def DisableLogger(handler, parentHandler=UniLogger): """ Disable given file logger. """ if handler: handler.flush() handler.close() if handler in parentHandler.handlers: parentHandler.removeHandler(handler) # --- Main init: SetLevel('DEBUG') # set up DEBUG verbosity level by default for UniLogger streamHandler = logging.StreamHandler() # initialize STDOUT UniLogger streamHandler.setFormatter(formatter) # set formatter for STDOUT UniLogger streamHandler.level = logging.INFO # set up INFO verbosity level by default for STDOUT UniLogger UniLogger.addHandler(streamHandler) # adding STDOUT UniLogger handler to Parent UniLogger # fileLogHandler = EnableLogger(logFile='log.txt', parentHandler=UniLogger, useFormat=formatter) # add logging to file sepWide = '-' * 120 # long-long log separator sepLong = '-' * 80 # long log separator sepShort = '-' * 40 # short log separator sepLine = '=--=' * 20 # log part separator
""" Class using to set up log level filtering. """ def __init__(self, level): super().__init__() self.level = level def filter(self, record): return record.levelno >= self.level
errors.go
package file_reader import ( "fmt" "path/filepath" "strings" "github.com/werf/werf/pkg/giterminism_manager/errors" ) type UntrackedFilesError FileReaderError type UncommittedFilesError FileReaderError type FileNotAcceptedError FileReaderError type FileNotFoundInProjectDirectoryError FileReaderError type FileNotFoundInProjectRepositoryError FileReaderError type FileReaderError struct { error } func IsFileNotFoundInProjectDirectoryError(err error) bool
func (r FileReader) NewFileNotFoundInProjectDirectoryError(relPath string) error { return FileNotFoundInProjectDirectoryError{errors.NewError(fmt.Sprintf("the file %q not found in the project directory", filepath.ToSlash(relPath)))} } func (r FileReader) NewFileNotFoundInProjectRepositoryError(relPath string) error { return FileNotFoundInProjectRepositoryError{errors.NewError(fmt.Sprintf("the file %q not found in the project git repository", filepath.ToSlash(relPath)))} } func (r FileReader) NewSubmoduleAddedAndNotCommittedError(submodulePath string) error { errorMsg := fmt.Sprintf("the added submodule %q must be committed", filepath.ToSlash(submodulePath)) return r.uncommittedErrorBase(errorMsg, filepath.ToSlash(submodulePath)) } func (r FileReader) NewSubmoduleDeletedError(submodulePath string) error { errorMsg := fmt.Sprintf("the deleted submodule %q must be committed", filepath.ToSlash(submodulePath)) return r.uncommittedErrorBase(errorMsg, filepath.ToSlash(submodulePath)) } func (r FileReader) NewSubmoduleHasUntrackedChangesError(submodulePath string) error { errorMsg := fmt.Sprintf("the submodule %q has untracked changes that must be discarded or committed (do not forget to push new changes to the submodule remote)", filepath.ToSlash(submodulePath)) return UntrackedFilesError{errors.NewError(errorMsg)} } func (r FileReader) NewSubmoduleHasUncommittedChangesError(submodulePath string) error { errorMsg := fmt.Sprintf("the submodule %q has uncommitted changes that must be discarded or committed (do not forget to push new changes to the submodule remote)", filepath.ToSlash(submodulePath)) return UncommittedFilesError{fmt.Errorf("%s", errorMsg)} } func (r FileReader) NewSubmoduleCommitChangedError(submodulePath string) error { errorMsg := fmt.Sprintf("the submodule %q is not clean and %s. Do not forget to push the current commit to the submodule remote if this commit exists only locally", filepath.ToSlash(submodulePath), r.uncommittedUntrackedExpectedAction()) return r.uncommittedErrorBase(errorMsg, filepath.ToSlash(submodulePath)) } func (r FileReader) NewUntrackedFilesError(relPaths ...string) error { var errorMsg string if len(relPaths) == 1 { errorMsg = fmt.Sprintf("the untracked file %q %s", filepath.ToSlash(relPaths[0]), r.uncommittedUntrackedExpectedAction()) } else if len(relPaths) > 1 { errorMsg = fmt.Sprintf("the following untracked files %s:\n\n%s", r.uncommittedUntrackedExpectedAction(), prepareListOfFilesString(relPaths)) } else { panic("unexpected condition") } return UntrackedFilesError{errors.NewError(errorMsg)} } func (r FileReader) NewUncommittedFilesError(relPaths ...string) error { var errorMsg string if len(relPaths) == 1 { errorMsg = fmt.Sprintf("the file %q %s", filepath.ToSlash(relPaths[0]), r.uncommittedUntrackedExpectedAction()) } else if len(relPaths) > 1 { errorMsg = fmt.Sprintf("the following files %s:\n\n%s", r.uncommittedUntrackedExpectedAction(), prepareListOfFilesString(relPaths)) } else { panic("unexpected condition") } return r.uncommittedErrorBase(errorMsg, strings.Join(formatFilePathList(relPaths), " ")) } func (r FileReader) uncommittedErrorBase(errorMsg string, gitAddArg string) error { if r.sharedOptions.Dev() { errorMsg = fmt.Sprintf(`%s To stage the changes use the following command: "git add %s".`, errorMsg, gitAddArg) } else { errorMsg = fmt.Sprintf(`%s You may be interested in the development mode (activated by the --dev option), which allows working with project files without doing redundant commits during debugging and development. Two development modes are supported (controlled with the --dev-mode option): - simple (default): for working with the worktree state of the git repository; - strict: for working with the index state of the git repository.`, errorMsg) } return UncommittedFilesError{errors.NewError(errorMsg)} } func (r FileReader) uncommittedUntrackedExpectedAction() string { if r.sharedOptions.Dev() { return "must be staged" } else { return "must be committed" } } func prepareListOfFilesString(paths []string) string { return " - " + strings.Join(formatFilePathList(paths), "\n - ") } func formatFilePathList(paths []string) []string { var result []string for _, path := range paths { result = append(result, filepath.ToSlash(path)) } return result }
{ switch err.(type) { case FileNotFoundInProjectDirectoryError: return true default: return false } }
k10app.go
// Copyright (c) arkade author(s) 2022. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. // kasten contains a suite of Sponsored Apps for arkade package kasten import ( "fmt" "strconv" "strings" "github.com/alexellis/arkade/pkg/apps" "github.com/alexellis/arkade/pkg/config" "github.com/alexellis/arkade/pkg/types" "github.com/spf13/cobra" ) func MakeInstallK10() *cobra.Command { var k10cmd = &cobra.Command{ Use: "k10", Short: "Install K10", Long: `Kasten K10 by Veeam is purpose-built for Kubernetes backup and restore. Note: K10 performs best if your cluster supports a CSI driver, see the following command: kubectl get storageclasses `, Example: ` arkade install k10 arkade install k10 --help arkade install k10 \ --set eula.accept=true \ --set clusterName=my-k10 \ --set prometheus.server.enabled=false See also: all helm chart options: https://docs.kasten.io/latest/install/advanced.html#complete-list-of-k10-helm-options`, SilenceUsage: true, } k10cmd.Flags().StringP("namespace", "n", "kasten-io", "The namespace used for installation") k10cmd.Flags().Bool("update-repo", true, "Update the helm repo") k10cmd.Flags().Bool("eula", false, "Accept the EULA") k10cmd.Flags().Bool("token-auth", false, "Change to token mode for authentication") k10cmd.Flags().Bool("prometheus", true, "Enable Prometheus server") k10cmd.Flags().Bool("grafana", true, "Enable Grafana server") k10cmd.Flags().StringArray("set", []string{}, "Use custom flags or override existing flags \n(example --set image=org/repo:tag)") k10cmd.PreRunE = func(cmd *cobra.Command, args []string) error { if _, err := cmd.Flags().GetBool("eula"); err != nil { if err != nil { return fmt.Errorf("error with \"eula\" flag %w", err) } } if _, err := cmd.Flags().GetBool("prometheus"); err != nil { if err != nil { return fmt.Errorf("error with \"prometheus\" flag %w", err) } } if _, err := cmd.Flags().GetBool("grafana"); err != nil { if err != nil { return fmt.Errorf("error with \"grafana\" flag %w", err) } } if _, err := cmd.Flags().GetBool("token-auth"); err != nil { if err != nil { return fmt.Errorf("error with \"token-auth\" flag %w", err) } } return nil } k10cmd.RunE = func(command *cobra.Command, args []string) error { kubeConfigPath, _ := command.Flags().GetString("kubeconfig") if err := config.SetKubeconfig(kubeConfigPath); err != nil { return err } eula, _ := command.Flags().GetBool("eula") tokenAuth, _ := command.Flags().GetBool("token-auth") grafana, _ := command.Flags().GetBool("grafana") prometheus, _ := command.Flags().GetBool("prometheus") wait, _ := command.Flags().GetBool("wait") namespace, _ := command.Flags().GetString("namespace") overrides := map[string]string{ "prometheus.server.enabled": strconv.FormatBool(prometheus), "eula.accept": strconv.FormatBool(eula), "auth.tokenAuth.enabled": strconv.FormatBool(tokenAuth), "grafana.enabled": strconv.FormatBool(grafana), } if command.Flags().Changed("cluster-name") { v, _ := command.Flags().GetString("cluster-name") overrides["clusterName"] = v } customFlags, _ := command.Flags().GetStringArray("set") if err := mergeFlags(overrides, customFlags); err != nil { return err } k10cmdOptions := types.DefaultInstallOptions(). WithNamespace(namespace). WithHelmRepo("kasten/k10"). WithHelmURL("https://charts.kasten.io/"). WithOverrides(overrides). WithWait(wait). WithKubeconfigPath(kubeConfigPath) _, err := apps.MakeInstallChart(k10cmdOptions) if err != nil { return err } fmt.Println(k10InstallCmd) return nil } return k10cmd } const k10InfoMsg = `# The K10 app has been installed # You may also need to install pre-requisites and configure a # CSI driver for your cluster. https://docs.kasten.io/latest/install/storage.html # The app may take a few moments to come up, run the following to # wait for it: kubectl rollout status -n kasten-io deploy/frontend-svc # Then access the dashboard via: kubectl -n kasten-io port-forward service/gateway 8080:8000 http://127.0.0.1:8080/k10/#/ # Find out your next steps here: https://docs.kasten.io/latest/install/install.html` const k10InstallCmd = `======================================================================= = k10 has been installed. = =======================================================================` + "\n\n" + k10InfoMsg + "\n\n" func mergeFlags(existingMap map[string]string, setOverrides []string) error { for _, setOverride := range setOverrides { flag := strings.Split(setOverride, "=") if len(flag) != 2 { return fmt.Errorf("incorrect format for custom flag `%s`", setOverride) } existingMap[flag[0]] = flag[1] }
}
return nil
sectionLists.js
var app = new Vue({ el:'#section-list', data:{ sectionList: [], keyword: "" }, methods:{ sectionDetails: function(item_id){ window.location.href = '/wechat/course/sectionIntroduction?item_id=' + item_id; }, index: function() { window.location.href = "/wechat"; }, myCenter: function() { window.location.href = "/wechat/center/userCenter"; }, top: function() { $('body,html').animate({scrollTop:0},300); } } }) var isNeedRefresh = false; var page_num = 1; var data_order = 'create_time'; $(function() { var course_id = $.getUrlParam('course_id'); getSectionList(course_id,data_order); $(window).scroll(function(){ var scrollTop = $(this).scrollTop(); var scrollHeight = $(document).height(); var windowHeight = $(this).height(); if(!isNeedRefresh && (scrollHeight - scrollTop - windowHeight <= 25)){ isNeedRefresh = true; page_num = page_num + 1; getSectionList(course_id,data_order); $(window).scrollTop(0); } }); $("img.icon-search").on("click", function(event) { event.preventDefault(); var keyword = $("input[name=keyword]").val(); app.keyword = keyword; getSectionList(course_id,data_order); }); $('.sellect-label').on('click', function(event) { event.preventDefault(); /* Act on the event */ page_num = 1; isNeedRefresh = false; data_order = $(this).attr("data-order"); $(".sellect-label").each(function() { if($(this).hasClass("active")) { $(this).removeClass("active"); } }); $(this).addClass("active"); var keyword = $("input[name=keyword]").val(); app.keyword = keyword; getSectionList(course_id,data_order); }); }); function
(course_id,data_order){ $.ajax({ url:urlCourseItemList, type:"POST", data:{ course_id: course_id, order: data_order, keyword: app.keyword, page_num: page_num }, dataType:"JSON", success:function(data){ if(data.code==200){ if(!isNullOrEmpty(data.data.list)) { if(page_num == 1){ app.sectionList = data.data.list; }else{ app.sectionList = app.sectionList.concat(data.data.list); } }else{ isNeedRefresh = true; } } } }) }
getSectionList
gpu_pwr.py
import pandas import pdb from datetime import datetime import matplotlib import numpy as np import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import glob import sys from matplotlib.ticker import MultipleLocator testcase = sys.argv[1] # K80_vgg19_32 print(testcase) base_dir = '/scratch/li.baol/GPU_pwr_meas/tensorflow/round1/' log_dir = base_dir + testcase + '_*/' # /scratch/li.baol/GPU_pwr_meas/pytorch/K80_vgg19_32_*/ dirs = glob.glob(log_dir) dirs.sort() pwr_all = [] avg_all = [] for tc in dirs: model = tc.split('/')[5+1] files = glob.glob(tc + "sample*.csv") files.sort() avg_pwr = [0] * (len(files) + 1)
minute = int(fil.split('/')[6+1].split('_')[1].split('.')[0]) try: # in case the file is empty data = pandas.read_csv(file_path) pwr = data[data.columns[2]].tolist() pwr_array = np.asarray(pwr) if (len(pwr) == 0): avg_pwr[minute] = 0 else: avg_pwr[minute] = np.average(pwr_array) except pandas.errors.EmptyDataError: avg_pwr[minute] = 0 pass pwr_all.append(avg_pwr) avg_pwr_filter = [i for i in avg_pwr if i > 10] # remove power measurements below 10W avg_all.append(sum(avg_pwr_filter) / len(avg_pwr_filter)) #------------- plot ---------------# width = 0.1 fig, axs = plt.subplots(1, 1, gridspec_kw={'hspace': 0, 'wspace': 0}, figsize=(12,5)) fig.suptitle(testcase + " GPU power (W) during training epochs") for i in range(len(pwr_all)): x = np.arange(len(pwr_all[i])) axs.scatter(x, pwr_all[i], label = str(i)) axs.set_xlabel('# of sample with 10s interval') axs.set_ylabel('power(W)') #axs.set_yticks(minor=True) axs.get_yaxis().set_minor_locator(MultipleLocator(5)) axs.legend() axs.grid(which='both', axis='y', linestyle=':', color='black') pwr = int(sum(avg_all) / len(avg_all)) plt.savefig(base_dir + "png/" + testcase + '_pwr' + str(pwr) + ".png") df = pandas.DataFrame(avg_all, columns=["power(W)"]) df.to_csv(base_dir + 'csv/' + testcase + '.csv', index=False)
for fil in files: file_path = fil
runtests.py
import sys try: from django.conf import settings settings.configure( DEBUG=True, USE_TZ=True, DATABASES={ "default": { "ENGINE": "django.db.backends.sqlite3", } }, ROOT_URLCONF="taggit_serializer.urls", INSTALLED_APPS=[ "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sites", "rest_framework", "taggit", 'nose', "django_nose", "taggit_serializer", "tests", ], SITE_ID=1, NOSE_ARGS=['-s'], MIDDLEWARE_CLASSES=[], ) try: import django setup = django.setup except AttributeError: pass else: setup() from django_nose import NoseTestSuiteRunner except ImportError: import traceback traceback.print_exc() raise ImportError("To fix this error, run: pip install -r requirements-test.txt") def run_tests(*test_args):
if __name__ == '__main__': run_tests(*sys.argv[1:])
if not test_args: test_args = ['tests'] # Run tests test_runner = NoseTestSuiteRunner(verbosity=0) failures = test_runner.run_tests(test_args) if failures: sys.exit(failures)
start.js
var sys = require('sys') var exec = require('child_process').exec; function
(error, stdout, stderr) {sys.puts(stdout)} var child = exec("start.bat", puts); // redirects output child.stdout.pipe(process.stdout); child.stderr.pipe(process.stderr);
puts
grr_chipsec_test.py
#!/usr/bin/env python """Test Chipsec client actions.""" import collections import sys import mock from chipsec.helper import oshelper from grr.client import vfs from grr.client.components.chipsec_support.actions import chipsec_types from grr.lib import flags from grr.test_lib import client_test_lib from grr.test_lib import test_lib class MockUnknownChipsetError(RuntimeError): pass class MockSPI(mock.MagicMock): def get_SPI_region(self, unused_region): # pylint: disable=invalid-name return (0, 0xffff, 0) def read_spi(self, unused_offset, size): return "\xff" * size
class UnsupportedChipset(mock.MagicMock): def init(self, unused_platform, unused_load_driver): msg = "Unsupported Platform: VID = 0x0000, DID = 0x0000" raise MockUnknownChipsetError(msg) class FailingOsHelperChipset(mock.MagicMock): def init(self, unused_platform, unused_load_driver): msg = "Unable to open /sys/bus/pci/devices/0000:00:00.0/config" raise oshelper.OsHelperError(msg, -1) class GRRChipsecTest(client_test_lib.EmptyActionTest): """Generic test class for GRR-Chipsec actions.""" def setUp(self): # Mock the interface for Chipsec self.chipsec_mock = mock.MagicMock() self.chipsec_mock.chipset = mock.MagicMock() self.chipsec_mock.chipset.UnknownChipsetError = MockUnknownChipsetError self.chipsec_mock.hal = mock.MagicMock() self.chipsec_mock.logger = mock.MagicMock() mock_modules = { "chipsec": self.chipsec_mock, "chipsec.hal": self.chipsec_mock.hal, } self.chipsec_patch = mock.patch.dict(sys.modules, mock_modules) self.chipsec_patch.start() # Import the ClientAction to test with the Chipsec mock in place. # pylint: disable=g-import-not-at-top, unused-variable from grr.client.components.chipsec_support.actions import grr_chipsec # pylint: enable=g-import-not-at-top, unused-variable # Keep a reference to the module so child classes may mock its content. self.grr_chipsec_module = grr_chipsec self.grr_chipsec_module.chipset = self.chipsec_mock.chipset self.grr_chipsec_module.logger = self.chipsec_mock.logger def tearDown(self): self.chipsec_patch.stop() class TestChipsecDumpFlashImage(GRRChipsecTest): """Test the client dump flash image action.""" def setUp(self): super(TestChipsecDumpFlashImage, self).setUp() self.chipsec_mock.hal.spi = mock.MagicMock() self.chipsec_mock.hal.spi.SPI = MockSPI self.grr_chipsec_module.spi = self.chipsec_mock.hal.spi def testDumpFlashImage(self): """Test the basic dump.""" args = chipsec_types.DumpFlashImageRequest() result = self.RunAction(self.grr_chipsec_module.DumpFlashImage, args)[0] with vfs.VFSOpen(result.path) as image: self.assertEqual(image.read(0x20000), "\xff" * 0x10000) def testDumpFlashImageVerbose(self): """Test the basic dump with the verbose mode enabled.""" args = chipsec_types.DumpFlashImageRequest(log_level=1) result = self.RunAction(self.grr_chipsec_module.DumpFlashImage, args)[0] with vfs.VFSOpen(result.path) as image: self.assertEqual(image.read(0x20000), "\xff" * 0x10000) self.assertNotEqual(self.chipsec_mock.logger.logger.call_count, 0) def testDumpFlashImageUnknownChipset(self): """By default, if the chipset is unknown, no exception is raised.""" self.chipsec_mock.chipset.cs = UnsupportedChipset args = chipsec_types.DumpFlashImageRequest() self.RunAction(self.grr_chipsec_module.DumpFlashImage, args) def testDumpFlashImageUnknownChipsetVerbose(self): """Test unknown chipset with verbose mode. If the chipset is unknown but verbose enabled, no exception is raised and at least one response should be returned with non-empty logs. """ self.chipsec_mock.chipset.cs = UnsupportedChipset args = chipsec_types.DumpFlashImageRequest(log_level=1) self.RunAction(self.grr_chipsec_module.DumpFlashImage, args) self.assertNotEquals(self.chipsec_mock.logger.logger.call_count, 0) self.assertGreaterEqual(len(self.results), 1) self.assertNotEquals(len(self.results[0].logs), 0) self.assertEquals(self.results[0].path.path, "") def testDumpFlashImageOsHelperErrorChipset(self): """If an exception is raised by the helper layer, handle it.""" self.chipsec_mock.chipset.cs = FailingOsHelperChipset args = chipsec_types.DumpFlashImageRequest() self.RunAction(self.grr_chipsec_module.DumpFlashImage, args) class MockACPI(object): def __init__(self, unused_chipset): self.tableList = { # pylint: disable=invalid-name "DSDT": [(0xAABBCCDDEEFF0011)], "FACP": [(0x1100FFEEDDCCBBAA)], "XSDT": [(0x1122334455667788)], "SSDT": [(0x1234567890ABCDEF), (0x2234567890ABCDEF), (0x3234567890ABCDEF)] } # Mimic the behaviour of tableList in Chipsec # pylint: disable=invalid-name self.tableList = collections.defaultdict(list, self.tableList) # pylint: enable=invalid-name # key: header, content self.table_content = { 0xAABBCCDDEEFF0011: ("\xFF" * 0xFF, "\xEE" * 0xFF), 0x1100FFEEDDCCBBAA: ("\xEE" * 0xFF, "\xFF" * 0xFF), 0x1122334455667788: ("\xAB" * 0xFF, "\xCD" * 0xFF), 0x1234567890ABCDEF: ("\xEF" * 0xFF, "\xFE" * 0xFF), 0x2234567890ABCDEF: ("\xDC" * 0xFF, "\xBA" * 0xFF), 0x3234567890ABCDEF: ("\xAA" * 0xFF, "\xBB" * 0xFF) } def get_ACPI_table(self, name): # pylint: disable=invalid-name return [self.table_content[address] for address in self.tableList[name]] class MockACPIReadingRestrictedArea(object): def __init__(self, unused_chipset): # Simulate /dev/mem error raise OSError("Operation not permitted") def get_ACPI_table(self, unused_name): # pylint: disable=invalid-name return [] class TestDumpACPITable(GRRChipsecTest): def setUp(self): super(TestDumpACPITable, self).setUp() self.chipsec_mock.hal.acpi = mock.MagicMock() self.chipsec_mock.hal.acpi.ACPI = MockACPI self.grr_chipsec_module.acpi = self.chipsec_mock.hal.acpi def testDumpValidSingleACPITable(self): """Tests basic valid ACPI table dump.""" args = chipsec_types.DumpACPITableRequest(table_signature="DSDT") result = self.RunAction(self.grr_chipsec_module.DumpACPITable, args)[0] self.assertEqual(len(result.acpi_tables), 1) self.assertEqual(result.acpi_tables[0].table_address, 0xAABBCCDDEEFF0011) self.assertEqual(result.acpi_tables[0].table_blob, "\xFF" * 0xFF + "\xEE" * 0xFF) def testDumpValidMultipleACPITables(self): """Tests valid ACPI table dump that would yield several tables.""" args = chipsec_types.DumpACPITableRequest(table_signature="SSDT") result = self.RunAction(self.grr_chipsec_module.DumpACPITable, args)[0] self.assertEqual(len(result.acpi_tables), 3) self.assertEqual(result.acpi_tables[0].table_address, 0x1234567890ABCDEF) self.assertEqual(result.acpi_tables[0].table_blob, "\xEF" * 0xFF + "\xFE" * 0xFF) self.assertEqual(result.acpi_tables[1].table_address, 0x2234567890ABCDEF) self.assertEqual(result.acpi_tables[1].table_blob, "\xDC" * 0xFF + "\xBA" * 0xFF) self.assertEqual(result.acpi_tables[2].table_address, 0x3234567890ABCDEF) self.assertEqual(result.acpi_tables[2].table_blob, "\xAA" * 0xFF + "\xBB" * 0xFF) def testDumpValidSingleACPITableVerbose(self): """Tests valid ACPI table dump with verbose mode enabled.""" args = chipsec_types.DumpACPITableRequest( table_signature="XSDT", logging=True) result = self.RunAction(self.grr_chipsec_module.DumpACPITable, args)[0] self.assertEqual(result.acpi_tables[0].table_address, 0x1122334455667788) self.assertEqual(result.acpi_tables[0].table_blob, "\xAB" * 0xFF + "\xCD" * 0xFF) self.assertNotEquals(self.chipsec_mock.logger.logger.call_count, 0) def testDumpInvalidACPITable(self): """Tests dumping invalid ACPI table.""" args = chipsec_types.DumpACPITableRequest(table_signature="INVALID_TABLE") result = self.RunAction(self.grr_chipsec_module.DumpACPITable, args)[0] self.assertNotEquals(len(result.logs), 0) def testDumpACPITableUnknownChipset(self): """By default, if the chipset is unknown, no exception is raised.""" self.chipsec_mock.chipset.cs = UnsupportedChipset args = chipsec_types.DumpACPITableRequest(table_signature="FACP") self.RunAction(self.grr_chipsec_module.DumpACPITable, args) def testDumpACPITableUnknownChipsetVerbose(self): """Tests unknown chipset with verbose mode. If the chipset is unknown but verbose enabled, no exception is raised and at least one response should be returned with non-empty logs. """ self.chipsec_mock.chipset.cs = UnsupportedChipset args = chipsec_types.DumpACPITableRequest( table_signature="FACP", logging=True) self.RunAction(self.grr_chipsec_module.DumpACPITable, args) self.assertNotEquals(self.chipsec_mock.logger.logger.call_count, 0) self.assertGreaterEqual(len(self.results), 1) self.assertNotEquals(len(self.results[0].logs), 0) def testDumpACPITableTriggeringDevMemError(self): """Tests the condition where OSError is triggered due to using /dev/mem. No exception should be raised, and the log describing the error should be returned. """ self.chipsec_mock.acpi.ACPI = MockACPIReadingRestrictedArea args = chipsec_types.DumpACPITableRequest(table_signature="FACP") self.RunAction(self.grr_chipsec_module.DumpACPITable, args) self.assertGreaterEqual(len(self.results), 1) self.assertNotEquals(len(self.results[0].logs), 0) def main(argv): test_lib.main(argv) if __name__ == "__main__": flags.StartMain(main)
trait-pointers.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // min-lldb-version: 310 // compile-flags:-g // gdb-command:run // lldb-command:run #![allow(unused_variables)] #![feature(box_syntax)] #![omit_gdb_pretty_printer_section] trait Trait { fn method(&self) -> int { 0 } } struct
{ a: int, b: f64 } impl Trait for Struct {} // There is no real test here yet. Just make sure that it compiles without crashing. fn main() { let stack_struct = Struct { a:0, b: 1.0 }; let reference: &Trait = &stack_struct as &Trait; let unique: Box<Trait> = box Struct { a:2, b: 3.0 } as Box<Trait>; }
Struct
helpers.test.ts
import { findElementByType } from '../../util/helpers'; import { sdpStereoHack, sdpMediaOrderHack, sdpBitrateHack, getDevices, assureDeviceId, getBrowserInfo, getWebRTCInfo, getWebRTCSupportedBrowserList, SUPPORTED_WEBRTC, } from '../../webrtc/helpers'; describe('Helpers browser functions', () => { describe('findElementByType', () => { it('should return null if there is no document global object', () => { document = null; expect(findElementByType('fakeElement')).toEqual(null); }); it('should select the DOM element by ID', () => { const fake = document.createElement('div'); fake.id = 'fakeElement'; document.getElementById = jest.fn().mockReturnValue(fake); expect(findElementByType('fakeElement')).toEqual(fake); }); it('should return null if the DOM element does not exists', () => { const fake = document.createElement('div'); fake.id = 'fakeElement'; // @ts-ignore document.getElementById.mockRestore(); expect(findElementByType('fake-Element')).toEqual(null); }); it('should select the DOM element by a Function', () => { const fake = document.createElement('div'); fake.id = 'fakeElement'; expect(findElementByType(jest.fn().mockReturnValue(fake))).toEqual(fake); }); }); describe('sdpStereoHack', () => { const SDP_OPUS_STEREO = 'v=0\r\no=- 135160591336882782 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE audio video\r\na=msid-semantic: WMS 381b9efc-7cf5-45bb-8f39-c06558b288de\r\nm=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 0 8 106 105 13 110 112 113 126\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:Y5Zy\r\na=ice-pwd:yQLVrXgG+irP0tgLLr4ZjQb5\r\na=ice-options:trickle\r\na=fingerprint:sha-256 45:ED:86:FB:EB:FE:21:20:62:C4:07:81:AA:B8:BC:87:60:CC:2B:54:CE:D5:F0:16:93:C4:61:23:28:59:DF:8B\r\na=setup:actpass\r\na=mid:audio\r\na=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\na=sendrecv\r\na=rtcp-mux\r\na=rtpmap:111 opus/48000/2\r\na=rtcp-fb:111 transport-cc\r\na=fmtp:111 minptime=10;useinbandfec=1; stereo=1; sprop-stereo=1\r\na=rtpmap:103 ISAC/16000\r\na=rtpmap:104 ISAC/32000\r\na=rtpmap:9 G722/8000\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:106 CN/32000\r\na=rtpmap:105 CN/16000\r\na=rtpmap:13 CN/8000\r\na=rtpmap:110 telephone-event/48000\r\na=rtpmap:112 telephone-event/32000\r\na=rtpmap:113 telephone-event/16000\r\na=rtpmap:126 telephone-event/8000\r\na=ssrc:3652058873 cname:kufSZ8JnlRUuQVc2\r\na=ssrc:3652058873 msid:381b9efc-7cf5-45bb-8f39-c06558b288de 8841cbb1-90ba-4655-8784-60a185846706\r\na=ssrc:3652058873 mslabel:381b9efc-7cf5-45bb-8f39-c06558b288de\r\na=ssrc:3652058873 label:8841cbb1-90ba-4655-8784-60a185846706\r\nm=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99 100 101 102 122 127 121 125 107 108 109 124 120 123 119 114\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:Y5Zy\r\na=ice-pwd:yQLVrXgG+irP0tgLLr4ZjQb5\r\na=ice-options:trickle\r\na=fingerprint:sha-256 45:ED:86:FB:EB:FE:21:20:62:C4:07:81:AA:B8:BC:87:60:CC:2B:54:CE:D5:F0:16:93:C4:61:23:28:59:DF:8B\r\na=setup:actpass\r\na=mid:video\r\na=extmap:2 urn:ietf:params:rtp-hdrext:toffset\r\na=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:4 urn:3gpp:video-orientation\r\na=extmap:5 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\na=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay\r\na=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type\r\na=extmap:8 http://www.webrtc.org/experiments/rtp-hdrext/video-timing\r\na=extmap:10 http://tools.ietf.org/html/draft-ietf-avtext-framemarking-07\r\na=sendrecv\r\na=rtcp-mux\r\na=rtcp-rsize\r\na=rtpmap:96 VP8/90000\r\na=rtcp-fb:96 goog-remb\r\na=rtcp-fb:96 transport-cc\r\na=rtcp-fb:96 ccm fir\r\na=rtcp-fb:96 nack\r\na=rtcp-fb:96 nack pli\r\na=rtpmap:97 rtx/90000\r\na=fmtp:97 apt=96\r\na=rtpmap:98 VP9/90000\r\na=rtcp-fb:98 goog-remb\r\na=rtcp-fb:98 transport-cc\r\na=rtcp-fb:98 ccm fir\r\na=rtcp-fb:98 nack\r\na=rtcp-fb:98 nack pli\r\na=fmtp:98 profile-id=0\r\na=rtpmap:99 rtx/90000\r\na=fmtp:99 apt=98\r\na=rtpmap:100 H264/90000\r\na=rtcp-fb:100 goog-remb\r\na=rtcp-fb:100 transport-cc\r\na=rtcp-fb:100 ccm fir\r\na=rtcp-fb:100 nack\r\na=rtcp-fb:100 nack pli\r\na=fmtp:100 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f\r\na=rtpmap:101 rtx/90000\r\na=fmtp:101 apt=100\r\na=rtpmap:102 H264/90000\r\na=rtcp-fb:102 goog-remb\r\na=rtcp-fb:102 transport-cc\r\na=rtcp-fb:102 ccm fir\r\na=rtcp-fb:102 nack\r\na=rtcp-fb:102 nack pli\r\na=fmtp:102 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42001f\r\na=rtpmap:122 rtx/90000\r\na=fmtp:122 apt=102\r\na=rtpmap:127 H264/90000\r\na=rtcp-fb:127 goog-remb\r\na=rtcp-fb:127 transport-cc\r\na=rtcp-fb:127 ccm fir\r\na=rtcp-fb:127 nack\r\na=rtcp-fb:127 nack pli\r\na=fmtp:127 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f\r\na=rtpmap:121 rtx/90000\r\na=fmtp:121 apt=127\r\na=rtpmap:125 H264/90000\r\na=rtcp-fb:125 goog-remb\r\na=rtcp-fb:125 transport-cc\r\na=rtcp-fb:125 ccm fir\r\na=rtcp-fb:125 nack\r\na=rtcp-fb:125 nack pli\r\na=fmtp:125 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42e01f\r\na=rtpmap:107 rtx/90000\r\na=fmtp:107 apt=125\r\na=rtpmap:108 H264/90000\r\na=rtcp-fb:108 goog-remb\r\na=rtcp-fb:108 transport-cc\r\na=rtcp-fb:108 ccm fir\r\na=rtcp-fb:108 nack\r\na=rtcp-fb:108 nack pli\r\na=fmtp:108 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=4d0032\r\na=rtpmap:109 rtx/90000\r\na=fmtp:109 apt=108\r\na=rtpmap:124 H264/90000\r\na=rtcp-fb:124 goog-remb\r\na=rtcp-fb:124 transport-cc\r\na=rtcp-fb:124 ccm fir\r\na=rtcp-fb:124 nack\r\na=rtcp-fb:124 nack pli\r\na=fmtp:124 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=640032\r\na=rtpmap:120 rtx/90000\r\na=fmtp:120 apt=124\r\na=rtpmap:123 red/90000\r\na=rtpmap:119 rtx/90000\r\na=fmtp:119 apt=123\r\na=rtpmap:114 ulpfec/90000\r\na=ssrc-group:FID 1714381393 967654061\r\na=ssrc:1714381393 cname:kufSZ8JnlRUuQVc2\r\na=ssrc:1714381393 msid:381b9efc-7cf5-45bb-8f39-c06558b288de 99d2faa8-950d-40f7-ad80-16789c9b4faa\r\na=ssrc:1714381393 mslabel:381b9efc-7cf5-45bb-8f39-c06558b288de\r\na=ssrc:1714381393 label:99d2faa8-950d-40f7-ad80-16789c9b4faa\r\na=ssrc:967654061 cname:kufSZ8JnlRUuQVc2\r\na=ssrc:967654061 msid:381b9efc-7cf5-45bb-8f39-c06558b288de 99d2faa8-950d-40f7-ad80-16789c9b4faa\r\na=ssrc:967654061 mslabel:381b9efc-7cf5-45bb-8f39-c06558b288de\r\na=ssrc:967654061 label:99d2faa8-950d-40f7-ad80-16789c9b4faa\r\n'; const SDP_OPUS_NO_STEREO = 'v=0\r\no=- 135160591336882782 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE audio video\r\na=msid-semantic: WMS 381b9efc-7cf5-45bb-8f39-c06558b288de\r\nm=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 0 8 106 105 13 110 112 113 126\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:Y5Zy\r\na=ice-pwd:yQLVrXgG+irP0tgLLr4ZjQb5\r\na=ice-options:trickle\r\na=fingerprint:sha-256 45:ED:86:FB:EB:FE:21:20:62:C4:07:81:AA:B8:BC:87:60:CC:2B:54:CE:D5:F0:16:93:C4:61:23:28:59:DF:8B\r\na=setup:actpass\r\na=mid:audio\r\na=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\na=sendrecv\r\na=rtcp-mux\r\na=rtpmap:111 opus/48000/2\r\na=rtcp-fb:111 transport-cc\r\na=fmtp:111 minptime=10;useinbandfec=1\r\na=rtpmap:103 ISAC/16000\r\na=rtpmap:104 ISAC/32000\r\na=rtpmap:9 G722/8000\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:106 CN/32000\r\na=rtpmap:105 CN/16000\r\na=rtpmap:13 CN/8000\r\na=rtpmap:110 telephone-event/48000\r\na=rtpmap:112 telephone-event/32000\r\na=rtpmap:113 telephone-event/16000\r\na=rtpmap:126 telephone-event/8000\r\na=ssrc:3652058873 cname:kufSZ8JnlRUuQVc2\r\na=ssrc:3652058873 msid:381b9efc-7cf5-45bb-8f39-c06558b288de 8841cbb1-90ba-4655-8784-60a185846706\r\na=ssrc:3652058873 mslabel:381b9efc-7cf5-45bb-8f39-c06558b288de\r\na=ssrc:3652058873 label:8841cbb1-90ba-4655-8784-60a185846706\r\nm=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99 100 101 102 122 127 121 125 107 108 109 124 120 123 119 114\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:Y5Zy\r\na=ice-pwd:yQLVrXgG+irP0tgLLr4ZjQb5\r\na=ice-options:trickle\r\na=fingerprint:sha-256 45:ED:86:FB:EB:FE:21:20:62:C4:07:81:AA:B8:BC:87:60:CC:2B:54:CE:D5:F0:16:93:C4:61:23:28:59:DF:8B\r\na=setup:actpass\r\na=mid:video\r\na=extmap:2 urn:ietf:params:rtp-hdrext:toffset\r\na=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:4 urn:3gpp:video-orientation\r\na=extmap:5 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\na=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay\r\na=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type\r\na=extmap:8 http://www.webrtc.org/experiments/rtp-hdrext/video-timing\r\na=extmap:10 http://tools.ietf.org/html/draft-ietf-avtext-framemarking-07\r\na=sendrecv\r\na=rtcp-mux\r\na=rtcp-rsize\r\na=rtpmap:96 VP8/90000\r\na=rtcp-fb:96 goog-remb\r\na=rtcp-fb:96 transport-cc\r\na=rtcp-fb:96 ccm fir\r\na=rtcp-fb:96 nack\r\na=rtcp-fb:96 nack pli\r\na=rtpmap:97 rtx/90000\r\na=fmtp:97 apt=96\r\na=rtpmap:98 VP9/90000\r\na=rtcp-fb:98 goog-remb\r\na=rtcp-fb:98 transport-cc\r\na=rtcp-fb:98 ccm fir\r\na=rtcp-fb:98 nack\r\na=rtcp-fb:98 nack pli\r\na=fmtp:98 profile-id=0\r\na=rtpmap:99 rtx/90000\r\na=fmtp:99 apt=98\r\na=rtpmap:100 H264/90000\r\na=rtcp-fb:100 goog-remb\r\na=rtcp-fb:100 transport-cc\r\na=rtcp-fb:100 ccm fir\r\na=rtcp-fb:100 nack\r\na=rtcp-fb:100 nack pli\r\na=fmtp:100 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f\r\na=rtpmap:101 rtx/90000\r\na=fmtp:101 apt=100\r\na=rtpmap:102 H264/90000\r\na=rtcp-fb:102 goog-remb\r\na=rtcp-fb:102 transport-cc\r\na=rtcp-fb:102 ccm fir\r\na=rtcp-fb:102 nack\r\na=rtcp-fb:102 nack pli\r\na=fmtp:102 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42001f\r\na=rtpmap:122 rtx/90000\r\na=fmtp:122 apt=102\r\na=rtpmap:127 H264/90000\r\na=rtcp-fb:127 goog-remb\r\na=rtcp-fb:127 transport-cc\r\na=rtcp-fb:127 ccm fir\r\na=rtcp-fb:127 nack\r\na=rtcp-fb:127 nack pli\r\na=fmtp:127 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f\r\na=rtpmap:121 rtx/90000\r\na=fmtp:121 apt=127\r\na=rtpmap:125 H264/90000\r\na=rtcp-fb:125 goog-remb\r\na=rtcp-fb:125 transport-cc\r\na=rtcp-fb:125 ccm fir\r\na=rtcp-fb:125 nack\r\na=rtcp-fb:125 nack pli\r\na=fmtp:125 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42e01f\r\na=rtpmap:107 rtx/90000\r\na=fmtp:107 apt=125\r\na=rtpmap:108 H264/90000\r\na=rtcp-fb:108 goog-remb\r\na=rtcp-fb:108 transport-cc\r\na=rtcp-fb:108 ccm fir\r\na=rtcp-fb:108 nack\r\na=rtcp-fb:108 nack pli\r\na=fmtp:108 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=4d0032\r\na=rtpmap:109 rtx/90000\r\na=fmtp:109 apt=108\r\na=rtpmap:124 H264/90000\r\na=rtcp-fb:124 goog-remb\r\na=rtcp-fb:124 transport-cc\r\na=rtcp-fb:124 ccm fir\r\na=rtcp-fb:124 nack\r\na=rtcp-fb:124 nack pli\r\na=fmtp:124 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=640032\r\na=rtpmap:120 rtx/90000\r\na=fmtp:120 apt=124\r\na=rtpmap:123 red/90000\r\na=rtpmap:119 rtx/90000\r\na=fmtp:119 apt=123\r\na=rtpmap:114 ulpfec/90000\r\na=ssrc-group:FID 1714381393 967654061\r\na=ssrc:1714381393 cname:kufSZ8JnlRUuQVc2\r\na=ssrc:1714381393 msid:381b9efc-7cf5-45bb-8f39-c06558b288de 99d2faa8-950d-40f7-ad80-16789c9b4faa\r\na=ssrc:1714381393 mslabel:381b9efc-7cf5-45bb-8f39-c06558b288de\r\na=ssrc:1714381393 label:99d2faa8-950d-40f7-ad80-16789c9b4faa\r\na=ssrc:967654061 cname:kufSZ8JnlRUuQVc2\r\na=ssrc:967654061 msid:381b9efc-7cf5-45bb-8f39-c06558b288de 99d2faa8-950d-40f7-ad80-16789c9b4faa\r\na=ssrc:967654061 mslabel:381b9efc-7cf5-45bb-8f39-c06558b288de\r\na=ssrc:967654061 label:99d2faa8-950d-40f7-ad80-16789c9b4faa\r\n'; const SDP_NO_OPUS_NO_STEREO = 'v=0\r\no=- 135160591336882782 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE audio video\r\na=msid-semantic: WMS 381b9efc-7cf5-45bb-8f39-c06558b288de\r\nm=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 0 8 106 105 13 110 112 113 126\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:Y5Zy\r\na=ice-pwd:yQLVrXgG+irP0tgLLr4ZjQb5\r\na=ice-options:trickle\r\na=fingerprint:sha-256 45:ED:86:FB:EB:FE:21:20:62:C4:07:81:AA:B8:BC:87:60:CC:2B:54:CE:D5:F0:16:93:C4:61:23:28:59:DF:8B\r\na=setup:actpass\r\na=mid:audio\r\na=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\na=sendrecv\r\na=rtcp-mux\r\na=rtpmap:111 opus/48000/2\r\na=rtcp-fb:111 transport-cc\r\na=rtpmap:103 ISAC/16000\r\na=rtpmap:104 ISAC/32000\r\na=rtpmap:9 G722/8000\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:106 CN/32000\r\na=rtpmap:105 CN/16000\r\na=rtpmap:13 CN/8000\r\na=rtpmap:110 telephone-event/48000\r\na=rtpmap:112 telephone-event/32000\r\na=rtpmap:113 telephone-event/16000\r\na=rtpmap:126 telephone-event/8000\r\na=ssrc:3652058873 cname:kufSZ8JnlRUuQVc2\r\na=ssrc:3652058873 msid:381b9efc-7cf5-45bb-8f39-c06558b288de 8841cbb1-90ba-4655-8784-60a185846706\r\na=ssrc:3652058873 mslabel:381b9efc-7cf5-45bb-8f39-c06558b288de\r\na=ssrc:3652058873 label:8841cbb1-90ba-4655-8784-60a185846706\r\nm=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99 100 101 102 122 127 121 125 107 108 109 124 120 123 119 114\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:Y5Zy\r\na=ice-pwd:yQLVrXgG+irP0tgLLr4ZjQb5\r\na=ice-options:trickle\r\na=fingerprint:sha-256 45:ED:86:FB:EB:FE:21:20:62:C4:07:81:AA:B8:BC:87:60:CC:2B:54:CE:D5:F0:16:93:C4:61:23:28:59:DF:8B\r\na=setup:actpass\r\na=mid:video\r\na=extmap:2 urn:ietf:params:rtp-hdrext:toffset\r\na=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:4 urn:3gpp:video-orientation\r\na=extmap:5 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\na=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay\r\na=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type\r\na=extmap:8 http://www.webrtc.org/experiments/rtp-hdrext/video-timing\r\na=extmap:10 http://tools.ietf.org/html/draft-ietf-avtext-framemarking-07\r\na=sendrecv\r\na=rtcp-mux\r\na=rtcp-rsize\r\na=rtpmap:96 VP8/90000\r\na=rtcp-fb:96 goog-remb\r\na=rtcp-fb:96 transport-cc\r\na=rtcp-fb:96 ccm fir\r\na=rtcp-fb:96 nack\r\na=rtcp-fb:96 nack pli\r\na=rtpmap:97 rtx/90000\r\na=fmtp:97 apt=96\r\na=rtpmap:98 VP9/90000\r\na=rtcp-fb:98 goog-remb\r\na=rtcp-fb:98 transport-cc\r\na=rtcp-fb:98 ccm fir\r\na=rtcp-fb:98 nack\r\na=rtcp-fb:98 nack pli\r\na=fmtp:98 profile-id=0\r\na=rtpmap:99 rtx/90000\r\na=fmtp:99 apt=98\r\na=rtpmap:100 H264/90000\r\na=rtcp-fb:100 goog-remb\r\na=rtcp-fb:100 transport-cc\r\na=rtcp-fb:100 ccm fir\r\na=rtcp-fb:100 nack\r\na=rtcp-fb:100 nack pli\r\na=fmtp:100 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f\r\na=rtpmap:101 rtx/90000\r\na=fmtp:101 apt=100\r\na=rtpmap:102 H264/90000\r\na=rtcp-fb:102 goog-remb\r\na=rtcp-fb:102 transport-cc\r\na=rtcp-fb:102 ccm fir\r\na=rtcp-fb:102 nack\r\na=rtcp-fb:102 nack pli\r\na=fmtp:102 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42001f\r\na=rtpmap:122 rtx/90000\r\na=fmtp:122 apt=102\r\na=rtpmap:127 H264/90000\r\na=rtcp-fb:127 goog-remb\r\na=rtcp-fb:127 transport-cc\r\na=rtcp-fb:127 ccm fir\r\na=rtcp-fb:127 nack\r\na=rtcp-fb:127 nack pli\r\na=fmtp:127 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f\r\na=rtpmap:121 rtx/90000\r\na=fmtp:121 apt=127\r\na=rtpmap:125 H264/90000\r\na=rtcp-fb:125 goog-remb\r\na=rtcp-fb:125 transport-cc\r\na=rtcp-fb:125 ccm fir\r\na=rtcp-fb:125 nack\r\na=rtcp-fb:125 nack pli\r\na=fmtp:125 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42e01f\r\na=rtpmap:107 rtx/90000\r\na=fmtp:107 apt=125\r\na=rtpmap:108 H264/90000\r\na=rtcp-fb:108 goog-remb\r\na=rtcp-fb:108 transport-cc\r\na=rtcp-fb:108 ccm fir\r\na=rtcp-fb:108 nack\r\na=rtcp-fb:108 nack pli\r\na=fmtp:108 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=4d0032\r\na=rtpmap:109 rtx/90000\r\na=fmtp:109 apt=108\r\na=rtpmap:124 H264/90000\r\na=rtcp-fb:124 goog-remb\r\na=rtcp-fb:124 transport-cc\r\na=rtcp-fb:124 ccm fir\r\na=rtcp-fb:124 nack\r\na=rtcp-fb:124 nack pli\r\na=fmtp:124 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=640032\r\na=rtpmap:120 rtx/90000\r\na=fmtp:120 apt=124\r\na=rtpmap:123 red/90000\r\na=rtpmap:119 rtx/90000\r\na=fmtp:119 apt=123\r\na=rtpmap:114 ulpfec/90000\r\na=ssrc-group:FID 1714381393 967654061\r\na=ssrc:1714381393 cname:kufSZ8JnlRUuQVc2\r\na=ssrc:1714381393 msid:381b9efc-7cf5-45bb-8f39-c06558b288de 99d2faa8-950d-40f7-ad80-16789c9b4faa\r\na=ssrc:1714381393 mslabel:381b9efc-7cf5-45bb-8f39-c06558b288de\r\na=ssrc:1714381393 label:99d2faa8-950d-40f7-ad80-16789c9b4faa\r\na=ssrc:967654061 cname:kufSZ8JnlRUuQVc2\r\na=ssrc:967654061 msid:381b9efc-7cf5-45bb-8f39-c06558b288de 99d2faa8-950d-40f7-ad80-16789c9b4faa\r\na=ssrc:967654061 mslabel:381b9efc-7cf5-45bb-8f39-c06558b288de\r\na=ssrc:967654061 label:99d2faa8-950d-40f7-ad80-16789c9b4faa\r\n'; const SDP_NO_OPUS_STEREO = 'v=0\r\no=- 135160591336882782 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE audio video\r\na=msid-semantic: WMS 381b9efc-7cf5-45bb-8f39-c06558b288de\r\nm=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 0 8 106 105 13 110 112 113 126\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:Y5Zy\r\na=ice-pwd:yQLVrXgG+irP0tgLLr4ZjQb5\r\na=ice-options:trickle\r\na=fingerprint:sha-256 45:ED:86:FB:EB:FE:21:20:62:C4:07:81:AA:B8:BC:87:60:CC:2B:54:CE:D5:F0:16:93:C4:61:23:28:59:DF:8B\r\na=setup:actpass\r\na=mid:audio\r\na=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\na=sendrecv\r\na=rtcp-mux\r\na=rtpmap:111 opus/48000/2\r\na=fmtp:111 stereo=1; sprop-stereo=1\r\na=rtcp-fb:111 transport-cc\r\na=rtpmap:103 ISAC/16000\r\na=rtpmap:104 ISAC/32000\r\na=rtpmap:9 G722/8000\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:106 CN/32000\r\na=rtpmap:105 CN/16000\r\na=rtpmap:13 CN/8000\r\na=rtpmap:110 telephone-event/48000\r\na=rtpmap:112 telephone-event/32000\r\na=rtpmap:113 telephone-event/16000\r\na=rtpmap:126 telephone-event/8000\r\na=ssrc:3652058873 cname:kufSZ8JnlRUuQVc2\r\na=ssrc:3652058873 msid:381b9efc-7cf5-45bb-8f39-c06558b288de 8841cbb1-90ba-4655-8784-60a185846706\r\na=ssrc:3652058873 mslabel:381b9efc-7cf5-45bb-8f39-c06558b288de\r\na=ssrc:3652058873 label:8841cbb1-90ba-4655-8784-60a185846706\r\nm=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99 100 101 102 122 127 121 125 107 108 109 124 120 123 119 114\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:Y5Zy\r\na=ice-pwd:yQLVrXgG+irP0tgLLr4ZjQb5\r\na=ice-options:trickle\r\na=fingerprint:sha-256 45:ED:86:FB:EB:FE:21:20:62:C4:07:81:AA:B8:BC:87:60:CC:2B:54:CE:D5:F0:16:93:C4:61:23:28:59:DF:8B\r\na=setup:actpass\r\na=mid:video\r\na=extmap:2 urn:ietf:params:rtp-hdrext:toffset\r\na=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:4 urn:3gpp:video-orientation\r\na=extmap:5 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\na=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay\r\na=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type\r\na=extmap:8 http://www.webrtc.org/experiments/rtp-hdrext/video-timing\r\na=extmap:10 http://tools.ietf.org/html/draft-ietf-avtext-framemarking-07\r\na=sendrecv\r\na=rtcp-mux\r\na=rtcp-rsize\r\na=rtpmap:96 VP8/90000\r\na=rtcp-fb:96 goog-remb\r\na=rtcp-fb:96 transport-cc\r\na=rtcp-fb:96 ccm fir\r\na=rtcp-fb:96 nack\r\na=rtcp-fb:96 nack pli\r\na=rtpmap:97 rtx/90000\r\na=fmtp:97 apt=96\r\na=rtpmap:98 VP9/90000\r\na=rtcp-fb:98 goog-remb\r\na=rtcp-fb:98 transport-cc\r\na=rtcp-fb:98 ccm fir\r\na=rtcp-fb:98 nack\r\na=rtcp-fb:98 nack pli\r\na=fmtp:98 profile-id=0\r\na=rtpmap:99 rtx/90000\r\na=fmtp:99 apt=98\r\na=rtpmap:100 H264/90000\r\na=rtcp-fb:100 goog-remb\r\na=rtcp-fb:100 transport-cc\r\na=rtcp-fb:100 ccm fir\r\na=rtcp-fb:100 nack\r\na=rtcp-fb:100 nack pli\r\na=fmtp:100 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f\r\na=rtpmap:101 rtx/90000\r\na=fmtp:101 apt=100\r\na=rtpmap:102 H264/90000\r\na=rtcp-fb:102 goog-remb\r\na=rtcp-fb:102 transport-cc\r\na=rtcp-fb:102 ccm fir\r\na=rtcp-fb:102 nack\r\na=rtcp-fb:102 nack pli\r\na=fmtp:102 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42001f\r\na=rtpmap:122 rtx/90000\r\na=fmtp:122 apt=102\r\na=rtpmap:127 H264/90000\r\na=rtcp-fb:127 goog-remb\r\na=rtcp-fb:127 transport-cc\r\na=rtcp-fb:127 ccm fir\r\na=rtcp-fb:127 nack\r\na=rtcp-fb:127 nack pli\r\na=fmtp:127 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f\r\na=rtpmap:121 rtx/90000\r\na=fmtp:121 apt=127\r\na=rtpmap:125 H264/90000\r\na=rtcp-fb:125 goog-remb\r\na=rtcp-fb:125 transport-cc\r\na=rtcp-fb:125 ccm fir\r\na=rtcp-fb:125 nack\r\na=rtcp-fb:125 nack pli\r\na=fmtp:125 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42e01f\r\na=rtpmap:107 rtx/90000\r\na=fmtp:107 apt=125\r\na=rtpmap:108 H264/90000\r\na=rtcp-fb:108 goog-remb\r\na=rtcp-fb:108 transport-cc\r\na=rtcp-fb:108 ccm fir\r\na=rtcp-fb:108 nack\r\na=rtcp-fb:108 nack pli\r\na=fmtp:108 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=4d0032\r\na=rtpmap:109 rtx/90000\r\na=fmtp:109 apt=108\r\na=rtpmap:124 H264/90000\r\na=rtcp-fb:124 goog-remb\r\na=rtcp-fb:124 transport-cc\r\na=rtcp-fb:124 ccm fir\r\na=rtcp-fb:124 nack\r\na=rtcp-fb:124 nack pli\r\na=fmtp:124 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=640032\r\na=rtpmap:120 rtx/90000\r\na=fmtp:120 apt=124\r\na=rtpmap:123 red/90000\r\na=rtpmap:119 rtx/90000\r\na=fmtp:119 apt=123\r\na=rtpmap:114 ulpfec/90000\r\na=ssrc-group:FID 1714381393 967654061\r\na=ssrc:1714381393 cname:kufSZ8JnlRUuQVc2\r\na=ssrc:1714381393 msid:381b9efc-7cf5-45bb-8f39-c06558b288de 99d2faa8-950d-40f7-ad80-16789c9b4faa\r\na=ssrc:1714381393 mslabel:381b9efc-7cf5-45bb-8f39-c06558b288de\r\na=ssrc:1714381393 label:99d2faa8-950d-40f7-ad80-16789c9b4faa\r\na=ssrc:967654061 cname:kufSZ8JnlRUuQVc2\r\na=ssrc:967654061 msid:381b9efc-7cf5-45bb-8f39-c06558b288de 99d2faa8-950d-40f7-ad80-16789c9b4faa\r\na=ssrc:967654061 mslabel:381b9efc-7cf5-45bb-8f39-c06558b288de\r\na=ssrc:967654061 label:99d2faa8-950d-40f7-ad80-16789c9b4faa\r\n'; it('set stereo=1 if a=fmtp is present', () => { expect(sdpStereoHack(SDP_OPUS_NO_STEREO)).toEqual(SDP_OPUS_STEREO); }); it('set stereo=1 if a=fmtp is NOT present', () => { expect(sdpStereoHack(SDP_NO_OPUS_NO_STEREO)).toEqual(SDP_NO_OPUS_STEREO); }); }); describe('sdpMediaOrderHack', () => { const OFFER_OK = 'v=0\r\no=mozilla...THIS_IS_SDPARTA-65.0 4664580510618001282 0 IN IP4 0.0.0.0\r\ns=-\r\nt=0 0\r\na=sendrecv\r\na=fingerprint:sha-256 37:18:D1:6A:F4:B6:DB:00:A0:48:4B:EC:CC:F3:E1:AF:DC:DB:DA:2C:E2:C0:6B:36:92:02:84:04:60:B5:EB:70\r\na=group:BUNDLE 0 1\r\na=ice-options:trickle\r\na=msid-semantic:WMS *\r\nm=audio 60578 UDP/TLS/RTP/SAVPF 109 9 0 8 101\r\nc=IN IP4 192.168.1.4\r\na=candidate:0 1 UDP 2122252543 192.168.1.4 60578 typ host\r\na=candidate:1 1 TCP 2105524479 192.168.1.4 9 typ host tcptype active\r\na=candidate:0 2 UDP 2122252542 192.168.1.4 56425 typ host\r\na=candidate:1 2 TCP 2105524478 192.168.1.4 9 typ host tcptype active\r\na=sendrecv\r\na=end-of-candidates\r\na=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\na=extmap:2/recvonly urn:ietf:params:rtp-hdrext:csrc-audio-level\r\na=extmap:3 urn:ietf:params:rtp-hdrext:sdes:mid\r\na=fmtp:109 maxplaybackrate=48000;stereo=1;useinbandfec=1\r\na=fmtp:101 0-15\r\na=ice-pwd:37573269874225f2b9ee22d8fc483281\r\na=ice-ufrag:e762c9de\r\na=mid:0\r\na=msid:{8de043d7-7ff5-5c46-8822-e0d9ffd96e73} {d3bf3e75-0c87-f849-a967-6ec743afd59b}\r\na=rtcp:56425 IN IP4 192.168.1.4\r\na=rtcp-mux\r\na=rtpmap:109 opus/48000/2\r\na=rtpmap:9 G722/8000/1\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:101 telephone-event/8000\r\na=setup:actpass\r\na=ssrc:3703202793 cname:{05f7b618-2088-4048-9d8a-37e95f7fd8b6}\r\nm=video 55993 UDP/TLS/RTP/SAVPF 120 121 126 97\r\nc=IN IP4 192.168.1.4\r\na=candidate:0 1 UDP 2122252543 192.168.1.4 55993 typ host\r\na=candidate:1 1 TCP 2105524479 192.168.1.4 9 typ host tcptype active\r\na=candidate:0 2 UDP 2122252542 192.168.1.4 54949 typ host\r\na=candidate:1 2 TCP 2105524478 192.168.1.4 9 typ host tcptype active\r\na=sendrecv\r\na=end-of-candidates\r\na=extmap:3 urn:ietf:params:rtp-hdrext:sdes:mid\r\na=extmap:4 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:5 urn:ietf:params:rtp-hdrext:toffset\r\na=fmtp:126 profile-level-id=42e01f;level-asymmetry-allowed=1;packetization-mode=1\r\na=fmtp:97 profile-level-id=42e01f;level-asymmetry-allowed=1\r\na=fmtp:120 max-fs=12288;max-fr=60\r\na=fmtp:121 max-fs=12288;max-fr=60\r\na=ice-pwd:37573269874225f2b9ee22d8fc483281\r\na=ice-ufrag:e762c9de\r\na=mid:1\r\na=msid:{8de043d7-7ff5-5c46-8822-e0d9ffd96e73} {77747bff-84dd-124b-8f35-3d84e89cd9fe}\r\na=rtcp:54949 IN IP4 192.168.1.4\r\na=rtcp-fb:120 nack\r\na=rtcp-fb:120 nack pli\r\na=rtcp-fb:120 ccm fir\r\na=rtcp-fb:120 goog-remb\r\na=rtcp-fb:121 nack\r\na=rtcp-fb:121 nack pli\r\na=rtcp-fb:121 ccm fir\r\na=rtcp-fb:121 goog-remb\r\na=rtcp-fb:126 nack\r\na=rtcp-fb:126 nack pli\r\na=rtcp-fb:126 ccm fir\r\na=rtcp-fb:126 goog-remb\r\na=rtcp-fb:97 nack\r\na=rtcp-fb:97 nack pli\r\na=rtcp-fb:97 ccm fir\r\na=rtcp-fb:97 goog-remb\r\na=rtcp-mux\r\na=rtpmap:120 VP8/90000\r\na=rtpmap:121 VP9/90000\r\na=rtpmap:126 H264/90000\r\na=rtpmap:97 H264/90000\r\na=setup:actpass\r\na=ssrc:3672465901 cname:{05f7b618-2088-4048-9d8a-37e95f7fd8b6}\r\n'; const OFFER_KO = 'v=0\r\no=mozilla...THIS_IS_SDPARTA-65.0 4664580510618001282 0 IN IP4 0.0.0.0\r\ns=-\r\nt=0 0\r\na=sendrecv\r\na=fingerprint:sha-256 37:18:D1:6A:F4:B6:DB:00:A0:48:4B:EC:CC:F3:E1:AF:DC:DB:DA:2C:E2:C0:6B:36:92:02:84:04:60:B5:EB:70\r\na=group:BUNDLE 0 1\r\na=ice-options:trickle\r\na=msid-semantic:WMS *\r\nm=video 55993 UDP/TLS/RTP/SAVPF 120 121 126 97\r\nc=IN IP4 192.168.1.4\r\na=candidate:0 1 UDP 2122252543 192.168.1.4 55993 typ host\r\na=candidate:1 1 TCP 2105524479 192.168.1.4 9 typ host tcptype active\r\na=candidate:0 2 UDP 2122252542 192.168.1.4 54949 typ host\r\na=candidate:1 2 TCP 2105524478 192.168.1.4 9 typ host tcptype active\r\na=sendrecv\r\na=end-of-candidates\r\na=extmap:3 urn:ietf:params:rtp-hdrext:sdes:mid\r\na=extmap:4 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:5 urn:ietf:params:rtp-hdrext:toffset\r\na=fmtp:126 profile-level-id=42e01f;level-asymmetry-allowed=1;packetization-mode=1\r\na=fmtp:97 profile-level-id=42e01f;level-asymmetry-allowed=1\r\na=fmtp:120 max-fs=12288;max-fr=60\r\na=fmtp:121 max-fs=12288;max-fr=60\r\na=ice-pwd:37573269874225f2b9ee22d8fc483281\r\na=ice-ufrag:e762c9de\r\na=mid:1\r\na=msid:{8de043d7-7ff5-5c46-8822-e0d9ffd96e73} {77747bff-84dd-124b-8f35-3d84e89cd9fe}\r\na=rtcp:54949 IN IP4 192.168.1.4\r\na=rtcp-fb:120 nack\r\na=rtcp-fb:120 nack pli\r\na=rtcp-fb:120 ccm fir\r\na=rtcp-fb:120 goog-remb\r\na=rtcp-fb:121 nack\r\na=rtcp-fb:121 nack pli\r\na=rtcp-fb:121 ccm fir\r\na=rtcp-fb:121 goog-remb\r\na=rtcp-fb:126 nack\r\na=rtcp-fb:126 nack pli\r\na=rtcp-fb:126 ccm fir\r\na=rtcp-fb:126 goog-remb\r\na=rtcp-fb:97 nack\r\na=rtcp-fb:97 nack pli\r\na=rtcp-fb:97 ccm fir\r\na=rtcp-fb:97 goog-remb\r\na=rtcp-mux\r\na=rtpmap:120 VP8/90000\r\na=rtpmap:121 VP9/90000\r\na=rtpmap:126 H264/90000\r\na=rtpmap:97 H264/90000\r\na=setup:actpass\r\na=ssrc:3672465901 cname:{05f7b618-2088-4048-9d8a-37e95f7fd8b6}\r\nm=audio 60578 UDP/TLS/RTP/SAVPF 109 9 0 8 101\r\nc=IN IP4 192.168.1.4\r\na=candidate:0 1 UDP 2122252543 192.168.1.4 60578 typ host\r\na=candidate:1 1 TCP 2105524479 192.168.1.4 9 typ host tcptype active\r\na=candidate:0 2 UDP 2122252542 192.168.1.4 56425 typ host\r\na=candidate:1 2 TCP 2105524478 192.168.1.4 9 typ host tcptype active\r\na=sendrecv\r\na=end-of-candidates\r\na=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\na=extmap:2/recvonly urn:ietf:params:rtp-hdrext:csrc-audio-level\r\na=extmap:3 urn:ietf:params:rtp-hdrext:sdes:mid\r\na=fmtp:109 maxplaybackrate=48000;stereo=1;useinbandfec=1\r\na=fmtp:101 0-15\r\na=ice-pwd:37573269874225f2b9ee22d8fc483281\r\na=ice-ufrag:e762c9de\r\na=mid:0\r\na=msid:{8de043d7-7ff5-5c46-8822-e0d9ffd96e73} {d3bf3e75-0c87-f849-a967-6ec743afd59b}\r\na=rtcp:56425 IN IP4 192.168.1.4\r\na=rtcp-mux\r\na=rtpmap:109 opus/48000/2\r\na=rtpmap:9 G722/8000/1\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:101 telephone-event/8000\r\na=setup:actpass\r\na=ssrc:3703202793 cname:{05f7b618-2088-4048-9d8a-37e95f7fd8b6}\r\n'; const ANSWER = 'v=0\r\no=FreeSWITCH 1548927489 1548927490 IN IP4 190.102.98.65\r\ns=FreeSWITCH\r\nc=IN IP4 190.102.98.65\r\nt=0 0\r\na=msid-semantic: WMS 2OlCk4kjBnIzrzS1reSby6Zc0RIbdof6\r\nm=audio 21632 UDP/TLS/RTP/SAVPF 109 101\r\na=rtpmap:109 opus/48000/2\r\na=fmtp:109 useinbandfec=0; stereo=1\r\na=rtpmap:101 telephone-event/8000\r\na=silenceSupp:off - - - -\r\na=ptime:20\r\na=sendrecv\r\na=fingerprint:sha-256 2D:89:4F:82:44:AC:3C:CB:B3:63:AC:17:11:49:4E:11:1A:7D:70:2D:18:51:00:76:03:E1:82:72:92:3F:20:5B\r\na=setup:active\r\na=rtcp-mux\r\na=rtcp:21632 IN IP4 190.102.98.65\r\na=ice-ufrag:1NDpJtrAbZCfeHb7\r\na=ice-pwd:Zzab7nPT9SXkERNvvhK5B2wC\r\na=candidate:7330097990 1 udp 659136 190.102.98.65 21632 typ host generation 0\r\na=end-of-candidates\r\na=ssrc:3361527577 cname:3rydmInNWVddlW4C\r\na=ssrc:3361527577 msid:2OlCk4kjBnIzrzS1reSby6Zc0RIbdof6 a0\r\na=ssrc:3361527577 mslabel:2OlCk4kjBnIzrzS1reSby6Zc0RIbdof6\r\na=ssrc:3361527577 label:2OlCk4kjBnIzrzS1reSby6Zc0RIbdof6a0\r\nm=video 32174 UDP/TLS/RTP/SAVPF 120\r\nb=AS:5120\r\na=rtpmap:120 VP8/90000\r\na=fmtp:120 max-fs=12288;max-fr=60\r\na=sendrecv\r\na=fingerprint:sha-256 2D:89:4F:82:44:AC:3C:CB:B3:63:AC:17:11:49:4E:11:1A:7D:70:2D:18:51:00:76:03:E1:82:72:92:3F:20:5B\r\na=setup:active\r\na=rtcp-mux\r\na=rtcp:32174 IN IP4 190.102.98.65\r\na=rtcp-fb:120 ccm fir\r\na=rtcp-fb:120 nack\r\na=rtcp-fb:120 nack pli\r\na=ssrc:2587074312 cname:3rydmInNWVddlW4C\r\na=ssrc:2587074312 msid:2OlCk4kjBnIzrzS1reSby6Zc0RIbdof6 v0\r\na=ssrc:2587074312 mslabel:2OlCk4kjBnIzrzS1reSby6Zc0RIbdof6\r\na=ssrc:2587074312 label:2OlCk4kjBnIzrzS1reSby6Zc0RIbdof6v0\r\na=ice-ufrag:a18QY1pFCOxw1p3M\r\na=ice-pwd:jbKGpwsMOR8bsqKsiI96zoB2\r\na=candidate:4637747447 1 udp 659136 190.102.98.65 32174 typ host generation 0\r\na=end-of-candidates\r\n'; const ANSWER_REVERTED = 'v=0\r\no=FreeSWITCH 1548927489 1548927490 IN IP4 190.102.98.65\r\ns=FreeSWITCH\r\nc=IN IP4 190.102.98.65\r\nt=0 0\r\na=msid-semantic: WMS 2OlCk4kjBnIzrzS1reSby6Zc0RIbdof6\r\nm=video 32174 UDP/TLS/RTP/SAVPF 120\r\nb=AS:5120\r\na=rtpmap:120 VP8/90000\r\na=fmtp:120 max-fs=12288;max-fr=60\r\na=sendrecv\r\na=fingerprint:sha-256 2D:89:4F:82:44:AC:3C:CB:B3:63:AC:17:11:49:4E:11:1A:7D:70:2D:18:51:00:76:03:E1:82:72:92:3F:20:5B\r\na=setup:active\r\na=rtcp-mux\r\na=rtcp:32174 IN IP4 190.102.98.65\r\na=rtcp-fb:120 ccm fir\r\na=rtcp-fb:120 nack\r\na=rtcp-fb:120 nack pli\r\na=ssrc:2587074312 cname:3rydmInNWVddlW4C\r\na=ssrc:2587074312 msid:2OlCk4kjBnIzrzS1reSby6Zc0RIbdof6 v0\r\na=ssrc:2587074312 mslabel:2OlCk4kjBnIzrzS1reSby6Zc0RIbdof6\r\na=ssrc:2587074312 label:2OlCk4kjBnIzrzS1reSby6Zc0RIbdof6v0\r\na=ice-ufrag:a18QY1pFCOxw1p3M\r\na=ice-pwd:jbKGpwsMOR8bsqKsiI96zoB2\r\na=candidate:4637747447 1 udp 659136 190.102.98.65 32174 typ host generation 0\r\na=end-of-candidates\r\nm=audio 21632 UDP/TLS/RTP/SAVPF 109 101\r\na=rtpmap:109 opus/48000/2\r\na=fmtp:109 useinbandfec=0; stereo=1\r\na=rtpmap:101 telephone-event/8000\r\na=silenceSupp:off - - - -\r\na=ptime:20\r\na=sendrecv\r\na=fingerprint:sha-256 2D:89:4F:82:44:AC:3C:CB:B3:63:AC:17:11:49:4E:11:1A:7D:70:2D:18:51:00:76:03:E1:82:72:92:3F:20:5B\r\na=setup:active\r\na=rtcp-mux\r\na=rtcp:21632 IN IP4 190.102.98.65\r\na=ice-ufrag:1NDpJtrAbZCfeHb7\r\na=ice-pwd:Zzab7nPT9SXkERNvvhK5B2wC\r\na=candidate:7330097990 1 udp 659136 190.102.98.65 21632 typ host generation 0\r\na=end-of-candidates\r\na=ssrc:3361527577 cname:3rydmInNWVddlW4C\r\na=ssrc:3361527577 msid:2OlCk4kjBnIzrzS1reSby6Zc0RIbdof6 a0\r\na=ssrc:3361527577 mslabel:2OlCk4kjBnIzrzS1reSby6Zc0RIbdof6\r\na=ssrc:3361527577 label:2OlCk4kjBnIzrzS1reSby6Zc0RIbdof6a0\r\n'; it('reorder sdp media lines for audio to come first', () => { expect(sdpMediaOrderHack(ANSWER, OFFER_KO)).toEqual(ANSWER_REVERTED); }); it('if audio already comes first, do nothing', () => { expect(sdpMediaOrderHack(ANSWER, OFFER_OK)).toEqual(ANSWER); }); }); describe('sdpBitrateHack', () => { it('change the SDP properly with default values', () => { const SDP = 'v=0\r\no=- 135160591336882782 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE audio video\r\na=msid-semantic: WMS 381b9efc-7cf5-45bb-8f39-c06558b288de\r\nm=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 0 8 106 105 13 110 112 113 126\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:Y5Zy\r\na=ice-pwd:yQLVrXgG+irP0tgLLr4ZjQb5\r\na=ice-options:trickle\r\na=fingerprint:sha-256 45:ED:86:FB:EB:FE:21:20:62:C4:07:81:AA:B8:BC:87:60:CC:2B:54:CE:D5:F0:16:93:C4:61:23:28:59:DF:8B\r\na=setup:actpass\r\na=mid:audio\r\na=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\na=sendrecv\r\na=rtcp-mux\r\na=rtpmap:111 opus/48000/2\r\na=rtcp-fb:111 transport-cc\r\na=fmtp:111 minptime=10;useinbandfec=1\r\na=rtpmap:103 ISAC/16000\r\na=rtpmap:104 ISAC/32000\r\na=rtpmap:9 G722/8000\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:106 CN/32000\r\na=rtpmap:105 CN/16000\r\na=rtpmap:13 CN/8000\r\na=rtpmap:110 telephone-event/48000\r\na=rtpmap:112 telephone-event/32000\r\na=rtpmap:113 telephone-event/16000\r\na=rtpmap:126 telephone-event/8000\r\na=ssrc:3652058873 cname:kufSZ8JnlRUuQVc2\r\na=ssrc:3652058873 msid:381b9efc-7cf5-45bb-8f39-c06558b288de 8841cbb1-90ba-4655-8784-60a185846706\r\na=ssrc:3652058873 mslabel:381b9efc-7cf5-45bb-8f39-c06558b288de\r\na=ssrc:3652058873 label:8841cbb1-90ba-4655-8784-60a185846706\r\nm=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99 100 101 102 122 127 121 125 107 108 109 124 120 123 119 114\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:Y5Zy\r\na=ice-pwd:yQLVrXgG+irP0tgLLr4ZjQb5\r\na=ice-options:trickle\r\na=fingerprint:sha-256 45:ED:86:FB:EB:FE:21:20:62:C4:07:81:AA:B8:BC:87:60:CC:2B:54:CE:D5:F0:16:93:C4:61:23:28:59:DF:8B\r\na=setup:actpass\r\na=mid:video\r\na=extmap:2 urn:ietf:params:rtp-hdrext:toffset\r\na=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:4 urn:3gpp:video-orientation\r\na=extmap:5 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\na=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay\r\na=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type\r\na=extmap:8 http://www.webrtc.org/experiments/rtp-hdrext/video-timing\r\na=extmap:10 http://tools.ietf.org/html/draft-ietf-avtext-framemarking-07\r\na=sendrecv\r\na=rtcp-mux\r\na=rtcp-rsize\r\na=rtpmap:96 VP8/90000\r\na=rtcp-fb:96 goog-remb\r\na=rtcp-fb:96 transport-cc\r\na=rtcp-fb:96 ccm fir\r\na=rtcp-fb:96 nack\r\na=rtcp-fb:96 nack pli\r\na=rtpmap:97 rtx/90000\r\na=fmtp:97 apt=96\r\na=rtpmap:98 VP9/90000\r\na=rtcp-fb:98 goog-remb\r\na=rtcp-fb:98 transport-cc\r\na=rtcp-fb:98 ccm fir\r\na=rtcp-fb:98 nack\r\na=rtcp-fb:98 nack pli\r\na=fmtp:98 profile-id=0\r\na=rtpmap:99 rtx/90000\r\na=fmtp:99 apt=98\r\na=rtpmap:100 H264/90000\r\na=rtcp-fb:100 goog-remb\r\na=rtcp-fb:100 transport-cc\r\na=rtcp-fb:100 ccm fir\r\na=rtcp-fb:100 nack\r\na=rtcp-fb:100 nack pli\r\na=fmtp:100 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f\r\na=rtpmap:101 rtx/90000\r\na=fmtp:101 apt=100\r\na=rtpmap:102 H264/90000\r\na=rtcp-fb:102 goog-remb\r\na=rtcp-fb:102 transport-cc\r\na=rtcp-fb:102 ccm fir\r\na=rtcp-fb:102 nack\r\na=rtcp-fb:102 nack pli\r\na=fmtp:102 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42001f\r\na=rtpmap:122 rtx/90000\r\na=fmtp:122 apt=102\r\na=rtpmap:127 H264/90000\r\na=rtcp-fb:127 goog-remb\r\na=rtcp-fb:127 transport-cc\r\na=rtcp-fb:127 ccm fir\r\na=rtcp-fb:127 nack\r\na=rtcp-fb:127 nack pli\r\na=fmtp:127 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f\r\na=rtpmap:121 rtx/90000\r\na=fmtp:121 apt=127\r\na=rtpmap:125 H264/90000\r\na=rtcp-fb:125 goog-remb\r\na=rtcp-fb:125 transport-cc\r\na=rtcp-fb:125 ccm fir\r\na=rtcp-fb:125 nack\r\na=rtcp-fb:125 nack pli\r\na=fmtp:125 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42e01f\r\na=rtpmap:107 rtx/90000\r\na=fmtp:107 apt=125\r\na=rtpmap:108 H264/90000\r\na=rtcp-fb:108 goog-remb\r\na=rtcp-fb:108 transport-cc\r\na=rtcp-fb:108 ccm fir\r\na=rtcp-fb:108 nack\r\na=rtcp-fb:108 nack pli\r\na=fmtp:108 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=4d0032\r\na=rtpmap:109 rtx/90000\r\na=fmtp:109 apt=108\r\na=rtpmap:124 H264/90000\r\na=rtcp-fb:124 goog-remb\r\na=rtcp-fb:124 transport-cc\r\na=rtcp-fb:124 ccm fir\r\na=rtcp-fb:124 nack\r\na=rtcp-fb:124 nack pli\r\na=fmtp:124 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=640032\r\na=rtpmap:120 rtx/90000\r\na=fmtp:120 apt=124\r\na=rtpmap:123 red/90000\r\na=rtpmap:119 rtx/90000\r\na=fmtp:119 apt=123\r\na=rtpmap:114 ulpfec/90000\r\na=ssrc-group:FID 1714381393 967654061\r\na=ssrc:1714381393 cname:kufSZ8JnlRUuQVc2\r\na=ssrc:1714381393 msid:381b9efc-7cf5-45bb-8f39-c06558b288de 99d2faa8-950d-40f7-ad80-16789c9b4faa\r\na=ssrc:1714381393 mslabel:381b9efc-7cf5-45bb-8f39-c06558b288de\r\na=ssrc:1714381393 label:99d2faa8-950d-40f7-ad80-16789c9b4faa\r\na=ssrc:967654061 cname:kufSZ8JnlRUuQVc2\r\na=ssrc:967654061 msid:381b9efc-7cf5-45bb-8f39-c06558b288de 99d2faa8-950d-40f7-ad80-16789c9b4faa\r\na=ssrc:967654061 mslabel:381b9efc-7cf5-45bb-8f39-c06558b288de\r\na=ssrc:967654061 label:99d2faa8-950d-40f7-ad80-16789c9b4faa\r\n'; const SDP_CHANGED = 'v=0\r\no=- 135160591336882782 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE audio video\r\na=msid-semantic: WMS 381b9efc-7cf5-45bb-8f39-c06558b288de\r\nm=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 0 8 106 105 13 110 112 113 126\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:Y5Zy\r\na=ice-pwd:yQLVrXgG+irP0tgLLr4ZjQb5\r\na=ice-options:trickle\r\na=fingerprint:sha-256 45:ED:86:FB:EB:FE:21:20:62:C4:07:81:AA:B8:BC:87:60:CC:2B:54:CE:D5:F0:16:93:C4:61:23:28:59:DF:8B\r\na=setup:actpass\r\na=mid:audio\r\na=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\na=sendrecv\r\na=rtcp-mux\r\na=rtpmap:111 opus/48000/2\r\na=rtcp-fb:111 transport-cc\r\na=fmtp:111 minptime=10;useinbandfec=1;x-google-max-bitrate=2048;x-google-min-bitrate=0;x-google-start-bitrate=1024\r\na=rtpmap:103 ISAC/16000\r\na=rtpmap:104 ISAC/32000\r\na=rtpmap:9 G722/8000\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:106 CN/32000\r\na=rtpmap:105 CN/16000\r\na=rtpmap:13 CN/8000\r\na=rtpmap:110 telephone-event/48000\r\na=rtpmap:112 telephone-event/32000\r\na=rtpmap:113 telephone-event/16000\r\na=rtpmap:126 telephone-event/8000\r\na=ssrc:3652058873 cname:kufSZ8JnlRUuQVc2\r\na=ssrc:3652058873 msid:381b9efc-7cf5-45bb-8f39-c06558b288de 8841cbb1-90ba-4655-8784-60a185846706\r\na=ssrc:3652058873 mslabel:381b9efc-7cf5-45bb-8f39-c06558b288de\r\na=ssrc:3652058873 label:8841cbb1-90ba-4655-8784-60a185846706\r\nm=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99 100 101 102 122 127 121 125 107 108 109 124 120 123 119 114\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:Y5Zy\r\na=ice-pwd:yQLVrXgG+irP0tgLLr4ZjQb5\r\na=ice-options:trickle\r\na=fingerprint:sha-256 45:ED:86:FB:EB:FE:21:20:62:C4:07:81:AA:B8:BC:87:60:CC:2B:54:CE:D5:F0:16:93:C4:61:23:28:59:DF:8B\r\na=setup:actpass\r\na=mid:video\r\nb=AS:2048\r\na=extmap:2 urn:ietf:params:rtp-hdrext:toffset\r\na=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:4 urn:3gpp:video-orientation\r\na=extmap:5 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\na=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay\r\na=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type\r\na=extmap:8 http://www.webrtc.org/experiments/rtp-hdrext/video-timing\r\na=extmap:10 http://tools.ietf.org/html/draft-ietf-avtext-framemarking-07\r\na=sendrecv\r\na=rtcp-mux\r\na=rtcp-rsize\r\na=rtpmap:96 VP8/90000\r\na=rtcp-fb:96 goog-remb\r\na=rtcp-fb:96 transport-cc\r\na=rtcp-fb:96 ccm fir\r\na=rtcp-fb:96 nack\r\na=rtcp-fb:96 nack pli\r\na=rtpmap:97 rtx/90000\r\na=fmtp:97 apt=96;x-google-max-bitrate=2048;x-google-min-bitrate=0;x-google-start-bitrate=1024\r\na=rtpmap:98 VP9/90000\r\na=rtcp-fb:98 goog-remb\r\na=rtcp-fb:98 transport-cc\r\na=rtcp-fb:98 ccm fir\r\na=rtcp-fb:98 nack\r\na=rtcp-fb:98 nack pli\r\na=fmtp:98 profile-id=0;x-google-max-bitrate=2048;x-google-min-bitrate=0;x-google-start-bitrate=1024\r\na=rtpmap:99 rtx/90000\r\na=fmtp:99 apt=98;x-google-max-bitrate=2048;x-google-min-bitrate=0;x-google-start-bitrate=1024\r\na=rtpmap:100 H264/90000\r\na=rtcp-fb:100 goog-remb\r\na=rtcp-fb:100 transport-cc\r\na=rtcp-fb:100 ccm fir\r\na=rtcp-fb:100 nack\r\na=rtcp-fb:100 nack pli\r\na=fmtp:100 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f;x-google-max-bitrate=2048;x-google-min-bitrate=0;x-google-start-bitrate=1024\r\na=rtpmap:101 rtx/90000\r\na=fmtp:101 apt=100;x-google-max-bitrate=2048;x-google-min-bitrate=0;x-google-start-bitrate=1024\r\na=rtpmap:102 H264/90000\r\na=rtcp-fb:102 goog-remb\r\na=rtcp-fb:102 transport-cc\r\na=rtcp-fb:102 ccm fir\r\na=rtcp-fb:102 nack\r\na=rtcp-fb:102 nack pli\r\na=fmtp:102 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42001f;x-google-max-bitrate=2048;x-google-min-bitrate=0;x-google-start-bitrate=1024\r\na=rtpmap:122 rtx/90000\r\na=fmtp:122 apt=102;x-google-max-bitrate=2048;x-google-min-bitrate=0;x-google-start-bitrate=1024\r\na=rtpmap:127 H264/90000\r\na=rtcp-fb:127 goog-remb\r\na=rtcp-fb:127 transport-cc\r\na=rtcp-fb:127 ccm fir\r\na=rtcp-fb:127 nack\r\na=rtcp-fb:127 nack pli\r\na=fmtp:127 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f;x-google-max-bitrate=2048;x-google-min-bitrate=0;x-google-start-bitrate=1024\r\na=rtpmap:121 rtx/90000\r\na=fmtp:121 apt=127;x-google-max-bitrate=2048;x-google-min-bitrate=0;x-google-start-bitrate=1024\r\na=rtpmap:125 H264/90000\r\na=rtcp-fb:125 goog-remb\r\na=rtcp-fb:125 transport-cc\r\na=rtcp-fb:125 ccm fir\r\na=rtcp-fb:125 nack\r\na=rtcp-fb:125 nack pli\r\na=fmtp:125 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42e01f;x-google-max-bitrate=2048;x-google-min-bitrate=0;x-google-start-bitrate=1024\r\na=rtpmap:107 rtx/90000\r\na=fmtp:107 apt=125;x-google-max-bitrate=2048;x-google-min-bitrate=0;x-google-start-bitrate=1024\r\na=rtpmap:108 H264/90000\r\na=rtcp-fb:108 goog-remb\r\na=rtcp-fb:108 transport-cc\r\na=rtcp-fb:108 ccm fir\r\na=rtcp-fb:108 nack\r\na=rtcp-fb:108 nack pli\r\na=fmtp:108 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=4d0032;x-google-max-bitrate=2048;x-google-min-bitrate=0;x-google-start-bitrate=1024\r\na=rtpmap:109 rtx/90000\r\na=fmtp:109 apt=108;x-google-max-bitrate=2048;x-google-min-bitrate=0;x-google-start-bitrate=1024\r\na=rtpmap:124 H264/90000\r\na=rtcp-fb:124 goog-remb\r\na=rtcp-fb:124 transport-cc\r\na=rtcp-fb:124 ccm fir\r\na=rtcp-fb:124 nack\r\na=rtcp-fb:124 nack pli\r\na=fmtp:124 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=640032;x-google-max-bitrate=2048;x-google-min-bitrate=0;x-google-start-bitrate=1024\r\na=rtpmap:120 rtx/90000\r\na=fmtp:120 apt=124;x-google-max-bitrate=2048;x-google-min-bitrate=0;x-google-start-bitrate=1024\r\na=rtpmap:123 red/90000\r\na=rtpmap:119 rtx/90000\r\na=fmtp:119 apt=123;x-google-max-bitrate=2048;x-google-min-bitrate=0;x-google-start-bitrate=1024\r\na=rtpmap:114 ulpfec/90000\r\na=ssrc-group:FID 1714381393 967654061\r\na=ssrc:1714381393 cname:kufSZ8JnlRUuQVc2\r\na=ssrc:1714381393 msid:381b9efc-7cf5-45bb-8f39-c06558b288de 99d2faa8-950d-40f7-ad80-16789c9b4faa\r\na=ssrc:1714381393 mslabel:381b9efc-7cf5-45bb-8f39-c06558b288de\r\na=ssrc:1714381393 label:99d2faa8-950d-40f7-ad80-16789c9b4faa\r\na=ssrc:967654061 cname:kufSZ8JnlRUuQVc2\r\na=ssrc:967654061 msid:381b9efc-7cf5-45bb-8f39-c06558b288de 99d2faa8-950d-40f7-ad80-16789c9b4faa\r\na=ssrc:967654061 mslabel:381b9efc-7cf5-45bb-8f39-c06558b288de\r\na=ssrc:967654061 label:99d2faa8-950d-40f7-ad80-16789c9b4faa\r\n'; expect(sdpBitrateHack(SDP, 2048, 0, 1024)).toEqual(SDP_CHANGED); }); it('change the SDP properly with other values', () => { const SDP = 'v=0\r\no=- 135160591336882782 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE audio video\r\na=msid-semantic: WMS 381b9efc-7cf5-45bb-8f39-c06558b288de\r\nm=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 0 8 106 105 13 110 112 113 126\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:Y5Zy\r\na=ice-pwd:yQLVrXgG+irP0tgLLr4ZjQb5\r\na=ice-options:trickle\r\na=fingerprint:sha-256 45:ED:86:FB:EB:FE:21:20:62:C4:07:81:AA:B8:BC:87:60:CC:2B:54:CE:D5:F0:16:93:C4:61:23:28:59:DF:8B\r\na=setup:actpass\r\na=mid:audio\r\na=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\na=sendrecv\r\na=rtcp-mux\r\na=rtpmap:111 opus/48000/2\r\na=rtcp-fb:111 transport-cc\r\na=fmtp:111 minptime=10;useinbandfec=1\r\na=rtpmap:103 ISAC/16000\r\na=rtpmap:104 ISAC/32000\r\na=rtpmap:9 G722/8000\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:106 CN/32000\r\na=rtpmap:105 CN/16000\r\na=rtpmap:13 CN/8000\r\na=rtpmap:110 telephone-event/48000\r\na=rtpmap:112 telephone-event/32000\r\na=rtpmap:113 telephone-event/16000\r\na=rtpmap:126 telephone-event/8000\r\na=ssrc:3652058873 cname:kufSZ8JnlRUuQVc2\r\na=ssrc:3652058873 msid:381b9efc-7cf5-45bb-8f39-c06558b288de 8841cbb1-90ba-4655-8784-60a185846706\r\na=ssrc:3652058873 mslabel:381b9efc-7cf5-45bb-8f39-c06558b288de\r\na=ssrc:3652058873 label:8841cbb1-90ba-4655-8784-60a185846706\r\nm=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99 100 101 102 122 127 121 125 107 108 109 124 120 123 119 114\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:Y5Zy\r\na=ice-pwd:yQLVrXgG+irP0tgLLr4ZjQb5\r\na=ice-options:trickle\r\na=fingerprint:sha-256 45:ED:86:FB:EB:FE:21:20:62:C4:07:81:AA:B8:BC:87:60:CC:2B:54:CE:D5:F0:16:93:C4:61:23:28:59:DF:8B\r\na=setup:actpass\r\na=mid:video\r\na=extmap:2 urn:ietf:params:rtp-hdrext:toffset\r\na=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:4 urn:3gpp:video-orientation\r\na=extmap:5 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\na=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay\r\na=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type\r\na=extmap:8 http://www.webrtc.org/experiments/rtp-hdrext/video-timing\r\na=extmap:10 http://tools.ietf.org/html/draft-ietf-avtext-framemarking-07\r\na=sendrecv\r\na=rtcp-mux\r\na=rtcp-rsize\r\na=rtpmap:96 VP8/90000\r\na=rtcp-fb:96 goog-remb\r\na=rtcp-fb:96 transport-cc\r\na=rtcp-fb:96 ccm fir\r\na=rtcp-fb:96 nack\r\na=rtcp-fb:96 nack pli\r\na=rtpmap:97 rtx/90000\r\na=fmtp:97 apt=96\r\na=rtpmap:98 VP9/90000\r\na=rtcp-fb:98 goog-remb\r\na=rtcp-fb:98 transport-cc\r\na=rtcp-fb:98 ccm fir\r\na=rtcp-fb:98 nack\r\na=rtcp-fb:98 nack pli\r\na=fmtp:98 profile-id=0\r\na=rtpmap:99 rtx/90000\r\na=fmtp:99 apt=98\r\na=rtpmap:100 H264/90000\r\na=rtcp-fb:100 goog-remb\r\na=rtcp-fb:100 transport-cc\r\na=rtcp-fb:100 ccm fir\r\na=rtcp-fb:100 nack\r\na=rtcp-fb:100 nack pli\r\na=fmtp:100 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f\r\na=rtpmap:101 rtx/90000\r\na=fmtp:101 apt=100\r\na=rtpmap:102 H264/90000\r\na=rtcp-fb:102 goog-remb\r\na=rtcp-fb:102 transport-cc\r\na=rtcp-fb:102 ccm fir\r\na=rtcp-fb:102 nack\r\na=rtcp-fb:102 nack pli\r\na=fmtp:102 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42001f\r\na=rtpmap:122 rtx/90000\r\na=fmtp:122 apt=102\r\na=rtpmap:127 H264/90000\r\na=rtcp-fb:127 goog-remb\r\na=rtcp-fb:127 transport-cc\r\na=rtcp-fb:127 ccm fir\r\na=rtcp-fb:127 nack\r\na=rtcp-fb:127 nack pli\r\na=fmtp:127 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f\r\na=rtpmap:121 rtx/90000\r\na=fmtp:121 apt=127\r\na=rtpmap:125 H264/90000\r\na=rtcp-fb:125 goog-remb\r\na=rtcp-fb:125 transport-cc\r\na=rtcp-fb:125 ccm fir\r\na=rtcp-fb:125 nack\r\na=rtcp-fb:125 nack pli\r\na=fmtp:125 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42e01f\r\na=rtpmap:107 rtx/90000\r\na=fmtp:107 apt=125\r\na=rtpmap:108 H264/90000\r\na=rtcp-fb:108 goog-remb\r\na=rtcp-fb:108 transport-cc\r\na=rtcp-fb:108 ccm fir\r\na=rtcp-fb:108 nack\r\na=rtcp-fb:108 nack pli\r\na=fmtp:108 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=4d0032\r\na=rtpmap:109 rtx/90000\r\na=fmtp:109 apt=108\r\na=rtpmap:124 H264/90000\r\na=rtcp-fb:124 goog-remb\r\na=rtcp-fb:124 transport-cc\r\na=rtcp-fb:124 ccm fir\r\na=rtcp-fb:124 nack\r\na=rtcp-fb:124 nack pli\r\na=fmtp:124 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=640032\r\na=rtpmap:120 rtx/90000\r\na=fmtp:120 apt=124\r\na=rtpmap:123 red/90000\r\na=rtpmap:119 rtx/90000\r\na=fmtp:119 apt=123\r\na=rtpmap:114 ulpfec/90000\r\na=ssrc-group:FID 1714381393 967654061\r\na=ssrc:1714381393 cname:kufSZ8JnlRUuQVc2\r\na=ssrc:1714381393 msid:381b9efc-7cf5-45bb-8f39-c06558b288de 99d2faa8-950d-40f7-ad80-16789c9b4faa\r\na=ssrc:1714381393 mslabel:381b9efc-7cf5-45bb-8f39-c06558b288de\r\na=ssrc:1714381393 label:99d2faa8-950d-40f7-ad80-16789c9b4faa\r\na=ssrc:967654061 cname:kufSZ8JnlRUuQVc2\r\na=ssrc:967654061 msid:381b9efc-7cf5-45bb-8f39-c06558b288de 99d2faa8-950d-40f7-ad80-16789c9b4faa\r\na=ssrc:967654061 mslabel:381b9efc-7cf5-45bb-8f39-c06558b288de\r\na=ssrc:967654061 label:99d2faa8-950d-40f7-ad80-16789c9b4faa\r\n'; const SDP_CHANGED = 'v=0\r\no=- 135160591336882782 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE audio video\r\na=msid-semantic: WMS 381b9efc-7cf5-45bb-8f39-c06558b288de\r\nm=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 0 8 106 105 13 110 112 113 126\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:Y5Zy\r\na=ice-pwd:yQLVrXgG+irP0tgLLr4ZjQb5\r\na=ice-options:trickle\r\na=fingerprint:sha-256 45:ED:86:FB:EB:FE:21:20:62:C4:07:81:AA:B8:BC:87:60:CC:2B:54:CE:D5:F0:16:93:C4:61:23:28:59:DF:8B\r\na=setup:actpass\r\na=mid:audio\r\na=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\na=sendrecv\r\na=rtcp-mux\r\na=rtpmap:111 opus/48000/2\r\na=rtcp-fb:111 transport-cc\r\na=fmtp:111 minptime=10;useinbandfec=1;x-google-max-bitrate=3072;x-google-min-bitrate=384;x-google-start-bitrate=1536\r\na=rtpmap:103 ISAC/16000\r\na=rtpmap:104 ISAC/32000\r\na=rtpmap:9 G722/8000\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:106 CN/32000\r\na=rtpmap:105 CN/16000\r\na=rtpmap:13 CN/8000\r\na=rtpmap:110 telephone-event/48000\r\na=rtpmap:112 telephone-event/32000\r\na=rtpmap:113 telephone-event/16000\r\na=rtpmap:126 telephone-event/8000\r\na=ssrc:3652058873 cname:kufSZ8JnlRUuQVc2\r\na=ssrc:3652058873 msid:381b9efc-7cf5-45bb-8f39-c06558b288de 8841cbb1-90ba-4655-8784-60a185846706\r\na=ssrc:3652058873 mslabel:381b9efc-7cf5-45bb-8f39-c06558b288de\r\na=ssrc:3652058873 label:8841cbb1-90ba-4655-8784-60a185846706\r\nm=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99 100 101 102 122 127 121 125 107 108 109 124 120 123 119 114\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:Y5Zy\r\na=ice-pwd:yQLVrXgG+irP0tgLLr4ZjQb5\r\na=ice-options:trickle\r\na=fingerprint:sha-256 45:ED:86:FB:EB:FE:21:20:62:C4:07:81:AA:B8:BC:87:60:CC:2B:54:CE:D5:F0:16:93:C4:61:23:28:59:DF:8B\r\na=setup:actpass\r\na=mid:video\r\nb=AS:3072\r\na=extmap:2 urn:ietf:params:rtp-hdrext:toffset\r\na=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:4 urn:3gpp:video-orientation\r\na=extmap:5 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\na=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay\r\na=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type\r\na=extmap:8 http://www.webrtc.org/experiments/rtp-hdrext/video-timing\r\na=extmap:10 http://tools.ietf.org/html/draft-ietf-avtext-framemarking-07\r\na=sendrecv\r\na=rtcp-mux\r\na=rtcp-rsize\r\na=rtpmap:96 VP8/90000\r\na=rtcp-fb:96 goog-remb\r\na=rtcp-fb:96 transport-cc\r\na=rtcp-fb:96 ccm fir\r\na=rtcp-fb:96 nack\r\na=rtcp-fb:96 nack pli\r\na=rtpmap:97 rtx/90000\r\na=fmtp:97 apt=96;x-google-max-bitrate=3072;x-google-min-bitrate=384;x-google-start-bitrate=1536\r\na=rtpmap:98 VP9/90000\r\na=rtcp-fb:98 goog-remb\r\na=rtcp-fb:98 transport-cc\r\na=rtcp-fb:98 ccm fir\r\na=rtcp-fb:98 nack\r\na=rtcp-fb:98 nack pli\r\na=fmtp:98 profile-id=0;x-google-max-bitrate=3072;x-google-min-bitrate=384;x-google-start-bitrate=1536\r\na=rtpmap:99 rtx/90000\r\na=fmtp:99 apt=98;x-google-max-bitrate=3072;x-google-min-bitrate=384;x-google-start-bitrate=1536\r\na=rtpmap:100 H264/90000\r\na=rtcp-fb:100 goog-remb\r\na=rtcp-fb:100 transport-cc\r\na=rtcp-fb:100 ccm fir\r\na=rtcp-fb:100 nack\r\na=rtcp-fb:100 nack pli\r\na=fmtp:100 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f;x-google-max-bitrate=3072;x-google-min-bitrate=384;x-google-start-bitrate=1536\r\na=rtpmap:101 rtx/90000\r\na=fmtp:101 apt=100;x-google-max-bitrate=3072;x-google-min-bitrate=384;x-google-start-bitrate=1536\r\na=rtpmap:102 H264/90000\r\na=rtcp-fb:102 goog-remb\r\na=rtcp-fb:102 transport-cc\r\na=rtcp-fb:102 ccm fir\r\na=rtcp-fb:102 nack\r\na=rtcp-fb:102 nack pli\r\na=fmtp:102 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42001f;x-google-max-bitrate=3072;x-google-min-bitrate=384;x-google-start-bitrate=1536\r\na=rtpmap:122 rtx/90000\r\na=fmtp:122 apt=102;x-google-max-bitrate=3072;x-google-min-bitrate=384;x-google-start-bitrate=1536\r\na=rtpmap:127 H264/90000\r\na=rtcp-fb:127 goog-remb\r\na=rtcp-fb:127 transport-cc\r\na=rtcp-fb:127 ccm fir\r\na=rtcp-fb:127 nack\r\na=rtcp-fb:127 nack pli\r\na=fmtp:127 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f;x-google-max-bitrate=3072;x-google-min-bitrate=384;x-google-start-bitrate=1536\r\na=rtpmap:121 rtx/90000\r\na=fmtp:121 apt=127;x-google-max-bitrate=3072;x-google-min-bitrate=384;x-google-start-bitrate=1536\r\na=rtpmap:125 H264/90000\r\na=rtcp-fb:125 goog-remb\r\na=rtcp-fb:125 transport-cc\r\na=rtcp-fb:125 ccm fir\r\na=rtcp-fb:125 nack\r\na=rtcp-fb:125 nack pli\r\na=fmtp:125 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42e01f;x-google-max-bitrate=3072;x-google-min-bitrate=384;x-google-start-bitrate=1536\r\na=rtpmap:107 rtx/90000\r\na=fmtp:107 apt=125;x-google-max-bitrate=3072;x-google-min-bitrate=384;x-google-start-bitrate=1536\r\na=rtpmap:108 H264/90000\r\na=rtcp-fb:108 goog-remb\r\na=rtcp-fb:108 transport-cc\r\na=rtcp-fb:108 ccm fir\r\na=rtcp-fb:108 nack\r\na=rtcp-fb:108 nack pli\r\na=fmtp:108 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=4d0032;x-google-max-bitrate=3072;x-google-min-bitrate=384;x-google-start-bitrate=1536\r\na=rtpmap:109 rtx/90000\r\na=fmtp:109 apt=108;x-google-max-bitrate=3072;x-google-min-bitrate=384;x-google-start-bitrate=1536\r\na=rtpmap:124 H264/90000\r\na=rtcp-fb:124 goog-remb\r\na=rtcp-fb:124 transport-cc\r\na=rtcp-fb:124 ccm fir\r\na=rtcp-fb:124 nack\r\na=rtcp-fb:124 nack pli\r\na=fmtp:124 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=640032;x-google-max-bitrate=3072;x-google-min-bitrate=384;x-google-start-bitrate=1536\r\na=rtpmap:120 rtx/90000\r\na=fmtp:120 apt=124;x-google-max-bitrate=3072;x-google-min-bitrate=384;x-google-start-bitrate=1536\r\na=rtpmap:123 red/90000\r\na=rtpmap:119 rtx/90000\r\na=fmtp:119 apt=123;x-google-max-bitrate=3072;x-google-min-bitrate=384;x-google-start-bitrate=1536\r\na=rtpmap:114 ulpfec/90000\r\na=ssrc-group:FID 1714381393 967654061\r\na=ssrc:1714381393 cname:kufSZ8JnlRUuQVc2\r\na=ssrc:1714381393 msid:381b9efc-7cf5-45bb-8f39-c06558b288de 99d2faa8-950d-40f7-ad80-16789c9b4faa\r\na=ssrc:1714381393 mslabel:381b9efc-7cf5-45bb-8f39-c06558b288de\r\na=ssrc:1714381393 label:99d2faa8-950d-40f7-ad80-16789c9b4faa\r\na=ssrc:967654061 cname:kufSZ8JnlRUuQVc2\r\na=ssrc:967654061 msid:381b9efc-7cf5-45bb-8f39-c06558b288de 99d2faa8-950d-40f7-ad80-16789c9b4faa\r\na=ssrc:967654061 mslabel:381b9efc-7cf5-45bb-8f39-c06558b288de\r\na=ssrc:967654061 label:99d2faa8-950d-40f7-ad80-16789c9b4faa\r\n'; expect(sdpBitrateHack(SDP, 3072, 384, 1536)).toEqual(SDP_CHANGED); }); }); describe('getDevices', () => { beforeEach(() => { // @ts-ignore navigator.mediaDevices.getUserMedia.mockClear(); }); it('should return the device list removing the duplicates', async (done) => { const devices = await getDevices(); expect(devices).toHaveLength(5); done(); }); it('should return the full device list', async (done) => { const devices = await getDevices(null, true); expect(devices).toHaveLength(7); done(); }); it('should return the audioIn device list with kind audioinput', async (done) => { const devices = await getDevices('audioinput'); expect(devices).toHaveLength(2); expect(devices[0].deviceId).toEqual('default'); done(); }); it('should return the video device list with kind videoinput', async (done) => { const devices = await getDevices('videoinput'); expect(devices).toHaveLength(2); expect(devices[0].deviceId).toEqual( '2060bf50ab9c29c12598bf4eafeafa71d4837c667c7c172bb4407ec6c5150206' ); done(); }); it('should return the audioOut device list with kind audiooutput', async (done) => { const devices = await getDevices('audiooutput'); expect(devices).toHaveLength(1); expect(devices[0].deviceId).toEqual('default'); done(); }); describe('without camera permissions', () => { const DEVICES_CAMERA_NO_LABELS = [ { deviceId: 'uuid', kind: 'audioinput', label: 'mic1', groupId: '83ef347b97d14abd837e8c6dbb819c5be84cfe0756dd41455b375cfd4c0ddb4f', }, { deviceId: 'uuid', kind: 'audioinput', label: 'mic2', groupId: '83ef347b97d14abd837e8c6dbb819c5be84cfe0756dd41455b375cfd4c0ddb4f', }, { deviceId: 'uuid', kind: 'audioinput', label: 'mic3', groupId: '67a612f4ac80c6c9854b50d664348e69b5a11421a0ba8d68e2c00f3539992b4c', }, { deviceId: 'uuid', kind: 'videoinput', label: '', groupId: '72e8ab9444144c3f8e04276a5801e520e83fc801702a6ef68e9e344083f6f6ce', }, { deviceId: 'uuid', kind: 'videoinput', label: '', groupId: '67a612f4ac80c6c9854b50d664348e69b5a11421a0ba8d68e2c00f3539992b4c', }, { deviceId: 'uuid', kind: 'audiooutput', label: 'speaker1', groupId: '83ef347b97d14abd837e8c6dbb819c5be84cfe0756dd41455b375cfd4c0ddb4f', }, { deviceId: 'uuid', kind: 'audiooutput', label: 'speaker2', groupId: '83ef347b97d14abd837e8c6dbb819c5be84cfe0756dd41455b375cfd4c0ddb4f', }, ]; it('should invoke getUserMedia to request camera permissions and return device list removing duplicates', async (done) => { const devices = await getDevices(); expect(navigator.mediaDevices.getUserMedia).toHaveBeenCalledTimes(1); expect(navigator.mediaDevices.getUserMedia).toHaveBeenCalledWith({ audio: true, video: true, }); expect(devices[0].label).toEqual( 'Default - External Microphone (Built-in)' ); expect( devices.every((d: MediaDeviceInfo) => d.deviceId && d.label) ).toBe(true); done(); }); }); describe('without microphone permissions', () => { const DEVICES_MICROPHONE_NO_LABELS = [ { deviceId: 'uuid', kind: 'audioinput', label: '', groupId: '83ef347b97d14abd837e8c6dbb819c5be84cfe0756dd41455b375cfd4c0ddb4f', }, { deviceId: 'uuid', kind: 'audioinput', label: '', groupId: '83ef347b97d14abd837e8c6dbb819c5be84cfe0756dd41455b375cfd4c0ddb4f', }, { deviceId: 'uuid', kind: 'audioinput', label: '', groupId: '67a612f4ac80c6c9854b50d664348e69b5a11421a0ba8d68e2c00f3539992b4c', }, { deviceId: 'uuid', kind: 'videoinput', label: 'camera1', groupId: '72e8ab9444144c3f8e04276a5801e520e83fc801702a6ef68e9e344083f6f6ce', }, { deviceId: 'uuid', kind: 'videoinput', label: 'camera2', groupId: '67a612f4ac80c6c9854b50d664348e69b5a11421a0ba8d68e2c00f3539992b4c', }, { deviceId: 'uuid', kind: 'audiooutput', label: 'speaker1', groupId: '83ef347b97d14abd837e8c6dbb819c5be84cfe0756dd41455b375cfd4c0ddb4f', }, { deviceId: 'uuid', kind: 'audiooutput', label: 'speaker2', groupId: '83ef347b97d14abd837e8c6dbb819c5be84cfe0756dd41455b375cfd4c0ddb4f', }, ]; it('should invoke getUserMedia to request microphone permissions and return device list removing duplicates', async (done) => { const devices = await getDevices(); expect(navigator.mediaDevices.getUserMedia).toHaveBeenCalledTimes(1); expect(navigator.mediaDevices.getUserMedia).toHaveBeenCalledWith({ audio: true, video: true, }); expect(devices[0].label).toEqual( 'Default - External Microphone (Built-in)' ); expect( devices.every((d: MediaDeviceInfo) => d.deviceId && d.label) ).toBe(true); done(); }); }); }); describe('assureDeviceId', () => { beforeEach(() => { // @ts-ignore navigator.mediaDevices.enumerateDevices.mockClear(); }); it('should return the deviceId if the device is available', async (done) => { // See setup/browser.ts for these values. const deviceId = await assureDeviceId( '2060bf50ab9c29c12598bf4eafeafa71d4837c667c7c172bb4407ec6c5150206', 'FaceTime HD Camera', 'videoinput' ); expect(deviceId).toEqual( '2060bf50ab9c29c12598bf4eafeafa71d4837c667c7c172bb4407ec6c5150206' ); expect(navigator.mediaDevices.enumerateDevices).toHaveBeenCalledTimes(1); done(); }); it('should return null if the device is no longer available', async (done) => { const NEW_DEVICE_LIST = [ { deviceId: 'uuid', kind: 'videoinput', label: 'camera1', groupId: '72e8ab9444144c3f8e04276a5801e520e83fc801702a6ef68e9e344083f6f6ce', }, { deviceId: 'uuid', kind: 'videoinput', label: 'camera2', groupId: '67a612f4ac80c6c9854b50d664348e69b5a11421a0ba8d68e2c00f3539992b4c', }, ]; // @ts-ignore navigator.mediaDevices.enumerateDevices.mockResolvedValueOnce( NEW_DEVICE_LIST ); const deviceId = await assureDeviceId( '2060bf50ab9c29c12598bf4eafeafa71d4837c667c7c172bb4407ec6c5150206', 'FaceTime HD Camera', 'videoinput' ); expect(deviceId).toBeNull(); expect(navigator.mediaDevices.enumerateDevices).toHaveBeenCalledTimes(1); done(); }); it('should recognize the device by its label', async (done) => { const NEW_DEVICE_LIST = [ { deviceId: 'uuid', kind: 'videoinput', label: 'camera1', groupId: '72e8ab9444144c3f8e04276a5801e520e83fc801702a6ef68e9e344083f6f6ce', }, { deviceId: 'new-uuid', kind: 'videoinput', label: 'FaceTime HD Camera', groupId: '67a612f4ac80c6c9854b50d664348e69b5a11421a0ba8d68e2c00f3539992b4c', }, ]; // @ts-ignore navigator.mediaDevices.enumerateDevices.mockResolvedValueOnce( NEW_DEVICE_LIST ); const deviceId = await assureDeviceId( '2060bf50ab9c29c12598bf4eafeafa71d4837c667c7c172bb4407ec6c5150206', 'FaceTime HD Camera', 'videoinput' ); expect(deviceId).toEqual('new-uuid'); expect(navigator.mediaDevices.enumerateDevices).toHaveBeenCalledTimes(1); done(); }); }); describe('getBrowserInfo', () => { it('should return error when code runs without a web browser', async (done) => { Object.defineProperty(global, 'navigator', { value: null, writable: true, }); expect(() => getBrowserInfo()).toThrow( 'You should use @telnyx/webrtc in a web browser such as Chrome|Firefox|Safari' ); done(); }); it('should return error when code runs in not supported browser', async (done) => { Object.defineProperty(global, 'navigator', { value: { userAgent: "I'm a not supported browser" }, writable: true, }); expect(() => getBrowserInfo()).toThrow( 'This browser does not support @telnyx/webrtc. To see browser support list: `TelnyxRTC.webRTCSupportedBrowserList()`' ); done(); }); it('should return error when code runs in not supported browser', async (done) => { Object.defineProperty(global, 'navigator', { value: { userAgent: "I'm a not supported browser" }, writable: true, }); expect(() => getBrowserInfo()).toThrow( 'This browser does not support @telnyx/webrtc. To see browser support list: `TelnyxRTC.webRTCSupportedBrowserList()`' ); done(); }); it('should return error when code runs in Opera browser', async (done) => { Object.defineProperty(global, 'navigator', { value: { userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36 OPR/72.0.3815.400', }, writable: true, }); expect(() => getBrowserInfo()).toThrow( 'This browser does not support @telnyx/webrtc. To see browser support list: `TelnyxRTC.webRTCSupportedBrowserList()`' ); done(); }); it('should return supported configuration for WebRTC when the browser is Chrome', async (done) => { Object.defineProperty(global, 'navigator', { value: { userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36', }, writable: true, }); const result = getBrowserInfo(); expect(result).not.toBeNull(); expect(result.name).toEqual('Chrome'); expect(result.version).toEqual(87); expect(result.supportAudio).toBeTruthy(); expect(result.supportVideo).toBeTruthy(); done(); }); it('should return supported configuration for WebRTC when the browser is Firefox', async (done) => { Object.defineProperty(global, 'navigator', { value: { userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:84.0) Gecko/20100101 Firefox/84.0', }, writable: true, }); const result = getBrowserInfo(); expect(result).not.toBeNull(); expect(result.name).toEqual('Firefox'); expect(result.version).toEqual(84); expect(result.supportAudio).toBeTruthy(); expect(result.supportVideo).toBeFalsy(); done(); }); it('should return supported configuration for WebRTC when the browser is Safari', async (done) => { Object.defineProperty(global, 'navigator', { value: { userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.1 Safari/605.1.15', }, writable: true, }); const result = getBrowserInfo(); expect(result).not.toBeNull(); expect(result.name).toEqual('Safari'); expect(result.version).toEqual(14); expect(result.supportAudio).toBeTruthy(); expect(result.supportVideo).toBeTruthy(); done(); }); it('should return supported configuration for WebRTC when the browser is Edge', async (done) => { Object.defineProperty(global, 'navigator', { value: { userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36 Edg/87.0.664.75', }, writable: true, }); const result = getBrowserInfo(); expect(result).not.toBeNull(); expect(result.name).toEqual('Edg'); expect(result.version).toEqual(87); expect(result.supportAudio).toBeTruthy(); expect(result.supportVideo).toBeTruthy();
}); describe('getWebRTCInfo', () => { it('should return error when code runs without a web browser', async (done) => { Object.defineProperty(global, 'navigator', { value: null, writable: true, }); const result = getWebRTCInfo(); expect(result).toEqual( 'You should use @telnyx/webrtc in a web browser such as Chrome|Firefox|Safari' ); done(); }); it('should return webRTC info about supported features on current browser', async (done) => { const chromeUserAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36'; Object.defineProperty(global, 'navigator', { value: { userAgent: chromeUserAgent }, writable: true, }); const mockFn = jest.fn().mockImplementation(() => { return { global: { RTCPeerConnection: jest.fn(), }, }; }); const result = getWebRTCInfo(); expect(result).not.toBeNull(); expect(result.browserInfo).toEqual(chromeUserAgent); expect(result.browserName).toEqual('Chrome'); expect(result.browserVersion).toEqual(87); expect(result.supportRTCPeerConnection).toBeTruthy(); done(); }); it('should return supportWebRTC equal false when browser does not support RTC', async (done) => { jest.clearAllMocks(); const chromeUserAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36'; Object.defineProperty(global, 'navigator', { value: { userAgent: chromeUserAgent }, writable: true, }); const result = getWebRTCInfo(); expect(result).not.toBeNull(); expect(result.browserInfo).toEqual(chromeUserAgent); expect(result.browserName).toEqual('Chrome'); expect(result.browserVersion).toEqual(87); expect(result.supportWebRTC).toBeFalsy(); done(); }); }); describe('getWebRTCSupportedBrowserList', () => { const supportedBrowserList = [ { operationSystem: 'Android', supported: [ { browserName: 'Chrome', features: ['audio'], supported: 'full' }, { browserName: 'Firefox', features: ['audio'], supported: 'partial' }, { browserName: 'Safari', supported: 'not supported' }, { browserName: 'Edge', supported: 'not supported' }, ], }, { operationSystem: 'iOS', supported: [ { browserName: 'Chrome', supported: 'not supported' }, { browserName: 'Firefox', supported: 'not supported' }, { browserName: 'Safari', features: ['video', 'audio'], supported: 'full' }, { browserName: 'Edge', supported: 'not supported' }, ], }, { operationSystem: 'Linux', supported: [ { browserName: 'Chrome', features: ['video', 'audio'], supported: 'full', }, { browserName: 'Firefox', features: ['audio'], supported: 'partial' }, { browserName: 'Safari', supported: 'not supported' }, { browserName: 'Edge', supported: 'not supported' }, ], }, { operationSystem: 'MacOS', supported: [ { browserName: 'Chrome', features: ['video', 'audio'], supported: 'full', }, { browserName: 'Firefox', features: ['audio'], supported: 'partial' }, { browserName: 'Safari', features: ['video', 'audio'], supported: 'full', }, { browserName: 'Edge', features: ['audio'], supported: 'partial' }, ], }, { operationSystem: 'Windows', supported: [ { browserName: 'Chrome', features: ['video', 'audio'], supported: 'full', }, { browserName: 'Firefox', features: ['audio'], supported: 'partial' }, { browserName: 'Safari', supported: 'not supported' }, { browserName: 'Edge', features: ['audio'], supported: 'partial' }, ], }, ]; it('should return an array with all webrtc supported browser list', () => { const result = getWebRTCSupportedBrowserList(); expect(result).not.toBeNull(); expect(result).toEqual(supportedBrowserList); }); it('should return an array with 5 operational system', () => { const result = getWebRTCSupportedBrowserList(); expect(result).not.toBeNull(); expect(result).toHaveLength(5); }); it('should return an array with 5 operational system', () => { const operationSystem = ['Android', 'iOS', 'Linux', 'MacOS', 'Windows']; const result = getWebRTCSupportedBrowserList(); expect(result).not.toBeNull(); const resultSO = result.map((item) => item.operationSystem); expect(result).toHaveLength(5); expect(resultSO).toEqual(operationSystem); }); it('should return an array with 4 supported browsers', () => { const browsers = ['Chrome', 'Firefox', 'Safari', 'Edge']; const result = getWebRTCSupportedBrowserList(); expect(result).not.toBeNull(); expect(result).toHaveLength(5); const resultSupportedBrowser = result.map((item) => item.supported); const supportedBroswers = resultSupportedBrowser[0].map( (item) => item.browserName ); expect(supportedBroswers).toEqual(browsers); }); it('should return supported info for MacOS using Firefox browser', () => { const result = getWebRTCSupportedBrowserList(); expect(result).not.toBeNull(); expect(result).toHaveLength(5); const resultMacOs = result.filter( (item) => item.operationSystem === 'MacOS' )[0]; const resultFirefox = resultMacOs.supported.filter( (item) => item.browserName === 'Firefox' )[0]; expect(resultFirefox.browserName).toEqual('Firefox'); expect(resultFirefox.supported).toEqual(SUPPORTED_WEBRTC.partial); expect(resultFirefox.features).toHaveLength(1); expect(resultFirefox.features[0]).toEqual('audio'); }); }); });
done(); });
runtimes.rs
// Copyright 2019 Parity Technologies (UK) Ltd. // This file is part of substrate-subxt. // // subxt 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. // // subxt 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 substrate-subxt. If not, see <http://www.gnu.org/licenses/>. use sp_runtime::{ generic::Header, traits::{ BlakeTwo256, IdentifyAccount, Verify, }, MultiSignature, OpaqueExtrinsic, }; use crate::frame::{ balances::{ AccountData, Balances, }, contracts::Contracts, system::System, }; /// Concrete type definitions compatible with those in the default substrate `node_runtime` /// /// # Note /// /// If the concrete types in the target substrate runtime differ from these, a custom Runtime /// definition MUST be used to ensure type compatibility. #[derive(Debug, Clone, Eq, PartialEq)] pub struct
; impl System for DefaultNodeRuntime { type Index = u32; type BlockNumber = u32; type Hash = sp_core::H256; type Hashing = BlakeTwo256; type AccountId = <<MultiSignature as Verify>::Signer as IdentifyAccount>::AccountId; type Address = pallet_indices::address::Address<Self::AccountId, u32>; type Header = Header<Self::BlockNumber, BlakeTwo256>; type Extrinsic = OpaqueExtrinsic; type AccountData = AccountData<<Self as Balances>::Balance>; } impl Balances for DefaultNodeRuntime { type Balance = u128; } impl Contracts for DefaultNodeRuntime {} /// Concrete type definitions compatible with those for kusama, v0.7 /// /// # Note /// /// Main difference is `type Address = AccountId`. /// Also the contracts module is not part of the kusama runtime. #[derive(Debug, Clone, Eq, PartialEq)] pub struct KusamaRuntime; impl System for KusamaRuntime { type Index = u32; type BlockNumber = u32; type Hash = sp_core::H256; type Hashing = BlakeTwo256; type AccountId = <<MultiSignature as Verify>::Signer as IdentifyAccount>::AccountId; type Address = Self::AccountId; type Header = Header<Self::BlockNumber, BlakeTwo256>; type Extrinsic = OpaqueExtrinsic; type AccountData = AccountData<<Self as Balances>::Balance>; } impl Balances for KusamaRuntime { type Balance = u128; }
DefaultNodeRuntime
resources.py
import os import re import ctypes import zlib import functools from urllib.parse import urlparse from collections import namedtuple from copy import deepcopy from datafaucet import metadata from datafaucet.paths import rootdir from datafaucet._utils import merge, to_ordered_dict from datafaucet.yaml import YamlDict from datafaucet.download import download import datafaucet.logging as log Urn = namedtuple('Urn', ['scheme', 'user', 'password', 'host', 'port', 'path', 'params', 'query', 'fragment']) def filter_empty(lst): return [x for x in lst if x != '' and x is not None] def tsplit(s, sep, shift='left'): s = s.split(sep) if shift=='left': return (s[0],s[1]) if len(s)>1 else ('', s[0]) else: # right return (s[0],s[1]) if len(s)>1 else (s[0], '') def urnparse(s): scheme, url = tsplit(s, '//') path_only = ((not scheme) or scheme.startswith('jdbc:sqlite') or scheme.startswith('s3a')) url = urlparse(url) if path_only else urlparse('scheme://'+url) path = url.path query = url.query scheme = filter_empty(scheme.split(':')) auth, netloc = tsplit(url.netloc, '@') user, password = tsplit(auth, ':', 'right') host, port = tsplit(netloc,':', 'right') # parsing oracle thin urn for user, password oracle_thin_scheme = len(scheme)==4 and ':'.join(scheme[0:3])=='jdbc:oracle:thin' if oracle_thin_scheme and scheme[-1][-1]=='@': o_user, o_password = tsplit(scheme[-1].rstrip('@'), '/', 'right') user = o_user or user password = o_password or password # parsing oracle params if oracle_thin_scheme: path, *params = path.split(',') query = query + '&'.join(filter_empty(params)) # parsing mssql params jdbc_mssql_scheme = len(scheme)==2 and ':'.join(scheme[0:2])=='jdbc:sqlserver' if jdbc_mssql_scheme: netloc, *params = netloc.split(';') host, port = tsplit(netloc,':', 'right') query = query + '&'.join(filter_empty(params)) params = filter_empty(query.split('&')) params = [tuple(p.split('=')) for p in params] urn = Urn(scheme,user, password, host, port, path, params, query, url.fragment) return urn def path_to_jdbc(md, provider=False): database = md['database'] table = md['table'] path = md['path'] or '' if md['format']!='jdbc': return database, table, path e = filter_empty(path.split('/')) if len(e)==0: pass elif len(e)==1: if provider: database = e[0] or None path = None else: table = e[0] or None path = None else: database = e[0] or None table = e[1] or None path = None return database, table, path def get_default_md(): f = [ 'service', 'format', 'version', 'host', 'port', 'driver', 'database', 'schema', 'table', 'user', 'password', 'path', 'options', 'provider' ] return dict(zip(f, [None for _ in range(len(f))])) def metadata_overrides(md, host=None, service=None, port=None, user=None, password=None, driver=None, database=None, schema=None, table=None, format=None, version=None, hostname=None, username=None, **options): d = {} d['path'] = md.get('url') or md.get('path') d['provider'] = md.get('provider') d['host'] = host or hostname or md['host'] or md.get('hostname') d['port'] = port or md['port'] d['service'] = service or md['service'] d['format'] = format or md['format'] d['version'] = version or md['version'] d['user'] = user or username or md['user'] or md.get('username') d['password'] = password or md['password'] d['database'] = database or md['database'] d['schema'] = schema or md['schema'] d['table'] = table or md['table'] d['driver'] = driver or md['driver'] d['options'] = merge(md['options'], options) if database or table: d['path'] = None return d def resource_from_dict(d): md = get_default_md() d['path'] = d.get('path') or d.get('url') for k in md.keys(): md[k] = d.get(k) return md def resource_from_urn(urn): md = get_default_md() query = get_sql_query(urn.path) if query: md['table'] = query md['format'] = 'jdbc' return md params = dict(urn.params) if urn.scheme and urn.scheme[0]=='jdbc': service, format = urn.scheme[1], urn.scheme[0] else: service = urn.scheme[0] if urn.scheme else '' format = get_format({'format':None, 'service': service, 'path': urn.path}) compression = get_compression(urn.path) if compression: params['compression'] = compression md['service'] = service md['format'] = format md['host'] = urn.host md['port'] = urn.port md['path'] = urn.path md['user'] = urn.user md['password'] = urn.password md['options'] = params for k,v in md.items(): if not v: md[k] = None return md def get_sql_query(s): # if SQL query is detected, # wrap the resource path as a temp table sql_query = s sql_query = sql_query.replace('\n', ' ') sql_query = sql_query.replace('\t', ' ') sql_query = sql_query.replace('\r', ' ') sql_query = ' '.join(sql_query.split()) sql_query = sql_query.rstrip(' ') sql_query = sql_query.rstrip(';') sql_query = sql_query.lower() #imple sql test: check for from or where prefixed with a space # indicates multiple words if any([x in sql_query for x in [' from ', ' where ']]): return sql_query else: return None def to_resource(url_alias=None, *args, **kwargs): md = None # if a dict, create from dictionary if isinstance(url_alias, dict): md = resource_from_dict(url_alias) # if a string, and a metadata profile is loaded, check for aliases if metadata.profile(): if not md and url_alias in metadata.profile().get('resources', {}).keys(): md = metadata.profile()['resources'][url_alias] if not md and url_alias in metadata.profile().get('providers', {}).keys(): md = metadata.profile()['providers'][url_alias] # if nothing found yet, interpret as a urn/path if not md and url_alias: md = resource_from_urn(urnparse(url_alias)) # empty default if not md: md = get_default_md() # sanitize path if it's a url or a query if md['path']: url_md = resource_from_urn(urnparse(md['path'])) md = merge(url_md, md) md['path'] = url_md['path'] # override using kwargs md = metadata_overrides(md, **kwargs) if 'hostname' in md: del md['hostname'] if 'username' in md: del md['username'] return md def get_compression(path): if not path: return None _, ext = os.path.splitext(path) d = { '.lz': 'lz', '.lzo': 'lzo', '.gz': 'gzip', '.bz2': 'bzip2', } return d.get(ext) def get_format(md): if md['format']: return md['format'] # get the provider format if md['service'] in ['sqlite', 'mysql', 'postgres', 'mssql', 'oracle']: return 'jdbc' if md['service'] in ['mongodb']: return 'mongo' if md['service'] in ['elastic']: return 'json' # check if path is a query query = get_sql_query(md['path']) if query: return 'jdbc' # extract the format from file extension #‘.gz’, ‘.bz2’, ‘.zip’, ‘.snappy’, '.deflate' path, ext = os.path.splitext(md['path']) if get_compression(md['path']): _, ext = os.path.splitext(path) if ext and ext[0]=='.': ext = ext[1:] # default is None return ext or None def get_driver(service): drivers = { 'sqlite': 'org.sqlite.JDBC', 'mysql': 'com.mysql.cj.jdbc.Driver', 'postgres': 'org.postgresql.Driver', 'mssql': 'com.microsoft.sqlserver.jdbc.SQLServerDriver', 'oracle': 'oracle.jdbc.driver.OracleDriver', 'clickhouse': 'ru.yandex.clickhouse.ClickHouseDriver' } return drivers.get(service) def get_port(service): ports = { 'http':80, 'https':443, 'hdfs': 8020, 'mysql': 3306, 'postgres': 5432, 'mssql': 1433, 'mongodb': 27017, 'oracle': 1521, 'clickhouse':8123, 'elastic': 9200, 's3a':9000 } return ports.get(service) def get_version(service): versions = { 'hdfs': '3.1.1', 'sqlite': '3.25.2', 'mysql': '8.0.12', 'postgres': '42.2.5', 'mssql': '6.4.0.jre8', 'mongodb': '2.4.1', 'oracle': '12.2.0.1', 'clickhouse':'0.1.54', 's3a':'3.1.1' } return versions.get(service) def get_url(md): service = md['service'] path = md['path'] host_port = f"{md['host']}:{md['port']}" if md['port'] else md['host'] if service in ['local', 'file']: url = path elif service == 'sqlite': url = f"jdbc:sqlite:{path}" elif service == 'hdfs': url = f"hdfs://{host_port}{md['path']}" elif service in ['http', 'https']: url = f"{service}://{host_port}{md['path']}" elif service in ['minio', 's3a']: url = f"s3a://{md['path']}" elif service == 'mysql': url = f"jdbc:mysql://{host_port}/{md['database']}" elif service == 'postgres': url = f"jdbc:postgresql://{host_port}/{md['database']}" elif service == 'clickhouse': url = f"jdbc:clickhouse://{host_port}/{md['database']}" elif service == 'mssql': url = f"jdbc:sqlserver://{host_port};databaseName={md['database']}" elif service == 'oracle': url = f"jdbc:oracle:thin:@//{host_port}/{md['database']}" elif service == 'elastic': url = f"http://{host_port}/{md['database']}" elif service == 'mongodb': url = f"mongodb://{md['user']}:{md['password']}@{host_port}/{md['path']}" return url def process_metadata(md): # update format from md['format'] = get_format(md) # if no service, at this point use file md['service'] = md['service'] or 'file' # standardize some service names services = { 'minio': 's3a', 'local': 'file' } md['service'] = services.get(md['service'], md['service']) # if no host, use localhost md['host'] = md['host'] or '127.0.0.1' # if local file system and rel path, prepend rootdir if md['service'] in ['file', 'sqlite'] and not os.path.isabs(md['path']): md['path'] = os.path.join(rootdir(), md['path']) # if service is s3a, remove leading '/' if md['service'] == 's3a' and md['path']: md['path'] = md['path'].lstrip('/') # if service is mongodb, use '.' instead of '/' if md['service'] == 'mongodb' and md['path']: md['path'] = md['path'].replace('/', '.') # generate database, table from path if md['format']=='jdbc': md['database'], md['table'], md['path'] = path_to_jdbc(md) # set driver md['driver'] = md['driver'] or get_driver(md['service']) # if not table, provide no result query md['table'] = md['table'] or 'SELECT 0 as result where 1 = 0' # if schema is not yet defined, # take the default for each service default_schemas = { 'mysql': md['database'], 'mssql': 'dbo', 'postgres': 'public', 'clickhouse': 'default', 'oracle': md['user'] } md['schema'] = md['schema'] or default_schemas.get(md['service']) query = get_sql_query(md['table']) if query and not query.endswith('as _query'): md['table'] = '( {} ) as _query'.format(query) md['version'] = md['version'] or get_version(md['service']) md['port'] = md['port'] or get_port(md['service']) md['port'] = int(md['port']) if md['port'] else None md['url'] = get_url(md) if not isinstance(md['options'], dict): md['options'] = {} compression = get_compression(md['path']) if md['format']!='jdbc' and compression: md['options']['compression'] = compression h_list = [] for k in ['url', 'format', 'table', 'database']: v = zlib.crc32(md[k].encode()) if md[k] else 0 h_list.append(v) md['hash'] = functools.reduce(lambda a,b : a^b, h_list) md['hash'] = hex(ctypes.c_size_t(md['hash']).value) return md def assemble_metadat
[ 'hash', 'url', 'service', 'version', 'format', 'host' ] if md['service'] != 'file': keys.append('port') if md['service'] == 's3a' or md['format'] == 'jdbc': keys.extend([ 'user', 'password']) if md['format'] == 'jdbc': keys.extend([ 'driver', 'database', 'schema', 'table']) keys.append('options') return YamlDict(to_ordered_dict(md, keys)) def Resource(path_or_alias_or_url=None, provider_path_or_alias_or_url=None, host=None, service=None, port=None, user=None, password=None, driver=None, database=None, schema=None, table=None, format=None, version=None, hostname=None, username=None, **options): prov = provider_path_or_alias_or_url path = path_or_alias_or_url # get the resource, by alias metadata or by url rmd = to_resource(path, host=host, service=service, port=port, user=user, password=password, driver=driver, database=database, schema=schema, table=table, format=format, version=version, hostname=hostname, username=username, **options) # get the provider by reference from the resource, if available prov = prov or rmd.get('provider') # get the provider, by alias metadata or by url pmd = to_resource(prov) # check if the provider is a jdbc connection, if so set it pmd['database'], pmd['table'], pmd['path'] = path_to_jdbc(pmd, True) # merge provider and resource metadata md = merge(pmd,rmd) # concatenate paths, if no table is defined if md['table']: md['path'] = None else: md['path'] = os.path.join(pmd['path'] or '', rmd['path'] or '') #process metadata md = process_metadata(md) #todo: verify resource # check format and other minimum requirements are met # assemble output md = assemble_metadata(md) return md def get_local(md): if md['service'].startswith('http'): md['path'] = download(md['url'], md['format']) md['service'] = 'file' md['url'] = None return Resource(md) else: return md
a(md): keys =
status.go
// // Copyright 2019 Insolar Technologies GmbH // // 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. // package metrics import ( "bytes" "fmt" "html/template" "io" "net/http" "time" "github.com/insolar/insolar/version" ) var statusTmpl = ` <html> <head>
<style> * { box-sizing: border-box; } h1 { text-transform: uppercase; } section { width: 100%; border: 1px solid blue; } section header { text-transform:uppercase; width: 100%; height: 48px; padding: 0 12px; line-height: 48px; font-size: 24px; background-color:blue; color: whitesmoke; } dl { display: grid; grid-template-columns: 200px 1fr; grid-template-rows: 1fr; } dl dt { grid-column: 1; font-weight: bold; text-transform: capitalize; text-align: right; } dl dd { grid-column: 2; } </style> </head> <body> <h1>STATUS</h1> <h2>Build info</h2> <pre> {{ .VersionInfo }} </pre> <section> <header>General</header> <div class="content"> <dl> <dt>Uptime:</dt> <dd>{{ .Uptime }}</dd> <dt>metrics:</dt> <dd><a href="/metrics">/metrics</a></dd> <dt>pprof:</dt> <dd><a href="/debug/pprof">/debug/pprof</a></dd> <dt>rpcz:</dt> <dd> <a href="/debug/rpcz">/debug/rpcz</a></dd> <dt>tracez:</dt> <dd><a href="/debug/tracez">/debug/tracez</a></dd> </dl> </div> </section> </body> </html> ` var parsedStatusTmpl = template.Must(template.New("proc_status").Parse(statusTmpl)) type procStatus struct { StartTime time.Time } func newProcStatus() *procStatus { info := &procStatus{ StartTime: time.Now(), } return info } func (ps *procStatus) ServeHTTP(w http.ResponseWriter, r *http.Request) { var b bytes.Buffer err := parsedStatusTmpl.Execute(&b, struct { VersionInfo string Uptime string }{ VersionInfo: version.GetFullVersion(), Uptime: fmt.Sprintf("%v", time.Since(ps.StartTime)), }) if err != nil { http.Error(w, fmt.Sprintln("Template error:", err), http.StatusInternalServerError) return } w.Header().Set("Content-Type", "text/html") _, err = io.Copy(w, &b) if err != nil { http.Error(w, fmt.Sprintln("Copy error:", err), http.StatusInternalServerError) return } }
<title>_status page</title>
visualization.py
from pathlib import Path import panel as pn import pandas as pd import plotly.express as px from models.pages import Page from models.utils.paths import get_prepared_data_path, get_standardized_data_file from dashboard.widgets import heatmap PREPARED_DATA_DIR = get_prepared_data_path() PREPARED_DATA_FILE = get_standardized_data_file() COLUMNS = ['non-communicable chronic disease [deaths]', 'cancer [deaths]', 'cardiovascular disease [deaths]', 'diabetes mellitus [deaths]', 'chronic respiratory diseases [deaths]', 'diseases of digestive system [deaths]', 'life expectancy [age]'] def get_correlation_heatmap(df, columns): corr = df[columns].corr() z = corr.values.round(decimals=2) x = corr.index y = corr.index return heatmap(z, x, y, labels=dict(color='Correlation')) def get_line_plot(df, x_col, y_col, index, title, width=500): if width is None: fig = px.line(df, x=x_col, y=y_col, color=index, title=title) return pn.pane.Plotly(fig) else: fig = px.line(df, x=x_col, y=y_col, color=index, title=title, width=width) return pn.pane.Plotly(fig) data = pd.read_csv(Path(PREPARED_DATA_DIR, PREPARED_DATA_FILE)) df = data[data['sex'] == 3] class VisualizationPage(Page): def __init__(self): super().__init__() self.df = df self.checkbutton = pn.widgets.CheckButtonGroup(name='Countries', value=['Netherlands'], options=['Netherlands', 'Japan', 'Canada']) self.pane = pn.Column(self.checkbutton, self.get_plot(self.checkbutton)) self.button = pn.widgets.Button(name='Visualization') self.checkbutton.param.watch(self.update, 'value') def get_plot(self, checkbutton): gspec = pn.GridSpec(ncols=2, nrows=4, width=1200, height=1800) selection = df.loc[df['country'].isin(checkbutton.value)] # life expectancy plot life_exp_plot = pn.pane.Plotly( px.line(selection, x='year', y='life expectancy [age]', color='country', title='life expectancy')) # plots about disease plots = [] for col in COLUMNS[:-1]: plots.append(pn.pane.Plotly( px.line(selection, x='year', y=col, labels={col: 'Deaths per 100.000 people'}, color='country', title=col.replace('[deaths]', '')))) gspec[0, :] = life_exp_plot gspec[1, 0] = plots[0] gspec[1, 1] = plots[1] gspec[2, 0] = plots[2] gspec[2, 1] = plots[3] gspec[3, 0] = plots[4] gspec[3, 1] = plots[5] return gspec def update(self, event):
def get_contents(self): return self.pane, self.button
self.pane[1] = self.get_plot(self.checkbutton)
json.value-object.ts
import { ValueObject } from './value-object'; export abstract class JsonValueObject extends ValueObject<string> { get value(): any {
} set value(value: any) { super.value = typeof value === 'string' ? JSON.parse(value) : value; } toString(): string { return JSON.stringify(this.value); } }
return super.value;
datamaps.flk.js
(function() { var svg; //save off default references var d3 = window.d3, topojson = window.topojson; var defaultOptions = { scope: 'world', responsive: false, aspectRatio: 0.5625, setProjection: setProjection, projection: 'equirectangular', dataType: 'json', data: {}, done: function() {}, fills: { defaultFill: '#ABDDA4' }, filters: {}, geographyConfig: { dataUrl: null, hideAntarctica: true, hideHawaiiAndAlaska : false, borderWidth: 1, borderColor: '#FDFDFD', popupTemplate: function(geography, data) { return '<div class="hoverinfo"><strong>' + geography.properties.name + '</strong></div>'; }, popupOnHover: true, highlightOnHover: true, highlightFillColor: '#FC8D59', highlightBorderColor: 'rgba(250, 15, 160, 0.2)', highlightBorderWidth: 2 }, projectionConfig: { rotation: [97, 0] }, bubblesConfig: { borderWidth: 2, borderColor: '#FFFFFF', popupOnHover: true, radius: null, popupTemplate: function(geography, data) { return '<div class="hoverinfo"><strong>' + data.name + '</strong></div>'; }, fillOpacity: 0.75, animate: true, highlightOnHover: true, highlightFillColor: '#FC8D59', highlightBorderColor: 'rgba(250, 15, 160, 0.2)', highlightBorderWidth: 2, highlightFillOpacity: 0.85, exitDelay: 100, key: JSON.stringify }, arcConfig: { strokeColor: '#DD1C77', strokeWidth: 1, arcSharpness: 1, animationSpeed: 600 } }; /* Getter for value. If not declared on datumValue, look up the chain into optionsValue */ function
( datumValue, optionsValue, context ) { if ( typeof context === 'undefined' ) { context = optionsValue; optionsValues = undefined; } var value = typeof datumValue !== 'undefined' ? datumValue : optionsValue; if (typeof value === 'undefined') { return null; } if ( typeof value === 'function' ) { var fnContext = [context]; if ( context.geography ) { fnContext = [context.geography, context.data]; } return value.apply(null, fnContext); } else { return value; } } function addContainer( element, height, width ) { this.svg = d3.select( element ).append('svg') .attr('width', width || element.offsetWidth) .attr('data-width', width || element.offsetWidth) .attr('class', 'datamap') .attr('height', height || element.offsetHeight) .style('overflow', 'hidden'); // IE10+ doesn't respect height/width when map is zoomed in if (this.options.responsive) { d3.select(this.options.element).style({'position': 'relative', 'padding-bottom': (this.options.aspectRatio*100) + '%'}); d3.select(this.options.element).select('svg').style({'position': 'absolute', 'width': '100%', 'height': '100%'}); d3.select(this.options.element).select('svg').select('g').selectAll('path').style('vector-effect', 'non-scaling-stroke'); } return this.svg; } // setProjection takes the svg element and options function setProjection( element, options ) { var width = options.width || element.offsetWidth; var height = options.height || element.offsetHeight; var projection, path; var svg = this.svg; if ( options && typeof options.scope === 'undefined') { options.scope = 'world'; } if ( options.scope === 'usa' ) { projection = d3.geo.albersUsa() .scale(width) .translate([width / 2, height / 2]); } else if ( options.scope === 'world' ) { projection = d3.geo[options.projection]() .scale((width + 1) / 2 / Math.PI) .translate([width / 2, height / (options.projection === "mercator" ? 1.45 : 1.8)]); } if ( options.projection === 'orthographic' ) { svg.append("defs").append("path") .datum({type: "Sphere"}) .attr("id", "sphere") .attr("d", path); svg.append("use") .attr("class", "stroke") .attr("xlink:href", "#sphere"); svg.append("use") .attr("class", "fill") .attr("xlink:href", "#sphere"); projection.scale(250).clipAngle(90).rotate(options.projectionConfig.rotation) } path = d3.geo.path() .projection( projection ); return {path: path, projection: projection}; } function addStyleBlock() { if ( d3.select('.datamaps-style-block').empty() ) { d3.select('head').append('style').attr('class', 'datamaps-style-block') .html('.datamap path.datamaps-graticule { fill: none; stroke: #777; stroke-width: 0.5px; stroke-opacity: .5; pointer-events: none; } .datamap .labels {pointer-events: none;} .datamap path {stroke: #FFFFFF; stroke-width: 1px;} .datamaps-legend dt, .datamaps-legend dd { float: left; margin: 0 3px 0 0;} .datamaps-legend dd {width: 20px; margin-right: 6px; border-radius: 3px;} .datamaps-legend {padding-bottom: 20px; z-index: 1001; position: absolute; left: 4px; font-size: 12px; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;} .datamaps-hoverover {display: none; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; } .hoverinfo {padding: 4px; border-radius: 1px; background-color: #FFF; box-shadow: 1px 1px 5px #CCC; font-size: 12px; border: 1px solid #CCC; } .hoverinfo hr {border:1px dotted #CCC; }'); } } function drawSubunits( data ) { var fillData = this.options.fills, colorCodeData = this.options.data || {}, geoConfig = this.options.geographyConfig; var subunits = this.svg.select('g.datamaps-subunits'); if ( subunits.empty() ) { subunits = this.addLayer('datamaps-subunits', null, true); } var geoData = topojson.feature( data, data.objects[ this.options.scope ] ).features; if ( geoConfig.hideAntarctica ) { geoData = geoData.filter(function(feature) { return feature.id !== "ATA"; }); } if ( geoConfig.hideHawaiiAndAlaska ) { geoData = geoData.filter(function(feature) { return feature.id !== "HI" && feature.id !== 'AK'; }); } var geo = subunits.selectAll('path.datamaps-subunit').data( geoData ); geo.enter() .append('path') .attr('d', this.path) .attr('class', function(d) { return 'datamaps-subunit ' + d.id; }) .attr('data-info', function(d) { return JSON.stringify( colorCodeData[d.id]); }) .style('fill', function(d) { //if fillKey - use that //otherwise check 'fill' //otherwise check 'defaultFill' var fillColor; var datum = colorCodeData[d.id]; if ( datum && datum.fillKey ) { fillColor = fillData[ val(datum.fillKey, {data: colorCodeData[d.id], geography: d}) ]; } if ( typeof fillColor === 'undefined' ) { fillColor = val(datum && datum.fillColor, fillData.defaultFill, {data: colorCodeData[d.id], geography: d}); } return fillColor; }) .style('stroke-width', geoConfig.borderWidth) .style('stroke', geoConfig.borderColor); } function handleGeographyConfig () { var hoverover; var svg = this.svg; var self = this; var options = this.options.geographyConfig; if ( options.highlightOnHover || options.popupOnHover ) { svg.selectAll('.datamaps-subunit') .on('mouseover', function(d) { var $this = d3.select(this); var datum = self.options.data[d.id] || {}; if ( options.highlightOnHover ) { var previousAttributes = { 'fill': $this.style('fill'), 'stroke': $this.style('stroke'), 'stroke-width': $this.style('stroke-width'), 'fill-opacity': $this.style('fill-opacity') }; $this .style('fill', val(datum.highlightFillColor, options.highlightFillColor, datum)) .style('stroke', val(datum.highlightBorderColor, options.highlightBorderColor, datum)) .style('stroke-width', val(datum.highlightBorderWidth, options.highlightBorderWidth, datum)) .style('fill-opacity', val(datum.highlightFillOpacity, options.highlightFillOpacity, datum)) .attr('data-previousAttributes', JSON.stringify(previousAttributes)); //as per discussion on https://github.com/markmarkoh/datamaps/issues/19 if ( ! /((MSIE)|(Trident))/.test(navigator.userAgent) ) { moveToFront.call(this); } } if ( options.popupOnHover ) { self.updatePopup($this, d, options, svg); } }) .on('mouseout', function() { var $this = d3.select(this); if (options.highlightOnHover) { //reapply previous attributes var previousAttributes = JSON.parse( $this.attr('data-previousAttributes') ); for ( var attr in previousAttributes ) { $this.style(attr, previousAttributes[attr]); } } $this.on('mousemove', null); d3.selectAll('.datamaps-hoverover').style('display', 'none'); }); } function moveToFront() { this.parentNode.appendChild(this); } } //plugin to add a simple map legend function addLegend(layer, data, options) { data = data || {}; if ( !this.options.fills ) { return; } var html = '<dl>'; var label = ''; if ( data.legendTitle ) { html = '<h2>' + data.legendTitle + '</h2>' + html; } for ( var fillKey in this.options.fills ) { if ( fillKey === 'defaultFill') { if (! data.defaultFillName ) { continue; } label = data.defaultFillName; } else { if (data.labels && data.labels[fillKey]) { label = data.labels[fillKey]; } else { label= fillKey + ': '; } } html += '<dt>' + label + '</dt>'; html += '<dd style="background-color:' + this.options.fills[fillKey] + '">&nbsp;</dd>'; } html += '</dl>'; var hoverover = d3.select( this.options.element ).append('div') .attr('class', 'datamaps-legend') .html(html); } function addGraticule ( layer, options ) { var graticule = d3.geo.graticule(); this.svg.insert("path", '.datamaps-subunits') .datum(graticule) .attr("class", "datamaps-graticule") .attr("d", this.path); } function handleArcs (layer, data, options) { var self = this, svg = this.svg; if ( !data || (data && !data.slice) ) { throw "Datamaps Error - arcs must be an array"; } // For some reason arc options were put in an `options` object instead of the parent arc // I don't like this, so to match bubbles and other plugins I'm moving it // This is to keep backwards compatability for ( var i = 0; i < data.length; i++ ) { data[i] = defaults(data[i], data[i].options); delete data[i].options; } if ( typeof options === "undefined" ) { options = defaultOptions.arcConfig; } var arcs = layer.selectAll('path.datamaps-arc').data( data, JSON.stringify ); var path = d3.geo.path() .projection(self.projection); arcs .enter() .append('svg:path') .attr('class', 'datamaps-arc') .style('stroke-linecap', 'round') .style('stroke', function(datum) { return val(datum.strokeColor, options.strokeColor, datum); }) .style('fill', 'none') .style('stroke-width', function(datum) { return val(datum.strokeWidth, options.strokeWidth, datum); }) .attr('d', function(datum) { var originXY = self.latLngToXY(val(datum.origin.latitude, datum), val(datum.origin.longitude, datum)) var destXY = self.latLngToXY(val(datum.destination.latitude, datum), val(datum.destination.longitude, datum)); var midXY = [ (originXY[0] + destXY[0]) / 2, (originXY[1] + destXY[1]) / 2]; if (options.greatArc) { // TODO: Move this to inside `if` clause when setting attr `d` var greatArc = d3.geo.greatArc() .source(function(d) { return [val(d.origin.longitude, d), val(d.origin.latitude, d)]; }) .target(function(d) { return [val(d.destination.longitude, d), val(d.destination.latitude, d)]; }); return path(greatArc(datum)) } var sharpness = val(datum.arcSharpness, options.arcSharpness, datum); return "M" + originXY[0] + ',' + originXY[1] + "S" + (midXY[0] + (50 * sharpness)) + "," + (midXY[1] - (75 * sharpness)) + "," + destXY[0] + "," + destXY[1]; }) .transition() .delay(100) .style('fill', function(datum) { /* Thank you Jake Archibald, this is awesome. Source: http://jakearchibald.com/2013/animated-line-drawing-svg/ */ var length = this.getTotalLength(); this.style.transition = this.style.WebkitTransition = 'none'; this.style.strokeDasharray = length + ' ' + length; this.style.strokeDashoffset = length; this.getBoundingClientRect(); this.style.transition = this.style.WebkitTransition = 'stroke-dashoffset ' + val(datum.animationSpeed, options.animationSpeed, datum) + 'ms ease-out'; this.style.strokeDashoffset = '0'; return 'none'; }) arcs.exit() .transition() .style('opacity', 0) .remove(); } function handleLabels ( layer, options ) { var self = this; options = options || {}; var labelStartCoodinates = this.projection([-67.707617, 42.722131]); this.svg.selectAll(".datamaps-subunit") .attr("data-foo", function(d) { var center = self.path.centroid(d); var xOffset = 7.5, yOffset = 5; if ( ["FL", "KY", "MI"].indexOf(d.id) > -1 ) xOffset = -2.5; if ( d.id === "NY" ) xOffset = -1; if ( d.id === "MI" ) yOffset = 18; if ( d.id === "LA" ) xOffset = 13; var x,y; x = center[0] - xOffset; y = center[1] + yOffset; var smallStateIndex = ["VT", "NH", "MA", "RI", "CT", "NJ", "DE", "MD", "DC"].indexOf(d.id); if ( smallStateIndex > -1) { var yStart = labelStartCoodinates[1]; x = labelStartCoodinates[0]; y = yStart + (smallStateIndex * (2+ (options.fontSize || 12))); layer.append("line") .attr("x1", x - 3) .attr("y1", y - 5) .attr("x2", center[0]) .attr("y2", center[1]) .style("stroke", options.labelColor || "#000") .style("stroke-width", options.lineWidth || 1) } layer.append("text") .attr("x", x) .attr("y", y) .style("font-size", (options.fontSize || 10) + 'px') .style("font-family", options.fontFamily || "Verdana") .style("fill", options.labelColor || "#000") .text( d.id ); return "bar"; }); } function handleBubbles (layer, data, options ) { var self = this, fillData = this.options.fills, filterData = this.options.filters, svg = this.svg; if ( !data || (data && !data.slice) ) { throw "Datamaps Error - bubbles must be an array"; } var bubbles = layer.selectAll('circle.datamaps-bubble').data( data, options.key ); bubbles .enter() .append('svg:circle') .attr('class', 'datamaps-bubble') .attr('cx', function ( datum ) { var latLng; if ( datumHasCoords(datum) ) { latLng = self.latLngToXY(datum.latitude, datum.longitude); } else if ( datum.centered ) { latLng = self.path.centroid(svg.select('path.' + datum.centered).data()[0]); } if ( latLng ) return latLng[0]; }) .attr('cy', function ( datum ) { var latLng; if ( datumHasCoords(datum) ) { latLng = self.latLngToXY(datum.latitude, datum.longitude); } else if ( datum.centered ) { latLng = self.path.centroid(svg.select('path.' + datum.centered).data()[0]); } if ( latLng ) return latLng[1]; }) .attr('r', function(datum) { // if animation enabled start with radius 0, otherwise use full size. return options.animate ? 0 : val(datum.radius, options.radius, datum); }) .attr('data-info', function(d) { return JSON.stringify(d); }) .attr('filter', function (datum) { var filterKey = filterData[ val(datum.filterKey, options.filterKey, datum) ]; if (filterKey) { return filterKey; } }) .style('stroke', function ( datum ) { return val(datum.borderColor, options.borderColor, datum); }) .style('stroke-width', function ( datum ) { return val(datum.borderWidth, options.borderWidth, datum); }) .style('fill-opacity', function ( datum ) { return val(datum.fillOpacity, options.fillOpacity, datum); }) .style('fill', function ( datum ) { var fillColor = fillData[ val(datum.fillKey, options.fillKey, datum) ]; return fillColor || fillData.defaultFill; }) .on('mouseover', function ( datum ) { var $this = d3.select(this); if (options.highlightOnHover) { //save all previous attributes for mouseout var previousAttributes = { 'fill': $this.style('fill'), 'stroke': $this.style('stroke'), 'stroke-width': $this.style('stroke-width'), 'fill-opacity': $this.style('fill-opacity') }; $this .style('fill', val(datum.highlightFillColor, options.highlightFillColor, datum)) .style('stroke', val(datum.highlightBorderColor, options.highlightBorderColor, datum)) .style('stroke-width', val(datum.highlightBorderWidth, options.highlightBorderWidth, datum)) .style('fill-opacity', val(datum.highlightFillOpacity, options.highlightFillOpacity, datum)) .attr('data-previousAttributes', JSON.stringify(previousAttributes)); } if (options.popupOnHover) { self.updatePopup($this, datum, options, svg); } }) .on('mouseout', function ( datum ) { var $this = d3.select(this); if (options.highlightOnHover) { //reapply previous attributes var previousAttributes = JSON.parse( $this.attr('data-previousAttributes') ); for ( var attr in previousAttributes ) { $this.style(attr, previousAttributes[attr]); } } d3.selectAll('.datamaps-hoverover').style('display', 'none'); }) bubbles.transition() .duration(400) .attr('r', function ( datum ) { return val(datum.radius, options.radius, datum); }); bubbles.exit() .transition() .delay(options.exitDelay) .attr("r", 0) .remove(); function datumHasCoords (datum) { return typeof datum !== 'undefined' && typeof datum.latitude !== 'undefined' && typeof datum.longitude !== 'undefined'; } } //stolen from underscore.js function defaults(obj) { Array.prototype.slice.call(arguments, 1).forEach(function(source) { if (source) { for (var prop in source) { if (obj[prop] == null) obj[prop] = source[prop]; } } }); return obj; } /************************************** Public Functions ***************************************/ function Datamap( options ) { if ( typeof d3 === 'undefined' || typeof topojson === 'undefined' ) { throw new Error('Include d3.js (v3.0.3 or greater) and topojson on this page before creating a new map'); } //set options for global use this.options = defaults(options, defaultOptions); this.options.geographyConfig = defaults(options.geographyConfig, defaultOptions.geographyConfig); this.options.projectionConfig = defaults(options.projectionConfig, defaultOptions.projectionConfig); this.options.bubblesConfig = defaults(options.bubblesConfig, defaultOptions.bubblesConfig); this.options.arcConfig = defaults(options.arcConfig, defaultOptions.arcConfig); //add the SVG container if ( d3.select( this.options.element ).select('svg').length > 0 ) { addContainer.call(this, this.options.element, this.options.height, this.options.width ); } /* Add core plugins to this instance */ this.addPlugin('bubbles', handleBubbles); this.addPlugin('legend', addLegend); this.addPlugin('arc', handleArcs); this.addPlugin('labels', handleLabels); this.addPlugin('graticule', addGraticule); //append style block with basic hoverover styles if ( ! this.options.disableDefaultStyles ) { addStyleBlock(); } return this.draw(); } // resize map Datamap.prototype.resize = function () { var self = this; var options = self.options; if (options.responsive) { var newsize = options.element.clientWidth, oldsize = d3.select( options.element).select('svg').attr('data-width'); d3.select(options.element).select('svg').selectAll('g').attr('transform', 'scale(' + (newsize / oldsize) + ')'); } } // actually draw the features(states & countries) Datamap.prototype.draw = function() { //save off in a closure var self = this; var options = self.options; //set projections and paths based on scope var pathAndProjection = options.setProjection.apply(self, [options.element, options] ); this.path = pathAndProjection.path; this.projection = pathAndProjection.projection; //if custom URL for topojson data, retrieve it and render if ( options.geographyConfig.dataUrl ) { d3.json( options.geographyConfig.dataUrl, function(error, results) { if ( error ) throw new Error(error); self.customTopo = results; draw( results ); }); } else { draw( this[options.scope + 'Topo'] || options.geographyConfig.dataJson); } return this; function draw (data) { // if fetching remote data, draw the map first then call `updateChoropleth` if ( self.options.dataUrl ) { //allow for csv or json data types d3[self.options.dataType](self.options.dataUrl, function(data) { //in the case of csv, transform data to object if ( self.options.dataType === 'csv' && (data && data.slice) ) { var tmpData = {}; for(var i = 0; i < data.length; i++) { tmpData[data[i].id] = data[i]; } data = tmpData; } Datamaps.prototype.updateChoropleth.call(self, data); }); } drawSubunits.call(self, data); handleGeographyConfig.call(self); if ( self.options.geographyConfig.popupOnHover || self.options.bubblesConfig.popupOnHover) { hoverover = d3.select( self.options.element ).append('div') .attr('class', 'datamaps-hoverover') .style('z-index', 10001) .style('position', 'absolute'); } //fire off finished callback self.options.done(self); } }; /************************************** TopoJSON ***************************************/ Datamap.prototype.worldTopo = '__WORLD__'; Datamap.prototype.abwTopo = '__ABW__'; Datamap.prototype.afgTopo = '__AFG__'; Datamap.prototype.agoTopo = '__AGO__'; Datamap.prototype.aiaTopo = '__AIA__'; Datamap.prototype.albTopo = '__ALB__'; Datamap.prototype.aldTopo = '__ALD__'; Datamap.prototype.andTopo = '__AND__'; Datamap.prototype.areTopo = '__ARE__'; Datamap.prototype.argTopo = '__ARG__'; Datamap.prototype.armTopo = '__ARM__'; Datamap.prototype.asmTopo = '__ASM__'; Datamap.prototype.ataTopo = '__ATA__'; Datamap.prototype.atcTopo = '__ATC__'; Datamap.prototype.atfTopo = '__ATF__'; Datamap.prototype.atgTopo = '__ATG__'; Datamap.prototype.ausTopo = '__AUS__'; Datamap.prototype.autTopo = '__AUT__'; Datamap.prototype.azeTopo = '__AZE__'; Datamap.prototype.bdiTopo = '__BDI__'; Datamap.prototype.belTopo = '__BEL__'; Datamap.prototype.benTopo = '__BEN__'; Datamap.prototype.bfaTopo = '__BFA__'; Datamap.prototype.bgdTopo = '__BGD__'; Datamap.prototype.bgrTopo = '__BGR__'; Datamap.prototype.bhrTopo = '__BHR__'; Datamap.prototype.bhsTopo = '__BHS__'; Datamap.prototype.bihTopo = '__BIH__'; Datamap.prototype.bjnTopo = '__BJN__'; Datamap.prototype.blmTopo = '__BLM__'; Datamap.prototype.blrTopo = '__BLR__'; Datamap.prototype.blzTopo = '__BLZ__'; Datamap.prototype.bmuTopo = '__BMU__'; Datamap.prototype.bolTopo = '__BOL__'; Datamap.prototype.braTopo = '__BRA__'; Datamap.prototype.brbTopo = '__BRB__'; Datamap.prototype.brnTopo = '__BRN__'; Datamap.prototype.btnTopo = '__BTN__'; Datamap.prototype.norTopo = '__NOR__'; Datamap.prototype.bwaTopo = '__BWA__'; Datamap.prototype.cafTopo = '__CAF__'; Datamap.prototype.canTopo = '__CAN__'; Datamap.prototype.cheTopo = '__CHE__'; Datamap.prototype.chlTopo = '__CHL__'; Datamap.prototype.chnTopo = '__CHN__'; Datamap.prototype.civTopo = '__CIV__'; Datamap.prototype.clpTopo = '__CLP__'; Datamap.prototype.cmrTopo = '__CMR__'; Datamap.prototype.codTopo = '__COD__'; Datamap.prototype.cogTopo = '__COG__'; Datamap.prototype.cokTopo = '__COK__'; Datamap.prototype.colTopo = '__COL__'; Datamap.prototype.comTopo = '__COM__'; Datamap.prototype.cpvTopo = '__CPV__'; Datamap.prototype.criTopo = '__CRI__'; Datamap.prototype.csiTopo = '__CSI__'; Datamap.prototype.cubTopo = '__CUB__'; Datamap.prototype.cuwTopo = '__CUW__'; Datamap.prototype.cymTopo = '__CYM__'; Datamap.prototype.cynTopo = '__CYN__'; Datamap.prototype.cypTopo = '__CYP__'; Datamap.prototype.czeTopo = '__CZE__'; Datamap.prototype.deuTopo = '__DEU__'; Datamap.prototype.djiTopo = '__DJI__'; Datamap.prototype.dmaTopo = '__DMA__'; Datamap.prototype.dnkTopo = '__DNK__'; Datamap.prototype.domTopo = '__DOM__'; Datamap.prototype.dzaTopo = '__DZA__'; Datamap.prototype.ecuTopo = '__ECU__'; Datamap.prototype.egyTopo = '__EGY__'; Datamap.prototype.eriTopo = '__ERI__'; Datamap.prototype.esbTopo = '__ESB__'; Datamap.prototype.espTopo = '__ESP__'; Datamap.prototype.estTopo = '__EST__'; Datamap.prototype.ethTopo = '__ETH__'; Datamap.prototype.finTopo = '__FIN__'; Datamap.prototype.fjiTopo = '__FJI__'; Datamap.prototype.flkTopo = {"type":"Topology","objects":{"flk":{"type":"GeometryCollection","geometries":[{"type":"MultiPolygon","properties":{"name":"Falkland Islands"},"id":"FK","arcs":[[[0]],[[1]],[[2]],[[3]],[[4]],[[5]],[[6]],[[7]],[[8]],[[9]],[[10]],[[11]],[[12]],[[13]],[[14]],[[15]],[[16]],[[17]],[[18]],[[19]],[[20]],[[21]],[[22]]]}]}},"arcs":[[[5904,5],[-6,-5],[-19,55],[7,96],[17,20],[18,-16],[2,-53],[-8,-28],[-1,-10],[0,-14],[1,-28],[-3,-10],[-8,-7]],[[6170,2561],[-21,-22],[-45,6],[-44,30],[10,33],[30,21],[167,46],[68,-37],[-5,-10],[-105,-35],[-7,-11],[-48,-21]],[[4396,3004],[62,-48],[109,17],[76,44],[34,-64],[-71,-61],[-56,-65],[-24,-76],[-76,43],[-62,48],[-43,53],[-71,-11],[-34,64],[-62,54],[85,81],[71,23],[-10,59],[46,92],[71,28],[95,1],[10,-59],[-66,-23],[0,-70],[-51,-60],[-33,-70]],[[4286,4144],[45,-144],[138,18],[59,-17],[42,-69],[-13,-25],[-11,-35],[-10,-42],[-6,-47],[49,-39],[-6,-71],[-40,-68],[-50,-31],[-23,-7],[-29,-19],[-24,-29],[-23,-79],[-26,3],[-22,37],[-3,63],[-1,8],[-2,8],[-4,8],[-5,7],[30,39],[26,68],[12,85],[-9,92],[-35,67],[-45,33],[-39,41],[-17,89],[14,99],[28,-43]],[[8019,4840],[15,-3],[25,5],[16,23],[-3,35],[12,6],[14,-9],[38,-42],[0,-7],[-12,-9],[-4,-36],[-8,-42],[-33,-2],[-52,27],[-26,-1],[0,-22],[17,-51],[-13,-22],[-31,5],[-3,-14],[29,-23],[30,16],[24,31],[5,-11],[-13,-47],[-6,-50],[5,-48],[24,-60],[-3,-31],[-8,-22],[2,-32],[18,-39],[-13,-23],[-58,12],[-22,28],[20,28],[2,36],[-16,0],[-30,-12],[-44,27],[-40,36],[-64,38],[-7,26],[-1,46],[-14,42],[-35,39],[-24,45],[20,34],[34,29],[39,24],[41,13],[28,22],[25,6],[8,7],[-20,24],[10,14],[42,-3],[32,-15],[16,-25],[12,-23]],[[4587,5020],[7,-53],[-24,-37],[-28,-12],[-16,7],[-5,15],[-6,17],[-11,15],[-14,1],[-17,-4],[-11,21],[16,63],[-5,40],[10,54],[35,39],[28,-11],[1,-35],[-9,-42],[15,-39],[18,-14],[16,-25]],[[232,5743],[0,-32],[26,-18],[28,-5],[30,7],[30,16],[-65,-128],[-97,1],[-102,81],[-82,114],[14,16],[13,11],[30,11],[25,-14],[60,-20],[46,-52],[13,21],[10,65],[9,26],[6,35],[12,33],[30,13],[24,-7],[21,-21],[18,-34],[15,-45],[-30,-11],[-84,-63]],[[4805,5874],[-44,-26],[-29,11],[-15,50],[6,38],[28,27],[92,12],[14,14],[74,83],[12,5],[-19,-68],[-2,-121],[-25,-23],[-92,-2]],[[1224,5601],[-17,-61],[-61,-152],[116,0],[-22,-48],[-19,-95],[-17,-38],[-39,-32],[-131,-35],[-81,-32],[-56,4],[-132,63],[12,52],[8,19],[-41,1],[-17,33],[-8,43],[-12,30],[-28,13],[-59,7],[-28,15],[-10,13],[-6,13],[-8,10],[-14,0],[22,114],[-19,74],[-44,43],[-52,18],[48,68],[39,31],[44,8],[114,-3],[16,5],[34,87],[53,97],[32,38],[40,24],[13,3],[30,0],[13,-3],[22,-18],[7,-20],[3,-18],[6,-12],[57,-33],[24,-39],[-13,-54],[-52,-52],[-137,-92],[-50,-89],[-7,-43],[14,-12],[202,80],[85,90],[55,36],[46,54],[25,118],[-12,43],[-27,17],[-13,22],[32,60],[35,38],[31,5],[22,-30],[9,-68],[-6,-46],[-13,-53],[-16,-48],[-14,-30],[-15,-48],[-6,-127],[-7,-58]],[[346,6460],[-47,-33],[-110,8],[-45,-30],[-22,-52],[-8,-60],[0,-156],[-34,16],[-35,25],[-29,41],[-16,61],[17,103],[22,70],[35,45],[59,30],[60,2],[101,-56],[52,-14]],[[1804,6564],[-30,-14],[-13,15],[-8,19],[-4,20],[12,36],[2,173],[-12,31],[-11,18],[-9,32],[6,26],[16,-9],[33,-59],[4,-25],[-1,-27],[14,-91],[11,-24],[29,-36],[-2,-23],[-11,-29],[-26,-33]],[[1636,7024],[-17,-18],[-200,43],[-18,37],[22,22],[153,-27],[33,-22],[27,-35]],[[5450,8221],[21,-33],[283,-135],[75,-61],[42,-75],[-120,7],[-49,-26],[-24,-82],[11,-78],[36,-3],[46,18],[41,-11],[-75,-51],[-129,-172],[-65,-61],[-18,57],[-30,19],[-33,-11],[-33,-30],[0,-35],[10,-28],[-3,-30],[-24,-84],[19,14],[59,19],[0,-33],[-89,-145],[-10,-33],[-9,-145],[-20,-33],[-34,-23],[-69,-102],[-39,-19],[-32,20],[-15,46],[-1,56],[11,55],[-87,-122],[-47,-45],[-39,25],[-153,-178],[78,8],[-12,-57],[-96,-146],[-124,-267],[-75,-105],[-185,-196],[-295,-498],[-56,-134],[-26,-80],[-30,-67],[-43,-46],[-123,-37],[-178,-154],[-21,152],[-9,23],[-71,12],[-37,15],[-16,24],[-12,57],[-27,-2],[-29,-28],[-18,-27],[-6,-54],[33,-107],[-8,-49],[-56,-37],[-241,21],[-64,-42],[-33,-5],[-17,47],[9,31],[50,62],[17,43],[-183,-88],[-45,-48],[-30,-95],[17,-79],[32,-88],[17,-116],[-14,-77],[-34,-65],[-224,-307],[-33,-31],[-61,4],[-87,73],[-61,-6],[11,-8],[4,-27],[-2,-33],[-5,-21],[-19,-14],[-19,21],[-19,30],[-46,38],[-53,98],[-16,22],[-32,14],[-55,56],[-37,1],[-17,-22],[-5,-36],[8,-34],[76,-43],[42,-72],[31,-92],[18,-92],[-114,-156],[-157,-103],[-151,19],[-96,205],[36,-4],[27,-12],[25,-4],[30,20],[-53,46],[-69,90],[-61,101],[-29,82],[21,16],[37,51],[16,54],[-44,25],[-281,14],[-36,-14],[-23,-38],[17,-23],[36,-11],[36,-3],[56,-31],[63,-78],[54,-95],[28,-83],[-162,0],[-46,10],[-23,25],[-15,35],[-126,199],[-33,37],[-36,6],[-38,-1],[-38,12],[-49,55],[-91,147],[-50,47],[-129,33],[-42,58],[19,124],[29,53],[70,-18],[150,-73],[122,-10],[29,-23],[12,-50],[-2,-59],[13,-41],[54,6],[-39,177],[188,29],[177,81],[0,35],[-89,59],[-75,16],[-65,40],[-58,131],[242,3],[127,-37],[51,-108],[19,0],[11,38],[12,24],[35,48],[4,-54],[15,-46],[21,-19],[28,27],[29,36],[27,2],[29,-13],[78,-15],[29,-17],[46,-44],[46,-59],[24,-1],[25,60],[-38,33],[0,35],[71,-2],[79,18],[75,37],[61,54],[72,154],[16,23],[8,22],[-16,40],[-31,24],[-39,-29],[-101,-107],[-133,-60],[-139,4],[-115,74],[222,-17],[56,33],[20,17],[55,28],[11,28],[9,47],[21,47],[26,40],[22,26],[-26,61],[2,41],[15,34],[9,42],[-4,49],[-14,113],[-3,71],[29,89],[67,65],[77,27],[57,-21],[-21,-43],[-24,-38],[-50,-61],[85,24],[36,0],[14,-42],[-8,-48],[-53,-147],[33,-24],[82,-86],[4,85],[22,64],[38,34],[52,-5],[-33,76],[-11,60],[6,169],[10,49],[26,31],[32,13],[29,-4],[18,-24],[20,-83],[17,-38],[19,5],[25,25],[23,6],[9,-53],[12,-14],[28,21],[85,90],[8,96],[-3,109],[5,76],[-74,30],[-69,-17],[-67,-33],[-67,-19],[-164,29],[-71,-26],[17,-109],[-22,-60],[-21,0],[-23,22],[-31,5],[-125,-94],[-38,-15],[-125,0],[-40,-18],[-21,-43],[-15,-47],[-20,-34],[-57,-1],[-28,77],[-27,93],[-49,44],[-62,31],[-52,79],[-31,105],[3,108],[39,88],[45,-9],[53,-49],[278,-102],[80,-3],[66,35],[128,118],[65,25],[220,-26],[196,91],[58,-11],[117,-137],[66,-37],[156,-19],[-41,97],[-67,53],[-78,23],[-72,5],[-56,32],[-164,216],[-30,21],[-56,25],[-30,28],[-76,140],[-73,9],[-409,220],[-34,38],[-30,108],[-6,62],[26,27],[164,0],[134,-41],[29,25],[-39,105],[-58,71],[-74,47],[-78,30],[-106,17],[-77,-8],[-38,6],[-87,59],[-38,9],[-28,12],[-31,32],[-21,40],[3,40],[11,57],[-15,62],[-42,112],[32,-4],[29,3],[27,14],[25,26],[92,-73],[310,-144],[97,-69],[285,-282],[228,-134],[250,-44],[459,104],[-67,91],[-198,21],[27,118],[59,90],[65,70],[16,68],[18,22],[33,-37],[10,-32],[20,-130],[169,165],[92,46],[82,-31],[0,-36],[-16,-16],[-8,-17],[-5,-18],[-9,-20],[262,-58],[83,-48],[-45,-25],[-47,-11],[-99,0],[80,-106],[148,0],[525,142],[50,24],[94,101],[57,17],[0,-36],[-196,-166],[-72,-43],[126,-84],[134,-3],[275,122],[-19,49],[-34,45],[-38,33],[-34,13],[-18,29],[-2,153],[-7,66],[23,-4],[48,7],[24,-3],[-5,23],[-7,59],[-6,24],[40,1],[51,-13],[43,-28],[19,-49]],[[4468,8263],[76,-67],[5,106],[62,-11],[14,-83],[62,-44],[105,-16],[10,-61],[-81,-22],[-104,-62],[-86,-56],[-81,-12],[-81,61],[9,78],[57,55],[-67,22],[-109,-23],[-86,61],[-19,55],[76,12],[81,11],[23,95],[57,-6],[39,-49],[38,-44]],[[3906,8304],[-64,-28],[-56,2],[-55,40],[-48,58],[-40,72],[-29,79],[131,48],[43,1],[43,-14],[109,-73],[19,-1],[-41,-30],[-18,-3],[0,-39],[39,-61],[-33,-51]],[[3104,8492],[76,-10],[70,6],[151,42],[69,-23],[30,-108],[12,-21],[22,-56],[7,-57],[-33,-26],[-105,-142],[-44,-120],[-13,-21],[-29,3],[-81,53],[-32,14],[-199,-45],[-42,8],[-51,27],[-40,48],[-8,70],[40,75],[69,43],[134,26],[30,-23],[57,-100],[29,-22],[41,3],[36,12],[33,22],[33,34],[-50,57],[-153,103],[-107,39],[-131,113],[-38,46],[-46,75],[-3,35],[30,32],[45,6],[25,-33],[17,-52],[18,-47],[58,-57],[73,-29]],[[2224,8429],[-17,-8],[-8,29],[-3,29],[-9,23],[-34,15],[-55,16],[-56,54],[-29,111],[39,43],[77,-74],[39,-55],[21,-18],[37,-49],[10,-63],[-12,-53]],[[7211,8360],[66,-14],[142,0],[32,-17],[28,-26],[31,-22],[42,-3],[0,32],[-11,65],[43,56],[65,41],[265,30],[49,-30],[46,-44],[114,-45],[50,-55],[126,-177],[18,-72],[11,-105],[12,-72],[-14,-58],[-66,-63],[-54,-29],[-72,-22],[-71,-6],[-52,18],[-28,60],[-46,176],[-40,48],[-48,-15],[-44,-58],[-80,-137],[95,-3],[17,-70],[-36,-230],[37,-37],[177,114],[64,-8],[13,-54],[-5,-66],[-11,-69],[-6,-61],[3,-90],[9,-32],[43,-1],[11,8],[20,49],[17,11],[11,-17],[18,-77],[10,-29],[37,-29],[44,3],[39,30],[22,51],[58,-40],[35,-54],[18,-73],[5,-101],[16,-70],[40,-89],[47,-77],[41,-32],[48,34],[-23,78],[-72,137],[30,63],[60,-14],[119,-85],[-20,123],[-67,52],[-72,32],[-33,61],[19,38],[37,33],[26,41],[-14,66],[-36,22],[-85,-46],[-42,8],[-28,41],[-2,40],[3,43],[-11,53],[-13,29],[-20,33],[-18,6],[-8,-48],[-11,-50],[-28,-28],[-34,-11],[-32,-1],[-32,20],[13,46],[49,75],[128,306],[34,47],[32,16],[75,76],[37,17],[585,51],[153,56],[84,0],[74,-25],[31,-29],[30,-53],[47,-213],[19,-32],[29,-28],[86,-171],[29,-35],[39,-27],[76,-27],[-22,-51],[-54,-39],[-21,-54],[72,0],[22,-47],[-25,-59],[-69,-34],[-347,56],[-235,164],[-58,15],[-24,-41],[34,-126],[-149,73],[-176,-105],[49,-96],[94,-79],[103,-55],[79,-22],[160,46],[78,-56],[261,-32],[104,-35],[88,-70],[36,-119],[-51,-67],[-116,-50],[-198,-43],[0,-39],[168,-71],[62,3],[111,46],[55,9],[63,-19],[0,-36],[-78,-8],[-283,-162],[-58,-13],[-189,-5],[-37,-15],[-3,-40],[-35,-38],[-37,-18],[-424,-59],[-217,40],[-109,-5],[0,-35],[34,-8],[97,-66],[46,-20],[147,-13],[0,-35],[-79,-28],[-164,12],[-81,-20],[-194,-142],[-75,-3],[60,-34],[58,5],[173,98],[187,2],[-38,-58],[-70,-58],[-76,-44],[-119,-40],[-213,-155],[-133,-68],[-258,47],[-144,-12],[-100,-38],[-444,7],[-67,31],[-95,104],[-129,56],[-63,63],[-60,38],[-28,38],[-14,44],[-10,53],[-15,45],[-28,21],[-35,-30],[-30,-74],[-22,-79],[-8,-49],[15,-66],[37,-63],[47,-49],[129,-47],[113,-68],[102,-93],[54,-99],[-39,-91],[73,-27],[158,51],[81,-6],[105,-34],[80,-67],[1,-107],[76,-71],[-145,-114],[-46,-64],[33,-36],[20,-47],[13,-59],[24,-178],[-1,-52],[-22,-19],[-47,-2],[-26,25],[-87,191],[-32,55],[-32,45],[-40,31],[-51,11],[-25,11],[-33,47],[-18,10],[-17,-10],[-8,-23],[-11,-24],[-31,-11],[-24,6],[-41,24],[-21,5],[-37,-17],[2,-41],[15,-49],[1,-37],[-38,-48],[-87,-62],[-38,-48],[-46,-38],[-30,61],[-32,174],[-58,-75],[-31,43],[-20,94],[-22,76],[-60,36],[-62,-18],[-48,1],[-21,91],[-50,-32],[-42,15],[-81,91],[-20,39],[-16,20],[-21,6],[-34,-17],[-12,-26],[-9,-31],[-21,-30],[-40,-23],[-36,-6],[-36,10],[-40,19],[-25,20],[-19,25],[-21,19],[-33,7],[-19,-11],[-41,-48],[-24,-12],[-29,-30],[16,-59],[41,-36],[83,61],[146,-43],[41,-33],[5,-74],[-1,-75],[21,-33],[55,11],[38,20],[37,4],[52,-35],[-95,-139],[101,7],[50,-10],[41,-36],[-47,-51],[-108,-52],[-37,-39],[-21,-97],[40,-31],[65,6],[160,65],[54,3],[9,-52],[-30,-44],[-144,-102],[36,-68],[63,-64],[38,-69],[-40,-83],[-60,-16],[-69,34],[-120,88],[-73,10],[-63,-12],[-57,7],[-55,70],[-14,45],[-6,43],[-11,43],[-28,47],[-32,22],[-34,9],[-33,20],[-32,55],[-48,-25],[-112,150],[-53,17],[-12,-33],[-12,-61],[-14,-102],[-15,-33],[-32,35],[-48,87],[-63,-51],[27,-92],[93,-141],[-11,1],[-19,-32],[-19,-47],[-8,-48],[14,-35],[34,-12],[66,-8],[69,-46],[44,-60],[18,-77],[-13,-100],[-17,-20],[-33,-48],[-15,-51],[34,-24],[6,-20],[63,-80],[15,-6],[-21,-92],[-56,32],[-94,131],[-65,44],[-141,33],[-61,62],[11,100],[-34,65],[-56,36],[-129,37],[-48,43],[-1,65],[67,86],[-48,29],[-96,-37],[-39,26],[-7,29],[2,68],[-5,24],[-87,114],[-103,91],[-27,32],[-31,50],[-19,58],[6,56],[19,18],[24,-5],[25,-16],[19,-19],[59,-77],[20,-15],[52,4],[36,38],[6,61],[-37,75],[115,28],[51,40],[27,78],[-51,27],[-55,49],[-46,62],[-22,74],[4,47],[14,21],[22,-7],[28,-43],[27,-21],[40,-5],[77,8],[-44,102],[-23,37],[-30,36],[46,27],[99,19],[47,25],[0,39],[-157,50],[-72,56],[-2,103],[67,49],[92,-39],[95,-62],[72,-19],[59,64],[-42,64],[-73,65],[-39,62],[16,58],[36,3],[43,-10],[38,17],[18,43],[-2,46],[-18,36],[-36,18],[48,35],[209,90],[56,-63],[35,55],[37,238],[43,-52],[45,-10],[100,29],[-47,123],[-10,55],[269,216],[46,-71],[36,33],[35,70],[45,39],[213,46],[45,-10],[16,-41],[1,-46],[-3,-48],[4,-46],[15,-39],[19,-35],[16,-38],[7,-48],[-8,-48],[-16,-47],[-10,-43],[16,-76],[-2,-44],[-8,-44],[-8,-36],[46,23],[54,15],[46,32],[25,73],[-13,75],[-34,90],[-26,93],[10,137],[-37,44],[-31,60],[17,108],[24,26],[32,5],[27,12],[12,46],[-9,48],[-22,5],[-28,-4],[-58,41],[-197,87],[-126,127],[-62,124],[50,87],[79,107],[28,180],[142,-318],[88,-110],[59,141],[-74,121],[-18,118],[42,62],[106,-49],[-73,86],[-254,136],[-56,46],[10,78],[27,84],[36,69],[41,34],[18,-10],[54,-48],[24,-14],[34,0],[92,33],[24,22],[15,50],[9,50],[8,22],[189,7],[66,23],[55,43],[25,70],[-16,71],[-80,138],[-29,90],[-26,41],[-30,36],[-20,14],[-14,23],[-34,158],[59,-28],[89,-124],[43,-29],[61,-10],[132,-59],[231,-165]],[[4473,8731],[68,-27],[286,36],[25,-8],[2,-19],[-4,-25],[7,-26],[19,-35],[9,-33],[17,-23],[41,-9],[19,14],[12,32],[9,34],[8,20],[28,27],[21,11],[27,4],[63,-28],[47,-74],[31,-103],[12,-118],[-68,-19],[-65,-42],[-163,-10],[-65,40],[-93,172],[-72,40],[-314,32],[-118,35],[-26,18],[-19,44],[-6,45],[14,33],[40,6],[63,38],[72,-29],[73,-53]],[[1122,8953],[-68,-7],[29,24],[100,45],[112,36],[39,-13],[-43,-33],[-72,-32],[-97,-20]],[[1284,9469],[-6,-61],[-48,6],[-47,44],[-52,69],[-42,44],[16,80],[84,-125],[58,-44],[37,-13]],[[752,9650],[-22,-7],[-38,13],[-92,50],[-38,10],[-25,12],[-2,28],[23,24],[17,23],[-2,25],[-19,50],[1,45],[38,-11],[37,-44],[39,-65],[13,-30],[11,-35],[6,-16],[34,-24],[16,-22],[3,-26]],[[430,9777],[-9,-18],[-39,5],[-44,34],[-32,47],[-56,30],[-19,24],[-18,2],[-17,10],[-7,32],[-3,39],[14,17],[32,-17],[63,-65],[17,-26],[84,-58],[26,-27],[8,-29]]],"transform":{"scale":[0.0003584261421142103,0.00019223927602759005],"translate":[-61.31818600199989,-52.93539804499985]}}; Datamap.prototype.fraTopo = '__FRA__'; Datamap.prototype.froTopo = '__FRO__'; Datamap.prototype.fsmTopo = '__FSM__'; Datamap.prototype.gabTopo = '__GAB__'; Datamap.prototype.psxTopo = '__PSX__'; Datamap.prototype.gbrTopo = '__GBR__'; Datamap.prototype.geoTopo = '__GEO__'; Datamap.prototype.ggyTopo = '__GGY__'; Datamap.prototype.ghaTopo = '__GHA__'; Datamap.prototype.gibTopo = '__GIB__'; Datamap.prototype.ginTopo = '__GIN__'; Datamap.prototype.gmbTopo = '__GMB__'; Datamap.prototype.gnbTopo = '__GNB__'; Datamap.prototype.gnqTopo = '__GNQ__'; Datamap.prototype.grcTopo = '__GRC__'; Datamap.prototype.grdTopo = '__GRD__'; Datamap.prototype.grlTopo = '__GRL__'; Datamap.prototype.gtmTopo = '__GTM__'; Datamap.prototype.gumTopo = '__GUM__'; Datamap.prototype.guyTopo = '__GUY__'; Datamap.prototype.hkgTopo = '__HKG__'; Datamap.prototype.hmdTopo = '__HMD__'; Datamap.prototype.hndTopo = '__HND__'; Datamap.prototype.hrvTopo = '__HRV__'; Datamap.prototype.htiTopo = '__HTI__'; Datamap.prototype.hunTopo = '__HUN__'; Datamap.prototype.idnTopo = '__IDN__'; Datamap.prototype.imnTopo = '__IMN__'; Datamap.prototype.indTopo = '__IND__'; Datamap.prototype.ioaTopo = '__IOA__'; Datamap.prototype.iotTopo = '__IOT__'; Datamap.prototype.irlTopo = '__IRL__'; Datamap.prototype.irnTopo = '__IRN__'; Datamap.prototype.irqTopo = '__IRQ__'; Datamap.prototype.islTopo = '__ISL__'; Datamap.prototype.isrTopo = '__ISR__'; Datamap.prototype.itaTopo = '__ITA__'; Datamap.prototype.jamTopo = '__JAM__'; Datamap.prototype.jeyTopo = '__JEY__'; Datamap.prototype.jorTopo = '__JOR__'; Datamap.prototype.jpnTopo = '__JPN__'; Datamap.prototype.kabTopo = '__KAB__'; Datamap.prototype.kasTopo = '__KAS__'; Datamap.prototype.kazTopo = '__KAZ__'; Datamap.prototype.kenTopo = '__KEN__'; Datamap.prototype.kgzTopo = '__KGZ__'; Datamap.prototype.khmTopo = '__KHM__'; Datamap.prototype.kirTopo = '__KIR__'; Datamap.prototype.knaTopo = '__KNA__'; Datamap.prototype.korTopo = '__KOR__'; Datamap.prototype.kosTopo = '__KOS__'; Datamap.prototype.kwtTopo = '__KWT__'; Datamap.prototype.laoTopo = '__LAO__'; Datamap.prototype.lbnTopo = '__LBN__'; Datamap.prototype.lbrTopo = '__LBR__'; Datamap.prototype.lbyTopo = '__LBY__'; Datamap.prototype.lcaTopo = '__LCA__'; Datamap.prototype.lieTopo = '__LIE__'; Datamap.prototype.lkaTopo = '__LKA__'; Datamap.prototype.lsoTopo = '__LSO__'; Datamap.prototype.ltuTopo = '__LTU__'; Datamap.prototype.luxTopo = '__LUX__'; Datamap.prototype.lvaTopo = '__LVA__'; Datamap.prototype.macTopo = '__MAC__'; Datamap.prototype.mafTopo = '__MAF__'; Datamap.prototype.marTopo = '__MAR__'; Datamap.prototype.mcoTopo = '__MCO__'; Datamap.prototype.mdaTopo = '__MDA__'; Datamap.prototype.mdgTopo = '__MDG__'; Datamap.prototype.mdvTopo = '__MDV__'; Datamap.prototype.mexTopo = '__MEX__'; Datamap.prototype.mhlTopo = '__MHL__'; Datamap.prototype.mkdTopo = '__MKD__'; Datamap.prototype.mliTopo = '__MLI__'; Datamap.prototype.mltTopo = '__MLT__'; Datamap.prototype.mmrTopo = '__MMR__'; Datamap.prototype.mneTopo = '__MNE__'; Datamap.prototype.mngTopo = '__MNG__'; Datamap.prototype.mnpTopo = '__MNP__'; Datamap.prototype.mozTopo = '__MOZ__'; Datamap.prototype.mrtTopo = '__MRT__'; Datamap.prototype.msrTopo = '__MSR__'; Datamap.prototype.musTopo = '__MUS__'; Datamap.prototype.mwiTopo = '__MWI__'; Datamap.prototype.mysTopo = '__MYS__'; Datamap.prototype.namTopo = '__NAM__'; Datamap.prototype.nclTopo = '__NCL__'; Datamap.prototype.nerTopo = '__NER__'; Datamap.prototype.nfkTopo = '__NFK__'; Datamap.prototype.ngaTopo = '__NGA__'; Datamap.prototype.nicTopo = '__NIC__'; Datamap.prototype.niuTopo = '__NIU__'; Datamap.prototype.nldTopo = '__NLD__'; Datamap.prototype.nplTopo = '__NPL__'; Datamap.prototype.nruTopo = '__NRU__'; Datamap.prototype.nulTopo = '__NUL__'; Datamap.prototype.nzlTopo = '__NZL__'; Datamap.prototype.omnTopo = '__OMN__'; Datamap.prototype.pakTopo = '__PAK__'; Datamap.prototype.panTopo = '__PAN__'; Datamap.prototype.pcnTopo = '__PCN__'; Datamap.prototype.perTopo = '__PER__'; Datamap.prototype.pgaTopo = '__PGA__'; Datamap.prototype.phlTopo = '__PHL__'; Datamap.prototype.plwTopo = '__PLW__'; Datamap.prototype.pngTopo = '__PNG__'; Datamap.prototype.polTopo = '__POL__'; Datamap.prototype.priTopo = '__PRI__'; Datamap.prototype.prkTopo = '__PRK__'; Datamap.prototype.prtTopo = '__PRT__'; Datamap.prototype.pryTopo = '__PRY__'; Datamap.prototype.pyfTopo = '__PYF__'; Datamap.prototype.qatTopo = '__QAT__'; Datamap.prototype.rouTopo = '__ROU__'; Datamap.prototype.rusTopo = '__RUS__'; Datamap.prototype.rwaTopo = '__RWA__'; Datamap.prototype.sahTopo = '__SAH__'; Datamap.prototype.sauTopo = '__SAU__'; Datamap.prototype.scrTopo = '__SCR__'; Datamap.prototype.sdnTopo = '__SDN__'; Datamap.prototype.sdsTopo = '__SDS__'; Datamap.prototype.senTopo = '__SEN__'; Datamap.prototype.serTopo = '__SER__'; Datamap.prototype.sgpTopo = '__SGP__'; Datamap.prototype.sgsTopo = '__SGS__'; Datamap.prototype.shnTopo = '__SHN__'; Datamap.prototype.slbTopo = '__SLB__'; Datamap.prototype.sleTopo = '__SLE__'; Datamap.prototype.slvTopo = '__SLV__'; Datamap.prototype.smrTopo = '__SMR__'; Datamap.prototype.solTopo = '__SOL__'; Datamap.prototype.somTopo = '__SOM__'; Datamap.prototype.spmTopo = '__SPM__'; Datamap.prototype.srbTopo = '__SRB__'; Datamap.prototype.stpTopo = '__STP__'; Datamap.prototype.surTopo = '__SUR__'; Datamap.prototype.svkTopo = '__SVK__'; Datamap.prototype.svnTopo = '__SVN__'; Datamap.prototype.sweTopo = '__SWE__'; Datamap.prototype.swzTopo = '__SWZ__'; Datamap.prototype.sxmTopo = '__SXM__'; Datamap.prototype.sycTopo = '__SYC__'; Datamap.prototype.syrTopo = '__SYR__'; Datamap.prototype.tcaTopo = '__TCA__'; Datamap.prototype.tcdTopo = '__TCD__'; Datamap.prototype.tgoTopo = '__TGO__'; Datamap.prototype.thaTopo = '__THA__'; Datamap.prototype.tjkTopo = '__TJK__'; Datamap.prototype.tkmTopo = '__TKM__'; Datamap.prototype.tlsTopo = '__TLS__'; Datamap.prototype.tonTopo = '__TON__'; Datamap.prototype.ttoTopo = '__TTO__'; Datamap.prototype.tunTopo = '__TUN__'; Datamap.prototype.turTopo = '__TUR__'; Datamap.prototype.tuvTopo = '__TUV__'; Datamap.prototype.twnTopo = '__TWN__'; Datamap.prototype.tzaTopo = '__TZA__'; Datamap.prototype.ugaTopo = '__UGA__'; Datamap.prototype.ukrTopo = '__UKR__'; Datamap.prototype.umiTopo = '__UMI__'; Datamap.prototype.uryTopo = '__URY__'; Datamap.prototype.usaTopo = '__USA__'; Datamap.prototype.usgTopo = '__USG__'; Datamap.prototype.uzbTopo = '__UZB__'; Datamap.prototype.vatTopo = '__VAT__'; Datamap.prototype.vctTopo = '__VCT__'; Datamap.prototype.venTopo = '__VEN__'; Datamap.prototype.vgbTopo = '__VGB__'; Datamap.prototype.virTopo = '__VIR__'; Datamap.prototype.vnmTopo = '__VNM__'; Datamap.prototype.vutTopo = '__VUT__'; Datamap.prototype.wlfTopo = '__WLF__'; Datamap.prototype.wsbTopo = '__WSB__'; Datamap.prototype.wsmTopo = '__WSM__'; Datamap.prototype.yemTopo = '__YEM__'; Datamap.prototype.zafTopo = '__ZAF__'; Datamap.prototype.zmbTopo = '__ZMB__'; Datamap.prototype.zweTopo = '__ZWE__'; /************************************** Utilities ***************************************/ //convert lat/lng coords to X / Y coords Datamap.prototype.latLngToXY = function(lat, lng) { return this.projection([lng, lat]); }; //add <g> layer to root SVG Datamap.prototype.addLayer = function( className, id, first ) { var layer; if ( first ) { layer = this.svg.insert('g', ':first-child') } else { layer = this.svg.append('g') } return layer.attr('id', id || '') .attr('class', className || ''); }; Datamap.prototype.updateChoropleth = function(data) { var svg = this.svg; for ( var subunit in data ) { if ( data.hasOwnProperty(subunit) ) { var color; var subunitData = data[subunit] if ( ! subunit ) { continue; } else if ( typeof subunitData === "string" ) { color = subunitData; } else if ( typeof subunitData.color === "string" ) { color = subunitData.color; } else { color = this.options.fills[ subunitData.fillKey ]; } //if it's an object, overriding the previous data if ( subunitData === Object(subunitData) ) { this.options.data[subunit] = defaults(subunitData, this.options.data[subunit] || {}); var geo = this.svg.select('.' + subunit).attr('data-info', JSON.stringify(this.options.data[subunit])); } svg .selectAll('.' + subunit) .transition() .style('fill', color); } } }; Datamap.prototype.updatePopup = function (element, d, options) { var self = this; element.on('mousemove', null); element.on('mousemove', function() { var position = d3.mouse(self.options.element); d3.select(self.svg[0][0].parentNode).select('.datamaps-hoverover') .style('top', ( (position[1] + 30)) + "px") .html(function() { var data = JSON.parse(element.attr('data-info')); try { return options.popupTemplate(d, data); } catch (e) { return ""; } }) .style('left', ( position[0]) + "px"); }); d3.select(self.svg[0][0].parentNode).select('.datamaps-hoverover').style('display', 'block'); }; Datamap.prototype.addPlugin = function( name, pluginFn ) { var self = this; if ( typeof Datamap.prototype[name] === "undefined" ) { Datamap.prototype[name] = function(data, options, callback, createNewLayer) { var layer; if ( typeof createNewLayer === "undefined" ) { createNewLayer = false; } if ( typeof options === 'function' ) { callback = options; options = undefined; } options = defaults(options || {}, self.options[name + 'Config']); //add a single layer, reuse the old layer if ( !createNewLayer && this.options[name + 'Layer'] ) { layer = this.options[name + 'Layer']; options = options || this.options[name + 'Options']; } else { layer = this.addLayer(name); this.options[name + 'Layer'] = layer; this.options[name + 'Options'] = options; } pluginFn.apply(this, [layer, data, options]); if ( callback ) { callback(layer); } }; } }; // expose library if (typeof exports === 'object') { d3 = require('d3'); topojson = require('topojson'); module.exports = Datamap; } else if ( typeof define === "function" && define.amd ) { define( "datamaps", ["require", "d3", "topojson"], function(require) { d3 = require('d3'); topojson = require('topojson'); return Datamap; }); } else { window.Datamap = window.Datamaps = Datamap; } if ( window.jQuery ) { window.jQuery.fn.datamaps = function(options, callback) { options = options || {}; options.element = this[0]; var datamap = new Datamap(options); if ( typeof callback === "function" ) { callback(datamap, options); } return this; }; } })();
val
__main__.py
""" Runs pedal as a toplevel module """ import sys
from pedal.command_line.command_line import parse_args, main args = parse_args() main(args)
libpinyin.js
// Note: For maximum-speed code, see "Optimizing Code" on the Emscripten wiki, https://github.com/kripken/emscripten/wiki/Optimizing-Code // Note: Some Emscripten settings may limit the speed of the generated code. // The Module object: Our interface to the outside world. We import // and export values on it, and do the work to get that through // closure compiler if necessary. There are various ways Module can be used: // 1. Not defined. We create it here // 2. A function parameter, function(Module) { ..generated code.. } // 3. pre-run appended it, var Module = {}; ..generated code.. // 4. External script tag defines var Module. // We need to do an eval in order to handle the closure compiler // case, where this code here is minified but Module was defined // elsewhere (e.g. case 4 above). We also need to check if Module // already exists (e.g. case 3 above). // Note that if you want to run closure, and also to use Module // after the generated code, you will need to define var Module = {}; // before the code. Then that object will be used in the code, and you // can continue to use Module afterwards as well. var Module; if (!Module) Module = eval('(function() { try { return Module || {} } catch(e) { return {} } })()'); (function(Module) { // We need to put this library in Web Workers so we can't acess the 'document' // object in this file. In fact, this library doesn't really need the 'document' // object for our purpose, so we create a dummy object for it. var document = { addEventListener: function() {} }; // Sometimes an existing Module object exists with properties // meant to overwrite the default module functionality. Here // we collect those properties and reapply _after_ we configure // the current environment's defaults to avoid having to be so // defensive during initialization. var moduleOverrides = {}; for (var key in Module) { if (Module.hasOwnProperty(key)) { moduleOverrides[key] = Module[key]; } } // The environment setup code below is customized to use Module. // *** Environment setup code *** var ENVIRONMENT_IS_NODE = typeof process === 'object' && typeof require === 'function'; var ENVIRONMENT_IS_WEB = typeof window === 'object'; var ENVIRONMENT_IS_WORKER = typeof importScripts === 'function'; var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER; if (ENVIRONMENT_IS_NODE) { // Expose functionality in the same simple way that the shells work // Note that we pollute the global namespace here, otherwise we break in node Module['print'] = function(x) { process['stdout'].write(x + '\n'); }; Module['printErr'] = function(x) { process['stderr'].write(x + '\n'); }; var nodeFS = require('fs'); var nodePath = require('path'); Module['read'] = function(filename, binary) { filename = nodePath['normalize'](filename); var ret = nodeFS['readFileSync'](filename); // The path is absolute if the normalized version is the same as the resolved. if (!ret && filename != nodePath['resolve'](filename)) { filename = path.join(__dirname, '..', 'src', filename); ret = nodeFS['readFileSync'](filename); } if (ret && !binary) ret = ret.toString(); return ret; }; Module['readBinary'] = function(filename) { return Module['read'](filename, true) }; Module['load'] = function(f) { globalEval(read(f)); }; Module['arguments'] = process['argv'].slice(2); module.exports = Module; } if (ENVIRONMENT_IS_SHELL) { Module['print'] = print; if (typeof printErr != 'undefined') Module['printErr'] = printErr; // not present in v8 or older sm Module['read'] = read; Module['readBinary'] = function(f) { return read(f, 'binary'); }; if (typeof scriptArgs != 'undefined') { Module['arguments'] = scriptArgs; } else if (typeof arguments != 'undefined') { Module['arguments'] = arguments; } this['Module'] = Module; } if (ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_WORKER) { Module['print'] = function(x) { console.log(x); }; Module['printErr'] = function(x) { console.log(x); }; this['Module'] = Module; } if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) { Module['read'] = function(url) { var xhr = new XMLHttpRequest(); xhr.open('GET', url, false); xhr.send(null); return xhr.responseText; }; if (typeof arguments != 'undefined') { Module['arguments'] = arguments; } } if (ENVIRONMENT_IS_WORKER) { // We can do very little here... var TRY_USE_DUMP = false; Module['print'] = (TRY_USE_DUMP && (typeof(dump) !== "undefined") ? (function(x) { dump(x); }) : (function(x) { // self.postMessage(x); // enable this if you want stdout to be sent as messages })); Module['load'] = importScripts; } if (!ENVIRONMENT_IS_WORKER && !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_SHELL) { // Unreachable because SHELL is dependant on the others throw 'Unknown runtime environment. Where are we?'; } function globalEval(x) { eval.call(null, x); } if (!Module['load'] && Module['read']) { Module['load'] = function(f) { globalEval(Module['read'](f)); }; } if (!Module['print']) { Module['print'] = function(){}; } if (!Module['printErr']) { Module['printErr'] = Module['print']; } if (!Module['arguments']) { Module['arguments'] = []; } // *** Environment setup code *** // Closure helpers Module.print = Module['print']; Module.printErr = Module['printErr']; // Callbacks Module['preRun'] = []; Module['postRun'] = []; // Merge back in the overrides for (var key in moduleOverrides) { if (moduleOverrides.hasOwnProperty(key)) { Module[key] = moduleOverrides[key]; } } // === Auto-generated preamble library stuff === //======================================== // Runtime code shared with compiler //======================================== var Runtime = { stackSave: function () { return STACKTOP; }, stackRestore: function (stackTop) { STACKTOP = stackTop; }, forceAlign: function (target, quantum) { quantum = quantum || 4; if (quantum == 1) return target; if (isNumber(target) && isNumber(quantum)) { return Math.ceil(target/quantum)*quantum; } else if (isNumber(quantum) && isPowerOfTwo(quantum)) { var logg = log2(quantum); return '((((' +target + ')+' + (quantum-1) + ')>>' + logg + ')<<' + logg + ')'; } return 'Math.ceil((' + target + ')/' + quantum + ')*' + quantum; }, isNumberType: function (type) { return type in Runtime.INT_TYPES || type in Runtime.FLOAT_TYPES; }, isPointerType: function isPointerType(type) { return type[type.length-1] == '*'; }, isStructType: function isStructType(type) { if (isPointerType(type)) return false; if (isArrayType(type)) return true; if (/<?{ ?[^}]* ?}>?/.test(type)) return true; // { i32, i8 } etc. - anonymous struct types // See comment in isStructPointerType() return type[0] == '%'; }, INT_TYPES: {"i1":0,"i8":0,"i16":0,"i32":0,"i64":0}, FLOAT_TYPES: {"float":0,"double":0}, or64: function (x, y) { var l = (x | 0) | (y | 0); var h = (Math.round(x / 4294967296) | Math.round(y / 4294967296)) * 4294967296; return l + h; }, and64: function (x, y) { var l = (x | 0) & (y | 0); var h = (Math.round(x / 4294967296) & Math.round(y / 4294967296)) * 4294967296; return l + h; }, xor64: function (x, y) { var l = (x | 0) ^ (y | 0); var h = (Math.round(x / 4294967296) ^ Math.round(y / 4294967296)) * 4294967296; return l + h; }, getNativeTypeSize: function (type, quantumSize) { if (Runtime.QUANTUM_SIZE == 1) return 1; var size = { '%i1': 1, '%i8': 1, '%i16': 2, '%i32': 4, '%i64': 8, "%float": 4, "%double": 8 }['%'+type]; // add '%' since float and double confuse Closure compiler as keys, and also spidermonkey as a compiler will remove 's from '_i8' etc if (!size) { if (type.charAt(type.length-1) == '*') { size = Runtime.QUANTUM_SIZE; // A pointer } else if (type[0] == 'i') { var bits = parseInt(type.substr(1)); assert(bits % 8 == 0); size = bits/8; } } return size; }, getNativeFieldSize: function (type) { return Math.max(Runtime.getNativeTypeSize(type), Runtime.QUANTUM_SIZE); }, dedup: function dedup(items, ident) { var seen = {}; if (ident) { return items.filter(function(item) { if (seen[item[ident]]) return false; seen[item[ident]] = true; return true; }); } else { return items.filter(function(item) { if (seen[item]) return false; seen[item] = true; return true; }); } }, set: function set() { var args = typeof arguments[0] === 'object' ? arguments[0] : arguments; var ret = {}; for (var i = 0; i < args.length; i++) { ret[args[i]] = 0; } return ret; }, STACK_ALIGN: 8, getAlignSize: function (type, size, vararg) { // we align i64s and doubles on 64-bit boundaries, unlike x86 if (type == 'i64' || type == 'double' || vararg) return 8; if (!type) return Math.min(size, 8); // align structures internally to 64 bits return Math.min(size || (type ? Runtime.getNativeFieldSize(type) : 0), Runtime.QUANTUM_SIZE); }, calculateStructAlignment: function calculateStructAlignment(type) { type.flatSize = 0; type.alignSize = 0; var diffs = []; var prev = -1; var index = 0; type.flatIndexes = type.fields.map(function(field) { index++; var size, alignSize; if (Runtime.isNumberType(field) || Runtime.isPointerType(field)) { size = Runtime.getNativeTypeSize(field); // pack char; char; in structs, also char[X]s. alignSize = Runtime.getAlignSize(field, size); } else if (Runtime.isStructType(field)) { if (field[1] === '0') { // this is [0 x something]. When inside another structure like here, it must be at the end, // and it adds no size // XXX this happens in java-nbody for example... assert(index === type.fields.length, 'zero-length in the middle!'); size = 0; alignSize = type.alignSize || QUANTUM_SIZE; } else { size = Types.types[field].flatSize; alignSize = Runtime.getAlignSize(null, Types.types[field].alignSize); } } else if (field[0] == 'b') { // bN, large number field, like a [N x i8] size = field.substr(1)|0; alignSize = 1; } else { throw 'Unclear type in struct: ' + field + ', in ' + type.name_ + ' :: ' + dump(Types.types[type.name_]); } if (type.packed) alignSize = 1; type.alignSize = Math.max(type.alignSize, alignSize); var curr = Runtime.alignMemory(type.flatSize, alignSize); // if necessary, place this on aligned memory type.flatSize = curr + size; if (prev >= 0) { diffs.push(curr-prev); } prev = curr; return curr; }); type.flatSize = Runtime.alignMemory(type.flatSize, type.alignSize); if (diffs.length == 0) { type.flatFactor = type.flatSize; } else if (Runtime.dedup(diffs).length == 1) { type.flatFactor = diffs[0]; } type.needsFlattening = (type.flatFactor != 1); return type.flatIndexes; }, generateStructInfo: function (struct, typeName, offset) { var type, alignment; if (typeName) { offset = offset || 0; type = (typeof Types === 'undefined' ? Runtime.typeInfo : Types.types)[typeName]; if (!type) return null; if (type.fields.length != struct.length) { printErr('Number of named fields must match the type for ' + typeName + ': possibly duplicate struct names. Cannot return structInfo'); return null; } alignment = type.flatIndexes; } else { var type = { fields: struct.map(function(item) { return item[0] }) }; alignment = Runtime.calculateStructAlignment(type); } var ret = { __size__: type.flatSize }; if (typeName) { struct.forEach(function(item, i) { if (typeof item === 'string') { ret[item] = alignment[i] + offset; } else { // embedded struct var key; for (var k in item) key = k; ret[key] = Runtime.generateStructInfo(item[key], type.fields[i], alignment[i]); } }); } else { struct.forEach(function(item, i) { ret[item[1]] = alignment[i]; }); } return ret; }, dynCall: function (sig, ptr, args) { if (args && args.length) { if (!args.splice) args = Array.prototype.slice.call(args); args.splice(0, 0, ptr); return Module['dynCall_' + sig].apply(null, args); } else { return Module['dynCall_' + sig].call(null, ptr); } }, functionPointers: [], addFunction: function (func) { for (var i = 0; i < Runtime.functionPointers.length; i++) { if (!Runtime.functionPointers[i]) { Runtime.functionPointers[i] = func; return 2 + 2*i; } } throw 'Finished up all reserved function pointers. Use a higher value for RESERVED_FUNCTION_POINTERS.'; }, removeFunction: function (index) { Runtime.functionPointers[(index-2)/2] = null; }, warnOnce: function (text) { if (!Runtime.warnOnce.shown) Runtime.warnOnce.shown = {}; if (!Runtime.warnOnce.shown[text]) { Runtime.warnOnce.shown[text] = 1; Module.printErr(text); } }, funcWrappers: {}, getFuncWrapper: function (func, sig) { assert(sig); if (!Runtime.funcWrappers[func]) { Runtime.funcWrappers[func] = function() { return Runtime.dynCall(sig, func, arguments); }; } return Runtime.funcWrappers[func]; }, UTF8Processor: function () { var buffer = []; var needed = 0; this.processCChar = function (code) { code = code & 0xff; if (needed) { buffer.push(code); needed--; } if (buffer.length == 0) { if (code < 128) return String.fromCharCode(code); buffer.push(code); if (code > 191 && code < 224) { needed = 1; } else { needed = 2; } return ''; } if (needed > 0) return ''; var c1 = buffer[0]; var c2 = buffer[1]; var c3 = buffer[2]; var ret; if (c1 > 191 && c1 < 224) { ret = String.fromCharCode(((c1 & 31) << 6) | (c2 & 63)); } else { ret = String.fromCharCode(((c1 & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); } buffer.length = 0; return ret; } this.processJSString = function(string) { string = unescape(encodeURIComponent(string)); var ret = []; for (var i = 0; i < string.length; i++) { ret.push(string.charCodeAt(i)); } return ret; } }, stackAlloc: function (size) { var ret = STACKTOP;STACKTOP = (STACKTOP + size)|0;STACKTOP = ((((STACKTOP)+7)>>3)<<3); return ret; }, staticAlloc: function (size) { var ret = STATICTOP;STATICTOP = (STATICTOP + size)|0;STATICTOP = ((((STATICTOP)+7)>>3)<<3); return ret; }, dynamicAlloc: function (size) { var ret = DYNAMICTOP;DYNAMICTOP = (DYNAMICTOP + size)|0;DYNAMICTOP = ((((DYNAMICTOP)+7)>>3)<<3); if (DYNAMICTOP >= TOTAL_MEMORY) enlargeMemory();; return ret; }, alignMemory: function (size,quantum) { var ret = size = Math.ceil((size)/(quantum ? quantum : 8))*(quantum ? quantum : 8); return ret; }, makeBigInt: function (low,high,unsigned) { var ret = (unsigned ? ((+(((low)>>>(0))))+((+(((high)>>>(0))))*(+(4294967296)))) : ((+(((low)>>>(0))))+((+(((high)|(0))))*(+(4294967296))))); return ret; }, GLOBAL_BASE: 8, QUANTUM_SIZE: 4, __dummy__: 0 } //======================================== // Runtime essentials //======================================== var __THREW__ = 0; // Used in checking for thrown exceptions. var ABORT = false; // whether we are quitting the application. no code should run after this. set in exit() and abort() var undef = 0; // tempInt is used for 32-bit signed values or smaller. tempBigInt is used // for 32-bit unsigned values or more than 32 bits. TODO: audit all uses of tempInt var tempValue, tempInt, tempBigInt, tempInt2, tempBigInt2, tempPair, tempBigIntI, tempBigIntR, tempBigIntS, tempBigIntP, tempBigIntD; var tempI64, tempI64b; var tempRet0, tempRet1, tempRet2, tempRet3, tempRet4, tempRet5, tempRet6, tempRet7, tempRet8, tempRet9; function assert(condition, text) { if (!condition) { abort('Assertion failed: ' + text); } } var globalScope = this; // C calling interface. A convenient way to call C functions (in C files, or // defined with extern "C"). // // Note: LLVM optimizations can inline and remove functions, after which you will not be // able to call them. Closure can also do so. To avoid that, add your function to // the exports using something like // // -s EXPORTED_FUNCTIONS='["_main", "_myfunc"]' // // @param ident The name of the C function (note that C++ functions will be name-mangled - use extern "C") // @param returnType The return type of the function, one of the JS types 'number', 'string' or 'array' (use 'number' for any C pointer, and // 'array' for JavaScript arrays and typed arrays; note that arrays are 8-bit). // @param argTypes An array of the types of arguments for the function (if there are no arguments, this can be ommitted). Types are as in returnType, // except that 'array' is not possible (there is no way for us to know the length of the array) // @param args An array of the arguments to the function, as native JS values (as in returnType) // Note that string arguments will be stored on the stack (the JS string will become a C string on the stack). // @return The return value, as a native JS value (as in returnType) function ccall(ident, returnType, argTypes, args) { return ccallFunc(getCFunc(ident), returnType, argTypes, args); } Module["ccall"] = ccall; // Returns the C function with a specified identifier (for C++, you need to do manual name mangling) function getCFunc(ident) { try { var func = Module['_' + ident]; // closure exported function if (!func) func = eval('_' + ident); // explicit lookup } catch(e) { } assert(func, 'Cannot call unknown function ' + ident + ' (perhaps LLVM optimizations or closure removed it?)'); return func; } // Internal function that does a C call using a function, not an identifier function ccallFunc(func, returnType, argTypes, args) { var stack = 0; function toC(value, type) { if (type == 'string') { if (value === null || value === undefined || value === 0) return 0; // null string if (!stack) stack = Runtime.stackSave(); var ret = Runtime.stackAlloc(value.length+1); writeStringToMemory(value, ret); return ret; } else if (type == 'array') { if (!stack) stack = Runtime.stackSave(); var ret = Runtime.stackAlloc(value.length); writeArrayToMemory(value, ret); return ret; } return value; } function fromC(value, type) { if (type == 'string') { return Pointer_stringify(value); } assert(type != 'array'); return value; } var i = 0; var cArgs = args ? args.map(function(arg) { return toC(arg, argTypes[i++]); }) : []; var ret = fromC(func.apply(null, cArgs), returnType); if (stack) Runtime.stackRestore(stack); return ret; } // Returns a native JS wrapper for a C function. This is similar to ccall, but // returns a function you can call repeatedly in a normal way. For example: // // var my_function = cwrap('my_c_function', 'number', ['number', 'number']); // alert(my_function(5, 22)); // alert(my_function(99, 12)); // function cwrap(ident, returnType, argTypes) { var func = getCFunc(ident); return function() { return ccallFunc(func, returnType, argTypes, Array.prototype.slice.call(arguments)); } } Module["cwrap"] = cwrap; // Sets a value in memory in a dynamic way at run-time. Uses the // type data. This is the same as makeSetValue, except that // makeSetValue is done at compile-time and generates the needed // code then, whereas this function picks the right code at // run-time. // Note that setValue and getValue only do *aligned* writes and reads! // Note that ccall uses JS types as for defining types, while setValue and // getValue need LLVM types ('i8', 'i32') - this is a lower-level operation function setValue(ptr, value, type, noSafe) { type = type || 'i8'; if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit switch(type) { case 'i1': HEAP8[(ptr)]=value; break; case 'i8': HEAP8[(ptr)]=value; break; case 'i16': HEAP16[((ptr)>>1)]=value; break; case 'i32': HEAP32[((ptr)>>2)]=value; break; case 'i64': (tempI64 = [value>>>0,((Math.min((+(Math.floor((value)/(+(4294967296))))), (+(4294967295))))|0)>>>0],HEAP32[((ptr)>>2)]=tempI64[0],HEAP32[(((ptr)+(4))>>2)]=tempI64[1]); break; case 'float': HEAPF32[((ptr)>>2)]=value; break; case 'double': HEAPF64[((ptr)>>3)]=value; break; default: abort('invalid type for setValue: ' + type); } } Module['setValue'] = setValue; // Parallel to setValue. function getValue(ptr, type, noSafe) { type = type || 'i8'; if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit switch(type) { case 'i1': return HEAP8[(ptr)]; case 'i8': return HEAP8[(ptr)]; case 'i16': return HEAP16[((ptr)>>1)]; case 'i32': return HEAP32[((ptr)>>2)]; case 'i64': return HEAP32[((ptr)>>2)]; case 'float': return HEAPF32[((ptr)>>2)]; case 'double': return HEAPF64[((ptr)>>3)]; default: abort('invalid type for setValue: ' + type); } return null; } Module['getValue'] = getValue; var ALLOC_NORMAL = 0; // Tries to use _malloc() var ALLOC_STACK = 1; // Lives for the duration of the current function call var ALLOC_STATIC = 2; // Cannot be freed var ALLOC_DYNAMIC = 3; // Cannot be freed except through sbrk var ALLOC_NONE = 4; // Do not allocate Module['ALLOC_NORMAL'] = ALLOC_NORMAL; Module['ALLOC_STACK'] = ALLOC_STACK; Module['ALLOC_STATIC'] = ALLOC_STATIC; Module['ALLOC_DYNAMIC'] = ALLOC_DYNAMIC; Module['ALLOC_NONE'] = ALLOC_NONE; // allocate(): This is for internal use. You can use it yourself as well, but the interface // is a little tricky (see docs right below). The reason is that it is optimized // for multiple syntaxes to save space in generated code. So you should // normally not use allocate(), and instead allocate memory using _malloc(), // initialize it with setValue(), and so forth. // @slab: An array of data, or a number. If a number, then the size of the block to allocate, // in *bytes* (note that this is sometimes confusing: the next parameter does not // affect this!) // @types: Either an array of types, one for each byte (or 0 if no type at that position), // or a single type which is used for the entire block. This only matters if there // is initial data - if @slab is a number, then this does not matter at all and is // ignored. // @allocator: How to allocate memory, see ALLOC_* function allocate(slab, types, allocator, ptr) { var zeroinit, size; if (typeof slab === 'number') { zeroinit = true; size = slab; } else { zeroinit = false; size = slab.length; } var singleType = typeof types === 'string' ? types : null; var ret; if (allocator == ALLOC_NONE) { ret = ptr; } else { ret = [_malloc, Runtime.stackAlloc, Runtime.staticAlloc, Runtime.dynamicAlloc][allocator === undefined ? ALLOC_STATIC : allocator](Math.max(size, singleType ? 1 : types.length)); } if (zeroinit) { var ptr = ret, stop; assert((ret & 3) == 0); stop = ret + (size & ~3); for (; ptr < stop; ptr += 4) { HEAP32[((ptr)>>2)]=0; } stop = ret + size; while (ptr < stop) { HEAP8[((ptr++)|0)]=0; } return ret; } if (singleType === 'i8') { if (slab.subarray || slab.slice) { HEAPU8.set(slab, ret); } else { HEAPU8.set(new Uint8Array(slab), ret); } return ret; } var i = 0, type, typeSize, previousType; while (i < size) { var curr = slab[i]; if (typeof curr === 'function') { curr = Runtime.getFunctionIndex(curr); } type = singleType || types[i]; if (type === 0) { i++; continue; } if (type == 'i64') type = 'i32'; // special case: we have one i32 here, and one i32 later setValue(ret+i, curr, type); // no need to look up size unless type changes, so cache it if (previousType !== type) { typeSize = Runtime.getNativeTypeSize(type); previousType = type; } i += typeSize; } return ret; } Module['allocate'] = allocate; function Pointer_stringify(ptr, /* optional */ length) { // Find the length, and check for UTF while doing so var hasUtf = false; var t; var i = 0; while (1) { t = HEAPU8[(((ptr)+(i))|0)]; if (t >= 128) hasUtf = true; else if (t == 0 && !length) break; i++; if (length && i == length) break; } if (!length) length = i; var ret = ''; if (!hasUtf) { var MAX_CHUNK = 1024; // split up into chunks, because .apply on a huge string can overflow the stack var curr; while (length > 0) { curr = String.fromCharCode.apply(String, HEAPU8.subarray(ptr, ptr + Math.min(length, MAX_CHUNK))); ret = ret ? ret + curr : curr; ptr += MAX_CHUNK; length -= MAX_CHUNK; } return ret; } var utf8 = new Runtime.UTF8Processor(); for (i = 0; i < length; i++) { t = HEAPU8[(((ptr)+(i))|0)]; ret += utf8.processCChar(t); } return ret; } Module['Pointer_stringify'] = Pointer_stringify; // Memory management var PAGE_SIZE = 4096; function alignMemoryPage(x) { return ((x+4095)>>12)<<12; } var HEAP; var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64; var STATIC_BASE = 0, STATICTOP = 0, staticSealed = false; // static area var STACK_BASE = 0, STACKTOP = 0, STACK_MAX = 0; // stack area var DYNAMIC_BASE = 0, DYNAMICTOP = 0; // dynamic area handled by sbrk function enlargeMemory() { abort('Cannot enlarge memory arrays in asm.js. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value, or (2) set Module.TOTAL_MEMORY before the program runs.'); } var TOTAL_STACK = Module['TOTAL_STACK'] || 131072; var TOTAL_MEMORY = Module['TOTAL_MEMORY'] || 4194304; var FAST_MEMORY = Module['FAST_MEMORY'] || 2097152; // Initialize the runtime's memory // check for full engine support (use string 'subarray' to avoid closure compiler confusion) assert(!!Int32Array && !!Float64Array && !!(new Int32Array(1)['subarray']) && !!(new Int32Array(1)['set']), 'Cannot fallback to non-typed array case: Code is too specialized'); var buffer = new ArrayBuffer(TOTAL_MEMORY); HEAP8 = new Int8Array(buffer); HEAP16 = new Int16Array(buffer); HEAP32 = new Int32Array(buffer); HEAPU8 = new Uint8Array(buffer); HEAPU16 = new Uint16Array(buffer); HEAPU32 = new Uint32Array(buffer); HEAPF32 = new Float32Array(buffer); HEAPF64 = new Float64Array(buffer); // Endianness check (note: assumes compiler arch was little-endian) HEAP32[0] = 255; assert(HEAPU8[0] === 255 && HEAPU8[3] === 0, 'Typed arrays 2 must be run on a little-endian system'); Module['HEAP'] = HEAP; Module['HEAP8'] = HEAP8; Module['HEAP16'] = HEAP16; Module['HEAP32'] = HEAP32; Module['HEAPU8'] = HEAPU8; Module['HEAPU16'] = HEAPU16; Module['HEAPU32'] = HEAPU32; Module['HEAPF32'] = HEAPF32; Module['HEAPF64'] = HEAPF64; function callRuntimeCallbacks(callbacks) { while(callbacks.length > 0) { var callback = callbacks.shift(); if (typeof callback == 'function') { callback(); continue; } var func = callback.func; if (typeof func === 'number') { if (callback.arg === undefined) { Runtime.dynCall('v', func); } else { Runtime.dynCall('vi', func, [callback.arg]); } } else { func(callback.arg === undefined ? null : callback.arg); } } } var __ATPRERUN__ = []; // functions called before the runtime is initialized var __ATINIT__ = []; // functions called during startup var __ATMAIN__ = []; // functions called when main() is to be run var __ATEXIT__ = []; // functions called during shutdown var __ATPOSTRUN__ = []; // functions called after the runtime has exited var runtimeInitialized = false; function preRun() { // compatibility - merge in anything from Module['preRun'] at this time if (Module['preRun']) { if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']]; while (Module['preRun'].length) { addOnPreRun(Module['preRun'].shift()); } } callRuntimeCallbacks(__ATPRERUN__); } function ensureInitRuntime() { if (runtimeInitialized) return; runtimeInitialized = true; callRuntimeCallbacks(__ATINIT__); } function preMain() { callRuntimeCallbacks(__ATMAIN__); } function exitRuntime() { callRuntimeCallbacks(__ATEXIT__); } function postRun() { // compatibility - merge in anything from Module['postRun'] at this time if (Module['postRun']) { if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']]; while (Module['postRun'].length) { addOnPostRun(Module['postRun'].shift()); } } callRuntimeCallbacks(__ATPOSTRUN__); } function addOnPreRun(cb) { __ATPRERUN__.unshift(cb); } Module['addOnPreRun'] = Module.addOnPreRun = addOnPreRun; function addOnInit(cb) { __ATINIT__.unshift(cb); } Module['addOnInit'] = Module.addOnInit = addOnInit; function addOnPreMain(cb) { __ATMAIN__.unshift(cb); } Module['addOnPreMain'] = Module.addOnPreMain = addOnPreMain; function addOnExit(cb) { __ATEXIT__.unshift(cb); } Module['addOnExit'] = Module.addOnExit = addOnExit; function addOnPostRun(cb) { __ATPOSTRUN__.unshift(cb); } Module['addOnPostRun'] = Module.addOnPostRun = addOnPostRun; // Tools // This processes a JS string into a C-line array of numbers, 0-terminated. // For LLVM-originating strings, see parser.js:parseLLVMString function function intArrayFromString(stringy, dontAddNull, length /* optional */) { var ret = (new Runtime.UTF8Processor()).processJSString(stringy); if (length) { ret.length = length; } if (!dontAddNull) { ret.push(0); } return ret; } Module['intArrayFromString'] = intArrayFromString; function intArrayToString(array) { var ret = []; for (var i = 0; i < array.length; i++) { var chr = array[i]; if (chr > 0xFF) { chr &= 0xFF; } ret.push(String.fromCharCode(chr)); } return ret.join(''); } Module['intArrayToString'] = intArrayToString; // Write a Javascript array to somewhere in the heap function writeStringToMemory(string, buffer, dontAddNull) { var array = intArrayFromString(string, dontAddNull); var i = 0; while (i < array.length) { var chr = array[i]; HEAP8[(((buffer)+(i))|0)]=chr i = i + 1; } } Module['writeStringToMemory'] = writeStringToMemory; function writeArrayToMemory(array, buffer) { for (var i = 0; i < array.length; i++) { HEAP8[(((buffer)+(i))|0)]=array[i]; } } Module['writeArrayToMemory'] = writeArrayToMemory; function unSign(value, bits, ignore, sig) { if (value >= 0) { return value; } return bits <= 32 ? 2*Math.abs(1 << (bits-1)) + value // Need some trickery, since if bits == 32, we are right at the limit of the bits JS uses in bitshifts : Math.pow(2, bits) + value; } function reSign(value, bits, ignore, sig) { if (value <= 0) { return value; } var half = bits <= 32 ? Math.abs(1 << (bits-1)) // abs is needed if bits == 32 : Math.pow(2, bits-1); if (value >= half && (bits <= 32 || value > half)) { // for huge values, we can hit the precision limit and always get true here. so don't do that // but, in general there is no perfect solution here. With 64-bit ints, we get rounding and errors // TODO: In i64 mode 1, resign the two parts separately and safely value = -2*half + value; // Cannot bitshift half, as it may be at the limit of the bits JS uses in bitshifts } return value; } if (!Math['imul']) Math['imul'] = function(a, b) { var ah = a >>> 16; var al = a & 0xffff; var bh = b >>> 16; var bl = b & 0xffff; return (al*bl + ((ah*bl + al*bh) << 16))|0; }; Math.imul = Math['imul']; // A counter of dependencies for calling run(). If we need to // do asynchronous work before running, increment this and // decrement it. Incrementing must happen in a place like // PRE_RUN_ADDITIONS (used by emcc to add file preloading). // Note that you can add dependencies in preRun, even though // it happens right before run - run will be postponed until // the dependencies are met. var runDependencies = 0; var runDependencyTracking = {}; var calledInit = false, calledRun = false; var runDependencyWatcher = null; function addRunDependency(id) { runDependencies++; if (Module['monitorRunDependencies']) { Module['monitorRunDependencies'](runDependencies); } if (id) { assert(!runDependencyTracking[id]); runDependencyTracking[id] = 1; } else { Module.printErr('warning: run dependency added without ID'); } } Module['addRunDependency'] = addRunDependency; function removeRunDependency(id) { runDependencies--; if (Module['monitorRunDependencies']) { Module['monitorRunDependencies'](runDependencies); } if (id) { assert(runDependencyTracking[id]); delete runDependencyTracking[id]; } else { Module.printErr('warning: run dependency removed without ID'); } if (runDependencies == 0) { if (runDependencyWatcher !== null) { clearInterval(runDependencyWatcher); runDependencyWatcher = null; } // If run has never been called, and we should call run (INVOKE_RUN is true, and Module.noInitialRun is not false) if (!calledRun && shouldRunNow) run(); } } Module['removeRunDependency'] = removeRunDependency; Module["preloadedImages"] = {}; // maps url to image data Module["preloadedAudios"] = {}; // maps url to audio data function loadMemoryInitializer(filename) { function applyData(data) { HEAPU8.set(data, STATIC_BASE); } // always do this asynchronously, to keep shell and web as similar as possible addOnPreRun(function() { if (ENVIRONMENT_IS_NODE || ENVIRONMENT_IS_SHELL) { applyData(Module['readBinary'](filename)); } else { Browser.asyncLoad(filename, function(data) { applyData(data); }, function(data) { throw 'could not load memory initializer ' + filename; }); } }); } // === Body === STATIC_BASE = 8; STATICTOP = STATIC_BASE + 47432; /* global initializers */ __ATINIT__.push({ func: function() { runPostSets() } }); var _stderr; var ___progname; var __ZTVN10__cxxabiv120__si_class_type_infoE; var __ZTVN10__cxxabiv119__pointer_type_infoE; var __ZTVN10__cxxabiv117__class_type_infoE; var __ZTIy; var __ZTIx; var __ZTIt; var __ZTIs; var __ZTIm; var __ZTIl; var __ZTIj; var __ZTIi; var __ZTIh; var __ZTIf; var __ZTIe; var __ZTId; var __ZTIc; var __ZTIa; var __ZN10ime_pinyin11DictBuilderC1Ev; var __ZN10ime_pinyin11DictBuilderD1Ev; var __ZN10ime_pinyin8DictTrieC1Ev; var __ZN10ime_pinyin8DictTrieD1Ev; var __ZN10ime_pinyin12MatrixSearchC1Ev; var __ZN10ime_pinyin12MatrixSearchD1Ev; var __ZN10ime_pinyin5NGramC1Ev; var __ZN10ime_pinyin5NGramD1Ev; var __ZN10ime_pinyin12SpellingTrieC1Ev; var __ZN10ime_pinyin12SpellingTrieD1Ev; var __ZN10ime_pinyin4SyncC1Ev; var __ZN10ime_pinyin4SyncD1Ev; var __ZN10ime_pinyin8DictListC1Ev; var __ZN10ime_pinyin8DictListD1Ev; var __ZN10ime_pinyin8LpiCacheC1Ev; var __ZN10ime_pinyin8LpiCacheD1Ev; var __ZN10ime_pinyin13SpellingTableC1Ev; var __ZN10ime_pinyin13SpellingTableD1Ev; var __ZN10ime_pinyin14SpellingParserC1Ev; var __ZN10ime_pinyin8UserDictC1Ev; var __ZN10ime_pinyin8UserDictD1Ev; var __ZN10ime_pinyin11Utf16ReaderC1Ev; var __ZN10ime_pinyin11Utf16ReaderD1Ev; var __ZNSt9type_infoD1Ev; var __ZNSt8bad_castC1Ev; var __ZNSt8bad_castD1Ev; var __ZNSt10bad_typeidC1Ev; var __ZNSt10bad_typeidD1Ev; var __ZN10__cxxabiv116__shim_type_infoD1Ev; var __ZN10__cxxabiv123__fundamental_type_infoD1Ev; var __ZN10__cxxabiv123__fundamental_type_infoD2Ev; var __ZN10__cxxabiv117__array_type_infoD1Ev; var __ZN10__cxxabiv117__array_type_infoD2Ev; var __ZN10__cxxabiv120__function_type_infoD1Ev; var __ZN10__cxxabiv120__function_type_infoD2Ev; var __ZN10__cxxabiv116__enum_type_infoD1Ev; var __ZN10__cxxabiv116__enum_type_infoD2Ev; var __ZN10__cxxabiv117__class_type_infoD1Ev; var __ZN10__cxxabiv117__class_type_infoD2Ev; var __ZN10__cxxabiv120__si_class_type_infoD1Ev; var __ZN10__cxxabiv120__si_class_type_infoD2Ev; var __ZN10__cxxabiv121__vmi_class_type_infoD1Ev; var __ZN10__cxxabiv121__vmi_class_type_infoD2Ev; var __ZN10__cxxabiv117__pbase_type_infoD1Ev; var __ZN10__cxxabiv117__pbase_type_infoD2Ev; var __ZN10__cxxabiv119__pointer_type_infoD1Ev; var __ZN10__cxxabiv119__pointer_type_infoD2Ev; var __ZN10__cxxabiv129__pointer_to_member_type_infoD1Ev; var __ZN10__cxxabiv129__pointer_to_member_type_infoD2Ev; var __ZNSt9bad_allocC1Ev; var __ZNSt9bad_allocD1Ev; var __ZNSt20bad_array_new_lengthC1Ev; var __ZNSt20bad_array_new_lengthD1Ev; var __ZNSt20bad_array_new_lengthD2Ev; var _err; var _errx; var _warn; var _warnx; var _verr; var _verrx; var _vwarn; var _vwarnx; var _stderr = _stderr=allocate([0,0,0,0,0,0,0,0], "i8", ALLOC_STATIC); __ZTVN10__cxxabiv120__si_class_type_infoE=allocate([0,0,0,0,248,41,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], "i8", ALLOC_STATIC); __ZTVN10__cxxabiv119__pointer_type_infoE=allocate([0,0,0,0,24,42,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,0,0,0,0,0,0,0,0], "i8", ALLOC_STATIC); __ZTVN10__cxxabiv117__class_type_infoE=allocate([0,0,0,0,56,42,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], "i8", ALLOC_STATIC); __ZTIy=allocate([0,0,0,0,0,0,0,0], "i8", ALLOC_STATIC); __ZTIx=allocate([0,0,0,0,0,0,0,0], "i8", ALLOC_STATIC); __ZTIt=allocate([0,0,0,0,0,0,0,0], "i8", ALLOC_STATIC); __ZTIs=allocate([0,0,0,0,0,0,0,0], "i8", ALLOC_STATIC); __ZTIm=allocate([0,0,0,0,0,0,0,0], "i8", ALLOC_STATIC); __ZTIl=allocate([0,0,0,0,0,0,0,0], "i8", ALLOC_STATIC); __ZTIj=allocate([0,0,0,0,0,0,0,0], "i8", ALLOC_STATIC); __ZTIi=allocate([0,0,0,0,0,0,0,0], "i8", ALLOC_STATIC); __ZTIh=allocate([0,0,0,0,0,0,0,0], "i8", ALLOC_STATIC); __ZTIf=allocate([0,0,0,0,0,0,0,0], "i8", ALLOC_STATIC); __ZTIe=allocate([0,0,0,0,0,0,0,0], "i8", ALLOC_STATIC); __ZTId=allocate([0,0,0,0,0,0,0,0], "i8", ALLOC_STATIC); __ZTIc=allocate([0,0,0,0,0,0,0,0], "i8", ALLOC_STATIC); __ZTIa=allocate([0,0,0,0,0,0,0,0], "i8", ALLOC_STATIC); /* memory initializer */ allocate([45,44,32,0,0,0,0,0,45,44,32,0,0,0,0,0,45,44,32,0,0,0,0,0,45,44,32,0,0,0,0,0,45,44,32,0,0,0,0,0,91,114,111,111,116,32,105,115,32,108,97,121,101,114,32,45,49,93,0,0,0,0,0,0,10,45,45,45,45,45,45,45,45,45,45,45,45,83,84,65,84,32,73,78,70,79,45,45,45,45,45,45,45,45,45,45,45,45,45,0,0,0,0,0,111,112,116,105,111,110,32,114,101,113,117,105,114,101,115,32,97,110,32,97,114,103,117,109,101,110,116,32,45,45,32,37,115,0,0,0,0,0,0,0,111,112,116,105,111,110,32,114,101,113,117,105,114,101,115,32,97,110,32,97,114,103,117,109,101,110,116,32,45,45,32,37,99,0,0,0,0,0,0,0,0,0,0,0,0,0,36,64,0,0,0,0,0,0,89,64,0,0,0,0,0,136,195,64,0,0,0,0,132,215,151,65,0,128,224,55,121,195,65,67,23,110,5,181,181,184,147,70,245,249,63,233,3,79,56,77,50,29,48,249,72,119,130,90,60,191,115,127,221,79,21,117,64,181,0,0,0,0,0,0,63,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,255,255,255,255,0,0,0,0,255,255,255,255,0,0,0,0,111,112,116,105,111,110,32,100,111,101,115,110,39,116,32,116,97,107,101,32,97,110,32,97,114,103,117,109,101,110,116,32,45,45,32,37,46,42,115,0,117,110,107,110,111,119,110,32,111,112,116,105,111,110,32,45,45,32,37,115,0,0,0,0,117,110,107,110,111,119,110,32,111,112,116,105,111,110,32,45,45,32,37,99,0,0,0,0,255,255,255,255,0,0,0,0,97,109,98,105,103,117,111,117,115,32,111,112,116,105,111,110,32,45,45,32,37,46,42,115,0,0,0,0,0,0,0,0,32,77,105,108,101,83,116,111,110,101,58,32,37,120,44,32,37,120,10,0,0,0,0,0,78,85,76,76,32,33,61,32,100,101,112,32,38,38,32,102,114,111,109,95,104,97,110,100,108,101,32,62,32,48,32,38,38,32,102,114,111,109,95,104,97,110,100,108,101,32,60,32,109,105,108,101,95,115,116,111,110,101,115,95,112,111,115,95,0,0,0,0,0,0,0,0,37,115,58,32,0,0,0,0,102,111,117,110,100,95,110,117,109,32,43,32,49,32,60,32,109,97,120,95,115,112,108,105,100,115,0,0,0,0,0,0,83,104,0,0,0,0,0,0,108,109,97,95,102,114,101,113,95,105,100,120,95,0,0,0,100,108,95,115,117,99,99,101,115,115,0,0,0,0,0,0,45,45,45,37,100,10,0,0,115,111,110,45,62,115,112,108,95,105,100,120,32,62,61,32,105,100,95,115,116,97,114,116,32,38,38,32,115,111,110,45,62,115,112,108,95,105,100,120,32,60,32,105,100,95,115,116,97,114,116,32,43,32,105,100,95,110,117,109,0,0,0,0,78,85,76,76,32,33,61,32,104,122,95,102,111,117,110,100,32,38,38,32,104,97,110,122,105,32,61,61,32,42,104,122,95,102,111,117,110,100,0,0,67,104,0,0,0,0,0,0,102,114,101,113,95,99,111,100,101,115,95,0,0,0,0,0,48,32,33,61,32,110,117,109,0,0,0,0,0,0,0,0,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,37,100,39,116,104,32,68,77,73,32,110,111,100,101,32,98,101,103,105,110,45,45,45,45,45,45,45,45,45,45,45,62,10,0,0,0,0,0,0,49,32,61,61,32,110,111,100,101,45,62,115,111,110,95,49,115,116,95,111,102,102,0,0,104,122,115,95,108,101,110,32,60,61,32,107,77,97,120,80,114,101,100,105,99,116,83,105,122,101,32,38,38,32,104,122,115,95,108,101,110,32,62,32,48,0,0,0,0,0,0,0,37,115,0,0,0,0,0,0,102,114,101,113,95,99,111,100,101,115,95,100,102,95,0,0,49,32,61,61,32,115,112,108,95,105,100,120,95,110,117,109,0,0,0,0,0,0,0,0,115,112,108,95,105,100,95,102,114,32,60,61,32,107,77,97,120,76,101,109,109,97,83,105,122,101,0,0,0,0,0,0,78,85,76,76,32,33,61,32,100,101,112,32,38,38,32,48,32,61,61,32,102,114,111,109,95,104,97,110,100,108,101,0,105,100,95,110,117,109,32,61,61,32,115,116,97,114,116,95,105,100,95,91,107,77,97,120,76,101,109,109,97,83,105,122,101,93,0,0,0,0,0,0,115,111,110,95,112,111,115,32,43,32,49,32,61,61,32,110,117,109,95,111,102,95,115,111,110,0,0,0,0,0,0,0,102,114,101,113,115,91,112,111,115,93,32,62,32,48,0,0,117,116,102,49,54,95,115,116,114,108,101,110,40,116,111,107,101,110,41,32,60,61,32,107,77,97,120,80,105,110,121,105,110,83,105,122,101,0,0,0,116,109,112,32,61,61,32,108,109,97,95,108,101,110,0,0,48,32,61,61,32,100,101,112,45,62,115,112,108,105,100,115,95,101,120,116,101,110,100,101,100,0,0,0,0,0,0,0,46,46,47,115,104,97,114,101,47,109,97,116,114,105,120,115,101,97,114,99,104,46,99,112,112,0,0,0,0,0,0,0,80,79,83,73,88,76,89,95,67,79,82,82,69,67,84,0,99,117,114,114,101,110,116,95,112,111,115,32,61,61,32,115,116,97,114,116,95,112,111,115,95,91,107,77,97,120,76,101,109,109,97,83,105,122,101,93,0,0,0,0,0,0,0,0,105,115,95,118,97,108,105,100,95,115,112,108,95,99,104,97,114,40,99,104,97,114,95,99,117,114,114,101,110,116,41,0,105,100,120,95,110,111,119,32,43,32,49,32,61,61,32,110,101,120,116,95,105,100,120,95,117,110,117,115,101,100,0,0,78,85,76,76,32,33,61,32,116,111,107,101,110,0,0,0,99,95,112,104,114,97,115,101,95,46,108,101,110,103,116,104,32,62,32,48,32,38,38,32,99,95,112,121,95,108,101,110,32,61,61,32,99,95,112,104,114,97,115,101,95,46,115,112,108,95,115,116,97,114,116,91,99,95,112,104,114,97,115,101,95,46,115,117,98,108,109,97,95,115,116,97,114,116,91,99,95,112,104,114,97,115,101,95,46,115,117,98,108,109,97,95,110,117,109,93,93,0,0,0,114,98,0,0,0,0,0,0,115,99,105,115,95,110,117,109,95,32,61,61,32,115,99,105,115,95,110,117,109,0,0,0,40,99,104,97,114,95,102,111,114,95,110,111,100,101,32,62,61,32,39,65,39,41,32,38,38,32,40,99,104,97,114,95,102,111,114,95,110,111,100,101,32,60,61,32,39,90,39,32,124,124,32,39,104,39,32,61,61,32,99,104,97,114,95,102,111,114,95,110,111,100,101,41,0,0,0,0,0,0,0,0,108,101,109,109,97,95,97,114,114,91,112,111,115,93,46,105,100,120,95,98,121,95,104,122,32,61,61,32,105,100,120,95,110,111,119,0,0,0,0,0,109,111,118,101,95,112,111,115,32,62,32,48,0,0,0,0,98,95,97,99,95,116,109,112,0,0,0,0,0,0,0,0,119,98,0,0,0,0,0,0,46,46,32,116,111,116,97,108,32,108,101,109,109,97,32,110,111,100,101,32,110,117,109,98,101,114,58,32,37,108,100,10,0,0,0,0,0,0,0,0,115,116,97,116,105,99,95,99,97,115,116,60,115,105,122,101,95,116,62,40,115,112,108,105,100,32,45,32,107,70,117,108,108,83,112,108,73,100,83,116,97,114,116,41,32,60,32,98,117,102,95,115,105,122,101,0,115,116,100,58,58,98,97,100,95,97,108,108,111,99,0,0,109,97,120,32,115,121,115,116,101,109,32,98,121,116,101,115,32,61,32,37,49,48,108,117,10,0,0,0,0,0,0,0,46,46,32,115,111,110,32,98,117,102,32,97,108,108,111,99,97,116,105,111,110,32,110,117,109,98,101,114,32,119,105,116,104,32,109,111,114,101,32,116,104,97,110,32,49,32,115,111,110,58,32,37,108,100,10,0,102,97,108,115,101,0,0,0,78,85,76,76,32,33,61,32,105,110,115,116,97,110,99,101,95,0,0,0,0,0,0,0,115,116,100,58,58,98,97,100,95,99,97,115,116,0,0,0,99,117,114,114,101,110,116,95,104,122,95,108,101,110,32,62,61,32,108,97,115,116,95,104,122,95,108,101,110,0,0,0,46,46,32,115,111,110,32,98,117,102,32,97,108,108,111,99,97,116,105,111,110,32,110,117,109,98,101,114,32,119,105,116,104,32,111,110,108,121,32,49,32,115,111,110,58,32,37,108,100,10,0,0,0,0,0,0,121,109,95,105,100,32,62,32,48,0,0,0,0,0,0,0,105,116,101,109,95,110,117,109,91,99,111,100,101,93,32,62,32,48,0,0,0,0,0,0,46,46,32,116,111,116,97,108,95,104,111,109,111,95,110,117,109,32,112,101,114,32,108,97,121,101,114,58,10,32,32,32,48,44,32,0,0,0,0,0,114,98,0,0,0,0,0,0,46,46,32,116,111,116,97,108,95,110,111,100,101,95,105,110,95,115,111,110,98,117,102,95,97,108,108,110,111,115,111,110,32,112,101,114,32,108,97,121,101,114,58,10,32,32,32,0,42,102,111,117,110,100,32,61,61,32,104,122,0,0,0,0,108,109,97,95,98,117,102,91,114,101,109,97,105,110,95,110,117,109,32,45,32,49,93,46,104,97,110,122,105,32,61,61,32,108,109,97,95,98,117,102,91,112,111,115,93,46,104,97,110,122,105,0,0,0,0,0,119,43,0,0,0,0,0,0,46,46,32,116,111,116,97,108,95,115,111,110,98,117,102,95,97,108,108,110,111,115,111,110,32,112,101,114,32,108,97,121,101,114,58,10,32,32,32,0,114,101,109,97,105,110,95,110,117,109,32,62,32,48,0,0,46,46,32,116,111,116,97,108,95,115,111,110,98,117,102,95,110,117,109,32,112,101,114,32,108,97,121,101,114,58,10,32,32,32,0,0,0,0,0,0,108,112,115,105,95,110,117,109,32,62,32,110,117,109,0,0,46,46,32,116,111,116,97,108,95,110,111,100,101,95,104,97,115,115,111,110,32,112,101,114,32,108,97,121,101,114,58,10,32,32,32,49,44,32,0,0,78,85,76,76,32,33,61,32,109,116,114,120,95,110,100,0,46,46,47,115,104,97,114,101,47,115,112,101,108,108,105,110,103,116,97,98,108,101,46,99,112,112,0,0,0,0,0,0,46,46,32,116,111,116,97,108,95,115,111,110,95,110,117,109,32,112,101,114,32,108,97,121,101,114,58,10,32,32,32,0,100,109,105,95,99,95,112,104,114,97,115,101,95,0,0,0,108,109,97,95,115,116,97,114,116,95,91,102,105,120,101,100,95,108,109,97,115,95,93,32,61,61,32,102,105,120,101,100,95,104,122,115,95,0,0,0,46,46,47,115,104,97,114,101,47,108,112,105,99,97,99,104,101,46,99,112,112,0,0,0,115,112,108,95,116,114,105,101,95,45,62,105,115,95,104,97,108,102,95,105,100,40,115,112,108,105,100,41,0,0,0,0,46,46,32,109,97,120,95,104,111,109,111,98,117,102,95,108,101,110,32,112,101,114,32,108,97,121,101,114,58,10,32,32,32,45,44,32,0,0,0,0,108,109,97,95,105,100,95,110,117,109,95,32,43,32,102,105,120,101,100,95,108,109,97,115,95,32,45,32,112,111,115,32,45,32,49,32,62,61,32,112,111,115,0,0,0,0,0,0,108,109,97,95,110,111,100,101,95,110,117,109,95,108,101,48,95,32,60,61,32,98,117,102,95,115,105,122,101,0,0,0,37,115,58,32,0,0,0,0,105,110,32,117,115,101,32,98,121,116,101,115,32,32,32,32,32,61,32,37,49,48,108,117,10,0,0,0,0,0,0,0,46,46,47,115,104,97,114,101,47,117,115,101,114,100,105,99,116,46,99,112,112,0,0,0,112,104,114,97,115,101,95,108,101,110,32,62,32,48,0,0,97,118,101,114,97,103,101,95,115,99,111,114,101,32,60,61,32,50,53,53,0,0,0,0,78,85,76,76,32,33,61,32,108,112,105,95,99,97,99,104,101,95,108,101,110,95,0,0,108,101,109,109,97,95,97,114,114,91,48,93,46,105,100,120,95,98,121,95,104,122,32,61,61,32,49,0,0,0,0,0,37,115,10,0,0,0,0,0,37,108,100,44,32,0,0,0,112,104,114,97,115,101,95,108,101,110,32,61,61,32,108,109,97,95,115,116,97,114,116,95,91,102,105,120,101,100,95,108,109,97,115,95,93,0,0,0,115,117,99,101,115,115,0,0,46,46,47,115,104,97,114,101,47,100,105,99,116,108,105,115,116,46,99,112,112,0,0,0,99,98,95,110,101,119,0,0,37,115,10,0,0,0,0,0,46,46,32,109,97,120,95,115,111,110,98,117,102,95,108,101,110,32,112,101,114,32,108,97,121,101,114,40,102,114,111,109,32,108,97,121,101,114,32,48,41,58,10,32,32,32,0,0,108,109,97,95,108,101,110,32,61,61,32,108,109,97,95,115,116,97,114,116,95,91,112,111,115,32,43,32,49,93,32,45,32,108,109,97,95,115,116,97,114,116,95,91,112,111,115,93,0,0,0,0,0,0,0,0,42,110,117,109,32,62,61,32,49,0,0,0,0,0,0,0,111,108,100,114,111,119,32,62,61,32,100,109,105,45,62,115,112,108,115,116,114,95,108,101,110,0,0,0,0,0,0,0,100,101,112,95,45,62,105,100,95,110,117,109,32,62,32,48,0,0,0,0,0,0,0,0,99,97,110,100,95,115,112,108,105,100,115,95,116,104,105,115,32,62,32,48,0,0,0,0,37,115,58,32,0,0,0,0,115,111,110,95,112,111,115,32,43,32,49,32,61,61,32,112,97,114,101,110,116,95,115,111,110,95,110,117,109,0,0,0,48,32,61,61,32,112,114,101,118,95,105,100,115,95,110,117,109,0,0,0,0,0,0,0,40,33,97,114,103,95,118,97,108,105,100,32,38,38,32,115,112,108,105,100,115,95,109,97,120,32,62,61,32,108,109,97,95,108,101,110,41,32,124,124,32,108,109,97,95,108,101,110,32,61,61,32,115,112,108,105,100,115,95,109,97,120,0,0,104,111,109,111,95,110,117,109,32,60,61,32,50,53,53,0,78,85,76,76,32,33,61,32,101,110,100,95,110,111,100,101,0,0,0,0,0,0,0,0,110,111,100,101,95,115,111,110,45,62,115,112,108,95,105,100,120,32,62,61,32,105,100,95,115,116,97,114,116,32,38,38,32,110,111,100,101,95,115,111,110,45,62,115,112,108,95,105,100,120,32,60,32,105,100,95,115,116,97,114,116,32,43,32,105,100,95,110,117,109,0,0,104,111,109,111,95,110,117,109,32,60,61,32,54,53,53,51,53,0,0,0,0,0,0,0,46,46,47,115,104,97,114,101,47,115,112,101,108,108,105,110,103,116,114,105,101,46,99,112,112,0,0,0,0,0,0,0,98,0,0,0,0,0,0,0,110,111,100,101,32,61,61,32,114,111,111,116,95,32,38,38,32,49,32,61,61,32,110,111,100,101,95,102,114,95,110,117,109,0,0,0,0,0,0,0,115,112,108,95,115,116,97,114,116,95,91,102,105,120,101,100,95,104,122,115,95,93,32,61,61,32,102,105,120,101,100,95,99,104,95,112,111,115,0,0,37,115,58,32,0,0,0,0,112,97,114,101,110,116,95,115,111,110,95,110,117,109,32,60,61,32,50,53,53,0,0,0,115,116,101,112,95,116,111,95,100,109,105,95,102,114,32,33,61,32,115,116,97,116,105,99,95,99,97,115,116,60,80,111,111,108,80,111,115,84,121,112,101,62,40,45,49,41,0,0,105,100,95,110,117,109,32,62,32,48,0,0,0,0,0,0,98,97,100,95,97,114,114,97,121,95,110,101,119,95,108,101,110,103,116,104,0,0,0,0,112,97,114,101,110,116,95,115,111,110,95,110,117,109,32,60,61,32,54,53,53,51,53,0,99,97,110,100,95,108,101,110,32,62,32,48,0,0,0,0,46,46,47,115,104,97,114,101,47,100,105,99,116,116,114,105,101,46,99,112,112,0,0,0,110,111,100,101,95,103,101,49,45,62,115,111,110,95,49,115,116,95,111,102,102,95,108,32,62,32,48,32,124,124,32,110,111,100,101,95,103,101,49,45,62,115,111,110,95,49,115,116,95,111,102,102,95,104,32,62,32,48,0,0,0,0,0,0,115,121,115,116,101,109,32,98,121,116,101,115,32,32,32,32,32,61,32,37,49,48,108,117,10,0,0,0,0,0,0,0,115,116,100,58,58,98,97,100,95,116,121,112,101,105,100,0,108,101,118,101,108,32,60,32,107,77,97,120,76,101,109,109,97,83,105,122,101,0,0,0,114,98,0,0,0,0,0,0,115,99,111,114,101,32,62,61,32,48,0,0,0,0,0,0,60,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,37,100,39,116,104,32,68,77,73,32,110,111,100,101,32,101,110,100,45,45,45,45,45,45,45,45,45,45,45,45,45,45,10,10,0,0,0,0,0,78,85,76,76,32,33,61,32,108,112,105,95,99,97,99,104,101,95,0,0,0,0,0,0,110,111,100,101,95,108,101,48,45,62,115,111,110,95,49,115,116,95,111,102,102,32,60,61,32,108,109,97,95,110,111,100,101,95,110,117,109,95,103,101,49,95,0,0,0,0,0,0,78,85,76,76,32,33,61,32,115,116,114,0,0,0,0,0,108,97,115,116,95,104,122,95,108,101,110,32,62,32,48,0,46,46,47,115,104,97,114,101,47,110,103,114,97,109,46,99,112,112,0,0,0,0,0,0,102,111,117,110,100,0,0,0,58,32,0,0,0,0,0,0,32,84,111,116,97,108,32,80,105,110,121,105,110,32,76,101,110,58,32,37,100,10,0,0,104,50,102,95,110,117,109,95,91,42,115,112,108,105,100,93,32,62,32,48,0,0,0,0,110,111,100,101,45,62,115,111,110,95,49,115,116,95,111,102,102,95,108,32,62,32,48,32,124,124,32,110,111,100,101,45,62,115,111,110,95,49,115,116,95,111,102,102,95,104,32,62,32,48,0,0,0,0,0,0,115,116,97,116,105,99,95,99,97,115,116,60,115,105,122,101,95,116,62,40,102,111,117,110,100,32,45,32,98,117,102,95,41,32,62,61,32,115,116,97,114,116,95,112,111,115,95,91,115,116,114,95,108,101,110,32,45,32,49,93,0,0,0,0,105,116,101,109,95,110,117,109,0,0,0,0,0,0,0,0,58,32,0,0,0,0,0,0,78,85,76,76,32,33,61,32,100,105,99,116,95,116,114,105,101,45,62,108,109,97,95,105,100,120,95,98,117,102,95,0,32,83,112,101,108,108,105,110,103,32,58,32,37,115,44,32,37,100,10,0,0,0,0,0,110,111,100,101,45,62,115,111,110,95,49,115,116,95,111,102,102,32,60,61,32,108,109,97,95,110,111,100,101,95,110,117,109,95,103,101,49,95,0,0,102,111,117,110,100,32,62,32,98,117,102,95,0,0,0,0,90,104,0,0,0,0,0,0,78,85,76,76,32,33,61,32,100,105,99,116,95,116,114,105,101,45,62,114,111,111,116,95,0,0,0,0,0,0,0,0,46,46,47,115,104,97,114,101,47,100,105,99,116,98,117,105,108,100,101,114,46,99,112,112,0,0,0,0,0,0,0,0,114,98,0,0,0,0,0,0,98,111,111,108,32,105,109,101,95,112,105,110,121,105,110,58,58,83,112,101,108,108,105,110,103,84,114,105,101,58,58,105,102,95,118,97,108,105,100,95,105,100,95,117,112,100,97,116,101,40,117,105,110,116,49,54,32,42,41,32,99,111,110,115,116,0,0,0,0,0,0,0,118,111,105,100,32,105,109,101,95,112,105,110,121,105,110,58,58,85,115,101,114,68,105,99,116,58,58,114,101,99,108,97,105,109,40,41,0,0,0,0,105,109,101,95,112,105,110,121,105,110,58,58,76,112,105,67,97,99,104,101,58,58,76,112,105,67,97,99,104,101,40,41,0,0,0,0,0,0,0,0,115,116,97,116,105,99,32,105,109,101,95,112,105,110,121,105,110,58,58,76,112,105,67,97,99,104,101,32,38,105,109,101,95,112,105,110,121,105,110,58,58,76,112,105,67,97,99,104,101,58,58,103,101,116,95,105,110,115,116,97,110,99,101,40,41,0,0,0,0,0,0,0,98,111,111,108,32,105,109,101,95,112,105,110,121,105,110,58,58,68,105,99,116,84,114,105,101,58,58,108,111,97,100,95,100,105,99,116,40,70,73,76,69,32,42,41,0,0,0,0,118,105,114,116,117,97,108,32,115,105,122,101,95,116,32,105,109,101,95,112,105,110,121,105,110,58,58,68,105,99,116,84,114,105,101,58,58,103,101,116,95,108,112,105,115,40,99,111,110,115,116,32,117,105,110,116,49,54,32,42,44,32,117,105,110,116,49,54,44,32,76,109,97,80,115,98,73,116,101,109,32,42,44,32,115,105,122,101,95,116,41,0,0,0,0,0,118,105,114,116,117,97,108,32,117,105,110,116,49,54,32,105,109,101,95,112,105,110,121,105,110,58,58,68,105,99,116,84,114,105,101,58,58,103,101,116,95,108,101,109,109,97,95,115,112,108,105,100,115,40,76,101,109,109,97,73,100,84,121,112,101,44,32,117,105,110,116,49,54,32,42,44,32,117,105,110,116,49,54,44,32,98,111,111,108,41,0,0,0,0,0,0,77,105,108,101,83,116,111,110,101,72,97,110,100,108,101,32,105,109,101,95,112,105,110,121,105,110,58,58,68,105,99,116,84,114,105,101,58,58,101,120,116,101,110,100,95,100,105,99,116,50,40,77,105,108,101,83,116,111,110,101,72,97,110,100,108,101,44,32,99,111,110,115,116,32,68,105,99,116,69,120,116,80,97,114,97,32,42,44,32,76,109,97,80,115,98,73,116,101,109,32,42,44,32,115,105,122,101,95,116,44,32,115,105,122,101,95,116,32,42,41,0,0,0,0,0,0,0,0,77,105,108,101,83,116,111,110,101,72,97,110,100,108,101,32,105,109,101,95,112,105,110,121,105,110,58,58,68,105,99,116,84,114,105,101,58,58,101,120,116,101,110,100,95,100,105,99,116,49,40,77,105,108,101,83,116,111,110,101,72,97,110,100,108,101,44,32,99,111,110,115,116,32,68,105,99,116,69,120,116,80,97,114,97,32,42,44,32,76,109,97,80,115,98,73,116,101,109,32,42,44,32,115,105,122,101,95,116,44,32,115,105,122,101,95,116,32,42,41,0,0,0,0,0,0,0,0,77,105,108,101,83,116,111,110,101,72,97,110,100,108,101,32,105,109,101,95,112,105,110,121,105,110,58,58,68,105,99,116,84,114,105,101,58,58,101,120,116,101,110,100,95,100,105,99,116,48,40,77,105,108,101,83,116,111,110,101,72,97,110,100,108,101,44,32,99,111,110,115,116,32,68,105,99,116,69,120,116,80,97,114,97,32,42,44,32,76,109,97,80,115,98,73,116,101,109,32,42,44,32,115,105,122,101,95,116,44,32,115,105,122,101,95,116,32,42,41,0,0,0,0,0,0,0,0,118,105,114,116,117,97,108,32,77,105,108,101,83,116,111,110,101,72,97,110,100,108,101,32,105,109,101,95,112,105,110,121,105,110,58,58,68,105,99,116,84,114,105,101,58,58,101,120,116,101,110,100,95,100,105,99,116,40,77,105,108,101,83,116,111,110,101,72,97,110,100,108,101,44,32,99,111,110,115,116,32,68,105,99,116,69,120,116,80,97,114,97,32,42,44,32,76,109,97,80,115,98,73,116,101,109,32,42,44,32,115,105,122,101,95,116,44,32,115,105,122,101,95,116,32,42,41,0,98,111,111,108,32,105,109,101,95,112,105,110,121,105,110,58,58,68,105,99,116,84,114,105,101,58,58,116,114,121,95,101,120,116,101,110,100,40,99,111,110,115,116,32,117,105,110,116,49,54,32,42,44,32,117,105,110,116,49,54,44,32,76,101,109,109,97,73,100,84,121,112,101,41,0,0,0,0,0,0,118,111,105,100,32,105,109,101,95,112,105,110,121,105,110,58,58,68,105,99,116,76,105,115,116,58,58,102,105,108,108,95,115,99,105,115,40,99,111,110,115,116,32,105,109,101,95,112,105,110,121,105,110,58,58,83,105,110,103,108,101,67,104,97,114,73,116,101,109,32,42,44,32,115,105,122,101,95,116,41,0,0,0,0,0,0,0,0,118,111,105,100,32,105,109,101,95,112,105,110,121,105,110,58,58,68,105,99,116,76,105,115,116,58,58,102,105,108,108,95,108,105,115,116,40,99,111,110,115,116,32,105,109,101,95,112,105,110,121,105,110,58,58,76,101,109,109,97,69,110,116,114,121,32,42,44,32,115,105,122,101,95,116,41,0,0,0,0,115,105,122,101,95,116,32,105,109,101,95,112,105,110,121,105,110,58,58,68,105,99,116,76,105,115,116,58,58,112,114,101,100,105,99,116,40,99,111,110,115,116,32,99,104,97,114,49,54,32,42,44,32,117,105,110,116,49,54,44,32,78,80,114,101,100,105,99,116,73,116,101,109,32,42,44,32,115,105,122,101,95,116,44,32,115,105,122,101,95,116,41,0,0,0,0,117,105,110,116,49,54,32,105,109,101,95,112,105,110,121,105,110,58,58,68,105,99,116,76,105,115,116,58,58,103,101,116,95,115,112,108,105,100,115,95,102,111,114,95,104,97,110,122,105,40,99,104,97,114,49,54,44,32,117,105,110,116,49,54,44,32,117,105,110,116,49,54,32,42,44,32,117,105,110,116,49,54,41,0,0,0,0,0,118,111,105,100,32,105,109,101,95,112,105,110,121,105,110,58,58,68,105,99,116,76,105,115,116,58,58,99,111,110,118,101,114,116,95,116,111,95,115,99,105,115,95,105,100,115,40,99,104,97,114,49,54,32,42,44,32,117,105,110,116,49,54,41,0,0,0,0,0,0,0,0,118,111,105,100,32,105,109,101,95,112,105,110,121,105,110,58,58,68,105,99,116,76,105,115,116,58,58,99,111,110,118,101,114,116,95,116,111,95,104,97,110,122,105,115,40,99,104,97,114,49,54,32,42,44,32,117,105,110,116,49,54,41,0,0,115,105,122,101,95,116,32,105,109,101,95,112,105,110,121,105,110,58,58,68,105,99,116,76,105,115,116,58,58,99,97,108,99,117,108,97,116,101,95,115,105,122,101,40,99,111,110,115,116,32,105,109,101,95,112,105,110,121,105,110,58,58,76,101,109,109,97,69,110,116,114,121,32,42,44,32,115,105,122,101,95,116,41,0,0,0,0,0,76,101,109,109,97,73,100,84,121,112,101,32,105,109,101,95,112,105,110,121,105,110,58,58,68,105,99,116,76,105,115,116,58,58,103,101,116,95,108,101,109,109,97,95,105,100,40,99,111,110,115,116,32,99,104,97,114,49,54,32,42,44,32,117,105,110,116,49,54,41,0,0,98,111,111,108,32,105,109,101,95,112,105,110,121,105,110,58,58,78,71,114,97,109,58,58,98,117,105,108,100,95,117,110,105,103,114,97,109,40,105,109,101,95,112,105,110,121,105,110,58,58,76,101,109,109,97,69,110,116,114,121,32,42,44,32,115,105,122,101,95,116,44,32,76,101,109,109,97,73,100,84,121,112,101,41,0,0,0,0,100,111,117,98,108,101,32,105,109,101,95,112,105,110,121,105,110,58,58,114,101,99,97,108,99,117,108,97,116,101,95,107,101,114,110,101,108,40,100,111,117,98,108,101,32,42,44,32,115,105,122,101,95,116,44,32,100,111,117,98,108,101,32,42,44,32,67,79,68,69,66,79,79,75,95,84,89,80,69,32,42,41,0,0,0,0,0,0,99,111,110,115,116,32,99,104,97,114,32,42,105,109,101,95,112,105,110,121,105,110,58,58,83,112,101,108,108,105,110,103,84,97,98,108,101,58,58,97,114,114,97,110,103,101,40,115,105,122,101,95,116,32,42,44,32,115,105,122,101,95,116,32,42,41,0,0,0,0,0,0,105,109,101,95,112,105,110,121,105,110,58,58,83,112,101,108,108,105,110,103,78,111,100,101,32,42,105,109,101,95,112,105,110,121,105,110,58,58,83,112,101,108,108,105,110,103,84,114,105,101,58,58,99,111,110,115,116,114,117,99,116,95,115,112,101,108,108,105,110,103,115,95,115,117,98,115,101,116,40,115,105,122,101,95,116,44,32,115,105,122,101,95,116,44,32,115,105,122,101,95,116,44,32,105,109,101,95,112,105,110,121,105,110,58,58,83,112,101,108,108,105,110,103,78,111,100,101,32,42,41,0,0,0,0,0,0,98,111,111,108,32,105,109,101,95,112,105,110,121,105,110,58,58,83,112,101,108,108,105,110,103,84,114,105,101,58,58,98,117,105,108,100,95,121,109,95,105,110,102,111,40,41,0,0,115,105,122,101,95,116,32,105,109,101,95,112,105,110,121,105,110,58,58,77,97,116,114,105,120,83,101,97,114,99,104,58,58,100,101,108,115,101,97,114,99,104,40,115,105,122,101,95,116,44,32,98,111,111,108,44,32,98,111,111,108,41,0,0,115,105,122,101,95,116,32,105,109,101,95,112,105,110,121,105,110,58,58,77,97,116,114,105,120,83,101,97,114,99,104,58,58,103,101,116,95,108,112,105,115,40,99,111,110,115,116,32,117,105,110,116,49,54,32,42,44,32,115,105,122,101,95,116,44,32,76,109,97,80,115,98,73,116,101,109,32,42,44,32,115,105,122,101,95,116,44,32,99,111,110,115,116,32,99,104,97,114,49,54,32,42,44,32,98,111,111,108,41,0,0,0,115,105,122,101,95,116,32,105,109,101,95,112,105,110,121,105,110,58,58,77,97,116,114,105,120,83,101,97,114,99,104,58,58,99,104,111,111,115,101,40,115,105,122,101,95,116,41,0,98,111,111,108,32,105,109,101,95,112,105,110,121,105,110,58,58,77,97,116,114,105,120,83,101,97,114,99,104,58,58,97,100,100,95,108,109,97,95,116,111,95,117,115,101,114,100,105,99,116,40,117,105,110,116,49,54,44,32,117,105,110,116,49,54,44,32,102,108,111,97,116,41,0,0,0,0,0,0,0,115,105,122,101,95,116,32,105,109,101,95,112,105,110,121,105,110,58,58,77,97,116,114,105,120,83,101,97,114,99,104,58,58,99,97,110,99,101,108,95,108,97,115,116,95,99,104,111,105,99,101,40,41,0,0,0,118,111,105,100,32,105,109,101,95,112,105,110,121,105,110,58,58,77,97,116,114,105,120,83,101,97,114,99,104,58,58,109,101,114,103,101,95,102,105,120,101,100,95,108,109,97,115,40,115,105,122,101,95,116,41,0,118,111,105,100,32,105,109,101,95,112,105,110,121,105,110,58,58,77,97,116,114,105,120,83,101,97,114,99,104,58,58,103,101,116,95,115,112,108,95,115,116,97,114,116,95,105,100,40,41,0,0,0,0,0,0,0,98,111,111,108,32,105,109,101,95,112,105,110,121,105,110,58,58,77,97,116,114,105,120,83,101,97,114,99,104,58,58,97,100,100,95,99,104,97,114,95,113,119,101,114,116,121,40,41,0,0,0,0,0,0,0,0,115,105,122,101,95,116,32,105,109,101,95,112,105,110,121,105,110,58,58,77,97,116,114,105,120,83,101,97,114,99,104,58,58,101,120,116,101,110,100,95,109,116,114,120,95,110,100,40,77,97,116,114,105,120,78,111,100,101,32,42,44,32,76,109,97,80,115,98,73,116,101,109,32,42,44,32,115,105,122,101,95,116,44,32,80,111,111,108,80,111,115,84,121,112,101,44,32,115,105,122,101,95,116,41,0,0,0,0,0,0,0,0,98,111,111,108,32,105,109,101,95,112,105,110,121,105,110,58,58,77,97,116,114,105,120,83,101,97,114,99,104,58,58,114,101,115,101,116,95,115,101,97,114,99,104,40,115,105,122,101,95,116,44,32,98,111,111,108,44,32,98,111,111,108,44,32,98,111,111,108,41,0,0,0,115,105,122,101,95,116,32,105,109,101,95,112,105,110,121,105,110,58,58,77,97,116,114,105,120,83,101,97,114,99,104,58,58,101,120,116,101,110,100,95,100,109,105,95,99,40,68,105,99,116,69,120,116,80,97,114,97,32,42,44,32,68,105,99,116,77,97,116,99,104,73,110,102,111,32,42,41,0,0,0,115,105,122,101,95,116,32,105,109,101,95,112,105,110,121,105,110,58,58,77,97,116,114,105,120,83,101,97,114,99,104,58,58,101,120,116,101,110,100,95,100,109,105,40,68,105,99,116,69,120,116,80,97,114,97,32,42,44,32,68,105,99,116,77,97,116,99,104,73,110,102,111,32,42,41,0,0,0,0,0,99,104,97,114,49,54,32,42,105,109,101,95,112,105,110,121,105,110,58,58,68,105,99,116,66,117,105,108,100,101,114,58,58,114,101,97,100,95,118,97,108,105,100,95,104,97,110,122,105,115,40,99,111,110,115,116,32,99,104,97,114,32,42,44,32,115,105,122,101,95,116,32,42,41,0,0,0,0,0,0,98,111,111,108,32,105,109,101,95,112,105,110,121,105,110,58,58,68,105,99,116,66,117,105,108,100,101,114,58,58,104,122,95,105,110,95,104,97,110,122,105,115,95,108,105,115,116,40,99,111,110,115,116,32,99,104,97,114,49,54,32,42,44,32,115,105,122,101,95,116,44,32,99,104,97,114,49,54,41,0,98,111,111,108,32,105,109,101,95,112,105,110,121,105,110,58,58,68,105,99,116,66,117,105,108,100,101,114,58,58,99,111,110,115,116,114,117,99,116,95,115,117,98,115,101,116,40,118,111,105,100,32,42,44,32,105,109,101,95,112,105,110,121,105,110,58,58,76,101,109,109,97,69,110,116,114,121,32,42,44,32,115,105,122,101,95,116,44,32,115,105,122,101,95,116,44,32,115,105,122,101,95,116,41,0,0,0,0,0,0,0,0,118,111,105,100,32,105,109,101,95,112,105,110,121,105,110,58,58,68,105,99,116,66,117,105,108,100,101,114,58,58,103,101,116,95,116,111,112,95,108,101,109,109,97,115,40,41,0,0,115,105,122,101,95,116,32,105,109,101,95,112,105,110,121,105,110,58,58,68,105,99,116,66,117,105,108,100,101,114,58,58,114,101,97,100,95,114,97,119,95,100,105,99,116,40,99,111,110,115,116,32,99,104,97,114,32,42,44,32,99,111,110,115,116,32,99,104,97,114,32,42,44,32,115,105,122,101,95,116,41,0,0,0,0,0,0,0,115,105,122,101,95,116,32,105,109,101,95,112,105,110,121,105,110,58,58,68,105,99,116,66,117,105,108,100,101,114,58,58,98,117,105,108,100,95,115,99,105,115,40,41,0,0,0,0,98,111,111,108,32,105,109,101,95,112,105,110,121,105,110,58,58,68,105,99,116,66,117,105,108,100,101,114,58,58,98,117,105,108,100,95,100,105,99,116,40,99,111,110,115,116,32,99,104,97,114,32,42,44,32,99,111,110,115,116,32,99,104,97,114,32,42,44,32,105,109,101,95,112,105,110,121,105,110,58,58,68,105,99,116,84,114,105,101,32,42,41,0,0,0,0,32,183,0,0,0,0,0,0,0,0,0,0,200,38,0,0,62,0,0,0,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,216,38,0,0,38,0,0,0,84,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,232,38,0,0,98,0,0,0,50,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,248,38,0,0,38,0,0,0,82,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,39,0,0,26,0,0,0,78,0,0,0,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,152,41,0,0,30,0,0,0,2,0,0,0,2,0,0,0,14,0,0,0,12,0,0,0,2,0,0,0,2,0,0,0,10,0,0,0,20,0,0,0,4,0,0,0,8,0,0,0,2,0,0,0,6,0,0,0,8,0,0,0,30,0,0,0,16,0,0,0,48,0,0,0,16,0,0,0,10,0,0,0,48,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,168,41,0,0,68,0,0,0,12,0,0,0,12,0,0,0,8,0,0,0,18,0,0,0,10,0,0,0,4,0,0,0,6,0,0,0,14,0,0,0,12,0,0,0,6,0,0,0,8,0,0,0,18,0,0,0,10,0,0,0,42,0,0,0,4,0,0,0,28,0,0,0,6,0,0,0,8,0,0,0,18,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,41,0,0,74,0,0,0,34,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,200,41,0,0,88,0,0,0,60,0,0,0,94,0,0,0,22,0,0,0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,216,41,0,0,88,0,0,0,24,0,0,0,94,0,0,0,22,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,232,41,0,0,88,0,0,0,106,0,0,0,94,0,0,0,22,0,0,0,10,0,0,0,4,0,0,0,4,0,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,42,0,0,88,0,0,0,46,0,0,0,94,0,0,0,22,0,0,0,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,40,42,0,0,88,0,0,0,70,0,0,0,94,0,0,0,22,0,0,0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,72,42,0,0,88,0,0,0,20,0,0,0,94,0,0,0,22,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,88,42,0,0,88,0,0,0,72,0,0,0,94,0,0,0,22,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,104,42,0,0,88,0,0,0,100,0,0,0,94,0,0,0,22,0,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,121,0,0,0,0,0,0,0,120,0,0,0,0,0,0,0,119,0,0,0,0,0,0,0,118,0,0,0,0,0,0,0,116,0,0,0,0,0,0,0,115,0,0,0,0,0,0,0,109,0,0,0,0,0,0,0,108,0,0,0,0,0,0,0,106,0,0,0,0,0,0,0,105,0,0,0,0,0,0,0,104,0,0,0,0,0,0,0,102,0,0,0,0,0,0,0,101,0,0,0,0,0,0,0,100,0,0,0,0,0,0,0,99,0,0,0,0,0,0,0,98,0,0,0,0,0,0,0,97,0,0,0,0,0,0,0,83,116,57,116,121,112,101,95,105,110,102,111,0,0,0,0,83,116,57,101,120,99,101,112,116,105,111,110,0,0,0,0,83,116,57,98,97,100,95,97,108,108,111,99,0,0,0,0,83,116,56,98,97,100,95,99,97,115,116,0,0,0,0,0,83,116,50,48,98,97,100,95,97,114,114,97,121,95,110,101,119,95,108,101,110,103,116,104,0,0,0,0,0,0,0,0,83,116,49,48,98,97,100,95,116,121,112,101,105,100,0,0,80,121,0,0,0,0,0,0,80,120,0,0,0,0,0,0,80,119,0,0,0,0,0,0,80,118,0,0,0,0,0,0,80,116,0,0,0,0,0,0,80,115,0,0,0,0,0,0,80,109,0,0,0,0,0,0,80,108,0,0,0,0,0,0,80,106,0,0,0,0,0,0,80,105,0,0,0,0,0,0,80,104,0,0,0,0,0,0,80,102,0,0,0,0,0,0,80,101,0,0,0,0,0,0,80,100,0,0,0,0,0,0,80,99,0,0,0,0,0,0,80,98,0,0,0,0,0,0,80,97,0,0,0,0,0,0,80,75,121,0,0,0,0,0,80,75,120,0,0,0,0,0,80,75,119,0,0,0,0,0,80,75,118,0,0,0,0,0,80,75,116,0,0,0,0,0,80,75,115,0,0,0,0,0,80,75,109,0,0,0,0,0,80,75,108,0,0,0,0,0,80,75,106,0,0,0,0,0,80,75,105,0,0,0,0,0,80,75,104,0,0,0,0,0,80,75,102,0,0,0,0,0,80,75,101,0,0,0,0,0,80,75,100,0,0,0,0,0,80,75,99,0,0,0,0,0,80,75,98,0,0,0,0,0,80,75,97,0,0,0,0,0,80,75,68,115,0,0,0,0,80,75,68,110,0,0,0,0,80,75,68,105,0,0,0,0,80,68,115,0,0,0,0,0,80,68,110,0,0,0,0,0,80,68,105,0,0,0,0,0,78,49,48,105,109,101,95,112,105,110,121,105,110,56,85,115,101,114,68,105,99,116,69,0,78,49,48,105,109,101,95,112,105,110,121,105,110,56,68,105,99,116,84,114,105,101,69,0,78,49,48,105,109,101,95,112,105,110,121,105,110,49,50,65,116,111,109,68,105,99,116,66,97,115,101,69,0,0,0,0,78,49,48,95,95,99,120,120,97,98,105,118,49,50,57,95,95,112,111,105,110,116,101,114,95,116,111,95,109,101,109,98,101,114,95,116,121,112,101,95,105,110,102,111,69,0,0,0,78,49,48,95,95,99,120,120,97,98,105,118,49,50,51,95,95,102,117,110,100,97,109,101,110,116,97,108,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,50,49,95,95,118,109,105,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,0,0,78,49,48,95,95,99,120,120,97,98,105,118,49,50,48,95,95,115,105,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,0,0,0,78,49,48,95,95,99,120,120,97,98,105,118,49,50,48,95,95,102,117,110,99,116,105,111,110,95,116,121,112,101,95,105,110,102,111,69,0,0,0,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,57,95,95,112,111,105,110,116,101,114,95,116,121,112,101,95,105,110,102,111,69,0,0,0,0,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,55,95,95,112,98,97,115,101,95,116,121,112,101,95,105,110,102,111,69,0,0,0,0,0,0,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,55,95,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,0,0,0,0,0,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,55,95,95,97,114,114,97,121,95,116,121,112,101,95,105,110,102,111,69,0,0,0,0,0,0,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,54,95,95,115,104,105,109,95,116,121,112,101,95,105,110,102,111,69,0,0,0,0,0,0,0,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,54,95,95,101,110,117,109,95,116,121,112,101,95,105,110,102,111,69,0,0,0,0,0,0,0,0,68,115,0,0,0,0,0,0,68,110,0,0,0,0,0,0,68,105,0,0,0,0,0,0,56,33,0,0,96,34,0,0,56,33,0,0,104,34,0,0,56,33,0,0,200,34,0,0,0,0,0,0,216,34,0,0,0,0,0,0,232,34,0,0,0,0,0,0,248,34,0,0,208,38,0,0,0,0,0,0,0,0,0,0,8,35,0,0,208,38,0,0,0,0,0,0,0,0,0,0,24,35,0,0,216,38,0,0,0,0,0,0,0,0,0,0,56,35,0,0,208,38,0,0,0,0,0,0,0,0,0,0,72,35,0,0,0,0,0,0,0,0,0,0,0,0,0,0,80,35,0,0,0,0,0,0,0,0,0,0,0,0,0,0,88,35,0,0,0,0,0,0,176,38,0,0,0,0,0,0,96,35,0,0,0,0,0,0,184,38,0,0,0,0,0,0,104,35,0,0,0,0,0,0,0,0,0,0,0,0,0,0,112,35,0,0,0,0,0,0,0,0,0,0,0,0,0,0,120,35,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,35,0,0,0,0,0,0,0,0,0,0,0,0,0,0,136,35,0,0,0,0,0,0,0,0,0,0,0,0,0,0,144,35,0,0,0,0,0,0,0,0,0,0,0,0,0,0,152,35,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,35,0,0,0,0,0,0,0,0,0,0,0,0,0,0,168,35,0,0,0,0,0,0,0,0,0,0,0,0,0,0,176,35,0,0,0,0,0,0,0,0,0,0,0,0,0,0,184,35,0,0,0,0,0,0,0,0,0,0].concat([0,0,0,0,192,35,0,0,0,0,0,0,192,38,0,0,0,0,0,0,200,35,0,0,0,0,0,0,0,0,0,0,0,0,0,0,208,35,0,0,1,0,0,0,0,0,0,0,0,0,0,0,216,35,0,0,1,0,0,0,0,0,0,0,0,0,0,0,224,35,0,0,1,0,0,0,176,38,0,0,0,0,0,0,232,35,0,0,1,0,0,0,184,38,0,0,0,0,0,0,240,35,0,0,1,0,0,0,0,0,0,0,0,0,0,0,248,35,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,36,0,0,1,0,0,0,0,0,0,0,0,0,0,0,8,36,0,0,1,0,0,0,0,0,0,0,0,0,0,0,16,36,0,0,1,0,0,0,0,0,0,0,0,0,0,0,24,36,0,0,1,0,0,0,0,0,0,0,0,0,0,0,32,36,0,0,1,0,0,0,0,0,0,0,0,0,0,0,40,36,0,0,1,0,0,0,0,0,0,0,0,0,0,0,48,36,0,0,1,0,0,0,0,0,0,0,0,0,0,0,56,36,0,0,1,0,0,0,0,0,0,0,0,0,0,0,64,36,0,0,1,0,0,0,0,0,0,0,0,0,0,0,72,36,0,0,1,0,0,0,192,38,0,0,0,0,0,0,80,36,0,0,1,0,0,0,0,0,0,0,0,0,0,0,88,36,0,0,1,0,0,0,120,42,0,0,0,0,0,0,96,36,0,0,1,0,0,0,128,42,0,0,0,0,0,0,104,36,0,0,1,0,0,0,136,42,0,0,0,0,0,0,112,36,0,0,0,0,0,0,120,42,0,0,0,0,0,0,120,36,0,0,0,0,0,0,128,42,0,0,0,0,0,0,128,36,0,0,0,0,0,0,136,42,0,0,0,0,0,0,136,36,0,0,192,41,0,0,0,0,0,0,96,33,0,0,160,36,0,0,0,0,0,0,1,0,0,0,192,41,0,0,0,0,0,0,0,0,0,0,184,36,0,0,0,0,0,0,216,36,0,0,40,42,0,0,0,0,0,0,0,0,0,0,8,37,0,0,88,42,0,0,0,0,0,0,0,0,0,0,48,37,0,0,56,42,0,0,0,0,0,0,0,0,0,0,88,37,0,0,56,42,0,0,0,0,0,0,0,0,0,0,128,37,0,0,88,42,0,0,0,0,0,0,0,0,0,0,168,37,0,0,40,42,0,0,0,0,0,0,0,0,0,0,208,37,0,0,88,42,0,0,0,0,0,0,0,0,0,0,248,37,0,0,88,42,0,0,0,0,0,0,0,0,0,0,32,38,0,0,88,42,0,0,0,0,0,0,0,0,0,0,72,38,0,0,200,38,0,0,0,0,0,0,0,0,0,0,112,38,0,0,88,42,0,0,0,0,0,0,56,33,0,0,152,38,0,0,56,33,0,0,160,38,0,0,56,33,0,0,168,38,0,0,72,77,0,0,0,0,0,72,78,71,0,0,0,0,78,71,0,0,0,0,0,0,0,0,48,65,66,67,99,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,115,84,85,86,87,88,89,90,122,0,0,2,1,1,1,2,1,1,1,0,1,1,1,1,1,2,1,1,1,1,1,0,0,1,1,1,1,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,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,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,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,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,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,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0,128,48,0,0,128,32,14,0,128,32,200,3,128,32,8,250,128,32,8,130,0,0,192,224,240,248,252,0]) , "i8", ALLOC_NONE, Runtime.GLOBAL_BASE) var tempDoublePtr = Runtime.alignMemory(allocate(12, "i8", ALLOC_STATIC), 8); assert(tempDoublePtr % 8 == 0); function copyTempFloat(ptr) { // functions, because inlining this code increases code size too much HEAP8[tempDoublePtr] = HEAP8[ptr]; HEAP8[tempDoublePtr+1] = HEAP8[ptr+1]; HEAP8[tempDoublePtr+2] = HEAP8[ptr+2]; HEAP8[tempDoublePtr+3] = HEAP8[ptr+3]; } function copyTempDouble(ptr) { HEAP8[tempDoublePtr] = HEAP8[ptr]; HEAP8[tempDoublePtr+1] = HEAP8[ptr+1]; HEAP8[tempDoublePtr+2] = HEAP8[ptr+2]; HEAP8[tempDoublePtr+3] = HEAP8[ptr+3]; HEAP8[tempDoublePtr+4] = HEAP8[ptr+4]; HEAP8[tempDoublePtr+5] = HEAP8[ptr+5]; HEAP8[tempDoublePtr+6] = HEAP8[ptr+6]; HEAP8[tempDoublePtr+7] = HEAP8[ptr+7]; } function ___gxx_personality_v0() { } Module["_strcpy"] = _strcpy; function _llvm_umul_with_overflow_i32(x, y) { x = x>>>0; y = y>>>0; return ((asm["setTempRet0"](x*y > 4294967295),(x*y)>>>0)|0); } Module["_memset"] = _memset;var _llvm_memset_p0i8_i32=_memset; var ERRNO_CODES={EPERM:1,ENOENT:2,ESRCH:3,EINTR:4,EIO:5,ENXIO:6,E2BIG:7,ENOEXEC:8,EBADF:9,ECHILD:10,EAGAIN:11,EWOULDBLOCK:11,ENOMEM:12,EACCES:13,EFAULT:14,ENOTBLK:15,EBUSY:16,EEXIST:17,EXDEV:18,ENODEV:19,ENOTDIR:20,EISDIR:21,EINVAL:22,ENFILE:23,EMFILE:24,ENOTTY:25,ETXTBSY:26,EFBIG:27,ENOSPC:28,ESPIPE:29,EROFS:30,EMLINK:31,EPIPE:32,EDOM:33,ERANGE:34,ENOMSG:35,EIDRM:36,ECHRNG:37,EL2NSYNC:38,EL3HLT:39,EL3RST:40,ELNRNG:41,EUNATCH:42,ENOCSI:43,EL2HLT:44,EDEADLK:45,ENOLCK:46,EBADE:50,EBADR:51,EXFULL:52,ENOANO:53,EBADRQC:54,EBADSLT:55,EDEADLOCK:56,EBFONT:57,ENOSTR:60,ENODATA:61,ETIME:62,ENOSR:63,ENONET:64,ENOPKG:65,EREMOTE:66,ENOLINK:67,EADV:68,ESRMNT:69,ECOMM:70,EPROTO:71,EMULTIHOP:74,ELBIN:75,EDOTDOT:76,EBADMSG:77,EFTYPE:79,ENOTUNIQ:80,EBADFD:81,EREMCHG:82,ELIBACC:83,ELIBBAD:84,ELIBSCN:85,ELIBMAX:86,ELIBEXEC:87,ENOSYS:88,ENMFILE:89,ENOTEMPTY:90,ENAMETOOLONG:91,ELOOP:92,EOPNOTSUPP:95,EPFNOSUPPORT:96,ECONNRESET:104,ENOBUFS:105,EAFNOSUPPORT:106,EPROTOTYPE:107,ENOTSOCK:108,ENOPROTOOPT:109,ESHUTDOWN:110,ECONNREFUSED:111,EADDRINUSE:112,ECONNABORTED:113,ENETUNREACH:114,ENETDOWN:115,ETIMEDOUT:116,EHOSTDOWN:117,EHOSTUNREACH:118,EINPROGRESS:119,EALREADY:120,EDESTADDRREQ:121,EMSGSIZE:122,EPROTONOSUPPORT:123,ESOCKTNOSUPPORT:124,EADDRNOTAVAIL:125,ENETRESET:126,EISCONN:127,ENOTCONN:128,ETOOMANYREFS:129,EPROCLIM:130,EUSERS:131,EDQUOT:132,ESTALE:133,ENOTSUP:134,ENOMEDIUM:135,ENOSHARE:136,ECASECLASH:137,EILSEQ:138,EOVERFLOW:139,ECANCELED:140,ENOTRECOVERABLE:141,EOWNERDEAD:142,ESTRPIPE:143}; var ___errno_state=0;function ___setErrNo(value) { // For convenient setting and returning of errno. HEAP32[((___errno_state)>>2)]=value return value; } var _stdin=allocate(1, "i32*", ALLOC_STATIC); var _stdout=allocate(1, "i32*", ALLOC_STATIC); var _stderr=allocate(1, "i32*", ALLOC_STATIC); var __impure_ptr=allocate(1, "i32*", ALLOC_STATIC);var FS={currentPath:"/",nextInode:2,streams:[null],ignorePermissions:true,createFileHandle:function (stream, fd) { if (typeof stream === 'undefined') { stream = null; } if (!fd) { if (stream && stream.socket) { for (var i = 1; i < 64; i++) { if (!FS.streams[i]) { fd = i; break; } } assert(fd, 'ran out of low fds for sockets'); } else { fd = Math.max(FS.streams.length, 64); for (var i = FS.streams.length; i < fd; i++) { FS.streams[i] = null; // Keep dense } } } // Close WebSocket first if we are about to replace the fd (i.e. dup2) if (FS.streams[fd] && FS.streams[fd].socket && FS.streams[fd].socket.close) { FS.streams[fd].socket.close(); } FS.streams[fd] = stream; return fd; },removeFileHandle:function (fd) { FS.streams[fd] = null; },joinPath:function (parts, forceRelative) { var ret = parts[0]; for (var i = 1; i < parts.length; i++) { if (ret[ret.length-1] != '/') ret += '/'; ret += parts[i]; } if (forceRelative && ret[0] == '/') ret = ret.substr(1); return ret; },absolutePath:function (relative, base) { if (typeof relative !== 'string') return null; if (base === undefined) base = FS.currentPath; if (relative && relative[0] == '/') base = ''; var full = base + '/' + relative; var parts = full.split('/').reverse(); var absolute = ['']; while (parts.length) { var part = parts.pop(); if (part == '' || part == '.') { // Nothing. } else if (part == '..') { if (absolute.length > 1) absolute.pop(); } else { absolute.push(part); } } return absolute.length == 1 ? '/' : absolute.join('/'); },analyzePath:function (path, dontResolveLastLink, linksVisited) { var ret = { isRoot: false, exists: false, error: 0, name: null, path: null, object: null, parentExists: false, parentPath: null, parentObject: null }; path = FS.absolutePath(path); if (path == '/') { ret.isRoot = true; ret.exists = ret.parentExists = true; ret.name = '/'; ret.path = ret.parentPath = '/'; ret.object = ret.parentObject = FS.root; } else if (path !== null) { linksVisited = linksVisited || 0; path = path.slice(1).split('/'); var current = FS.root; var traversed = ['']; while (path.length) { if (path.length == 1 && current.isFolder) { ret.parentExists = true; ret.parentPath = traversed.length == 1 ? '/' : traversed.join('/'); ret.parentObject = current; ret.name = path[0]; } var target = path.shift(); if (!current.isFolder) { ret.error = ERRNO_CODES.ENOTDIR; break; } else if (!current.read) { ret.error = ERRNO_CODES.EACCES; break; } else if (!current.contents.hasOwnProperty(target)) { ret.error = ERRNO_CODES.ENOENT; break; } current = current.contents[target]; if (current.link && !(dontResolveLastLink && path.length == 0)) { if (linksVisited > 40) { // Usual Linux SYMLOOP_MAX. ret.error = ERRNO_CODES.ELOOP; break; } var link = FS.absolutePath(current.link, traversed.join('/')); ret = FS.analyzePath([link].concat(path).join('/'), dontResolveLastLink, linksVisited + 1); return ret; } traversed.push(target); if (path.length == 0) { ret.exists = true; ret.path = traversed.join('/'); ret.object = current; } } } return ret; },findObject:function (path, dontResolveLastLink) { var ret = FS.analyzePath(path, dontResolveLastLink); if (ret.exists) { return ret.object; } else { ___setErrNo(ret.error); return null; } },createObject:function (parent, name, properties, canRead, canWrite) { if (!parent) parent = '/'; if (typeof parent === 'string') parent = FS.findObject(parent); if (!parent) { ___setErrNo(ERRNO_CODES.EACCES); throw new Error('Parent path must exist.'); } if (!parent.isFolder) { ___setErrNo(ERRNO_CODES.ENOTDIR); throw new Error('Parent must be a folder.'); } if (!parent.write && !FS.ignorePermissions) { ___setErrNo(ERRNO_CODES.EACCES); throw new Error('Parent folder must be writeable.'); } if (!name || name == '.' || name == '..') { ___setErrNo(ERRNO_CODES.ENOENT); throw new Error('Name must not be empty.'); } if (parent.contents.hasOwnProperty(name)) { ___setErrNo(ERRNO_CODES.EEXIST); throw new Error("Can't overwrite object."); } parent.contents[name] = { read: canRead === undefined ? true : canRead, write: canWrite === undefined ? false : canWrite, timestamp: Date.now(), inodeNumber: FS.nextInode++ }; for (var key in properties) { if (properties.hasOwnProperty(key)) { parent.contents[name][key] = properties[key]; } } return parent.contents[name]; },createFolder:function (parent, name, canRead, canWrite) { var properties = {isFolder: true, isDevice: false, contents: {}}; return FS.createObject(parent, name, properties, canRead, canWrite); },createPath:function (parent, path, canRead, canWrite) { var current = FS.findObject(parent); if (current === null) throw new Error('Invalid parent.'); path = path.split('/').reverse(); while (path.length) { var part = path.pop(); if (!part) continue; if (!current.contents.hasOwnProperty(part)) { FS.createFolder(current, part, canRead, canWrite); } current = current.contents[part]; } return current; },createFile:function (parent, name, properties, canRead, canWrite) { properties.isFolder = false; return FS.createObject(parent, name, properties, canRead, canWrite); },createDataFile:function (parent, name, data, canRead, canWrite) { if (typeof data === 'string') { var dataArray = new Array(data.length); for (var i = 0, len = data.length; i < len; ++i) dataArray[i] = data.charCodeAt(i); data = dataArray; } var properties = { isDevice: false, contents: data.subarray ? data.subarray(0) : data // as an optimization, create a new array wrapper (not buffer) here, to help JS engines understand this object }; return FS.createFile(parent, name, properties, canRead, canWrite); },createLazyFile:function (parent, name, url, canRead, canWrite) { if (typeof XMLHttpRequest !== 'undefined') { if (!ENVIRONMENT_IS_WORKER) throw 'Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc'; // Lazy chunked Uint8Array (implements get and length from Uint8Array). Actual getting is abstracted away for eventual reuse. var LazyUint8Array = function() { this.lengthKnown = false; this.chunks = []; // Loaded chunks. Index is the chunk number } LazyUint8Array.prototype.get = function(idx) { if (idx > this.length-1 || idx < 0) { return undefined; } var chunkOffset = idx % this.chunkSize; var chunkNum = Math.floor(idx / this.chunkSize); return this.getter(chunkNum)[chunkOffset]; } LazyUint8Array.prototype.setDataGetter = function(getter) { this.getter = getter; } LazyUint8Array.prototype.cacheLength = function() { // Find length var xhr = new XMLHttpRequest(); xhr.open('HEAD', url, false); xhr.send(null); if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status); var datalength = Number(xhr.getResponseHeader("Content-length")); var header; var hasByteServing = (header = xhr.getResponseHeader("Accept-Ranges")) && header === "bytes"; var chunkSize = 1024*1024; // Chunk size in bytes if (!hasByteServing) chunkSize = datalength; // Function to get a range from the remote URL. var doXHR = (function(from, to) { if (from > to) throw new Error("invalid range (" + from + ", " + to + ") or no bytes requested!"); if (to > datalength-1) throw new Error("only " + datalength + " bytes available! programmer error!"); // TODO: Use mozResponseArrayBuffer, responseStream, etc. if available. var xhr = new XMLHttpRequest(); xhr.open('GET', url, false); if (datalength !== chunkSize) xhr.setRequestHeader("Range", "bytes=" + from + "-" + to); // Some hints to the browser that we want binary data. if (typeof Uint8Array != 'undefined') xhr.responseType = 'arraybuffer'; if (xhr.overrideMimeType) { xhr.overrideMimeType('text/plain; charset=x-user-defined'); } xhr.send(null); if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status); if (xhr.response !== undefined) { return new Uint8Array(xhr.response || []); } else { return intArrayFromString(xhr.responseText || '', true); } }); var lazyArray = this; lazyArray.setDataGetter(function(chunkNum) { var start = chunkNum * chunkSize; var end = (chunkNum+1) * chunkSize - 1; // including this byte end = Math.min(end, datalength-1); // if datalength-1 is selected, this is the last block if (typeof(lazyArray.chunks[chunkNum]) === "undefined") { lazyArray.chunks[chunkNum] = doXHR(start, end); } if (typeof(lazyArray.chunks[chunkNum]) === "undefined") throw new Error("doXHR failed!"); return lazyArray.chunks[chunkNum]; }); this._length = datalength; this._chunkSize = chunkSize; this.lengthKnown = true; } var lazyArray = new LazyUint8Array(); Object.defineProperty(lazyArray, "length", { get: function() { if(!this.lengthKnown) { this.cacheLength(); } return this._length; } }); Object.defineProperty(lazyArray, "chunkSize", { get: function() { if(!this.lengthKnown) { this.cacheLength(); } return this._chunkSize; } }); var properties = { isDevice: false, contents: lazyArray }; } else { var properties = { isDevice: false, url: url }; } return FS.createFile(parent, name, properties, canRead, canWrite); },createPreloadedFile:function (parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile) { Browser.init(); var fullname = FS.joinPath([parent, name], true); function processData(byteArray) { function finish(byteArray) { if (!dontCreateFile) { FS.createDataFile(parent, name, byteArray, canRead, canWrite); } if (onload) onload(); removeRunDependency('cp ' + fullname); } var handled = false; Module['preloadPlugins'].forEach(function(plugin) { if (handled) return; if (plugin['canHandle'](fullname)) { plugin['handle'](byteArray, fullname, finish, function() { if (onerror) onerror(); removeRunDependency('cp ' + fullname); }); handled = true; } }); if (!handled) finish(byteArray); } addRunDependency('cp ' + fullname); if (typeof url == 'string') { Browser.asyncLoad(url, function(byteArray) { processData(byteArray); }, onerror); } else { processData(url); } },createLink:function (parent, name, target, canRead, canWrite) { var properties = {isDevice: false, link: target}; return FS.createFile(parent, name, properties, canRead, canWrite); },createDevice:function (parent, name, input, output) { if (!(input || output)) { throw new Error('A device must have at least one callback defined.'); } var ops = {isDevice: true, input: input, output: output}; return FS.createFile(parent, name, ops, Boolean(input), Boolean(output)); },forceLoadFile:function (obj) { if (obj.isDevice || obj.isFolder || obj.link || obj.contents) return true; var success = true; if (typeof XMLHttpRequest !== 'undefined') { throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread."); } else if (Module['read']) { // Command-line. try { // WARNING: Can't read binary files in V8's d8 or tracemonkey's js, as // read() will try to parse UTF8. obj.contents = intArrayFromString(Module['read'](obj.url), true); } catch (e) { success = false; } } else { throw new Error('Cannot load without read() or XMLHttpRequest.'); } if (!success) ___setErrNo(ERRNO_CODES.EIO); return success; },staticInit:function () { // The main file system tree. All the contents are inside this. FS.root = { read: true, write: true, isFolder: true, isDevice: false, timestamp: Date.now(), inodeNumber: 1, contents: {} }; // Create the temporary folder, if not already created try { FS.createFolder('/', 'tmp', true, true); } catch(e) {} FS.createFolder('/', 'dev', true, true); },init:function (input, output, error) { // Make sure we initialize only once. assert(!FS.init.initialized, 'FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)'); FS.init.initialized = true; // Allow Module.stdin etc. to provide defaults, if none explicitly passed to us here input = input || Module['stdin']; output = output || Module['stdout']; error = error || Module['stderr']; // Default handlers. var stdinOverridden = true, stdoutOverridden = true, stderrOverridden = true; if (!input) { stdinOverridden = false; input = function() { if (!input.cache || !input.cache.length) { var result; if (typeof window != 'undefined' && typeof window.prompt == 'function') { // Browser. result = window.prompt('Input: '); if (result === null) result = String.fromCharCode(0); // cancel ==> EOF } else if (typeof readline == 'function') { // Command line. result = readline(); } if (!result) result = ''; input.cache = intArrayFromString(result + '\n', true); } return input.cache.shift(); }; } var utf8 = new Runtime.UTF8Processor(); function createSimpleOutput() { var fn = function (val) { if (val === null || val === 10) { fn.printer(fn.buffer.join('')); fn.buffer = []; } else { fn.buffer.push(utf8.processCChar(val)); } }; return fn; } if (!output) { stdoutOverridden = false; output = createSimpleOutput(); } if (!output.printer) output.printer = Module['print']; if (!output.buffer) output.buffer = []; if (!error) { stderrOverridden = false; error = createSimpleOutput(); } if (!error.printer) error.printer = Module['printErr']; if (!error.buffer) error.buffer = []; // Create the I/O devices. var stdin = FS.createDevice('/dev', 'stdin', input); stdin.isTerminal = !stdinOverridden; var stdout = FS.createDevice('/dev', 'stdout', null, output); stdout.isTerminal = !stdoutOverridden; var stderr = FS.createDevice('/dev', 'stderr', null, error); stderr.isTerminal = !stderrOverridden; FS.createDevice('/dev', 'tty', input, output); FS.createDevice('/dev', 'null', function(){}, function(){}); // Create default streams. FS.streams[1] = { path: '/dev/stdin', object: stdin, position: 0, isRead: true, isWrite: false, isAppend: false, error: false, eof: false, ungotten: [] }; FS.streams[2] = { path: '/dev/stdout', object: stdout, position: 0, isRead: false, isWrite: true, isAppend: false, error: false, eof: false, ungotten: [] }; FS.streams[3] = { path: '/dev/stderr', object: stderr, position: 0, isRead: false, isWrite: true, isAppend: false, error: false, eof: false, ungotten: [] }; // TODO: put these low in memory like we used to assert on: assert(Math.max(_stdin, _stdout, _stderr) < 15000); // make sure these are low, we flatten arrays with these HEAP32[((_stdin)>>2)]=1; HEAP32[((_stdout)>>2)]=2; HEAP32[((_stderr)>>2)]=3; // Other system paths FS.createPath('/', 'dev/shm/tmp', true, true); // temp files // Newlib initialization for (var i = FS.streams.length; i < Math.max(_stdin, _stdout, _stderr) + 4; i++) { FS.streams[i] = null; // Make sure to keep FS.streams dense } FS.streams[_stdin] = FS.streams[1]; FS.streams[_stdout] = FS.streams[2]; FS.streams[_stderr] = FS.streams[3]; allocate([ allocate( [0, 0, 0, 0, _stdin, 0, 0, 0, _stdout, 0, 0, 0, _stderr, 0, 0, 0], 'void*', ALLOC_NORMAL) ], 'void*', ALLOC_NONE, __impure_ptr); },quit:function () { if (!FS.init.initialized) return; // Flush any partially-printed lines in stdout and stderr. Careful, they may have been closed if (FS.streams[2] && FS.streams[2].object.output.buffer.length > 0) FS.streams[2].object.output(10); if (FS.streams[3] && FS.streams[3].object.output.buffer.length > 0) FS.streams[3].object.output(10); },standardizePath:function (path) { if (path.substr(0, 2) == './') path = path.substr(2); return path; },deleteFile:function (path) { path = FS.analyzePath(path); if (!path.parentExists || !path.exists) { throw 'Invalid path ' + path; } delete path.parentObject.contents[path.name]; }}; Module['FS'] = FS; var ___dirent_struct_layout={__size__:1040,d_ino:0,d_name:4,d_off:1028,d_reclen:1032,d_type:1036};function _open(path, oflag, varargs) { // int open(const char *path, int oflag, ...); // http://pubs.opengroup.org/onlinepubs/009695399/functions/open.html // NOTE: This implementation tries to mimic glibc rather than strictly // following the POSIX standard. var mode = HEAP32[((varargs)>>2)]; // Simplify flags. var accessMode = oflag & 3; var isWrite = accessMode != 0; var isRead = accessMode != 1; var isCreate = Boolean(oflag & 512); var isExistCheck = Boolean(oflag & 2048); var isTruncate = Boolean(oflag & 1024); var isAppend = Boolean(oflag & 8); // Verify path. var origPath = path; path = FS.analyzePath(Pointer_stringify(path)); if (!path.parentExists) { ___setErrNo(path.error); return -1; } var target = path.object || null; var finalPath; // Verify the file exists, create if needed and allowed. if (target) { if (isCreate && isExistCheck) { ___setErrNo(ERRNO_CODES.EEXIST); return -1; } if ((isWrite || isTruncate) && target.isFolder) { ___setErrNo(ERRNO_CODES.EISDIR); return -1; } if (isRead && !target.read || isWrite && !target.write) { ___setErrNo(ERRNO_CODES.EACCES); return -1; } if (isTruncate && !target.isDevice) { target.contents = []; } else { if (!FS.forceLoadFile(target)) { ___setErrNo(ERRNO_CODES.EIO); return -1; } } finalPath = path.path; } else { if (!isCreate) { ___setErrNo(ERRNO_CODES.ENOENT); return -1; } if (!path.parentObject.write) { ___setErrNo(ERRNO_CODES.EACCES); return -1; } target = FS.createDataFile(path.parentObject, path.name, [], mode & 0x100, mode & 0x80); // S_IRUSR, S_IWUSR. finalPath = path.parentPath + '/' + path.name; } // Actually create an open stream. var id; if (target.isFolder) { var entryBuffer = 0; if (___dirent_struct_layout) { entryBuffer = _malloc(___dirent_struct_layout.__size__); } var contents = []; for (var key in target.contents) contents.push(key); id = FS.createFileHandle({ path: finalPath, object: target, // An index into contents. Special values: -2 is ".", -1 is "..". position: -2, isRead: true, isWrite: false, isAppend: false, error: false, eof: false, ungotten: [], // Folder-specific properties: // Remember the contents at the time of opening in an array, so we can // seek between them relying on a single order. contents: contents, // Each stream has its own area for readdir() returns. currentEntry: entryBuffer }); } else { id = FS.createFileHandle({ path: finalPath, object: target, position: 0, isRead: isRead, isWrite: isWrite, isAppend: isAppend, error: false, eof: false, ungotten: [] }); } return id; }function _fopen(filename, mode) { // FILE *fopen(const char *restrict filename, const char *restrict mode); // http://pubs.opengroup.org/onlinepubs/000095399/functions/fopen.html var flags; mode = Pointer_stringify(mode); if (mode[0] == 'r') { if (mode.indexOf('+') != -1) { flags = 2; } else { flags = 0; } } else if (mode[0] == 'w') { if (mode.indexOf('+') != -1) { flags = 2; } else { flags = 1; } flags |= 512; flags |= 1024; } else if (mode[0] == 'a') { if (mode.indexOf('+') != -1) { flags = 2; } else { flags = 1; } flags |= 512; flags |= 8; } else { ___setErrNo(ERRNO_CODES.EINVAL); return 0; } var ret = _open(filename, flags, allocate([0x1FF, 0, 0, 0], 'i32', ALLOC_STACK)); // All creation permissions. return (ret == -1) ? 0 : ret; } function _recv(fd, buf, len, flags) { var info = FS.streams[fd]; if (!info) return -1; if (!info.hasData()) { ___setErrNo(ERRNO_CODES.EAGAIN); // no data, and all sockets are nonblocking, so this is the right behavior return -1; } var buffer = info.inQueue.shift(); if (len < buffer.length) { if (info.stream) { // This is tcp (reliable), so if not all was read, keep it info.inQueue.unshift(buffer.subarray(len)); } buffer = buffer.subarray(0, len); } HEAPU8.set(buffer, buf); return buffer.length; } function _pread(fildes, buf, nbyte, offset) { // ssize_t pread(int fildes, void *buf, size_t nbyte, off_t offset); // http://pubs.opengroup.org/onlinepubs/000095399/functions/read.html var stream = FS.streams[fildes]; if (!stream || stream.object.isDevice) { ___setErrNo(ERRNO_CODES.EBADF); return -1; } else if (!stream.isRead) { ___setErrNo(ERRNO_CODES.EACCES); return -1; } else if (stream.object.isFolder) { ___setErrNo(ERRNO_CODES.EISDIR); return -1; } else if (nbyte < 0 || offset < 0) { ___setErrNo(ERRNO_CODES.EINVAL); return -1; } else if (offset >= stream.object.contents.length) { return 0; } else { var bytesRead = 0; var contents = stream.object.contents; var size = Math.min(contents.length - offset, nbyte); assert(size >= 0); if (contents.subarray) { // typed array HEAPU8.set(contents.subarray(offset, offset+size), buf); } else if (contents.slice) { // normal array for (var i = 0; i < size; i++) { HEAP8[(((buf)+(i))|0)]=contents[offset + i] } } else { for (var i = 0; i < size; i++) { // LazyUint8Array from sync binary XHR HEAP8[(((buf)+(i))|0)]=contents.get(offset + i) } } bytesRead += size; return bytesRead; } }function _read(fildes, buf, nbyte) { // ssize_t read(int fildes, void *buf, size_t nbyte); // http://pubs.opengroup.org/onlinepubs/000095399/functions/read.html var stream = FS.streams[fildes]; if (stream && ('socket' in stream)) { return _recv(fildes, buf, nbyte, 0); } else if (!stream) { ___setErrNo(ERRNO_CODES.EBADF); return -1; } else if (!stream.isRead) { ___setErrNo(ERRNO_CODES.EACCES); return -1; } else if (nbyte < 0) { ___setErrNo(ERRNO_CODES.EINVAL); return -1; } else { var bytesRead; if (stream.object.isDevice) { if (stream.object.input) { bytesRead = 0; for (var i = 0; i < nbyte; i++) { try { var result = stream.object.input(); } catch (e) { ___setErrNo(ERRNO_CODES.EIO); return -1; } if (result === undefined && bytesRead === 0) { ___setErrNo(ERRNO_CODES.EAGAIN); return -1; } if (result === null || result === undefined) break; bytesRead++; HEAP8[(((buf)+(i))|0)]=result } return bytesRead; } else { ___setErrNo(ERRNO_CODES.ENXIO); return -1; } } else { bytesRead = _pread(fildes, buf, nbyte, stream.position); assert(bytesRead >= -1); if (bytesRead != -1) { stream.position += bytesRead; } return bytesRead; } } }function _fread(ptr, size, nitems, stream) { // size_t fread(void *restrict ptr, size_t size, size_t nitems, FILE *restrict stream); // http://pubs.opengroup.org/onlinepubs/000095399/functions/fread.html var bytesToRead = nitems * size; if (bytesToRead == 0) { return 0; } var bytesRead = 0; var streamObj = FS.streams[stream]; while (streamObj.ungotten.length && bytesToRead > 0) { HEAP8[((ptr++)|0)]=streamObj.ungotten.pop() bytesToRead--; bytesRead++; } var err = _read(stream, ptr, bytesToRead); if (err == -1) { if (streamObj) streamObj.error = true; return 0; } bytesRead += err; if (bytesRead < bytesToRead) streamObj.eof = true; return Math.floor(bytesRead / size); } function _close(fildes) { // int close(int fildes); // http://pubs.opengroup.org/onlinepubs/000095399/functions/close.html if (FS.streams[fildes]) { if (FS.streams[fildes].currentEntry) { _free(FS.streams[fildes].currentEntry); } FS.streams[fildes] = null; return 0; } else { ___setErrNo(ERRNO_CODES.EBADF); return -1; } } function _fsync(fildes) { // int fsync(int fildes); // http://pubs.opengroup.org/onlinepubs/000095399/functions/fsync.html if (FS.streams[fildes]) { // We write directly to the file system, so there's nothing to do here. return 0; } else { ___setErrNo(ERRNO_CODES.EBADF); return -1; } }function _fclose(stream) { // int fclose(FILE *stream); // http://pubs.opengroup.org/onlinepubs/000095399/functions/fclose.html _fsync(stream); return _close(stream); } function _lseek(fildes, offset, whence) { // off_t lseek(int fildes, off_t offset, int whence); // http://pubs.opengroup.org/onlinepubs/000095399/functions/lseek.html if (FS.streams[fildes] && !FS.streams[fildes].object.isDevice) { var stream = FS.streams[fildes]; var position = offset; if (whence === 1) { // SEEK_CUR. position += stream.position; } else if (whence === 2) { // SEEK_END. position += stream.object.contents.length; } if (position < 0) { ___setErrNo(ERRNO_CODES.EINVAL); return -1; } else { stream.ungotten = []; stream.position = position; return position; } } else { ___setErrNo(ERRNO_CODES.EBADF); return -1; } }function _fseek(stream, offset, whence) { // int fseek(FILE *stream, long offset, int whence); // http://pubs.opengroup.org/onlinepubs/000095399/functions/fseek.html var ret = _lseek(stream, offset, whence); if (ret == -1) { return -1; } else { FS.streams[stream].eof = false; return 0; } } function _ftell(stream) { // long ftell(FILE *stream); // http://pubs.opengroup.org/onlinepubs/000095399/functions/ftell.html if (FS.streams[stream]) { stream = FS.streams[stream]; if (stream.object.isDevice) { ___setErrNo(ERRNO_CODES.ESPIPE); return -1; } else { return stream.position; } } else { ___setErrNo(ERRNO_CODES.EBADF); return -1; } } function ___assert_func(filename, line, func, condition) { throw 'Assertion failed: ' + (condition ? Pointer_stringify(condition) : 'unknown condition') + ', at: ' + [filename ? Pointer_stringify(filename) : 'unknown filename', line, func ? Pointer_stringify(func) : 'unknown function'] + ' at ' + new Error().stack; } Module["_memcpy"] = _memcpy;var _llvm_memcpy_p0i8_p0i8_i32=_memcpy; function __exit(status) { // void _exit(int status); // http://pubs.opengroup.org/onlinepubs/000095399/functions/exit.html Module['exit'](status); }function _exit(status) { __exit(status); }function __ZSt9terminatev() { _exit(-1234); } Module["_strlen"] = _strlen; function _send(fd, buf, len, flags) { var info = FS.streams[fd]; if (!info) return -1; info.sender(HEAPU8.subarray(buf, buf+len)); return len; } function _pwrite(fildes, buf, nbyte, offset) { // ssize_t pwrite(int fildes, const void *buf, size_t nbyte, off_t offset); // http://pubs.opengroup.org/onlinepubs/000095399/functions/write.html var stream = FS.streams[fildes]; if (!stream || stream.object.isDevice) { ___setErrNo(ERRNO_CODES.EBADF); return -1; } else if (!stream.isWrite) { ___setErrNo(ERRNO_CODES.EACCES); return -1; } else if (stream.object.isFolder) { ___setErrNo(ERRNO_CODES.EISDIR); return -1; } else if (nbyte < 0 || offset < 0) { ___setErrNo(ERRNO_CODES.EINVAL); return -1; } else { var contents = stream.object.contents; while (contents.length < offset) contents.push(0); for (var i = 0; i < nbyte; i++) { contents[offset + i] = HEAPU8[(((buf)+(i))|0)]; } stream.object.timestamp = Date.now(); return i; } }function _write(fildes, buf, nbyte) { // ssize_t write(int fildes, const void *buf, size_t nbyte); // http://pubs.opengroup.org/onlinepubs/000095399/functions/write.html var stream = FS.streams[fildes]; if (stream && ('socket' in stream)) { return _send(fildes, buf, nbyte, 0); } else if (!stream) { ___setErrNo(ERRNO_CODES.EBADF); return -1; } else if (!stream.isWrite) { ___setErrNo(ERRNO_CODES.EACCES); return -1; } else if (nbyte < 0) { ___setErrNo(ERRNO_CODES.EINVAL); return -1; } else { if (stream.object.isDevice) { if (stream.object.output) { for (var i = 0; i < nbyte; i++) { try { stream.object.output(HEAP8[(((buf)+(i))|0)]); } catch (e) { ___setErrNo(ERRNO_CODES.EIO); return -1; } } stream.object.timestamp = Date.now(); return i; } else { ___setErrNo(ERRNO_CODES.ENXIO); return -1; } } else { var bytesWritten = _pwrite(fildes, buf, nbyte, stream.position); if (bytesWritten != -1) stream.position += bytesWritten; return bytesWritten; } } }function _fwrite(ptr, size, nitems, stream) { // size_t fwrite(const void *restrict ptr, size_t size, size_t nitems, FILE *restrict stream); // http://pubs.opengroup.org/onlinepubs/000095399/functions/fwrite.html var bytesToWrite = nitems * size; if (bytesToWrite == 0) return 0; var bytesWritten = _write(stream, ptr, bytesToWrite); if (bytesWritten == -1) { if (FS.streams[stream]) FS.streams[stream].error = true; return 0; } else { return Math.floor(bytesWritten / size); } } function __reallyNegative(x) { return x < 0 || (x === 0 && (1/x) === -Infinity); }function __formatString(format, varargs) { var textIndex = format; var argIndex = 0; function getNextArg(type) { // NOTE: Explicitly ignoring type safety. Otherwise this fails: // int x = 4; printf("%c\n", (char)x); var ret; if (type === 'double') { ret = HEAPF64[(((varargs)+(argIndex))>>3)]; } else if (type == 'i64') { ret = [HEAP32[(((varargs)+(argIndex))>>2)], HEAP32[(((varargs)+(argIndex+8))>>2)]]; argIndex += 8; // each 32-bit chunk is in a 64-bit block } else { type = 'i32'; // varargs are always i32, i64, or double ret = HEAP32[(((varargs)+(argIndex))>>2)]; } argIndex += Math.max(Runtime.getNativeFieldSize(type), Runtime.getAlignSize(type, null, true)); return ret; } var ret = []; var curr, next, currArg; while(1) { var startTextIndex = textIndex; curr = HEAP8[(textIndex)]; if (curr === 0) break; next = HEAP8[((textIndex+1)|0)]; if (curr == 37) { // Handle flags. var flagAlwaysSigned = false; var flagLeftAlign = false; var flagAlternative = false; var flagZeroPad = false; flagsLoop: while (1) { switch (next) { case 43: flagAlwaysSigned = true; break; case 45: flagLeftAlign = true; break; case 35: flagAlternative = true; break; case 48: if (flagZeroPad) { break flagsLoop; } else { flagZeroPad = true; break; } default: break flagsLoop; } textIndex++; next = HEAP8[((textIndex+1)|0)]; } // Handle width. var width = 0; if (next == 42) { width = getNextArg('i32'); textIndex++; next = HEAP8[((textIndex+1)|0)]; } else { while (next >= 48 && next <= 57) { width = width * 10 + (next - 48); textIndex++; next = HEAP8[((textIndex+1)|0)]; } } // Handle precision. var precisionSet = false; if (next == 46) { var precision = 0; precisionSet = true; textIndex++; next = HEAP8[((textIndex+1)|0)]; if (next == 42) { precision = getNextArg('i32'); textIndex++; } else { while(1) { var precisionChr = HEAP8[((textIndex+1)|0)]; if (precisionChr < 48 || precisionChr > 57) break; precision = precision * 10 + (precisionChr - 48); textIndex++; } } next = HEAP8[((textIndex+1)|0)]; } else { var precision = 6; // Standard default. } // Handle integer sizes. WARNING: These assume a 32-bit architecture! var argSize; switch (String.fromCharCode(next)) { case 'h': var nextNext = HEAP8[((textIndex+2)|0)]; if (nextNext == 104) { textIndex++; argSize = 1; // char (actually i32 in varargs) } else { argSize = 2; // short (actually i32 in varargs) } break; case 'l': var nextNext = HEAP8[((textIndex+2)|0)]; if (nextNext == 108) { textIndex++; argSize = 8; // long long } else { argSize = 4; // long } break; case 'L': // long long case 'q': // int64_t case 'j': // intmax_t argSize = 8; break; case 'z': // size_t case 't': // ptrdiff_t case 'I': // signed ptrdiff_t or unsigned size_t argSize = 4; break; default: argSize = null; } if (argSize) textIndex++; next = HEAP8[((textIndex+1)|0)]; // Handle type specifier. switch (String.fromCharCode(next)) { case 'd': case 'i': case 'u': case 'o': case 'x': case 'X': case 'p': { // Integer. var signed = next == 100 || next == 105; argSize = argSize || 4; var currArg = getNextArg('i' + (argSize * 8)); var origArg = currArg; var argText; // Flatten i64-1 [low, high] into a (slightly rounded) double if (argSize == 8) { currArg = Runtime.makeBigInt(currArg[0], currArg[1], next == 117); } // Truncate to requested size. if (argSize <= 4) { var limit = Math.pow(256, argSize) - 1; currArg = (signed ? reSign : unSign)(currArg & limit, argSize * 8); } // Format the number. var currAbsArg = Math.abs(currArg); var prefix = ''; if (next == 100 || next == 105) { if (argSize == 8 && i64Math) argText = i64Math.stringify(origArg[0], origArg[1], null); else argText = reSign(currArg, 8 * argSize, 1).toString(10); } else if (next == 117) { if (argSize == 8 && i64Math) argText = i64Math.stringify(origArg[0], origArg[1], true); else argText = unSign(currArg, 8 * argSize, 1).toString(10); currArg = Math.abs(currArg); } else if (next == 111) { argText = (flagAlternative ? '0' : '') + currAbsArg.toString(8); } else if (next == 120 || next == 88) { prefix = (flagAlternative && currArg != 0) ? '0x' : ''; if (argSize == 8 && i64Math) { if (origArg[1]) { argText = (origArg[1]>>>0).toString(16); var lower = (origArg[0]>>>0).toString(16); while (lower.length < 8) lower = '0' + lower; argText += lower; } else { argText = (origArg[0]>>>0).toString(16); } } else if (currArg < 0) { // Represent negative numbers in hex as 2's complement. currArg = -currArg; argText = (currAbsArg - 1).toString(16); var buffer = []; for (var i = 0; i < argText.length; i++) { buffer.push((0xF - parseInt(argText[i], 16)).toString(16)); } argText = buffer.join(''); while (argText.length < argSize * 2) argText = 'f' + argText; } else { argText = currAbsArg.toString(16); } if (next == 88) { prefix = prefix.toUpperCase(); argText = argText.toUpperCase(); } } else if (next == 112) { if (currAbsArg === 0) { argText = '(nil)'; } else { prefix = '0x'; argText = currAbsArg.toString(16); } } if (precisionSet) { while (argText.length < precision) { argText = '0' + argText; } } // Add sign if needed if (flagAlwaysSigned) { if (currArg < 0) { prefix = '-' + prefix; } else { prefix = '+' + prefix; } } // Add padding. while (prefix.length + argText.length < width) { if (flagLeftAlign) { argText += ' '; } else { if (flagZeroPad) { argText = '0' + argText; } else { prefix = ' ' + prefix; } } } // Insert the result into the buffer. argText = prefix + argText; argText.split('').forEach(function(chr) { ret.push(chr.charCodeAt(0)); }); break; } case 'f': case 'F': case 'e': case 'E': case 'g': case 'G': { // Float. var currArg = getNextArg('double'); var argText; if (isNaN(currArg)) { argText = 'nan'; flagZeroPad = false; } else if (!isFinite(currArg)) { argText = (currArg < 0 ? '-' : '') + 'inf'; flagZeroPad = false; } else { var isGeneral = false; var effectivePrecision = Math.min(precision, 20); // Convert g/G to f/F or e/E, as per: // http://pubs.opengroup.org/onlinepubs/9699919799/functions/printf.html if (next == 103 || next == 71) { isGeneral = true; precision = precision || 1; var exponent = parseInt(currArg.toExponential(effectivePrecision).split('e')[1], 10); if (precision > exponent && exponent >= -4) { next = ((next == 103) ? 'f' : 'F').charCodeAt(0); precision -= exponent + 1; } else { next = ((next == 103) ? 'e' : 'E').charCodeAt(0); precision--; } effectivePrecision = Math.min(precision, 20); } if (next == 101 || next == 69) { argText = currArg.toExponential(effectivePrecision); // Make sure the exponent has at least 2 digits. if (/[eE][-+]\d$/.test(argText)) { argText = argText.slice(0, -1) + '0' + argText.slice(-1); } } else if (next == 102 || next == 70) { argText = currArg.toFixed(effectivePrecision); if (currArg === 0 && __reallyNegative(currArg)) { argText = '-' + argText; } } var parts = argText.split('e'); if (isGeneral && !flagAlternative) { // Discard trailing zeros and periods. while (parts[0].length > 1 && parts[0].indexOf('.') != -1 && (parts[0].slice(-1) == '0' || parts[0].slice(-1) == '.')) { parts[0] = parts[0].slice(0, -1); } } else { // Make sure we have a period in alternative mode. if (flagAlternative && argText.indexOf('.') == -1) parts[0] += '.'; // Zero pad until required precision. while (precision > effectivePrecision++) parts[0] += '0'; } argText = parts[0] + (parts.length > 1 ? 'e' + parts[1] : ''); // Capitalize 'E' if needed. if (next == 69) argText = argText.toUpperCase(); // Add sign. if (flagAlwaysSigned && currArg >= 0) { argText = '+' + argText; } } // Add padding. while (argText.length < width) { if (flagLeftAlign) { argText += ' '; } else { if (flagZeroPad && (argText[0] == '-' || argText[0] == '+')) { argText = argText[0] + '0' + argText.slice(1); } else { argText = (flagZeroPad ? '0' : ' ') + argText; } } } // Adjust case. if (next < 97) argText = argText.toUpperCase(); // Insert the result into the buffer. argText.split('').forEach(function(chr) { ret.push(chr.charCodeAt(0)); }); break; } case 's': { // String. var arg = getNextArg('i8*'); var argLength = arg ? _strlen(arg) : '(null)'.length; if (precisionSet) argLength = Math.min(argLength, precision); if (!flagLeftAlign) { while (argLength < width--) { ret.push(32); } } if (arg) { for (var i = 0; i < argLength; i++) { ret.push(HEAPU8[((arg++)|0)]); } } else { ret = ret.concat(intArrayFromString('(null)'.substr(0, argLength), true)); } if (flagLeftAlign) { while (argLength < width--) { ret.push(32); } } break; } case 'c': { // Character. if (flagLeftAlign) ret.push(getNextArg('i8')); while (--width > 0) { ret.push(32); } if (!flagLeftAlign) ret.push(getNextArg('i8')); break; } case 'n': { // Write the length written so far to the next parameter. var ptr = getNextArg('i32*'); HEAP32[((ptr)>>2)]=ret.length break; } case '%': { // Literal percent sign. ret.push(curr); break; } default: { // Unknown specifiers remain untouched. for (var i = startTextIndex; i < textIndex + 2; i++) { ret.push(HEAP8[(i)]); } } } textIndex += 2; // TODO: Support a/A (hex float) and m (last error) specifiers. // TODO: Support %1${specifier} for arg selection. } else { ret.push(curr); textIndex += 1; } } return ret; }function _fprintf(stream, format, varargs) { // int fprintf(FILE *restrict stream, const char *restrict format, ...); // http://pubs.opengroup.org/onlinepubs/000095399/functions/printf.html var result = __formatString(format, varargs); var stack = Runtime.stackSave(); var ret = _fwrite(allocate(result, 'i8', ALLOC_STACK), 1, result.length, stream); Runtime.stackRestore(stack); return ret; }function _printf(format, varargs) { // int printf(const char *restrict format, ...); // http://pubs.opengroup.org/onlinepubs/000095399/functions/printf.html var stdout = HEAP32[((_stdout)>>2)]; return _fprintf(stdout, format, varargs); } var _llvm_memset_p0i8_i64=_memset; function _fputs(s, stream) { // int fputs(const char *restrict s, FILE *restrict stream); // http://pubs.opengroup.org/onlinepubs/000095399/functions/fputs.html return _write(stream, s, _strlen(s)); } function _fputc(c, stream) { // int fputc(int c, FILE *stream); // http://pubs.opengroup.org/onlinepubs/000095399/functions/fputc.html var chr = unSign(c & 0xFF); HEAP8[((_fputc.ret)|0)]=chr var ret = _write(stream, _fputc.ret, 1); if (ret == -1) { if (FS.streams[stream]) FS.streams[stream].error = true; return -1; } else { return chr; } }function _puts(s) { // int puts(const char *s); // http://pubs.opengroup.org/onlinepubs/000095399/functions/puts.html // NOTE: puts() always writes an extra newline. var stdout = HEAP32[((_stdout)>>2)]; var ret = _fputs(s, stdout); if (ret < 0) { return ret; } else { var newlineRet = _fputc(10, stdout); return (newlineRet < 0) ? -1 : ret + 1; } } function _putchar(c) { // int putchar(int c); // http://pubs.opengroup.org/onlinepubs/000095399/functions/putchar.html return _fputc(c, HEAP32[((_stdout)>>2)]); } function _fdopen(fildes, mode) { // FILE *fdopen(int fildes, const char *mode); // http://pubs.opengroup.org/onlinepubs/000095399/functions/fdopen.html if (FS.streams[fildes]) { var stream = FS.streams[fildes]; mode = Pointer_stringify(mode); if ((mode.indexOf('w') != -1 && !stream.isWrite) || (mode.indexOf('r') != -1 && !stream.isRead) || (mode.indexOf('a') != -1 && !stream.isAppend) || (mode.indexOf('+') != -1 && (!stream.isRead || !stream.isWrite))) { ___setErrNo(ERRNO_CODES.EINVAL); return 0; } else { stream.error = false; stream.eof = false; return fildes; } } else { ___setErrNo(ERRNO_CODES.EBADF); return 0; } } function ___cxa_pure_virtual() { ABORT = true; throw 'Pure virtual function called!'; } function _qsort2(base, num, size, cmp) { // forward calls to the JavaScript sort method // first, sort the items logically var keys = []; for (var i = 0; i < num; i++) { keys.push(HEAP32[(base + i * size) >> 2]); } keys.sort(function(a, b) { return a - b; }); // apply the sort for (var i = 0; i < num; i++) { HEAP32[(base+i*size >> 2)] = keys[i]; } } function _qsort(base, num, size, cmp) { if (num == 0 || size == 0) return; // forward calls to the JavaScript sort method // first, sort the items logically var keys = []; for (var i = 0; i < num; i++) keys.push(i); keys.sort(function(a, b) { return Module['dynCall_iii'](cmp, base+a*size, base+b*size); }); // apply the sort var temp = _malloc(num*size); _memcpy(temp, base, num*size); for (var i = 0; i < num; i++) { if (keys[i] == i) continue; // already in place _memcpy(base+i*size, temp+keys[i]*size, size); } _free(temp); } var _fabs=Math.abs; var _log=Math.log; function _strncmp(px, py, n) { var i = 0; while (i < n) { var x = HEAPU8[(((px)+(i))|0)]; var y = HEAPU8[(((py)+(i))|0)]; if (x == y && x == 0) return 0; if (x == 0) return -1; if (y == 0) return 1; if (x == y) { i ++; continue; } else { return x > y ? 1 : -1; } } return 0; }function _strcmp(px, py) { return _strncmp(px, py, TOTAL_MEMORY); } function _snprintf(s, n, format, varargs) { // int snprintf(char *restrict s, size_t n, const char *restrict format, ...); // http://pubs.opengroup.org/onlinepubs/000095399/functions/printf.html var result = __formatString(format, varargs); var limit = (n === undefined) ? result.length : Math.min(result.length, Math.max(n - 1, 0)); if (s < 0) { s = -s; var buf = _malloc(limit+1); HEAP32[((s)>>2)]=buf; s = buf; } for (var i = 0; i < limit; i++) { HEAP8[(((s)+(i))|0)]=result[i]; } if (limit < n || (n === undefined)) HEAP8[(((s)+(i))|0)]=0; return result.length; } function _strdup(ptr) { var len = _strlen(ptr); var newStr = _malloc(len + 1); (_memcpy(newStr, ptr, len)|0); HEAP8[(((newStr)+(len))|0)]=0; return newStr; } function _bsearch(key, base, num, size, compar) { var cmp = function(x, y) { return Module['dynCall_iii'](compar, x, y); }; var left = 0; var right = num; var mid, test, addr; while (left < right) { mid = (left + right) >>> 1; addr = base + (mid * size); test = cmp(key, addr); if (test < 0) { right = mid; } else if (test > 0) { left = mid + 1; } else { return addr; } } return 0; } var _sqrt=Math.sqrt; Module["_strncpy"] = _strncpy; function _gettimeofday(ptr) { // %struct.timeval = type { i32, i32 } var now = Date.now(); HEAP32[((ptr)>>2)]=Math.floor(now/1000); // seconds HEAP32[(((ptr)+(4))>>2)]=Math.floor((now-1000*Math.floor(now/1000))*1000); // microseconds return 0; } Module["_memcmp"] = _memcmp; function _unlink(path) { // int unlink(const char *path); // http://pubs.opengroup.org/onlinepubs/000095399/functions/unlink.html path = Pointer_stringify(path); path = FS.analyzePath(path, true); if (!path.parentExists || !path.exists) { ___setErrNo(path.error); return -1; } else if (path.object.isFolder) { ___setErrNo(ERRNO_CODES.EPERM); return -1; } else if (!path.parentObject.write) { ___setErrNo(ERRNO_CODES.EACCES); return -1; } else { delete path.parentObject.contents[path.name]; return 0; } } function _ferror(stream) { // int ferror(FILE *stream); // http://pubs.opengroup.org/onlinepubs/000095399/functions/ferror.html return Number(FS.streams[stream] && FS.streams[stream].error); } function _feof(stream) { // int feof(FILE *stream); // http://pubs.opengroup.org/onlinepubs/000095399/functions/feof.html return Number(FS.streams[stream] && FS.streams[stream].eof); } function _truncate(path, length) { // int truncate(const char *path, off_t length); // http://pubs.opengroup.org/onlinepubs/000095399/functions/truncate.html // NOTE: The path argument may be a string, to simplify ftruncate(). if (length < 0) { ___setErrNo(ERRNO_CODES.EINVAL); return -1; } else { if (typeof path !== 'string') path = Pointer_stringify(path); var target = FS.findObject(path); if (target === null) return -1; if (target.isFolder) { ___setErrNo(ERRNO_CODES.EISDIR); return -1; } else if (target.isDevice) { ___setErrNo(ERRNO_CODES.EINVAL); return -1; } else if (!target.write) { ___setErrNo(ERRNO_CODES.EACCES); return -1; } else { var contents = target.contents; if (length < contents.length) contents.length = length; else while (length > contents.length) contents.push(0); target.timestamp = Date.now(); return 0; } } }function _ftruncate(fildes, length) { // int ftruncate(int fildes, off_t length); // http://pubs.opengroup.org/onlinepubs/000095399/functions/ftruncate.html if (FS.streams[fildes] && FS.streams[fildes].isWrite) { return _truncate(FS.streams[fildes].path, length); } else if (FS.streams[fildes]) { ___setErrNo(ERRNO_CODES.EINVAL); return -1; } else { ___setErrNo(ERRNO_CODES.EBADF); return -1; } } Module["_memmove"] = _memmove;var _llvm_memmove_p0i8_p0i8_i32=_memmove; function _time(ptr) { var ret = Math.floor(Date.now()/1000); if (ptr) { HEAP32[((ptr)>>2)]=ret } return ret; } function _abort() { Module['abort'](); } function ___errno_location() { return ___errno_state; }var ___errno=___errno_location; function _sysconf(name) { // long sysconf(int name); // http://pubs.opengroup.org/onlinepubs/009695399/functions/sysconf.html switch(name) { case 8: return PAGE_SIZE; case 54: case 56: case 21: case 61: case 63: case 22: case 67: case 23: case 24: case 25: case 26: case 27: case 69: case 28: case 101: case 70: case 71: case 29: case 30: case 199: case 75: case 76: case 32: case 43: case 44: case 80: case 46: case 47: case 45: case 48: case 49: case 42: case 82: case 33: case 7: case 108: case 109: case 107: case 112: case 119: case 121: return 200809; case 13: case 104: case 94: case 95: case 34: case 35: case 77: case 81: case 83: case 84: case 85: case 86: case 87: case 88: case 89: case 90: case 91: case 94: case 95: case 110: case 111: case 113: case 114: case 115: case 116: case 117: case 118: case 120: case 40: case 16: case 79: case 19: return -1; case 92: case 93: case 5: case 72: case 6: case 74: case 92: case 93: case 96: case 97: case 98: case 99: case 102: case 103: case 105: return 1; case 38: case 66: case 50: case 51: case 4: return 1024; case 15: case 64: case 41: return 32; case 55: case 37: case 17: return 2147483647; case 18: case 1: return 47839; case 59: case 57: return 99; case 68: case 58: return 2048; case 0: return 2097152; case 3: return 65536; case 14: return 32768; case 73: return 32767; case 39: return 16384; case 60: return 1000; case 106: return 700; case 52: return 256; case 62: return 255; case 2: return 100; case 65: return 64; case 36: return 20; case 100: return 16; case 20: return 6; case 53: return 4; case 10: return 1; } ___setErrNo(ERRNO_CODES.EINVAL); return -1; } function _sbrk(bytes) { // Implement a Linux-like 'memory area' for our 'process'. // Changes the size of the memory area by |bytes|; returns the // address of the previous top ('break') of the memory area // We control the "dynamic" memory - DYNAMIC_BASE to DYNAMICTOP var self = _sbrk; if (!self.called) { DYNAMICTOP = alignMemoryPage(DYNAMICTOP); // make sure we start out aligned self.called = true; assert(Runtime.dynamicAlloc); self.alloc = Runtime.dynamicAlloc; Runtime.dynamicAlloc = function() { abort('cannot dynamically allocate, sbrk now has control') }; } var ret = DYNAMICTOP; if (bytes != 0) self.alloc(bytes); return ret; // Previous break location. } function ___cxa_allocate_exception(size) { return _malloc(size); } function _llvm_eh_exception() { return HEAP32[((_llvm_eh_exception.buf)>>2)]; } function __ZSt18uncaught_exceptionv() { // std::uncaught_exception() return !!__ZSt18uncaught_exceptionv.uncaught_exception; } function ___cxa_is_number_type(type) { var isNumber = false; try { if (type == __ZTIi) isNumber = true } catch(e){} try { if (type == __ZTIj) isNumber = true } catch(e){} try { if (type == __ZTIl) isNumber = true } catch(e){} try { if (type == __ZTIm) isNumber = true } catch(e){} try { if (type == __ZTIx) isNumber = true } catch(e){} try { if (type == __ZTIy) isNumber = true } catch(e){} try { if (type == __ZTIf) isNumber = true } catch(e){} try { if (type == __ZTId) isNumber = true } catch(e){} try { if (type == __ZTIe) isNumber = true } catch(e){} try { if (type == __ZTIc) isNumber = true } catch(e){} try { if (type == __ZTIa) isNumber = true } catch(e){} try { if (type == __ZTIh) isNumber = true } catch(e){} try { if (type == __ZTIs) isNumber = true } catch(e){} try { if (type == __ZTIt) isNumber = true } catch(e){} return isNumber; }function ___cxa_does_inherit(definiteType, possibilityType, possibility) { if (possibility == 0) return false; if (possibilityType == 0 || possibilityType == definiteType) return true; var possibility_type_info; if (___cxa_is_number_type(possibilityType)) { possibility_type_info = possibilityType; } else { var possibility_type_infoAddr = HEAP32[((possibilityType)>>2)] - 8; possibility_type_info = HEAP32[((possibility_type_infoAddr)>>2)]; } switch (possibility_type_info) { case 0: // possibility is a pointer // See if definite type is a pointer var definite_type_infoAddr = HEAP32[((definiteType)>>2)] - 8; var definite_type_info = HEAP32[((definite_type_infoAddr)>>2)]; if (definite_type_info == 0) { // Also a pointer; compare base types of pointers var defPointerBaseAddr = definiteType+8; var defPointerBaseType = HEAP32[((defPointerBaseAddr)>>2)]; var possPointerBaseAddr = possibilityType+8; var possPointerBaseType = HEAP32[((possPointerBaseAddr)>>2)]; return ___cxa_does_inherit(defPointerBaseType, possPointerBaseType, possibility); } else return false; // one pointer and one non-pointer case 1: // class with no base class return false; case 2: // class with base class var parentTypeAddr = possibilityType + 8; var parentType = HEAP32[((parentTypeAddr)>>2)]; return ___cxa_does_inherit(definiteType, parentType, possibility); default: return false; // some unencountered type } } function ___resumeException(ptr) { if (HEAP32[((_llvm_eh_exception.buf)>>2)] == 0) HEAP32[((_llvm_eh_exception.buf)>>2)]=ptr; throw ptr + " - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch.";; }function ___cxa_find_matching_catch(thrown, throwntype) { if (thrown == -1) thrown = HEAP32[((_llvm_eh_exception.buf)>>2)]; if (throwntype == -1) throwntype = HEAP32[(((_llvm_eh_exception.buf)+(4))>>2)]; var typeArray = Array.prototype.slice.call(arguments, 2); // If throwntype is a pointer, this means a pointer has been // thrown. When a pointer is thrown, actually what's thrown // is a pointer to the pointer. We'll dereference it. if (throwntype != 0 && !___cxa_is_number_type(throwntype)) { var throwntypeInfoAddr= HEAP32[((throwntype)>>2)] - 8; var throwntypeInfo= HEAP32[((throwntypeInfoAddr)>>2)]; if (throwntypeInfo == 0) thrown = HEAP32[((thrown)>>2)]; } // The different catch blocks are denoted by different types. // Due to inheritance, those types may not precisely match the // type of the thrown object. Find one which matches, and // return the type of the catch block which should be called. for (var i = 0; i < typeArray.length; i++) { if (___cxa_does_inherit(typeArray[i], throwntype, thrown)) return ((asm["setTempRet0"](typeArray[i]),thrown)|0); } // Shouldn't happen unless we have bogus data in typeArray // or encounter a type for which emscripten doesn't have suitable // typeinfo defined. Best-efforts match just in case. return ((asm["setTempRet0"](throwntype),thrown)|0); }function ___cxa_throw(ptr, type, destructor) { if (!___cxa_throw.initialized) { try { HEAP32[((__ZTVN10__cxxabiv119__pointer_type_infoE)>>2)]=0; // Workaround for libcxxabi integration bug } catch(e){} try { HEAP32[((__ZTVN10__cxxabiv117__class_type_infoE)>>2)]=1; // Workaround for libcxxabi integration bug } catch(e){} try { HEAP32[((__ZTVN10__cxxabiv120__si_class_type_infoE)>>2)]=2; // Workaround for libcxxabi integration bug } catch(e){} ___cxa_throw.initialized = true; } HEAP32[((_llvm_eh_exception.buf)>>2)]=ptr HEAP32[(((_llvm_eh_exception.buf)+(4))>>2)]=type HEAP32[(((_llvm_eh_exception.buf)+(8))>>2)]=destructor if (!("uncaught_exception" in __ZSt18uncaught_exceptionv)) { __ZSt18uncaught_exceptionv.uncaught_exception = 1; } else { __ZSt18uncaught_exceptionv.uncaught_exception++; } throw ptr + " - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch.";; } function ___cxa_call_unexpected(exception) { Module.printErr('Unexpected exception thrown, this is not properly supported - aborting'); ABORT = true; throw exception; } function ___cxa_begin_catch(ptr) { __ZSt18uncaught_exceptionv.uncaught_exception--; return ptr; } function ___cxa_free_exception(ptr) { try { return _free(ptr); } catch(e) { // XXX FIXME } }function ___cxa_end_catch() { if (___cxa_end_catch.rethrown) { ___cxa_end_catch.rethrown = false; return; } // Clear state flag. asm['setThrew'](0); // Clear type. HEAP32[(((_llvm_eh_exception.buf)+(4))>>2)]=0 // Call destructor if one is registered then clear it. var ptr = HEAP32[((_llvm_eh_exception.buf)>>2)]; var destructor = HEAP32[(((_llvm_eh_exception.buf)+(8))>>2)]; if (destructor) { Runtime.dynCall('vi', destructor, [ptr]); HEAP32[(((_llvm_eh_exception.buf)+(8))>>2)]=0 } // Free ptr if it isn't null. if (ptr) { ___cxa_free_exception(ptr); HEAP32[((_llvm_eh_exception.buf)>>2)]=0 } } var _environ=allocate(1, "i32*", ALLOC_STATIC);var ___environ=_environ;function ___buildEnvironment(env) { // WARNING: Arbitrary limit! var MAX_ENV_VALUES = 64; var TOTAL_ENV_SIZE = 1024; // Statically allocate memory for the environment. var poolPtr; var envPtr; if (!___buildEnvironment.called) { ___buildEnvironment.called = true; // Set default values. Use string keys for Closure Compiler compatibility. ENV['USER'] = 'root'; ENV['PATH'] = '/'; ENV['PWD'] = '/'; ENV['HOME'] = '/home/emscripten'; ENV['LANG'] = 'en_US.UTF-8'; ENV['_'] = './this.program'; // Allocate memory. poolPtr = allocate(TOTAL_ENV_SIZE, 'i8', ALLOC_STATIC); envPtr = allocate(MAX_ENV_VALUES * 4, 'i8*', ALLOC_STATIC); HEAP32[((envPtr)>>2)]=poolPtr HEAP32[((_environ)>>2)]=envPtr; } else { envPtr = HEAP32[((_environ)>>2)]; poolPtr = HEAP32[((envPtr)>>2)]; } // Collect key=value lines. var strings = []; var totalSize = 0; for (var key in env) { if (typeof env[key] === 'string') { var line = key + '=' + env[key]; strings.push(line); totalSize += line.length; } } if (totalSize > TOTAL_ENV_SIZE) { throw new Error('Environment size exceeded TOTAL_ENV_SIZE!'); } // Make new. var ptrSize = 4; for (var i = 0; i < strings.length; i++) { var line = strings[i]; for (var j = 0; j < line.length; j++) { HEAP8[(((poolPtr)+(j))|0)]=line.charCodeAt(j); } HEAP8[(((poolPtr)+(j))|0)]=0; HEAP32[(((envPtr)+(i * ptrSize))>>2)]=poolPtr; poolPtr += line.length + 1; } HEAP32[(((envPtr)+(strings.length * ptrSize))>>2)]=0; }var ENV={};function _getenv(name) { // char *getenv(const char *name); // http://pubs.opengroup.org/onlinepubs/009695399/functions/getenv.html if (name === 0) return 0; name = Pointer_stringify(name); if (!ENV.hasOwnProperty(name)) return 0; if (_getenv.ret) _free(_getenv.ret); _getenv.ret = allocate(intArrayFromString(ENV[name]), 'i8', ALLOC_NORMAL); return _getenv.ret; } function _strchr(ptr, chr) { ptr--; do { ptr++; var val = HEAP8[(ptr)]; if (val == chr) return ptr; } while (val); return 0; } var _llvm_va_start=undefined; function _llvm_va_end() {} function _vfprintf(s, f, va_arg) { return _fprintf(s, f, HEAP32[((va_arg)>>2)]); } var ERRNO_MESSAGES={0:"Success",1:"Not super-user",2:"No such file or directory",3:"No such process",4:"Interrupted system call",5:"I/O error",6:"No such device or address",7:"Arg list too long",8:"Exec format error",9:"Bad file number",10:"No children",11:"No more processes",12:"Not enough core",13:"Permission denied",14:"Bad address",15:"Block device required",16:"Mount device busy",17:"File exists",18:"Cross-device link",19:"No such device",20:"Not a directory",21:"Is a directory",22:"Invalid argument",23:"Too many open files in system",24:"Too many open files",25:"Not a typewriter",26:"Text file busy",27:"File too large",28:"No space left on device",29:"Illegal seek",30:"Read only file system",31:"Too many links",32:"Broken pipe",33:"Math arg out of domain of func",34:"Math result not representable",35:"No message of desired type",36:"Identifier removed",37:"Channel number out of range",38:"Level 2 not synchronized",39:"Level 3 halted",40:"Level 3 reset",41:"Link number out of range",42:"Protocol driver not attached",43:"No CSI structure available",44:"Level 2 halted",45:"Deadlock condition",46:"No record locks available",50:"Invalid exchange",51:"Invalid request descriptor",52:"Exchange full",53:"No anode",54:"Invalid request code",55:"Invalid slot",56:"File locking deadlock error",57:"Bad font file fmt",60:"Device not a stream",61:"No data (for no delay io)",62:"Timer expired",63:"Out of streams resources",64:"Machine is not on the network",65:"Package not installed",66:"The object is remote",67:"The link has been severed",68:"Advertise error",69:"Srmount error",70:"Communication error on send",71:"Protocol error",74:"Multihop attempted",75:"Inode is remote (not really error)",76:"Cross mount point (not really error)",77:"Trying to read unreadable message",79:"Inappropriate file type or format",80:"Given log. name not unique",81:"f.d. invalid for this operation",82:"Remote address changed",83:"Can\t access a needed shared lib",84:"Accessing a corrupted shared lib",85:".lib section in a.out corrupted",86:"Attempting to link in too many libs",87:"Attempting to exec a shared library",88:"Function not implemented",89:"No more files",90:"Directory not empty",91:"File or path name too long",92:"Too many symbolic links",95:"Operation not supported on transport endpoint",96:"Protocol family not supported",104:"Connection reset by peer",105:"No buffer space available",106:"Address family not supported by protocol family",107:"Protocol wrong type for socket",108:"Socket operation on non-socket",109:"Protocol not available",110:"Can't send after socket shutdown",111:"Connection refused",112:"Address already in use",113:"Connection aborted",114:"Network is unreachable",115:"Network interface is not configured",116:"Connection timed out",117:"Host is down",118:"Host is unreachable",119:"Connection already in progress",120:"Socket already connected",121:"Destination address required",122:"Message too long",123:"Unknown protocol",124:"Socket type not supported",125:"Address not available",126:"ENETRESET",127:"Socket is already connected",128:"Socket is not connected",129:"TOOMANYREFS",130:"EPROCLIM",131:"EUSERS",132:"EDQUOT",133:"ESTALE",134:"Not supported",135:"No medium (in tape drive)",136:"No such host or network path",137:"Filename exists with different case",138:"EILSEQ",139:"Value too large for defined data type",140:"Operation canceled",141:"State not recoverable",142:"Previous owner died",143:"Streams pipe error"};function _strerror_r(errnum, strerrbuf, buflen) { if (errnum in ERRNO_MESSAGES) { if (ERRNO_MESSAGES[errnum].length > buflen - 1) { return ___setErrNo(ERRNO_CODES.ERANGE); } else { var msg = ERRNO_MESSAGES[errnum]; for (var i = 0; i < msg.length; i++) { HEAP8[(((strerrbuf)+(i))|0)]=msg.charCodeAt(i) } HEAP8[(((strerrbuf)+(i))|0)]=0 return 0; } } else { return ___setErrNo(ERRNO_CODES.EINVAL); } }function _strerror(errnum) { if (!_strerror.buffer) _strerror.buffer = _malloc(256); _strerror_r(errnum, _strerror.buffer, 256); return _strerror.buffer; } function _isspace(chr) { switch(chr) { case 32: case 9: case 10: case 11: case 12: case 13: return true; default: return false; }; } var Browser={mainLoop:{scheduler:null,shouldPause:false,paused:false,queue:[],pause:function () { Browser.mainLoop.shouldPause = true; },resume:function () { if (Browser.mainLoop.paused) { Browser.mainLoop.paused = false; Browser.mainLoop.scheduler(); } Browser.mainLoop.shouldPause = false; },updateStatus:function () { if (Module['setStatus']) { var message = Module['statusMessage'] || 'Please wait...'; var remaining = Browser.mainLoop.remainingBlockers; var expected = Browser.mainLoop.expectedBlockers; if (remaining) { if (remaining < expected) { Module['setStatus'](message + ' (' + (expected - remaining) + '/' + expected + ')'); } else { Module['setStatus'](message); } } else { Module['setStatus'](''); } } }},isFullScreen:false,pointerLock:false,moduleContextCreatedCallbacks:[],workers:[],init:function () { if (!Module["preloadPlugins"]) Module["preloadPlugins"] = []; // needs to exist even in workers if (Browser.initted || ENVIRONMENT_IS_WORKER) return; Browser.initted = true; try { new Blob(); Browser.hasBlobConstructor = true; } catch(e) { Browser.hasBlobConstructor = false; console.log("warning: no blob constructor, cannot create blobs with mimetypes"); } Browser.BlobBuilder = typeof MozBlobBuilder != "undefined" ? MozBlobBuilder : (typeof WebKitBlobBuilder != "undefined" ? WebKitBlobBuilder : (!Browser.hasBlobConstructor ? console.log("warning: no BlobBuilder") : null)); Browser.URLObject = typeof window != "undefined" ? (window.URL ? window.URL : window.webkitURL) : console.log("warning: cannot create object URLs"); // Support for plugins that can process preloaded files. You can add more of these to // your app by creating and appending to Module.preloadPlugins. // // Each plugin is asked if it can handle a file based on the file's name. If it can, // it is given the file's raw data. When it is done, it calls a callback with the file's // (possibly modified) data. For example, a plugin might decompress a file, or it // might create some side data structure for use later (like an Image element, etc.). var imagePlugin = {}; imagePlugin['canHandle'] = function(name) { return !Module.noImageDecoding && /\.(jpg|jpeg|png|bmp)$/i.test(name); }; imagePlugin['handle'] = function(byteArray, name, onload, onerror) { var b = null; if (Browser.hasBlobConstructor) { try { b = new Blob([byteArray], { type: Browser.getMimetype(name) }); if (b.size !== byteArray.length) { // Safari bug #118630 // Safari's Blob can only take an ArrayBuffer b = new Blob([(new Uint8Array(byteArray)).buffer], { type: Browser.getMimetype(name) }); } } catch(e) { Runtime.warnOnce('Blob constructor present but fails: ' + e + '; falling back to blob builder'); } } if (!b) { var bb = new Browser.BlobBuilder(); bb.append((new Uint8Array(byteArray)).buffer); // we need to pass a buffer, and must copy the array to get the right data range b = bb.getBlob(); } var url = Browser.URLObject.createObjectURL(b); var img = new Image(); img.onload = function() { assert(img.complete, 'Image ' + name + ' could not be decoded'); var canvas = document.createElement('canvas'); canvas.width = img.width; canvas.height = img.height; var ctx = canvas.getContext('2d'); ctx.drawImage(img, 0, 0); Module["preloadedImages"][name] = canvas; Browser.URLObject.revokeObjectURL(url); if (onload) onload(byteArray); }; img.onerror = function(event) { console.log('Image ' + url + ' could not be decoded'); if (onerror) onerror(); }; img.src = url; }; Module['preloadPlugins'].push(imagePlugin); var audioPlugin = {}; audioPlugin['canHandle'] = function(name) { return !Module.noAudioDecoding && name.substr(-4) in { '.ogg': 1, '.wav': 1, '.mp3': 1 }; }; audioPlugin['handle'] = function(byteArray, name, onload, onerror) { var done = false; function finish(audio) { if (done) return; done = true; Module["preloadedAudios"][name] = audio; if (onload) onload(byteArray); } function fail() { if (done) return; done = true; Module["preloadedAudios"][name] = new Audio(); // empty shim if (onerror) onerror(); } if (Browser.hasBlobConstructor) { try { var b = new Blob([byteArray], { type: Browser.getMimetype(name) }); } catch(e) { return fail(); } var url = Browser.URLObject.createObjectURL(b); // XXX we never revoke this! var audio = new Audio(); audio.addEventListener('canplaythrough', function() { finish(audio) }, false); // use addEventListener due to chromium bug 124926 audio.onerror = function(event) { if (done) return; console.log('warning: browser could not fully decode audio ' + name + ', trying slower base64 approach'); function encode64(data) { var BASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; var PAD = '='; var ret = ''; var leftchar = 0; var leftbits = 0; for (var i = 0; i < data.length; i++) { leftchar = (leftchar << 8) | data[i]; leftbits += 8; while (leftbits >= 6) { var curr = (leftchar >> (leftbits-6)) & 0x3f; leftbits -= 6; ret += BASE[curr]; } } if (leftbits == 2) { ret += BASE[(leftchar&3) << 4]; ret += PAD + PAD; } else if (leftbits == 4) { ret += BASE[(leftchar&0xf) << 2]; ret += PAD; } return ret; } audio.src = 'data:audio/x-' + name.substr(-3) + ';base64,' + encode64(byteArray); finish(audio); // we don't wait for confirmation this worked - but it's worth trying }; audio.src = url; // workaround for chrome bug 124926 - we do not always get oncanplaythrough or onerror Browser.safeSetTimeout(function() { finish(audio); // try to use it even though it is not necessarily ready to play }, 10000); } else { return fail(); } }; Module['preloadPlugins'].push(audioPlugin); // Canvas event setup var canvas = Module['canvas']; canvas.requestPointerLock = canvas['requestPointerLock'] || canvas['mozRequestPointerLock'] || canvas['webkitRequestPointerLock']; canvas.exitPointerLock = document['exitPointerLock'] || document['mozExitPointerLock'] || document['webkitExitPointerLock'] || function(){}; // no-op if function does not exist canvas.exitPointerLock = canvas.exitPointerLock.bind(document); function pointerLockChange() { Browser.pointerLock = document['pointerLockElement'] === canvas || document['mozPointerLockElement'] === canvas || document['webkitPointerLockElement'] === canvas; } document.addEventListener('pointerlockchange', pointerLockChange, false); document.addEventListener('mozpointerlockchange', pointerLockChange, false); document.addEventListener('webkitpointerlockchange', pointerLockChange, false); if (Module['elementPointerLock']) { canvas.addEventListener("click", function(ev) { if (!Browser.pointerLock && canvas.requestPointerLock) { canvas.requestPointerLock(); ev.preventDefault(); } }, false); } },createContext:function (canvas, useWebGL, setInModule) { var ctx; try { if (useWebGL) { ctx = canvas.getContext('experimental-webgl', { alpha: false }); } else { ctx = canvas.getContext('2d'); } if (!ctx) throw ':('; } catch (e) { Module.print('Could not create canvas - ' + e); return null; } if (useWebGL) { // Set the background of the WebGL canvas to black canvas.style.backgroundColor = "black"; // Warn on context loss canvas.addEventListener('webglcontextlost', function(event) { alert('WebGL context lost. You will need to reload the page.'); }, false); } if (setInModule) { Module.ctx = ctx; Module.useWebGL = useWebGL; Browser.moduleContextCreatedCallbacks.forEach(function(callback) { callback() }); Browser.init(); } return ctx; },destroyContext:function (canvas, useWebGL, setInModule) {},fullScreenHandlersInstalled:false,lockPointer:undefined,resizeCanvas:undefined,requestFullScreen:function (lockPointer, resizeCanvas) { Browser.lockPointer = lockPointer; Browser.resizeCanvas = resizeCanvas; if (typeof Browser.lockPointer === 'undefined') Browser.lockPointer = true; if (typeof Browser.resizeCanvas === 'undefined') Browser.resizeCanvas = false; var canvas = Module['canvas']; function fullScreenChange() { Browser.isFullScreen = false; if ((document['webkitFullScreenElement'] || document['webkitFullscreenElement'] || document['mozFullScreenElement'] || document['mozFullscreenElement'] || document['fullScreenElement'] || document['fullscreenElement']) === canvas) { canvas.cancelFullScreen = document['cancelFullScreen'] || document['mozCancelFullScreen'] || document['webkitCancelFullScreen']; canvas.cancelFullScreen = canvas.cancelFullScreen.bind(document); if (Browser.lockPointer) canvas.requestPointerLock(); Browser.isFullScreen = true; if (Browser.resizeCanvas) Browser.setFullScreenCanvasSize(); } else if (Browser.resizeCanvas){ Browser.setWindowedCanvasSize(); } if (Module['onFullScreen']) Module['onFullScreen'](Browser.isFullScreen); } if (!Browser.fullScreenHandlersInstalled) { Browser.fullScreenHandlersInstalled = true; document.addEventListener('fullscreenchange', fullScreenChange, false); document.addEventListener('mozfullscreenchange', fullScreenChange, false); document.addEventListener('webkitfullscreenchange', fullScreenChange, false); } canvas.requestFullScreen = canvas['requestFullScreen'] || canvas['mozRequestFullScreen'] || (canvas['webkitRequestFullScreen'] ? function() { canvas['webkitRequestFullScreen'](Element['ALLOW_KEYBOARD_INPUT']) } : null); canvas.requestFullScreen(); },requestAnimationFrame:function (func) { if (!window.requestAnimationFrame) { window.requestAnimationFrame = window['requestAnimationFrame'] || window['mozRequestAnimationFrame'] || window['webkitRequestAnimationFrame'] || window['msRequestAnimationFrame'] || window['oRequestAnimationFrame'] || window['setTimeout']; } window.requestAnimationFrame(func); },safeCallback:function (func) { return function() { if (!ABORT) return func.apply(null, arguments); }; },safeRequestAnimationFrame:function (func) { return Browser.requestAnimationFrame(function() { if (!ABORT) func(); }); },safeSetTimeout:function (func, timeout) { return setTimeout(function() { if (!ABORT) func(); }, timeout); },safeSetInterval:function (func, timeout) { return setInterval(function() { if (!ABORT) func(); }, timeout); },getMimetype:function (name) { return { 'jpg': 'image/jpeg', 'jpeg': 'image/jpeg', 'png': 'image/png', 'bmp': 'image/bmp', 'ogg': 'audio/ogg', 'wav': 'audio/wav', 'mp3': 'audio/mpeg' }[name.substr(name.lastIndexOf('.')+1)]; },getUserMedia:function (func) { if(!window.getUserMedia) { window.getUserMedia = navigator['getUserMedia'] || navigator['mozGetUserMedia']; } window.getUserMedia(func); },getMovementX:function (event) { return event['movementX'] || event['mozMovementX'] || event['webkitMovementX'] || 0; },getMovementY:function (event) { return event['movementY'] || event['mozMovementY'] || event['webkitMovementY'] || 0; },mouseX:0,mouseY:0,mouseMovementX:0,mouseMovementY:0,calculateMouseEvent:function (event) { // event should be mousemove, mousedown or mouseup if (Browser.pointerLock) { // When the pointer is locked, calculate the coordinates // based on the movement of the mouse. // Workaround for Firefox bug 764498 if (event.type != 'mousemove' && ('mozMovementX' in event)) { Browser.mouseMovementX = Browser.mouseMovementY = 0; } else { Browser.mouseMovementX = Browser.getMovementX(event); Browser.mouseMovementY = Browser.getMovementY(event); } // check if SDL is available if (typeof SDL != "undefined") { Browser.mouseX = SDL.mouseX + Browser.mouseMovementX; Browser.mouseY = SDL.mouseY + Browser.mouseMovementY; } else { // just add the mouse delta to the current absolut mouse position // FIXME: ideally this should be clamped against the canvas size and zero Browser.mouseX += Browser.mouseMovementX; Browser.mouseY += Browser.mouseMovementY; } } else { // Otherwise, calculate the movement based on the changes // in the coordinates. var rect = Module["canvas"].getBoundingClientRect(); var x = event.clientX - (window.scrollX + rect.left); var y = event.clientY - (window.scrollY + rect.top); // the canvas might be CSS-scaled compared to its backbuffer; // SDL-using content will want mouse coordinates in terms // of backbuffer units. var cw = Module["canvas"].width; var ch = Module["canvas"].height; x = x * (cw / rect.width); y = y * (ch / rect.height); Browser.mouseMovementX = x - Browser.mouseX; Browser.mouseMovementY = y - Browser.mouseY; Browser.mouseX = x; Browser.mouseY = y; } },xhrLoad:function (url, onload, onerror) { var xhr = new XMLHttpRequest(); xhr.open('GET', url, true); xhr.responseType = 'arraybuffer'; xhr.onload = function() { if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0 onload(xhr.response); } else { onerror(); } }; xhr.onerror = onerror; xhr.send(null); },asyncLoad:function (url, onload, onerror, noRunDep) { Browser.xhrLoad(url, function(arrayBuffer) { assert(arrayBuffer, 'Loading data file "' + url + '" failed (no arrayBuffer).'); onload(new Uint8Array(arrayBuffer)); if (!noRunDep) removeRunDependency('al ' + url); }, function(event) { if (onerror) { onerror(); } else { throw 'Loading data file "' + url + '" failed.'; } }); if (!noRunDep) addRunDependency('al ' + url); },resizeListeners:[],updateResizeListeners:function () { var canvas = Module['canvas']; Browser.resizeListeners.forEach(function(listener) { listener(canvas.width, canvas.height); }); },setCanvasSize:function (width, height, noUpdates) { var canvas = Module['canvas']; canvas.width = width; canvas.height = height; if (!noUpdates) Browser.updateResizeListeners(); },windowedWidth:0,windowedHeight:0,setFullScreenCanvasSize:function () { var canvas = Module['canvas']; this.windowedWidth = canvas.width; this.windowedHeight = canvas.height; canvas.width = screen.width; canvas.height = screen.height; // check if SDL is available if (typeof SDL != "undefined") { var flags = HEAPU32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)]; flags = flags | 0x00800000; // set SDL_FULLSCREEN flag HEAP32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)]=flags } Browser.updateResizeListeners(); },setWindowedCanvasSize:function () { var canvas = Module['canvas']; canvas.width = this.windowedWidth; canvas.height = this.windowedHeight; // check if SDL is available if (typeof SDL != "undefined") { var flags = HEAPU32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)]; flags = flags & ~0x00800000; // clear SDL_FULLSCREEN flag HEAP32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)]=flags } Browser.updateResizeListeners(); }}; FS.staticInit();__ATINIT__.unshift({ func: function() { if (!Module["noFSInit"] && !FS.init.initialized) FS.init() } });__ATMAIN__.push({ func: function() { FS.ignorePermissions = false } });__ATEXIT__.push({ func: function() { FS.quit() } });Module["FS_createFolder"] = FS.createFolder;Module["FS_createPath"] = FS.createPath;Module["FS_createDataFile"] = FS.createDataFile;Module["FS_createPreloadedFile"] = FS.createPreloadedFile;Module["FS_createLazyFile"] = FS.createLazyFile;Module["FS_createLink"] = FS.createLink;Module["FS_createDevice"] = FS.createDevice; ___errno_state = Runtime.staticAlloc(4); HEAP32[((___errno_state)>>2)]=0; _fputc.ret = allocate([0], "i8", ALLOC_STATIC); _llvm_eh_exception.buf = allocate(12, "void*", ALLOC_STATIC); ___buildEnvironment(ENV); Module["requestFullScreen"] = function(lockPointer, resizeCanvas) { Browser.requestFullScreen(lockPointer, resizeCanvas) }; Module["requestAnimationFrame"] = function(func) { Browser.requestAnimationFrame(func) }; Module["pauseMainLoop"] = function() { Browser.mainLoop.pause() }; Module["resumeMainLoop"] = function() { Browser.mainLoop.resume() }; Module["getUserMedia"] = function() { Browser.getUserMedia() } STACK_BASE = STACKTOP = Runtime.alignMemory(STATICTOP); staticSealed = true; // seal the static portion of memory STACK_MAX = STACK_BASE + 131072; DYNAMIC_BASE = DYNAMICTOP = Runtime.alignMemory(STACK_MAX); assert(DYNAMIC_BASE < TOTAL_MEMORY); // Stack must fit in TOTAL_MEMORY; allocations from here on may enlarge TOTAL_MEMORY var ctlz_i8 = allocate([8,7,6,6,5,5,5,5,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,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,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,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,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,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,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], "i8", ALLOC_DYNAMIC); var cttz_i8 = allocate([8,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0], "i8", ALLOC_DYNAMIC); var Math_min = Math.min; function invoke_viiiii(index,a1,a2,a3,a4,a5) { try { Module["dynCall_viiiii"](index,a1,a2,a3,a4,a5); } catch(e) { if (typeof e !== 'number' && e !== 'longjmp') throw e; asm["setThrew"](1, 0); } } function invoke_vi(index,a1) { try { Module["dynCall_vi"](index,a1); } catch(e) { if (typeof e !== 'number' && e !== 'longjmp') throw e; asm["setThrew"](1, 0); } } function invoke_vii(index,a1,a2) { try { Module["dynCall_vii"](index,a1,a2); } catch(e) { if (typeof e !== 'number' && e !== 'longjmp') throw e; asm["setThrew"](1, 0); } } function invoke_iiiiiii(index,a1,a2,a3,a4,a5,a6) { try { return Module["dynCall_iiiiiii"](index,a1,a2,a3,a4,a5,a6); } catch(e) { if (typeof e !== 'number' && e !== 'longjmp') throw e; asm["setThrew"](1, 0); } } function invoke_iiiii(index,a1,a2,a3,a4) { try { return Module["dynCall_iiiii"](index,a1,a2,a3,a4); } catch(e) { if (typeof e !== 'number' && e !== 'longjmp') throw e; asm["setThrew"](1, 0); } } function invoke_ii(index,a1) { try { return Module["dynCall_ii"](index,a1); } catch(e) { if (typeof e !== 'number' && e !== 'longjmp') throw e; asm["setThrew"](1, 0); } } function invoke_iiii(index,a1,a2,a3) { try { return Module["dynCall_iiii"](index,a1,a2,a3); } catch(e) { if (typeof e !== 'number' && e !== 'longjmp') throw e; asm["setThrew"](1, 0); } } function invoke_viii(index,a1,a2,a3) { try { Module["dynCall_viii"](index,a1,a2,a3); } catch(e) { if (typeof e !== 'number' && e !== 'longjmp') throw e; asm["setThrew"](1, 0); } } function invoke_v(index) { try { Module["dynCall_v"](index); } catch(e) { if (typeof e !== 'number' && e !== 'longjmp') throw e; asm["setThrew"](1, 0); } } function invoke_viiiiii(index,a1,a2,a3,a4,a5,a6) { try { Module["dynCall_viiiiii"](index,a1,a2,a3,a4,a5,a6); } catch(e) { if (typeof e !== 'number' && e !== 'longjmp') throw e; asm["setThrew"](1, 0); } } function invoke_iii(index,a1,a2) { try { return Module["dynCall_iii"](index,a1,a2); } catch(e) { if (typeof e !== 'number' && e !== 'longjmp') throw e; asm["setThrew"](1, 0); } } function invoke_iiiiii(index,a1,a2,a3,a4,a5) { try { return Module["dynCall_iiiiii"](index,a1,a2,a3,a4,a5); } catch(e) { if (typeof e !== 'number' && e !== 'longjmp') throw e; asm["setThrew"](1, 0); } } function invoke_viiii(index,a1,a2,a3,a4) { try { Module["dynCall_viiii"](index,a1,a2,a3,a4); } catch(e) { if (typeof e !== 'number' && e !== 'longjmp') throw e; asm["setThrew"](1, 0); } } function asmPrintInt(x, y) { Module.print('int ' + x + ',' + y);// + ' ' + new Error().stack); } function asmPrintFloat(x, y) { Module.print('float ' + x + ',' + y);// + ' ' + new Error().stack); } // EMSCRIPTEN_START_ASM var asm = (function(global, env, buffer) { 'use asm'; var HEAP8 = new global.Int8Array(buffer); var HEAP16 = new global.Int16Array(buffer); var HEAP32 = new global.Int32Array(buffer); var HEAPU8 = new global.Uint8Array(buffer); var HEAPU16 = new global.Uint16Array(buffer); var HEAPU32 = new global.Uint32Array(buffer); var HEAPF32 = new global.Float32Array(buffer); var HEAPF64 = new global.Float64Array(buffer); var STACKTOP=env.STACKTOP|0; var STACK_MAX=env.STACK_MAX|0; var tempDoublePtr=env.tempDoublePtr|0; var ABORT=env.ABORT|0; var cttz_i8=env.cttz_i8|0; var ctlz_i8=env.ctlz_i8|0; var __ZTIy=env.__ZTIy|0; var __ZTIx=env.__ZTIx|0; var __ZTIt=env.__ZTIt|0; var __ZTIs=env.__ZTIs|0; var __ZTIm=env.__ZTIm|0; var __ZTIl=env.__ZTIl|0; var __ZTIi=env.__ZTIi|0; var __ZTIh=env.__ZTIh|0; var __ZTIj=env.__ZTIj|0; var __ZTIe=env.__ZTIe|0; var __ZTId=env.__ZTId|0; var __ZTVN10__cxxabiv117__class_type_infoE=env.__ZTVN10__cxxabiv117__class_type_infoE|0; var __ZTIf=env.__ZTIf|0; var __ZTIa=env.__ZTIa|0; var __ZTIc=env.__ZTIc|0; var __ZTVN10__cxxabiv120__si_class_type_infoE=env.__ZTVN10__cxxabiv120__si_class_type_infoE|0; var _stderr=env._stderr|0; var ___progname=env.___progname|0; var __ZTVN10__cxxabiv119__pointer_type_infoE=env.__ZTVN10__cxxabiv119__pointer_type_infoE|0; var NaN=+env.NaN; var Infinity=+env.Infinity; var __THREW__ = 0; var threwValue = 0; var setjmpId = 0; var undef = 0; var tempInt = 0, tempBigInt = 0, tempBigIntP = 0, tempBigIntS = 0, tempBigIntR = 0.0, tempBigIntI = 0, tempBigIntD = 0, tempValue = 0, tempDouble = 0.0; var tempRet0 = 0; var tempRet1 = 0; var tempRet2 = 0; var tempRet3 = 0; var tempRet4 = 0; var tempRet5 = 0; var tempRet6 = 0; var tempRet7 = 0; var tempRet8 = 0; var tempRet9 = 0; var Math_floor=global.Math.floor; var Math_abs=global.Math.abs; var Math_sqrt=global.Math.sqrt; var Math_pow=global.Math.pow; var Math_cos=global.Math.cos; var Math_sin=global.Math.sin; var Math_tan=global.Math.tan; var Math_acos=global.Math.acos; var Math_asin=global.Math.asin; var Math_atan=global.Math.atan; var Math_atan2=global.Math.atan2; var Math_exp=global.Math.exp; var Math_log=global.Math.log; var Math_ceil=global.Math.ceil; var Math_imul=global.Math.imul; var abort=env.abort; var assert=env.assert; var asmPrintInt=env.asmPrintInt; var asmPrintFloat=env.asmPrintFloat; var Math_min=env.min; var invoke_viiiii=env.invoke_viiiii; var invoke_vi=env.invoke_vi; var invoke_vii=env.invoke_vii; var invoke_iiiiiii=env.invoke_iiiiiii; var invoke_iiiii=env.invoke_iiiii; var invoke_ii=env.invoke_ii; var invoke_iiii=env.invoke_iiii; var invoke_viii=env.invoke_viii; var invoke_v=env.invoke_v; var invoke_viiiiii=env.invoke_viiiiii; var invoke_iii=env.invoke_iii; var invoke_iiiiii=env.invoke_iiiiii; var invoke_viiii=env.invoke_viiii; var _strncmp=env._strncmp; var _lseek=env._lseek; var ___cxa_call_unexpected=env.___cxa_call_unexpected; var _snprintf=env._snprintf; var ___cxa_free_exception=env.___cxa_free_exception; var ___cxa_throw=env.___cxa_throw; var _fread=env._fread; var _fclose=env._fclose; var _strerror=env._strerror; var ___cxa_pure_virtual=env.___cxa_pure_virtual; var _fprintf=env._fprintf; var _sqrt=env._sqrt; var _llvm_va_end=env._llvm_va_end; var _pread=env._pread; var _close=env._close; var _feof=env._feof; var _fopen=env._fopen; var _open=env._open; var _strchr=env._strchr; var _fputc=env._fputc; var ___buildEnvironment=env.___buildEnvironment; var _log=env._log; var _puts=env._puts; var _abort=env._abort; var ___setErrNo=env.___setErrNo; var _recv=env._recv; var _fseek=env._fseek; var _qsort2=env._qsort2; var _qsort=env._qsort; var _send=env._send; var _write=env._write; var _fputs=env._fputs; var _ftell=env._ftell; var _llvm_umul_with_overflow_i32=env._llvm_umul_with_overflow_i32; var _exit=env._exit; var ___cxa_find_matching_catch=env.___cxa_find_matching_catch; var _strdup=env._strdup; var ___cxa_allocate_exception=env.___cxa_allocate_exception; var _ferror=env._ferror; var _printf=env._printf; var _sysconf=env._sysconf; var _sbrk=env._sbrk; var _truncate=env._truncate; var _read=env._read; var ___cxa_is_number_type=env.___cxa_is_number_type; var __reallyNegative=env.__reallyNegative; var _time=env._time; var __formatString=env.__formatString; var ___cxa_does_inherit=env.___cxa_does_inherit; var _getenv=env._getenv; var __ZSt9terminatev=env.__ZSt9terminatev; var _gettimeofday=env._gettimeofday; var _llvm_eh_exception=env._llvm_eh_exception; var _vfprintf=env._vfprintf; var ___cxa_begin_catch=env.___cxa_begin_catch; var _unlink=env._unlink; var ___assert_func=env.___assert_func; var __ZSt18uncaught_exceptionv=env.__ZSt18uncaught_exceptionv; var _pwrite=env._pwrite; var _putchar=env._putchar; var _fabs=env._fabs; var _fsync=env._fsync; var _strerror_r=env._strerror_r; var ___errno_location=env.___errno_location; var ___gxx_personality_v0=env.___gxx_personality_v0; var _isspace=env._isspace; var _fdopen=env._fdopen; var _bsearch=env._bsearch; var _fwrite=env._fwrite; var _ftruncate=env._ftruncate; var __exit=env.__exit; var ___resumeException=env.___resumeException; var _strcmp=env._strcmp; var ___cxa_end_catch=env.___cxa_end_catch; // EMSCRIPTEN_START_FUNCS function stackAlloc(size) { size = size | 0; var ret = 0; ret = STACKTOP; STACKTOP = STACKTOP + size | 0; STACKTOP = STACKTOP + 7 >> 3 << 3; return ret | 0; } function stackSave() { return STACKTOP | 0; } function stackRestore(top) { top = top | 0; STACKTOP = top; } function setThrew(threw, value) { threw = threw | 0; value = value | 0; if ((__THREW__ | 0) == 0) { __THREW__ = threw; threwValue = value; } } function copyTempFloat(ptr) { ptr = ptr | 0; HEAP8[tempDoublePtr] = HEAP8[ptr]; HEAP8[tempDoublePtr + 1 | 0] = HEAP8[ptr + 1 | 0]; HEAP8[tempDoublePtr + 2 | 0] = HEAP8[ptr + 2 | 0]; HEAP8[tempDoublePtr + 3 | 0] = HEAP8[ptr + 3 | 0]; } function copyTempDouble(ptr) { ptr = ptr | 0; HEAP8[tempDoublePtr] = HEAP8[ptr]; HEAP8[tempDoublePtr + 1 | 0] = HEAP8[ptr + 1 | 0]; HEAP8[tempDoublePtr + 2 | 0] = HEAP8[ptr + 2 | 0]; HEAP8[tempDoublePtr + 3 | 0] = HEAP8[ptr + 3 | 0]; HEAP8[tempDoublePtr + 4 | 0] = HEAP8[ptr + 4 | 0]; HEAP8[tempDoublePtr + 5 | 0] = HEAP8[ptr + 5 | 0]; HEAP8[tempDoublePtr + 6 | 0] = HEAP8[ptr + 6 | 0]; HEAP8[tempDoublePtr + 7 | 0] = HEAP8[ptr + 7 | 0]; } function setTempRet0(value) { value = value | 0; tempRet0 = value; } function setTempRet1(value) { value = value | 0; tempRet1 = value; } function setTempRet2(value) { value = value | 0; tempRet2 = value; } function setTempRet3(value) { value = value | 0; tempRet3 = value; } function setTempRet4(value) { value = value | 0; tempRet4 = value; } function setTempRet5(value) { value = value | 0; tempRet5 = value; } function setTempRet6(value) { value = value | 0; tempRet6 = value; } function setTempRet7(value) { value = value | 0; tempRet7 = value; } function setTempRet8(value) { value = value | 0; tempRet8 = value; } function setTempRet9(value) { value = value | 0; tempRet9 = value; } function runPostSets() { HEAP32[__ZTVN10__cxxabiv120__si_class_type_infoE + 8 >> 2] = 88; HEAP32[__ZTVN10__cxxabiv120__si_class_type_infoE + 12 >> 2] = 108; HEAP32[__ZTVN10__cxxabiv120__si_class_type_infoE + 16 >> 2] = 94; HEAP32[__ZTVN10__cxxabiv120__si_class_type_infoE + 20 >> 2] = 22; HEAP32[__ZTVN10__cxxabiv120__si_class_type_infoE + 24 >> 2] = 10; HEAP32[__ZTVN10__cxxabiv120__si_class_type_infoE + 28 >> 2] = 6; HEAP32[__ZTVN10__cxxabiv120__si_class_type_infoE + 32 >> 2] = 2; HEAP32[__ZTVN10__cxxabiv120__si_class_type_infoE + 36 >> 2] = 4; HEAP32[__ZTVN10__cxxabiv119__pointer_type_infoE + 8 >> 2] = 88; HEAP32[__ZTVN10__cxxabiv119__pointer_type_infoE + 12 >> 2] = 96; HEAP32[__ZTVN10__cxxabiv119__pointer_type_infoE + 16 >> 2] = 94; HEAP32[__ZTVN10__cxxabiv119__pointer_type_infoE + 20 >> 2] = 22; HEAP32[__ZTVN10__cxxabiv119__pointer_type_infoE + 24 >> 2] = 12; HEAP32[__ZTVN10__cxxabiv117__class_type_infoE + 8 >> 2] = 88; HEAP32[__ZTVN10__cxxabiv117__class_type_infoE + 12 >> 2] = 86; HEAP32[__ZTVN10__cxxabiv117__class_type_infoE + 16 >> 2] = 94; HEAP32[__ZTVN10__cxxabiv117__class_type_infoE + 20 >> 2] = 22; HEAP32[__ZTVN10__cxxabiv117__class_type_infoE + 24 >> 2] = 10; HEAP32[__ZTVN10__cxxabiv117__class_type_infoE + 28 >> 2] = 2; HEAP32[__ZTVN10__cxxabiv117__class_type_infoE + 32 >> 2] = 6; HEAP32[__ZTVN10__cxxabiv117__class_type_infoE + 36 >> 2] = 2; HEAP32[__ZTIy >> 2] = 8504; HEAP32[__ZTIy + 4 >> 2] = 8784; HEAP32[__ZTIx >> 2] = 8504; HEAP32[__ZTIx + 4 >> 2] = 8792; HEAP32[__ZTIt >> 2] = 8504; HEAP32[__ZTIt + 4 >> 2] = 8816; HEAP32[__ZTIs >> 2] = 8504; HEAP32[__ZTIs + 4 >> 2] = 8824; HEAP32[__ZTIm >> 2] = 8504; HEAP32[__ZTIm + 4 >> 2] = 8832; HEAP32[__ZTIl >> 2] = 8504; HEAP32[__ZTIl + 4 >> 2] = 8840; HEAP32[__ZTIj >> 2] = 8504; HEAP32[__ZTIj + 4 >> 2] = 8848; HEAP32[__ZTIi >> 2] = 8504; HEAP32[__ZTIi + 4 >> 2] = 8856; HEAP32[__ZTIh >> 2] = 8504; HEAP32[__ZTIh + 4 >> 2] = 8864; HEAP32[__ZTIf >> 2] = 8504; HEAP32[__ZTIf + 4 >> 2] = 8872; HEAP32[__ZTIe >> 2] = 8504; HEAP32[__ZTIe + 4 >> 2] = 8880; HEAP32[__ZTId >> 2] = 8504; HEAP32[__ZTId + 4 >> 2] = 8888; HEAP32[__ZTIc >> 2] = 8504; HEAP32[__ZTIc + 4 >> 2] = 8896; HEAP32[__ZTIa >> 2] = 8504; HEAP32[__ZTIa + 4 >> 2] = 8912; HEAP32[2482] = __ZTVN10__cxxabiv117__class_type_infoE + 8; HEAP32[2484] = __ZTVN10__cxxabiv117__class_type_infoE + 8; HEAP32[2486] = __ZTVN10__cxxabiv120__si_class_type_infoE + 8; HEAP32[2490] = __ZTVN10__cxxabiv120__si_class_type_infoE + 8; HEAP32[2494] = __ZTVN10__cxxabiv120__si_class_type_infoE + 8; HEAP32[2498] = __ZTVN10__cxxabiv120__si_class_type_infoE + 8; HEAP32[2502] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2505] = __ZTIy; HEAP32[2506] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2509] = __ZTIx; HEAP32[2510] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2514] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2518] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2521] = __ZTIt; HEAP32[2522] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2525] = __ZTIs; HEAP32[2526] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2529] = __ZTIm; HEAP32[2530] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2533] = __ZTIl; HEAP32[2534] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2537] = __ZTIj; HEAP32[2538] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2541] = __ZTIi; HEAP32[2542] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2545] = __ZTIh; HEAP32[2546] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2549] = __ZTIf; HEAP32[2550] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2553] = __ZTIe; HEAP32[2554] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2557] = __ZTId; HEAP32[2558] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2561] = __ZTIc; HEAP32[2562] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2566] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2569] = __ZTIa; HEAP32[2570] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2573] = __ZTIy; HEAP32[2574] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2577] = __ZTIx; HEAP32[2578] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2582] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2586] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2589] = __ZTIt; HEAP32[2590] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2593] = __ZTIs; HEAP32[2594] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2597] = __ZTIm; HEAP32[2598] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2601] = __ZTIl; HEAP32[2602] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2605] = __ZTIj; HEAP32[2606] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2609] = __ZTIi; HEAP32[2610] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2613] = __ZTIh; HEAP32[2614] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2617] = __ZTIf; HEAP32[2618] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2621] = __ZTIe; HEAP32[2622] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2625] = __ZTId; HEAP32[2626] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2629] = __ZTIc; HEAP32[2630] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2634] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2637] = __ZTIa; HEAP32[2638] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2642] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2646] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2650] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2654] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2658] = __ZTVN10__cxxabiv119__pointer_type_infoE + 8; HEAP32[2662] = __ZTVN10__cxxabiv120__si_class_type_infoE + 8; HEAP32[2672] = __ZTVN10__cxxabiv117__class_type_infoE + 8; HEAP32[2674] = __ZTVN10__cxxabiv120__si_class_type_infoE + 8; HEAP32[2678] = __ZTVN10__cxxabiv120__si_class_type_infoE + 8; HEAP32[2682] = __ZTVN10__cxxabiv120__si_class_type_infoE + 8; HEAP32[2686] = __ZTVN10__cxxabiv120__si_class_type_infoE + 8; HEAP32[2690] = __ZTVN10__cxxabiv120__si_class_type_infoE + 8; HEAP32[2694] = __ZTVN10__cxxabiv120__si_class_type_infoE + 8; HEAP32[2698] = __ZTVN10__cxxabiv120__si_class_type_infoE + 8; HEAP32[2702] = __ZTVN10__cxxabiv120__si_class_type_infoE + 8; HEAP32[2706] = __ZTVN10__cxxabiv120__si_class_type_infoE + 8; HEAP32[2710] = __ZTVN10__cxxabiv120__si_class_type_infoE + 8; HEAP32[2714] = __ZTVN10__cxxabiv120__si_class_type_infoE + 8; } function __ZN10ime_pinyin14compare_char16EPKvS1_($p1, $p2) { $p1 = $p1 | 0; $p2 = $p2 | 0; var $1 = 0, $3 = 0, $retval_0 = 0; $1 = HEAP16[$p1 >> 1] | 0; $3 = HEAP16[$p2 >> 1] | 0; if (($1 & 65535) < ($3 & 65535)) { $retval_0 = -1; return $retval_0 | 0; } $retval_0 = ($1 & 65535) > ($3 & 65535) | 0; return $retval_0 | 0; } function _im_get_spl_start_at($id) { $id = $id | 0; return HEAP16[(HEAP32[2818] | 0) + ($id << 1) >> 1] | 0; } function _im_get_predict_at($pos) { $pos = $pos | 0; var $retval_0 = 0; if ($pos >>> 0 > 499) { $retval_0 = 0; } else { $retval_0 = 11280 + ($pos * 48 | 0) | 0; } return $retval_0 | 0; } function __ZN10ime_pinyin22cmp_scis_hz_splid_freqEPKvS1_($p1, $p2) { $p1 = $p1 | 0; $p2 = $p2 | 0; var $1 = 0, $3 = 0, $5 = 0, $bf_clear = 0, $7 = 0, $bf_clear12 = 0, $8 = 0, $9 = 0, $10 = 0.0, $11 = 0.0, $retval_0 = 0; $1 = HEAP16[$p1 + 4 >> 1] | 0; $3 = HEAP16[$p2 + 4 >> 1] | 0; do { if (($1 & 65535) < ($3 & 65535)) { $retval_0 = -1; } else { if (($1 & 65535) > ($3 & 65535)) { $retval_0 = 1; break; } $5 = HEAP16[$p1 + 6 >> 1] | 0; $bf_clear = $5 & 31; $7 = HEAP16[$p2 + 6 >> 1] | 0; $bf_clear12 = $7 & 31; if (($bf_clear & 65535) < ($bf_clear12 & 65535)) { $retval_0 = -1; break; } if (($bf_clear & 65535) > ($bf_clear12 & 65535)) { $retval_0 = 1; break; } $8 = ($5 & 65535) >>> 5; $9 = ($7 & 65535) >>> 5; if (($8 & 65535) < ($9 & 65535)) { $retval_0 = -1; break; } if (($8 & 65535) > ($9 & 65535)) { $retval_0 = 1; break; } $10 = +HEAPF32[$p1 >> 2]; $11 = +HEAPF32[$p2 >> 2]; if ($10 > $11) { $retval_0 = -1; break; } $retval_0 = $10 < $11 | 0; } } while (0); return $retval_0 | 0; } function __ZN10ime_pinyin17cmp_scis_hz_splidEPKvS1_($p1, $p2) { $p1 = $p1 | 0; $p2 = $p2 | 0; var $1 = 0, $3 = 0, $5 = 0, $bf_clear = 0, $7 = 0, $bf_clear12 = 0, $8 = 0, $9 = 0, $retval_0 = 0; $1 = HEAP16[$p1 + 4 >> 1] | 0; $3 = HEAP16[$p2 + 4 >> 1] | 0; do { if (($1 & 65535) < ($3 & 65535)) { $retval_0 = -1; } else { if (($1 & 65535) > ($3 & 65535)) { $retval_0 = 1; break; } $5 = HEAP16[$p1 + 6 >> 1] | 0; $bf_clear = $5 & 31; $7 = HEAP16[$p2 + 6 >> 1] | 0; $bf_clear12 = $7 & 31; if (($bf_clear & 65535) < ($bf_clear12 & 65535)) { $retval_0 = -1; break; } if (($bf_clear & 65535) > ($bf_clear12 & 65535)) { $retval_0 = 1; break; } $8 = ($5 & 65535) >>> 5; $9 = ($7 & 65535) >>> 5; if (($8 & 65535) < ($9 & 65535)) { $retval_0 = -1; break; } $retval_0 = ($8 & 65535) > ($9 & 65535) | 0; } } while (0); return $retval_0 | 0; } function _im_open_decoder($fn_sys_dict, $fn_usr_dict) { $fn_sys_dict = $fn_sys_dict | 0; $fn_usr_dict = $fn_usr_dict | 0; var $0 = 0, $call = 0, $6 = 0, $retval_0 = 0; $0 = HEAP32[10830] | 0; if (($0 | 0) != 0) { __ZN10ime_pinyin12MatrixSearchD2Ev($0); __ZdlPv($0 | 0); } $call = __Znwj(12504) | 0; $6 = $call; __ZN10ime_pinyin12MatrixSearchC2Ev($6); HEAP32[10830] = $6; if (($call | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $retval_0 = __ZN10ime_pinyin12MatrixSearch4initEPKcS2_($6, $fn_sys_dict, $fn_usr_dict) | 0; return $retval_0 | 0; } function _im_open_decoder_fd($sys_fd, $start_offset, $length, $fn_usr_dict) { $sys_fd = $sys_fd | 0; $start_offset = $start_offset | 0; $length = $length | 0; $fn_usr_dict = $fn_usr_dict | 0; var $0 = 0, $call = 0, $6 = 0, $retval_0 = 0; $0 = HEAP32[10830] | 0; if (($0 | 0) != 0) { __ZN10ime_pinyin12MatrixSearchD2Ev($0); __ZdlPv($0 | 0); } $call = __Znwj(12504) | 0; $6 = $call; __ZN10ime_pinyin12MatrixSearchC2Ev($6); HEAP32[10830] = $6; if (($call | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $retval_0 = __ZN10ime_pinyin12MatrixSearch7init_fdEillPKc($6, $sys_fd, $start_offset, $length, $fn_usr_dict) | 0; return $retval_0 | 0; } function _im_close_decoder() { var $0 = 0, $1 = 0; $0 = HEAP32[10830] | 0; do { if (($0 | 0) != 0) { __ZN10ime_pinyin12MatrixSearch5closeEv($0); $1 = HEAP32[10830] | 0; if (($1 | 0) == 0) { break; } __ZN10ime_pinyin12MatrixSearchD2Ev($1); __ZdlPv($1 | 0); } } while (0); HEAP32[10830] = 0; return; } function _im_set_max_lens($max_sps_len, $max_hzs_len) { $max_sps_len = $max_sps_len | 0; $max_hzs_len = $max_hzs_len | 0; var $0 = 0; $0 = HEAP32[10830] | 0; if (($0 | 0) == 0) { return; } __ZN10ime_pinyin12MatrixSearch12set_max_lensEjj($0, $max_sps_len, $max_hzs_len); return; } function _im_flush_cache() { var $0 = 0; $0 = HEAP32[10830] | 0; if (($0 | 0) == 0) { return; } __ZN10ime_pinyin12MatrixSearch11flush_cacheEv($0); return; } function _im_search($pybuf, $pylen) { $pybuf = $pybuf | 0; $pylen = $pylen | 0; var $0 = 0, $retval_0 = 0; $0 = HEAP32[10830] | 0; if (($0 | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } __ZN10ime_pinyin12MatrixSearch6searchEPKcj($0, $pybuf, $pylen) | 0; $retval_0 = __ZN10ime_pinyin12MatrixSearch17get_candidate_numEv(HEAP32[10830] | 0) | 0; return $retval_0 | 0; } function _im_delsearch($pos, $is_pos_in_splid, $clear_fixed_this_step) { $pos = $pos | 0; $is_pos_in_splid = $is_pos_in_splid | 0; $clear_fixed_this_step = $clear_fixed_this_step | 0; var $0 = 0, $retval_0 = 0; $0 = HEAP32[10830] | 0; if (($0 | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } __ZN10ime_pinyin12MatrixSearch9delsearchEjbb($0, $pos, $is_pos_in_splid, $clear_fixed_this_step) | 0; $retval_0 = __ZN10ime_pinyin12MatrixSearch17get_candidate_numEv(HEAP32[10830] | 0) | 0; return $retval_0 | 0; } function _im_reset_search() { var $0 = 0; $0 = HEAP32[10830] | 0; if (($0 | 0) == 0) { return; } __ZN10ime_pinyin12MatrixSearch12reset_searchEv($0) | 0; return; } function _im_get_sps_str($decoded_len) { $decoded_len = $decoded_len | 0; var $0 = 0, $retval_0 = 0; $0 = HEAP32[10830] | 0; if (($0 | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $retval_0 = __ZN10ime_pinyin12MatrixSearch9get_pystrEPj($0, $decoded_len) | 0; return $retval_0 | 0; } function _im_get_candidate($cand_id, $cand_str, $max_len) { $cand_id = $cand_id | 0; $cand_str = $cand_str | 0; $max_len = $max_len | 0; var $0 = 0, $retval_0 = 0; $0 = HEAP32[10830] | 0; if (($0 | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $retval_0 = __ZN10ime_pinyin12MatrixSearch13get_candidateEjPtj($0, $cand_id, $cand_str, $max_len) | 0; return $retval_0 | 0; } function _toUTF8($src, $length) { $src = $src | 0; $length = $length | 0; var $utf16Start = 0, $utf8Start = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16 | 0; $utf16Start = sp | 0; $utf8Start = sp + 8 | 0; HEAP32[$utf16Start >> 2] = $src; HEAP32[$utf8Start >> 2] = 43328; _ConvertUTF16toUTF8($utf16Start, $src + ($length << 1) | 0, $utf8Start, 44352, 0) | 0; STACKTOP = sp; return 43328 | 0; } function _toUTF16($src, $length) { $src = $src | 0; $length = $length | 0; var $utf8Start = 0, $utf16Start = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16 | 0; $utf8Start = sp | 0; $utf16Start = sp + 8 | 0; HEAP32[$utf8Start >> 2] = $src; HEAP32[$utf16Start >> 2] = 44352; _ConvertUTF8toUTF16($utf8Start, $src + $length | 0, $utf16Start, 46400, 0) | 0; STACKTOP = sp; return 44352 | 0; } function _im_get_candidate_char($cand_id) { $cand_id = $cand_id | 0; var $0 = 0, $arraydecay = 0, $retval_0 = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 128 | 0; $0 = HEAP32[10830] | 0; if (($0 | 0) == 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } $arraydecay = sp | 0; __ZN10ime_pinyin12MatrixSearch13get_candidateEjPtj($0, $cand_id, $arraydecay, 64) | 0; _toUTF8($arraydecay, 64) | 0; $retval_0 = 43328; STACKTOP = sp; return $retval_0 | 0; } function _im_get_spl_start() { var $0 = 0, $retval_0 = 0; $0 = HEAP32[10830] | 0; if (($0 | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $retval_0 = __ZN10ime_pinyin12MatrixSearch13get_spl_startERPKt($0, 11272) | 0; return $retval_0 | 0; } function _im_choose($choice_id) { $choice_id = $choice_id | 0; var $0 = 0, $retval_0 = 0; $0 = HEAP32[10830] | 0; if (($0 | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $retval_0 = __ZN10ime_pinyin12MatrixSearch6chooseEj($0, $choice_id) | 0; return $retval_0 | 0; } function _im_cancel_last_choice() { var $0 = 0, $retval_0 = 0; $0 = HEAP32[10830] | 0; if (($0 | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $retval_0 = __ZN10ime_pinyin12MatrixSearch18cancel_last_choiceEv($0) | 0; return $retval_0 | 0; } function _im_get_fixed_len() { var $0 = 0, $retval_0 = 0; $0 = HEAP32[10830] | 0; if (($0 | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $retval_0 = __ZN10ime_pinyin12MatrixSearch12get_fixedlenEv($0) | 0; return $retval_0 | 0; } function _im_get_predicts_utf8($buf, $pre_buf) { $buf = $buf | 0; $pre_buf = $pre_buf | 0; var $call5 = 0, $idx_09 = 0, $arraydecay = 0, $inc = 0, $retval_0 = 0; if (($buf | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } _toUTF16($buf, 64) | 0; _utf16_strlen(44352) | 0; $call5 = __ZN10ime_pinyin12MatrixSearch12get_predictsEPKtPA8_tj(HEAP32[10830] | 0, 44352, 35280, 500) | 0; HEAP32[$pre_buf >> 2] = 11280; $idx_09 = 0; while (1) { $arraydecay = (HEAP32[$pre_buf >> 2] | 0) + ($idx_09 * 48 | 0) | 0; _toUTF8(35280 + ($idx_09 << 4) | 0, 8) | 0; _strcpy($arraydecay | 0, 43328 | 0) | 0; $inc = $idx_09 + 1 | 0; if ($inc >>> 0 < 500) { $idx_09 = $inc; } else { $retval_0 = $call5; break; } } return $retval_0 | 0; } function _im_get_predicts($his_buf, $pre_buf) { $his_buf = $his_buf | 0; $pre_buf = $pre_buf | 0; var $retval_0 = 0; if (($his_buf | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } _utf16_strlen($his_buf) | 0; HEAP32[$pre_buf >> 2] = 35280; $retval_0 = __ZN10ime_pinyin12MatrixSearch12get_predictsEPKtPA8_tj(HEAP32[10830] | 0, $his_buf, 35280, 500) | 0; return $retval_0 | 0; } function _im_enable_shm_as_szm($enable) { $enable = $enable | 0; __ZN10ime_pinyin12SpellingTrie14szm_enable_shmEb(__ZN10ime_pinyin12SpellingTrie12get_instanceEv() | 0, $enable); return; } function _im_enable_ym_as_szm($enable) { $enable = $enable | 0; __ZN10ime_pinyin12SpellingTrie13szm_enable_ymEb(__ZN10ime_pinyin12SpellingTrie12get_instanceEv() | 0, $enable); return; } function __ZN10ime_pinyin19cmp_lemma_entry_hzsEPKvS1_($p1, $p2) { $p1 = $p1 | 0; $p2 = $p2 | 0; var $arraydecay = 0, $call = 0, $arraydecay2 = 0, $call3 = 0, $retval_0 = 0; $arraydecay = $p1 + 8 | 0; $call = _utf16_strlen($arraydecay) | 0; $arraydecay2 = $p2 + 8 | 0; $call3 = _utf16_strlen($arraydecay2) | 0; if ($call >>> 0 < $call3 >>> 0) { $retval_0 = -1; return $retval_0 | 0; } if ($call >>> 0 > $call3 >>> 0) { $retval_0 = 1; return $retval_0 | 0; } $retval_0 = _utf16_strcmp($arraydecay, $arraydecay2) | 0; return $retval_0 | 0; } function __ZN10ime_pinyin10compare_pyEPKvS1_($p1, $p2) { $p1 = $p1 | 0; $p2 = $p2 | 0; var $call = 0, $retval_0 = 0; $call = _utf16_strcmp($p1 + 42 | 0, $p2 + 42 | 0) | 0; if (($call | 0) != 0) { $retval_0 = $call; return $retval_0 | 0; } $retval_0 = ~~+HEAPF32[$p2 + 120 >> 2] - ~~+HEAPF32[$p1 + 120 >> 2] | 0; return $retval_0 | 0; } function __ZN10ime_pinyin22cmp_lemma_entry_hzspysEPKvS1_($p1, $p2) { $p1 = $p1 | 0; $p2 = $p2 | 0; var $arraydecay = 0, $call = 0, $arraydecay2 = 0, $call3 = 0, $call11 = 0, $retval_0 = 0; $arraydecay = $p1 + 8 | 0; $call = _utf16_strlen($arraydecay) | 0; $arraydecay2 = $p2 + 8 | 0; $call3 = _utf16_strlen($arraydecay2) | 0; if ($call >>> 0 < $call3 >>> 0) { $retval_0 = -1; return $retval_0 | 0; } if ($call >>> 0 > $call3 >>> 0) { $retval_0 = 1; return $retval_0 | 0; } $call11 = _utf16_strcmp($arraydecay, $arraydecay2) | 0; if (($call11 | 0) != 0) { $retval_0 = $call11; return $retval_0 | 0; } $retval_0 = _utf16_strcmp($p1 + 42 | 0, $p2 + 42 | 0) | 0; return $retval_0 | 0; } function __ZN10ime_pinyin14compare_splid2EPKvS1_($p1, $p2) { $p1 = $p1 | 0; $p2 = $p2 | 0; return _utf16_strcmp($p1 + 42 | 0, $p2 + 42 | 0) | 0; } function __ZN10ime_pinyin11DictBuilderC2Ev($this) { $this = $this | 0; _memset($this | 0, 0, 60); return; } function __ZN10ime_pinyin11DictBuilderD2Ev($this) { $this = $this | 0; __ZN10ime_pinyin11DictBuilder13free_resourceEv($this); return; } function __ZN10ime_pinyin11DictBuilder13free_resourceEv($this) { $this = $this | 0; var $lemma_arr_ = 0, $0 = 0, $scis_ = 0, $2 = 0, $lma_nodes_le0_ = 0, $4 = 0, $6 = 0, $8 = 0, $spl_table_ = 0, $10 = 0, $spl_parser_ = 0, $14 = 0; $lemma_arr_ = $this | 0; $0 = HEAP32[$lemma_arr_ >> 2] | 0; if (($0 | 0) != 0) { __ZdaPv($0); } $scis_ = $this + 8 | 0; $2 = HEAP32[$scis_ >> 2] | 0; if (($2 | 0) != 0) { __ZdaPv($2); } $lma_nodes_le0_ = $this + 16 | 0; $4 = HEAP32[$lma_nodes_le0_ >> 2] | 0; if (($4 | 0) != 0) { __ZdaPv($4); } $6 = HEAP32[$this + 20 >> 2] | 0; if (($6 | 0) != 0) { __ZdaPv($6); } $8 = HEAP32[$this + 32 >> 2] | 0; if (($8 | 0) != 0) { __ZdaPv($8); } $spl_table_ = $this + 52 | 0; $10 = HEAP32[$spl_table_ >> 2] | 0; if (($10 | 0) != 0) { __ZN10ime_pinyin13SpellingTableD2Ev($10); __ZdlPv($10 | 0); } $spl_parser_ = $this + 56 | 0; $14 = HEAP32[$spl_parser_ >> 2] | 0; if (($14 | 0) != 0) { __ZdlPv($14); } HEAP32[$lemma_arr_ >> 2] = 0; HEAP32[$scis_ >> 2] = 0; HEAP32[$spl_table_ >> 2] = 0; HEAP32[$spl_parser_ >> 2] = 0; HEAP32[$this + 4 >> 2] = 0; _memset($lma_nodes_le0_ | 0, 0, 28); return; } function __ZN10ime_pinyin11DictBuilder14alloc_resourceEj($this, $lma_num) { $this = $this | 0; $lma_num = $lma_num | 0; var $lemma_num_ = 0, $0$0 = 0, $lemma_arr_ = 0, $top_lmas_ = 0, $mul = 0, $scis_num_ = 0, $7$0 = 0, $scis_ = 0, $lma_nodes_le0_ = 0, $14$0 = 0, $lma_nodes_ge1_ = 0, $20$0 = 0, $homo_idx_buf_ = 0, $25 = 0, $spl_table_ = 0, $call13 = 0, $26 = 0, $27 = 0, $53 = 0, $retval_0 = 0; if (($lma_num | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } __ZN10ime_pinyin11DictBuilder13free_resourceEv($this); $lemma_num_ = $this + 4 | 0; HEAP32[$lemma_num_ >> 2] = $lma_num; $0$0 = _llvm_umul_with_overflow_i32($lma_num | 0, 124) | 0; $lemma_arr_ = $this | 0; HEAP32[$lemma_arr_ >> 2] = __Znaj(tempRet0 ? -1 : $0$0) | 0; HEAP32[$this + 48 >> 2] = 0; $top_lmas_ = $this + 44 | 0; HEAP32[$top_lmas_ >> 2] = __Znaj(1240) | 0; $mul = HEAP32[$lemma_num_ >> 2] << 3; $scis_num_ = $this + 12 | 0; HEAP32[$scis_num_ >> 2] = $mul; $7$0 = _llvm_umul_with_overflow_i32($mul | 0, 8) | 0; $scis_ = $this + 8 | 0; HEAP32[$scis_ >> 2] = __Znaj(tempRet0 ? -1 : $7$0) | 0; HEAP32[$this + 24 >> 2] = 0; $lma_nodes_le0_ = $this + 16 | 0; HEAP32[$lma_nodes_le0_ >> 2] = __Znaj(7728) | 0; HEAP32[$this + 28 >> 2] = 0; $14$0 = _llvm_umul_with_overflow_i32(HEAP32[$lemma_num_ >> 2] | 0, 10) | 0; $lma_nodes_ge1_ = $this + 20 | 0; HEAP32[$lma_nodes_ge1_ >> 2] = __Znaj(tempRet0 ? -1 : $14$0) | 0; $20$0 = _llvm_umul_with_overflow_i32(HEAP32[$lemma_num_ >> 2] | 0, 4) | 0; $homo_idx_buf_ = $this + 32 | 0; HEAP32[$homo_idx_buf_ >> 2] = __Znaj(tempRet0 ? -1 : $20$0) | 0; $25 = __Znwj(56) | 0; __ZN10ime_pinyin13SpellingTableC2Ev($25); $spl_table_ = $this + 52 | 0; HEAP32[$spl_table_ >> 2] = $25; $call13 = __Znwj(4) | 0; $26 = $call13; __ZN10ime_pinyin14SpellingParserC2Ev($26); HEAP32[$this + 56 >> 2] = $26; $27 = HEAP32[$lemma_arr_ >> 2] | 0; do { if (($27 | 0) != 0) { if ((HEAP32[$top_lmas_ >> 2] | 0) == 0) { break; } if ((HEAP32[$scis_ >> 2] | 0) == 0) { break; } if ((HEAP32[$spl_table_ >> 2] | 0) == 0 | ($call13 | 0) == 0) { break; } if ((HEAP32[$lma_nodes_le0_ >> 2] | 0) == 0) { break; } if ((HEAP32[$lma_nodes_ge1_ >> 2] | 0) == 0) { break; } if ((HEAP32[$homo_idx_buf_ >> 2] | 0) == 0) { break; } _memset($27 | 0, 0, (HEAP32[$lemma_num_ >> 2] | 0) * 124 | 0 | 0); _memset(HEAP32[$scis_ >> 2] | 0, 0, HEAP32[$scis_num_ >> 2] << 3 | 0); _memset(HEAP32[$lma_nodes_le0_ >> 2] | 0, 0, 7728); _memset(HEAP32[$lma_nodes_ge1_ >> 2] | 0, 0, (HEAP32[$lemma_num_ >> 2] | 0) * 10 | 0 | 0); _memset(HEAP32[$homo_idx_buf_ >> 2] | 0, 0, HEAP32[$lemma_num_ >> 2] << 2 | 0); $53 = HEAP32[$spl_table_ >> 2] | 0; __ZN10ime_pinyin13SpellingTable10init_tableEjjb($53, 6, 2e3, 1) | 0; $retval_0 = 1; return $retval_0 | 0; } } while (0); __ZN10ime_pinyin11DictBuilder13free_resourceEv($this); $retval_0 = 0; return $retval_0 | 0; } function __ZN10ime_pinyin11DictBuilder17read_valid_hanzisEPKcPj($this, $fn_validhzs, $num) { $this = $this | 0; $fn_validhzs = $fn_validhzs | 0; $num = $num | 0; var $utf16header = 0, $call = 0, $cmp7 = 0, $div = 0, $sub = 0, $2$0 = 0, $call16 = 0, $call22 = 0, $cmp23 = 0, $retval_0 = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 8 | 0; $utf16header = sp | 0; if (($fn_validhzs | 0) == 0 | ($num | 0) == 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } HEAP32[$num >> 2] = 0; $call = _fopen($fn_validhzs | 0, 4440) | 0; if (($call | 0) == 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } $cmp7 = (_fread($utf16header | 0, 2, 1, $call | 0) | 0) == 1; if (!($cmp7 & (HEAP16[$utf16header >> 1] | 0) == -257)) { _fclose($call | 0) | 0; $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } _fseek($call | 0, 0, 2) | 0; $div = (_ftell($call | 0) | 0) >>> 1; HEAP32[$num >> 2] = $div; if (($div | 0) == 0) { ___assert_func(4408, 240, 7456, 3040); return 0; } $sub = $div - 1 | 0; HEAP32[$num >> 2] = $sub; $2$0 = _llvm_umul_with_overflow_i32($sub | 0, 2) | 0; $call16 = __Znaj(tempRet0 ? -1 : $2$0) | 0; if (($call16 | 0) == 0) { _fclose($call | 0) | 0; $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } _fseek($call | 0, 2, 0) | 0; $call22 = _fread($call16 | 0, 2, HEAP32[$num >> 2] | 0, $call | 0) | 0; $cmp23 = ($call22 | 0) == (HEAP32[$num >> 2] | 0); _fclose($call | 0) | 0; if ($cmp23) { __ZN10ime_pinyin7myqsortEPvjjPFiPKvS2_E($call16, HEAP32[$num >> 2] | 0, 2, 24); $retval_0 = $call16; STACKTOP = sp; return $retval_0 | 0; } else { __ZdaPv($call16); $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } return 0; } function __ZN10ime_pinyin11DictBuilder19format_spelling_strEPc($this, $spl_str) { $this = $this | 0; $spl_str = $spl_str | 0; var $0 = 0, $1 = 0, $arrayidx21 = 0, $pos_020 = 0, $4 = 0; if (($spl_str | 0) == 0) { return; } $0 = HEAP8[$spl_str] | 0; if ($0 << 24 >> 24 == 0) { return; } else { $pos_020 = 0; $arrayidx21 = $spl_str; $1 = $0; } do { if (($1 - 97 & 255) < 26) { HEAP8[$arrayidx21] = $1 - 32 & 255; } do { if ($pos_020 << 16 >> 16 == 1) { if ((HEAP8[$arrayidx21] | 0) != 72) { break; } $4 = HEAP8[$spl_str] | 0; if (!(($4 << 24 >> 24 | 0) == 67 | ($4 << 24 >> 24 | 0) == 83 | ($4 << 24 >> 24 | 0) == 90)) { break; } HEAP8[$arrayidx21] = 104; } } while (0); $pos_020 = $pos_020 + 1 & 65535; $arrayidx21 = $spl_str + ($pos_020 & 65535) | 0; $1 = HEAP8[$arrayidx21] | 0; } while ($1 << 24 >> 24 != 0); return; } function __ZN10ime_pinyin11DictBuilder18str_in_hanzis_listEPKtjS2_j($this, $hzs, $hzs_len, $str, $str_len) { $this = $this | 0; $hzs = $hzs | 0; $hzs_len = $hzs_len | 0; $str = $str | 0; $str_len = $str_len | 0; var $pos_0 = 0, $retval_0 = 0, label = 0; if (($hzs | 0) == 0 | ($str | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } else { $pos_0 = 0; } while (1) { if ($pos_0 >>> 0 >= $str_len >>> 0) { $retval_0 = 1; label = 227; break; } if (__ZN10ime_pinyin11DictBuilder17hz_in_hanzis_listEPKtjt(0, $hzs, $hzs_len, HEAP16[$str + ($pos_0 << 1) >> 1] | 0) | 0) { $pos_0 = $pos_0 + 1 | 0; } else { $retval_0 = 0; label = 226; break; } } if ((label | 0) == 226) { return $retval_0 | 0; } else if ((label | 0) == 227) { return $retval_0 | 0; } return 0; } function __ZN10ime_pinyin11DictBuilder17sort_lemmas_by_hzEv($this) { $this = $this | 0; var $lemma_arr_ = 0, $0 = 0, $lemma_num_ = 0, $1 = 0, $i_09 = 0, $idx_max_08 = 0, $5 = 0, $inc23 = 0, $phitmp = 0, $retval_0 = 0; $lemma_arr_ = $this | 0; $0 = HEAP32[$lemma_arr_ >> 2] | 0; if (($0 | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $lemma_num_ = $this + 4 | 0; $1 = HEAP32[$lemma_num_ >> 2] | 0; if (($1 | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } __ZN10ime_pinyin7myqsortEPvjjPFiPKvS2_E($0, $1, 124, 22); HEAP32[(HEAP32[$lemma_arr_ >> 2] | 0) + 4 >> 2] = 1; if ((HEAP32[$lemma_num_ >> 2] | 0) >>> 0 > 1) { $idx_max_08 = 2; $i_09 = 1; } else { $retval_0 = 2; return $retval_0 | 0; } while (1) { $5 = HEAP32[$lemma_arr_ >> 2] | 0; _utf16_strcmp($5 + ($i_09 * 124 | 0) + 8 | 0, $5 + (($i_09 - 1 | 0) * 124 | 0) + 8 | 0) | 0; HEAP32[(HEAP32[$lemma_arr_ >> 2] | 0) + ($i_09 * 124 | 0) + 4 >> 2] = $idx_max_08; $inc23 = $i_09 + 1 | 0; $phitmp = $idx_max_08 + 1 | 0; if ($inc23 >>> 0 < (HEAP32[$lemma_num_ >> 2] | 0) >>> 0) { $idx_max_08 = $phitmp; $i_09 = $inc23; } else { $retval_0 = $phitmp; break; } } return $retval_0 | 0; } function __ZN10ime_pinyin11DictBuilder17hz_in_hanzis_listEPKtjt($this, $hzs, $hzs_len, $hz) { $this = $this | 0; $hzs = $hzs | 0; $hzs_len = $hzs_len | 0; $hz = $hz | 0; var $hz_addr = 0, $call = 0, $retval_0 = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 8 | 0; $hz_addr = sp | 0; HEAP16[$hz_addr >> 1] = $hz; if (($hzs | 0) == 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } $call = __ZN10ime_pinyin9mybsearchEPKvS1_jjPFiS1_S1_E($hz_addr, $hzs, $hzs_len, 2, 24) | 0; if (($call | 0) == 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } if ((HEAP16[$call >> 1] | 0) == (HEAP16[$hz_addr >> 1] | 0)) { $retval_0 = 1; STACKTOP = sp; return $retval_0 | 0; } else { ___assert_func(4408, 273, 7536, 2128); return 0; } return 0; } function __ZN10ime_pinyin11DictBuilder14get_top_lemmasEv($this) { $this = $this | 0; var $top_lmas_num_ = 0, $lemma_arr_ = 0, $lemma_num_ = 0, $top_lmas_ = 0, $top_lmas_13 = 0, $pos_016 = 0, $2 = 0, $5 = 0, $6 = 0, $7 = 0, $arrayidx11 = 0, $9 = 0, $cmp19 = 0, $move_pos_0_in = 0, $move_pos_0 = 0, $12 = 0, $sub30 = 0, $13 = 0, $14 = 0, $21 = 0, $22 = 0, $23 = 0, $24 = 0, $inc = 0, label = 0; $top_lmas_num_ = $this + 48 | 0; HEAP32[$top_lmas_num_ >> 2] = 0; $lemma_arr_ = $this | 0; if ((HEAP32[$lemma_arr_ >> 2] | 0) == 0) { return; } $lemma_num_ = $this + 4 | 0; if ((HEAP32[$lemma_num_ >> 2] | 0) == 0) { return; } $top_lmas_ = $this + 44 | 0; $top_lmas_13 = $this + 44 | 0; $pos_016 = 0; L275 : while (1) { $2 = HEAP32[$top_lmas_num_ >> 2] | 0; do { if (($2 | 0) == 0) { $5 = HEAP32[$top_lmas_ >> 2] | 0; $6 = (HEAP32[$lemma_arr_ >> 2] | 0) + ($pos_016 * 124 | 0) | 0; _memcpy($5 | 0, $6 | 0, 124) | 0; HEAP32[$top_lmas_num_ >> 2] = 1; } else { $7 = HEAP32[$lemma_arr_ >> 2] | 0; $arrayidx11 = $7 + ($pos_016 * 124 | 0) | 0; $9 = HEAP32[$top_lmas_13 >> 2] | 0; $cmp19 = $2 >>> 0 < 10; if (+HEAPF32[$7 + ($pos_016 * 124 | 0) + 120 >> 2] <= +HEAPF32[$9 + (($2 - 1 | 0) * 124 | 0) + 120 >> 2]) { if (!$cmp19) { break; } $23 = $9 + ($2 * 124 | 0) | 0; $24 = $arrayidx11; _memcpy($23 | 0, $24 | 0, 124) | 0; HEAP32[$top_lmas_num_ >> 2] = (HEAP32[$top_lmas_num_ >> 2] | 0) + 1; break; } if ($cmp19) { HEAP32[$top_lmas_num_ >> 2] = $2 + 1; } $move_pos_0_in = HEAP32[$top_lmas_num_ >> 2] | 0; while (1) { $move_pos_0 = $move_pos_0_in - 1 | 0; if (($move_pos_0 | 0) == 0) { label = 258; break L275; } $12 = HEAP32[$top_lmas_13 >> 2] | 0; $sub30 = $move_pos_0_in - 2 | 0; $13 = $12 + ($move_pos_0 * 124 | 0) | 0; $14 = $12 + ($sub30 * 124 | 0) | 0; _memcpy($13 | 0, $14 | 0, 124) | 0; if (($sub30 | 0) == 0) { break; } if (+HEAPF32[(HEAP32[$top_lmas_13 >> 2] | 0) + (($move_pos_0_in - 3 | 0) * 124 | 0) + 120 >> 2] > +HEAPF32[(HEAP32[$lemma_arr_ >> 2] | 0) + ($pos_016 * 124 | 0) + 120 >> 2]) { break; } else { $move_pos_0_in = $move_pos_0; } } $21 = (HEAP32[$top_lmas_13 >> 2] | 0) + ($sub30 * 124 | 0) | 0; $22 = (HEAP32[$lemma_arr_ >> 2] | 0) + ($pos_016 * 124 | 0) | 0; _memcpy($21 | 0, $22 | 0, 124) | 0; } } while (0); $inc = $pos_016 + 1 | 0; if ($inc >>> 0 < (HEAP32[$lemma_num_ >> 2] | 0) >>> 0) { $pos_016 = $inc; } else { label = 264; break; } } if ((label | 0) == 258) { ___assert_func(4408, 315, 7728, 1616); } else if ((label | 0) == 264) { return; } } function __ZN10ime_pinyin11DictBuilder13read_raw_dictEPKcS2_j($this, $fn_raw, $fn_validhzs, $max_item) { $this = $this | 0; $fn_raw = $fn_raw | 0; $fn_validhzs = $fn_validhzs | 0; $max_item = $max_item | 0; var $utf16_reader = 0, $read_buf = 0, $valid_hzs_num = 0, $token_size = 0, $to_tokenize = 0, $call11 = 0, $arraydecay = 0, $lemma_arr_ = 0, $cmp66 = 0, $spl_table_ = 0, $i_045 = 0, $call19 = 0, $call27 = 0, $arraydecay35 = 0, $call41 = 0, $call49 = 0.0, $call61 = 0, $call65 = 0, $8 = 0, $9 = 0, $hz_pos_0 = 0, $call95 = 0, $17 = 0, $spelling_not_support_0_off0 = 0, $i_1 = 0, $inc143 = 0, $lemma_num_0 = 0, $retval_0 = 0, $retval_1 = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 1072 | 0; $utf16_reader = sp | 0; $read_buf = sp + 24 | 0; $valid_hzs_num = sp + 1048 | 0; $token_size = sp + 1056 | 0; $to_tokenize = sp + 1064 | 0; if (($fn_raw | 0) == 0) { $retval_1 = 0; STACKTOP = sp; return $retval_1 | 0; } __ZN10ime_pinyin11Utf16ReaderC2Ev($utf16_reader); L301 : do { if (__ZN10ime_pinyin11Utf16Reader4openEPKcj($utf16_reader, $fn_raw, 5120) | 0) { if (!(__ZN10ime_pinyin11DictBuilder14alloc_resourceEj($this, 24e4) | 0)) { __ZN10ime_pinyin11Utf16Reader5closeEv($utf16_reader) | 0; } HEAP32[$valid_hzs_num >> 2] = 0; $call11 = __ZN10ime_pinyin11DictBuilder17read_valid_hanzisEPKcPj(0, $fn_validhzs, $valid_hzs_num) | 0; L308 : do { if (($max_item | 0) == 0) { $lemma_num_0 = 24e4; } else { $arraydecay = $read_buf | 0; $lemma_arr_ = $this | 0; $cmp66 = ($call11 | 0) == 0; $spl_table_ = $this + 52 | 0; $i_045 = 0; L310 : while (1) { if ((__ZN10ime_pinyin11Utf16Reader8readlineEPtj($utf16_reader, $arraydecay, 512) | 0) == 0) { $lemma_num_0 = $i_045; break L308; } HEAP32[$to_tokenize >> 2] = $arraydecay; $call19 = _utf16_strtok($arraydecay, $token_size, $to_tokenize) | 0; if (($call19 | 0) == 0) { label = 284; break; } $call27 = _utf16_strlen($call19) | 0; L317 : do { if ($call27 >>> 0 > 8) { $i_1 = $i_045 - 1 | 0; } else { if ($call27 >>> 0 > 4) { $i_1 = $i_045 - 1 | 0; break; } $arraydecay35 = (HEAP32[$lemma_arr_ >> 2] | 0) + ($i_045 * 124 | 0) + 8 | 0; _utf16_strcpy($arraydecay35, $call19) | 0; HEAP8[(HEAP32[$lemma_arr_ >> 2] | 0) + ($i_045 * 124 | 0) + 116 | 0] = HEAP32[$token_size >> 2] & 255; $call41 = _utf16_strtok(HEAP32[$to_tokenize >> 2] | 0, $token_size, $to_tokenize) | 0; if (($call41 | 0) == 0) { label = 294; break L310; } $call49 = +_utf16_atof($call41); HEAPF32[(HEAP32[$lemma_arr_ >> 2] | 0) + ($i_045 * 124 | 0) + 120 >> 2] = $call49; do { if ($call27 >>> 0 > 1) { if (+HEAPF32[(HEAP32[$lemma_arr_ >> 2] | 0) + ($i_045 * 124 | 0) + 120 >> 2] >= 60.0) { break; } $i_1 = $i_045 - 1 | 0; break L317; } } while (0); $call61 = _utf16_strtok(HEAP32[$to_tokenize >> 2] | 0, $token_size, $to_tokenize) | 0; if (($call61 | 0) == 0) { label = 302; break L310; } $call65 = _utf16_atoi($call61) | 0; do { if ($cmp66) { label = 307; } else { $8 = HEAP32[$valid_hzs_num >> 2] | 0; if (($8 | 0) == 0) { label = 307; break; } $9 = HEAP32[$lemma_arr_ >> 2] | 0; if (__ZN10ime_pinyin11DictBuilder18str_in_hanzis_listEPKtjS2_j(0, $call11, $8, $9 + ($i_045 * 124 | 0) + 8 | 0, HEAPU8[$9 + ($i_045 * 124 | 0) + 116 | 0] | 0) | 0) { $hz_pos_0 = 0; break; } $i_1 = $i_045 - 1 | 0; break L317; } } while (0); do { if ((label | 0) == 307) { label = 0; if (($call65 | 0) == 0) { $hz_pos_0 = 0; break; } $i_1 = $i_045 - 1 | 0; break L317; } } while (0); while (1) { if ($hz_pos_0 >>> 0 >= (HEAPU8[(HEAP32[$lemma_arr_ >> 2] | 0) + ($i_045 * 124 | 0) + 116 | 0] | 0) >>> 0) { $spelling_not_support_0_off0 = 1; break; } $call95 = _utf16_strtok(HEAP32[$to_tokenize >> 2] | 0, $token_size, $to_tokenize) | 0; if (($call95 | 0) == 0) { label = 315; break L310; } if ((_utf16_strlen($call95) | 0) >>> 0 >= 7) { label = 319; break L310; } _utf16_strcpy_tochar((HEAP32[$lemma_arr_ >> 2] | 0) + ($i_045 * 124 | 0) + 60 + ($hz_pos_0 * 7 | 0) | 0, $call95) | 0; __ZN10ime_pinyin11DictBuilder19format_spelling_strEPc(0, (HEAP32[$lemma_arr_ >> 2] | 0) + ($i_045 * 124 | 0) + 60 + ($hz_pos_0 * 7 | 0) | 0); $17 = HEAP32[$lemma_arr_ >> 2] | 0; if (__ZN10ime_pinyin13SpellingTable12put_spellingEPKcd(HEAP32[$spl_table_ >> 2] | 0, $17 + ($i_045 * 124 | 0) + 60 + ($hz_pos_0 * 7 | 0) | 0, +HEAPF32[$17 + ($i_045 * 124 | 0) + 120 >> 2]) | 0) { $hz_pos_0 = $hz_pos_0 + 1 | 0; } else { $spelling_not_support_0_off0 = 0; break; } } $i_1 = (($spelling_not_support_0_off0 & (_utf16_strtok(HEAP32[$to_tokenize >> 2] | 0, $token_size, $to_tokenize) | 0) == 0 ^ 1) << 31 >> 31) + $i_045 | 0; } } while (0); $inc143 = $i_1 + 1 | 0; if ($inc143 >>> 0 < $max_item >>> 0) { $i_045 = $inc143; } else { $lemma_num_0 = 24e4; break L308; } } if ((label | 0) == 294) { __ZN10ime_pinyin11DictBuilder13free_resourceEv($this); __ZN10ime_pinyin11Utf16Reader5closeEv($utf16_reader) | 0; $retval_0 = 0; break L301; } else if ((label | 0) == 284) { __ZN10ime_pinyin11DictBuilder13free_resourceEv($this); __ZN10ime_pinyin11Utf16Reader5closeEv($utf16_reader) | 0; $retval_0 = 0; break L301; } else if ((label | 0) == 302) { ___assert_func(4408, 448, 7776, 1344); return 0; } else if ((label | 0) == 315) { __ZN10ime_pinyin11DictBuilder13free_resourceEv($this); __ZN10ime_pinyin11Utf16Reader5closeEv($utf16_reader) | 0; $retval_0 = 0; break L301; } else if ((label | 0) == 319) { ___assert_func(4408, 475, 7776, 1096); return 0; } } } while (0); if (($call11 | 0) != 0) { __ZdaPv($call11); } __ZN10ime_pinyin11Utf16Reader5closeEv($utf16_reader) | 0; $retval_0 = $lemma_num_0; } else { $retval_0 = 0; } } while (0); __ZN10ime_pinyin11Utf16ReaderD2Ev($utf16_reader); $retval_1 = $retval_0; STACKTOP = sp; return $retval_1 | 0; } function __ZN10ime_pinyin11DictBuilder10build_dictEPKcS2_PNS_8DictTrieE($this, $fn_raw, $fn_validhzs, $dict_trie) { $this = $this | 0; $fn_raw = $fn_raw | 0; $fn_validhzs = $fn_validhzs | 0; $dict_trie = $dict_trie | 0; var $spl_item_size = 0, $spl_num = 0, $is_pre = 0, $call = 0, $lemma_num_ = 0, $spl_table_ = 0, $call7 = 0, $call11 = 0, $1 = 0, $2 = 0, $call13 = 0.0, $lemma_arr_ = 0, $spl_parser_ = 0, $arraydecay34 = 0, $arraydecay35 = 0, $i_049 = 0, $hz_pos_047 = 0, $8 = 0, $arraydecay = 0, $scis_num_ = 0, $17 = 0, $lemma_arr_63 = 0, $call69 = 0, $23 = 0, $24 = 0, $lma_nds_used_num_le0_ = 0, $lma_nodes_le0_ = 0, $call80 = 0, $34$0 = 0, $root_ = 0, $lma_nds_used_num_ge1_ = 0, $40$0 = 0, $nodes_ge1_ = 0, $homo_idx_num_eq1_ = 0, $homo_idx_num_gt1_ = 0, $top_lmas_num_ = 0, $add89 = 0, $mul = 0, $call90 = 0, $lma_idx_buf_ = 0, $53 = 0, $55 = 0, $mul109 = 0, $58 = 0, $60 = 0, $mul112 = 0, $homo_idx_buf_ = 0, $add116_lcssa = 0, $top_lmas_ = 0, $pos_043 = 0, $inc123 = 0, $add116 = 0, $pos125_040 = 0, $retval_0 = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 40 | 0; $spl_item_size = sp | 0; $spl_num = sp + 8 | 0; $is_pre = sp + 32 | 0; if (($fn_raw | 0) == 0 | ($dict_trie | 0) == 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } $call = __ZN10ime_pinyin11DictBuilder13read_raw_dictEPKcS2_j($this, $fn_raw, $fn_validhzs, 24e4) | 0; $lemma_num_ = $this + 4 | 0; HEAP32[$lemma_num_ >> 2] = $call; if (($call | 0) == 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } $spl_table_ = $this + 52 | 0; $call7 = __ZN10ime_pinyin13SpellingTable7arrangeEPjS1_(HEAP32[$spl_table_ >> 2] | 0, $spl_item_size, $spl_num) | 0; if (($call7 | 0) == 0) { __ZN10ime_pinyin11DictBuilder13free_resourceEv($this); $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } $call11 = __ZN10ime_pinyin12SpellingTrie12get_instanceEv() | 0; $1 = HEAP32[$spl_item_size >> 2] | 0; $2 = HEAP32[$spl_num >> 2] | 0; $call13 = +__ZN10ime_pinyin13SpellingTable19get_score_amplifierEv(HEAP32[$spl_table_ >> 2] | 0); if (!(__ZN10ime_pinyin12SpellingTrie9constructEPKcjjfh($call11, $call7, $1, $2, $call13, __ZN10ime_pinyin13SpellingTable17get_average_scoreEv(HEAP32[$spl_table_ >> 2] | 0) | 0) | 0)) { __ZN10ime_pinyin11DictBuilder13free_resourceEv($this); $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } L386 : do { if ((HEAP32[$lemma_num_ >> 2] | 0) != 0) { $lemma_arr_ = $this | 0; $spl_parser_ = $this + 56 | 0; $arraydecay34 = sp + 16 | 0; $arraydecay35 = sp + 24 | 0; $i_049 = 0; L388 : while (1) { if ((HEAP8[(HEAP32[$lemma_arr_ >> 2] | 0) + ($i_049 * 124 | 0) + 116 | 0] | 0) != 0) { $hz_pos_047 = 0; do { HEAP8[$is_pre] = 1; $8 = HEAP32[$spl_parser_ >> 2] | 0; $arraydecay = (HEAP32[$lemma_arr_ >> 2] | 0) + ($i_049 * 124 | 0) + 60 + ($hz_pos_047 * 7 | 0) | 0; if ((__ZN10ime_pinyin14SpellingParser14splstr_to_idxsEPKctPtS3_tRb($8, $arraydecay, (_strlen($arraydecay | 0) | 0) & 65535, $arraydecay34, $arraydecay35, 2, $is_pre) | 0) << 16 >> 16 != 1) { label = 346; break L388; } if (__ZNK10ime_pinyin12SpellingTrie10is_half_idEt($call11, HEAP16[$arraydecay34 >> 1] | 0) | 0) { if ((__ZNK10ime_pinyin12SpellingTrie12half_to_fullEtPt($call11, HEAP16[$arraydecay34 >> 1] | 0, $arraydecay34) | 0) << 16 >> 16 == 0) { label = 349; break L388; } } HEAP16[(HEAP32[$lemma_arr_ >> 2] | 0) + ($i_049 * 124 | 0) + 42 + ($hz_pos_047 << 1) >> 1] = HEAP16[$arraydecay34 >> 1] | 0; $hz_pos_047 = $hz_pos_047 + 1 | 0; } while ($hz_pos_047 >>> 0 < (HEAPU8[(HEAP32[$lemma_arr_ >> 2] | 0) + ($i_049 * 124 | 0) + 116 | 0] | 0) >>> 0); } $i_049 = $i_049 + 1 | 0; if ($i_049 >>> 0 >= (HEAP32[$lemma_num_ >> 2] | 0) >>> 0) { break L386; } } if ((label | 0) == 349) { ___assert_func(4408, 556, 7912, 752); return 0; } else if ((label | 0) == 346) { ___assert_func(4408, 552, 7912, 920); return 0; } } } while (0); __ZN10ime_pinyin11DictBuilder17sort_lemmas_by_hzEv($this) | 0; $scis_num_ = $this + 12 | 0; HEAP32[$scis_num_ >> 2] = __ZN10ime_pinyin11DictBuilder10build_scisEv($this) | 0; $17 = __Znwj(128) | 0; __ZN10ime_pinyin8DictListC2Ev($17); HEAP32[$dict_trie + 4 >> 2] = $17; $lemma_arr_63 = $this | 0; if (!(__ZN10ime_pinyin8DictList9init_listEPKNS_14SingleCharItemEjPKNS_10LemmaEntryEj($17, HEAP32[$this + 8 >> 2] | 0, HEAP32[$scis_num_ >> 2] | 0, HEAP32[$lemma_arr_63 >> 2] | 0, HEAP32[$lemma_num_ >> 2] | 0) | 0)) { ___assert_func(4408, 572, 7912, 600); return 0; } $call69 = __ZN10ime_pinyin5NGram12get_instanceEv() | 0; $23 = HEAP32[$lemma_arr_63 >> 2] | 0; $24 = HEAP32[$lemma_num_ >> 2] | 0; __ZN10ime_pinyin5NGram13build_unigramEPNS_10LemmaEntryEjj($call69, $23, $24, (HEAP32[$23 + (($24 - 1 | 0) * 124 | 0) + 4 >> 2] | 0) + 1 | 0) | 0; __ZN10ime_pinyin7myqsortEPvjjPFiPKvS2_E(HEAP32[$lemma_arr_63 >> 2] | 0, HEAP32[$lemma_num_ >> 2] | 0, 124, 6); __ZN10ime_pinyin11DictBuilder14get_top_lemmasEv($this); __ZN10ime_pinyin11DictBuilder9stat_initEv($this); $lma_nds_used_num_le0_ = $this + 24 | 0; HEAP32[$lma_nds_used_num_le0_ >> 2] = 1; $lma_nodes_le0_ = $this + 16 | 0; $call80 = __ZN10ime_pinyin11DictBuilder16construct_subsetEPvPNS_10LemmaEntryEjjj($this, HEAP32[$lma_nodes_le0_ >> 2] | 0, HEAP32[$lemma_arr_63 >> 2] | 0, 0, HEAP32[$lemma_num_ >> 2] | 0, 0) | 0; if (!$call80) { __ZN10ime_pinyin11DictBuilder13free_resourceEv($this); $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } $34$0 = _llvm_umul_with_overflow_i32(HEAP32[$lma_nds_used_num_le0_ >> 2] | 0, 16) | 0; $root_ = $dict_trie + 12 | 0; HEAP32[$root_ >> 2] = __Znaj(tempRet0 ? -1 : $34$0) | 0; $lma_nds_used_num_ge1_ = $this + 28 | 0; $40$0 = _llvm_umul_with_overflow_i32(HEAP32[$lma_nds_used_num_ge1_ >> 2] | 0, 10) | 0; $nodes_ge1_ = $dict_trie + 16 | 0; HEAP32[$nodes_ge1_ >> 2] = __Znaj(tempRet0 ? -1 : $40$0) | 0; $homo_idx_num_eq1_ = $this + 36 | 0; $homo_idx_num_gt1_ = $this + 40 | 0; $top_lmas_num_ = $this + 48 | 0; $add89 = (HEAP32[$homo_idx_num_gt1_ >> 2] | 0) + (HEAP32[$homo_idx_num_eq1_ >> 2] | 0) + (HEAP32[$top_lmas_num_ >> 2] | 0) | 0; $mul = $add89 * 3 | 0; $call90 = __Znaj($mul) | 0; $lma_idx_buf_ = $dict_trie + 32 | 0; HEAP32[$lma_idx_buf_ >> 2] = $call90; if ((HEAP32[$root_ >> 2] | 0) == 0) { ___assert_func(4408, 606, 7912, 4376); return 0; } if (($call90 | 0) == 0) { ___assert_func(4408, 607, 7912, 4256); return 0; } HEAP32[$dict_trie + 24 >> 2] = HEAP32[$lma_nds_used_num_le0_ >> 2]; HEAP32[$dict_trie + 28 >> 2] = HEAP32[$lma_nds_used_num_ge1_ >> 2]; HEAP32[$dict_trie + 36 >> 2] = $mul; HEAP32[$dict_trie + 44 >> 2] = HEAP32[$top_lmas_num_ >> 2]; $53 = HEAP32[$root_ >> 2] | 0; $55 = HEAP32[$lma_nodes_le0_ >> 2] | 0; $mul109 = HEAP32[$lma_nds_used_num_le0_ >> 2] << 4; _memcpy($53 | 0, $55 | 0, $mul109) | 0; $58 = HEAP32[$nodes_ge1_ >> 2] | 0; $60 = HEAP32[$this + 20 >> 2] | 0; $mul112 = (HEAP32[$lma_nds_used_num_ge1_ >> 2] | 0) * 10 | 0; _memcpy($58 | 0, $60 | 0, $mul112) | 0; if ((HEAP32[$homo_idx_num_gt1_ >> 2] | 0) == (-(HEAP32[$homo_idx_num_eq1_ >> 2] | 0) | 0)) { $add116_lcssa = 0; } else { $homo_idx_buf_ = $this + 32 | 0; $pos_043 = 0; while (1) { __ZN10ime_pinyin11DictBuilder13id_to_charbufEPhj(0, (HEAP32[$lma_idx_buf_ >> 2] | 0) + ($pos_043 * 3 | 0) | 0, HEAP32[(HEAP32[$homo_idx_buf_ >> 2] | 0) + ($pos_043 << 2) >> 2] | 0); $inc123 = $pos_043 + 1 | 0; $add116 = (HEAP32[$homo_idx_num_gt1_ >> 2] | 0) + (HEAP32[$homo_idx_num_eq1_ >> 2] | 0) | 0; if ($inc123 >>> 0 < $add116 >>> 0) { $pos_043 = $inc123; } else { $add116_lcssa = $add116; break; } } } if ($add116_lcssa >>> 0 < $add89 >>> 0) { $top_lmas_ = $this + 44 | 0; $pos125_040 = $add116_lcssa; do { __ZN10ime_pinyin11DictBuilder13id_to_charbufEPhj(0, (HEAP32[$lma_idx_buf_ >> 2] | 0) + ($pos125_040 * 3 | 0) | 0, HEAP32[(HEAP32[$top_lmas_ >> 2] | 0) + (($pos125_040 - (HEAP32[$homo_idx_num_eq1_ >> 2] | 0) - (HEAP32[$homo_idx_num_gt1_ >> 2] | 0) | 0) * 124 | 0) + 4 >> 2] | 0); $pos125_040 = $pos125_040 + 1 | 0; } while ($pos125_040 >>> 0 < $add89 >>> 0); } __ZN10ime_pinyin11DictBuilder13free_resourceEv($this); $retval_0 = $call80; STACKTOP = sp; return $retval_0 | 0; } function __ZN10ime_pinyin11DictBuilder13id_to_charbufEPhj($this, $buf, $id) { $this = $this | 0; $buf = $buf | 0; $id = $id | 0; if (($buf | 0) == 0) { return; } HEAP8[$buf] = $id & 255; HEAP8[$buf + 1 | 0] = $id >>> 8 & 255; HEAP8[$buf + 2 | 0] = $id >>> 16 & 255; return; } function __ZN10ime_pinyin11DictBuilder14set_son_offsetEPNS_10LmaNodeGE1Ej($this, $node, $offset) { $this = $this | 0; $node = $node | 0; $offset = $offset | 0; HEAP16[$node >> 1] = $offset & 65535; HEAP8[$node + 8 | 0] = $offset >>> 16 & 255; return; } function __ZN10ime_pinyin11DictBuilder22set_homo_id_buf_offsetEPNS_10LmaNodeGE1Ej($this, $node, $offset) { $this = $this | 0; $node = $node | 0; $offset = $offset | 0; HEAP16[$node + 2 >> 1] = $offset & 65535; HEAP8[$node + 9 | 0] = $offset >>> 16 & 255; return; } function __ZN10ime_pinyin11DictBuilder9stat_initEv($this) { $this = $this | 0; _memset($this + 60 | 0, 0, 268); return; } function __ZN10ime_pinyin11DictBuilder10build_scisEv($this) { $this = $this | 0; var $key = 0, $scis_ = 0, $lemma_num_ = 0, $scis_num_ = 0, $call = 0, $6 = 0, $10 = 0, $lemma_arr_ = 0, $pos_049 = 0, $15 = 0, $conv = 0, $cmp42 = 0, $hzpos_047 = 0, $24 = 0, $call36 = 0, $36 = 0, $pos63_044 = 0, $unique_scis_num_043 = 0, $52 = 0, $sub = 0, $61 = 0, $62 = 0, $63 = 0, $64$1 = 0, $call99 = 0, $70 = 0, $unique_scis_num_1 = 0, $inc106 = 0, $unique_scis_num_0_lcssa = 0, $lemma_arr_115 = 0, $hz127 = 0, $76 = 0, $77 = 0, $pos109_040 = 0, $79 = 0, $conv118 = 0, $hzpos119_038 = 0, $83 = 0, $bf_value138 = 0, $call140 = 0, $retval_0 = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 8 | 0; $key = sp | 0; $scis_ = $this + 8 | 0; if ((HEAP32[$scis_ >> 2] | 0) == 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } $lemma_num_ = $this + 4 | 0; $scis_num_ = $this + 12 | 0; if (HEAP32[$lemma_num_ >> 2] << 3 >>> 0 > (HEAP32[$scis_num_ >> 2] | 0) >>> 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } $call = __ZN10ime_pinyin12SpellingTrie12get_instanceEv() | 0; HEAPF32[HEAP32[$scis_ >> 2] >> 2] = 0.0; HEAP16[(HEAP32[$scis_ >> 2] | 0) + 4 >> 1] = 0; $6 = (HEAP32[$scis_ >> 2] | 0) + 6 | 0; HEAP16[$6 >> 1] = HEAP16[$6 >> 1] & 31; $10 = (HEAP32[$scis_ >> 2] | 0) + 6 | 0; HEAP16[$10 >> 1] = HEAP16[$10 >> 1] & -32; HEAP32[$scis_num_ >> 2] = 1; if ((HEAP32[$lemma_num_ >> 2] | 0) != 0) { $lemma_arr_ = $this | 0; $pos_049 = 0; do { $15 = HEAP8[(HEAP32[$lemma_arr_ >> 2] | 0) + ($pos_049 * 124 | 0) + 116 | 0] | 0; $conv = $15 & 255; if ($15 << 24 >> 24 != 0) { $cmp42 = $15 << 24 >> 24 == 1; $hzpos_047 = 0; do { HEAP16[(HEAP32[$scis_ >> 2] | 0) + (HEAP32[$scis_num_ >> 2] << 3) + 4 >> 1] = HEAP16[(HEAP32[$lemma_arr_ >> 2] | 0) + ($pos_049 * 124 | 0) + 8 + ($hzpos_047 << 1) >> 1] | 0; $24 = (HEAP32[$scis_ >> 2] | 0) + (HEAP32[$scis_num_ >> 2] << 3) + 6 | 0; HEAP16[$24 >> 1] = HEAP16[$24 >> 1] & 31 | HEAP16[(HEAP32[$lemma_arr_ >> 2] | 0) + ($pos_049 * 124 | 0) + 42 + ($hzpos_047 << 1) >> 1] << 5; $call36 = __ZNK10ime_pinyin12SpellingTrie12full_to_halfEt($call, (HEAPU16[(HEAP32[$scis_ >> 2] | 0) + (HEAP32[$scis_num_ >> 2] << 3) + 6 >> 1] | 0) >>> 5) | 0; $36 = (HEAP32[$scis_ >> 2] | 0) + (HEAP32[$scis_num_ >> 2] << 3) + 6 | 0; HEAP16[$36 >> 1] = HEAP16[$36 >> 1] & -32 | $call36 & 31; if ($cmp42) { HEAPF32[(HEAP32[$scis_ >> 2] | 0) + (HEAP32[$scis_num_ >> 2] << 3) >> 2] = +HEAPF32[(HEAP32[$lemma_arr_ >> 2] | 0) + ($pos_049 * 124 | 0) + 120 >> 2]; } else { HEAPF32[(HEAP32[$scis_ >> 2] | 0) + (HEAP32[$scis_num_ >> 2] << 3) >> 2] = 9.999999974752427e-7; } HEAP32[$scis_num_ >> 2] = (HEAP32[$scis_num_ >> 2] | 0) + 1; $hzpos_047 = $hzpos_047 + 1 | 0; } while ($hzpos_047 >>> 0 < $conv >>> 0); } $pos_049 = $pos_049 + 1 | 0; } while ($pos_049 >>> 0 < (HEAP32[$lemma_num_ >> 2] | 0) >>> 0); } __ZN10ime_pinyin7myqsortEPvjjPFiPKvS2_E(HEAP32[$scis_ >> 2] | 0, HEAP32[$scis_num_ >> 2] | 0, 8, 50); if ((HEAP32[$scis_num_ >> 2] | 0) >>> 0 > 1) { $unique_scis_num_043 = 1; $pos63_044 = 1; while (1) { $52 = HEAP32[$scis_ >> 2] | 0; $sub = $pos63_044 - 1 | 0; if ((HEAP16[$52 + ($pos63_044 << 3) + 4 >> 1] | 0) == (HEAP16[$52 + ($sub << 3) + 4 >> 1] | 0)) { if ((HEAPU16[$52 + ($pos63_044 << 3) + 6 >> 1] | 0) >>> 5 << 16 >> 16 == (HEAPU16[$52 + ($sub << 3) + 6 >> 1] | 0) >>> 5 << 16 >> 16) { $unique_scis_num_1 = $unique_scis_num_043; } else { label = 398; } } else { label = 398; } if ((label | 0) == 398) { label = 0; $61 = HEAP32[$scis_ >> 2] | 0; $62 = $61 + ($pos63_044 << 3) | 0; $63 = $61 + ($unique_scis_num_043 << 3) | 0; $64$1 = HEAP32[$62 + 4 >> 2] | 0; HEAP32[$63 >> 2] = HEAP32[$62 >> 2]; HEAP32[$63 + 4 >> 2] = $64$1; $call99 = __ZNK10ime_pinyin12SpellingTrie12full_to_halfEt($call, (HEAPU16[(HEAP32[$scis_ >> 2] | 0) + ($pos63_044 << 3) + 6 >> 1] | 0) >>> 5) | 0; $70 = (HEAP32[$scis_ >> 2] | 0) + ($unique_scis_num_043 << 3) + 6 | 0; HEAP16[$70 >> 1] = HEAP16[$70 >> 1] & -32 | $call99 & 31; $unique_scis_num_1 = $unique_scis_num_043 + 1 | 0; } $inc106 = $pos63_044 + 1 | 0; if ($inc106 >>> 0 < (HEAP32[$scis_num_ >> 2] | 0) >>> 0) { $unique_scis_num_043 = $unique_scis_num_1; $pos63_044 = $inc106; } else { $unique_scis_num_0_lcssa = $unique_scis_num_1; break; } } } else { $unique_scis_num_0_lcssa = 1; } HEAP32[$scis_num_ >> 2] = $unique_scis_num_0_lcssa; L465 : do { if ((HEAP32[$lemma_num_ >> 2] | 0) != 0) { $lemma_arr_115 = $this | 0; $hz127 = $key + 4 | 0; $76 = $key + 6 | 0; $77 = $key; $pos109_040 = 0; L467 : while (1) { $79 = HEAP8[(HEAP32[$lemma_arr_115 >> 2] | 0) + ($pos109_040 * 124 | 0) + 116 | 0] | 0; $conv118 = $79 & 255; if ($79 << 24 >> 24 != 0) { $hzpos119_038 = 0; do { HEAP16[$hz127 >> 1] = HEAP16[(HEAP32[$lemma_arr_115 >> 2] | 0) + ($pos109_040 * 124 | 0) + 8 + ($hzpos119_038 << 1) >> 1] | 0; $83 = HEAP16[(HEAP32[$lemma_arr_115 >> 2] | 0) + ($pos109_040 * 124 | 0) + 42 + ($hzpos119_038 << 1) >> 1] | 0; HEAP16[$76 >> 1] = HEAP16[$76 >> 1] & 31 | $83 << 5; $bf_value138 = (__ZNK10ime_pinyin12SpellingTrie12full_to_halfEt($call, $83 & 2047) | 0) & 31; HEAP16[$76 >> 1] = HEAP16[$76 >> 1] & -32 | $bf_value138; $call140 = __ZN10ime_pinyin9mybsearchEPKvS1_jjPFiS1_S1_E($77, HEAP32[$scis_ >> 2] | 0, $unique_scis_num_0_lcssa, 8, 34) | 0; if (($call140 | 0) == 0) { break L467; } HEAP16[(HEAP32[$lemma_arr_115 >> 2] | 0) + ($pos109_040 * 124 | 0) + 26 + ($hzpos119_038 << 1) >> 1] = ($call140 - (HEAP32[$scis_ >> 2] | 0) | 0) >>> 3 & 65535; HEAP16[(HEAP32[$lemma_arr_115 >> 2] | 0) + ($pos109_040 * 124 | 0) + 42 + ($hzpos119_038 << 1) >> 1] = (HEAPU16[$call140 + 6 >> 1] | 0) >>> 5; $hzpos119_038 = $hzpos119_038 + 1 | 0; } while ($hzpos119_038 >>> 0 < $conv118 >>> 0); } $pos109_040 = $pos109_040 + 1 | 0; if ($pos109_040 >>> 0 >= (HEAP32[$lemma_num_ >> 2] | 0) >>> 0) { break L465; } } ___assert_func(4408, 763, 7864, 4048); return 0; } } while (0); $retval_0 = HEAP32[$scis_num_ >> 2] | 0; STACKTOP = sp; return $retval_0 | 0; } function __ZN10ime_pinyin11DictBuilder16construct_subsetEPvPNS_10LemmaEntryEjjj($this, $parent, $lemma_arr, $item_start, $item_end, $level) { $this = $this | 0; $parent = $parent | 0; $lemma_arr = $lemma_arr | 0; $item_start = $item_start | 0; $item_end = $item_end | 0; $level = $level | 0; var $lemma_arr_ = 0, $add = 0, $parent_son_num_0192 = 0, $spl_idx_node_0191 = 0, $i_0190 = 0, $2 = 0, $parent_son_num_0_inc = 0, $inc11 = 0, $parent_son_num_0_lcssa = 0, $inc12 = 0, $arrayidx14 = 0, $arrayidx20 = 0, $arrayidx22 = 0, $sonbufs_num1_ = 0, $sonbufs_numgt1_ = 0, $total_lma_node_num_ = 0, $cmp30 = 0, $lma_nds_used_num_le0_ = 0, $10 = 0, $11 = 0, $lma_nds_used_num_ge1_ = 0, $14 = 0, $15 = 0, $lma_nds_used_num_ge1_56 = 0, $19 = 0, $20 = 0, $son_1st_le0_0 = 0, $son_1st_ge1_0 = 0, $22 = 0, $23 = 0, $add74 = 0, $_ = 0, $homo_num_1_neg171 = 0, $homo_idx_num_eq1_ = 0, $homo_idx_num_gt1_ = 0, $arrayidx170 = 0, $homo_idx_buf_ = 0, $homo_idx_num_eq1_123 = 0, $homo_idx_num_gt1_125 = 0, $arrayidx153 = 0, $arrayidx159 = 0, $homo_idx_num_eq1_115 = 0, $homo_idx_num_gt1_116 = 0, $homo_num_1_neg183 = 0, $spl_idx_node_2182 = 0, $i81_0180 = 0, $item_start_next_0177 = 0, $homo_num_1175 = 0, $son_pos_0174 = 0, $allson_noson_0_off0173 = 0, $25 = 0, $26 = 0, $add_ptr107 = 0, $add_ptr113 = 0, $node_cur_le0_0 = 0, $node_cur_ge1_0 = 0, $34 = 0, $35 = 0, $36 = 0, $add_ptr126_sum = 0, $homo_pos_0155 = 0, $next_parent_0 = 0, $add168 = 0, $allson_noson_1_off0 = 0, $allson_noson_2_off0 = 0, $son_pos_1 = 0, $homo_num_3 = 0, $item_start_next_1 = 0, $spl_idx_node_3 = 0, $inc183 = 0, $homo_num_1_neg = 0, $homo_num_1_neg_lcssa = 0, $spl_idx_node_2_lcssa = 0, $item_start_next_0_lcssa = 0, $homo_num_1_lcssa = 0, $son_pos_0_lcssa = 0, $allson_noson_0_off0_lcssa = 0, $add_ptr189 = 0, $homo_idx_num_eq1_191 = 0, $add_ptr199 = 0, $homo_idx_num_gt1_202 = 0, $node_cur_le0185_0 = 0, $node_cur_ge1186_0 = 0, $51 = 0, $52 = 0, $53 = 0, $add_ptr214_sum = 0, $homo_pos233_0153 = 0, $arrayidx245 = 0, $arrayidx252 = 0, $next_parent258_0 = 0, $add263 = 0, $arrayidx267 = 0, $arrayidx271 = 0, $arrayidx273 = 0, $retval_0 = 0, label = 0; if (!($level >>> 0 < 8 & $item_end >>> 0 > $item_start >>> 0)) { $retval_0 = 0; return $retval_0 | 0; } $lemma_arr_ = $this | 0; $add = $item_start + 1 | 0; if ($add >>> 0 < $item_end >>> 0) { $i_0190 = $add; $spl_idx_node_0191 = HEAP16[(HEAP32[$lemma_arr_ >> 2] | 0) + ($item_start * 124 | 0) + 42 + ($level << 1) >> 1] | 0; $parent_son_num_0192 = 0; while (1) { $2 = HEAP16[$lemma_arr + ($i_0190 * 124 | 0) + 42 + ($level << 1) >> 1] | 0; $parent_son_num_0_inc = ($2 << 16 >> 16 != $spl_idx_node_0191 << 16 >> 16) + $parent_son_num_0192 | 0; $inc11 = $i_0190 + 1 | 0; if ($inc11 >>> 0 < $item_end >>> 0) { $i_0190 = $inc11; $spl_idx_node_0191 = $2; $parent_son_num_0192 = $parent_son_num_0_inc; } else { $parent_son_num_0_lcssa = $parent_son_num_0_inc; break; } } } else { $parent_son_num_0_lcssa = 0; } $inc12 = $parent_son_num_0_lcssa + 1 | 0; if ($level >>> 0 >= 8) { ___assert_func(4408, 803, 7616, 3816); return 0; } $arrayidx14 = $this + 60 + ($level << 2) | 0; if ($inc12 >>> 0 > (HEAP32[$arrayidx14 >> 2] | 0) >>> 0) { HEAP32[$arrayidx14 >> 2] = $inc12; } $arrayidx20 = $this + 124 + ($level << 2) | 0; HEAP32[$arrayidx20 >> 2] = (HEAP32[$arrayidx20 >> 2] | 0) + $inc12; $arrayidx22 = $this + 188 + ($level << 2) | 0; HEAP32[$arrayidx22 >> 2] = (HEAP32[$arrayidx22 >> 2] | 0) + 1; if (($parent_son_num_0_lcssa | 0) == 0) { $sonbufs_num1_ = $this + 316 | 0; HEAP32[$sonbufs_num1_ >> 2] = (HEAP32[$sonbufs_num1_ >> 2] | 0) + 1; } else { $sonbufs_numgt1_ = $this + 320 | 0; HEAP32[$sonbufs_numgt1_ >> 2] = (HEAP32[$sonbufs_numgt1_ >> 2] | 0) + 1; } $total_lma_node_num_ = $this + 324 | 0; HEAP32[$total_lma_node_num_ >> 2] = (HEAP32[$total_lma_node_num_ >> 2] | 0) + $inc12; $cmp30 = ($level | 0) == 0; do { if ($cmp30) { $lma_nds_used_num_le0_ = $this + 24 | 0; HEAP32[$parent >> 2] = HEAP32[$lma_nds_used_num_le0_ >> 2]; $10 = HEAP32[$this + 16 >> 2] | 0; $11 = HEAP32[$lma_nds_used_num_le0_ >> 2] | 0; HEAP32[$lma_nds_used_num_le0_ >> 2] = $11 + $inc12; if ($inc12 >>> 0 < 65536) { HEAP16[$parent + 10 >> 1] = $inc12 & 65535; $son_1st_ge1_0 = 0; $son_1st_le0_0 = $10 + ($11 << 4) | 0; break; } else { ___assert_func(4408, 827, 7616, 3640); return 0; } } else { if (($level | 0) == 1) { $lma_nds_used_num_ge1_ = $this + 28 | 0; HEAP32[$parent >> 2] = HEAP32[$lma_nds_used_num_ge1_ >> 2]; $14 = HEAP32[$this + 20 >> 2] | 0; $15 = HEAP32[$lma_nds_used_num_ge1_ >> 2] | 0; HEAP32[$lma_nds_used_num_ge1_ >> 2] = $15 + $inc12; if ($inc12 >>> 0 < 65536) { HEAP16[$parent + 10 >> 1] = $inc12 & 65535; $son_1st_ge1_0 = $14 + ($15 * 10 | 0) | 0; $son_1st_le0_0 = 0; break; } else { ___assert_func(4408, 836, 7616, 3640); return 0; } } else { $lma_nds_used_num_ge1_56 = $this + 28 | 0; __ZN10ime_pinyin11DictBuilder14set_son_offsetEPNS_10LmaNodeGE1Ej(0, $parent, HEAP32[$lma_nds_used_num_ge1_56 >> 2] | 0); $19 = HEAP32[$this + 20 >> 2] | 0; $20 = HEAP32[$lma_nds_used_num_ge1_56 >> 2] | 0; HEAP32[$lma_nds_used_num_ge1_56 >> 2] = $20 + $inc12; if ($inc12 >>> 0 < 256) { HEAP8[$parent + 6 | 0] = $inc12 & 255; $son_1st_ge1_0 = $19 + ($20 * 10 | 0) | 0; $son_1st_le0_0 = 0; break; } else { ___assert_func(4408, 845, 7616, 3528); return 0; } } } } while (0); $22 = HEAP32[$lemma_arr_ >> 2] | 0; $23 = HEAP16[$22 + ($item_start * 124 | 0) + 42 + ($level << 1) >> 1] | 0; $add74 = $level + 1 | 0; $_ = (HEAP16[$22 + ($item_start * 124 | 0) + 42 + ($add74 << 1) >> 1] | 0) == 0 | 0; $homo_num_1_neg171 = -$_ | 0; L512 : do { if ($add >>> 0 < $item_end >>> 0) { $homo_idx_num_eq1_ = $this + 36 | 0; $homo_idx_num_gt1_ = $this + 40 | 0; $arrayidx170 = $this + 156 + ($level << 2) | 0; $homo_idx_buf_ = $this + 32 | 0; $homo_idx_num_eq1_123 = $this + 36 | 0; $homo_idx_num_gt1_125 = $this + 40 | 0; $arrayidx153 = $this + 92 + ($level << 2) | 0; $arrayidx159 = $this + 284 + ($level << 2) | 0; $homo_idx_num_eq1_115 = $this + 36 | 0; $homo_idx_num_gt1_116 = $this + 40 | 0; $allson_noson_0_off0173 = 1; $son_pos_0174 = 0; $homo_num_1175 = $_; $item_start_next_0177 = $item_start; $i81_0180 = $add; $spl_idx_node_2182 = $23; $homo_num_1_neg183 = $homo_num_1_neg171; while (1) { $25 = HEAP32[$lemma_arr_ >> 2] | 0; $26 = HEAP16[$25 + ($i81_0180 * 124 | 0) + 42 + ($level << 1) >> 1] | 0; if ($26 << 16 >> 16 == $spl_idx_node_2182 << 16 >> 16) { $spl_idx_node_3 = $spl_idx_node_2182; $item_start_next_1 = $item_start_next_0177; $homo_num_3 = ((HEAP16[$25 + ($i81_0180 * 124 | 0) + 42 + ($add74 << 1) >> 1] | 0) == 0) + $homo_num_1175 | 0; $son_pos_1 = $son_pos_0174; $allson_noson_2_off0 = $allson_noson_0_off0173; } else { if ($cmp30) { $add_ptr107 = $son_1st_le0_0 + ($son_pos_0174 << 4) | 0; HEAP16[$son_1st_le0_0 + ($son_pos_0174 << 4) + 8 >> 1] = $spl_idx_node_2182; HEAP32[$son_1st_le0_0 + ($son_pos_0174 << 4) + 4 >> 2] = (HEAP32[$homo_idx_num_gt1_ >> 2] | 0) + (HEAP32[$homo_idx_num_eq1_ >> 2] | 0); HEAP32[$add_ptr107 >> 2] = 0; HEAP32[$homo_idx_num_eq1_ >> 2] = (HEAP32[$homo_idx_num_eq1_ >> 2] | 0) + $homo_num_1175; $node_cur_ge1_0 = 0; $node_cur_le0_0 = $add_ptr107; } else { $add_ptr113 = $son_1st_ge1_0 + ($son_pos_0174 * 10 | 0) | 0; HEAP16[$son_1st_ge1_0 + ($son_pos_0174 * 10 | 0) + 4 >> 1] = $spl_idx_node_2182; __ZN10ime_pinyin11DictBuilder22set_homo_id_buf_offsetEPNS_10LmaNodeGE1Ej(0, $add_ptr113, (HEAP32[$homo_idx_num_gt1_116 >> 2] | 0) + (HEAP32[$homo_idx_num_eq1_115 >> 2] | 0) | 0); __ZN10ime_pinyin11DictBuilder14set_son_offsetEPNS_10LmaNodeGE1Ej(0, $add_ptr113, 0); HEAP32[$homo_idx_num_gt1_116 >> 2] = (HEAP32[$homo_idx_num_gt1_116 >> 2] | 0) + $homo_num_1175; $node_cur_ge1_0 = $add_ptr113; $node_cur_le0_0 = 0; } if (($homo_num_1175 | 0) != 0) { $34 = HEAP32[$homo_idx_buf_ >> 2] | 0; $35 = HEAP32[$homo_idx_num_eq1_123 >> 2] | 0; $36 = HEAP32[$homo_idx_num_gt1_125 >> 2] | 0; if ($cmp30) { if ($homo_num_1175 >>> 0 >= 65536) { label = 444; break; } HEAP16[$node_cur_le0_0 + 12 >> 1] = $homo_num_1175 & 65535; } else { if ($homo_num_1175 >>> 0 >= 256) { label = 447; break; } HEAP8[$node_cur_ge1_0 + 7 | 0] = $homo_num_1175 & 255; } if (($homo_num_1175 | 0) != 0) { $add_ptr126_sum = $35 + $homo_num_1_neg183 + $36 | 0; $homo_pos_0155 = 0; do { HEAP32[$34 + ($add_ptr126_sum + $homo_pos_0155 << 2) >> 2] = HEAP32[(HEAP32[$lemma_arr_ >> 2] | 0) + (($homo_pos_0155 + $item_start_next_0177 | 0) * 124 | 0) + 4 >> 2]; $homo_pos_0155 = $homo_pos_0155 + 1 | 0; } while ($homo_pos_0155 >>> 0 < $homo_num_1175 >>> 0); } if ($homo_num_1175 >>> 0 > (HEAP32[$arrayidx153 >> 2] | 0) >>> 0) { HEAP32[$arrayidx153 >> 2] = $homo_num_1175; } HEAP32[$arrayidx159 >> 2] = (HEAP32[$arrayidx159 >> 2] | 0) + $homo_num_1175; } if (($i81_0180 - $item_start_next_0177 | 0) >>> 0 > $homo_num_1175 >>> 0) { if ($cmp30) { $next_parent_0 = $node_cur_le0_0; } else { $next_parent_0 = $node_cur_ge1_0; } $add168 = $item_start_next_0177 + $homo_num_1175 | 0; __ZN10ime_pinyin11DictBuilder16construct_subsetEPvPNS_10LemmaEntryEjjj($this, $next_parent_0, $lemma_arr, $add168, $i81_0180, $add74) | 0; HEAP32[$arrayidx170 >> 2] = (HEAP32[$arrayidx170 >> 2] | 0) + 1; $allson_noson_1_off0 = 0; } else { $allson_noson_1_off0 = $allson_noson_0_off0173; } $spl_idx_node_3 = $26; $item_start_next_1 = $i81_0180; $homo_num_3 = (HEAP16[$25 + ($i81_0180 * 124 | 0) + 42 + ($add74 << 1) >> 1] | 0) == 0 | 0; $son_pos_1 = $son_pos_0174 + 1 | 0; $allson_noson_2_off0 = $allson_noson_1_off0; } $inc183 = $i81_0180 + 1 | 0; $homo_num_1_neg = -$homo_num_3 | 0; if ($inc183 >>> 0 < $item_end >>> 0) { $allson_noson_0_off0173 = $allson_noson_2_off0; $son_pos_0174 = $son_pos_1; $homo_num_1175 = $homo_num_3; $item_start_next_0177 = $item_start_next_1; $i81_0180 = $inc183; $spl_idx_node_2182 = $spl_idx_node_3; $homo_num_1_neg183 = $homo_num_1_neg; } else { $allson_noson_0_off0_lcssa = $allson_noson_2_off0; $son_pos_0_lcssa = $son_pos_1; $homo_num_1_lcssa = $homo_num_3; $item_start_next_0_lcssa = $item_start_next_1; $spl_idx_node_2_lcssa = $spl_idx_node_3; $homo_num_1_neg_lcssa = $homo_num_1_neg; break L512; } } if ((label | 0) == 444) { ___assert_func(4408, 893, 7616, 3376); return 0; } else if ((label | 0) == 447) { ___assert_func(4408, 896, 7616, 3264); return 0; } } else { $allson_noson_0_off0_lcssa = 1; $son_pos_0_lcssa = 0; $homo_num_1_lcssa = $_; $item_start_next_0_lcssa = $item_start; $spl_idx_node_2_lcssa = $23; $homo_num_1_neg_lcssa = $homo_num_1_neg171; } } while (0); if ($cmp30) { $add_ptr189 = $son_1st_le0_0 + ($son_pos_0_lcssa << 4) | 0; HEAP16[$son_1st_le0_0 + ($son_pos_0_lcssa << 4) + 8 >> 1] = $spl_idx_node_2_lcssa; $homo_idx_num_eq1_191 = $this + 36 | 0; HEAP32[$son_1st_le0_0 + ($son_pos_0_lcssa << 4) + 4 >> 2] = (HEAP32[$this + 40 >> 2] | 0) + (HEAP32[$homo_idx_num_eq1_191 >> 2] | 0); HEAP32[$add_ptr189 >> 2] = 0; HEAP32[$homo_idx_num_eq1_191 >> 2] = (HEAP32[$homo_idx_num_eq1_191 >> 2] | 0) + $homo_num_1_lcssa; $node_cur_ge1186_0 = 0; $node_cur_le0185_0 = $add_ptr189; } else { $add_ptr199 = $son_1st_ge1_0 + ($son_pos_0_lcssa * 10 | 0) | 0; HEAP16[$son_1st_ge1_0 + ($son_pos_0_lcssa * 10 | 0) + 4 >> 1] = $spl_idx_node_2_lcssa; $homo_idx_num_gt1_202 = $this + 40 | 0; __ZN10ime_pinyin11DictBuilder22set_homo_id_buf_offsetEPNS_10LmaNodeGE1Ej(0, $add_ptr199, (HEAP32[$homo_idx_num_gt1_202 >> 2] | 0) + (HEAP32[$this + 36 >> 2] | 0) | 0); __ZN10ime_pinyin11DictBuilder14set_son_offsetEPNS_10LmaNodeGE1Ej(0, $add_ptr199, 0); HEAP32[$homo_idx_num_gt1_202 >> 2] = (HEAP32[$homo_idx_num_gt1_202 >> 2] | 0) + $homo_num_1_lcssa; $node_cur_ge1186_0 = $add_ptr199; $node_cur_le0185_0 = 0; } if (($homo_num_1_lcssa | 0) != 0) { $51 = HEAP32[$this + 32 >> 2] | 0; $52 = HEAP32[$this + 36 >> 2] | 0; $53 = HEAP32[$this + 40 >> 2] | 0; do { if ($cmp30) { if ($homo_num_1_lcssa >>> 0 < 65536) { HEAP16[$node_cur_le0185_0 + 12 >> 1] = $homo_num_1_lcssa & 65535; break; } else { ___assert_func(4408, 962, 7616, 3376); return 0; } } else { if ($homo_num_1_lcssa >>> 0 < 256) { HEAP8[$node_cur_ge1186_0 + 7 | 0] = $homo_num_1_lcssa & 255; break; } else { ___assert_func(4408, 965, 7616, 3264); return 0; } } } while (0); if (($homo_num_1_lcssa | 0) != 0) { $add_ptr214_sum = $52 + $homo_num_1_neg_lcssa + $53 | 0; $homo_pos233_0153 = 0; do { HEAP32[$51 + ($add_ptr214_sum + $homo_pos233_0153 << 2) >> 2] = HEAP32[$lemma_arr + (($homo_pos233_0153 + $item_start_next_0_lcssa | 0) * 124 | 0) + 4 >> 2]; $homo_pos233_0153 = $homo_pos233_0153 + 1 | 0; } while ($homo_pos233_0153 >>> 0 < $homo_num_1_lcssa >>> 0); } $arrayidx245 = $this + 92 + ($level << 2) | 0; if ($homo_num_1_lcssa >>> 0 > (HEAP32[$arrayidx245 >> 2] | 0) >>> 0) { HEAP32[$arrayidx245 >> 2] = $homo_num_1_lcssa; } $arrayidx252 = $this + 284 + ($level << 2) | 0; HEAP32[$arrayidx252 >> 2] = (HEAP32[$arrayidx252 >> 2] | 0) + $homo_num_1_lcssa; } do { if (($item_end - $item_start_next_0_lcssa | 0) >>> 0 > $homo_num_1_lcssa >>> 0) { if ($cmp30) { $next_parent258_0 = $node_cur_le0185_0; } else { $next_parent258_0 = $node_cur_ge1186_0; } $add263 = $item_start_next_0_lcssa + $homo_num_1_lcssa | 0; __ZN10ime_pinyin11DictBuilder16construct_subsetEPvPNS_10LemmaEntryEjjj($this, $next_parent258_0, $lemma_arr, $add263, $item_end, $add74) | 0; $arrayidx267 = $this + 156 + ($level << 2) | 0; HEAP32[$arrayidx267 >> 2] = (HEAP32[$arrayidx267 >> 2] | 0) + 1; } else { if (!$allson_noson_0_off0_lcssa) { break; } $arrayidx271 = $this + 220 + ($level << 2) | 0; HEAP32[$arrayidx271 >> 2] = (HEAP32[$arrayidx271 >> 2] | 0) + 1; $arrayidx273 = $this + 252 + ($level << 2) | 0; HEAP32[$arrayidx273 >> 2] = (HEAP32[$arrayidx273 >> 2] | 0) + $inc12; } } while (0); if (($son_pos_0_lcssa + 1 | 0) == ($inc12 | 0)) { $retval_0 = 1; return $retval_0 | 0; } else { ___assert_func(4408, 1003, 7616, 3144); return 0; } return 0; } function __ZN10ime_pinyin12AtomDictBaseC2Ev($this) { $this = $this | 0; HEAP32[$this >> 2] = 8368; return; } function __ZN10ime_pinyin8DictTrie12get_lemma_idEj($this, $id_offset) { $this = $this | 0; $id_offset = $id_offset | 0; var $mul = 0, $0 = 0; $mul = $id_offset * 3 | 0; $0 = HEAP32[$this + 32 >> 2] | 0; return HEAPU8[(HEAP32[$this + 32 >> 2] | 0) + $mul | 0] | 0 | (HEAPU8[$0 + ($mul + 1) | 0] | 0 | (HEAPU8[$0 + ($mul + 2) | 0] | 0) << 8) << 8 | 0; } function __ZN10ime_pinyin11DictBuilder10stat_printEv($this) { $this = $this | 0; var sp = 0; sp = STACKTOP; _puts(72) | 0; _puts(48) | 0; _printf(2936, (tempInt = STACKTOP, STACKTOP = STACKTOP + 1 | 0, STACKTOP = STACKTOP + 7 >> 3 << 3, HEAP32[tempInt >> 2] = 0, tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 60 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 64 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 68 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 72 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 76 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 80 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 84 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 88 >> 2], tempInt) | 0) | 0; _puts(40) | 0; _printf(2552, (tempInt = STACKTOP, STACKTOP = STACKTOP + 1 | 0, STACKTOP = STACKTOP + 7 >> 3 << 3, HEAP32[tempInt >> 2] = 0, tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 92 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 96 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 100 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 104 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 108 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 112 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 116 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 120 >> 2], tempInt) | 0) | 0; _putchar(10) | 0; _printf(2408, (tempInt = STACKTOP, STACKTOP = STACKTOP + 1 | 0, STACKTOP = STACKTOP + 7 >> 3 << 3, HEAP32[tempInt >> 2] = 0, tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 124 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 128 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 132 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 136 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 140 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 144 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 148 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 152 >> 2], tempInt) | 0) | 0; _puts(32) | 0; _printf(2320, (tempInt = STACKTOP, STACKTOP = STACKTOP + 1 | 0, STACKTOP = STACKTOP + 7 >> 3 << 3, HEAP32[tempInt >> 2] = 0, tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 156 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 160 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 164 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 168 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 172 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 176 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 180 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 184 >> 2], tempInt) | 0) | 0; _putchar(10) | 0; _printf(2264, (tempInt = STACKTOP, STACKTOP = STACKTOP + 1 | 0, STACKTOP = STACKTOP + 7 >> 3 << 3, HEAP32[tempInt >> 2] = 0, tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 188 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 192 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 196 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 200 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 204 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 208 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 212 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 216 >> 2], tempInt) | 0) | 0; _puts(24) | 0; _printf(2208, (tempInt = STACKTOP, STACKTOP = STACKTOP + 1 | 0, STACKTOP = STACKTOP + 7 >> 3 << 3, HEAP32[tempInt >> 2] = 0, tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 220 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 224 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 228 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 232 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 236 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 240 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 244 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 248 >> 2], tempInt) | 0) | 0; _puts(16) | 0; _printf(2080, (tempInt = STACKTOP, STACKTOP = STACKTOP + 1 | 0, STACKTOP = STACKTOP + 7 >> 3 << 3, HEAP32[tempInt >> 2] = 0, tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 252 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 256 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 260 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 264 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 268 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 272 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 276 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 280 >> 2], tempInt) | 0) | 0; _puts(8) | 0; _printf(2032, (tempInt = STACKTOP, STACKTOP = STACKTOP + 1 | 0, STACKTOP = STACKTOP + 7 >> 3 << 3, HEAP32[tempInt >> 2] = 0, tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 284 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 288 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 292 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 296 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 300 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 304 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 308 >> 2], tempInt) | 0) | 0; _printf(2840, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 312 >> 2], tempInt) | 0) | 0; _putchar(10) | 0; _printf(1936, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 316 >> 2], tempInt) | 0) | 0; _printf(1800, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP32[$this + 320 >> 2], tempInt) | 0) | 0; _printf(1656, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = (HEAP32[$this + 324 >> 2] | 0) + 1, tempInt) | 0) | 0; STACKTOP = sp; return; } function __ZN10ime_pinyin8DictTrieC2Ev($this) { $this = $this | 0; __ZN10ime_pinyin12AtomDictBaseC2Ev($this | 0); HEAP32[$this >> 2] = 8272; HEAP32[$this + 8 >> 2] = __ZN10ime_pinyin12SpellingTrie14get_cpinstanceEv() | 0; HEAP32[$this + 4 >> 2] = 0; HEAP32[$this + 56 >> 2] = 0; _memset($this + 12 | 0, 0, 40); FUNCTION_TABLE_viii[HEAP32[(HEAP32[$this >> 2] | 0) + 20 >> 2] & 15]($this, 0, 1); return; } function __ZN10ime_pinyin8DictTrieD0Ev($this) { $this = $this | 0; __ZN10ime_pinyin8DictTrieD2Ev($this); __ZdlPv($this); return; } function __ZN10ime_pinyin8DictTrieD2Ev($this) { $this = $this | 0; HEAP32[$this >> 2] = 8272; __ZN10ime_pinyin8DictTrie13free_resourceEb($this, 1); return; } function __ZN10ime_pinyin8DictTrie13free_resourceEb($this, $free_dict_list) { $this = $this | 0; $free_dict_list = $free_dict_list | 0; var $root_ = 0, $0 = 0, $splid_le0_index_ = 0, $2 = 0, $nodes_ge1_ = 0, $4 = 0, $dict_list_ = 0, $6 = 0, $parsing_marks_ = 0, $10 = 0, $mile_stones_ = 0, $12 = 0, $14 = 0, $vtable = 0, $vfn = 0, $15 = 0; $root_ = $this + 12 | 0; $0 = HEAP32[$root_ >> 2] | 0; if (($0 | 0) != 0) { _free($0); } HEAP32[$root_ >> 2] = 0; $splid_le0_index_ = $this + 20 | 0; $2 = HEAP32[$splid_le0_index_ >> 2] | 0; if (($2 | 0) != 0) { _free($2); } HEAP32[$splid_le0_index_ >> 2] = 0; $nodes_ge1_ = $this + 16 | 0; $4 = HEAP32[$nodes_ge1_ >> 2] | 0; if (($4 | 0) != 0) { _free($4); } HEAP32[$nodes_ge1_ >> 2] = 0; if ($free_dict_list) { $dict_list_ = $this + 4 | 0; $6 = HEAP32[$dict_list_ >> 2] | 0; if (($6 | 0) != 0) { __ZN10ime_pinyin8DictListD2Ev($6); __ZdlPv($6 | 0); } HEAP32[$dict_list_ >> 2] = 0; } $parsing_marks_ = $this + 48 | 0; $10 = HEAP32[$parsing_marks_ >> 2] | 0; if (($10 | 0) != 0) { __ZdaPv($10 | 0); } HEAP32[$parsing_marks_ >> 2] = 0; $mile_stones_ = $this + 56 | 0; $12 = HEAP32[$mile_stones_ >> 2] | 0; if (($12 | 0) == 0) { HEAP32[$mile_stones_ >> 2] = 0; $14 = $this; $vtable = HEAP32[$14 >> 2] | 0; $vfn = $vtable + 20 | 0; $15 = HEAP32[$vfn >> 2] | 0; FUNCTION_TABLE_viii[$15 & 15]($this, 0, 1); return; } __ZdaPv($12); HEAP32[$mile_stones_ >> 2] = 0; $14 = $this; $vtable = HEAP32[$14 >> 2] | 0; $vfn = $vtable + 20 | 0; $15 = HEAP32[$vfn >> 2] | 0; FUNCTION_TABLE_viii[$15 & 15]($this, 0, 1); return; } function __ZN10ime_pinyin8DictTrie10build_dictEPKcS2_($this, $fn_raw, $fn_validhzs) { $this = $this | 0; $fn_raw = $fn_raw | 0; $fn_validhzs = $fn_validhzs | 0; var $0 = 0; $0 = __Znwj(328) | 0; __ZN10ime_pinyin11DictBuilderC2Ev($0); __ZN10ime_pinyin8DictTrie13free_resourceEb($this, 1); return __ZN10ime_pinyin11DictBuilder10build_dictEPKcS2_PNS_8DictTrieE($0, $fn_raw, $fn_validhzs, $this) | 0; } function __ZN10ime_pinyin8DictTrie9save_dictEP7__sFILE($this, $fp) { $this = $this | 0; $fp = $fp | 0; var $lma_node_num_le0_ = 0, $lma_node_num_ge1_ = 0, $lma_idx_buf_len_ = 0, $call18 = 0, $call24 = 0, $call30 = 0, $retval_0 = 0; if (($fp | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $lma_node_num_le0_ = $this + 24 | 0; if ((_fwrite($lma_node_num_le0_ | 0, 4, 1, $fp | 0) | 0) != 1) { $retval_0 = 0; return $retval_0 | 0; } $lma_node_num_ge1_ = $this + 28 | 0; if ((_fwrite($lma_node_num_ge1_ | 0, 4, 1, $fp | 0) | 0) != 1) { $retval_0 = 0; return $retval_0 | 0; } $lma_idx_buf_len_ = $this + 36 | 0; if ((_fwrite($lma_idx_buf_len_ | 0, 4, 1, $fp | 0) | 0) != 1) { $retval_0 = 0; return $retval_0 | 0; } if ((_fwrite($this + 44 | 0, 4, 1, $fp | 0) | 0) != 1) { $retval_0 = 0; return $retval_0 | 0; } $call18 = _fwrite(HEAP32[$this + 12 >> 2] | 0, 16, HEAP32[$lma_node_num_le0_ >> 2] | 0, $fp | 0) | 0; if (($call18 | 0) != (HEAP32[$lma_node_num_le0_ >> 2] | 0)) { $retval_0 = 0; return $retval_0 | 0; } $call24 = _fwrite(HEAP32[$this + 16 >> 2] | 0, 10, HEAP32[$lma_node_num_ge1_ >> 2] | 0, $fp | 0) | 0; if (($call24 | 0) != (HEAP32[$lma_node_num_ge1_ >> 2] | 0)) { $retval_0 = 0; return $retval_0 | 0; } $call30 = _fwrite(HEAP32[$this + 32 >> 2] | 0, 1, HEAP32[$lma_idx_buf_len_ >> 2] | 0, $fp | 0) | 0; $retval_0 = ($call30 | 0) == (HEAP32[$lma_idx_buf_len_ >> 2] | 0); return $retval_0 | 0; } function __ZN10ime_pinyin8DictTrie9save_dictEPKc($this, $filename) { $this = $this | 0; $filename = $filename | 0; var $dict_list_ = 0, $call = 0, $call6 = 0, $call7 = 0, $retval_0 = 0; if (($filename | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } if ((HEAP32[$this + 12 >> 2] | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $dict_list_ = $this + 4 | 0; if ((HEAP32[$dict_list_ >> 2] | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $call = __ZN10ime_pinyin12SpellingTrie12get_instanceEv() | 0; $call6 = __ZN10ime_pinyin5NGram12get_instanceEv() | 0; $call7 = _fopen($filename | 0, 1648) | 0; if (($call7 | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } do { if (__ZN10ime_pinyin12SpellingTrie13save_spl_trieEP7__sFILE($call, $call7) | 0) { if (!(__ZN10ime_pinyin8DictList9save_listEP7__sFILE(HEAP32[$dict_list_ >> 2] | 0, $call7) | 0)) { break; } if (!(__ZN10ime_pinyin8DictTrie9save_dictEP7__sFILE($this, $call7) | 0)) { break; } if (!(__ZN10ime_pinyin5NGram10save_ngramEP7__sFILE($call6, $call7) | 0)) { break; } _fclose($call7 | 0) | 0; $retval_0 = 1; return $retval_0 | 0; } } while (0); _fclose($call7 | 0) | 0; $retval_0 = 0; return $retval_0 | 0; } function __ZN10ime_pinyin8DictTrie9load_dictEPKcjj($this, $filename, $start_id, $end_id) { $this = $this | 0; $filename = $filename | 0; $start_id = $start_id | 0; $end_id = $end_id | 0; var $call = 0, $call6 = 0, $0 = 0, $dict_list_ = 0, $call12 = 0, $call13 = 0, $retval_0 = 0; if (!(($filename | 0) != 0 & $end_id >>> 0 > $start_id >>> 0)) { $retval_0 = 0; return $retval_0 | 0; } $call = _fopen($filename | 0, 1464) | 0; if (($call | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } __ZN10ime_pinyin8DictTrie13free_resourceEb($this, 1); $call6 = __Znwj(128) | 0; $0 = $call6; __ZN10ime_pinyin8DictListC2Ev($0); $dict_list_ = $this + 4 | 0; HEAP32[$dict_list_ >> 2] = $0; if (($call6 | 0) == 0) { _fclose($call | 0) | 0; $retval_0 = 0; return $retval_0 | 0; } $call12 = __ZN10ime_pinyin12SpellingTrie12get_instanceEv() | 0; $call13 = __ZN10ime_pinyin5NGram12get_instanceEv() | 0; do { if (__ZN10ime_pinyin12SpellingTrie13load_spl_trieEP7__sFILE($call12, $call) | 0) { if (!(__ZN10ime_pinyin8DictList9load_listEP7__sFILE(HEAP32[$dict_list_ >> 2] | 0, $call) | 0)) { break; } if (!(__ZN10ime_pinyin8DictTrie9load_dictEP7__sFILE($this, $call) | 0)) { break; } if (!(__ZN10ime_pinyin5NGram10load_ngramEP7__sFILE($call13, $call) | 0)) { break; } if ((HEAP32[$this + 40 >> 2] | 0) >>> 0 > (1 - $start_id + $end_id | 0) >>> 0) { break; } _fclose($call | 0) | 0; $retval_0 = 1; return $retval_0 | 0; } } while (0); __ZN10ime_pinyin8DictTrie13free_resourceEb($this, 1); _fclose($call | 0) | 0; $retval_0 = 0; return $retval_0 | 0; } function __ZN10ime_pinyin8DictTrie12load_dict_fdEilljj($this, $sys_fd, $start_offset, $length, $start_id, $end_id) { $this = $this | 0; $sys_fd = $sys_fd | 0; $start_offset = $start_offset | 0; $length = $length | 0; $start_id = $start_id | 0; $end_id = $end_id | 0; var $call = 0, $call13 = 0, $0 = 0, $dict_list_ = 0, $call19 = 0, $call20 = 0, $retval_0 = 0; if (!(($length | 0) > 0 & ($start_offset | 0) > -1 & $end_id >>> 0 > $start_id >>> 0)) { $retval_0 = 0; return $retval_0 | 0; } $call = _fdopen($sys_fd | 0, 1464) | 0; if (($call | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } if ((_fseek($call | 0, $start_offset | 0, 0) | 0) == -1) { _fclose($call | 0) | 0; $retval_0 = 0; return $retval_0 | 0; } __ZN10ime_pinyin8DictTrie13free_resourceEb($this, 1); $call13 = __Znwj(128) | 0; $0 = $call13; __ZN10ime_pinyin8DictListC2Ev($0); $dict_list_ = $this + 4 | 0; HEAP32[$dict_list_ >> 2] = $0; if (($call13 | 0) == 0) { _fclose($call | 0) | 0; $retval_0 = 0; return $retval_0 | 0; } $call19 = __ZN10ime_pinyin12SpellingTrie12get_instanceEv() | 0; $call20 = __ZN10ime_pinyin5NGram12get_instanceEv() | 0; do { if (__ZN10ime_pinyin12SpellingTrie13load_spl_trieEP7__sFILE($call19, $call) | 0) { if (!(__ZN10ime_pinyin8DictList9load_listEP7__sFILE(HEAP32[$dict_list_ >> 2] | 0, $call) | 0)) { break; } if (!(__ZN10ime_pinyin8DictTrie9load_dictEP7__sFILE($this, $call) | 0)) { break; } if (!(__ZN10ime_pinyin5NGram10load_ngramEP7__sFILE($call20, $call) | 0)) { break; } if ((_ftell($call | 0) | 0) < ($length + $start_offset | 0)) { break; } if ((HEAP32[$this + 40 >> 2] | 0) >>> 0 > (1 - $start_id + $end_id | 0) >>> 0) { break; } _fclose($call | 0) | 0; $retval_0 = 1; return $retval_0 | 0; } } while (0); __ZN10ime_pinyin8DictTrie13free_resourceEb($this, 1); _fclose($call | 0) | 0; $retval_0 = 0; return $retval_0 | 0; } function __ZN10ime_pinyin8DictTrie15fill_lpi_bufferEPNS_10LmaPsbItemEjPNS_10LmaNodeLE0E($this, $lpi_items, $lpi_max, $node) { $this = $this | 0; $lpi_items = $lpi_items | 0; $lpi_max = $lpi_max | 0; $node = $node | 0; var $call = 0, $homo_idx_buf_off = 0, $num_of_homo = 0, $lpi_num_0 = 0, $bf_value = 0, $2 = 0, $inc = 0, $lpi_num_1 = 0, label = 0; $call = __ZN10ime_pinyin5NGram12get_instanceEv() | 0; $homo_idx_buf_off = $node + 4 | 0; $num_of_homo = $node + 12 | 0; $lpi_num_0 = 0; while (1) { if ($lpi_num_0 >>> 0 >= (HEAPU16[$num_of_homo >> 1] | 0) >>> 0) { $lpi_num_1 = $lpi_num_0; label = 602; break; } $bf_value = (__ZN10ime_pinyin8DictTrie12get_lemma_idEj($this, (HEAP32[$homo_idx_buf_off >> 2] | 0) + $lpi_num_0 | 0) | 0) & 16777215; $2 = $lpi_items + ($lpi_num_0 << 3) | 0; HEAP32[$2 >> 2] = $bf_value | HEAP32[$2 >> 2] & -268435456 | 16777216; HEAP16[$lpi_items + ($lpi_num_0 << 3) + 4 >> 1] = ~~+__ZN10ime_pinyin5NGram11get_uni_psbEj($call, $bf_value); $inc = $lpi_num_0 + 1 | 0; if ($inc >>> 0 < $lpi_max >>> 0) { $lpi_num_0 = $inc; } else { $lpi_num_1 = $inc; label = 601; break; } } if ((label | 0) == 602) { return $lpi_num_1 | 0; } else if ((label | 0) == 601) { return $lpi_num_1 | 0; } return 0; } function __ZN10ime_pinyin8DictTrie9load_dictEP7__sFILE($this, $fp) { $this = $this | 0; $fp = $fp | 0; var $lma_node_num_le0_ = 0, $lma_node_num_ge1_ = 0, $lma_idx_buf_len_ = 0, $top_lmas_num_ = 0, $root_ = 0, $nodes_ge1_ = 0, $lma_idx_buf_ = 0, $call29 = 0, $add = 0, $splid_le0_index_ = 0, $parsing_marks_ = 0, $mile_stones_ = 0, $18 = 0, $call57 = 0, $call64 = 0, $call71 = 0, $i_034 = 0, $last_pos_033_off0 = 0, $last_splid_032 = 0, $36 = 0, $last_pos_0_lcssa = 0, $last_splid_0_lcssa = 0, $conv10624 = 0, $add107 = 0, $conv117 = 0, $splid_030 = 0, $inc = 0, $39 = 0, $_lcssa = 0, $42 = 0, $inc99 = 0, $conv10627 = 0, $splid101_026 = 0, $sub111 = 0, $splid101_0 = 0, $conv106 = 0, $retval_0 = 0, label = 0; if (($fp | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $lma_node_num_le0_ = $this + 24 | 0; if ((_fread($lma_node_num_le0_ | 0, 4, 1, $fp | 0) | 0) != 1) { $retval_0 = 0; return $retval_0 | 0; } $lma_node_num_ge1_ = $this + 28 | 0; if ((_fread($lma_node_num_ge1_ | 0, 4, 1, $fp | 0) | 0) != 1) { $retval_0 = 0; return $retval_0 | 0; } $lma_idx_buf_len_ = $this + 36 | 0; if ((_fread($lma_idx_buf_len_ | 0, 4, 1, $fp | 0) | 0) != 1) { $retval_0 = 0; return $retval_0 | 0; } $top_lmas_num_ = $this + 44 | 0; if ((_fread($top_lmas_num_ | 0, 4, 1, $fp | 0) | 0) != 1) { $retval_0 = 0; return $retval_0 | 0; } if ((HEAP32[$top_lmas_num_ >> 2] | 0) >>> 0 >= (HEAP32[$lma_idx_buf_len_ >> 2] | 0) >>> 0) { $retval_0 = 0; return $retval_0 | 0; } __ZN10ime_pinyin8DictTrie13free_resourceEb($this, 0); $root_ = $this + 12 | 0; HEAP32[$root_ >> 2] = _malloc(HEAP32[$lma_node_num_le0_ >> 2] << 4) | 0; $nodes_ge1_ = $this + 16 | 0; HEAP32[$nodes_ge1_ >> 2] = _malloc((HEAP32[$lma_node_num_ge1_ >> 2] | 0) * 10 | 0) | 0; $lma_idx_buf_ = $this + 32 | 0; HEAP32[$lma_idx_buf_ >> 2] = _malloc(HEAP32[$lma_idx_buf_len_ >> 2] | 0) | 0; HEAP32[$this + 40 >> 2] = ((HEAP32[$lma_idx_buf_len_ >> 2] | 0) >>> 0) / 3 | 0; $call29 = __ZN10ime_pinyin12SpellingTrie16get_spelling_numEv(__ZN10ime_pinyin12SpellingTrie12get_instanceEv() | 0) | 0; $add = $call29 + 1 | 0; if ((HEAP32[$lma_node_num_le0_ >> 2] | 0) >>> 0 > $add >>> 0) { ___assert_func(3680, 196, 4672, 2640); return 0; } $splid_le0_index_ = $this + 20 | 0; HEAP32[$splid_le0_index_ >> 2] = _malloc($add << 1) | 0; $parsing_marks_ = $this + 48 | 0; HEAP32[$parsing_marks_ >> 2] = __Znaj(2400) | 0; $mile_stones_ = $this + 56 | 0; HEAP32[$mile_stones_ >> 2] = __Znaj(400) | 0; FUNCTION_TABLE_viii[HEAP32[(HEAP32[$this >> 2] | 0) + 20 >> 2] & 15]($this, 0, 1); $18 = HEAP32[$root_ >> 2] | 0; do { if (($18 | 0) != 0) { if ((HEAP32[$nodes_ge1_ >> 2] | 0) == 0) { break; } if ((HEAP32[$lma_idx_buf_ >> 2] | 0) == 0) { break; } if ((HEAP32[$splid_le0_index_ >> 2] | 0) == 0) { break; } if ((HEAP32[$parsing_marks_ >> 2] | 0) == 0) { break; } if ((HEAP32[$mile_stones_ >> 2] | 0) == 0) { break; } $call57 = _fread($18 | 0, 16, HEAP32[$lma_node_num_le0_ >> 2] | 0, $fp | 0) | 0; if (($call57 | 0) != (HEAP32[$lma_node_num_le0_ >> 2] | 0)) { $retval_0 = 0; return $retval_0 | 0; } $call64 = _fread(HEAP32[$nodes_ge1_ >> 2] | 0, 10, HEAP32[$lma_node_num_ge1_ >> 2] | 0, $fp | 0) | 0; if (($call64 | 0) != (HEAP32[$lma_node_num_ge1_ >> 2] | 0)) { $retval_0 = 0; return $retval_0 | 0; } $call71 = _fread(HEAP32[$lma_idx_buf_ >> 2] | 0, 1, HEAP32[$lma_idx_buf_len_ >> 2] | 0, $fp | 0) | 0; if (($call71 | 0) != (HEAP32[$lma_idx_buf_len_ >> 2] | 0)) { $retval_0 = 0; return $retval_0 | 0; } if ((HEAP32[$lma_node_num_le0_ >> 2] | 0) >>> 0 > 1) { $last_splid_032 = 30; $last_pos_033_off0 = 0; $i_034 = 1; while (1) { $36 = HEAP16[(HEAP32[$root_ >> 2] | 0) + ($i_034 << 4) + 8 >> 1] | 0; if (($last_splid_032 & 65535) < ($36 & 65535)) { $splid_030 = $last_splid_032; while (1) { HEAP16[(HEAP32[$splid_le0_index_ >> 2] | 0) + (($splid_030 & 65535) - 30 << 1) >> 1] = $last_pos_033_off0; $inc = $splid_030 + 1 & 65535; $39 = HEAP16[(HEAP32[$root_ >> 2] | 0) + ($i_034 << 4) + 8 >> 1] | 0; if (($inc & 65535) < ($39 & 65535)) { $splid_030 = $inc; } else { $_lcssa = $39; break; } } } else { $_lcssa = $36; } HEAP16[(HEAP32[$splid_le0_index_ >> 2] | 0) + (($_lcssa & 65535) - 30 << 1) >> 1] = $i_034 & 65535; $42 = HEAP16[(HEAP32[$root_ >> 2] | 0) + ($i_034 << 4) + 8 >> 1] | 0; $inc99 = $i_034 + 1 | 0; if ($inc99 >>> 0 < (HEAP32[$lma_node_num_le0_ >> 2] | 0) >>> 0) { $last_splid_032 = $42; $last_pos_033_off0 = $i_034 & 65535; $i_034 = $inc99; } else { break; } } $last_splid_0_lcssa = $42 + 1 & 65535; $last_pos_0_lcssa = $i_034; } else { $last_splid_0_lcssa = 31; $last_pos_0_lcssa = 0; } $conv10624 = $last_splid_0_lcssa & 65535; $add107 = $call29 + 31 | 0; if ($conv10624 >>> 0 >= $add107 >>> 0) { $retval_0 = 1; return $retval_0 | 0; } $conv117 = $last_pos_0_lcssa + 1 & 65535; $splid101_026 = $last_splid_0_lcssa; $conv10627 = $conv10624; while (1) { $sub111 = $conv10627 - 30 | 0; if ($sub111 >>> 0 >= $add >>> 0) { label = 629; break; } HEAP16[(HEAP32[$splid_le0_index_ >> 2] | 0) + ($sub111 << 1) >> 1] = $conv117; $splid101_0 = $splid101_026 + 1 & 65535; $conv106 = $splid101_0 & 65535; if ($conv106 >>> 0 < $add107 >>> 0) { $splid101_026 = $splid101_0; $conv10627 = $conv106; } else { $retval_0 = 1; label = 642; break; } } if ((label | 0) == 629) { ___assert_func(3680, 238, 4672, 1696); return 0; } else if ((label | 0) == 642) { return $retval_0 | 0; } } } while (0); __ZN10ime_pinyin8DictTrie13free_resourceEb($this, 0); $retval_0 = 0; return $retval_0 | 0; } function __ZN10ime_pinyin8DictTrie16reset_milestonesEtt($this, $from_step, $from_handle) { $this = $this | 0; $from_step = $from_step | 0; $from_handle = $from_handle | 0; var $mile_stones_pos_5 = 0; if ($from_step << 16 >> 16 == 0) { HEAP16[$this + 52 >> 1] = 0; HEAP16[$this + 60 >> 1] = 1; return; } if ($from_handle << 16 >> 16 == 0) { return; } $mile_stones_pos_5 = $this + 60 | 0; if ((HEAPU16[$mile_stones_pos_5 >> 1] | 0) <= ($from_handle & 65535)) { return; } HEAP16[$mile_stones_pos_5 >> 1] = $from_handle; HEAP16[$this + 52 >> 1] = HEAP16[(HEAP32[$this + 56 >> 2] | 0) + (($from_handle & 65535) << 2) >> 1] | 0; return; } function __ZN10ime_pinyin8DictTrie23get_homo_idx_buf_offsetEPKNS_10LmaNodeGE1E($this, $node) { $this = $this | 0; $node = $node | 0; return (HEAPU8[$node + 9 | 0] | 0) << 16 | (HEAPU16[$node + 2 >> 1] | 0) | 0; } function __ZN10ime_pinyin8DictTrie14get_son_offsetEPKNS_10LmaNodeGE1E($this, $node) { $this = $this | 0; $node = $node | 0; return (HEAPU8[$node + 8 | 0] | 0) << 16 | (HEAPU16[$node >> 1] | 0) | 0; } function __ZN10ime_pinyin8DictTrie15fill_lpi_bufferEPNS_10LmaPsbItemEjjPNS_10LmaNodeGE1Et($this, $lpi_items, $lpi_max, $homo_buf_off, $node, $lma_len) { $this = $this | 0; $lpi_items = $lpi_items | 0; $lpi_max = $lpi_max | 0; $homo_buf_off = $homo_buf_off | 0; $node = $node | 0; $lma_len = $lma_len | 0; var $call = 0, $num_of_homo = 0, $0 = 0, $lpi_num_0 = 0, $bf_value = 0, $2 = 0, $inc = 0, $lpi_num_1 = 0, label = 0; $call = __ZN10ime_pinyin5NGram12get_instanceEv() | 0; $num_of_homo = $node + 7 | 0; $0 = ($lma_len & 65535) << 24 & 251658240; $lpi_num_0 = 0; while (1) { if ($lpi_num_0 >>> 0 >= (HEAPU8[$num_of_homo] | 0) >>> 0) { $lpi_num_1 = $lpi_num_0; label = 661; break; } $bf_value = (__ZN10ime_pinyin8DictTrie12get_lemma_idEj($this, $lpi_num_0 + $homo_buf_off | 0) | 0) & 16777215; $2 = $lpi_items + ($lpi_num_0 << 3) | 0; HEAP32[$2 >> 2] = $bf_value | $0 | HEAP32[$2 >> 2] & -268435456; HEAP16[$lpi_items + ($lpi_num_0 << 3) + 4 >> 1] = ~~+__ZN10ime_pinyin5NGram11get_uni_psbEj($call, $bf_value); $inc = $lpi_num_0 + 1 | 0; if ($inc >>> 0 < $lpi_max >>> 0) { $lpi_num_0 = $inc; } else { $lpi_num_1 = $inc; label = 660; break; } } if ((label | 0) == 660) { return $lpi_num_1 | 0; } else if ((label | 0) == 661) { return $lpi_num_1 | 0; } return 0; } function __ZN10ime_pinyin8DictTrie11extend_dictEtPKNS_11DictExtParaEPNS_10LmaPsbItemEjPj($this, $from_handle, $dep, $lpi_items, $lpi_max, $lpi_num) { $this = $this | 0; $from_handle = $from_handle | 0; $dep = $dep | 0; $lpi_items = $lpi_items | 0; $lpi_max = $lpi_max | 0; $lpi_num = $lpi_num | 0; var $0 = 0, $retval_0 = 0; if (($dep | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $0 = HEAP16[$dep + 80 >> 1] | 0; if ($from_handle << 16 >> 16 == 0) { if ($0 << 16 >> 16 != 0) { ___assert_func(3680, 375, 5296, 1152); return 0; } $retval_0 = __ZN10ime_pinyin8DictTrie12extend_dict0EtPKNS_11DictExtParaEPNS_10LmaPsbItemEjPj($this, $from_handle, $dep, $lpi_items, $lpi_max, $lpi_num) | 0; return $retval_0 | 0; } if ($0 << 16 >> 16 == 1) { $retval_0 = __ZN10ime_pinyin8DictTrie12extend_dict1EtPKNS_11DictExtParaEPNS_10LmaPsbItemEjPj($this, $from_handle, $dep, $lpi_items, $lpi_max, $lpi_num) | 0; return $retval_0 | 0; } else { $retval_0 = __ZN10ime_pinyin8DictTrie12extend_dict2EtPKNS_11DictExtParaEPNS_10LmaPsbItemEjPj($this, $from_handle, $dep, $lpi_items, $lpi_max, $lpi_num) | 0; return $retval_0 | 0; } return 0; } function __ZN10ime_pinyin8DictTrie12extend_dict0EtPKNS_11DictExtParaEPNS_10LmaPsbItemEjPj($this, $from_handle, $dep, $lpi_items, $lpi_max, $lpi_num) { $this = $this | 0; $from_handle = $from_handle | 0; $dep = $dep | 0; $lpi_items = $lpi_items | 0; $lpi_max = $lpi_max | 0; $lpi_num = $lpi_num | 0; var $1 = 0, $2 = 0, $3 = 0, $call5 = 0, $root_ = 0, $conv6 = 0, $5 = 0, $conv8 = 0, $conv10 = 0, $add = 0, $conv14 = 0, $son_1st_off = 0, $mile_stones_pos_ = 0, $parsing_marks_pos_ = 0, $parsing_marks_ = 0, $8 = 0, $mile_stones_ = 0, $sub87 = 0, $spl_trie_ = 0, $son_pos_0 = 0, $ret_handle_0 = 0, $10 = 0, $add_ptr = 0, $spl_idx = 0, $11 = 0, $14 = 0, $call44 = 0, $18 = 0, $20 = 0, $26 = 0, $35 = 0, $ret_handle_1 = 0, $ret_handle_2 = 0, label = 0; if (!(($dep | 0) != 0 & $from_handle << 16 >> 16 == 0)) { ___assert_func(3680, 391, 5168, 976); return 0; } HEAP32[$lpi_num >> 2] = 0; $1 = HEAP16[$dep + (HEAPU16[$dep + 80 >> 1] << 1) >> 1] | 0; $2 = HEAP16[$dep + 88 >> 1] | 0; $3 = HEAP16[$dep + 90 >> 1] | 0; $call5 = __ZN10ime_pinyin8LpiCache9is_cachedEt(__ZN10ime_pinyin8LpiCache12get_instanceEv() | 0, $1) | 0; $root_ = $this + 12 | 0; $conv6 = $2 & 65535; $5 = HEAP32[$this + 20 >> 2] | 0; $conv8 = HEAPU16[$5 + ($conv6 - 30 << 1) >> 1] | 0; $conv10 = $3 & 65535; $add = $conv10 + $conv6 | 0; $conv14 = HEAPU16[$5 + ($add - 30 << 1) >> 1] | 0; $son_1st_off = HEAP32[$root_ >> 2] | 0; $mile_stones_pos_ = $this + 60 | 0; $parsing_marks_pos_ = $this + 52 | 0; $parsing_marks_ = $this + 48 | 0; $8 = $conv10 << 24; $mile_stones_ = $this + 56 | 0; $sub87 = $add - 1 | 0; $spl_trie_ = $this + 8 | 0; $ret_handle_0 = 0; $son_pos_0 = $conv8; while (1) { if ($son_pos_0 >>> 0 >= $conv14 >>> 0) { $ret_handle_2 = $ret_handle_0; label = 693; break; } if ((HEAP32[$son_1st_off >> 2] | 0) != 1) { label = 680; break; } $10 = HEAP32[$root_ >> 2] | 0; $add_ptr = $10 + ($son_pos_0 << 4) | 0; $spl_idx = $10 + ($son_pos_0 << 4) + 8 | 0; $11 = HEAP16[$spl_idx >> 1] | 0; if (!(($11 & 65535) >= ($2 & 65535) & ($11 & 65535 | 0) < ($add | 0))) { label = 682; break; } do { if (!$call5) { if ((HEAP32[$lpi_num >> 2] | 0) >>> 0 >= $lpi_max >>> 0) { break; } if (!(($son_pos_0 | 0) == ($conv8 | 0) | (__ZNK10ime_pinyin12SpellingTrie16is_half_id_yunmuEt(HEAP32[$spl_trie_ >> 2] | 0, $1) | 0) ^ 1)) { break; } $14 = HEAP32[$lpi_num >> 2] | 0; $call44 = __ZN10ime_pinyin8DictTrie15fill_lpi_bufferEPNS_10LmaPsbItemEjPNS_10LmaNodeLE0E($this, $lpi_items + ($14 << 3) | 0, $lpi_max - $14 | 0, $add_ptr) | 0; HEAP32[$lpi_num >> 2] = (HEAP32[$lpi_num >> 2] | 0) + $call44; } } while (0); do { if ((HEAP16[$spl_idx >> 1] | 0) == $2 << 16 >> 16) { if ((HEAPU16[$mile_stones_pos_ >> 1] | 0) >= 100) { $ret_handle_1 = $ret_handle_0; break; } $18 = HEAP16[$parsing_marks_pos_ >> 1] | 0; if (($18 & 65535) >= 600) { $ret_handle_1 = $ret_handle_0; break; } $20 = (HEAP32[$parsing_marks_ >> 2] | 0) + (($18 & 65535) << 2) | 0; HEAP32[$20 >> 2] = HEAP32[$20 >> 2] & -16777216 | $son_pos_0 & 16777215; $26 = (HEAP32[$parsing_marks_ >> 2] | 0) + (HEAPU16[$parsing_marks_pos_ >> 1] << 2) | 0; HEAP32[$26 >> 2] = HEAP32[$26 >> 2] & 16777215 | $8; HEAP16[(HEAP32[$mile_stones_ >> 2] | 0) + (HEAPU16[$mile_stones_pos_ >> 1] << 2) >> 1] = HEAP16[$parsing_marks_pos_ >> 1] | 0; HEAP16[(HEAP32[$mile_stones_ >> 2] | 0) + (HEAPU16[$mile_stones_pos_ >> 1] << 2) + 2 >> 1] = 1; $35 = HEAP16[$mile_stones_pos_ >> 1] | 0; HEAP16[$parsing_marks_pos_ >> 1] = (HEAP16[$parsing_marks_pos_ >> 1] | 0) + 1 & 65535; HEAP16[$mile_stones_pos_ >> 1] = (HEAP16[$mile_stones_pos_ >> 1] | 0) + 1 & 65535; $ret_handle_1 = $35; } else { $ret_handle_1 = $ret_handle_0; } } while (0); if ((HEAPU16[$spl_idx >> 1] | 0) < ($sub87 | 0)) { $ret_handle_0 = $ret_handle_1; $son_pos_0 = $son_pos_0 + 1 | 0; } else { $ret_handle_2 = $ret_handle_1; label = 694; break; } } if ((label | 0) == 680) { ___assert_func(3680, 408, 5168, 824); return 0; } else if ((label | 0) == 682) { ___assert_func(3680, 410, 5168, 624); return 0; } else if ((label | 0) == 693) { return $ret_handle_2 | 0; } else if ((label | 0) == 694) { return $ret_handle_2 | 0; } return 0; } function __ZN10ime_pinyin8DictTrie12extend_dict1EtPKNS_11DictExtParaEPNS_10LmaPsbItemEjPj($this, $from_handle, $dep, $lpi_items, $lpi_max, $lpi_num) { $this = $this | 0; $from_handle = $from_handle | 0; $dep = $dep | 0; $lpi_items = $lpi_items | 0; $lpi_max = $lpi_max | 0; $lpi_num = $lpi_num | 0; var $conv = 0, $mile_stones_pos_ = 0, $1 = 0, $2 = 0, $mile_stones_ = 0, $3 = 0, $mark_num = 0, $mark_start = 0, $parsing_marks_ = 0, $root_ = 0, $lma_node_num_ge1_ = 0, $nodes_ge1_ = 0, $conv37 = 0, $sub60 = 0, $add44 = 0, $parsing_marks_pos_ = 0, $ret_val_045 = 0, $h_pos_044 = 0, $p_mark_sroa_0_0_copyload = 0, $8 = 0, $bf_clear21 = 0, $conv1741 = 0, $ret_val_140 = 0, $ext_pos_039 = 0, $9 = 0, $add_ptr22_sum = 0, $num_of_son = 0, $son_1st_off = 0, $found_start_0 = 0, $found_num_0 = 0, $son_pos_0 = 0, $11 = 0, $13 = 0, $add_ptr34_sum = 0, $add_ptr35 = 0, $spl_idx = 0, $14 = 0, $15 = 0, $call49 = 0, $found_start_2 = 0, $found_num_1 = 0, $20 = 0, $23 = 0, $29 = 0, $ret_val_2 = 0, $inc103 = 0, $conv17 = 0, $ret_val_1_lcssa = 0, $inc106 = 0, $41 = 0, $ret_handle_0 = 0, label = 0; if (($dep | 0) == 0) { ___assert_func(3680, 450, 5040, 464); return 0; } $conv = $from_handle & 65535; if ($from_handle << 16 >> 16 == 0) { ___assert_func(3680, 450, 5040, 464); return 0; } $mile_stones_pos_ = $this + 60 | 0; if ((HEAPU16[$mile_stones_pos_ >> 1] | 0) <= ($from_handle & 65535)) { ___assert_func(3680, 450, 5040, 464); return 0; } $1 = HEAP16[$dep + 88 >> 1] | 0; $2 = HEAP16[$dep + 90 >> 1] | 0; $mile_stones_ = $this + 56 | 0; $3 = HEAP32[$mile_stones_ >> 2] | 0; $mark_num = $3 + ($conv << 2) + 2 | 0; if ((HEAP16[$mark_num >> 1] | 0) == 0) { $ret_handle_0 = 0; return $ret_handle_0 | 0; } $mark_start = $3 + ($conv << 2) | 0; $parsing_marks_ = $this + 48 | 0; $root_ = $this + 12 | 0; $lma_node_num_ge1_ = $this + 28 | 0; $nodes_ge1_ = $this + 16 | 0; $conv37 = $1 & 65535; $sub60 = $conv37 - 1 + ($2 & 65535) | 0; $add44 = ($2 & 65535) + $conv37 | 0; $parsing_marks_pos_ = $this + 52 | 0; $h_pos_044 = 0; $ret_val_045 = 0; L852 : while (1) { $p_mark_sroa_0_0_copyload = HEAP32[(HEAP32[$parsing_marks_ >> 2] | 0) + ((HEAPU16[$mark_start >> 1] | 0) + ($h_pos_044 & 65535) << 2) >> 2] | 0; $8 = $p_mark_sroa_0_0_copyload >>> 24; if (($8 | 0) == 0) { $ret_val_1_lcssa = $ret_val_045; } else { $bf_clear21 = $p_mark_sroa_0_0_copyload & 16777215; $ext_pos_039 = 0; $ret_val_140 = $ret_val_045; $conv1741 = 0; while (1) { $9 = HEAP32[$root_ >> 2] | 0; $add_ptr22_sum = $conv1741 + $bf_clear21 | 0; $num_of_son = $9 + ($add_ptr22_sum << 4) + 10 | 0; $son_1st_off = $9 + ($add_ptr22_sum << 4) | 0; $son_pos_0 = 0; $found_num_0 = 0; $found_start_0 = 0; while (1) { if ($son_pos_0 >>> 0 >= (HEAPU16[$num_of_son >> 1] | 0) >>> 0) { $ret_val_2 = $ret_val_140; break; } $11 = HEAP32[$son_1st_off >> 2] | 0; if ($11 >>> 0 > (HEAP32[$lma_node_num_ge1_ >> 2] | 0) >>> 0) { label = 706; break L852; } $13 = HEAP32[$nodes_ge1_ >> 2] | 0; $add_ptr34_sum = $11 + $son_pos_0 | 0; $add_ptr35 = $13 + ($add_ptr34_sum * 10 | 0) | 0; $spl_idx = $13 + ($add_ptr34_sum * 10 | 0) + 4 | 0; $14 = HEAP16[$spl_idx >> 1] | 0; if (($14 & 65535) >= ($1 & 65535) & ($14 & 65535 | 0) < ($add44 | 0)) { $15 = HEAP32[$lpi_num >> 2] | 0; if ($15 >>> 0 < $lpi_max >>> 0) { $call49 = __ZN10ime_pinyin8DictTrie15fill_lpi_bufferEPNS_10LmaPsbItemEjjPNS_10LmaNodeGE1Et($this, $lpi_items + ($15 << 3) | 0, $lpi_max - $15 | 0, __ZN10ime_pinyin8DictTrie23get_homo_idx_buf_offsetEPKNS_10LmaNodeGE1E(0, $add_ptr35) | 0, $add_ptr35, 2) | 0; HEAP32[$lpi_num >> 2] = (HEAP32[$lpi_num >> 2] | 0) + $call49; } $found_num_1 = $found_num_0 + 1 | 0; $found_start_2 = ($found_num_0 | 0) == 0 ? $son_pos_0 : $found_start_0; } else { $found_num_1 = $found_num_0; $found_start_2 = $found_start_0; } if ((HEAPU16[$spl_idx >> 1] | 0) >= ($sub60 | 0)) { label = 713; break; } if (($son_pos_0 | 0) == ((HEAPU16[$num_of_son >> 1] | 0) - 1 | 0)) { label = 713; break; } else { $son_pos_0 = $son_pos_0 + 1 | 0; $found_num_0 = $found_num_1; $found_start_0 = $found_start_2; } } do { if ((label | 0) == 713) { label = 0; if (($found_num_1 | 0) == 0) { $ret_val_2 = $ret_val_140; break; } do { if ((HEAPU16[$mile_stones_pos_ >> 1] | 0) < 100) { $20 = HEAP16[$parsing_marks_pos_ >> 1] | 0; if (($20 & 65535) >= 600) { break; } $23 = (HEAP32[$parsing_marks_ >> 2] | 0) + (($20 & 65535) << 2) | 0; HEAP32[$23 >> 2] = HEAP32[$23 >> 2] & -16777216 | (HEAP32[$son_1st_off >> 2] | 0) + $found_start_2 & 16777215; $29 = (HEAP32[$parsing_marks_ >> 2] | 0) + (HEAPU16[$parsing_marks_pos_ >> 1] << 2) | 0; HEAP32[$29 >> 2] = HEAP32[$29 >> 2] & 16777215 | $found_num_1 << 24; if (($ret_val_140 | 0) == 0) { HEAP16[(HEAP32[$mile_stones_ >> 2] | 0) + (HEAPU16[$mile_stones_pos_ >> 1] << 2) >> 1] = HEAP16[$parsing_marks_pos_ >> 1] | 0; } HEAP16[$parsing_marks_pos_ >> 1] = (HEAP16[$parsing_marks_pos_ >> 1] | 0) + 1 & 65535; } } while (0); $ret_val_2 = $ret_val_140 + 1 | 0; } } while (0); $inc103 = $ext_pos_039 + 1 & 65535; $conv17 = $inc103 & 65535; if ($conv17 >>> 0 < $8 >>> 0) { $ext_pos_039 = $inc103; $ret_val_140 = $ret_val_2; $conv1741 = $conv17; } else { $ret_val_1_lcssa = $ret_val_2; break; } } } $inc106 = $h_pos_044 + 1 & 65535; if (($inc106 & 65535) < (HEAPU16[$mark_num >> 1] | 0)) { $h_pos_044 = $inc106; $ret_val_045 = $ret_val_1_lcssa; } else { break; } } if ((label | 0) == 706) { ___assert_func(3680, 472, 5040, 4312); return 0; } if (($ret_val_1_lcssa | 0) == 0) { $ret_handle_0 = 0; return $ret_handle_0 | 0; } HEAP16[(HEAP32[$mile_stones_ >> 2] | 0) + (HEAPU16[$mile_stones_pos_ >> 1] << 2) + 2 >> 1] = $ret_val_1_lcssa & 65535; $41 = HEAP16[$mile_stones_pos_ >> 1] | 0; HEAP16[$mile_stones_pos_ >> 1] = $41 + 1 & 65535; $ret_handle_0 = $41; return $ret_handle_0 | 0; } function __ZN10ime_pinyin8DictTrie12extend_dict2EtPKNS_11DictExtParaEPNS_10LmaPsbItemEjPj($this, $from_handle, $dep, $lpi_items, $lpi_max, $lpi_num) { $this = $this | 0; $from_handle = $from_handle | 0; $dep = $dep | 0; $lpi_items = $lpi_items | 0; $lpi_max = $lpi_max | 0; $lpi_num = $lpi_num | 0; var $conv = 0, $mile_stones_pos_ = 0, $1 = 0, $2 = 0, $mile_stones_ = 0, $3 = 0, $mark_num = 0, $mark_start = 0, $parsing_marks_ = 0, $nodes_ge1_ = 0, $conv40 = 0, $sub67 = 0, $add47 = 0, $splids_extended = 0, $parsing_marks_pos_ = 0, $ret_val_046 = 0, $h_pos_045 = 0, $p_mark_sroa_0_0_copyload = 0, $8 = 0, $bf_clear21 = 0, $conv1742 = 0, $ret_val_141 = 0, $ext_pos_040 = 0, $9 = 0, $add_ptr22_sum = 0, $add_ptr24 = 0, $num_of_son = 0, $son_1st_off_l = 0, $son_1st_off_h = 0, $found_start_0 = 0, $found_num_0 = 0, $son_pos_0 = 0, $13 = 0, $add_ptr37_sum = 0, $add_ptr38 = 0, $spl_idx = 0, $14 = 0, $15 = 0, $call51 = 0, $call56 = 0, $found_start_2 = 0, $found_num_1 = 0, $21 = 0, $add85 = 0, $23 = 0, $29 = 0, $ret_val_2 = 0, $inc111 = 0, $conv17 = 0, $ret_val_1_lcssa = 0, $inc114 = 0, $41 = 0, $ret_handle_0 = 0, label = 0; if (($dep | 0) == 0) { ___assert_func(3680, 528, 4912, 464); return 0; } $conv = $from_handle & 65535; if ($from_handle << 16 >> 16 == 0) { ___assert_func(3680, 528, 4912, 464); return 0; } $mile_stones_pos_ = $this + 60 | 0; if ((HEAPU16[$mile_stones_pos_ >> 1] | 0) <= ($from_handle & 65535)) { ___assert_func(3680, 528, 4912, 464); return 0; } $1 = HEAP16[$dep + 88 >> 1] | 0; $2 = HEAP16[$dep + 90 >> 1] | 0; $mile_stones_ = $this + 56 | 0; $3 = HEAP32[$mile_stones_ >> 2] | 0; $mark_num = $3 + ($conv << 2) + 2 | 0; if ((HEAP16[$mark_num >> 1] | 0) == 0) { $ret_handle_0 = 0; return $ret_handle_0 | 0; } $mark_start = $3 + ($conv << 2) | 0; $parsing_marks_ = $this + 48 | 0; $nodes_ge1_ = $this + 16 | 0; $conv40 = $1 & 65535; $sub67 = $conv40 - 1 + ($2 & 65535) | 0; $add47 = ($2 & 65535) + $conv40 | 0; $splids_extended = $dep + 80 | 0; $parsing_marks_pos_ = $this + 52 | 0; $h_pos_045 = 0; $ret_val_046 = 0; L901 : while (1) { $p_mark_sroa_0_0_copyload = HEAP32[(HEAP32[$parsing_marks_ >> 2] | 0) + ((HEAPU16[$mark_start >> 1] | 0) + ($h_pos_045 & 65535) << 2) >> 2] | 0; $8 = $p_mark_sroa_0_0_copyload >>> 24; if (($8 | 0) == 0) { $ret_val_1_lcssa = $ret_val_046; } else { $bf_clear21 = $p_mark_sroa_0_0_copyload & 16777215; $ext_pos_040 = 0; $ret_val_141 = $ret_val_046; $conv1742 = 0; while (1) { $9 = HEAP32[$nodes_ge1_ >> 2] | 0; $add_ptr22_sum = $conv1742 + $bf_clear21 | 0; $add_ptr24 = $9 + ($add_ptr22_sum * 10 | 0) | 0; $num_of_son = $9 + ($add_ptr22_sum * 10 | 0) + 6 | 0; $son_1st_off_l = $add_ptr24 | 0; $son_1st_off_h = $9 + ($add_ptr22_sum * 10 | 0) + 8 | 0; $son_pos_0 = 0; $found_num_0 = 0; $found_start_0 = 0; while (1) { if ($son_pos_0 >>> 0 >= (HEAPU8[$num_of_son] | 0) >>> 0) { $ret_val_2 = $ret_val_141; break; } if ((HEAP16[$son_1st_off_l >> 1] | 0) == 0) { if ((HEAP8[$son_1st_off_h] | 0) == 0) { label = 743; break L901; } } $13 = HEAP32[$nodes_ge1_ >> 2] | 0; $add_ptr37_sum = (__ZN10ime_pinyin8DictTrie14get_son_offsetEPKNS_10LmaNodeGE1E(0, $add_ptr24) | 0) + $son_pos_0 | 0; $add_ptr38 = $13 + ($add_ptr37_sum * 10 | 0) | 0; $spl_idx = $13 + ($add_ptr37_sum * 10 | 0) + 4 | 0; $14 = HEAP16[$spl_idx >> 1] | 0; if (($14 & 65535) >= ($1 & 65535) & ($14 & 65535 | 0) < ($add47 | 0)) { $15 = HEAP32[$lpi_num >> 2] | 0; if ($15 >>> 0 < $lpi_max >>> 0) { $call51 = __ZN10ime_pinyin8DictTrie23get_homo_idx_buf_offsetEPKNS_10LmaNodeGE1E(0, $add_ptr38) | 0; $call56 = __ZN10ime_pinyin8DictTrie15fill_lpi_bufferEPNS_10LmaPsbItemEjjPNS_10LmaNodeGE1Et($this, $lpi_items + ($15 << 3) | 0, $lpi_max - $15 | 0, $call51, $add_ptr38, (HEAP16[$splids_extended >> 1] | 0) + 1 & 65535) | 0; HEAP32[$lpi_num >> 2] = (HEAP32[$lpi_num >> 2] | 0) + $call56; } $found_num_1 = $found_num_0 + 1 | 0; $found_start_2 = ($found_num_0 | 0) == 0 ? $son_pos_0 : $found_start_0; } else { $found_num_1 = $found_num_0; $found_start_2 = $found_start_0; } if ((HEAPU16[$spl_idx >> 1] | 0) >= ($sub67 | 0)) { label = 750; break; } if (($son_pos_0 | 0) == ((HEAPU8[$num_of_son] | 0) - 1 | 0)) { label = 750; break; } else { $son_pos_0 = $son_pos_0 + 1 | 0; $found_num_0 = $found_num_1; $found_start_0 = $found_start_2; } } do { if ((label | 0) == 750) { label = 0; if (($found_num_1 | 0) == 0) { $ret_val_2 = $ret_val_141; break; } do { if ((HEAPU16[$mile_stones_pos_ >> 1] | 0) < 100) { $21 = HEAP16[$parsing_marks_pos_ >> 1] | 0; if (($21 & 65535) >= 600) { break; } $add85 = (__ZN10ime_pinyin8DictTrie14get_son_offsetEPKNS_10LmaNodeGE1E(0, $add_ptr24) | 0) + $found_start_2 | 0; $23 = (HEAP32[$parsing_marks_ >> 2] | 0) + (($21 & 65535) << 2) | 0; HEAP32[$23 >> 2] = HEAP32[$23 >> 2] & -16777216 | $add85 & 16777215; $29 = (HEAP32[$parsing_marks_ >> 2] | 0) + (HEAPU16[$parsing_marks_pos_ >> 1] << 2) | 0; HEAP32[$29 >> 2] = HEAP32[$29 >> 2] & 16777215 | $found_num_1 << 24; if (($ret_val_141 | 0) == 0) { HEAP16[(HEAP32[$mile_stones_ >> 2] | 0) + (HEAPU16[$mile_stones_pos_ >> 1] << 2) >> 1] = HEAP16[$parsing_marks_pos_ >> 1] | 0; } HEAP16[$parsing_marks_pos_ >> 1] = (HEAP16[$parsing_marks_pos_ >> 1] | 0) + 1 & 65535; } } while (0); $ret_val_2 = $ret_val_141 + 1 | 0; } } while (0); $inc111 = $ext_pos_040 + 1 & 65535; $conv17 = $inc111 & 65535; if ($conv17 >>> 0 < $8 >>> 0) { $ext_pos_040 = $inc111; $ret_val_141 = $ret_val_2; $conv1742 = $conv17; } else { $ret_val_1_lcssa = $ret_val_2; break; } } } $inc114 = $h_pos_045 + 1 & 65535; if (($inc114 & 65535) < (HEAPU16[$mark_num >> 1] | 0)) { $h_pos_045 = $inc114; $ret_val_046 = $ret_val_1_lcssa; } else { break; } } if ((label | 0) == 743) { ___assert_func(3680, 551, 4912, 4112); return 0; } if (($ret_val_1_lcssa | 0) == 0) { $ret_handle_0 = 0; return $ret_handle_0 | 0; } HEAP16[(HEAP32[$mile_stones_ >> 2] | 0) + (HEAPU16[$mile_stones_pos_ >> 1] << 2) + 2 >> 1] = $ret_val_1_lcssa & 65535; $41 = HEAP16[$mile_stones_pos_ >> 1] | 0; HEAP16[$mile_stones_pos_ >> 1] = $41 + 1 & 65535; $ret_handle_0 = $41; return $ret_handle_0 | 0; } function __ZN10ime_pinyin8DictTrie10try_extendEPKttj($this, $splids, $splid_num, $id_lemma) { $this = $this | 0; $splids = $splids | 0; $splid_num = $splid_num | 0; $id_lemma = $id_lemma | 0; var $str = 0, $4 = 0, $nodes_ge1_52 = 0, $lma_node_num_ge1_ = 0, $nodes_ge1_ = 0, $conv650 = 0, $node_049 = 0, $pos_048 = 0, $node_son_047 = 0, $node_son35_046 = 0, $5 = 0, $6 = 0, $son_1st_off = 0, $arrayidx23 = 0, $son_pos_0 = 0, $node_son_1 = 0, $7 = 0, $9 = 0, $add_ptr19_sum = 0, $add_ptr21 = 0, $node_son_2 = 0, $13 = 0, $14 = 0, $conv41 = 0, $son_1st_off_l = 0, $16 = 0, $arrayidx59 = 0, $son_pos36_0 = 0, $node_son35_1 = 0, $conv38 = 0, $19 = 0, $add_ptr53_sum = 0, $add_ptr55 = 0, $node_son35_2 = 0, $node_son35_3 = 0, $node_son_3 = 0, $node_1_in = 0, $node_1 = 0, $inc76 = 0, $node_0_lcssa = 0, $conv83 = 0, $25 = 0, $26 = 0, $arraydecay = 0, $homo_pos_0 = 0, $call87 = 0, $29 = 0, $conv99 = 0, $homo_pos100_0 = 0, $retval_0 = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 8 | 0; $str = sp | 0; if ($splid_num << 16 >> 16 == 0 | ($splids | 0) == 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } $4 = (HEAP32[$this + 12 >> 2] | 0) + (HEAPU16[(HEAP32[$this + 20 >> 2] | 0) + ((HEAPU16[$splids >> 1] | 0) - 30 << 1) >> 1] << 4) | 0; L943 : do { if (($splid_num & 65535) > 1) { $nodes_ge1_52 = $this + 16 | 0; $lma_node_num_ge1_ = $this + 28 | 0; $nodes_ge1_ = $this + 16 | 0; $node_son35_046 = 0; $node_son_047 = 0; $pos_048 = 1; $node_049 = $4; $conv650 = 1; L945 : while (1) { if ($pos_048 << 16 >> 16 == 1) { $5 = $node_049 + 10 | 0; $6 = HEAP16[$5 >> 1] | 0; $son_1st_off = $node_049; $arrayidx23 = $splids + ($conv650 << 1) | 0; $node_son_1 = $node_son_047; $son_pos_0 = 0; while (1) { if (($son_pos_0 & 65535) >= ($6 & 65535)) { $node_son_2 = $node_son_1; break; } $7 = HEAP32[$son_1st_off >> 2] | 0; if ($7 >>> 0 > (HEAP32[$lma_node_num_ge1_ >> 2] | 0) >>> 0) { label = 775; break L945; } $9 = HEAP32[$nodes_ge1_ >> 2] | 0; $add_ptr19_sum = $7 + ($son_pos_0 & 65535) | 0; $add_ptr21 = $9 + ($add_ptr19_sum * 10 | 0) | 0; if ((HEAP16[$9 + ($add_ptr19_sum * 10 | 0) + 4 >> 1] | 0) == (HEAP16[$arrayidx23 >> 1] | 0)) { $node_son_2 = $add_ptr21; break; } else { $node_son_1 = $add_ptr21; $son_pos_0 = $son_pos_0 + 1 & 65535; } } if (($son_pos_0 & 65535) < (HEAPU16[$5 >> 1] | 0)) { $node_1_in = $node_son_2; $node_son_3 = $node_son_2; $node_son35_3 = $node_son35_046; } else { $retval_0 = 0; label = 794; break; } } else { $13 = $node_049; $14 = $node_049 + 6 | 0; $conv41 = HEAPU8[$14] | 0; $son_1st_off_l = $node_049; $16 = $node_049 + 8 | 0; $arrayidx59 = $splids + ($conv650 << 1) | 0; $node_son35_1 = $node_son35_046; $son_pos36_0 = 0; while (1) { $conv38 = $son_pos36_0 & 65535; if ($conv38 >>> 0 >= $conv41 >>> 0) { $node_son35_2 = $node_son35_1; break; } if ((HEAP16[$son_1st_off_l >> 1] | 0) == 0) { if ((HEAP8[$16] | 0) == 0) { label = 782; break L945; } } $19 = HEAP32[$nodes_ge1_52 >> 2] | 0; $add_ptr53_sum = (__ZN10ime_pinyin8DictTrie14get_son_offsetEPKNS_10LmaNodeGE1E(0, $13) | 0) + $conv38 | 0; $add_ptr55 = $19 + ($add_ptr53_sum * 10 | 0) | 0; if ((HEAP16[$19 + ($add_ptr53_sum * 10 | 0) + 4 >> 1] | 0) == (HEAP16[$arrayidx59 >> 1] | 0)) { $node_son35_2 = $add_ptr55; break; } else { $node_son35_1 = $add_ptr55; $son_pos36_0 = $son_pos36_0 + 1 & 65535; } } if ($conv38 >>> 0 < (HEAPU8[$14] | 0) >>> 0) { $node_1_in = $node_son35_2; $node_son_3 = $node_son_047; $node_son35_3 = $node_son35_2; } else { $retval_0 = 0; label = 796; break; } } $node_1 = $node_1_in; $inc76 = $pos_048 + 1 & 65535; if (($inc76 & 65535) < ($splid_num & 65535)) { $node_son35_046 = $node_son35_3; $node_son_047 = $node_son_3; $pos_048 = $inc76; $node_049 = $node_1; $conv650 = $inc76 & 65535; } else { $node_0_lcssa = $node_1; break L943; } } if ((label | 0) == 796) { STACKTOP = sp; return $retval_0 | 0; } else if ((label | 0) == 794) { STACKTOP = sp; return $retval_0 | 0; } else if ((label | 0) == 775) { ___assert_func(3680, 616, 5424, 3944); return 0; } else if ((label | 0) == 782) { ___assert_func(3680, 632, 5424, 3704); return 0; } } else { $node_0_lcssa = $4; } } while (0); if ($splid_num << 16 >> 16 == 1) { $conv83 = HEAPU16[$node_0_lcssa + 12 >> 1] | 0; $25 = $node_0_lcssa + 4 | 0; $26 = $this; $arraydecay = $str | 0; $homo_pos_0 = 0; while (1) { if ($homo_pos_0 >>> 0 >= $conv83 >>> 0) { $retval_0 = 0; label = 797; break; } $call87 = __ZN10ime_pinyin8DictTrie12get_lemma_idEj($this, (HEAP32[$25 >> 2] | 0) + $homo_pos_0 | 0) | 0; FUNCTION_TABLE_iiiii[HEAP32[(HEAP32[$26 >> 2] | 0) + 32 >> 2] & 31]($this, $call87, $arraydecay, 2) | 0; if (($call87 | 0) == ($id_lemma | 0)) { $retval_0 = 1; label = 798; break; } else { $homo_pos_0 = $homo_pos_0 + 1 | 0; } } if ((label | 0) == 797) { STACKTOP = sp; return $retval_0 | 0; } else if ((label | 0) == 798) { STACKTOP = sp; return $retval_0 | 0; } } else { $29 = $node_0_lcssa; $conv99 = HEAPU8[$node_0_lcssa + 7 | 0] | 0; $homo_pos100_0 = 0; while (1) { if ($homo_pos100_0 >>> 0 >= $conv99 >>> 0) { $retval_0 = 0; label = 799; break; } if ((__ZN10ime_pinyin8DictTrie12get_lemma_idEj($this, (__ZN10ime_pinyin8DictTrie23get_homo_idx_buf_offsetEPKNS_10LmaNodeGE1E(0, $29) | 0) + $homo_pos100_0 | 0) | 0) == ($id_lemma | 0)) { $retval_0 = 1; label = 800; break; } else { $homo_pos100_0 = $homo_pos100_0 + 1 | 0; } } if ((label | 0) == 799) { STACKTOP = sp; return $retval_0 | 0; } else if ((label | 0) == 800) { STACKTOP = sp; return $retval_0 | 0; } } return 0; } function __ZN10ime_pinyin8DictTrie10close_dictEv($this) { $this = $this | 0; return 1; } function __ZN10ime_pinyin8DictTrie16number_of_lemmasEv($this) { $this = $this | 0; return 0; } function __ZN10ime_pinyin8DictTrie9put_lemmaEPtS1_tt($this, $lemma_str, $splids, $lemma_len, $count) { $this = $this | 0; $lemma_str = $lemma_str | 0; $splids = $splids | 0; $lemma_len = $lemma_len | 0; $count = $count | 0; return 0; } function __ZN10ime_pinyin8DictTrie12update_lemmaEjsb($this, $lemma_id, $delta_count, $selected) { $this = $this | 0; $lemma_id = $lemma_id | 0; $delta_count = $delta_count | 0; $selected = $selected | 0; return 0; } function __ZN10ime_pinyin8DictTrie12get_lemma_idEPtS1_t($this, $lemma_str, $splids, $lemma_len) { $this = $this | 0; $lemma_str = $lemma_str | 0; $splids = $splids | 0; $lemma_len = $lemma_len | 0; return 0; } function __ZN10ime_pinyin8DictTrie15get_lemma_scoreEj($this, $lemma_id) { $this = $this | 0; $lemma_id = $lemma_id | 0; return 0; } function __ZN10ime_pinyin8DictTrie15get_lemma_scoreEPtS1_t($this, $lemma_str, $splids, $lemma_len) { $this = $this | 0; $lemma_str = $lemma_str | 0; $splids = $splids | 0; $lemma_len = $lemma_len | 0; return 0; } function __ZN10ime_pinyin8DictTrie12remove_lemmaEj($this, $lemma_id) { $this = $this | 0; $lemma_id = $lemma_id | 0; return 0; } function __ZN10ime_pinyin8DictTrie21get_total_lemma_countEv($this) { $this = $this | 0; return 0; } function __ZN10ime_pinyin8DictTrie11flush_cacheEv($this) { $this = $this | 0; return; } function __ZN10ime_pinyin12AtomDictBaseD1Ev($this) { $this = $this | 0; return; } function __ZN10ime_pinyin12MatrixSearch22reset_pointers_to_nullEv($this) { $this = $this | 0; HEAP32[$this + 12 >> 2] = 0; HEAP32[$this + 16 >> 2] = 0; HEAP32[$this + 20 >> 2] = 0; HEAP32[$this + 76 >> 2] = 0; HEAP32[$this + 80 >> 2] = 0; HEAP32[$this + 88 >> 2] = 0; HEAP32[$this + 96 >> 2] = 0; HEAP32[$this + 100 >> 2] = 0; HEAP32[$this + 104 >> 2] = 0; return; } function __ZN10ime_pinyin8DictTrie13get_lemma_strEjPtt($this, $id_lemma, $str_buf, $str_max) { $this = $this | 0; $id_lemma = $id_lemma | 0; $str_buf = $str_buf | 0; $str_max = $str_max | 0; return __ZN10ime_pinyin8DictList13get_lemma_strEjPtt(HEAP32[$this + 4 >> 2] | 0, $id_lemma, $str_buf, $str_max) | 0; } function __ZN10ime_pinyin8DictTrie31set_total_lemma_count_of_othersEj($this, $count) { $this = $this | 0; $count = $count | 0; __ZN10ime_pinyin5NGram23set_total_freq_none_sysEj(__ZN10ime_pinyin5NGram12get_instanceEv() | 0, $count); return; } function __ZN10ime_pinyin8DictTrie17convert_to_hanzisEPtt($this, $str, $str_len) { $this = $this | 0; $str = $str | 0; $str_len = $str_len | 0; __ZN10ime_pinyin8DictList17convert_to_hanzisEPtt(HEAP32[$this + 4 >> 2] | 0, $str, $str_len); return; } function __ZN10ime_pinyin8DictTrie19convert_to_scis_idsEPtt($this, $str, $str_len) { $this = $this | 0; $str = $str | 0; $str_len = $str_len | 0; __ZN10ime_pinyin8DictList19convert_to_scis_idsEPtt(HEAP32[$this + 4 >> 2] | 0, $str, $str_len); return; } function __ZN10ime_pinyin8DictTrie12get_lemma_idEPKtt($this, $lemma_str, $lemma_len) { $this = $this | 0; $lemma_str = $lemma_str | 0; $lemma_len = $lemma_len | 0; var $retval_0 = 0; if (($lemma_str | 0) == 0 | ($lemma_len & 65535) > 8) { $retval_0 = 0; return $retval_0 | 0; } $retval_0 = __ZN10ime_pinyin8DictList12get_lemma_idEPKtt(HEAP32[$this + 4 >> 2] | 0, $lemma_str, $lemma_len) | 0; return $retval_0 | 0; } function __ZN10ime_pinyin8DictTrie16predict_top_lmasEjPNS_12NPredictItemEjj($this, $his_len, $npre_items, $npre_max, $b4_used) { $this = $this | 0; $his_len = $his_len | 0; $npre_items = $npre_items | 0; $npre_max = $npre_max | 0; $b4_used = $b4_used | 0; var $call = 0, $top_lmas_num_ = 0, $sub = 0, $dict_list_ = 0, $conv10 = 0, $arraydecay20 = 0, $_in = 0, $item_num_0_ph18 = 0, $top_lmas_pos_0_ph17 = 0, $2 = 0, $top_lmas_pos_0 = 0, $call4 = 0, $inc = 0, $item_num_0_ph14 = 0, label = 0; $call = __ZN10ime_pinyin5NGram12get_instanceEv() | 0; $top_lmas_num_ = $this + 44 | 0; $sub = (((HEAP32[$this + 36 >> 2] | 0) >>> 0) / 3 | 0) - (HEAP32[$top_lmas_num_ >> 2] | 0) | 0; $dict_list_ = $this + 4 | 0; if (($npre_max | 0) == 0) { $item_num_0_ph14 = 0; return $item_num_0_ph14 | 0; } $conv10 = $his_len & 65535; $top_lmas_pos_0_ph17 = 0; $item_num_0_ph18 = 0; $_in = $npre_items; $arraydecay20 = $npre_items + 4 | 0; L1009 : while (1) { $2 = $_in; $top_lmas_pos_0 = $top_lmas_pos_0_ph17; do { if ($top_lmas_pos_0 >>> 0 >= (HEAP32[$top_lmas_num_ >> 2] | 0) >>> 0) { $item_num_0_ph14 = $item_num_0_ph18; label = 829; break L1009; } _memset($2 | 0, 0, 20); $call4 = __ZN10ime_pinyin8DictTrie12get_lemma_idEj($this, $sub + $top_lmas_pos_0 | 0) | 0; $top_lmas_pos_0 = $top_lmas_pos_0 + 1 | 0; } while ((__ZN10ime_pinyin8DictList13get_lemma_strEjPtt(HEAP32[$dict_list_ >> 2] | 0, $call4, $arraydecay20, 7) | 0) << 16 >> 16 == 0); HEAPF32[$_in >> 2] = +__ZN10ime_pinyin5NGram11get_uni_psbEj($call, $call4); HEAP16[$npre_items + ($item_num_0_ph18 * 20 | 0) + 18 >> 1] = $conv10; $inc = $item_num_0_ph18 + 1 | 0; if ($inc >>> 0 < $npre_max >>> 0) { $top_lmas_pos_0_ph17 = $top_lmas_pos_0; $item_num_0_ph18 = $inc; $_in = $npre_items + ($inc * 20 | 0) | 0; $arraydecay20 = $npre_items + ($inc * 20 | 0) + 4 | 0; } else { $item_num_0_ph14 = $inc; label = 831; break; } } if ((label | 0) == 829) { return $item_num_0_ph14 | 0; } else if ((label | 0) == 831) { return $item_num_0_ph14 | 0; } return 0; } function __ZN10ime_pinyin8DictTrie7predictEPKttPNS_12NPredictItemEjj($this, $last_hzs, $hzs_len, $npre_items, $npre_max, $b4_used) { $this = $this | 0; $last_hzs = $last_hzs | 0; $hzs_len = $hzs_len | 0; $npre_items = $npre_items | 0; $npre_max = $npre_max | 0; $b4_used = $b4_used | 0; return __ZN10ime_pinyin8DictList7predictEPKttPNS_12NPredictItemEjj(HEAP32[$this + 4 >> 2] | 0, $last_hzs, $hzs_len, $npre_items, $npre_max, $b4_used) | 0; } function __ZN10ime_pinyin12AtomDictBaseD0Ev($this) { $this = $this | 0; __ZdlPv($this); return; } function __ZN10ime_pinyin12MatrixSearchC2Ev($this) { $this = $this | 0; HEAP8[$this | 0] = 0; HEAP32[$this + 4 >> 2] = __ZN10ime_pinyin12SpellingTrie14get_cpinstanceEv() | 0; __ZN10ime_pinyin12MatrixSearch22reset_pointers_to_nullEv($this); HEAP32[$this + 72 >> 2] = 0; HEAP16[$this + 84 >> 1] = 0; HEAP16[$this + 92 >> 1] = 0; HEAP8[$this + 8 | 0] = 1; HEAP8[$this + 728 | 0] = 0; HEAP32[$this + 24 >> 2] = 39; HEAP32[$this + 28 >> 2] = 40; return; } function __ZN10ime_pinyin12MatrixSearchD2Ev($this) { $this = $this | 0; __ZN10ime_pinyin12MatrixSearch13free_resourceEv($this); return; } function __ZN10ime_pinyin12MatrixSearch13free_resourceEv($this) { $this = $this | 0; var $0 = 0, $3 = 0, $6 = 0, $8 = 0; $0 = HEAP32[$this + 12 >> 2] | 0; if (($0 | 0) != 0) { FUNCTION_TABLE_vi[HEAP32[(HEAP32[$0 >> 2] | 0) + 4 >> 2] & 127]($0); } $3 = HEAP32[$this + 16 >> 2] | 0; if (($3 | 0) != 0) { FUNCTION_TABLE_vi[HEAP32[(HEAP32[$3 >> 2] | 0) + 4 >> 2] & 127]($3); } $6 = HEAP32[$this + 20 >> 2] | 0; if (($6 | 0) != 0) { __ZdlPv($6); } $8 = HEAP32[$this + 76 >> 2] | 0; if (($8 | 0) == 0) { __ZN10ime_pinyin12MatrixSearch22reset_pointers_to_nullEv($this); return; } __ZdaPv($8); __ZN10ime_pinyin12MatrixSearch22reset_pointers_to_nullEv($this); return; } function __ZN10ime_pinyin8DictTrie8get_lpisEPKttPNS_10LmaPsbItemEj($this, $splid_str, $splid_str_len, $lma_buf, $max_lma_buf) { $this = $this | 0; $splid_str = $splid_str | 0; $splid_str_len = $splid_str_len | 0; $lma_buf = $lma_buf | 0; $max_lma_buf = $max_lma_buf | 0; var $node_buf1 = 0, $id_start = 0, $conv = 0, $root_ = 0, $0 = 0, $spl_trie_ = 0, $splid_le0_index_ = 0, $lma_node_num_ge1_ = 0, $nodes_ge1_ = 0, $nodes_ge1_165 = 0, $node_fr_le0_0_ph203 = 0, $node_to_le0_0_ph202 = 0, $node_fr_ge1_0_ph201 = 0, $node_to_ge1_0_ph200 = 0, $node_fr_num_0_ph199 = 0, $spl_pos_0_ph198 = 0, $node_fr_le0_0195 = 0, $node_to_le0_0194 = 0, $node_to_ge1_0193 = 0, $node_fr_num_0192 = 0, $spl_pos_0191 = 0, $arrayidx9 = 0, $call14 = 0, $id_num_0 = 0, $add191 = 0, $conv177 = 0, $cmp24 = 0, $conv32 = 0, $add = 0, $add66 = 0, $add125 = 0, $conv111 = 0, $node_to_num_1140 = 0, $node_fr_pos_0139 = 0, $8 = 0, $conv28 = 0, $11 = 0, $conv36 = 0, $son_1st_off = 0, $son_pos_0 = 0, $node_to_num_2 = 0, $15 = 0, $spl_idx = 0, $16 = 0, $17 = 0, $node_to_num_3 = 0, $node_to_num_4 = 0, $inc73 = 0, $inc75 = 0, $node_to_num_5134 = 0, $node_fr_pos83_0133 = 0, $21 = 0, $num_of_son = 0, $son_1st_off94 = 0, $son_pos89_0 = 0, $node_to_num_6 = 0, $23 = 0, $25 = 0, $add_ptr101_sum = 0, $add_ptr102 = 0, $spl_idx103 = 0, $26 = 0, $27 = 0, $node_to_num_7 = 0, $node_to_num_8 = 0, $inc134 = 0, $inc136 = 0, $spl_pos_0_ph_be = 0, $node_fr_num_0_ph_be = 0, $node_to_ge1_0_ph_be = 0, $node_to_le0_0_ph_be = 0, $node_fr_le0_0_ph_be = 0, $node_to_num_9145 = 0, $node_fr_pos144_0144 = 0, $31 = 0, $num_of_son152 = 0, $son_1st_off_l = 0, $son_1st_off_h = 0, $son_pos150_0 = 0, $node_to_num_10 = 0, $35 = 0, $add_ptr167_sum = 0, $add_ptr168 = 0, $spl_idx169 = 0, $36 = 0, $37 = 0, $node_to_num_11 = 0, $node_to_num_12 = 0, $inc200 = 0, $inc202 = 0, $spl_pos_2 = 0, $node_to_num_14 = 0, $call215 = 0, $node_to_num_15 = 0, $cmp228 = 0, $sub246 = 0, $42 = 0, $sub278 = 0, $lma_num_0 = 0, $node_pos_0 = 0, $43 = 0, $conv232 = 0, $homo_idx_buf_off = 0, $homo_pos_0 = 0, $add236 = 0, $bf_value = 0, $46 = 0, $51 = 0, $conv256 = 0, $homo_pos257_0 = 0, $add262 = 0, $bf_value267 = 0, $53 = 0, $num_of_homo_0 = 0, $add286 = 0, $retval_0 = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 1608 | 0; $node_buf1 = sp | 0; $id_start = sp + 1600 | 0; $conv = $splid_str_len & 65535; if (($splid_str_len & 65535) > 8) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } $root_ = $this + 12 | 0; $0 = HEAP32[$root_ >> 2] | 0; HEAP32[$node_buf1 >> 2] = $0; if (($0 | 0) == 0 | $splid_str_len << 16 >> 16 == 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } $spl_trie_ = $this + 8 | 0; $splid_le0_index_ = $this + 20 | 0; $lma_node_num_ge1_ = $this + 28 | 0; $nodes_ge1_ = $this + 16 | 0; $nodes_ge1_165 = $this + 16 | 0; $spl_pos_0_ph198 = 0; $node_fr_num_0_ph199 = 1; $node_to_ge1_0_ph200 = 0; $node_fr_ge1_0_ph201 = 0; $node_to_le0_0_ph202 = sp + 800 | 0; $node_fr_le0_0_ph203 = $node_buf1; L1043 : while (1) { $spl_pos_0191 = $spl_pos_0_ph198; $node_fr_num_0192 = $node_fr_num_0_ph199; $node_to_ge1_0193 = $node_to_ge1_0_ph200; $node_to_le0_0194 = $node_to_le0_0_ph202; $node_fr_le0_0195 = $node_fr_le0_0_ph203; while (1) { $arrayidx9 = $splid_str + ($spl_pos_0191 << 1) | 0; HEAP16[$id_start >> 1] = HEAP16[$arrayidx9 >> 1] | 0; if (__ZNK10ime_pinyin12SpellingTrie10is_half_idEt(HEAP32[$spl_trie_ >> 2] | 0, HEAP16[$arrayidx9 >> 1] | 0) | 0) { $call14 = __ZNK10ime_pinyin12SpellingTrie12half_to_fullEtPt(HEAP32[$spl_trie_ >> 2] | 0, HEAP16[$arrayidx9 >> 1] | 0, $id_start) | 0; if ($call14 << 16 >> 16 == 0) { label = 853; break L1043; } else { $id_num_0 = $call14; } } else { $id_num_0 = 1; } if (($spl_pos_0191 | 0) == 1) { label = 859; break; } else if (($spl_pos_0191 | 0) != 0) { label = 855; break; } if (($node_fr_num_0192 | 0) == 0) { $retval_0 = 0; label = 920; break L1043; } $cmp24 = ($node_fr_num_0192 | 0) == 1; $conv32 = $id_num_0 & 65535; $add = $conv32 - 30 | 0; $add66 = $conv32 - 1 | 0; $node_fr_pos_0139 = 0; $node_to_num_1140 = 0; while (1) { $8 = HEAP32[$node_fr_le0_0195 + ($node_fr_pos_0139 << 2) >> 2] | 0; if (!(($8 | 0) == (HEAP32[$root_ >> 2] | 0) & $cmp24)) { label = 862; break L1043; } $conv28 = HEAPU16[$id_start >> 1] | 0; $11 = HEAP32[$splid_le0_index_ >> 2] | 0; $conv36 = HEAPU16[$11 + ($add + $conv28 << 1) >> 1] | 0; $son_1st_off = $8 | 0; $node_to_num_2 = $node_to_num_1140; $son_pos_0 = HEAPU16[$11 + ($conv28 - 30 << 1) >> 1] | 0; while (1) { if ($son_pos_0 >>> 0 >= $conv36 >>> 0) { $node_to_num_4 = $node_to_num_2; break; } if ((HEAP32[$son_1st_off >> 2] | 0) != 1) { label = 866; break L1043; } $15 = HEAP32[$root_ >> 2] | 0; $spl_idx = $15 + ($son_pos_0 << 4) + 8 | 0; $16 = HEAP16[$spl_idx >> 1] | 0; $17 = HEAP16[$id_start >> 1] | 0; if (($16 & 65535) < ($17 & 65535)) { label = 914; break L1043; } if (($16 & 65535 | 0) >= (($17 & 65535) + $conv32 | 0)) { label = 915; break L1043; } if ($node_to_num_2 >>> 0 < 200) { HEAP32[$node_to_le0_0194 + ($node_to_num_2 << 2) >> 2] = $15 + ($son_pos_0 << 4); $node_to_num_3 = $node_to_num_2 + 1 | 0; } else { $node_to_num_3 = $node_to_num_2; } if ((HEAPU16[$spl_idx >> 1] | 0) < ($add66 + (HEAPU16[$id_start >> 1] | 0) | 0)) { $node_to_num_2 = $node_to_num_3; $son_pos_0 = $son_pos_0 + 1 | 0; } else { $node_to_num_4 = $node_to_num_3; break; } } $inc73 = $node_fr_pos_0139 + 1 | 0; if ($inc73 >>> 0 < $node_fr_num_0192 >>> 0) { $node_fr_pos_0139 = $inc73; $node_to_num_1140 = $node_to_num_4; } else { break; } } $inc75 = $spl_pos_0191 + 1 | 0; if ($inc75 >>> 0 >= $conv >>> 0 | ($node_to_num_4 | 0) == 0) { $node_to_num_14 = $node_to_num_4; $spl_pos_2 = $inc75; label = 899; break L1043; } if ($inc75 >>> 0 < $conv >>> 0) { $spl_pos_0191 = $inc75; $node_fr_num_0192 = $node_to_num_4; $node_to_ge1_0193 = $node_fr_le0_0195; $node_fr_le0_0195 = $node_to_le0_0194; $node_to_le0_0194 = 0; } else { $retval_0 = 0; label = 922; break L1043; } } if ((label | 0) == 855) { label = 0; if (($node_fr_num_0192 | 0) == 0) { $retval_0 = 0; label = 916; break; } $add191 = ($id_num_0 & 65535) - 1 | 0; $conv177 = $id_num_0 & 65535; $node_fr_pos144_0144 = 0; $node_to_num_9145 = 0; while (1) { $31 = HEAP32[$node_fr_ge1_0_ph201 + ($node_fr_pos144_0144 << 2) >> 2] | 0; $num_of_son152 = $31 + 6 | 0; $son_1st_off_l = $31 | 0; $son_1st_off_h = $31 + 8 | 0; $node_to_num_10 = $node_to_num_9145; $son_pos150_0 = 0; while (1) { if ($son_pos150_0 >>> 0 >= (HEAPU8[$num_of_son152] | 0) >>> 0) { $node_to_num_12 = $node_to_num_10; break; } if ((HEAP16[$son_1st_off_l >> 1] | 0) == 0) { if ((HEAP8[$son_1st_off_h] | 0) == 0) { label = 892; break L1043; } } $35 = HEAP32[$nodes_ge1_165 >> 2] | 0; $add_ptr167_sum = (__ZN10ime_pinyin8DictTrie14get_son_offsetEPKNS_10LmaNodeGE1E(0, $31) | 0) + $son_pos150_0 | 0; $add_ptr168 = $35 + ($add_ptr167_sum * 10 | 0) | 0; $spl_idx169 = $35 + ($add_ptr167_sum * 10 | 0) + 4 | 0; $36 = HEAP16[$spl_idx169 >> 1] | 0; $37 = HEAP16[$id_start >> 1] | 0; do { if (($36 & 65535) < ($37 & 65535)) { $node_to_num_11 = $node_to_num_10; } else { if (!(($36 & 65535 | 0) < (($37 & 65535) + $conv177 | 0) & $node_to_num_10 >>> 0 < 200)) { $node_to_num_11 = $node_to_num_10; break; } HEAP32[$node_to_ge1_0193 + ($node_to_num_10 << 2) >> 2] = $add_ptr168; $node_to_num_11 = $node_to_num_10 + 1 | 0; } } while (0); if ((HEAPU16[$spl_idx169 >> 1] | 0) < ($add191 + (HEAPU16[$id_start >> 1] | 0) | 0)) { $node_to_num_10 = $node_to_num_11; $son_pos150_0 = $son_pos150_0 + 1 | 0; } else { $node_to_num_12 = $node_to_num_11; break; } } $inc200 = $node_fr_pos144_0144 + 1 | 0; if ($inc200 >>> 0 < $node_fr_num_0192 >>> 0) { $node_fr_pos144_0144 = $inc200; $node_to_num_9145 = $node_to_num_12; } else { break; } } $inc202 = $spl_pos_0191 + 1 | 0; if ($inc202 >>> 0 >= $conv >>> 0 | ($node_to_num_12 | 0) == 0) { $node_to_num_14 = $node_to_num_12; $spl_pos_2 = $inc202; label = 899; break; } else { $node_fr_le0_0_ph_be = $node_fr_le0_0195; $node_to_le0_0_ph_be = $node_to_le0_0194; $node_to_ge1_0_ph_be = $node_fr_ge1_0_ph201; $node_fr_num_0_ph_be = $node_to_num_12; $spl_pos_0_ph_be = $inc202; } } else if ((label | 0) == 859) { label = 0; if (($node_fr_num_0192 | 0) == 0) { $retval_0 = 0; label = 921; break; } $add125 = ($id_num_0 & 65535) - 1 | 0; $conv111 = $id_num_0 & 65535; $node_fr_pos83_0133 = 0; $node_to_num_5134 = 0; while (1) { $21 = HEAP32[$node_fr_le0_0195 + ($node_fr_pos83_0133 << 2) >> 2] | 0; $num_of_son = $21 + 10 | 0; $son_1st_off94 = $21 | 0; $node_to_num_6 = $node_to_num_5134; $son_pos89_0 = 0; while (1) { if ($son_pos89_0 >>> 0 >= (HEAPU16[$num_of_son >> 1] | 0) >>> 0) { $node_to_num_8 = $node_to_num_6; break; } $23 = HEAP32[$son_1st_off94 >> 2] | 0; if ($23 >>> 0 > (HEAP32[$lma_node_num_ge1_ >> 2] | 0) >>> 0) { label = 879; break L1043; } $25 = HEAP32[$nodes_ge1_ >> 2] | 0; $add_ptr101_sum = $23 + $son_pos89_0 | 0; $add_ptr102 = $25 + ($add_ptr101_sum * 10 | 0) | 0; $spl_idx103 = $25 + ($add_ptr101_sum * 10 | 0) + 4 | 0; $26 = HEAP16[$spl_idx103 >> 1] | 0; $27 = HEAP16[$id_start >> 1] | 0; do { if (($26 & 65535) < ($27 & 65535)) { $node_to_num_7 = $node_to_num_6; } else { if (!(($26 & 65535 | 0) < (($27 & 65535) + $conv111 | 0) & $node_to_num_6 >>> 0 < 200)) { $node_to_num_7 = $node_to_num_6; break; } HEAP32[$node_to_ge1_0193 + ($node_to_num_6 << 2) >> 2] = $add_ptr102; $node_to_num_7 = $node_to_num_6 + 1 | 0; } } while (0); if ((HEAPU16[$spl_idx103 >> 1] | 0) < ($add125 + (HEAPU16[$id_start >> 1] | 0) | 0)) { $node_to_num_6 = $node_to_num_7; $son_pos89_0 = $son_pos89_0 + 1 | 0; } else { $node_to_num_8 = $node_to_num_7; break; } } $inc134 = $node_fr_pos83_0133 + 1 | 0; if ($inc134 >>> 0 < $node_fr_num_0192 >>> 0) { $node_fr_pos83_0133 = $inc134; $node_to_num_5134 = $node_to_num_8; } else { break; } } $inc136 = $spl_pos_0191 + 1 | 0; if ($inc136 >>> 0 >= $conv >>> 0 | ($node_to_num_8 | 0) == 0) { $node_to_num_14 = $node_to_num_8; $spl_pos_2 = $inc136; label = 899; break; } $node_fr_le0_0_ph_be = 0; $node_to_le0_0_ph_be = 0; $node_to_ge1_0_ph_be = $node_fr_le0_0195; $node_fr_num_0_ph_be = $node_to_num_8; $spl_pos_0_ph_be = $inc136; } if ($spl_pos_0_ph_be >>> 0 < $conv >>> 0) { $spl_pos_0_ph198 = $spl_pos_0_ph_be; $node_fr_num_0_ph199 = $node_fr_num_0_ph_be; $node_to_ge1_0_ph200 = $node_to_ge1_0_ph_be; $node_fr_ge1_0_ph201 = $node_to_ge1_0193; $node_to_le0_0_ph202 = $node_to_le0_0_ph_be; $node_fr_le0_0_ph203 = $node_fr_le0_0_ph_be; } else { $retval_0 = 0; label = 919; break; } } if ((label | 0) == 866) { ___assert_func(3680, 708, 4720, 824); return 0; } else if ((label | 0) == 862) { ___assert_func(3680, 703, 4720, 3440); return 0; } else if ((label | 0) == 892) { ___assert_func(3680, 768, 4720, 4112); return 0; } else if ((label | 0) == 853) { ___assert_func(3680, 696, 4720, 3600); return 0; } else if ((label | 0) == 879) { ___assert_func(3680, 737, 4720, 4312); return 0; } else if ((label | 0) == 899) { if (($node_to_num_14 | 0) == 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } $call215 = __ZN10ime_pinyin5NGram12get_instanceEv() | 0; do { if ($splid_str_len << 16 >> 16 == 1) { if (!(__ZNK10ime_pinyin12SpellingTrie16is_half_id_yunmuEt(HEAP32[$this + 8 >> 2] | 0, HEAP16[$splid_str >> 1] | 0) | 0)) { $node_to_num_15 = $node_to_num_14; break; } $node_to_num_15 = ($node_to_num_14 | 0) != 0 | 0; } else { $node_to_num_15 = $node_to_num_14; } } while (0); $cmp228 = $spl_pos_2 >>> 0 < 2; $sub246 = $max_lma_buf - 1 | 0; $42 = $conv << 24 & 251658240; $sub278 = $max_lma_buf - 1 | 0; $node_pos_0 = 0; $lma_num_0 = 0; while (1) { if ($node_pos_0 >>> 0 >= $node_to_num_15 >>> 0) { $retval_0 = $lma_num_0; label = 924; break; } L1117 : do { if ($cmp228) { $43 = HEAP32[$node_to_le0_0194 + ($node_pos_0 << 2) >> 2] | 0; $conv232 = HEAPU16[$43 + 12 >> 1] | 0; $homo_idx_buf_off = $43 + 4 | 0; $homo_pos_0 = 0; while (1) { if ($homo_pos_0 >>> 0 >= $conv232 >>> 0) { $num_of_homo_0 = $conv232; break L1117; } $add236 = $homo_pos_0 + $lma_num_0 | 0; $bf_value = (__ZN10ime_pinyin8DictTrie12get_lemma_idEj($this, (HEAP32[$homo_idx_buf_off >> 2] | 0) + $homo_pos_0 | 0) | 0) & 16777215; $46 = $lma_buf + ($add236 << 3) | 0; HEAP32[$46 >> 2] = $bf_value | HEAP32[$46 >> 2] & -268435456 | 16777216; HEAP16[$lma_buf + ($add236 << 3) + 4 >> 1] = ~~+__ZN10ime_pinyin5NGram11get_uni_psbEj($call215, $bf_value); if ($add236 >>> 0 < $sub246 >>> 0) { $homo_pos_0 = $homo_pos_0 + 1 | 0; } else { $num_of_homo_0 = $conv232; break; } } } else { $51 = HEAP32[$node_to_ge1_0193 + ($node_pos_0 << 2) >> 2] | 0; $conv256 = HEAPU8[$51 + 7 | 0] | 0; $homo_pos257_0 = 0; while (1) { if ($homo_pos257_0 >>> 0 >= $conv256 >>> 0) { $num_of_homo_0 = $conv256; break L1117; } $add262 = $homo_pos257_0 + $lma_num_0 | 0; $bf_value267 = (__ZN10ime_pinyin8DictTrie12get_lemma_idEj($this, (__ZN10ime_pinyin8DictTrie23get_homo_idx_buf_offsetEPKNS_10LmaNodeGE1E(0, $51) | 0) + $homo_pos257_0 | 0) | 0) & 16777215; $53 = $lma_buf + ($add262 << 3) | 0; HEAP32[$53 >> 2] = $bf_value267 | $42 | HEAP32[$53 >> 2] & -268435456; HEAP16[$lma_buf + ($add262 << 3) + 4 >> 1] = ~~+__ZN10ime_pinyin5NGram11get_uni_psbEj($call215, $bf_value267); if ($add262 >>> 0 < $sub278 >>> 0) { $homo_pos257_0 = $homo_pos257_0 + 1 | 0; } else { $num_of_homo_0 = $conv256; break; } } } } while (0); $add286 = $num_of_homo_0 + $lma_num_0 | 0; if ($add286 >>> 0 < $max_lma_buf >>> 0) { $node_pos_0 = $node_pos_0 + 1 | 0; $lma_num_0 = $add286; } else { $retval_0 = $max_lma_buf; label = 925; break; } } if ((label | 0) == 924) { STACKTOP = sp; return $retval_0 | 0; } else if ((label | 0) == 925) { STACKTOP = sp; return $retval_0 | 0; } } else if ((label | 0) == 914) { ___assert_func(3680, 711, 4720, 3304); return 0; } else if ((label | 0) == 915) { ___assert_func(3680, 711, 4720, 3304); return 0; } else if ((label | 0) == 916) { STACKTOP = sp; return $retval_0 | 0; } else if ((label | 0) == 919) { STACKTOP = sp; return $retval_0 | 0; } else if ((label | 0) == 920) { STACKTOP = sp; return $retval_0 | 0; } else if ((label | 0) == 921) { STACKTOP = sp; return $retval_0 | 0; } else if ((label | 0) == 922) { STACKTOP = sp; return $retval_0 | 0; } return 0; } function __ZN10ime_pinyin8DictTrie16get_lemma_splidsEjPttb($this, $id_lemma, $splids, $splids_max, $arg_valid) { $this = $this | 0; $id_lemma = $id_lemma | 0; $splids = $splids | 0; $splids_max = $splids_max | 0; $arg_valid = $arg_valid | 0; var $lma_str = 0, $spl_mtrx = 0, $spl_start = 0, $call = 0, $spl_trie_ = 0, $_in43 = 0, $try_num_0_lcssa = 0, $cmp6344 = 0, $conv652 = 0, $pos_051 = 0, $try_num_050 = 0, $arrayidx11 = 0, $cond_off0 = 0, $9 = 0, $call37 = 0, $cand_splids_this_0 = 0, $inc = 0, $phitmp = 0, $try_pos_0 = 0, $conv6147 = 0, $pos59_046 = 0, $mod_045 = 0, $12 = 0, $sub72 = 0, $mul86 = 0, $inc89 = 0, $retval_0 = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 128 | 0; $lma_str = sp | 0; $spl_mtrx = sp + 24 | 0; $spl_start = sp + 104 | 0; $call = FUNCTION_TABLE_iiiii[HEAP32[(HEAP32[$this >> 2] | 0) + 32 >> 2] & 31]($this, $id_lemma, $lma_str | 0, 9) | 0; if (!($call << 16 >> 16 == $splids_max << 16 >> 16 | (($call & 65535) > ($splids_max & 65535) | $arg_valid) ^ 1)) { ___assert_func(3680, 861, 4816, 3200); return 0; } HEAP16[$spl_start >> 1] = 0; L1141 : do { if ($call << 16 >> 16 == 0) { $try_num_0_lcssa = 1; } else { $spl_trie_ = $this + 8 | 0; $_in43 = $this + 4 | 0; $try_num_050 = 1; $pos_051 = 0; $conv652 = 0; while (1) { do { if ($arg_valid) { $arrayidx11 = $splids + ($conv652 << 1) | 0; if (__ZNK10ime_pinyin12SpellingTrie10is_full_idEt(HEAP32[$spl_trie_ >> 2] | 0, HEAP16[$arrayidx11 >> 1] | 0) | 0) { HEAP16[$spl_mtrx + ((HEAPU16[$spl_start + ($conv652 << 1) >> 1] | 0) << 1) >> 1] = HEAP16[$arrayidx11 >> 1] | 0; $cand_splids_this_0 = 1; break; } else { $cond_off0 = HEAP16[$splids + ($conv652 << 1) >> 1] | 0; label = 935; break; } } else { $cond_off0 = 0; label = 935; } } while (0); if ((label | 0) == 935) { label = 0; $9 = HEAP16[$spl_start + ($conv652 << 1) >> 1] | 0; $call37 = __ZN10ime_pinyin8DictList20get_splids_for_hanziEttPtt(HEAP32[$_in43 >> 2] | 0, HEAP16[$lma_str + ($conv652 << 1) >> 1] | 0, $cond_off0, $spl_mtrx + (($9 & 65535) << 1) | 0, 40 - $9 & 65535) | 0; if ($call37 << 16 >> 16 == 0) { break; } else { $cand_splids_this_0 = $call37; } } HEAP16[$spl_start + ($conv652 + 1 << 1) >> 1] = (HEAP16[$spl_start + ($conv652 << 1) >> 1] | 0) + $cand_splids_this_0 & 65535; $inc = $pos_051 + 1 & 65535; $phitmp = (Math_imul($cand_splids_this_0 & 65535, $try_num_050) | 0) & 65535; if (($inc & 65535) < ($call & 65535)) { $try_num_050 = $phitmp; $pos_051 = $inc; $conv652 = $inc & 65535; } else { $try_num_0_lcssa = $phitmp; break L1141; } } ___assert_func(3680, 877, 4816, 3112); return 0; } } while (0); $cmp6344 = $call << 16 >> 16 == 0; $try_pos_0 = 0; while (1) { if (($try_pos_0 & 65535) >>> 0 >= $try_num_0_lcssa >>> 0) { $retval_0 = 0; label = 944; break; } if (!$cmp6344) { $mod_045 = 1; $pos59_046 = 0; $conv6147 = 0; while (1) { $12 = HEAP16[$spl_start + ($conv6147 << 1) >> 1] | 0; $sub72 = (HEAP16[$spl_start + ($conv6147 + 1 << 1) >> 1] | 0) - $12 & 65535; HEAP16[$splids + ($conv6147 << 1) >> 1] = HEAP16[$spl_mtrx + (((((($try_pos_0 & 65535) / ($mod_045 & 65535) | 0) & 65535) % ($sub72 & 65535) | 0) & 65535) + ($12 & 65535) << 1) >> 1] | 0; $mul86 = Math_imul($sub72, $mod_045) | 0; $inc89 = $pos59_046 + 1 & 65535; if (($inc89 & 65535) < ($call & 65535)) { $mod_045 = $mul86; $pos59_046 = $inc89; $conv6147 = $inc89 & 65535; } else { break; } } } if (__ZN10ime_pinyin8DictTrie10try_extendEPKttj($this, $splids, $call, $id_lemma) | 0) { $retval_0 = $call; label = 943; break; } else { $try_pos_0 = $try_pos_0 + 1 & 65535; } } if ((label | 0) == 944) { STACKTOP = sp; return $retval_0 | 0; } else if ((label | 0) == 943) { STACKTOP = sp; return $retval_0 | 0; } return 0; } function __ZN10ime_pinyin12MatrixSearch12set_max_lensEjj($this, $max_sps_len, $max_hzs_len) { $this = $this | 0; $max_sps_len = $max_sps_len | 0; $max_hzs_len = $max_hzs_len | 0; if (($max_sps_len | 0) != 0) { HEAP32[$this + 24 >> 2] = $max_sps_len; } if (($max_hzs_len | 0) == 0) { return; } HEAP32[$this + 28 >> 2] = $max_hzs_len; return; } function __ZN10ime_pinyin12MatrixSearch16set_xi_an_switchEb($this, $xi_an_enabled) { $this = $this | 0; $xi_an_enabled = $xi_an_enabled | 0; HEAP8[$this + 8 | 0] = $xi_an_enabled & 1; return; } function __ZN10ime_pinyin12MatrixSearch16get_xi_an_switchEv($this) { $this = $this | 0; return (HEAP8[$this + 8 | 0] & 1) != 0 | 0; } function __ZN10ime_pinyin12MatrixSearch14alloc_resourceEv($this) { $this = $this | 0; var $0 = 0, $dict_trie_ = 0, $call2 = 0, $user_dict_ = 0, $3 = 0, $spl_parser_ = 0, $div = 0, $div10 = 0, $div12 = 0, $add = 0, $add15 = 0, $add16 = 0, $4$0 = 0, $call17 = 0, $share_buf_ = 0, $retval_0 = 0; __ZN10ime_pinyin12MatrixSearch13free_resourceEv($this); $0 = __Znwj(64) | 0; __ZN10ime_pinyin8DictTrieC2Ev($0); $dict_trie_ = $this + 12 | 0; HEAP32[$dict_trie_ >> 2] = $0; $call2 = __Znwj(1132) | 0; __ZN10ime_pinyin8UserDictC2Ev($call2); $user_dict_ = $this + 16 | 0; HEAP32[$user_dict_ >> 2] = $call2; $3 = __Znwj(4) | 0; __ZN10ime_pinyin14SpellingParserC2Ev($3); $spl_parser_ = $this + 20 | 0; HEAP32[$spl_parser_ >> 2] = $3; $div = (__ZN10ime_pinyin15align_to_size_tEj(3200) | 0) >>> 2; $div10 = (__ZN10ime_pinyin15align_to_size_tEj(9600) | 0) >>> 2; $div12 = (__ZN10ime_pinyin15align_to_size_tEj(480) | 0) >>> 2; $add = $div10 + $div | 0; $add15 = $add + $div12 | 0; $add16 = $add15 + ((__ZN10ime_pinyin15align_to_size_tEj(92) | 0) >>> 2) | 0; $4$0 = _llvm_umul_with_overflow_i32($add16 | 0, 4) | 0; $call17 = __Znaj(tempRet0 ? -1 : $4$0) | 0; $share_buf_ = $this + 76 | 0; HEAP32[$share_buf_ >> 2] = $call17; if ((HEAP32[$dict_trie_ >> 2] | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } if ((HEAP32[$user_dict_ >> 2] | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } if ((HEAP32[$spl_parser_ >> 2] | 0) == 0 | ($call17 | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } HEAP32[$this + 80 >> 2] = $call17; HEAP32[$this + 88 >> 2] = (HEAP32[$share_buf_ >> 2] | 0) + ($div << 2); HEAP32[$this + 96 >> 2] = (HEAP32[$share_buf_ >> 2] | 0) + ($add << 2); HEAP32[$this + 100 >> 2] = (HEAP32[$share_buf_ >> 2] | 0) + ($add15 << 2); HEAP32[$this + 104 >> 2] = HEAP32[$share_buf_ >> 2]; HEAP32[$this + 108 >> 2] = ($add16 << 2 >>> 0) / 20 | 0; $retval_0 = 1; return $retval_0 | 0; } function __ZN10ime_pinyin12MatrixSearch4initEPKcS2_($this, $fn_sys_dict, $fn_usr_dict) { $this = $this | 0; $fn_sys_dict = $fn_sys_dict | 0; $fn_usr_dict = $fn_usr_dict | 0; var $0 = 0, $user_dict_ = 0, $3 = 0, $call10 = 0, $6 = 0, $retval_0 = 0; if (($fn_sys_dict | 0) == 0 | ($fn_usr_dict | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } if (!(__ZN10ime_pinyin12MatrixSearch14alloc_resourceEv($this) | 0)) { $retval_0 = 0; return $retval_0 | 0; } $0 = HEAP32[$this + 12 >> 2] | 0; if (!(FUNCTION_TABLE_iiiii[HEAP32[(HEAP32[$0 >> 2] | 0) + 8 >> 2] & 31]($0, $fn_sys_dict, 1, 5e5) | 0)) { $retval_0 = 0; return $retval_0 | 0; } $user_dict_ = $this + 16 | 0; $3 = HEAP32[$user_dict_ >> 2] | 0; $call10 = FUNCTION_TABLE_iiiii[HEAP32[(HEAP32[$3 >> 2] | 0) + 8 >> 2] & 31]($3, $fn_usr_dict, 500001, 6e5) | 0; $6 = HEAP32[$user_dict_ >> 2] | 0; if ($call10) { FUNCTION_TABLE_vii[HEAP32[(HEAP32[$6 >> 2] | 0) + 72 >> 2] & 15]($6, 1e8); } else { if (($6 | 0) != 0) { FUNCTION_TABLE_vi[HEAP32[(HEAP32[$6 >> 2] | 0) + 4 >> 2] & 127]($6); } HEAP32[$user_dict_ >> 2] = 0; } __ZN10ime_pinyin12MatrixSearch13reset_search0Ev($this) | 0; HEAP8[$this | 0] = 1; $retval_0 = 1; return $retval_0 | 0; } function __ZN10ime_pinyin12MatrixSearch13reset_search0Ev($this) { $this = $this | 0; var $mtrx_nd_pool_used_ = 0, $matrix_ = 0, $6 = 0, $conv10 = 0, $add_ptr = 0, $12 = 0, $17 = 0, $21 = 0, $24 = 0, $retval_0 = 0; if ((HEAP8[$this | 0] & 1) == 0) { $retval_0 = 0; return $retval_0 | 0; } HEAP32[$this + 72 >> 2] = 0; $mtrx_nd_pool_used_ = $this + 84 | 0; HEAP16[$mtrx_nd_pool_used_ >> 1] = 0; HEAP16[$this + 92 >> 1] = 0; $matrix_ = $this + 96 | 0; HEAP16[HEAP32[$matrix_ >> 2] >> 1] = HEAP16[$mtrx_nd_pool_used_ >> 1] | 0; HEAP16[(HEAP32[$matrix_ >> 2] | 0) + 4 >> 1] = 1; HEAP16[$mtrx_nd_pool_used_ >> 1] = (HEAP16[$mtrx_nd_pool_used_ >> 1] | 0) + 1 & 65535; $6 = HEAP32[$this + 80 >> 2] | 0; $conv10 = HEAPU16[HEAP32[$matrix_ >> 2] >> 1] | 0; $add_ptr = $6 + ($conv10 << 4) | 0; HEAP32[$add_ptr >> 2] = 0; HEAPF32[$6 + ($conv10 << 4) + 4 >> 2] = 0.0; HEAP32[$6 + ($conv10 << 4) + 8 >> 2] = 0; HEAP16[$6 + ($conv10 << 4) + 14 >> 1] = 0; HEAP16[$6 + ($conv10 << 4) + 12 >> 1] = -1; HEAP16[(HEAP32[$matrix_ >> 2] | 0) + 2 >> 1] = 0; $12 = (HEAP32[$matrix_ >> 2] | 0) + 6 | 0; HEAP16[$12 >> 1] = HEAP16[$12 >> 1] & -32768; $17 = (HEAP32[$matrix_ >> 2] | 0) + 6 | 0; HEAP16[$17 >> 1] = HEAP16[$17 >> 1] | -32768; HEAP32[(HEAP32[$matrix_ >> 2] | 0) + 8 >> 2] = $add_ptr; HEAP16[$this + 116 >> 1] = 0; HEAP32[$this + 356 >> 2] = 0; HEAP16[$this + 736 >> 1] = 0; HEAP32[$this + 896 >> 2] = 0; $21 = HEAP32[$this + 12 >> 2] | 0; FUNCTION_TABLE_viii[HEAP32[(HEAP32[$21 >> 2] | 0) + 20 >> 2] & 15]($21, 0, 0); $24 = HEAP32[$this + 16 >> 2] | 0; if (($24 | 0) == 0) { $retval_0 = 1; return $retval_0 | 0; } FUNCTION_TABLE_viii[HEAP32[(HEAP32[$24 >> 2] | 0) + 20 >> 2] & 15]($24, 0, 0); $retval_0 = 1; return $retval_0 | 0; } function __ZN10ime_pinyin12MatrixSearch7init_fdEillPKc($this, $sys_fd, $start_offset, $length, $fn_usr_dict) { $this = $this | 0; $sys_fd = $sys_fd | 0; $start_offset = $start_offset | 0; $length = $length | 0; $fn_usr_dict = $fn_usr_dict | 0; var $user_dict_ = 0, $1 = 0, $call7 = 0, $4 = 0, $retval_0 = 0; if (($fn_usr_dict | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } if (!(__ZN10ime_pinyin12MatrixSearch14alloc_resourceEv($this) | 0)) { $retval_0 = 0; return $retval_0 | 0; } if (!(__ZN10ime_pinyin8DictTrie12load_dict_fdEilljj(HEAP32[$this + 12 >> 2] | 0, $sys_fd, $start_offset, $length, 1, 5e5) | 0)) { $retval_0 = 0; return $retval_0 | 0; } $user_dict_ = $this + 16 | 0; $1 = HEAP32[$user_dict_ >> 2] | 0; $call7 = FUNCTION_TABLE_iiiii[HEAP32[(HEAP32[$1 >> 2] | 0) + 8 >> 2] & 31]($1, $fn_usr_dict, 500001, 6e5) | 0; $4 = HEAP32[$user_dict_ >> 2] | 0; if ($call7) { FUNCTION_TABLE_vii[HEAP32[(HEAP32[$4 >> 2] | 0) + 72 >> 2] & 15]($4, 1e8); } else { if (($4 | 0) != 0) { FUNCTION_TABLE_vi[HEAP32[(HEAP32[$4 >> 2] | 0) + 4 >> 2] & 127]($4); } HEAP32[$user_dict_ >> 2] = 0; } __ZN10ime_pinyin12MatrixSearch13reset_search0Ev($this) | 0; HEAP8[$this | 0] = 1; $retval_0 = 1; return $retval_0 | 0; } function __ZN10ime_pinyin12MatrixSearch5closeEv($this) { $this = $this | 0; __ZN10ime_pinyin12MatrixSearch11flush_cacheEv($this); __ZN10ime_pinyin12MatrixSearch13free_resourceEv($this); HEAP8[$this | 0] = 0; return; } function __ZN10ime_pinyin12MatrixSearch11flush_cacheEv($this) { $this = $this | 0; var $0 = 0; $0 = HEAP32[$this + 16 >> 2] | 0; if (($0 | 0) == 0) { return; } FUNCTION_TABLE_vi[HEAP32[(HEAP32[$0 >> 2] | 0) + 76 >> 2] & 127]($0); return; } function __ZN10ime_pinyin12MatrixSearch12reset_searchEv($this) { $this = $this | 0; var $retval_0 = 0; if ((HEAP8[$this | 0] & 1) == 0) { $retval_0 = 0; return $retval_0 | 0; } $retval_0 = __ZN10ime_pinyin12MatrixSearch13reset_search0Ev($this) | 0; return $retval_0 | 0; } function __ZN10ime_pinyin12MatrixSearch10del_in_pysEjj($this, $start, $len) { $this = $this | 0; $start = $start | 0; $len = $len | 0; var $sub = 0, $start_addr_07 = 0, $arrayidx = 0, $inc = 0, label = 0; $sub = 40 - $len | 0; if ($sub >>> 0 > $start >>> 0) { $start_addr_07 = $start; } else { return; } while (1) { $arrayidx = $this + 32 + $start_addr_07 | 0; if ((HEAP8[$arrayidx] | 0) == 0) { label = 1022; break; } HEAP8[$arrayidx] = HEAP8[$start_addr_07 + $len + ($this + 32) | 0] | 0; $inc = $start_addr_07 + 1 | 0; if ($inc >>> 0 < $sub >>> 0) { $start_addr_07 = $inc; } else { label = 1020; break; } } if ((label | 0) == 1020) { return; } else if ((label | 0) == 1022) { return; } } function __ZN10ime_pinyin12MatrixSearch8add_charEc($this, $ch) { $this = $this | 0; $ch = $ch | 0; var $retval_0 = 0; if (!(__ZN10ime_pinyin12MatrixSearch16prepare_add_charEc($this, $ch) | 0)) { $retval_0 = 0; return $retval_0 | 0; } $retval_0 = __ZN10ime_pinyin12MatrixSearch15add_char_qwertyEv($this) | 0; return $retval_0 | 0; } function __ZN10ime_pinyin12MatrixSearch6searchEPKcj($this, $py, $py_len) { $this = $this | 0; $py = $py | 0; $py_len = $py_len | 0; var $_py_len = 0, $pys_decoded_len_ = 0, $2 = 0, $ch_pos_0 = 0, $3 = 0, $add_ptr = 0, $add_ptr21 = 0, $sub = 0, $ch_pos_1 = 0, $spl_id_num_ = 0, $py_len_addr_124 = 0, $retval_0 = 0, label = 0; if ((HEAP8[$this | 0] & 1) == 0 | ($py | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $_py_len = $py_len >>> 0 > 39 ? 39 : $py_len; $pys_decoded_len_ = $this + 72 | 0; $2 = HEAP32[$pys_decoded_len_ >> 2] | 0; $ch_pos_0 = 0; while (1) { if ($ch_pos_0 >>> 0 >= $2 >>> 0) { break; } $3 = HEAP8[$py + $ch_pos_0 | 0] | 0; if ($3 << 24 >> 24 == 0) { break; } if ($3 << 24 >> 24 == (HEAP8[$this + 32 + $ch_pos_0 | 0] | 0)) { $ch_pos_0 = $ch_pos_0 + 1 | 0; } else { break; } } __ZN10ime_pinyin12MatrixSearch12reset_searchEjbbb($this, $ch_pos_0, ($ch_pos_0 | 0) != (HEAP32[$pys_decoded_len_ >> 2] | 0), 0, 0) | 0; $add_ptr = $this + 32 + $ch_pos_0 | 0; $add_ptr21 = $py + $ch_pos_0 | 0; $sub = $_py_len - $ch_pos_0 | 0; _memcpy($add_ptr | 0, $add_ptr21 | 0, $sub) | 0; HEAP8[$this + 32 + $_py_len | 0] = 0; $ch_pos_1 = $ch_pos_0; while (1) { if ((HEAP8[$this + 32 + $ch_pos_1 | 0] | 0) == 0) { break; } if (__ZN10ime_pinyin12MatrixSearch8add_charEc($this, HEAP8[$py + $ch_pos_1 | 0] | 0) | 0) { $ch_pos_1 = $ch_pos_1 + 1 | 0; } else { label = 1036; break; } } if ((label | 0) == 1036) { HEAP32[$pys_decoded_len_ >> 2] = $ch_pos_1; } __ZN10ime_pinyin12MatrixSearch16get_spl_start_idEv($this); $spl_id_num_ = $this + 732 | 0; if ((HEAP32[$spl_id_num_ >> 2] | 0) >>> 0 > 9) { $py_len_addr_124 = $_py_len; do { $py_len_addr_124 = $py_len_addr_124 - 1 | 0; __ZN10ime_pinyin12MatrixSearch12reset_searchEjbbb($this, $py_len_addr_124, 0, 0, 0) | 0; HEAP8[$this + 32 + $py_len_addr_124 | 0] = 0; __ZN10ime_pinyin12MatrixSearch16get_spl_start_idEv($this); } while ((HEAP32[$spl_id_num_ >> 2] | 0) >>> 0 > 9); } __ZN10ime_pinyin12MatrixSearch18prepare_candidatesEv($this); $retval_0 = $ch_pos_1; return $retval_0 | 0; } function __ZN10ime_pinyin12MatrixSearch12reset_searchEjbbb($this, $ch_pos, $clear_fixed_this_step, $clear_dmi_this_step, $clear_mtrx_this_step) { $this = $this | 0; $ch_pos = $ch_pos | 0; $clear_fixed_this_step = $clear_fixed_this_step | 0; $clear_dmi_this_step = $clear_dmi_this_step | 0; $clear_mtrx_this_step = $clear_mtrx_this_step | 0; var $pys_decoded_len_ = 0, $cmp6 = 0, $3 = 0, $add = 0, $10 = 0, $dict_handles_to_clear_1 = 0, $16 = 0, $conv40 = 0, $20 = 0, $sub = 0, $matrix_54 = 0, $24 = 0, $31 = 0, $34 = 0, $sub85 = 0, $matrix_86 = 0, $39 = 0, $43 = 0, $fixed_hzs_ = 0, $fixed_ch_pos_0_ph = 0, $matrix_130 = 0, $50 = 0, $fixed_ch_pos_0 = 0, $cmp133 = 0, $fixed_lmas_ = 0, $52 = 0, $conv141114 = 0, $54 = 0, $inc = 0, $conv141 = 0, $conv141_lcssa = 0, $56 = 0, $conv157110 = 0, $58 = 0, $59 = 0, $inc162 = 0, $conv157 = 0, $61 = 0, $_lcssa = 0, $conv157_lcssa = 0, $cmp177 = 0, $or_cond85 = 0, $62 = 0, $dict_handles_to_clear174_0 = 0, $add200 = 0, $69 = 0, $dict_handles_to_clear174_1 = 0, $75 = 0, $conv224 = 0, $79 = 0, $sub241 = 0, $83 = 0, $90 = 0, $93 = 0, $sub276 = 0, $98 = 0, $102 = 0, $conv306105 = 0, $conv306108 = 0, $re_pos_0107 = 0, $inc311 = 0, $conv306 = 0, $arrayidx317 = 0, $sublma_num = 0, $length366 = 0, $conv321104 = 0, $subpos_0103 = 0, $108 = 0, $add329 = 0, $arrayidx332 = 0, $109 = 0, $splpos_0100 = 0, $conv334101 = 0, $dmi_c_phrase_ = 0, $length386 = 0, $c_py_pos_0 = 0, $116 = 0, $idxprom420 = 0, $120 = 0, $retval_0 = 0, label = 0; if ((HEAP8[$this | 0] & 1) == 0) { $retval_0 = 0; return $retval_0 | 0; } $pys_decoded_len_ = $this + 72 | 0; if ((HEAP32[$pys_decoded_len_ >> 2] | 0) >>> 0 < $ch_pos >>> 0 | $ch_pos >>> 0 > 39) { $retval_0 = 0; return $retval_0 | 0; } $cmp6 = ($ch_pos | 0) == 0; if ($cmp6) { __ZN10ime_pinyin12MatrixSearch13reset_search0Ev($this) | 0; $retval_0 = 1; return $retval_0 | 0; } do { if ($clear_dmi_this_step) { $3 = HEAP32[$this + 96 >> 2] | 0; if ((HEAP16[$3 + ($ch_pos * 12 | 0) + 6 >> 1] & 32767) == 0) { HEAP32[$pys_decoded_len_ >> 2] = $ch_pos; label = 1059; break; } else { $dict_handles_to_clear_1 = (HEAP32[$this + 88 >> 2] | 0) + ((HEAPU16[$3 + ($ch_pos * 12 | 0) + 2 >> 1] | 0) * 12 | 0) | 0; label = 1055; break; } } else { if ((HEAP32[$pys_decoded_len_ >> 2] | 0) >>> 0 <= $ch_pos >>> 0 | $clear_dmi_this_step) { HEAP32[$pys_decoded_len_ >> 2] = $ch_pos; label = 1060; break; } $add = $ch_pos + 1 | 0; $10 = HEAP32[$this + 96 >> 2] | 0; if ((HEAP16[$10 + ($add * 12 | 0) + 6 >> 1] & 32767) == 0) { label = 1058; break; } $dict_handles_to_clear_1 = (HEAP32[$this + 88 >> 2] | 0) + ((HEAPU16[$10 + ($add * 12 | 0) + 2 >> 1] | 0) * 12 | 0) | 0; label = 1055; } } while (0); do { if ((label | 0) == 1055) { if (($dict_handles_to_clear_1 | 0) == 0) { label = 1058; break; } $16 = HEAP32[$this + 12 >> 2] | 0; $conv40 = $ch_pos & 65535; FUNCTION_TABLE_viii[HEAP32[(HEAP32[$16 >> 2] | 0) + 20 >> 2] & 15]($16, $conv40, HEAP16[$dict_handles_to_clear_1 >> 1] | 0); $20 = HEAP32[$this + 16 >> 2] | 0; if (($20 | 0) == 0) { label = 1058; break; } FUNCTION_TABLE_viii[HEAP32[(HEAP32[$20 >> 2] | 0) + 20 >> 2] & 15]($20, $conv40, HEAP16[$dict_handles_to_clear_1 + 2 >> 1] | 0); label = 1058; } } while (0); if ((label | 0) == 1058) { HEAP32[$pys_decoded_len_ >> 2] = $ch_pos; if ($clear_dmi_this_step) { label = 1059; } else { label = 1060; } } if ((label | 0) == 1059) { $sub = $ch_pos - 1 | 0; $matrix_54 = $this + 96 | 0; $24 = HEAP32[$matrix_54 >> 2] | 0; HEAP16[$this + 92 >> 1] = (HEAP16[$24 + ($sub * 12 | 0) + 6 >> 1] & 32767) + (HEAP16[$24 + ($sub * 12 | 0) + 2 >> 1] | 0) & 65535; $31 = (HEAP32[$matrix_54 >> 2] | 0) + ($ch_pos * 12 | 0) + 6 | 0; HEAP16[$31 >> 1] = HEAP16[$31 >> 1] & -32768; } else if ((label | 0) == 1060) { $34 = HEAP32[$this + 96 >> 2] | 0; HEAP16[$this + 92 >> 1] = (HEAP16[$34 + ($ch_pos * 12 | 0) + 6 >> 1] & 32767) + (HEAP16[$34 + ($ch_pos * 12 | 0) + 2 >> 1] | 0) & 65535; } if ($clear_mtrx_this_step) { $sub85 = $ch_pos - 1 | 0; $matrix_86 = $this + 96 | 0; $39 = HEAP32[$matrix_86 >> 2] | 0; HEAP16[$this + 84 >> 1] = (HEAP16[$39 + ($sub85 * 12 | 0) + 4 >> 1] | 0) + (HEAP16[$39 + ($sub85 * 12 | 0) >> 1] | 0) & 65535; HEAP16[(HEAP32[$matrix_86 >> 2] | 0) + ($ch_pos * 12 | 0) + 4 >> 1] = 0; } else { $43 = HEAP32[$this + 96 >> 2] | 0; HEAP16[$this + 84 >> 1] = (HEAP16[$43 + ($ch_pos * 12 | 0) + 4 >> 1] | 0) + (HEAP16[$43 + ($ch_pos * 12 | 0) >> 1] | 0) & 65535; } $fixed_hzs_ = $this + 896 | 0; if ((HEAP32[$fixed_hzs_ >> 2] | 0) == 0) { $retval_0 = 1; return $retval_0 | 0; } do { if ((HEAP32[$this + 196 >> 2] | 0) == 16777215) { if ((HEAPU16[$this + 736 + ((HEAPU16[$this + 724 >> 1] | 0) << 1) >> 1] | 0) >>> 0 <= $ch_pos >>> 0) { break; } if ((HEAP32[$fixed_hzs_ >> 2] | 0) == 0) { $retval_0 = 1; return $retval_0 | 0; } $arrayidx317 = $this + 196 | 0; if ((HEAP32[$arrayidx317 >> 2] | 0) != 16777215) { $retval_0 = 1; return $retval_0 | 0; } $sublma_num = $this + 720 | 0; if ((HEAP32[$sublma_num >> 2] | 0) != 0) { $length366 = $this + 724 | 0; $subpos_0103 = 0; $conv321104 = 0; do { $108 = HEAP16[$this + 640 + ($conv321104 << 1) >> 1] | 0; $add329 = $conv321104 + 1 | 0; $arrayidx332 = $this + 640 + ($add329 << 1) | 0; $109 = HEAP16[$arrayidx332 >> 1] | 0; if (($108 & 65535) < ($109 & 65535)) { $splpos_0100 = $108; do { $conv334101 = $splpos_0100 & 65535; do { if ((HEAPU16[$this + 480 + ($conv334101 << 1) >> 1] | 0) >>> 0 <= $ch_pos >>> 0) { if ((HEAPU16[$this + 480 + ($conv334101 + 1 << 1) >> 1] | 0) >>> 0 <= $ch_pos >>> 0) { break; } HEAP16[$this + 560 + ($conv334101 << 1) >> 1] = 0; HEAP16[$arrayidx332 >> 1] = $splpos_0100; HEAP32[$sublma_num >> 2] = $add329; HEAP16[$length366 >> 1] = $splpos_0100; if ($splpos_0100 << 16 >> 16 != $108 << 16 >> 16) { break; } HEAP32[$sublma_num >> 2] = $conv321104; } } while (0); $splpos_0100 = $splpos_0100 + 1 & 65535; } while (($splpos_0100 & 65535) < ($109 & 65535)); } $subpos_0103 = $subpos_0103 + 1 & 65535; $conv321104 = $subpos_0103 & 65535; } while ($conv321104 >>> 0 < (HEAP32[$sublma_num >> 2] | 0) >>> 0); } __ZN10ime_pinyin12MatrixSearch13reset_search0Ev($this) | 0; $dmi_c_phrase_ = $this + 728 | 0; HEAP8[$dmi_c_phrase_] = 1; $length386 = $this + 724 | 0; $c_py_pos_0 = 0; while (1) { if (($c_py_pos_0 & 65535) >= (HEAPU16[$this + 736 + ((HEAPU16[$length386 >> 1] | 0) << 1) >> 1] | 0)) { break; } if (__ZN10ime_pinyin12MatrixSearch8add_charEc($this, HEAP8[($c_py_pos_0 & 65535) + ($this + 32) | 0] | 0) | 0) { $c_py_pos_0 = $c_py_pos_0 + 1 & 65535; } else { label = 1112; break; } } if ((label | 0) == 1112) { ___assert_func(1184, 393, 7224, 1632); return 0; } HEAP8[$dmi_c_phrase_] = 0; HEAP32[$this + 112 >> 2] = 1; HEAP32[$this + 356 >> 2] = 1; HEAP8[$this + 360 | 0] = 0; $116 = HEAP16[$length386 >> 1] | 0; HEAP32[$fixed_hzs_ >> 2] = $116 & 65535; HEAP16[$this + 118 >> 1] = $116; HEAP32[$arrayidx317 >> 2] = 16777215; $idxprom420 = HEAPU16[$this + 736 + (HEAP32[$fixed_hzs_ >> 2] << 1) >> 1] | 0; $120 = HEAP32[$this + 96 >> 2] | 0; HEAP32[$120 + ($idxprom420 * 12 | 0) + 8 >> 2] = (HEAP32[$this + 80 >> 2] | 0) + ((HEAPU16[$120 + ($idxprom420 * 12 | 0) >> 1] | 0) << 4); $retval_0 = 1; return $retval_0 | 0; } } while (0); if ($clear_fixed_this_step) { $fixed_ch_pos_0_ph = $cmp6 ? 0 : $ch_pos - 1 | 0; } else { $fixed_ch_pos_0_ph = $ch_pos; } $matrix_130 = $this + 96 | 0; $50 = HEAP32[$matrix_130 >> 2] | 0; $fixed_ch_pos_0 = $fixed_ch_pos_0_ph; while (1) { $cmp133 = ($fixed_ch_pos_0 | 0) == 0; if ((HEAP32[$50 + ($fixed_ch_pos_0 * 12 | 0) + 8 >> 2] | 0) != 0 | $cmp133) { break; } else { $fixed_ch_pos_0 = $fixed_ch_pos_0 - 1 | 0; } } $fixed_lmas_ = $this + 356 | 0; HEAP32[$fixed_lmas_ >> 2] = 0; HEAP32[$fixed_hzs_ >> 2] = 0; do { if (!$cmp133) { $52 = HEAP32[$fixed_hzs_ >> 2] | 0; $conv141114 = HEAPU16[$this + 736 + ($52 << 1) >> 1] | 0; if ($conv141114 >>> 0 < $fixed_ch_pos_0 >>> 0) { $54 = $52; while (1) { $inc = $54 + 1 | 0; HEAP32[$fixed_hzs_ >> 2] = $inc; $conv141 = HEAPU16[$this + 736 + ($inc << 1) >> 1] | 0; if ($conv141 >>> 0 < $fixed_ch_pos_0 >>> 0) { $54 = $inc; } else { $conv141_lcssa = $conv141; break; } } } else { $conv141_lcssa = $conv141114; } if (($conv141_lcssa | 0) != ($fixed_ch_pos_0 | 0)) { ___assert_func(1184, 308, 7224, 3480); return 0; } $56 = HEAP32[$fixed_lmas_ >> 2] | 0; $conv157110 = HEAPU16[$this + 116 + ($56 << 1) >> 1] | 0; $58 = HEAP32[$fixed_hzs_ >> 2] | 0; if ($conv157110 >>> 0 < $58 >>> 0) { $59 = $56; while (1) { $inc162 = $59 + 1 | 0; HEAP32[$fixed_lmas_ >> 2] = $inc162; $conv157 = HEAPU16[$this + 116 + ($inc162 << 1) >> 1] | 0; $61 = HEAP32[$fixed_hzs_ >> 2] | 0; if ($conv157 >>> 0 < $61 >>> 0) { $59 = $inc162; } else { $conv157_lcssa = $conv157; $_lcssa = $61; break; } } } else { $conv157_lcssa = $conv157110; $_lcssa = $58; } if (($conv157_lcssa | 0) == ($_lcssa | 0)) { break; } ___assert_func(1184, 312, 7224, 2456); return 0; } } while (0); $cmp177 = ($fixed_ch_pos_0 | 0) == ($ch_pos | 0); $or_cond85 = $cmp177 & $clear_dmi_this_step; do { if ($or_cond85) { $62 = HEAP32[$matrix_130 >> 2] | 0; if ((HEAP16[$62 + ($fixed_ch_pos_0 * 12 | 0) + 6 >> 1] & 32767) == 0) { $dict_handles_to_clear174_0 = 0; break; } $dict_handles_to_clear174_0 = (HEAP32[$this + 88 >> 2] | 0) + ((HEAPU16[$62 + ($fixed_ch_pos_0 * 12 | 0) + 2 >> 1] | 0) * 12 | 0) | 0; } else { $dict_handles_to_clear174_0 = 0; } } while (0); do { if ((HEAP32[$pys_decoded_len_ >> 2] | 0) >>> 0 <= $fixed_ch_pos_0 >>> 0 | $clear_dmi_this_step) { $dict_handles_to_clear174_1 = $dict_handles_to_clear174_0; label = 1086; } else { $add200 = $fixed_ch_pos_0 + 1 | 0; $69 = HEAP32[$matrix_130 >> 2] | 0; if ((HEAP16[$69 + ($add200 * 12 | 0) + 6 >> 1] & 32767) == 0) { break; } $dict_handles_to_clear174_1 = (HEAP32[$this + 88 >> 2] | 0) + ((HEAPU16[$69 + ($add200 * 12 | 0) + 2 >> 1] | 0) * 12 | 0) | 0; label = 1086; } } while (0); do { if ((label | 0) == 1086) { if (($dict_handles_to_clear174_1 | 0) == 0) { break; } $75 = HEAP32[$this + 12 >> 2] | 0; $conv224 = $fixed_ch_pos_0 & 65535; FUNCTION_TABLE_viii[HEAP32[(HEAP32[$75 >> 2] | 0) + 20 >> 2] & 15]($75, $conv224, HEAP16[$dict_handles_to_clear174_1 >> 1] | 0); $79 = HEAP32[$this + 16 >> 2] | 0; if (($79 | 0) == 0) { break; } FUNCTION_TABLE_viii[HEAP32[(HEAP32[$79 >> 2] | 0) + 20 >> 2] & 15]($79, $conv224, HEAP16[$dict_handles_to_clear174_1 + 2 >> 1] | 0); } } while (0); HEAP32[$pys_decoded_len_ >> 2] = $fixed_ch_pos_0; if ($or_cond85) { $sub241 = $fixed_ch_pos_0 - 1 | 0; $83 = HEAP32[$matrix_130 >> 2] | 0; HEAP16[$this + 92 >> 1] = (HEAP16[$83 + ($sub241 * 12 | 0) + 6 >> 1] & 32767) + (HEAP16[$83 + ($sub241 * 12 | 0) + 2 >> 1] | 0) & 65535; $90 = (HEAP32[$matrix_130 >> 2] | 0) + ($fixed_ch_pos_0 * 12 | 0) + 6 | 0; HEAP16[$90 >> 1] = HEAP16[$90 >> 1] & -32768; } else { $93 = HEAP32[$matrix_130 >> 2] | 0; HEAP16[$this + 92 >> 1] = (HEAP16[$93 + ($fixed_ch_pos_0 * 12 | 0) + 6 >> 1] & 32767) + (HEAP16[$93 + ($fixed_ch_pos_0 * 12 | 0) + 2 >> 1] | 0) & 65535; } if ($cmp177 & $clear_mtrx_this_step) { $sub276 = $fixed_ch_pos_0 - 1 | 0; $98 = HEAP32[$matrix_130 >> 2] | 0; HEAP16[$this + 84 >> 1] = (HEAP16[$98 + ($sub276 * 12 | 0) + 4 >> 1] | 0) + (HEAP16[$98 + ($sub276 * 12 | 0) >> 1] | 0) & 65535; HEAP16[(HEAP32[$matrix_130 >> 2] | 0) + ($fixed_ch_pos_0 * 12 | 0) + 4 >> 1] = 0; } else { $102 = HEAP32[$matrix_130 >> 2] | 0; HEAP16[$this + 84 >> 1] = (HEAP16[$102 + ($fixed_ch_pos_0 * 12 | 0) + 4 >> 1] | 0) + (HEAP16[$102 + ($fixed_ch_pos_0 * 12 | 0) >> 1] | 0) & 65535; } $conv306105 = $fixed_ch_pos_0 & 65535; if ($conv306105 >>> 0 >= $ch_pos >>> 0) { $retval_0 = 1; return $retval_0 | 0; } $re_pos_0107 = $fixed_ch_pos_0 & 65535; $conv306108 = $conv306105; while (1) { __ZN10ime_pinyin12MatrixSearch8add_charEc($this, HEAP8[$this + 32 + $conv306108 | 0] | 0) | 0; $inc311 = $re_pos_0107 + 1 & 65535; $conv306 = $inc311 & 65535; if ($conv306 >>> 0 < $ch_pos >>> 0) { $re_pos_0107 = $inc311; $conv306108 = $conv306; } else { $retval_0 = 1; break; } } return $retval_0 | 0; } function __ZN10ime_pinyin12MatrixSearch18prepare_candidatesEv($this) { $this = $this | 0; var $sent_len = 0, $fixed_hzs_ = 0, $sub = 0, $lma_size_max_0 = 0, $call = 0, $2 = 0, $lpi_total_ = 0, $lpi_num_full_match_013 = 0, $pfullsent_112 = 0, $lma_size_011 = 0, $4 = 0, $cmp22 = 0, $call23 = 0, $pfullsent_2 = 0, $lpi_num_full_match_1 = 0, $dec = 0, $lpi_num_full_match_0_lcssa = 0, $7 = 0, $8 = 0, $sub38 = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 32 | 0; $sent_len = sp + 24 | 0; $fixed_hzs_ = $this + 896 | 0; $sub = (HEAP32[$this + 732 >> 2] | 0) - (HEAP32[$fixed_hzs_ >> 2] | 0) | 0; $lma_size_max_0 = $sub >>> 0 < 8 ? $sub & 65535 : 8; $call = __ZN10ime_pinyin12MatrixSearch14get_candidate0EPtjS1_b($this, sp | 0, 9, $sent_len, 1) | 0; $2 = HEAP16[$sent_len >> 1] | 0; $lpi_total_ = $this + 12500 | 0; HEAP32[$lpi_total_ >> 2] = 0; if ($lma_size_max_0 << 16 >> 16 == 0) { $lpi_num_full_match_0_lcssa = 0; $7 = $this + 900 + ($lpi_num_full_match_0_lcssa << 3) | 0; $8 = HEAP32[$lpi_total_ >> 2] | 0; $sub38 = $8 - $lpi_num_full_match_0_lcssa | 0; __ZN10ime_pinyin7myqsortEPvjjPFiPKvS2_E($7, $sub38, 8, 20); STACKTOP = sp; return; } $lma_size_011 = $lma_size_max_0; $pfullsent_112 = ($2 & 65535) > 8 ? 0 : $call; $lpi_num_full_match_013 = 0; while (1) { $4 = HEAP32[$lpi_total_ >> 2] | 0; $cmp22 = $lma_size_011 << 16 >> 16 == $lma_size_max_0 << 16 >> 16; $call23 = __ZN10ime_pinyin12MatrixSearch8get_lpisEPKtjPNS_10LmaPsbItemEjS2_b($this, $this + 816 + (HEAP32[$fixed_hzs_ >> 2] << 1) | 0, $lma_size_011 & 65535, $this + 900 + ($4 << 3) | 0, 1450 - $4 | 0, $pfullsent_112, $cmp22) | 0; if (($call23 | 0) == 0) { $pfullsent_2 = $pfullsent_112; } else { HEAP32[$lpi_total_ >> 2] = (HEAP32[$lpi_total_ >> 2] | 0) + $call23; $pfullsent_2 = 0; } if ($cmp22) { $lpi_num_full_match_1 = HEAP32[$lpi_total_ >> 2] | 0; } else { $lpi_num_full_match_1 = $lpi_num_full_match_013; } $dec = $lma_size_011 - 1 & 65535; if ($dec << 16 >> 16 == 0) { $lpi_num_full_match_0_lcssa = $lpi_num_full_match_1; break; } else { $lma_size_011 = $dec; $pfullsent_112 = $pfullsent_2; $lpi_num_full_match_013 = $lpi_num_full_match_1; } } $7 = $this + 900 + ($lpi_num_full_match_0_lcssa << 3) | 0; $8 = HEAP32[$lpi_total_ >> 2] | 0; $sub38 = $8 - $lpi_num_full_match_0_lcssa | 0; __ZN10ime_pinyin7myqsortEPvjjPFiPKvS2_E($7, $sub38, 8, 20); STACKTOP = sp; return; } function __ZN10ime_pinyin12MatrixSearch16get_spl_start_idEv($this) { $this = $this | 0; var $lma_id_num_ = 0, $spl_id_num_ = 0, $pys_decoded_len_ = 0, $2 = 0, $matrix_ = 0, $fixed_lmas_ = 0, $fixed_hzs_ = 0, $mtrx_nd_pool_ = 0, $add_ptr = 0, $dmi_pool_ = 0, $dmi_pool_41 = 0, $mtrx_nd_093 = 0, $12 = 0, $15 = 0, $phitmp = 0, $step37 = 0, $conv3491_in = 0, $conv3491 = 0, $39 = 0, $40 = 0, $41 = 0, $42 = 0, $pos_087 = 0, $sub83 = 0, $add84 = 0, $43 = 0, $44 = 0, $arrayidx96 = 0, $xor55 = 0, $arrayidx108 = 0, $arrayidx134 = 0, $xor13658 = 0, $arrayidx147 = 0, $65 = 0, $66 = 0, $_lcssa = 0, $pos264_066 = 0, $67 = 0, $68 = 0, $69 = 0, $pos166_078 = 0, $sub181 = 0, $add188 = 0, $70 = 0, $71 = 0, $arrayidx200 = 0, $xor20252 = 0, $arrayidx213 = 0, $arrayidx238 = 0, $xor239 = 0, $arrayidx248 = 0, $92 = 0, $pos264_069 = 0, $pos264_0_in68 = 0, $93 = 0, $arrayidx279 = 0, $94 = 0, $storemerge = 0, $pos264_0 = 0, $98 = 0, $pos311_0 = 0, label = 0; $lma_id_num_ = $this + 112 | 0; HEAP32[$lma_id_num_ >> 2] = 0; HEAP16[$this + 116 >> 1] = 0; $spl_id_num_ = $this + 732 | 0; HEAP32[$spl_id_num_ >> 2] = 0; HEAP16[$this + 736 >> 1] = 0; if ((HEAP8[$this | 0] & 1) == 0) { return; } $pys_decoded_len_ = $this + 72 | 0; $2 = HEAP32[$pys_decoded_len_ >> 2] | 0; if (($2 | 0) == 0) { return; } $matrix_ = $this + 96 | 0; if ((HEAP16[(HEAP32[$matrix_ >> 2] | 0) + ($2 * 12 | 0) + 4 >> 1] | 0) == 0) { return; } $fixed_lmas_ = $this + 356 | 0; HEAP32[$lma_id_num_ >> 2] = HEAP32[$fixed_lmas_ >> 2]; $fixed_hzs_ = $this + 896 | 0; HEAP32[$spl_id_num_ >> 2] = HEAP32[$fixed_hzs_ >> 2]; $mtrx_nd_pool_ = $this + 80 | 0; $add_ptr = (HEAP32[$mtrx_nd_pool_ >> 2] | 0) + (HEAPU16[(HEAP32[$matrix_ >> 2] | 0) + ((HEAP32[$pys_decoded_len_ >> 2] | 0) * 12 | 0) >> 1] << 4) | 0; L1417 : do { if (($add_ptr | 0) != (HEAP32[$mtrx_nd_pool_ >> 2] | 0)) { $dmi_pool_ = $this + 88 | 0; $dmi_pool_41 = $this + 88 | 0; $mtrx_nd_093 = $add_ptr; do { $12 = HEAP32[$fixed_hzs_ >> 2] | 0; if (($12 | 0) != 0) { if ((HEAPU16[$mtrx_nd_093 + 14 >> 1] | 0) <= (HEAPU16[$this + 736 + ($12 << 1) >> 1] | 0)) { break L1417; } } $15 = HEAP16[$mtrx_nd_093 + 12 >> 1] | 0; if ($15 << 16 >> 16 != -1) { $phitmp = (HEAPU8[(HEAP32[$dmi_pool_ >> 2] | 0) + (($15 & 65535) * 12 | 0) + 9 | 0] | 0) >>> 1 & 255; $step37 = $mtrx_nd_093 + 14 | 0; $conv3491_in = $15; do { $conv3491 = $conv3491_in & 65535; HEAP16[$this + 736 + ((HEAP32[$spl_id_num_ >> 2] | 0) + 1 << 1) >> 1] = ((HEAP16[$step37 >> 1] | 0) - $phitmp & 65535) + ((HEAPU8[(HEAP32[$dmi_pool_41 >> 2] | 0) + ($conv3491 * 12 | 0) + 9 | 0] | 0) >>> 1 & 255) & 65535; HEAP16[$this + 816 + (HEAP32[$spl_id_num_ >> 2] << 1) >> 1] = HEAP16[(HEAP32[$dmi_pool_41 >> 2] | 0) + ($conv3491 * 12 | 0) + 6 >> 1] | 0; HEAP32[$spl_id_num_ >> 2] = (HEAP32[$spl_id_num_ >> 2] | 0) + 1; $conv3491_in = HEAP16[(HEAP32[$dmi_pool_41 >> 2] | 0) + ($conv3491 * 12 | 0) + 4 >> 1] | 0; } while ($conv3491_in << 16 >> 16 != -1); } HEAP16[$this + 116 + ((HEAP32[$lma_id_num_ >> 2] | 0) + 1 << 1) >> 1] = HEAP32[$spl_id_num_ >> 2] & 65535; HEAP32[$this + 196 + (HEAP32[$lma_id_num_ >> 2] << 2) >> 2] = HEAP32[$mtrx_nd_093 >> 2]; HEAP32[$lma_id_num_ >> 2] = (HEAP32[$lma_id_num_ >> 2] | 0) + 1; $mtrx_nd_093 = HEAP32[$mtrx_nd_093 + 8 >> 2] | 0; } while (($mtrx_nd_093 | 0) != (HEAP32[$mtrx_nd_pool_ >> 2] | 0)); } } while (0); $39 = HEAP32[$fixed_hzs_ >> 2] | 0; $40 = HEAP32[$spl_id_num_ >> 2] | 0; if ($39 >>> 0 < (((1 - $39 + $40 | 0) >>> 1) + $39 | 0) >>> 0) { $pos_087 = $39; $42 = $39; $41 = $40; while (1) { $sub83 = $42 - $pos_087 + $41 | 0; $add84 = $pos_087 + 1 | 0; if (($sub83 | 0) != ($add84 | 0)) { $arrayidx96 = $this + 736 + ($add84 << 1) | 0; $xor55 = HEAP16[$arrayidx96 >> 1] ^ HEAP16[$this + 736 + ($sub83 << 1) >> 1]; HEAP16[$arrayidx96 >> 1] = $xor55; $arrayidx108 = $this + 736 + ((HEAP32[$spl_id_num_ >> 2] | 0) - $pos_087 + (HEAP32[$fixed_hzs_ >> 2] | 0) << 1) | 0; HEAP16[$arrayidx108 >> 1] = HEAP16[$arrayidx108 >> 1] ^ $xor55; HEAP16[$arrayidx96 >> 1] = HEAP16[$arrayidx96 >> 1] ^ HEAP16[$this + 736 + ((HEAP32[$spl_id_num_ >> 2] | 0) - $pos_087 + (HEAP32[$fixed_hzs_ >> 2] | 0) << 1) >> 1]; $arrayidx134 = $this + 816 + ($pos_087 << 1) | 0; $xor13658 = HEAP16[$arrayidx134 >> 1] ^ HEAP16[$this + 816 + ((HEAP32[$spl_id_num_ >> 2] | 0) + ~$pos_087 + (HEAP32[$fixed_hzs_ >> 2] | 0) << 1) >> 1]; HEAP16[$arrayidx134 >> 1] = $xor13658; $arrayidx147 = $this + 816 + ((HEAP32[$spl_id_num_ >> 2] | 0) + ~$pos_087 + (HEAP32[$fixed_hzs_ >> 2] | 0) << 1) | 0; HEAP16[$arrayidx147 >> 1] = HEAP16[$arrayidx147 >> 1] ^ $xor13658; HEAP16[$arrayidx134 >> 1] = HEAP16[$arrayidx134 >> 1] ^ HEAP16[$this + 816 + ((HEAP32[$spl_id_num_ >> 2] | 0) + ~$pos_087 + (HEAP32[$fixed_hzs_ >> 2] | 0) << 1) >> 1]; } $43 = HEAP32[$fixed_hzs_ >> 2] | 0; $44 = HEAP32[$spl_id_num_ >> 2] | 0; if ($add84 >>> 0 < (((1 - $43 + $44 | 0) >>> 1) + $43 | 0) >>> 0) { $pos_087 = $add84; $42 = $43; $41 = $44; } else { break; } } } $65 = HEAP32[$fixed_lmas_ >> 2] | 0; $66 = HEAP32[$lma_id_num_ >> 2] | 0; L1437 : do { if ($65 >>> 0 < (((1 - $65 + $66 | 0) >>> 1) + $65 | 0) >>> 0) { $pos166_078 = $65; $69 = $65; $68 = $66; while (1) { $sub181 = $69 - $pos166_078 + $68 | 0; if (($sub181 - 1 | 0) >>> 0 < $pos166_078 >>> 0) { break; } $add188 = $pos166_078 + 1 | 0; if ($sub181 >>> 0 > $add188 >>> 0) { $arrayidx200 = $this + 116 + ($add188 << 1) | 0; $xor20252 = HEAP16[$arrayidx200 >> 1] ^ HEAP16[$this + 116 + ($69 - $pos166_078 + $68 << 1) >> 1]; HEAP16[$arrayidx200 >> 1] = $xor20252; $arrayidx213 = $this + 116 + ((HEAP32[$lma_id_num_ >> 2] | 0) - $pos166_078 + (HEAP32[$fixed_lmas_ >> 2] | 0) << 1) | 0; HEAP16[$arrayidx213 >> 1] = HEAP16[$arrayidx213 >> 1] ^ $xor20252; HEAP16[$arrayidx200 >> 1] = HEAP16[$arrayidx200 >> 1] ^ HEAP16[$this + 116 + ((HEAP32[$lma_id_num_ >> 2] | 0) - $pos166_078 + (HEAP32[$fixed_lmas_ >> 2] | 0) << 1) >> 1]; $arrayidx238 = $this + 196 + ($pos166_078 << 2) | 0; $xor239 = HEAP32[$arrayidx238 >> 2] ^ HEAP32[$this + 196 + ((HEAP32[$lma_id_num_ >> 2] | 0) + ~$pos166_078 + (HEAP32[$fixed_lmas_ >> 2] | 0) << 2) >> 2]; HEAP32[$arrayidx238 >> 2] = $xor239; $arrayidx248 = $this + 196 + ((HEAP32[$lma_id_num_ >> 2] | 0) + ~$pos166_078 + (HEAP32[$fixed_lmas_ >> 2] | 0) << 2) | 0; HEAP32[$arrayidx248 >> 2] = HEAP32[$arrayidx248 >> 2] ^ $xor239; HEAP32[$arrayidx238 >> 2] = HEAP32[$arrayidx238 >> 2] ^ HEAP32[$this + 196 + ((HEAP32[$lma_id_num_ >> 2] | 0) + ~$pos166_078 + (HEAP32[$fixed_lmas_ >> 2] | 0) << 2) >> 2]; } $70 = HEAP32[$fixed_lmas_ >> 2] | 0; $71 = HEAP32[$lma_id_num_ >> 2] | 0; if ($add188 >>> 0 < (((1 - $70 + $71 | 0) >>> 1) + $70 | 0) >>> 0) { $pos166_078 = $add188; $69 = $70; $68 = $71; } else { $_lcssa = $70; break L1437; } } ___assert_func(1184, 1360, 7e3, 2592); } else { $_lcssa = $65; } } while (0); $pos264_066 = $_lcssa + 1 | 0; $67 = HEAP32[$lma_id_num_ >> 2] | 0; if ($pos264_066 >>> 0 <= $67 >>> 0) { $pos264_0_in68 = $_lcssa; $pos264_069 = $pos264_066; $92 = $67; while (1) { $93 = HEAP16[$this + 116 + ($pos264_0_in68 << 1) >> 1] | 0; $arrayidx279 = $this + 116 + ($pos264_069 << 1) | 0; $94 = HEAP16[$arrayidx279 >> 1] | 0; if ($pos264_069 >>> 0 < $92 >>> 0) { $storemerge = ($94 + $93 & 65535) - (HEAP16[$this + 116 + ($pos264_0_in68 + 2 << 1) >> 1] | 0) & 65535; } else { $storemerge = ($94 + $93 & 65535) - (HEAP16[$this + 116 + (HEAP32[$fixed_lmas_ >> 2] << 1) >> 1] | 0) & 65535; } HEAP16[$arrayidx279 >> 1] = $storemerge; $pos264_0 = $pos264_069 + 1 | 0; $98 = HEAP32[$lma_id_num_ >> 2] | 0; if ($pos264_0 >>> 0 > $98 >>> 0) { break; } else { $pos264_0_in68 = $pos264_069; $pos264_069 = $pos264_0; $92 = $98; } } } HEAP32[$fixed_hzs_ >> 2] = 0; $pos311_0 = HEAP32[$spl_id_num_ >> 2] | 0; while (1) { if (($pos311_0 | 0) == 0) { label = 1169; break; } if ((HEAP32[(HEAP32[$matrix_ >> 2] | 0) + ((HEAPU16[$this + 736 + ($pos311_0 << 1) >> 1] | 0) * 12 | 0) + 8 >> 2] | 0) == 0) { $pos311_0 = $pos311_0 - 1 | 0; } else { break; } } if ((label | 0) == 1169) { return; } HEAP32[$fixed_hzs_ >> 2] = $pos311_0; return; } function __ZN10ime_pinyin12MatrixSearch9delsearchEjbb($this, $pos, $is_pos_in_splid, $clear_fixed_this_step) { $this = $this | 0; $pos = $pos | 0; $is_pos_in_splid = $is_pos_in_splid | 0; $clear_fixed_this_step = $clear_fixed_this_step | 0; var $pys_decoded_len_ = 0, $2 = 0, $reset_pos_0 = 0, $4 = 0, $fixed_lmas_ = 0, $7 = 0, $sublma_num = 0, $dec = 0, $16 = 0, $arrayidx58 = 0, $conv62 = 0, $sub = 0, $conv69 = 0, $conv84 = 0, $sub85 = 0, $reset_pos_1 = 0, $length94 = 0, $dmi_c_phrase_ = 0, $c_py_pos_0 = 0, $conv110 = 0, $29 = 0, $fixed_hzs_ = 0, $idxprom139 = 0, $33 = 0, $reset_pos_131 = 0, $reset_pos_2 = 0, $35 = 0, $retval_0 = 0, label = 0; if ((HEAP8[$this | 0] & 1) == 0) { $retval_0 = 0; return $retval_0 | 0; } $pys_decoded_len_ = $this + 72 | 0; $2 = HEAP32[$pys_decoded_len_ >> 2] | 0; if ($2 >>> 0 <= $pos >>> 0) { __ZN10ime_pinyin12MatrixSearch10del_in_pysEjj($this, $pos, 1); $reset_pos_0 = HEAP32[$pys_decoded_len_ >> 2] | 0; while (1) { $4 = HEAP8[$this + 32 + $reset_pos_0 | 0] | 0; if ($4 << 24 >> 24 == 0) { break; } if (__ZN10ime_pinyin12MatrixSearch8add_charEc($this, $4) | 0) { $reset_pos_0 = $reset_pos_0 + 1 | 0; } else { label = 1175; break; } } if ((label | 0) == 1175) { HEAP32[$pys_decoded_len_ >> 2] = $reset_pos_0; } __ZN10ime_pinyin12MatrixSearch16get_spl_start_idEv($this); __ZN10ime_pinyin12MatrixSearch18prepare_candidatesEv($this); $retval_0 = HEAP32[$pys_decoded_len_ >> 2] | 0; return $retval_0 | 0; } do { if ($is_pos_in_splid) { if ((HEAP32[$this + 732 >> 2] | 0) >>> 0 <= $pos >>> 0) { $retval_0 = $2; return $retval_0 | 0; } $arrayidx58 = $this + 736 + ($pos + 1 << 1) | 0; $conv62 = HEAPU16[$this + 736 + ($pos << 1) >> 1] | 0; $sub = (HEAPU16[$arrayidx58 >> 1] | 0) - $conv62 | 0; __ZN10ime_pinyin12MatrixSearch10del_in_pysEjj($this, $conv62, $sub); $conv69 = HEAPU16[$this + 116 + (HEAP32[$this + 356 >> 2] << 1) >> 1] | 0; if ($conv69 >>> 0 <= $pos >>> 0) { $reset_pos_131 = (HEAPU16[$arrayidx58 >> 1] | 0) - $sub | 0; label = 1198; break; } $conv84 = HEAPU16[$this + 736 + ($conv69 << 1) >> 1] | 0; $sub85 = $conv84 - $sub | 0; if (($conv84 | 0) == ($sub | 0)) { $reset_pos_1 = $sub85; label = 1189; break; } __ZN10ime_pinyin12MatrixSearch16merge_fixed_lmasEj($this, $pos); $reset_pos_1 = $sub85; label = 1189; } else { $fixed_lmas_ = $this + 356 | 0; $7 = HEAP32[$fixed_lmas_ >> 2] | 0; do { if (($7 | 0) != 0) { if ((HEAPU16[$this + 736 + (HEAPU16[$this + 116 + ($7 << 1) >> 1] << 1) >> 1] | 0) >>> 0 <= $pos >>> 0) { break; } $retval_0 = HEAP32[$pys_decoded_len_ >> 2] | 0; return $retval_0 | 0; } } while (0); __ZN10ime_pinyin12MatrixSearch10del_in_pysEjj($this, $pos, 1); if ((HEAPU16[$this + 736 + (HEAPU16[$this + 116 + (HEAP32[$fixed_lmas_ >> 2] << 1) >> 1] << 1) >> 1] | 0) != ($pos | 0)) { $reset_pos_131 = $pos; label = 1198; break; } if ((HEAP32[$this + 196 >> 2] | 0) != 16777215 | $clear_fixed_this_step ^ 1) { $reset_pos_131 = $pos; label = 1198; break; } $sublma_num = $this + 720 | 0; $dec = (HEAP32[$sublma_num >> 2] | 0) - 1 | 0; HEAP32[$sublma_num >> 2] = $dec; $16 = HEAP16[$this + 640 + ($dec << 1) >> 1] | 0; HEAP16[$this + 724 >> 1] = $16; $reset_pos_1 = HEAPU16[$this + 736 + (($16 & 65535) << 1) >> 1] | 0; label = 1189; } } while (0); do { if ((label | 0) == 1189) { if (($reset_pos_1 | 0) == 0) { $reset_pos_131 = 0; label = 1198; break; } $length94 = $this + 724 | 0; if ((HEAP16[$length94 >> 1] | 0) == 0) { ___assert_func(1184, 552, 6584, 1360); return 0; } if (($reset_pos_1 | 0) != (HEAPU16[$this + 480 + (HEAPU16[$this + 640 + (HEAP32[$this + 720 >> 2] << 1) >> 1] << 1) >> 1] | 0)) { ___assert_func(1184, 552, 6584, 1360); return 0; } __ZN10ime_pinyin12MatrixSearch13reset_search0Ev($this) | 0; $dmi_c_phrase_ = $this + 728 | 0; HEAP8[$dmi_c_phrase_] = 1; $c_py_pos_0 = 0; while (1) { $conv110 = $c_py_pos_0 & 65535; if ($conv110 >>> 0 >= $reset_pos_1 >>> 0) { label = 1197; break; } if (__ZN10ime_pinyin12MatrixSearch8add_charEc($this, HEAP8[$this + 32 + $conv110 | 0] | 0) | 0) { $c_py_pos_0 = $c_py_pos_0 + 1 & 65535; } else { label = 1196; break; } } if ((label | 0) == 1196) { ___assert_func(1184, 563, 6584, 1632); return 0; } else if ((label | 0) == 1197) { HEAP8[$dmi_c_phrase_] = 0; HEAP32[$this + 112 >> 2] = 1; HEAP32[$this + 356 >> 2] = 1; HEAP8[$this + 360 | 0] = 0; $29 = HEAP16[$length94 >> 1] | 0; $fixed_hzs_ = $this + 896 | 0; HEAP32[$fixed_hzs_ >> 2] = $29 & 65535; HEAP16[$this + 118 >> 1] = $29; HEAP32[$this + 196 >> 2] = 16777215; $idxprom139 = HEAPU16[$this + 736 + (HEAP32[$fixed_hzs_ >> 2] << 1) >> 1] | 0; $33 = HEAP32[$this + 96 >> 2] | 0; HEAP32[$33 + ($idxprom139 * 12 | 0) + 8 >> 2] = (HEAP32[$this + 80 >> 2] | 0) + (HEAPU16[$33 + ($idxprom139 * 12 | 0) >> 1] << 4); $reset_pos_2 = $reset_pos_1; break; } } } while (0); if ((label | 0) == 1198) { __ZN10ime_pinyin12MatrixSearch12reset_searchEjbbb($this, $reset_pos_131, $clear_fixed_this_step, 0, 0) | 0; $reset_pos_2 = $reset_pos_131; } while (1) { $35 = HEAP8[$this + 32 + $reset_pos_2 | 0] | 0; if ($35 << 24 >> 24 == 0) { break; } if (__ZN10ime_pinyin12MatrixSearch8add_charEc($this, $35) | 0) { $reset_pos_2 = $reset_pos_2 + 1 | 0; } else { label = 1201; break; } } if ((label | 0) == 1201) { HEAP32[$pys_decoded_len_ >> 2] = $reset_pos_2; } __ZN10ime_pinyin12MatrixSearch16get_spl_start_idEv($this); __ZN10ime_pinyin12MatrixSearch18prepare_candidatesEv($this); $retval_0 = HEAP32[$pys_decoded_len_ >> 2] | 0; return $retval_0 | 0; } function __ZN10ime_pinyin12MatrixSearch17get_candidate_numEv($this) { $this = $this | 0; var $2 = 0, $retval_0 = 0; if ((HEAP8[$this | 0] & 1) == 0) { $retval_0 = 0; return $retval_0 | 0; } $2 = HEAP32[$this + 72 >> 2] | 0; if (($2 | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } if ((HEAP16[(HEAP32[$this + 96 >> 2] | 0) + ($2 * 12 | 0) + 4 >> 1] | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $retval_0 = (HEAP32[$this + 12500 >> 2] | 0) + 1 | 0; return $retval_0 | 0; } function __ZN10ime_pinyin12MatrixSearch13get_candidateEjPtj($this, $cand_id, $cand_str, $max_len) { $this = $this | 0; $cand_id = $cand_id | 0; $cand_str = $cand_str | 0; $max_len = $max_len | 0; var $s = 0, $dec = 0, $5 = 0, $conv = 0, $s_len_0 = 0, $conv24 = 0, $retval_0 = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 24 | 0; $s = sp | 0; if ((HEAP8[$this | 0] & 1) == 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } if ((HEAP32[$this + 72 >> 2] | 0) == 0 | ($cand_str | 0) == 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } if (($cand_id | 0) == 0) { $retval_0 = __ZN10ime_pinyin12MatrixSearch14get_candidate0EPtjS1_b($this, $cand_str, $max_len, 0, 0) | 0; STACKTOP = sp; return $retval_0 | 0; } if ((HEAP32[$this + 12500 >> 2] | 0) == 0) { $retval_0 = __ZN10ime_pinyin12MatrixSearch14get_candidate0EPtjS1_b($this, $cand_str, $max_len, 0, 0) | 0; STACKTOP = sp; return $retval_0 | 0; } $dec = $cand_id - 1 | 0; $5 = HEAP32[$this + 900 + ($dec << 3) >> 2] | 0; $conv = $5 >>> 24 & 15; if (($conv & 65535) > 1) { $s_len_0 = __ZN10ime_pinyin12MatrixSearch13get_lemma_strEjPtt($this, $5 & 16777215, $s | 0, 9) | 0; } else { HEAP16[$s >> 1] = HEAP16[$this + 900 + ($dec << 3) + 6 >> 1] | 0; HEAP16[$s + 2 >> 1] = 0; $s_len_0 = $conv; } $conv24 = $s_len_0 & 65535; if (!($s_len_0 << 16 >> 16 != 0 & $conv24 >>> 0 < $max_len >>> 0)) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } _utf16_strncpy($cand_str, $s | 0, $conv24) | 0; HEAP16[$cand_str + ($conv24 << 1) >> 1] = 0; $retval_0 = $cand_str; STACKTOP = sp; return $retval_0 | 0; } function __ZN10ime_pinyin12MatrixSearch14get_candidate0EPtjS1_b($this, $cand_str, $max_len, $retstr_len, $only_unfixed) { $this = $this | 0; $cand_str = $cand_str | 0; $max_len = $max_len | 0; $retstr_len = $retstr_len | 0; $only_unfixed = $only_unfixed | 0; var $idxs = 0, $str = 0, $0 = 0, $1 = 0, $add_ptr = 0, $id_num_0_lcssa = 0, $arraydecay = 0, $fixed_hzs_ = 0, $fixed_hzs_33 = 0, $mtrx_nd_035 = 0, $id_num_034 = 0, $inc = 0, $6 = 0, $id_num_1 = 0, $ret_pos_0 = 0, $dec = 0, $7 = 0, $call = 0, $conv15 = 0, $sub23 = 0, $add_ptr29 = 0, $9 = 0, $add_ptr38 = 0, $ret_pos_1 = 0, $cmp57 = 0, $retval_0 = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 184 | 0; $idxs = sp | 0; $str = sp + 160 | 0; $0 = HEAP32[$this + 72 >> 2] | 0; if (($0 | 0) == 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } $1 = HEAP32[$this + 96 >> 2] | 0; if ((HEAP16[$1 + ($0 * 12 | 0) + 4 >> 1] | 0) == 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } $add_ptr = (HEAP32[$this + 80 >> 2] | 0) + (HEAPU16[$1 + ($0 * 12 | 0) >> 1] << 4) | 0; if (($add_ptr | 0) == 0) { $id_num_0_lcssa = 0; } else { $id_num_034 = 0; $mtrx_nd_035 = $add_ptr; while (1) { HEAP32[$idxs + ($id_num_034 << 2) >> 2] = HEAP32[$mtrx_nd_035 >> 2]; $inc = $id_num_034 + 1 | 0; $6 = HEAP32[$mtrx_nd_035 + 8 >> 2] | 0; if (($6 | 0) == 0) { $id_num_0_lcssa = $inc; break; } else { $id_num_034 = $inc; $mtrx_nd_035 = $6; } } } $arraydecay = $str | 0; $fixed_hzs_ = $this + 896 | 0; $fixed_hzs_33 = $this + 896 | 0; $ret_pos_0 = 0; $id_num_1 = $id_num_0_lcssa; L1561 : while (1) { $dec = $id_num_1 - 1 | 0; $7 = HEAP32[$idxs + ($dec << 2) >> 2] | 0; if (($7 | 0) == 0) { $ret_pos_1 = $ret_pos_0; } else { $call = __ZN10ime_pinyin12MatrixSearch13get_lemma_strEjPtt($this, $7, $arraydecay, 9) | 0; $conv15 = $call & 65535; if ($call << 16 >> 16 == 0) { $retval_0 = 0; label = 1263; break; } $sub23 = $max_len - $ret_pos_0 | 0; do { if ($only_unfixed) { if (((HEAP32[$fixed_hzs_ >> 2] | 0) + $sub23 | 0) >>> 0 <= $conv15 >>> 0) { $retval_0 = 0; label = 1264; break L1561; } $9 = HEAP32[$fixed_hzs_33 >> 2] | 0; if ($ret_pos_0 >>> 0 < $9 >>> 0) { break; } $add_ptr38 = $cand_str + ($ret_pos_0 - $9 << 1) | 0; _utf16_strncpy($add_ptr38, $arraydecay, $conv15) | 0; } else { if ($sub23 >>> 0 <= $conv15 >>> 0) { $retval_0 = 0; label = 1265; break L1561; } $add_ptr29 = $cand_str + ($ret_pos_0 << 1) | 0; _utf16_strncpy($add_ptr29, $arraydecay, $conv15) | 0; } } while (0); $ret_pos_1 = $conv15 + $ret_pos_0 | 0; } if (($dec | 0) == 0) { label = 1253; break; } else { $ret_pos_0 = $ret_pos_1; $id_num_1 = $dec; } } if ((label | 0) == 1263) { STACKTOP = sp; return $retval_0 | 0; } else if ((label | 0) == 1264) { STACKTOP = sp; return $retval_0 | 0; } else if ((label | 0) == 1265) { STACKTOP = sp; return $retval_0 | 0; } else if ((label | 0) == 1253) { $cmp57 = ($retstr_len | 0) != 0; if ($only_unfixed) { if ($cmp57) { HEAP16[$retstr_len >> 1] = $ret_pos_1 - (HEAP32[$this + 896 >> 2] | 0) & 65535; } HEAP16[$cand_str + ($ret_pos_1 - (HEAP32[$this + 896 >> 2] | 0) << 1) >> 1] = 0; $retval_0 = $cand_str; STACKTOP = sp; return $retval_0 | 0; } else { if ($cmp57) { HEAP16[$retstr_len >> 1] = $ret_pos_1 & 65535; } HEAP16[$cand_str + ($ret_pos_1 << 1) >> 1] = 0; $retval_0 = $cand_str; STACKTOP = sp; return $retval_0 | 0; } } return 0; } function __ZN10ime_pinyin12MatrixSearch13get_lemma_strEjPtt($this, $id_lemma, $str_buf, $str_max) { $this = $this | 0; $id_lemma = $id_lemma | 0; $str_buf = $str_buf | 0; $str_max = $str_max | 0; var $0 = 0, $3 = 0, $7 = 0, $sub = 0, $str_len_0 = 0, $arraydecay = 0, $conv28 = 0, $retval_0 = 0; if (__ZN10ime_pinyin15is_system_lemmaEj($id_lemma) | 0) { $0 = HEAP32[$this + 12 >> 2] | 0; $retval_0 = FUNCTION_TABLE_iiiii[HEAP32[(HEAP32[$0 >> 2] | 0) + 32 >> 2] & 31]($0, $id_lemma, $str_buf, $str_max) | 0; return $retval_0 | 0; } if (!(__ZN10ime_pinyin13is_user_lemmaEj($id_lemma) | 0)) { if (($str_max & 65535) < 2 | (__ZN10ime_pinyin18is_composing_lemmaEj($id_lemma) | 0) ^ 1) { $retval_0 = 0; return $retval_0 | 0; } $7 = HEAP16[$this + 640 + (HEAP32[$this + 720 >> 2] << 1) >> 1] | 0; $sub = ($str_max & 65535) - 1 | 0; $str_len_0 = ($7 & 65535 | 0) > ($sub | 0) ? $sub & 65535 : $7; $arraydecay = $this + 560 | 0; $conv28 = $str_len_0 & 65535; _utf16_strncpy($str_buf, $arraydecay, $conv28) | 0; HEAP16[$str_buf + ($conv28 << 1) >> 1] = 0; $retval_0 = $str_len_0; return $retval_0 | 0; } $3 = HEAP32[$this + 16 >> 2] | 0; if (($3 | 0) == 0) { HEAP16[$str_buf >> 1] = 0; $retval_0 = 0; return $retval_0 | 0; } else { $retval_0 = FUNCTION_TABLE_iiiii[HEAP32[(HEAP32[$3 >> 2] | 0) + 32 >> 2] & 31]($3, $id_lemma, $str_buf, $str_max) | 0; return $retval_0 | 0; } return 0; } function __ZN10ime_pinyin12MatrixSearch16update_dict_freqEv($this) { $this = $this | 0; var $0 = 0, $call = 0, $3 = 0; $0 = HEAP32[$this + 16 >> 2] | 0; if (($0 | 0) == 0) { return; } $call = FUNCTION_TABLE_ii[HEAP32[(HEAP32[$0 >> 2] | 0) + 68 >> 2] & 31]($0) | 0; $3 = HEAP32[$this + 12 >> 2] | 0; FUNCTION_TABLE_vii[HEAP32[(HEAP32[$3 >> 2] | 0) + 72 >> 2] & 15]($3, $call); return; } function __ZN10ime_pinyin12MatrixSearch16get_lemma_splidsEjPttb($this, $id_lemma, $splids, $splids_max, $arg_valid) { $this = $this | 0; $id_lemma = $id_lemma | 0; $splids = $splids | 0; $splids_max = $splids_max | 0; $arg_valid = $arg_valid | 0; var $spl_trie_ = 0, $splid_num_0 = 0, $splid_num_1 = 0, $2 = 0, $5 = 0, $length = 0, $spl_trie_45 = 0, $pos_0 = 0, $conv34 = 0, $10 = 0, $retval_0 = 0, label = 0; do { if ($arg_valid) { $spl_trie_ = $this + 4 | 0; $splid_num_0 = 0; while (1) { if (($splid_num_0 & 65535) >= ($splids_max & 65535)) { break; } if (__ZNK10ime_pinyin12SpellingTrie10is_half_idEt(HEAP32[$spl_trie_ >> 2] | 0, HEAP16[$splids + (($splid_num_0 & 65535) << 1) >> 1] | 0) | 0) { break; } else { $splid_num_0 = $splid_num_0 + 1 & 65535; } } if ($splid_num_0 << 16 >> 16 == $splids_max << 16 >> 16) { $retval_0 = $splid_num_0; } else { $splid_num_1 = $splid_num_0; break; } return $retval_0 | 0; } else { $splid_num_1 = 0; } } while (0); if (__ZN10ime_pinyin15is_system_lemmaEj($id_lemma) | 0) { $2 = HEAP32[$this + 12 >> 2] | 0; $retval_0 = FUNCTION_TABLE_iiiiii[HEAP32[(HEAP32[$2 >> 2] | 0) + 36 >> 2] & 15]($2, $id_lemma, $splids, $splids_max, $arg_valid) | 0; return $retval_0 | 0; } if (__ZN10ime_pinyin13is_user_lemmaEj($id_lemma) | 0) { $5 = HEAP32[$this + 16 >> 2] | 0; if (($5 | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $retval_0 = FUNCTION_TABLE_iiiiii[HEAP32[(HEAP32[$5 >> 2] | 0) + 36 >> 2] & 15]($5, $id_lemma, $splids, $splids_max, $arg_valid) | 0; return $retval_0 | 0; } if (!(__ZN10ime_pinyin18is_composing_lemmaEj($id_lemma) | 0)) { $retval_0 = $splid_num_1; return $retval_0 | 0; } $length = $this + 724 | 0; if ((HEAPU16[$length >> 1] | 0) > ($splids_max & 65535)) { $retval_0 = 0; return $retval_0 | 0; } $spl_trie_45 = $this + 4 | 0; $pos_0 = 0; while (1) { $conv34 = $pos_0 & 65535; if (($pos_0 & 65535) >= (HEAPU16[$length >> 1] | 0)) { $retval_0 = $splid_num_1; label = 1310; break; } $10 = HEAP16[$this + 400 + ($conv34 << 1) >> 1] | 0; HEAP16[$splids + ($conv34 << 1) >> 1] = $10; if (__ZNK10ime_pinyin12SpellingTrie10is_half_idEt(HEAP32[$spl_trie_45 >> 2] | 0, $10) | 0) { $retval_0 = 0; label = 1305; break; } else { $pos_0 = $pos_0 + 1 & 65535; } } if ((label | 0) == 1310) { return $retval_0 | 0; } else if ((label | 0) == 1305) { return $retval_0 | 0; } return 0; } function __ZN10ime_pinyin12MatrixSearch15debug_print_dmiEtt($this, $dmi_pos, $nest_level) { $this = $this | 0; $dmi_pos = $dmi_pos | 0; $nest_level = $nest_level | 0; var $conv = 0, $1 = 0, $cmp5 = 0, $2 = 0, $conv22 = 0, $call24 = 0, $spl_id = 0, $call25 = 0, $conv27 = 0, sp = 0; sp = STACKTOP; $conv = $dmi_pos & 65535; if ((HEAPU16[$this + 92 >> 1] | 0) <= ($dmi_pos & 65535)) { STACKTOP = sp; return; } $1 = HEAP32[$this + 88 >> 2] | 0; $cmp5 = $nest_level << 16 >> 16 == 1; if ($cmp5) { _printf(768, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = $conv, tempInt) | 0) | 0; } $2 = $1 + ($conv * 12 | 0) + 8 | 0; if ((HEAP8[$2] & 126) > 1) { __ZN10ime_pinyin12MatrixSearch15debug_print_dmiEtt($this, HEAP16[$1 + ($conv * 12 | 0) + 4 >> 1] | 0, $nest_level + 1 & 65535); } _printf(616, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = HEAP8[$2] & 127, tempInt) | 0) | 0; $conv22 = HEAPU16[$1 + ($conv * 12 | 0) + 2 >> 1] | 0; _printf(440, (tempInt = STACKTOP, STACKTOP = STACKTOP + 16 | 0, HEAP32[tempInt >> 2] = HEAPU16[$1 + ($conv * 12 | 0) >> 1] | 0, HEAP32[tempInt + 8 >> 2] = $conv22, tempInt) | 0) | 0; $call24 = __ZN10ime_pinyin12SpellingTrie12get_instanceEv() | 0; $spl_id = $1 + ($conv * 12 | 0) + 6 | 0; $call25 = __ZN10ime_pinyin12SpellingTrie16get_spelling_strEt($call24, HEAP16[$spl_id >> 1] | 0) | 0; $conv27 = HEAPU16[$spl_id >> 1] | 0; _printf(4288, (tempInt = STACKTOP, STACKTOP = STACKTOP + 16 | 0, HEAP32[tempInt >> 2] = $call25, HEAP32[tempInt + 8 >> 2] = $conv27, tempInt) | 0) | 0; _printf(4064, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = (HEAPU8[$1 + ($conv * 12 | 0) + 9 | 0] | 0) >>> 1 & 255, tempInt) | 0) | 0; if (!$cmp5) { STACKTOP = sp; return; } _printf(3864, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = $conv, tempInt) | 0) | 0; STACKTOP = sp; return; } function __ZN10ime_pinyin12MatrixSearch25try_add_cand0_to_userdictEv($this) { $this = $this | 0; var $call = 0, $fixed_lmas_ = 0, $conv27 = 0, $modified_0_off026 = 0, $pos_025 = 0, $lma_id_from_024 = 0, $cmp9_not = 0, $lma_id_from_1 = 0, $modified_1_off0 = 0, $_modified_1_off0 = 0, $inc = 0, $conv = 0, $conv_lcssa = 0, $modified_0_off0_lcssa = 0, $pos_0_lcssa = 0, $lma_id_from_0_lcssa = 0; $call = __ZN10ime_pinyin12MatrixSearch17get_candidate_numEv($this) | 0; if (!((HEAP32[$this + 896 >> 2] | 0) != 0 & ($call | 0) == 1)) { return 1; } $fixed_lmas_ = $this + 356 | 0; if ((HEAP32[$fixed_lmas_ >> 2] | 0) == 0) { $lma_id_from_0_lcssa = 0; $pos_0_lcssa = 0; $modified_0_off0_lcssa = 1; $conv_lcssa = 0; } else { $lma_id_from_024 = 0; $pos_025 = 0; $modified_0_off026 = 0; $conv27 = 0; while (1) { $cmp9_not = ((HEAPU16[$this + 116 + ($conv27 + 1 << 1) >> 1] | 0) - (HEAPU16[$this + 116 + (($lma_id_from_024 & 65535) << 1) >> 1] | 0) | 0) < 9; if ($cmp9_not | $modified_0_off026 ^ 1) { $modified_1_off0 = $cmp9_not & $modified_0_off026; $lma_id_from_1 = $cmp9_not ? $lma_id_from_024 : $pos_025; } else { __ZN10ime_pinyin12MatrixSearch19add_lma_to_userdictEttf($this, $lma_id_from_024, $pos_025, 0.0) | 0; $modified_1_off0 = 0; $lma_id_from_1 = $pos_025; } $_modified_1_off0 = (HEAP8[$this + 360 + $conv27 | 0] | 0) == 0 | $modified_1_off0; $inc = $pos_025 + 1 & 65535; $conv = $inc & 65535; if ($conv >>> 0 < (HEAP32[$fixed_lmas_ >> 2] | 0) >>> 0) { $lma_id_from_024 = $lma_id_from_1; $pos_025 = $inc; $modified_0_off026 = $_modified_1_off0; $conv27 = $conv; } else { break; } } $lma_id_from_0_lcssa = $lma_id_from_1; $pos_0_lcssa = $inc; $modified_0_off0_lcssa = $_modified_1_off0 ^ 1; $conv_lcssa = $conv; } if (((HEAPU16[$this + 116 + ($conv_lcssa << 1) >> 1] | 0) - (HEAPU16[$this + 116 + (($lma_id_from_0_lcssa & 65535) << 1) >> 1] | 0) | 0) < 2 | $modified_0_off0_lcssa) { return 1; } __ZN10ime_pinyin12MatrixSearch19add_lma_to_userdictEttf($this, $lma_id_from_0_lcssa, $pos_0_lcssa, 0.0) | 0; return 1; } function __ZN10ime_pinyin12MatrixSearch16merge_fixed_lmasEj($this, $del_spl_pos) { $this = $this | 0; $del_spl_pos = $del_spl_pos | 0; var $fixed_lmas_ = 0, $spl_id_num_ = 0, $sub = 0, $spl_start_ = 0, $sub549 = 0, $pos_073 = 0, $add9 = 0, $8 = 0, $9 = 0, $mul = 0, $11 = 0, $12 = 0, $mul32 = 0, $sublma_num137 = 0, $bp_0 = 0, $sublma_num45 = 0, $conv4964 = 0, $conv54 = 0, $add56 = 0, $arrayidx88 = 0, $conv4968 = 0, $phrase_len_067 = 0, $pos47_066 = 0, $arrayidx53 = 0, $19 = 0, $arrayidx60 = 0, $call = 0, $add112 = 0, $inc115 = 0, $conv49 = 0, $phrase_len_0_lcssa = 0, $conv13571 = 0, $pos133_070 = 0, $arrayidx143 = 0, $31 = 0, $phrase_len_1 = 0, $sublma_num180 = 0, $add189 = 0, $conv17861 = 0, $pos176_060 = 0, $length197 = 0, $conv20353 = 0, $pos201_052 = 0, $del_a_sub_0_off051 = 0, $arrayidx212 = 0, $42 = 0, $43 = 0, label = 0; $fixed_lmas_ = $this + 356 | 0; if ((HEAP32[$fixed_lmas_ >> 2] | 0) == 0) { return; } $spl_id_num_ = $this + 732 | 0; $sub = (HEAP32[$spl_id_num_ >> 2] | 0) - 1 | 0; HEAP32[$spl_id_num_ >> 2] = $sub; $spl_start_ = $this + 736 | 0; L1678 : do { if ($sub >>> 0 >= $del_spl_pos >>> 0) { $sub549 = (HEAP16[$this + 736 + ($del_spl_pos << 1) >> 1] | 0) - (HEAP16[$this + 736 + ($del_spl_pos + 1 << 1) >> 1] | 0) & 65535; $pos_073 = $del_spl_pos; while (1) { $add9 = $pos_073 + 1 | 0; HEAP16[$this + 736 + ($pos_073 << 1) >> 1] = $sub549 + (HEAP16[$this + 736 + ($add9 << 1) >> 1] | 0) & 65535; if (($pos_073 | 0) == (HEAP32[$spl_id_num_ >> 2] | 0)) { break L1678; } HEAP16[$this + 816 + ($pos_073 << 1) >> 1] = HEAP16[$this + 816 + ($add9 << 1) >> 1] | 0; if ($add9 >>> 0 > (HEAP32[$spl_id_num_ >> 2] | 0) >>> 0) { break; } else { $pos_073 = $add9; } } } } while (0); $8 = $this + 400 | 0; $9 = $this + 816 | 0; $mul = HEAP32[$spl_id_num_ >> 2] << 1; _memcpy($8 | 0, $9 | 0, $mul) | 0; $11 = $this + 480 | 0; $12 = $spl_start_; $mul32 = (HEAP32[$spl_id_num_ >> 2] << 1) + 2 | 0; _memcpy($11 | 0, $12 | 0, $mul32) | 0; do { if ((HEAP32[$fixed_lmas_ >> 2] | 0) >>> 0 > 1) { label = 1342; } else { if ((HEAP32[$this + 196 >> 2] | 0) != 16777215) { label = 1342; break; } $sublma_num137 = $this + 720 | 0; $pos133_070 = 0; $conv13571 = 0; do { $arrayidx143 = $this + 640 + ($conv13571 << 1) | 0; $31 = HEAP16[$arrayidx143 >> 1] | 0; if (($31 & 65535) >>> 0 > $del_spl_pos >>> 0) { HEAP16[$arrayidx143 >> 1] = $31 - 1 & 65535; } $pos133_070 = $pos133_070 + 1 & 65535; $conv13571 = $pos133_070 & 65535; } while ($conv13571 >>> 0 <= (HEAP32[$sublma_num137 >> 2] | 0) >>> 0); $phrase_len_1 = HEAP16[$this + 724 >> 1] | 0; } } while (0); do { if ((label | 0) == 1342) { if ((HEAP32[$this + 196 >> 2] | 0) == 16777215) { $bp_0 = 1; } else { HEAP32[$this + 720 >> 2] = 0; $bp_0 = 0; } $sublma_num45 = $this + 720 | 0; $conv4964 = $bp_0 & 65535; L1698 : do { if ($conv4964 >>> 0 > (HEAP32[$fixed_lmas_ >> 2] | 0) >>> 0) { $phrase_len_0_lcssa = 0; } else { $conv54 = HEAP32[$sublma_num45 >> 2] & 65535; $add56 = $conv54 - ($bp_0 & 65535) | 0; $arrayidx88 = $this + 640 + ($conv54 << 1) | 0; $pos47_066 = $bp_0; $phrase_len_067 = 0; $conv4968 = $conv4964; while (1) { $arrayidx53 = $this + 116 + ($conv4968 << 1) | 0; $19 = HEAP16[$arrayidx53 >> 1] | 0; $arrayidx60 = $this + 640 + ($add56 + $conv4968 << 1) | 0; HEAP16[$arrayidx60 >> 1] = $19; if ((HEAPU16[$arrayidx53 >> 1] | 0) >>> 0 > $del_spl_pos >>> 0) { HEAP16[$arrayidx60 >> 1] = $19 - 1 & 65535; } if (($conv4968 | 0) == (HEAP32[$fixed_lmas_ >> 2] | 0)) { $phrase_len_0_lcssa = $phrase_len_067; break L1698; } $call = __ZN10ime_pinyin12MatrixSearch13get_lemma_strEjPtt($this, HEAP32[$this + 196 + ($conv4968 << 2) >> 2] | 0, $this + 560 + ((HEAPU16[$arrayidx88 >> 1] | 0) + ($phrase_len_067 & 65535) << 1) | 0, 40 - $phrase_len_067 & 65535) | 0; if (($call & 65535 | 0) != ((HEAPU16[$this + 116 + ($conv4968 + 1 << 1) >> 1] | 0) - (HEAPU16[$arrayidx53 >> 1] | 0) | 0)) { break; } $add112 = $call + $phrase_len_067 & 65535; $inc115 = $pos47_066 + 1 & 65535; $conv49 = $inc115 & 65535; if ($conv49 >>> 0 > (HEAP32[$fixed_lmas_ >> 2] | 0) >>> 0) { $phrase_len_0_lcssa = $add112; break L1698; } else { $pos47_066 = $inc115; $phrase_len_067 = $add112; $conv4968 = $conv49; } } ___assert_func(1184, 1245, 6944, 2984); } } while (0); if ($phrase_len_0_lcssa << 16 >> 16 == (HEAP16[$this + 116 + (HEAP32[$fixed_lmas_ >> 2] << 1) >> 1] | 0)) { HEAP16[$this + 724 >> 1] = $phrase_len_0_lcssa; HEAP32[$sublma_num45 >> 2] = (HEAP32[$fixed_lmas_ >> 2] | 0) - ($bp_0 & 65535) + (HEAP32[$sublma_num45 >> 2] | 0); $phrase_len_1 = $phrase_len_0_lcssa; break; } else { ___assert_func(1184, 1248, 6944, 2848); } } } while (0); if (($phrase_len_1 << 16 >> 16 | 0) == 0) { ___assert_func(1184, 1260, 6944, 2736); } else if (($phrase_len_1 << 16 >> 16 | 0) == 1) { HEAP32[$fixed_lmas_ >> 2] = 0; return; } else { $sublma_num180 = $this + 720 | 0; if ((HEAPU16[$this + 640 + (HEAP32[$sublma_num180 >> 2] << 1) >> 1] | 0) != ($del_spl_pos | 0)) { $add189 = $del_spl_pos + 1 | 0; $pos176_060 = 0; $conv17861 = 0; do { HEAP16[$this + 560 + ($conv17861 + $del_spl_pos << 1) >> 1] = HEAP16[$this + 560 + ($add189 + $conv17861 << 1) >> 1] | 0; $pos176_060 = $pos176_060 + 1 & 65535; $conv17861 = $pos176_060 & 65535; } while ($conv17861 >>> 0 < ((HEAPU16[$this + 640 + (HEAP32[$sublma_num180 >> 2] << 1) >> 1] | 0) - $del_spl_pos | 0) >>> 0); } $length197 = $this + 724 | 0; HEAP16[$length197 >> 1] = (HEAP16[$length197 >> 1] | 0) - 1 & 65535; if ((HEAP32[$sublma_num180 >> 2] | 0) == 0) { return; } else { $del_a_sub_0_off051 = 0; $pos201_052 = 1; $conv20353 = 1; } do { $arrayidx212 = $this + 640 + ($conv20353 - 1 << 1) | 0; $42 = HEAP16[$this + 640 + ($conv20353 << 1) >> 1] | 0; $del_a_sub_0_off051 = (HEAP16[$arrayidx212 >> 1] | 0) == $42 << 16 >> 16 | $del_a_sub_0_off051; if ($del_a_sub_0_off051) { HEAP16[$arrayidx212 >> 1] = $42; } $pos201_052 = $pos201_052 + 1 & 65535; $conv20353 = $pos201_052 & 65535; $43 = HEAP32[$sublma_num180 >> 2] | 0; } while ($conv20353 >>> 0 <= $43 >>> 0); if (!$del_a_sub_0_off051) { return; } HEAP32[$sublma_num180 >> 2] = $43 - 1; return; } } function __ZN10ime_pinyin12MatrixSearch19add_lma_to_userdictEttf($this, $lma_fr, $lma_to, $score) { $this = $this | 0; $lma_fr = $lma_fr | 0; $lma_to = $lma_to | 0; $score = +$score; var $word_str = 0, $spl_ids = 0, $user_dict_ = 0, $spl_id_fr_027 = 0, $pos_026 = 0, $conv428 = 0, $1 = 0, $2 = 0, $4 = 0, $6 = 0, $sub18 = 0, $conv20 = 0, $add_ptr = 0, $add50 = 0, $inc = 0, $spl_id_fr_0_lcssa30 = 0, $7 = 0, $retval_0 = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 40 | 0; $word_str = sp | 0; $spl_ids = sp + 24 | 0; if ((($lma_to & 65535) - ($lma_fr & 65535) | 0) < 2) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } $user_dict_ = $this + 16 | 0; if ((HEAP32[$user_dict_ >> 2] | 0) == 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } do { if (($lma_fr & 65535) < ($lma_to & 65535)) { $pos_026 = $lma_fr; $spl_id_fr_027 = 0; while (1) { $conv428 = $pos_026 & 65535; $1 = HEAP32[$this + 196 + ($conv428 << 2) >> 2] | 0; if (__ZN10ime_pinyin13is_user_lemmaEj($1) | 0) { $2 = HEAP32[$user_dict_ >> 2] | 0; $4 = HEAP32[(HEAP32[$2 >> 2] | 0) + 48 >> 2] | 0; FUNCTION_TABLE_iiiii[$4 & 31]($2, $1, 1, 1) | 0; } $6 = HEAP16[$this + 116 + ($conv428 << 1) >> 1] | 0; $sub18 = (HEAP16[$this + 116 + ($conv428 + 1 << 1) >> 1] | 0) - $6 & 65535; $conv20 = $spl_id_fr_027 & 65535; $add_ptr = $spl_ids + ($conv20 << 1) | 0; _utf16_strncpy($add_ptr, $this + 816 + (($6 & 65535) << 1) | 0, $sub18 & 65535) | 0; if ((__ZN10ime_pinyin12MatrixSearch13get_lemma_strEjPtt($this, $1, $word_str + ($conv20 << 1) | 0, 9 - $spl_id_fr_027 & 65535) | 0) << 16 >> 16 != $sub18 << 16 >> 16) { label = 1383; break; } if ((__ZN10ime_pinyin12MatrixSearch16get_lemma_splidsEjPttb($this, $1, $add_ptr, $sub18, 1) | 0) << 16 >> 16 != $sub18 << 16 >> 16) { $retval_0 = 0; label = 1393; break; } $add50 = $sub18 + $spl_id_fr_027 & 65535; $inc = $pos_026 + 1 & 65535; if (($inc & 65535) < ($lma_to & 65535)) { $pos_026 = $inc; $spl_id_fr_027 = $add50; } else { label = 1386; break; } } if ((label | 0) == 1386) { if (($add50 & 65535) < 9) { $spl_id_fr_0_lcssa30 = $add50; break; } ___assert_func(1184, 682, 6808, 944); return 0; } else if ((label | 0) == 1383) { ___assert_func(1184, 672, 6808, 1136); return 0; } else if ((label | 0) == 1393) { STACKTOP = sp; return $retval_0 | 0; } } else { $spl_id_fr_0_lcssa30 = 0; } } while (0); $7 = HEAP32[$user_dict_ >> 2] | 0; $retval_0 = (FUNCTION_TABLE_iiiiii[HEAP32[(HEAP32[$7 >> 2] | 0) + 44 >> 2] & 15]($7, $word_str | 0, $spl_ids | 0, $spl_id_fr_0_lcssa30, 1) | 0) != 0; STACKTOP = sp; return $retval_0 | 0; } function __ZN10ime_pinyin12MatrixSearch9match_dmiEjPtt($this, $step_to, $spl_ids, $spl_id_num) { $this = $this | 0; $step_to = $step_to | 0; $spl_ids = $spl_ids | 0; $spl_id_num = $spl_id_num | 0; var $matrix_ = 0, $5 = 0, $dmi_pool_ = 0, $9 = 0, $conv19 = 0, $cmp2614 = 0, $sub = 0, $10 = 0, $dmi_pos_022 = 0, $add_ptr_sum = 0, $spl_pos_016 = 0, $dmi_015 = 0, $inc = 0, $inc49 = 0, $20 = 0, $retval_0 = 0, label = 0; if ((HEAP32[$this + 72 >> 2] | 0) >>> 0 < $step_to >>> 0) { $retval_0 = -1; return $retval_0 | 0; } $matrix_ = $this + 96 | 0; if ((HEAP16[(HEAP32[$matrix_ >> 2] | 0) + ($step_to * 12 | 0) + 6 >> 1] & 32767) == 0) { $retval_0 = -1; return $retval_0 | 0; } $5 = HEAP32[$matrix_ >> 2] | 0; if ((HEAP16[$5 + ($step_to * 12 | 0) + 6 >> 1] & 32767) == 0) { $retval_0 = -1; return $retval_0 | 0; } $dmi_pool_ = $this + 88 | 0; $9 = HEAP32[$dmi_pool_ >> 2] | 0; $conv19 = $spl_id_num & 65535; $cmp2614 = $spl_id_num << 16 >> 16 == 0; $sub = $conv19 - 1 | 0; $dmi_pos_022 = 0; $10 = $5; L1767 : while (1) { $add_ptr_sum = (HEAPU16[$10 + ($step_to * 12 | 0) + 2 >> 1] | 0) + ($dmi_pos_022 & 65535) | 0; L1769 : do { if ((HEAP8[$9 + ($add_ptr_sum * 12 | 0) + 8 | 0] & 127 | 0) == ($conv19 | 0)) { if ($cmp2614) { break L1767; } $dmi_015 = $9 + ($add_ptr_sum * 12 | 0) | 0; $spl_pos_016 = 0; while (1) { if ((HEAP16[$spl_ids + ($sub - ($spl_pos_016 & 65535) << 1) >> 1] | 0) != (HEAP16[$dmi_015 + 6 >> 1] | 0)) { break L1769; } $inc = $spl_pos_016 + 1 & 65535; if (($inc & 65535) < ($spl_id_num & 65535)) { $dmi_015 = (HEAP32[$dmi_pool_ >> 2] | 0) + ((HEAPU16[$dmi_015 + 4 >> 1] | 0) * 12 | 0) | 0; $spl_pos_016 = $inc; } else { break L1767; } } } } while (0); $inc49 = $dmi_pos_022 + 1 & 65535; $20 = HEAP32[$matrix_ >> 2] | 0; if (($inc49 & 65535) < (HEAP16[$20 + ($step_to * 12 | 0) + 6 >> 1] & 32767)) { $dmi_pos_022 = $inc49; $10 = $20; } else { $retval_0 = -1; label = 1410; break; } } if ((label | 0) == 1410) { return $retval_0 | 0; } $retval_0 = (HEAP16[(HEAP32[$matrix_ >> 2] | 0) + ($step_to * 12 | 0) + 2 >> 1] | 0) + $dmi_pos_022 & 65535; return $retval_0 | 0; } function __ZN10ime_pinyin12MatrixSearch12get_fixedlenEv($this) { $this = $this | 0; var $retval_0 = 0; if ((HEAP8[$this | 0] & 1) == 0) { $retval_0 = 0; return $retval_0 | 0; } if ((HEAP32[$this + 72 >> 2] | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $retval_0 = HEAP32[$this + 896 >> 2] | 0; return $retval_0 | 0; } function __ZN10ime_pinyin12MatrixSearch8fill_dmiEPNS_13DictMatchInfoEPtttthbhh($this, $dmi, $handles, $dmi_fr, $spl_id, $node_num, $dict_level, $splid_end_split, $splstr_len, $all_full_id) { $this = $this | 0; $dmi = $dmi | 0; $handles = $handles | 0; $dmi_fr = $dmi_fr | 0; $spl_id = $spl_id | 0; $node_num = $node_num | 0; $dict_level = $dict_level | 0; $splid_end_split = $splid_end_split | 0; $splstr_len = $splstr_len | 0; $all_full_id = $all_full_id | 0; var $2 = 0, $9 = 0; HEAP16[$dmi >> 1] = HEAP16[$handles >> 1] | 0; HEAP16[$dmi + 2 >> 1] = HEAP16[$handles + 2 >> 1] | 0; HEAP16[$dmi + 4 >> 1] = $dmi_fr; HEAP16[$dmi + 6 >> 1] = $spl_id; $2 = $dmi + 8 | 0; HEAP8[$2] = HEAP8[$2] & -128 | $dict_level & 127; HEAP8[$dmi + 9 | 0] = $splstr_len << 1 | $splid_end_split & 1; $9 = $dmi + 10 | 0; HEAP8[$9] = HEAP8[$9] & -2 | $all_full_id & 1; HEAP8[$2] = HEAP8[$2] & 127; return; } function __ZN10ime_pinyin12MatrixSearch16prepare_add_charEc($this, $ch) { $this = $this | 0; $ch = $ch | 0; var $pys_decoded_len_ = 0, $dmi_pool_used_ = 0, $inc = 0, $5 = 0, $retval_0 = 0; $pys_decoded_len_ = $this + 72 | 0; if ((HEAP32[$pys_decoded_len_ >> 2] | 0) >>> 0 > 38) { $retval_0 = 0; return $retval_0 | 0; } if (!(__ZN10ime_pinyin14SpellingParser17is_valid_to_parseEc(HEAP32[$this + 20 >> 2] | 0, $ch) | 0 | $ch << 24 >> 24 == 39)) { $retval_0 = 0; return $retval_0 | 0; } $dmi_pool_used_ = $this + 92 | 0; if ((HEAPU16[$dmi_pool_used_ >> 1] | 0) > 799) { $retval_0 = 0; return $retval_0 | 0; } HEAP8[(HEAP32[$pys_decoded_len_ >> 2] | 0) + ($this + 32) | 0] = $ch; $inc = (HEAP32[$pys_decoded_len_ >> 2] | 0) + 1 | 0; HEAP32[$pys_decoded_len_ >> 2] = $inc; $5 = HEAP32[$this + 96 >> 2] | 0; HEAP16[$5 + ($inc * 12 | 0) >> 1] = HEAP16[$this + 84 >> 1] | 0; HEAP16[$5 + ($inc * 12 | 0) + 4 >> 1] = 0; HEAP16[$5 + ($inc * 12 | 0) + 2 >> 1] = HEAP16[$dmi_pool_used_ >> 1] | 0; HEAP16[$5 + ($inc * 12 | 0) + 6 >> 1] = 0; $retval_0 = 1; return $retval_0 | 0; } function __ZN10ime_pinyin12MatrixSearch11is_split_atEt($this, $pos) { $this = $this | 0; $pos = $pos | 0; return (__ZN10ime_pinyin14SpellingParser17is_valid_to_parseEc(HEAP32[$this + 20 >> 2] | 0, HEAP8[($pos & 65535) - 1 + ($this + 32) | 0] | 0) | 0) ^ 1 | 0; } function __ZN10ime_pinyin12MatrixSearch6chooseEj($this, $cand_id) { $this = $this | 0; $cand_id = $cand_id | 0; var $lpi_item26 = 0, $lpi_item26_sub = 0, $tmpcast = 0, $pys_decoded_len_ = 0, $3 = 0, $idxprom = 0, $6 = 0, $fixed_lmas_ = 0, $8 = 0, $lma_id_num_ = 0, $9 = 0, $pos_028 = 0, $inc = 0, $10 = 0, $_lcssa = 0, $arrayidx19 = 0, $13 = 0, $15 = 0, $16 = 0, $dec = 0, $19 = 0, $bf_clear = 0, $20 = 0, $bf_clear43 = 0, $22 = 0, $24 = 0, $fixed_hzs_56 = 0, $25 = 0, $26 = 0, $conv63 = 0, $28 = 0, $matrix_66 = 0, $call72 = 0, $38 = 0, $40 = 0, $fixed_lmas_101 = 0, $43 = 0, $46 = 0, $step_to_0 = 0, $retval_0 = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 8 | 0; $lpi_item26 = sp | 0; $lpi_item26_sub = $lpi_item26 | 0; $tmpcast = $lpi_item26; if ((HEAP8[$this | 0] & 1) == 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } $pys_decoded_len_ = $this + 72 | 0; if ((HEAP32[$pys_decoded_len_ >> 2] | 0) == 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } if (($cand_id | 0) == 0) { $3 = HEAP32[$this + 732 >> 2] | 0; HEAP32[$this + 896 >> 2] = $3; $idxprom = HEAPU16[$this + 736 + ($3 << 1) >> 1] | 0; $6 = HEAP32[$this + 96 >> 2] | 0; HEAP32[$6 + ($idxprom * 12 | 0) + 8 >> 2] = (HEAP32[$this + 80 >> 2] | 0) + ((HEAPU16[$6 + ($idxprom * 12 | 0) >> 1] | 0) << 4); $fixed_lmas_ = $this + 356 | 0; $8 = HEAP32[$fixed_lmas_ >> 2] | 0; $lma_id_num_ = $this + 112 | 0; $9 = HEAP32[$lma_id_num_ >> 2] | 0; if ($8 >>> 0 < $9 >>> 0) { $pos_028 = $8; while (1) { HEAP8[$this + 360 + $pos_028 | 0] = 1; $inc = $pos_028 + 1 | 0; $10 = HEAP32[$lma_id_num_ >> 2] | 0; if ($inc >>> 0 < $10 >>> 0) { $pos_028 = $inc; } else { $_lcssa = $10; break; } } } else { $_lcssa = $9; } HEAP32[$fixed_lmas_ >> 2] = $_lcssa; HEAP32[$this + 12500 >> 2] = 0; do { if ((HEAP32[$lma_id_num_ >> 2] | 0) == 1) { $arrayidx19 = $this + 196 | 0; if (!(__ZN10ime_pinyin13is_user_lemmaEj(HEAP32[$arrayidx19 >> 2] | 0) | 0)) { break; } $13 = HEAP32[$this + 16 >> 2] | 0; if (($13 | 0) == 0) { break; } $15 = HEAP32[(HEAP32[$13 >> 2] | 0) + 48 >> 2] | 0; $16 = HEAP32[$arrayidx19 >> 2] | 0; FUNCTION_TABLE_iiiii[$15 & 31]($13, $16, 1, 1) | 0; } else { if ((HEAP32[$this + 16 >> 2] | 0) == 0) { break; } __ZN10ime_pinyin12MatrixSearch25try_add_cand0_to_userdictEv($this) | 0; } } while (0); __ZN10ime_pinyin12MatrixSearch16update_dict_freqEv($this); $retval_0 = 1; STACKTOP = sp; return $retval_0 | 0; } $dec = $cand_id - 1 | 0; $19 = HEAP32[$this + 900 + ($dec << 3) >> 2] | 0; $bf_clear = $19 & 16777215; $20 = HEAP16[$this + 900 + ($dec << 3) + 4 >> 1] | 0; $bf_clear43 = $19 >>> 24 & 15; if (($bf_clear43 | 0) == 0) { ___assert_func(1184, 819, 6760, 3664); return 0; } if (__ZN10ime_pinyin13is_user_lemmaEj($bf_clear) | 0) { $22 = HEAP32[$this + 16 >> 2] | 0; if (($22 | 0) != 0) { $24 = HEAP32[(HEAP32[$22 >> 2] | 0) + 48 >> 2] | 0; FUNCTION_TABLE_iiiii[$24 & 31]($22, $bf_clear, 1, 1) | 0; } __ZN10ime_pinyin12MatrixSearch16update_dict_freqEv($this); } $fixed_hzs_56 = $this + 896 | 0; $25 = HEAP32[$fixed_hzs_56 >> 2] | 0; $26 = HEAP16[$this + 736 + ($25 << 1) >> 1] | 0; $conv63 = HEAPU16[$this + 736 + ($25 + $bf_clear43 << 1) >> 1] | 0; $28 = HEAP32[$pys_decoded_len_ >> 2] | 0; __ZN10ime_pinyin12MatrixSearch12reset_searchEjbbb($this, $conv63, 0, 0, 1) | 0; $matrix_66 = $this + 96 | 0; HEAP16[(HEAP32[$matrix_66 >> 2] | 0) + ($conv63 * 12 | 0) + 4 >> 1] = 0; HEAP16[$lpi_item26 + 4 >> 1] = $20; HEAP32[$lpi_item26_sub >> 2] = HEAP32[$lpi_item26_sub >> 2] & -16777216 | $bf_clear; $call72 = __ZN10ime_pinyin12MatrixSearch9match_dmiEjPtt($this, $conv63, $this + 816 + (HEAP32[$fixed_hzs_56 >> 2] << 1) | 0, $bf_clear43 & 65535) | 0; if ($call72 << 16 >> 16 == -1) { ___assert_func(1184, 851, 6760, 3552); return 0; } __ZN10ime_pinyin12MatrixSearch14extend_mtrx_ndEPNS_10MatrixNodeEPNS_10LmaPsbItemEjtj($this, HEAP32[(HEAP32[$matrix_66 >> 2] | 0) + (($26 & 65535) * 12 | 0) + 8 >> 2] | 0, $tmpcast, 1, $call72, $conv63) | 0; $38 = HEAP32[$matrix_66 >> 2] | 0; HEAP32[$38 + ($conv63 * 12 | 0) + 8 >> 2] = (HEAP32[$this + 80 >> 2] | 0) + ((HEAPU16[$38 + ($conv63 * 12 | 0) >> 1] | 0) << 4); $40 = HEAP32[$matrix_66 >> 2] | 0; HEAP16[$this + 84 >> 1] = (HEAP16[$40 + ($conv63 * 12 | 0) + 4 >> 1] | 0) + (HEAP16[$40 + ($conv63 * 12 | 0) >> 1] | 0) & 65535; $fixed_lmas_101 = $this + 356 | 0; $43 = HEAP32[$fixed_lmas_101 >> 2] | 0; HEAP8[$this + 360 + $43 | 0] = ($bf_clear | 0) == (HEAP32[$this + 196 + ($43 << 2) >> 2] | 0) | 0; HEAP32[$this + 196 + (HEAP32[$fixed_lmas_101 >> 2] << 2) >> 2] = $bf_clear; $46 = HEAP32[$fixed_lmas_101 >> 2] | 0; HEAP16[$this + 116 + ($46 + 1 << 1) >> 1] = (HEAPU16[$this + 116 + ($46 << 1) >> 1] | 0) + $bf_clear43 & 65535; HEAP32[$fixed_lmas_101 >> 2] = (HEAP32[$fixed_lmas_101 >> 2] | 0) + 1; HEAP32[$fixed_hzs_56 >> 2] = (HEAP32[$fixed_hzs_56 >> 2] | 0) + $bf_clear43; $step_to_0 = $conv63; while (1) { if (($step_to_0 | 0) == ($28 | 0)) { break; } if (__ZN10ime_pinyin12MatrixSearch8add_charEc($this, HEAP8[$this + 32 + $step_to_0 | 0] | 0) | 0) { $step_to_0 = $step_to_0 + 1 | 0; } else { label = 1452; break; } } if ((label | 0) == 1452) { ___assert_func(1184, 871, 6760, 3432); return 0; } do { if ((HEAP32[$fixed_hzs_56 >> 2] | 0) >>> 0 < (HEAP32[$this + 732 >> 2] | 0) >>> 0) { __ZN10ime_pinyin12MatrixSearch18prepare_candidatesEv($this); } else { HEAP32[$this + 12500 >> 2] = 0; if ((HEAP32[$this + 16 >> 2] | 0) == 0) { break; } __ZN10ime_pinyin12MatrixSearch25try_add_cand0_to_userdictEv($this) | 0; } } while (0); $retval_0 = __ZN10ime_pinyin12MatrixSearch17get_candidate_numEv($this) | 0; STACKTOP = sp; return $retval_0 | 0; } function __ZN10ime_pinyin12MatrixSearch14extend_mtrx_ndEPNS_10MatrixNodeEPNS_10LmaPsbItemEjtj($this, $mtrx_nd, $lpi_items, $lpi_num, $dmi_fr, $res_row) { $this = $this | 0; $mtrx_nd = $mtrx_nd | 0; $lpi_items = $lpi_items | 0; $lpi_num = $lpi_num | 0; $dmi_fr = $dmi_fr | 0; $res_row = $res_row | 0; var $matrix_ = 0, $lpi_num_addr_0 = 0, $3 = 0, $conv12 = 0, $add_ptr = 0, $score14 = 0, $conv50 = 0, $sub_ptr_rhs_cast = 0, $score20 = 0, $pos_039 = 0, $arrayidx15 = 0, $add = 0.0, $10 = 0, $conv28 = 0, $add_ptr_sum = 0, $add_ptr29 = 0, $replace_0_off036 = 0, $mtrx_nd_res_035 = 0, $add_ptr31 = 0, $12 = 0, $13 = 0, $mtrx_nd_res_0_lcssa45 = 0, $mtrx_nd_res_0_lcssa43 = 0, $mtrx_nd_num54 = 0, $19 = 0, $retval_0 = 0, label = 0; if (($mtrx_nd | 0) == 0) { ___assert_func(1184, 1589, 7112, 2360); return 0; } $matrix_ = $this + 96 | 0; HEAP32[(HEAP32[$matrix_ >> 2] | 0) + ($res_row * 12 | 0) + 8 >> 2] = 0; if ((HEAPU16[$this + 84 >> 1] | 0) > 194) { $retval_0 = 0; return $retval_0 | 0; } $lpi_num_addr_0 = (HEAP16[$mtrx_nd + 14 >> 1] | 0) == 0 & $lpi_num >>> 0 > 5 ? 5 : $lpi_num; $3 = HEAP32[$this + 80 >> 2] | 0; $conv12 = HEAPU16[(HEAP32[$matrix_ >> 2] | 0) + ($res_row * 12 | 0) >> 1] | 0; $add_ptr = $3 + ($conv12 << 4) | 0; L1854 : do { if (($lpi_num_addr_0 | 0) != 0) { $score14 = $mtrx_nd + 4 | 0; $conv50 = $res_row & 65535; $sub_ptr_rhs_cast = $add_ptr; $score20 = $3 + ($conv12 << 4) + 4 | 0; $pos_039 = 0; do { $arrayidx15 = $lpi_items + ($pos_039 << 3) | 0; $add = +HEAPF32[$score14 >> 2] + +(HEAPU16[$lpi_items + ($pos_039 << 3) + 4 >> 1] | 0); if (($pos_039 | 0) != 0) { if ($add + -8.0e3 > +HEAPF32[$score20 >> 2]) { break L1854; } } $10 = HEAP16[(HEAP32[$matrix_ >> 2] | 0) + ($res_row * 12 | 0) + 4 >> 1] | 0; $conv28 = $10 & 65535; $add_ptr_sum = $conv28 + $conv12 | 0; $add_ptr29 = $3 + ($add_ptr_sum << 4) | 0; L1861 : do { if (($add_ptr_sum | 0) > ($conv12 | 0)) { $mtrx_nd_res_035 = $add_ptr29; $replace_0_off036 = 0; while (1) { $add_ptr31 = $mtrx_nd_res_035 - 16 | 0; if ($add >= +HEAPF32[$mtrx_nd_res_035 - 16 + 4 >> 2]) { break; } if ($mtrx_nd_res_035 - $sub_ptr_rhs_cast >> 4 >>> 0 < 5) { $12 = $mtrx_nd_res_035; $13 = $add_ptr31; HEAP32[$12 >> 2] = HEAP32[$13 >> 2]; HEAP32[$12 + 4 >> 2] = HEAP32[$13 + 4 >> 2]; HEAP32[$12 + 8 >> 2] = HEAP32[$13 + 8 >> 2]; HEAP32[$12 + 12 >> 2] = HEAP32[$13 + 12 >> 2]; } if ($add_ptr31 >>> 0 > $add_ptr >>> 0) { $mtrx_nd_res_035 = $add_ptr31; $replace_0_off036 = 1; } else { $mtrx_nd_res_0_lcssa43 = $add_ptr31; label = 1478; break L1861; } } if ($replace_0_off036) { $mtrx_nd_res_0_lcssa43 = $mtrx_nd_res_035; label = 1478; } else { $mtrx_nd_res_0_lcssa45 = $mtrx_nd_res_035; label = 1476; } } else { $mtrx_nd_res_0_lcssa45 = $add_ptr29; label = 1476; } } while (0); do { if ((label | 0) == 1476) { label = 0; if (($10 & 65535) >= 5) { break; } if (((HEAPU16[(HEAP32[$matrix_ >> 2] | 0) + ($res_row * 12 | 0) >> 1] | 0) + $conv28 | 0) >>> 0 < 200) { $mtrx_nd_res_0_lcssa43 = $mtrx_nd_res_0_lcssa45; label = 1478; } } } while (0); do { if ((label | 0) == 1478) { label = 0; HEAP32[$mtrx_nd_res_0_lcssa43 >> 2] = HEAP32[$arrayidx15 >> 2] & 16777215; HEAPF32[$mtrx_nd_res_0_lcssa43 + 4 >> 2] = $add; HEAP32[$mtrx_nd_res_0_lcssa43 + 8 >> 2] = $mtrx_nd; HEAP16[$mtrx_nd_res_0_lcssa43 + 12 >> 1] = $dmi_fr; HEAP16[$mtrx_nd_res_0_lcssa43 + 14 >> 1] = $conv50; $mtrx_nd_num54 = (HEAP32[$matrix_ >> 2] | 0) + ($res_row * 12 | 0) + 4 | 0; $19 = HEAP16[$mtrx_nd_num54 >> 1] | 0; if (($19 & 65535) >= 5) { break; } HEAP16[$mtrx_nd_num54 >> 1] = $19 + 1 & 65535; } } while (0); $pos_039 = $pos_039 + 1 | 0; } while ($pos_039 >>> 0 < $lpi_num_addr_0 >>> 0); } } while (0); $retval_0 = HEAPU16[(HEAP32[$matrix_ >> 2] | 0) + ($res_row * 12 | 0) + 4 >> 1] | 0; return $retval_0 | 0; } function __ZN10ime_pinyin12MatrixSearch18cancel_last_choiceEv($this) { $this = $this | 0; var $fixed_hzs_ = 0, $3 = 0, $6 = 0, $8 = 0, $conv7 = 0, $storemerge = 0, $step_start_0 = 0, $13 = 0, $retval_0 = 0, label = 0; if ((HEAP8[$this | 0] & 1) == 0) { $retval_0 = 0; return $retval_0 | 0; } if ((HEAP32[$this + 72 >> 2] | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $fixed_hzs_ = $this + 896 | 0; $3 = HEAP32[$fixed_hzs_ >> 2] | 0; do { if (($3 | 0) != 0) { $6 = HEAP32[(HEAP32[$this + 96 >> 2] | 0) + ((HEAPU16[$this + 736 + ($3 << 1) >> 1] | 0) * 12 | 0) + 8 >> 2] | 0; if (($6 | 0) == 0) { ___assert_func(1184, 895, 6888, 3280); return 0; } $8 = HEAP16[(HEAP32[$6 + 8 >> 2] | 0) + 14 >> 1] | 0; $conv7 = $8 & 65535; if ($8 << 16 >> 16 == 0) { $storemerge = 0; } else { $storemerge = $3 - (HEAP8[(HEAP32[$this + 88 >> 2] | 0) + ((HEAPU16[$6 + 12 >> 1] | 0) * 12 | 0) + 8 | 0] & 127) | 0; } HEAP32[$fixed_hzs_ >> 2] = $storemerge; __ZN10ime_pinyin12MatrixSearch12reset_searchEjbbb($this, $conv7, 0, 0, 0) | 0; $step_start_0 = $conv7; while (1) { $13 = HEAP8[$this + 32 + $step_start_0 | 0] | 0; if ($13 << 24 >> 24 == 0) { label = 1496; break; } if (__ZN10ime_pinyin12MatrixSearch8add_charEc($this, $13) | 0) { $step_start_0 = $step_start_0 + 1 | 0; } else { label = 1495; break; } } if ((label | 0) == 1495) { ___assert_func(1184, 910, 6888, 3432); return 0; } else if ((label | 0) == 1496) { __ZN10ime_pinyin12MatrixSearch18prepare_candidatesEv($this); break; } } } while (0); $retval_0 = __ZN10ime_pinyin12MatrixSearch17get_candidate_numEv($this) | 0; return $retval_0 | 0; } function __ZN10ime_pinyin12MatrixSearch15add_char_qwertyEv($this) { $this = $this | 0; var $is_pre = 0, $pys_decoded_len_ = 0, $matrix_ = 0, $fixed_hzs_ = 0, $dmi_c_phrase_ = 0, $spl_parser_ = 0, $dmi_pool_ = 0, $dep_68 = 0, $spl_trie_ = 0, $dep_74 = 0, $spl_trie_194 = 0, $lpi_total_ = 0, $mtrx_nd_pool_ = 0, $arraydecay290 = 0, $dmi_pool_used_292 = 0, $dmi_c_phrase_217 = 0, $dmi_pool_used_236 = 0, $dmi_pool_used_ = 0, $dmi_c_phrase_147 = 0, $dep_ = 0, $dmi_c_phrase_116 = 0, $xi_an_enabled_ = 0, $conv117 = 0, $spl_matched_0_off0116 = 0, $longest_ext_0115 = 0, $ext_len_0112 = 0, $2 = 0, $11 = 0, $sub24 = 0, $conv25 = 0, $conv30 = 0, $call = 0, $spl_matched_0_off0_ = 0, $call54 = 0, $21 = 0, $22 = 0, $conv6096 = 0, $add72101 = 0, $frombool191 = 0, $add72107 = 0, $conv60106 = 0, $dmi_pos_0105 = 0, $longest_ext_1104 = 0, $26 = 0, $add_ptr77 = 0, $27 = 0, $dmi_0 = 0, $dep_77 = 0, $46 = 0, $bf_clear145 = 0, $49 = 0, $conv146 = 0, $d_081 = 0, $prev_ids_num_080 = 0, $dec = 0, $52 = 0, $add_ptr171 = 0, $prev_ids_num_1 = 0, $cmp14272 = 0, $dep_71 = 0, $56 = 0, $call200 = 0, $call212 = 0, $73 = 0, $79 = 0, $80 = 0, $88 = 0, $conv257 = 0, $fr_row_0 = 0, $idxprom269 = 0, $95 = 0, $96 = 0, $conv27482 = 0, $conv27491 = 0, $mtrx_nd_pos_090 = 0, $longest_ext_289 = 0, $ext_len_0_longest_ext_2 = 0, $inc = 0, $conv274 = 0, $102 = 0, $longest_ext_4 = 0, $inc305 = 0, $conv60 = 0, $105 = 0, $add72 = 0, $longest_ext_5 = 0, $spl_matched_2_off0 = 0, $dec308 = 0, $spl_matched_0_off0_lcssa = 0, $mtrx_nd_pool_used_ = 0, $retval_0 = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 8 | 0; $is_pre = sp | 0; $pys_decoded_len_ = $this + 72 | 0; $matrix_ = $this + 96 | 0; HEAP16[(HEAP32[$matrix_ >> 2] | 0) + ((HEAP32[$pys_decoded_len_ >> 2] | 0) * 12 | 0) + 4 >> 1] = 0; $fixed_hzs_ = $this + 896 | 0; $dmi_c_phrase_ = $this + 728 | 0; $spl_parser_ = $this + 20 | 0; $dmi_pool_ = $this + 88 | 0; $dep_68 = $this + 100 | 0; $spl_trie_ = $this + 4 | 0; $dep_74 = $this + 100 | 0; $spl_trie_194 = $this + 4 | 0; $lpi_total_ = $this + 12500 | 0; $mtrx_nd_pool_ = $this + 80 | 0; $arraydecay290 = $this + 900 | 0; $dmi_pool_used_292 = $this + 92 | 0; $dmi_c_phrase_217 = $this + 728 | 0; $dmi_pool_used_236 = $this + 92 | 0; $dmi_pool_used_ = $this + 92 | 0; $dmi_c_phrase_147 = $this + 728 | 0; $dep_ = $this + 100 | 0; $dmi_c_phrase_116 = $this + 728 | 0; $xi_an_enabled_ = $this + 8 | 0; $ext_len_0112 = 7; $longest_ext_0115 = 0; $spl_matched_0_off0116 = 0; $conv117 = 7; L1902 : while (1) { $2 = HEAP32[$pys_decoded_len_ >> 2] | 0; L1904 : do { if ($conv117 >>> 0 > ($2 - (HEAPU16[$this + 736 + (HEAP32[$fixed_hzs_ >> 2] << 1) >> 1] | 0) | 0) >>> 0) { $spl_matched_2_off0 = $spl_matched_0_off0116; $longest_ext_5 = $longest_ext_0115; } else { do { if (!(($ext_len_0112 & 65535) < 2 | $longest_ext_0115 << 16 >> 16 == 0)) { if ((HEAP16[(HEAP32[$matrix_ >> 2] | 0) + (($2 - $conv117 | 0) * 12 | 0) + 6 >> 1] | 0) <= -1) { break; } if ((HEAP8[$xi_an_enabled_] & 1) == 0) { $spl_matched_0_off0_lcssa = $spl_matched_0_off0116; label = 1550; break L1902; } else { $spl_matched_2_off0 = $spl_matched_0_off0116; $longest_ext_5 = $longest_ext_0115; break L1904; } } } while (0); $11 = HEAP32[$pys_decoded_len_ >> 2] | 0; $sub24 = $11 - $conv117 | 0; $conv25 = $sub24 & 65535; $conv30 = $sub24 & 65535; if ((HEAPU16[$this + 736 + (HEAP32[$fixed_hzs_ >> 2] << 1) >> 1] | 0) >>> 0 > $conv30 >>> 0) { $spl_matched_2_off0 = $spl_matched_0_off0116; $longest_ext_5 = $longest_ext_0115; break; } if ((HEAP16[(HEAP32[$matrix_ >> 2] | 0) + ($conv30 * 12 | 0) + 4 >> 1] | 0) == 0) { if ((HEAP8[$dmi_c_phrase_] & 1) == 0) { $spl_matched_2_off0 = $spl_matched_0_off0116; $longest_ext_5 = $longest_ext_0115; break; } } HEAP8[$is_pre] = 0; $call = __ZN10ime_pinyin14SpellingParser16get_splid_by_strEPKctPb(HEAP32[$spl_parser_ >> 2] | 0, $this + 32 + $conv30 | 0, $ext_len_0112, $is_pre) | 0; $spl_matched_0_off0_ = $spl_matched_0_off0116 | (HEAP8[$is_pre] & 1) != 0; if ($call << 16 >> 16 == 0) { $spl_matched_2_off0 = $spl_matched_0_off0_; $longest_ext_5 = $longest_ext_0115; break; } $call54 = __ZN10ime_pinyin12MatrixSearch11is_split_atEt($this, $11 & 65535) | 0; $21 = HEAP32[$matrix_ >> 2] | 0; $22 = HEAP16[$21 + ($conv30 * 12 | 0) + 2 >> 1] | 0; $conv6096 = $22 & 65535; $add72101 = (HEAP16[$21 + ($conv30 * 12 | 0) + 6 >> 1] & 32767) + ($22 & 65535) | 0; if (($conv6096 | 0) >= ($add72101 + 1 | 0)) { $spl_matched_2_off0 = $spl_matched_0_off0_; $longest_ext_5 = $longest_ext_0115; break; } $frombool191 = $call54 & 1; $longest_ext_1104 = $longest_ext_0115; $dmi_pos_0105 = $22; $conv60106 = $conv6096; $add72107 = $add72101; while (1) { $26 = HEAP32[$dmi_pool_ >> 2] | 0; $add_ptr77 = $26 + ($conv60106 * 12 | 0) | 0; do { if (($conv60106 | 0) == ($add72107 | 0)) { $dmi_0 = 0; label = 1518; } else { $27 = HEAP32[$fixed_hzs_ >> 2] | 0; if (($27 | 0) != 0) { if (((HEAP32[$pys_decoded_len_ >> 2] | 0) - $conv117 - ((HEAPU8[$26 + ($conv60106 * 12 | 0) + 9 | 0] | 0) >>> 1 & 255) | 0) >>> 0 < (HEAPU16[$this + 736 + ($27 << 1) >> 1] | 0) >>> 0) { $longest_ext_4 = $longest_ext_1104; break; } } if ((HEAP8[$26 + ($conv60106 * 12 | 0) + 8 | 0] | 0) >= 0) { $dmi_0 = $add_ptr77; label = 1518; break; } if ((HEAP8[$dmi_c_phrase_116] & 1) == 0) { $longest_ext_4 = $longest_ext_1104; } else { $dmi_0 = $add_ptr77; label = 1518; } } } while (0); L1924 : do { if ((label | 0) == 1518) { label = 0; do { if (($longest_ext_1104 & 65535) > ($ext_len_0112 & 65535)) { if (($dmi_0 | 0) == 0) { if ((HEAP16[(HEAP32[$matrix_ >> 2] | 0) + ($conv30 * 12 | 0) + 6 >> 1] | 0) > -1) { $longest_ext_4 = $longest_ext_1104; break L1924; } HEAP16[(HEAP32[$dep_68 >> 2] | 0) + 80 >> 1] = 0; $dep_71 = $dep_68; $cmp14272 = 1; break; } else { if (__ZNK10ime_pinyin12SpellingTrie10is_half_idEt(HEAP32[$spl_trie_ >> 2] | 0, HEAP16[$dmi_0 + 6 >> 1] | 0) | 0) { $longest_ext_4 = $longest_ext_1104; break L1924; } HEAP16[(HEAP32[$dep_74 >> 2] | 0) + 80 >> 1] = 0; $dep_77 = $dep_74; label = 1525; break; } } else { HEAP16[(HEAP32[$dep_ >> 2] | 0) + 80 >> 1] = 0; if (($dmi_0 | 0) == 0) { $dep_71 = $dep_; $cmp14272 = 1; } else { $dep_77 = $dep_; label = 1525; } } } while (0); if ((label | 0) == 1525) { label = 0; $46 = $dmi_0 + 8 | 0; $bf_clear145 = HEAP8[$46] & 127; $49 = HEAP8[$dmi_c_phrase_147] & 1; if ($49 << 24 >> 24 == 0 & ($bf_clear145 & 255) > 7) { $longest_ext_4 = $longest_ext_1104; break; } $conv146 = $bf_clear145 & 255; if ($49 << 24 >> 24 != 0 & ($bf_clear145 & 255) > 39) { $longest_ext_4 = $longest_ext_1104; break; } L1938 : do { if (($dmi_0 | 0) == 0) { $prev_ids_num_1 = $conv146; } else { $prev_ids_num_080 = $conv146; $d_081 = $dmi_0; while (1) { $dec = $prev_ids_num_080 - 1 & 65535; HEAP16[(HEAP32[$dep_77 >> 2] | 0) + (($dec & 65535) << 1) >> 1] = HEAP16[$d_081 + 6 >> 1] | 0; $52 = HEAP16[$d_081 + 4 >> 1] | 0; if ($52 << 16 >> 16 == -1) { $prev_ids_num_1 = $dec; break L1938; } $add_ptr171 = (HEAP32[$dmi_pool_ >> 2] | 0) + (($52 & 65535) * 12 | 0) | 0; if (($add_ptr171 | 0) == 0) { $prev_ids_num_1 = $dec; break; } else { $prev_ids_num_080 = $dec; $d_081 = $add_ptr171; } } } } while (0); if ($prev_ids_num_1 << 16 >> 16 != 0) { label = 1531; break L1902; } HEAP16[(HEAP32[$dep_77 >> 2] | 0) + 80 >> 1] = HEAP8[$46] & 127; $dep_71 = $dep_77; $cmp14272 = 0; } $56 = HEAP32[$dep_71 >> 2] | 0; HEAP16[$56 + (HEAPU16[$56 + 80 >> 1] << 1) >> 1] = $call; HEAP16[(HEAP32[$dep_71 >> 2] | 0) + 82 >> 1] = $ext_len_0112; HEAP8[(HEAP32[$dep_71 >> 2] | 0) + 86 | 0] = $frombool191; HEAP16[(HEAP32[$dep_71 >> 2] | 0) + 90 >> 1] = 1; HEAP16[(HEAP32[$dep_71 >> 2] | 0) + 88 >> 1] = $call; if (__ZNK10ime_pinyin12SpellingTrie10is_half_idEt(HEAP32[$spl_trie_194 >> 2] | 0, $call) | 0) { $call200 = __ZNK10ime_pinyin12SpellingTrie12half_to_fullEtPt(HEAP32[$spl_trie_194 >> 2] | 0, $call, (HEAP32[$dep_71 >> 2] | 0) + 88 | 0) | 0; HEAP16[(HEAP32[$dep_71 >> 2] | 0) + 90 >> 1] = $call200; if ((HEAP16[(HEAP32[$dep_71 >> 2] | 0) + 90 >> 1] | 0) == 0) { label = 1535; break L1902; } } $call212 = __ZN10ime_pinyin12MatrixSearch10extend_dmiEPNS_11DictExtParaEPNS_13DictMatchInfoE($this, HEAP32[$dep_71 >> 2] | 0, $dmi_0) | 0; do { if (($call212 & 65535 | 0) != 0) { if ((HEAP8[$dmi_c_phrase_217] & 1) != 0) { $73 = (HEAP32[$dmi_pool_ >> 2] | 0) + ((HEAPU16[$dmi_pool_used_ >> 1] | 0) * 12 | 0) + 8 | 0; HEAP8[$73] = HEAP8[$73] | -128; } $79 = (HEAP32[$matrix_ >> 2] | 0) + ((HEAP32[$pys_decoded_len_ >> 2] | 0) * 12 | 0) + 6 | 0; $80 = HEAP16[$79 >> 1] | 0; HEAP16[$79 >> 1] = ($80 & 65535) + $call212 & 32767 | $80 & -32768; HEAP16[$dmi_pool_used_236 >> 1] = (HEAPU16[$dmi_pool_used_236 >> 1] | 0) + $call212 & 65535; if (__ZNK10ime_pinyin12SpellingTrie10is_half_idEt(HEAP32[$spl_trie_194 >> 2] | 0, $call) | 0) { break; } $88 = (HEAP32[$matrix_ >> 2] | 0) + ((HEAP32[$pys_decoded_len_ >> 2] | 0) * 12 | 0) + 6 | 0; HEAP16[$88 >> 1] = HEAP16[$88 >> 1] | -32768; } } while (0); if ((HEAP32[$lpi_total_ >> 2] | 0) == 0) { $longest_ext_4 = $longest_ext_1104; break; } if ($cmp14272) { $fr_row_0 = $conv25; } else { $conv257 = (HEAPU8[$dmi_0 + 9 | 0] | 0) >>> 1 & 255; if ($conv30 >>> 0 < $conv257 >>> 0) { label = 1544; break L1902; } $fr_row_0 = $sub24 - $conv257 & 65535; } $idxprom269 = $fr_row_0 & 65535; $95 = HEAP32[$matrix_ >> 2] | 0; $96 = HEAP16[$95 + ($idxprom269 * 12 | 0) >> 1] | 0; $conv27482 = $96 & 65535; if (($conv27482 | 0) < ((HEAPU16[$95 + ($idxprom269 * 12 | 0) + 4 >> 1] | 0) + ($96 & 65535) | 0)) { $longest_ext_289 = $longest_ext_1104; $mtrx_nd_pos_090 = $96; $conv27491 = $conv27482; } else { $longest_ext_4 = $longest_ext_1104; break; } while (1) { __ZN10ime_pinyin12MatrixSearch14extend_mtrx_ndEPNS_10MatrixNodeEPNS_10LmaPsbItemEjtj($this, (HEAP32[$mtrx_nd_pool_ >> 2] | 0) + ($conv27491 << 4) | 0, $arraydecay290, HEAP32[$lpi_total_ >> 2] | 0, (HEAPU16[$dmi_pool_used_292 >> 1] | 0) - $call212 & 65535, HEAP32[$pys_decoded_len_ >> 2] | 0) | 0; $ext_len_0_longest_ext_2 = $longest_ext_289 << 16 >> 16 == 0 ? $ext_len_0112 : $longest_ext_289; $inc = $mtrx_nd_pos_090 + 1 & 65535; $conv274 = $inc & 65535; $102 = HEAP32[$matrix_ >> 2] | 0; if (($conv274 | 0) < ((HEAPU16[$102 + ($idxprom269 * 12 | 0) + 4 >> 1] | 0) + (HEAPU16[$102 + ($idxprom269 * 12 | 0) >> 1] | 0) | 0)) { $longest_ext_289 = $ext_len_0_longest_ext_2; $mtrx_nd_pos_090 = $inc; $conv27491 = $conv274; } else { $longest_ext_4 = $ext_len_0_longest_ext_2; break; } } } } while (0); $inc305 = $dmi_pos_0105 + 1 & 65535; $conv60 = $inc305 & 65535; $105 = HEAP32[$matrix_ >> 2] | 0; $add72 = (HEAP16[$105 + ($conv30 * 12 | 0) + 6 >> 1] & 32767) + (HEAPU16[$105 + ($conv30 * 12 | 0) + 2 >> 1] | 0) | 0; if (($conv60 | 0) < ($add72 + 1 | 0)) { $longest_ext_1104 = $longest_ext_4; $dmi_pos_0105 = $inc305; $conv60106 = $conv60; $add72107 = $add72; } else { $spl_matched_2_off0 = $spl_matched_0_off0_; $longest_ext_5 = $longest_ext_4; break; } } } } while (0); $dec308 = $ext_len_0112 - 1 & 65535; if ($dec308 << 16 >> 16 == 0) { $spl_matched_0_off0_lcssa = $spl_matched_2_off0; label = 1550; break; } else { $ext_len_0112 = $dec308; $longest_ext_0115 = $longest_ext_5; $spl_matched_0_off0116 = $spl_matched_2_off0; $conv117 = $dec308 & 65535; } } if ((label | 0) == 1535) { ___assert_func(1184, 1082, 7056, 3088); return 0; } else if ((label | 0) == 1531) { ___assert_func(1184, 1070, 7056, 3176); return 0; } else if ((label | 0) == 1550) { $mtrx_nd_pool_used_ = $this + 84 | 0; HEAP16[$mtrx_nd_pool_used_ >> 1] = (HEAP16[$mtrx_nd_pool_used_ >> 1] | 0) + (HEAP16[(HEAP32[$matrix_ >> 2] | 0) + ((HEAP32[$pys_decoded_len_ >> 2] | 0) * 12 | 0) + 4 >> 1] | 0) & 65535; if ((HEAP8[$this + 728 | 0] & 1) != 0) { $retval_0 = 1; STACKTOP = sp; return $retval_0 | 0; } $retval_0 = $spl_matched_0_off0_lcssa | (HEAP16[(HEAP32[$matrix_ >> 2] | 0) + ((HEAP32[$pys_decoded_len_ >> 2] | 0) * 12 | 0) + 4 >> 1] | 0) != 0; STACKTOP = sp; return $retval_0 | 0; } else if ((label | 0) == 1544) { ___assert_func(1184, 1106, 7056, 3056); return 0; } return 0; } function __ZN10ime_pinyin12MatrixSearch10extend_dmiEPNS_11DictExtParaEPNS_13DictMatchInfoE($this, $dep, $dmi_s) { $this = $this | 0; $dep = $dep | 0; $dmi_s = $dmi_s | 0; var $lpi_num = 0, $handles = 0, $dmi_pool_used_ = 0, $call4 = 0, $splids_extended = 0, $3 = 0, $4 = 0, $cached_0_off0 = 0, $lpi_total_ = 0, $from_h_sroa_1_0 = 0, $from_h_sroa_0_0 = 0, $arrayidx23 = 0, $arrayidx24 = 0, $cmp28 = 0, $8 = 0, $call31 = 0, $12 = 0, $15 = 0, $call55 = 0, $20 = 0, $21 = 0, $add_ptr79 = 0, $tobool83 = 0, $conv84 = 0, $add91 = 0, $tobool94 = 0, $add100 = 0, $cond107_off0 = 0, $ret_val_0 = 0, $38 = 0, $arraydecay118 = 0, $retval_0 = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16 | 0; $lpi_num = sp | 0; $handles = sp + 8 | 0; $dmi_pool_used_ = $this + 92 | 0; if ((HEAPU16[$dmi_pool_used_ >> 1] | 0) > 799) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } if ((HEAP8[$this + 728 | 0] & 1) != 0) { $retval_0 = __ZN10ime_pinyin12MatrixSearch12extend_dmi_cEPNS_11DictExtParaEPNS_13DictMatchInfoE($this, $dep, $dmi_s) | 0; STACKTOP = sp; return $retval_0 | 0; } $call4 = __ZN10ime_pinyin8LpiCache12get_instanceEv() | 0; $splids_extended = $dep + 80 | 0; $3 = HEAP16[$splids_extended >> 1] | 0; $4 = HEAP16[$dep + (($3 & 65535) << 1) >> 1] | 0; if ($3 << 16 >> 16 == 0) { $cached_0_off0 = __ZN10ime_pinyin8LpiCache9is_cachedEt($call4, $4) | 0; } else { $cached_0_off0 = 0; } $lpi_total_ = $this + 12500 | 0; HEAP32[$lpi_total_ >> 2] = 0; if ((HEAP16[$splids_extended >> 1] | 0) == 0) { $from_h_sroa_0_0 = 0; $from_h_sroa_1_0 = 0; } else { $from_h_sroa_0_0 = HEAP16[$dmi_s >> 1] | 0; $from_h_sroa_1_0 = HEAP16[$dmi_s + 2 >> 1] | 0; } HEAP32[$lpi_num >> 2] = 0; $arrayidx23 = $handles + 2 | 0; HEAP16[$arrayidx23 >> 1] = 0; $arrayidx24 = $handles | 0; HEAP16[$arrayidx24 >> 1] = 0; $cmp28 = ($dmi_s | 0) == 0; do { if ($from_h_sroa_0_0 << 16 >> 16 != 0 | $cmp28) { $8 = HEAP32[$this + 12 >> 2] | 0; $call31 = FUNCTION_TABLE_iiiiiii[HEAP32[(HEAP32[$8 >> 2] | 0) + 24 >> 2] & 15]($8, $from_h_sroa_0_0, $dep, $this + 900 | 0, 1450, $lpi_num) | 0; HEAP16[$arrayidx24 >> 1] = $call31; if ($call31 << 16 >> 16 == 0) { break; } HEAP32[$lpi_total_ >> 2] = HEAP32[$lpi_num >> 2]; } } while (0); $12 = HEAP32[$this + 16 >> 2] | 0; do { if (($12 | 0) != 0) { if (!($from_h_sroa_1_0 << 16 >> 16 != 0 | $cmp28)) { break; } $15 = HEAP32[$lpi_total_ >> 2] | 0; $call55 = FUNCTION_TABLE_iiiiiii[HEAP32[(HEAP32[$12 >> 2] | 0) + 24 >> 2] & 15]($12, $from_h_sroa_1_0, $dep, $this + 900 + ($15 << 3) | 0, 1450 - $15 | 0, $lpi_num) | 0; HEAP16[$arrayidx23 >> 1] = $call55; if ($call55 << 16 >> 16 == 0) { break; } HEAP32[$lpi_total_ >> 2] = (HEAP32[$lpi_total_ >> 2] | 0) + (HEAP32[$lpi_num >> 2] | 0); } } while (0); if ((HEAP16[$arrayidx24 >> 1] | 0) == 0) { if ((HEAP16[$arrayidx23 >> 1] | 0) == 0) { $ret_val_0 = 0; } else { label = 1571; } } else { label = 1571; } do { if ((label | 0) == 1571) { $20 = HEAP16[$dmi_pool_used_ >> 1] | 0; if (($20 & 65535) > 799) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } $21 = HEAP32[$this + 88 >> 2] | 0; $add_ptr79 = $21 + (($20 & 65535) * 12 | 0) | 0; if ($cmp28) { $tobool83 = (HEAP8[$dep + 86 | 0] & 1) != 0; $conv84 = HEAP16[$dep + 82 >> 1] & 255; __ZN10ime_pinyin12MatrixSearch8fill_dmiEPNS_13DictMatchInfoEPtttthbhh(0, $add_ptr79, $arrayidx24, -1, $4, 0, 1, $tobool83, $conv84, (__ZNK10ime_pinyin12SpellingTrie10is_half_idEt(HEAP32[$this + 4 >> 2] | 0, $4) | 0) & 1 ^ 1); $ret_val_0 = 1; break; } $add91 = (HEAP8[$dmi_s + 8 | 0] & 127) + 1 & 255; $tobool94 = (HEAP8[$dep + 86 | 0] & 1) != 0; $add100 = (HEAP16[$dep + 82 >> 1] & 255) + ((HEAPU8[$dmi_s + 9 | 0] | 0) >>> 1) & 255; if (__ZNK10ime_pinyin12SpellingTrie10is_half_idEt(HEAP32[$this + 4 >> 2] | 0, $4) | 0) { $cond107_off0 = 0; } else { $cond107_off0 = HEAP8[$dmi_s + 10 | 0] & 1; } __ZN10ime_pinyin12MatrixSearch8fill_dmiEPNS_13DictMatchInfoEPtttthbhh(0, $add_ptr79, $arrayidx24, (($dmi_s - $21 | 0) / 12 | 0) & 65535, $4, 0, $add91, $tobool94, $add100, $cond107_off0); $ret_val_0 = 1; } } while (0); if ($cached_0_off0) { if (!(__ZNK10ime_pinyin12SpellingTrie10is_half_idEt(HEAP32[$this + 4 >> 2] | 0, $4) | 0)) { ___assert_func(1184, 1545, 7376, 2520); return 0; } HEAP32[$lpi_total_ >> 2] = __ZN10ime_pinyin8LpiCache9get_cacheEtPNS_10LmaPsbItemEj($call4, $4, $this + 900 | 0, 1450) | 0; $retval_0 = $ret_val_0; STACKTOP = sp; return $retval_0 | 0; } $38 = HEAP32[$lpi_total_ >> 2] | 0; if (($38 | 0) == 0) { $retval_0 = $ret_val_0; STACKTOP = sp; return $retval_0 | 0; } $arraydecay118 = $this + 900 | 0; __ZN10ime_pinyin12MatrixSearch20QsortLmaPsbItemByPsbEPNS_10LmaPsbItemEj(0, $arraydecay118, $38); if (!$cmp28) { $retval_0 = $ret_val_0; STACKTOP = sp; return $retval_0 | 0; } if (!(__ZNK10ime_pinyin12SpellingTrie10is_half_idEt(HEAP32[$this + 4 >> 2] | 0, $4) | 0)) { $retval_0 = $ret_val_0; STACKTOP = sp; return $retval_0 | 0; } HEAP32[$lpi_total_ >> 2] = __ZN10ime_pinyin8LpiCache9put_cacheEtPNS_10LmaPsbItemEj($call4, $4, $arraydecay118, HEAP32[$lpi_total_ >> 2] | 0) | 0; $retval_0 = $ret_val_0; STACKTOP = sp; return $retval_0 | 0; } function __ZN10ime_pinyin7compareEPKvS1_($a, $b) { $a = $a | 0; $b = $b | 0; return (HEAP32[$a >> 2] | 0) - (HEAP32[$b >> 2] | 0) | 0; } function __ZN10ime_pinyin11comp_doubleEPKvS1_($p1, $p2) { $p1 = $p1 | 0; $p2 = $p2 | 0; var $1 = 0.0, $3 = 0.0, $retval_0 = 0; $1 = +HEAPF64[$p1 >> 3]; $3 = +HEAPF64[$p2 >> 3]; if ($1 < $3) { $retval_0 = -1; return $retval_0 | 0; } $retval_0 = $1 > $3 | 0; return $retval_0 | 0; } function __ZN10ime_pinyin12MatrixSearch9get_pystrEPj($this, $decoded_len) { $this = $this | 0; $decoded_len = $decoded_len | 0; var $retval_0 = 0; if ((HEAP8[$this | 0] & 1) == 0 | ($decoded_len | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } HEAP32[$decoded_len >> 2] = HEAP32[$this + 72 >> 2]; $retval_0 = $this + 32 | 0; return $retval_0 | 0; } function __ZN10ime_pinyin12MatrixSearch20QsortLmaPsbItemByPsbEPNS_10LmaPsbItemEj($this, $lma_buf, $num) { $this = $this | 0; $lma_buf = $lma_buf | 0; $num = $num | 0; var $0$0 = 0, $call = 0, $4 = 0, $pos_023 = 0, $6$0 = 0, $call3 = 0, $10 = 0, $11 = 0, $mul = 0, $index_021 = 0, $15 = 0, $16 = 0, $17$1 = 0; $0$0 = _llvm_umul_with_overflow_i32($num | 0, 4) | 0; $call = __Znaj(tempRet0 ? -1 : $0$0) | 0; $4 = $call; if (($num | 0) != 0) { $pos_023 = 0; do { HEAP32[$4 + ($pos_023 << 2) >> 2] = (HEAPU16[$lma_buf + ($pos_023 << 3) + 4 >> 1] | 0) << 15 | $pos_023; $pos_023 = $pos_023 + 1 | 0; } while ($pos_023 >>> 0 < $num >>> 0); } _qsort2($call | 0, $num | 0, 4, 36); $6$0 = _llvm_umul_with_overflow_i32($num | 0, 8) | 0; $call3 = __Znaj(tempRet0 ? -1 : $6$0) | 0; $10 = $call3; $11 = $lma_buf | 0; $mul = $num << 3; _memcpy($call3 | 0, $11 | 0, $mul) | 0; if (($num | 0) != 0) { $index_021 = 0; do { $15 = $10 + ((HEAP32[$4 + ($index_021 << 2) >> 2] & 32767) << 3) | 0; $16 = $lma_buf + ($index_021 << 3) | 0; $17$1 = HEAP32[$15 + 4 >> 2] | 0; HEAP32[$16 >> 2] = HEAP32[$15 >> 2]; HEAP32[$16 + 4 >> 2] = $17$1; $index_021 = $index_021 + 1 | 0; } while ($index_021 >>> 0 < $num >>> 0); } if (($call | 0) != 0) { __ZdaPv($call); } if (($call3 | 0) == 0) { return; } __ZdaPv($call3); return; } function __ZN10ime_pinyin12MatrixSearch22QsortLmaPsbItemByHanziEPNS_10LmaPsbItemEj($this, $lma_buf, $num) { $this = $this | 0; $lma_buf = $lma_buf | 0; $num = $num | 0; var $0$0 = 0, $call = 0, $4 = 0, $pos_023 = 0, $6$0 = 0, $call3 = 0, $10 = 0, $11 = 0, $mul = 0, $index_021 = 0, $15 = 0, $16 = 0, $17$1 = 0; $0$0 = _llvm_umul_with_overflow_i32($num | 0, 4) | 0; $call = __Znaj(tempRet0 ? -1 : $0$0) | 0; $4 = $call; if (($num | 0) != 0) { $pos_023 = 0; do { HEAP32[$4 + ($pos_023 << 2) >> 2] = ((HEAPU16[$lma_buf + ($pos_023 << 3) + 6 >> 1] | 0) << 15) + $pos_023; $pos_023 = $pos_023 + 1 | 0; } while ($pos_023 >>> 0 < $num >>> 0); } _qsort2($call | 0, $num | 0, 4, 36); $6$0 = _llvm_umul_with_overflow_i32($num | 0, 8) | 0; $call3 = __Znaj(tempRet0 ? -1 : $6$0) | 0; $10 = $call3; $11 = $lma_buf | 0; $mul = $num << 3; _memcpy($call3 | 0, $11 | 0, $mul) | 0; if (($num | 0) != 0) { $index_021 = 0; do { $15 = $10 + ((HEAP32[$4 + ($index_021 << 2) >> 2] & 32767) << 3) | 0; $16 = $lma_buf + ($index_021 << 3) | 0; $17$1 = HEAP32[$15 + 4 >> 2] | 0; HEAP32[$16 >> 2] = HEAP32[$15 >> 2]; HEAP32[$16 + 4 >> 2] = $17$1; $index_021 = $index_021 + 1 | 0; } while ($index_021 >>> 0 < $num >>> 0); } if (($call | 0) != 0) { __ZdaPv($call); } if (($call3 | 0) == 0) { return; } __ZdaPv($call3); return; } function __ZN10ime_pinyin12MatrixSearch13get_spl_startERPKt($this, $spl_start) { $this = $this | 0; $spl_start = $spl_start | 0; __ZN10ime_pinyin12MatrixSearch16get_spl_start_idEv($this); HEAP32[$spl_start >> 2] = $this + 736; return HEAP32[$this + 732 >> 2] | 0; } function __ZN10ime_pinyin12MatrixSearch13inner_predictEPKttPA8_tj($this, $fixed_buf, $fixed_len, $predict_buf, $buf_len) { $this = $this | 0; $fixed_buf = $fixed_buf | 0; $fixed_len = $fixed_len | 0; $predict_buf = $predict_buf | 0; $buf_len = $buf_len | 0; var $npre_items_ = 0, $npre_items_len_ = 0, $conv = 0, $cmp4 = 0, $dict_trie_24 = 0, $user_dict_ = 0, $dict_trie_ = 0, $dict_trie_17 = 0, $len_051 = 0, $res_total_050 = 0, $sub = 0, $nlen_0 = 0, $nearest_n_word_0_off0 = 0, $res_total_1 = 0, $sub23 = 0, $8 = 0, $add_ptr28 = 0, $conv29 = 0, $call32 = 0, $12 = 0, $add_ptr44_sum = 0, $res_this_0 = 0, $add51 = 0, $dec = 0, $res_total_0_lcssa = 0, $call55 = 0, $buf_len_call55 = 0, $i_048 = 0; $npre_items_ = $this + 104 | 0; $npre_items_len_ = $this + 108 | 0; _memset(HEAP32[$npre_items_ >> 2] | 0, 0, (HEAP32[$npre_items_len_ >> 2] | 0) * 20 | 0 | 0); $conv = $fixed_len & 65535; if ($fixed_len << 16 >> 16 == 0) { $res_total_0_lcssa = 0; } else { $cmp4 = ($fixed_len & 65535) > 1; $dict_trie_24 = $this + 12 | 0; $user_dict_ = $this + 16 | 0; $dict_trie_ = $this + 12 | 0; $dict_trie_17 = $this + 12 | 0; $res_total_050 = 0; $len_051 = $conv; while (1) { $sub = (HEAP32[$npre_items_len_ >> 2] | 0) - $res_total_050 | 0; if ($cmp4 & ($len_051 | 0) == 1 & ($res_total_050 | 0) == 0) { $nlen_0 = 2; while (1) { if ($nlen_0 >>> 0 > $conv >>> 0) { $nearest_n_word_0_off0 = 0; break; } if ((__ZN10ime_pinyin8DictTrie12get_lemma_idEPKtt(HEAP32[$dict_trie_ >> 2] | 0, $fixed_buf + ($conv - $nlen_0 << 1) | 0, $nlen_0 & 65535) | 0) == 0) { $nlen_0 = $nlen_0 + 1 | 0; } else { $nearest_n_word_0_off0 = $len_051; break; } } $res_total_1 = (__ZN10ime_pinyin8DictTrie16predict_top_lmasEjPNS_12NPredictItemEjj(HEAP32[$dict_trie_17 >> 2] | 0, $nearest_n_word_0_off0, (HEAP32[$npre_items_ >> 2] | 0) + ($res_total_050 * 20 | 0) | 0, $sub, $res_total_050) | 0) + $res_total_050 | 0; } else { $res_total_1 = $res_total_050; } $sub23 = (HEAP32[$npre_items_len_ >> 2] | 0) - $res_total_1 | 0; $8 = HEAP32[$dict_trie_24 >> 2] | 0; $add_ptr28 = $fixed_buf + ($conv - $len_051 << 1) | 0; $conv29 = $len_051 & 65535; $call32 = FUNCTION_TABLE_iiiiiii[HEAP32[(HEAP32[$8 >> 2] | 0) + 40 >> 2] & 15]($8, $add_ptr28, $conv29, (HEAP32[$npre_items_ >> 2] | 0) + ($res_total_1 * 20 | 0) | 0, $sub23, $res_total_1) | 0; $12 = HEAP32[$user_dict_ >> 2] | 0; if (($12 | 0) == 0) { $res_this_0 = $call32; } else { $add_ptr44_sum = $call32 + $res_total_1 | 0; $res_this_0 = (FUNCTION_TABLE_iiiiiii[HEAP32[(HEAP32[$12 >> 2] | 0) + 40 >> 2] & 15]($12, $add_ptr28, $conv29, (HEAP32[$npre_items_ >> 2] | 0) + ($add_ptr44_sum * 20 | 0) | 0, $sub23 - $call32 | 0, $add_ptr44_sum) | 0) + $call32 | 0; } $add51 = $res_this_0 + $res_total_1 | 0; $dec = $len_051 - 1 | 0; if (($dec | 0) == 0) { $res_total_0_lcssa = $add51; break; } else { $res_total_050 = $add51; $len_051 = $dec; } } } $call55 = __ZN10ime_pinyin21remove_duplicate_npreEPNS_12NPredictItemEj(HEAP32[$npre_items_ >> 2] | 0, $res_total_0_lcssa) | 0; __ZN10ime_pinyin7myqsortEPvjjPFiPKvS2_E(HEAP32[$npre_items_ >> 2] | 0, $call55, 20, 4); $buf_len_call55 = $call55 >>> 0 > $buf_len >>> 0 ? $buf_len : $call55; if (($buf_len_call55 | 0) == 0) { return $buf_len_call55 | 0; } else { $i_048 = 0; } do { _utf16_strncpy($predict_buf + ($i_048 << 4) | 0, (HEAP32[$npre_items_ >> 2] | 0) + ($i_048 * 20 | 0) + 4 | 0, 7) | 0; HEAP16[$predict_buf + ($i_048 << 4) + 14 >> 1] = 0; $i_048 = $i_048 + 1 | 0; } while ($i_048 >>> 0 < $buf_len_call55 >>> 0); return $buf_len_call55 | 0; } function __ZN10ime_pinyin12MatrixSearch12get_predictsEPKtPA8_tj($this, $fixed_buf, $predict_buf, $buf_len) { $this = $this | 0; $fixed_buf = $fixed_buf | 0; $predict_buf = $predict_buf | 0; $buf_len = $buf_len | 0; var $call = 0, $retval_0 = 0; $call = _utf16_strlen($fixed_buf) | 0; if (($call | 0) == 0 | $call >>> 0 > 7 | ($buf_len | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $retval_0 = __ZN10ime_pinyin12MatrixSearch13inner_predictEPKttPA8_tj($this, $fixed_buf, $call & 65535, $predict_buf, $buf_len) | 0; return $retval_0 | 0; } function __ZN10ime_pinyin15qsearch_nearestEPddii($code_book, $freq, $start, $end) { $code_book = $code_book | 0; $freq = +$freq; $start = $start | 0; $end = $end | 0; var $end_tr23 = 0, $start_tr22 = 0, $call = 0.0, $div = 0, $cmp11 = 0, $start_tr_div = 0, $div_end_tr = 0, $retval_0 = 0, label = 0; if (($start | 0) == ($end | 0)) { $retval_0 = $start; return $retval_0 | 0; } else { $start_tr22 = $start; $end_tr23 = $end; } while (1) { if (($start_tr22 + 1 | 0) == ($end_tr23 | 0)) { break; } $div = ($end_tr23 + $start_tr22 | 0) / 2 | 0; $cmp11 = +HEAPF64[$code_book + ($div << 3) >> 3] > $freq; $start_tr_div = $cmp11 ? $start_tr22 : $div; $div_end_tr = $cmp11 ? $div : $end_tr23; if (($start_tr_div | 0) == ($div_end_tr | 0)) { $retval_0 = $start_tr_div; label = 1654; break; } else { $start_tr22 = $start_tr_div; $end_tr23 = $div_end_tr; } } if ((label | 0) == 1654) { return $retval_0 | 0; } $call = +__ZN10ime_pinyin8distanceEdd($freq, +HEAPF64[$code_book + ($end_tr23 << 3) >> 3]); $retval_0 = $call > +__ZN10ime_pinyin8distanceEdd($freq, +HEAPF64[$code_book + ($start_tr22 << 3) >> 3]) ? $start_tr22 : $end_tr23; return $retval_0 | 0; } function __ZN10ime_pinyin8distanceEdd($freq, $code) { $freq = +$freq; $code = +$code; var $call = 0.0; $call = +Math_log(+$freq); return +(+Math_abs(+($call - +Math_log(+$code))) * $freq); } function __ZN10ime_pinyin15update_code_idxEPdjS0_Ph($freqs, $num, $code_book, $code_idx) { $freqs = $freqs | 0; $num = $num | 0; $code_book = $code_book | 0; $code_idx = $code_idx | 0; var $changed_010 = 0, $pos_09 = 0, $conv = 0, $arrayidx2 = 0, $changed_0_inc = 0, $inc6 = 0, $changed_0_lcssa = 0; if (($num | 0) == 0) { $changed_0_lcssa = 0; return $changed_0_lcssa | 0; } else { $pos_09 = 0; $changed_010 = 0; } while (1) { $conv = (__ZN10ime_pinyin15qsearch_nearestEPddii($code_book, +HEAPF64[$freqs + ($pos_09 << 3) >> 3], 0, 255) | 0) & 255; $arrayidx2 = $code_idx + $pos_09 | 0; $changed_0_inc = ((HEAP8[$arrayidx2] | 0) != $conv << 24 >> 24) + $changed_010 | 0; HEAP8[$arrayidx2] = $conv; $inc6 = $pos_09 + 1 | 0; if ($inc6 >>> 0 < $num >>> 0) { $pos_09 = $inc6; $changed_010 = $changed_0_inc; } else { $changed_0_lcssa = $changed_0_inc; break; } } return $changed_0_lcssa | 0; } function __ZN10ime_pinyin13iterate_codesEPdjS0_Ph($freqs, $num, $code_book, $code_idx) { $freqs = $freqs | 0; $num = $num | 0; $code_book = $code_book | 0; $code_idx = $code_idx | 0; var $delta_last_0 = 0.0, $iter_num_0 = 0, $call1 = 0.0, $call3 = 0.0, label = 0; $iter_num_0 = 1; $delta_last_0 = 0.0; while (1) { __ZN10ime_pinyin15update_code_idxEPdjS0_Ph($freqs, $num, $code_book, $code_idx) | 0; $call1 = +__ZN10ime_pinyin18recalculate_kernelEPdjS0_Ph($freqs, $num, $code_book, $code_idx); if ($iter_num_0 >>> 0 > 1) { if ($call1 == 0.0) { label = 1668; break; } $call3 = +Math_abs(+($delta_last_0 - $call1)); if ($call3 / +Math_abs(+$call1) < 1.0e-9) { label = 1667; break; } } $iter_num_0 = $iter_num_0 + 1 | 0; $delta_last_0 = $call1; } if ((label | 0) == 1668) { return; } else if ((label | 0) == 1667) { return; } } function __ZN10ime_pinyin5NGramC2Ev($this) { $this = $this | 0; HEAP8[$this | 0] = 0; HEAP32[$this + 4 >> 2] = 0; _memset($this + 12 | 0, 0, 16); return; } function __ZN10ime_pinyin12MatrixSearch8get_lpisEPKtjPNS_10LmaPsbItemEjS2_b($this, $splid_str, $splid_str_len, $lma_buf, $max_lma_buf, $pfullsent, $sort_by_psb) { $this = $this | 0; $splid_str = $splid_str | 0; $splid_str_len = $splid_str_len | 0; $lma_buf = $lma_buf | 0; $max_lma_buf = $max_lma_buf | 0; $pfullsent = $pfullsent | 0; $sort_by_psb = $sort_by_psb | 0; var $hanzis = 0, $0 = 0, $conv = 0, $call = 0, $3 = 0, $num2_0 = 0, $add = 0, $arraydecay83 = 0, $add_ptr15 = 0, $6 = 0, $div = 0, $div_add = 0, $pos_0105 = 0, $arrayidx22 = 0, $8 = 0, $9 = 0, $10$1 = 0, $cmp61 = 0, $pos26_0102 = 0, $remain_num_0101 = 0, $sub34 = 0, $18 = 0, $19 = 0, $20$1 = 0, $23 = 0, $24 = 0, $25$1 = 0, $remain_num_1 = 0, $inc75 = 0, $pos77_0115 = 0, $cmp149 = 0, $arrayidx151 = 0, $cmp106 = 0, $arrayidx108 = 0, $pos91_0111 = 0, $remain_num90_0110 = 0, $hanzi98 = 0, $29 = 0, $sub100 = 0, $sub133 = 0, $39 = 0, $40 = 0, $41$1 = 0, $47 = 0, $48 = 0, $49$1 = 0, $remain_num90_1 = 0, $inc167 = 0, $num_1 = 0, $retval_0 = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 8 | 0; $hanzis = sp | 0; if ($splid_str_len >>> 0 > 8) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } $0 = HEAP32[$this + 12 >> 2] | 0; $conv = $splid_str_len & 65535; $call = FUNCTION_TABLE_iiiiii[HEAP32[(HEAP32[$0 >> 2] | 0) + 28 >> 2] & 15]($0, $splid_str, $conv, $lma_buf, $max_lma_buf) | 0; $3 = HEAP32[$this + 16 >> 2] | 0; if (($3 | 0) == 0) { $num2_0 = 0; } else { $num2_0 = FUNCTION_TABLE_iiiiii[HEAP32[(HEAP32[$3 >> 2] | 0) + 28 >> 2] & 15]($3, $splid_str, $conv, $lma_buf + ($call << 3) | 0, $max_lma_buf - $call | 0) | 0; } $add = $num2_0 + $call | 0; if (($add | 0) == 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } L2134 : do { if ($splid_str_len >>> 0 > 1) { $add_ptr15 = $lma_buf + ($add << 3) | 0; $6 = $add_ptr15; $div = ($max_lma_buf - $add << 3 >>> 0) / 28 | 0; if ($div >>> 0 <= $add >>> 0) { ___assert_func(1184, 1760, 6648, 2304); return 0; } $div_add = $add >>> 0 > $div >>> 0 ? $div : $add; if (($div_add | 0) == 0) { __ZN10ime_pinyin7myqsortEPvjjPFiPKvS2_E($add_ptr15 | 0, $div_add, 28, 26); $num_1 = 0; break; } else { $pos_0105 = 0; } do { $arrayidx22 = $lma_buf + ($pos_0105 << 3) | 0; $8 = $arrayidx22; $9 = $6 + ($pos_0105 * 28 | 0) | 0; $10$1 = HEAP32[$8 + 4 >> 2] | 0; HEAP32[$9 >> 2] = HEAP32[$8 >> 2]; HEAP32[$9 + 4 >> 2] = $10$1; __ZN10ime_pinyin12MatrixSearch13get_lemma_strEjPtt($this, HEAP32[$arrayidx22 >> 2] & 16777215, $6 + ($pos_0105 * 28 | 0) + 8 | 0, 9) | 0; $pos_0105 = $pos_0105 + 1 | 0; } while ($pos_0105 >>> 0 < $div_add >>> 0); __ZN10ime_pinyin7myqsortEPvjjPFiPKvS2_E($add_ptr15 | 0, $div_add, 28, 26); if (($div_add | 0) == 0) { $num_1 = 0; break; } $cmp61 = ($pfullsent | 0) == 0; $remain_num_0101 = 0; $pos26_0102 = 0; L2145 : while (1) { do { if (($pos26_0102 | 0) == 0) { label = 1691; } else { $sub34 = $pos26_0102 - 1 | 0; if ((_utf16_strcmp($6 + ($pos26_0102 * 28 | 0) + 8 | 0, $6 + ($sub34 * 28 | 0) + 8 | 0) | 0) != 0) { label = 1691; break; } if ((HEAPU16[$6 + ($pos26_0102 * 28 | 0) + 4 >> 1] | 0) >= (HEAPU16[$6 + ($sub34 * 28 | 0) + 4 >> 1] | 0)) { $remain_num_1 = $remain_num_0101; break; } if (($remain_num_0101 | 0) == 0) { break L2145; } $18 = $6 + ($pos26_0102 * 28 | 0) | 0; $19 = $lma_buf + ($remain_num_0101 - 1 << 3) | 0; $20$1 = HEAP32[$18 + 4 >> 2] | 0; HEAP32[$19 >> 2] = HEAP32[$18 >> 2]; HEAP32[$19 + 4 >> 2] = $20$1; $remain_num_1 = $remain_num_0101; } } while (0); do { if ((label | 0) == 1691) { label = 0; if (!$cmp61) { if ((_utf16_strcmp($6 + ($pos26_0102 * 28 | 0) + 8 | 0, $pfullsent) | 0) == 0) { $remain_num_1 = $remain_num_0101; break; } } $23 = $6 + ($pos26_0102 * 28 | 0) | 0; $24 = $lma_buf + ($remain_num_0101 << 3) | 0; $25$1 = HEAP32[$23 + 4 >> 2] | 0; HEAP32[$24 >> 2] = HEAP32[$23 >> 2]; HEAP32[$24 + 4 >> 2] = $25$1; $remain_num_1 = $remain_num_0101 + 1 | 0; } } while (0); $inc75 = $pos26_0102 + 1 | 0; if ($inc75 >>> 0 < $div_add >>> 0) { $remain_num_0101 = $remain_num_1; $pos26_0102 = $inc75; } else { $num_1 = $remain_num_1; break L2134; } } ___assert_func(1184, 1775, 6648, 2248); return 0; } else { if (($add | 0) == 0) { __ZN10ime_pinyin12MatrixSearch22QsortLmaPsbItemByHanziEPNS_10LmaPsbItemEj(0, $lma_buf, $add); $num_1 = 0; break; } $arraydecay83 = $hanzis | 0; $pos77_0115 = 0; do { __ZN10ime_pinyin12MatrixSearch13get_lemma_strEjPtt($this, HEAP32[$lma_buf + ($pos77_0115 << 3) >> 2] & 16777215, $arraydecay83, 2) | 0; HEAP16[$lma_buf + ($pos77_0115 << 3) + 6 >> 1] = HEAP16[$arraydecay83 >> 1] | 0; $pos77_0115 = $pos77_0115 + 1 | 0; } while ($pos77_0115 >>> 0 < $add >>> 0); __ZN10ime_pinyin12MatrixSearch22QsortLmaPsbItemByHanziEPNS_10LmaPsbItemEj(0, $lma_buf, $add); if (($add | 0) == 0) { $num_1 = 0; break; } $cmp149 = ($pfullsent | 0) == 0; $arrayidx151 = $pfullsent + 2 | 0; $cmp106 = ($pfullsent | 0) == 0; $arrayidx108 = $pfullsent + 2 | 0; $remain_num90_0110 = 0; $pos91_0111 = 0; L2167 : while (1) { L2169 : do { if (($pos91_0111 | 0) == 0) { label = 1709; } else { $hanzi98 = $lma_buf + ($pos91_0111 << 3) + 6 | 0; $29 = HEAP16[$hanzi98 >> 1] | 0; $sub100 = $pos91_0111 - 1 | 0; if ($29 << 16 >> 16 != (HEAP16[$lma_buf + ($sub100 << 3) + 6 >> 1] | 0)) { label = 1709; break; } do { if (!$cmp106) { if ((HEAP16[$arrayidx108 >> 1] | 0) != 0) { break; } if ($29 << 16 >> 16 == (HEAP16[$pfullsent >> 1] | 0)) { $remain_num90_1 = $remain_num90_0110; break L2169; } } } while (0); if ((HEAPU16[$lma_buf + ($pos91_0111 << 3) + 4 >> 1] | 0) >= (HEAPU16[$lma_buf + ($sub100 << 3) + 4 >> 1] | 0)) { $remain_num90_1 = $remain_num90_0110; break; } if (($remain_num90_0110 | 0) == 0) { label = 1705; break L2167; } $sub133 = $remain_num90_0110 - 1 | 0; if ((HEAP16[$lma_buf + ($sub133 << 3) + 6 >> 1] | 0) != (HEAP16[$hanzi98 >> 1] | 0)) { label = 1707; break L2167; } $39 = $lma_buf + ($pos91_0111 << 3) | 0; $40 = $lma_buf + ($sub133 << 3) | 0; $41$1 = HEAP32[$39 + 4 >> 2] | 0; HEAP32[$40 >> 2] = HEAP32[$39 >> 2]; HEAP32[$40 + 4 >> 2] = $41$1; $remain_num90_1 = $remain_num90_0110; } } while (0); L2179 : do { if ((label | 0) == 1709) { label = 0; do { if (!$cmp149) { if ((HEAP16[$arrayidx151 >> 1] | 0) != 0) { break; } if ((HEAP16[$lma_buf + ($pos91_0111 << 3) + 6 >> 1] | 0) == (HEAP16[$pfullsent >> 1] | 0)) { $remain_num90_1 = $remain_num90_0110; break L2179; } } } while (0); $47 = $lma_buf + ($pos91_0111 << 3) | 0; $48 = $lma_buf + ($remain_num90_0110 << 3) | 0; $49$1 = HEAP32[$47 + 4 >> 2] | 0; HEAP32[$48 >> 2] = HEAP32[$47 >> 2]; HEAP32[$48 + 4 >> 2] = $49$1; $remain_num90_1 = $remain_num90_0110 + 1 | 0; } } while (0); $inc167 = $pos91_0111 + 1 | 0; if ($inc167 >>> 0 < $add >>> 0) { $remain_num90_0110 = $remain_num90_1; $pos91_0111 = $inc167; } else { $num_1 = $remain_num90_1; break L2134; } } if ((label | 0) == 1705) { ___assert_func(1184, 1811, 6648, 2248); return 0; } else if ((label | 0) == 1707) { ___assert_func(1184, 1812, 6648, 2144); return 0; } } } while (0); if (!$sort_by_psb) { $retval_0 = $num_1; STACKTOP = sp; return $retval_0 | 0; } __ZN10ime_pinyin12MatrixSearch20QsortLmaPsbItemByPsbEPNS_10LmaPsbItemEj(0, $lma_buf, $num_1); $retval_0 = $num_1; STACKTOP = sp; return $retval_0 | 0; } function __ZN10ime_pinyin12MatrixSearch12extend_dmi_cEPNS_11DictExtParaEPNS_13DictMatchInfoE($this, $dep, $dmi_s) { $this = $this | 0; $dep = $dep | 0; $dmi_s = $dmi_s | 0; var $lpi_total_ = 0, $2 = 0, $conv = 0, $length = 0, $4 = 0, $6 = 0, $add_ptr = 0, $arraydecay = 0, $tobool13 = 0, $conv14 = 0, $add = 0, $tobool22 = 0, $add28 = 0, $cond38_off0 = 0, $25 = 0, $retval_0 = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 8 | 0; $lpi_total_ = $this + 12500 | 0; HEAP32[$lpi_total_ >> 2] = 0; if ((HEAP8[$this + 728 | 0] & 1) == 0) { ___assert_func(1184, 1556, 7296, 2440); return 0; } $2 = HEAP16[$dep + 80 >> 1] | 0; $conv = $2 & 65535; $length = $this + 724 | 0; if (($2 & 65535) >= (HEAPU16[$length >> 1] | 0)) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } $4 = HEAP16[$dep + ($conv << 1) >> 1] | 0; if ($4 << 16 >> 16 != (HEAP16[$this + 400 + ($conv << 1) >> 1] | 0)) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } $6 = HEAP32[$this + 88 >> 2] | 0; $add_ptr = $6 + ((HEAPU16[$this + 92 >> 1] | 0) * 12 | 0) | 0; $arraydecay = sp | 0; if (($dmi_s | 0) == 0) { $tobool13 = (HEAP8[$dep + 86 | 0] & 1) != 0; $conv14 = HEAP16[$dep + 82 >> 1] & 255; __ZN10ime_pinyin12MatrixSearch8fill_dmiEPNS_13DictMatchInfoEPtttthbhh(0, $add_ptr, $arraydecay, -1, $4, 0, 1, $tobool13, $conv14, (__ZNK10ime_pinyin12SpellingTrie10is_half_idEt(HEAP32[$this + 4 >> 2] | 0, $4) | 0) & 1 ^ 1); } else { $add = (HEAP8[$dmi_s + 8 | 0] & 127) + 1 & 255; $tobool22 = (HEAP8[$dep + 86 | 0] & 1) != 0; $add28 = (HEAP16[$dep + 82 >> 1] & 255) + ((HEAPU8[$dmi_s + 9 | 0] | 0) >>> 1) & 255; if (__ZNK10ime_pinyin12SpellingTrie10is_half_idEt(HEAP32[$this + 4 >> 2] | 0, $4) | 0) { $cond38_off0 = 0; } else { $cond38_off0 = HEAP8[$dmi_s + 10 | 0] & 1; } __ZN10ime_pinyin12MatrixSearch8fill_dmiEPNS_13DictMatchInfoEPtttthbhh(0, $add_ptr, $arraydecay, (($dmi_s - $6 | 0) / 12 | 0) & 65535, $4, 0, $add, $tobool22, $add28, $cond38_off0); } if (($conv | 0) != ((HEAPU16[$length >> 1] | 0) - 1 | 0)) { $retval_0 = 1; STACKTOP = sp; return $retval_0 | 0; } $25 = $this + 900 | 0; HEAP32[$25 >> 2] = HEAP32[$25 >> 2] | 16777215; HEAP16[$this + 904 >> 1] = 0; HEAP32[$lpi_total_ >> 2] = 1; $retval_0 = 1; STACKTOP = sp; return $retval_0 | 0; } function __ZN10ime_pinyin18recalculate_kernelEPdjS0_Ph($freqs, $num, $code_book, $code_idx) { $freqs = $freqs | 0; $num = $num | 0; $code_book = $code_book | 0; $code_idx = $code_idx | 0; var $call = 0, $0 = 0, $tobool = 0, $call1 = 0, $1 = 0, $tobool2 = 0, $ret_0_lcssa = 0.0, $pos_029 = 0, $ret_028 = 0.0, $2 = 0.0, $arrayidx6 = 0, $idxprom = 0, $add = 0.0, $arrayidx12 = 0, $arrayidx16 = 0, $inc = 0, $code_026 = 0, $8 = 0, label = 0; $call = __Znaj(1024) | 0; $0 = $call; $tobool = ($call | 0) == 0; if ($tobool) { ___assert_func(4024, 79, 6240, 4232); return 0.0; } _memset($call | 0, 0, 1024); $call1 = __Znaj(2048) | 0; $1 = $call1; $tobool2 = ($call1 | 0) == 0; if ($tobool2) { ___assert_func(4024, 83, 6240, 2920); return 0.0; } _memset($call1 | 0, 0, 2048); if (($num | 0) == 0) { $ret_0_lcssa = 0.0; } else { $ret_028 = 0.0; $pos_029 = 0; while (1) { $2 = +HEAPF64[$freqs + ($pos_029 << 3) >> 3]; $arrayidx6 = $code_idx + $pos_029 | 0; $idxprom = HEAPU8[$arrayidx6] | 0; $add = $ret_028 + +__ZN10ime_pinyin8distanceEdd($2, +HEAPF64[$code_book + ($idxprom << 3) >> 3]); $arrayidx12 = $1 + ($idxprom << 3) | 0; HEAPF64[$arrayidx12 >> 3] = $2 + +HEAPF64[$arrayidx12 >> 3]; $arrayidx16 = $0 + ((HEAPU8[$arrayidx6] | 0) << 2) | 0; HEAP32[$arrayidx16 >> 2] = (HEAP32[$arrayidx16 >> 2] | 0) + 1; $inc = $pos_029 + 1 | 0; if ($inc >>> 0 < $num >>> 0) { $ret_028 = $add; $pos_029 = $inc; } else { $ret_0_lcssa = $add; break; } } } $code_026 = 0; do { $8 = HEAP32[$0 + ($code_026 << 2) >> 2] | 0; if (($8 | 0) == 0) { label = 1745; break; } HEAPF64[$code_book + ($code_026 << 3) >> 3] = +HEAPF64[$1 + ($code_026 << 3) >> 3] / +($8 >>> 0 >>> 0); $code_026 = $code_026 + 1 | 0; } while ($code_026 >>> 0 < 256); if ((label | 0) == 1745) { ___assert_func(4024, 94, 6240, 2008); return 0.0; } if (!$tobool) { __ZdaPv($call); } if ($tobool2) { return +$ret_0_lcssa; } __ZdaPv($call1); return +$ret_0_lcssa; } function __ZN10ime_pinyin15is_system_lemmaEj($lma_id) { $lma_id = $lma_id | 0; return $lma_id >>> 0 < 500001 & ($lma_id | 0) != 0 | 0; } function __ZN10ime_pinyin13is_user_lemmaEj($lma_id) { $lma_id = $lma_id | 0; return ($lma_id - 500001 | 0) >>> 0 < 1e5 | 0; } function __ZN10ime_pinyin18is_composing_lemmaEj($lma_id) { $lma_id = $lma_id | 0; return ($lma_id | 0) == 16777215 | 0; } function __ZN10ime_pinyin15align_to_size_tEj($size) { $size = $size | 0; return $size + 3 & -4 | 0; } function __ZN10ime_pinyin15cmp_lpi_with_idEPKvS1_($p1, $p2) { $p1 = $p1 | 0; $p2 = $p2 | 0; var $bf_clear = 0, $bf_clear1 = 0, $retval_0 = 0; $bf_clear = HEAP32[$p1 >> 2] & 16777215; $bf_clear1 = HEAP32[$p2 >> 2] & 16777215; if ($bf_clear >>> 0 < $bf_clear1 >>> 0) { $retval_0 = -1; return $retval_0 | 0; } $retval_0 = $bf_clear >>> 0 > $bf_clear1 >>> 0 | 0; return $retval_0 | 0; } function __ZN10ime_pinyin12cmp_hanzis_1EPKvS1_($p1, $p2) { $p1 = $p1 | 0; $p2 = $p2 | 0; var $1 = 0, $3 = 0, $retval_0 = 0; $1 = HEAP16[$p1 >> 1] | 0; $3 = HEAP16[$p2 >> 1] | 0; if (($1 & 65535) < ($3 & 65535)) { $retval_0 = -1; return $retval_0 | 0; } $retval_0 = ($1 & 65535) > ($3 & 65535) | 0; return $retval_0 | 0; } function __ZN10ime_pinyin17cmp_npre_by_scoreEPKvS1_($p1, $p2) { $p1 = $p1 | 0; $p2 = $p2 | 0; var $0 = 0.0, $1 = 0.0, $retval_0 = 0; $0 = +HEAPF32[$p1 >> 2]; $1 = +HEAPF32[$p2 >> 2]; if ($0 > $1) { $retval_0 = 1; return $retval_0 | 0; } $retval_0 = ($0 < $1) << 31 >> 31; return $retval_0 | 0; } function __ZN10ime_pinyin5NGram11get_uni_psbEj($this, $lma_id) { $this = $this | 0; $lma_id = $lma_id | 0; return +(+((HEAPU16[(HEAP32[$this + 20 >> 2] | 0) + ((HEAPU8[(HEAP32[$this + 24 >> 2] | 0) + $lma_id | 0] | 0) << 1) >> 1] | 0) >>> 0) + +HEAPF32[$this + 12 >> 2]); } function __ZN10ime_pinyin16cmp_lpi_with_psbEPKvS1_($p1, $p2) { $p1 = $p1 | 0; $p2 = $p2 | 0; var $1 = 0, $3 = 0, $retval_0 = 0; $1 = HEAP16[$p1 + 4 >> 1] | 0; $3 = HEAP16[$p2 + 4 >> 1] | 0; if (($1 & 65535) > ($3 & 65535)) { $retval_0 = 1; return $retval_0 | 0; } $retval_0 = (($1 & 65535) < ($3 & 65535)) << 31 >> 31; return $retval_0 | 0; } function __ZN10ime_pinyin24cmp_lpi_with_unified_psbEPKvS1_($p1, $p2) { $p1 = $p1 | 0; $p2 = $p2 | 0; var $mul = 0, $mul4 = 0, $retval_0 = 0; $mul = Math_imul((HEAP32[$p2 >> 2] | 0) >>> 24 & 15, HEAPU16[$p1 + 4 >> 1] | 0) | 0; $mul4 = Math_imul((HEAP32[$p1 >> 2] | 0) >>> 24 & 15, HEAPU16[$p2 + 4 >> 1] | 0) | 0; if ($mul >>> 0 < $mul4 >>> 0) { $retval_0 = -1; return $retval_0 | 0; } $retval_0 = $mul >>> 0 > $mul4 >>> 0 | 0; return $retval_0 | 0; } function __ZN10ime_pinyin18cmp_lpi_with_hanziEPKvS1_($p1, $p2) { $p1 = $p1 | 0; $p2 = $p2 | 0; var $1 = 0, $3 = 0, $retval_0 = 0; $1 = HEAP16[$p1 + 6 >> 1] | 0; $3 = HEAP16[$p2 + 6 >> 1] | 0; if (($1 & 65535) < ($3 & 65535)) { $retval_0 = -1; return $retval_0 | 0; } $retval_0 = ($1 & 65535) > ($3 & 65535) | 0; return $retval_0 | 0; } function __ZN10ime_pinyin24cmp_npre_by_hislen_scoreEPKvS1_($p1, $p2) { $p1 = $p1 | 0; $p2 = $p2 | 0; var $1 = 0, $3 = 0, $4 = 0.0, $5 = 0.0, $retval_0 = 0; $1 = HEAP16[$p1 + 18 >> 1] | 0; $3 = HEAP16[$p2 + 18 >> 1] | 0; do { if (($1 & 65535) < ($3 & 65535)) { $retval_0 = 1; } else { if (($1 & 65535) > ($3 & 65535)) { $retval_0 = -1; break; } $4 = +HEAPF32[$p1 >> 2]; $5 = +HEAPF32[$p2 >> 2]; if ($4 > $5) { $retval_0 = 1; break; } $retval_0 = ($4 < $5) << 31 >> 31; } } while (0); return $retval_0 | 0; } function __ZN10ime_pinyin5NGramD2Ev($this) { $this = $this | 0; var $0 = 0, $1 = 0, $3 = 0; $0 = HEAP32[$this + 24 >> 2] | 0; if (($0 | 0) != 0) { _free($0); } $1 = HEAP32[$this + 16 >> 2] | 0; if (($1 | 0) != 0) { _free($1); } $3 = HEAP32[$this + 20 >> 2] | 0; if (($3 | 0) == 0) { return; } _free($3); return; } function __ZN10ime_pinyin5NGram12get_instanceEv() { var $1 = 0; if ((HEAP32[11854] | 0) == 0) { $1 = __Znwj(28) | 0; __ZN10ime_pinyin5NGramC2Ev($1); HEAP32[11854] = $1; } return HEAP32[11854] | 0; } function __ZN10ime_pinyin5NGram10save_ngramEP7__sFILE($this, $fp) { $this = $this | 0; $fp = $fp | 0; var $idx_num_ = 0, $freq_codes_ = 0, $lma_freq_idx_ = 0, $call20 = 0, $retval_0 = 0; if ((HEAP8[$this | 0] & 1) == 0 | ($fp | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $idx_num_ = $this + 4 | 0; if ((HEAP32[$idx_num_ >> 2] | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $freq_codes_ = $this + 20 | 0; if ((HEAP32[$freq_codes_ >> 2] | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $lma_freq_idx_ = $this + 24 | 0; if ((HEAP32[$lma_freq_idx_ >> 2] | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } if ((_fwrite($idx_num_ | 0, 4, 1, $fp | 0) | 0) != 1) { $retval_0 = 0; return $retval_0 | 0; } if ((_fwrite(HEAP32[$freq_codes_ >> 2] | 0, 2, 256, $fp | 0) | 0) != 256) { $retval_0 = 0; return $retval_0 | 0; } $call20 = _fwrite(HEAP32[$lma_freq_idx_ >> 2] | 0, 1, HEAP32[$idx_num_ >> 2] | 0, $fp | 0) | 0; $retval_0 = ($call20 | 0) == (HEAP32[$idx_num_ >> 2] | 0); return $retval_0 | 0; } function __ZN10ime_pinyin5NGram10load_ngramEP7__sFILE($this, $fp) { $this = $this | 0; $fp = $fp | 0; var $initialized_ = 0, $idx_num_ = 0, $lma_freq_idx_ = 0, $1 = 0, $freq_codes_ = 0, $2 = 0, $call16 = 0, $call31 = 0, $retval_0 = 0; if (($fp | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $initialized_ = $this | 0; HEAP8[$initialized_] = 0; $idx_num_ = $this + 4 | 0; if ((_fread($idx_num_ | 0, 4, 1, $fp | 0) | 0) != 1) { $retval_0 = 0; return $retval_0 | 0; } $lma_freq_idx_ = $this + 24 | 0; $1 = HEAP32[$lma_freq_idx_ >> 2] | 0; if (($1 | 0) != 0) { _free($1); } $freq_codes_ = $this + 20 | 0; $2 = HEAP32[$freq_codes_ >> 2] | 0; if (($2 | 0) != 0) { _free($2); } HEAP32[$lma_freq_idx_ >> 2] = _malloc(HEAP32[$idx_num_ >> 2] | 0) | 0; $call16 = _malloc(512) | 0; HEAP32[$freq_codes_ >> 2] = $call16; if ((HEAP32[$lma_freq_idx_ >> 2] | 0) == 0 | ($call16 | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } if ((_fread($call16 | 0, 2, 256, $fp | 0) | 0) != 256) { $retval_0 = 0; return $retval_0 | 0; } $call31 = _fread(HEAP32[$lma_freq_idx_ >> 2] | 0, 1, HEAP32[$idx_num_ >> 2] | 0, $fp | 0) | 0; if (($call31 | 0) != (HEAP32[$idx_num_ >> 2] | 0)) { $retval_0 = 0; return $retval_0 | 0; } HEAP8[$initialized_] = 1; HEAP32[$this + 8 >> 2] = 0; $retval_0 = 1; return $retval_0 | 0; } function __ZN10ime_pinyin5NGram23set_total_freq_none_sysEj($this, $freq_none_sys) { $this = $this | 0; $freq_none_sys = $freq_none_sys | 0; HEAP32[$this + 8 >> 2] = $freq_none_sys; if (($freq_none_sys | 0) == 0) { HEAPF32[$this + 12 >> 2] = 0.0; return; } else { HEAPF32[$this + 12 >> 2] = +Math_log(+(1.0e8 / +(($freq_none_sys + 1e8 | 0) >>> 0 >>> 0))) * -800.0; return; } } function __ZN10ime_pinyin5NGram20convert_psb_to_scoreEd($psb) { $psb = +$psb; var $conv = 0.0; $conv = +Math_log(+$psb) * -800.0; return +($conv > 16383.0 ? 16383.0 : $conv); } function __ZN10ime_pinyin17cmp_lpsi_with_strEPKvS1_($p1, $p2) { $p1 = $p1 | 0; $p2 = $p2 | 0; return _utf16_strcmp($p1 + 8 | 0, $p2 + 8 | 0) | 0; } function __ZN10ime_pinyin12cmp_hanzis_2EPKvS1_($p1, $p2) { $p1 = $p1 | 0; $p2 = $p2 | 0; return _utf16_strncmp($p1, $p2, 2) | 0; } function __ZN10ime_pinyin12cmp_hanzis_3EPKvS1_($p1, $p2) { $p1 = $p1 | 0; $p2 = $p2 | 0; return _utf16_strncmp($p1, $p2, 3) | 0; } function __ZN10ime_pinyin12cmp_hanzis_4EPKvS1_($p1, $p2) { $p1 = $p1 | 0; $p2 = $p2 | 0; return _utf16_strncmp($p1, $p2, 4) | 0; } function __ZN10ime_pinyin12cmp_hanzis_5EPKvS1_($p1, $p2) { $p1 = $p1 | 0; $p2 = $p2 | 0; return _utf16_strncmp($p1, $p2, 5) | 0; } function __ZN10ime_pinyin12cmp_hanzis_6EPKvS1_($p1, $p2) { $p1 = $p1 | 0; $p2 = $p2 | 0; return _utf16_strncmp($p1, $p2, 6) | 0; } function __ZN10ime_pinyin12cmp_hanzis_7EPKvS1_($p1, $p2) { $p1 = $p1 | 0; $p2 = $p2 | 0; return _utf16_strncmp($p1, $p2, 7) | 0; } function __ZN10ime_pinyin12cmp_hanzis_8EPKvS1_($p1, $p2) { $p1 = $p1 | 0; $p2 = $p2 | 0; return _utf16_strncmp($p1, $p2, 8) | 0; } function __ZN10ime_pinyin23cmp_npre_by_hanzi_scoreEPKvS1_($p1, $p2) { $p1 = $p1 | 0; $p2 = $p2 | 0; var $call = 0, $0 = 0.0, $1 = 0.0, $retval_0 = 0; $call = _utf16_strncmp($p1 + 4 | 0, $p2 + 4 | 0, 7) | 0; if (($call | 0) != 0) { $retval_0 = $call; return $retval_0 | 0; } $0 = +HEAPF32[$p1 >> 2]; $1 = +HEAPF32[$p2 >> 2]; if ($0 > $1) { $retval_0 = 1; return $retval_0 | 0; } $retval_0 = ($0 < $1) << 31 >> 31; return $retval_0 | 0; } function __ZN10ime_pinyin21remove_duplicate_npreEPNS_12NPredictItemEj($npre_items, $npre_num) { $npre_items = $npre_items | 0; $npre_num = $npre_num | 0; var $pos_018 = 0, $remain_num_017 = 0, $arrayidx = 0, $1 = 0, $2 = 0, $remain_num_1 = 0, $inc14 = 0, $retval_0 = 0; if (($npre_items | 0) == 0 | ($npre_num | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } __ZN10ime_pinyin7myqsortEPvjjPFiPKvS2_E($npre_items, $npre_num, 20, 16); if ($npre_num >>> 0 > 1) { $remain_num_017 = 1; $pos_018 = 1; } else { $retval_0 = 1; return $retval_0 | 0; } while (1) { $arrayidx = $npre_items + ($pos_018 * 20 | 0) | 0; if ((_utf16_strncmp($npre_items + ($pos_018 * 20 | 0) + 4 | 0, $npre_items + (($remain_num_017 - 1 | 0) * 20 | 0) + 4 | 0, 7) | 0) == 0) { $remain_num_1 = $remain_num_017; } else { if (($remain_num_017 | 0) != ($pos_018 | 0)) { $1 = $npre_items + ($remain_num_017 * 20 | 0) | 0; $2 = $arrayidx; HEAP32[$1 >> 2] = HEAP32[$2 >> 2]; HEAP32[$1 + 4 >> 2] = HEAP32[$2 + 4 >> 2]; HEAP32[$1 + 8 >> 2] = HEAP32[$2 + 8 >> 2]; HEAP32[$1 + 12 >> 2] = HEAP32[$2 + 12 >> 2]; HEAP32[$1 + 16 >> 2] = HEAP32[$2 + 16 >> 2]; } $remain_num_1 = $remain_num_017 + 1 | 0; } $inc14 = $pos_018 + 1 | 0; if ($inc14 >>> 0 < $npre_num >>> 0) { $remain_num_017 = $remain_num_1; $pos_018 = $inc14; } else { $retval_0 = $remain_num_1; break; } } return $retval_0 | 0; } function __ZN10ime_pinyin11compare_splEPKvS1_($p1, $p2) { $p1 = $p1 | 0; $p2 = $p2 | 0; return _strcmp($p1 | 0, $p2 | 0) | 0; } function __ZN10ime_pinyin12SpellingTrieC2Ev($this) { $this = $this | 0; HEAP32[$this >> 2] = 0; HEAP32[$this + 4 >> 2] = 0; HEAP32[$this + 8 >> 2] = 0; HEAP32[$this + 20 >> 2] = 0; _memset($this + 36 | 0, 0, 20); HEAP32[11856] = 0; HEAP32[$this + 24 >> 2] = 0; HEAP32[$this + 280 >> 2] = 0; __ZN10ime_pinyin12SpellingTrie14szm_enable_shmEb($this, 1); __ZN10ime_pinyin12SpellingTrie13szm_enable_ymEb($this, 1); HEAP32[$this + 284 >> 2] = 0; return; } function __ZN10ime_pinyin12SpellingTrie14szm_enable_shmEb($this, $enable) { $this = $this | 0; $enable = $enable | 0; var $conv10 = 0, $ch_09 = 0, $arrayidx = 0, $inc = 0, $conv1113 = 0, $ch9_012 = 0, $arrayidx18 = 0, $inc26 = 0; if ($enable) { $ch_09 = 65; $conv10 = 65; while (1) { if (__ZNK10ime_pinyin12SpellingTrie15is_shengmu_charEc(0, $ch_09) | 0) { $arrayidx = 10952 + ($conv10 - 65) | 0; HEAP8[$arrayidx] = HEAP8[$arrayidx] | 4; } $inc = $ch_09 + 1 & 255; if ($inc << 24 >> 24 < 91) { $ch_09 = $inc; $conv10 = $inc << 24 >> 24; } else { break; } } return; } else { $ch9_012 = 65; $conv1113 = 65; while (1) { if (__ZNK10ime_pinyin12SpellingTrie15is_shengmu_charEc(0, $ch9_012) | 0) { $arrayidx18 = 10952 + ($conv1113 - 65) | 0; HEAP8[$arrayidx18] = HEAP8[$arrayidx18] & -5; } $inc26 = $ch9_012 + 1 & 255; if ($inc26 << 24 >> 24 < 91) { $ch9_012 = $inc26; $conv1113 = $inc26 << 24 >> 24; } else { break; } } return; } } function __ZN10ime_pinyin12SpellingTrie13szm_enable_ymEb($this, $enable) { $this = $this | 0; $enable = $enable | 0; var $conv10 = 0, $ch_09 = 0, $arrayidx = 0, $inc = 0, $conv1113 = 0, $ch9_012 = 0, $arrayidx18 = 0, $inc26 = 0; if ($enable) { $ch_09 = 65; $conv10 = 65; while (1) { if (__ZNK10ime_pinyin12SpellingTrie13is_yunmu_charEc(0, $ch_09) | 0) { $arrayidx = 10952 + ($conv10 - 65) | 0; HEAP8[$arrayidx] = HEAP8[$arrayidx] | 4; } $inc = $ch_09 + 1 & 255; if ($inc << 24 >> 24 < 91) { $ch_09 = $inc; $conv10 = $inc << 24 >> 24; } else { break; } } return; } else { $ch9_012 = 65; $conv1113 = 65; while (1) { if (__ZNK10ime_pinyin12SpellingTrie13is_yunmu_charEc(0, $ch9_012) | 0) { $arrayidx18 = 10952 + ($conv1113 - 65) | 0; HEAP8[$arrayidx18] = HEAP8[$arrayidx18] & -5; } $inc26 = $ch9_012 + 1 & 255; if ($inc26 << 24 >> 24 < 91) { $ch9_012 = $inc26; $conv1113 = $inc26 << 24 >> 24; } else { break; } } return; } } function __ZN10ime_pinyin5NGram13build_unigramEPNS_10LemmaEntryEjj($this, $lemma_arr, $lemma_num, $next_idx_unused) { $this = $this | 0; $lemma_arr = $lemma_arr | 0; $lemma_num = $lemma_num | 0; $next_idx_unused = $next_idx_unused | 0; var $0$0 = 0, $call = 0, $4 = 0, $cmp5 = 0, $total_freq_078 = 0.0, $idx_now_077 = 0, $pos_076 = 0, $5 = 0, $inc = 0, $6 = 0.0, $storemerge = 0.0, $idx_now_1 = 0, $total_freq_1 = 0.0, $inc26 = 0, $total_freq_0_lcssa = 0.0, $idx_now_0_lcssa = 0, $add27 = 0, $idx_num_ = 0, $pos33_072 = 0, $arrayidx38 = 0, $div = 0.0, $freq_codes_df_ = 0, $10 = 0, $call55 = 0, $11 = 0, $12 = 0, $freq_codes_ = 0, $14 = 0, $call65 = 0, $15 = 0, $16 = 0, $code_pos_069 = 0, $freq_pos_068 = 0, $inc99 = 0, $freq_pos_1_ph = 0, $arrayidx78 = 0, $20 = 0.0, $i_0 = 0, $lma_freq_idx_ = 0, $25 = 0, $call105 = 0, $27 = 0, $code_pos116_066 = 0, $conv126 = 0, $retval_0 = 0; if (($lemma_arr | 0) == 0 | ($lemma_num | 0) == 0 | $next_idx_unused >>> 0 < 2) { $retval_0 = 0; return $retval_0 | 0; } $0$0 = _llvm_umul_with_overflow_i32($next_idx_unused | 0, 8) | 0; $call = __Znaj(tempRet0 ? -1 : $0$0) | 0; $4 = $call; $cmp5 = ($call | 0) == 0; if ($cmp5) { $retval_0 = 0; return $retval_0 | 0; } HEAPF64[$4 >> 3] = .3; L2413 : do { if (($lemma_num | 0) == 0) { $idx_now_0_lcssa = 0; $total_freq_0_lcssa = .3; } else { $pos_076 = 0; $idx_now_077 = 0; $total_freq_078 = .3; while (1) { $5 = HEAP32[$lemma_arr + ($pos_076 * 124 | 0) + 4 >> 2] | 0; if (($5 | 0) == ($idx_now_077 | 0)) { $total_freq_1 = $total_freq_078; $idx_now_1 = $idx_now_077; } else { $inc = $idx_now_077 + 1 | 0; if (($5 | 0) != ($inc | 0)) { break; } $6 = +HEAPF32[$lemma_arr + ($pos_076 * 124 | 0) + 120 >> 2]; $storemerge = $6 > 0.0 ? $6 : .3; HEAPF64[$4 + ($inc << 3) >> 3] = $storemerge; $total_freq_1 = $total_freq_078 + $storemerge; $idx_now_1 = $inc; } $inc26 = $pos_076 + 1 | 0; if ($inc26 >>> 0 < $lemma_num >>> 0) { $pos_076 = $inc26; $idx_now_077 = $idx_now_1; $total_freq_078 = $total_freq_1; } else { $idx_now_0_lcssa = $idx_now_1; $total_freq_0_lcssa = $total_freq_1; break L2413; } } ___assert_func(4024, 262, 6152, 1576); return 0; } } while (0); $add27 = $idx_now_0_lcssa + 1 | 0; $idx_num_ = $this + 4 | 0; HEAP32[$idx_num_ >> 2] = $add27; if (($add27 | 0) != ($next_idx_unused | 0)) { ___assert_func(4024, 273, 6152, 1312); return 0; } L2425 : do { if ((HEAP32[$idx_num_ >> 2] | 0) != 0) { $pos33_072 = 0; while (1) { $arrayidx38 = $4 + ($pos33_072 << 3) | 0; $div = +HEAPF64[$arrayidx38 >> 3] / $total_freq_0_lcssa; HEAPF64[$arrayidx38 >> 3] = $div; if ($div <= 0.0) { break; } $pos33_072 = $pos33_072 + 1 | 0; if ($pos33_072 >>> 0 >= (HEAP32[$idx_num_ >> 2] | 0) >>> 0) { break L2425; } } ___assert_func(4024, 277, 6152, 1080); return 0; } } while (0); $freq_codes_df_ = $this + 16 | 0; $10 = HEAP32[$freq_codes_df_ >> 2] | 0; do { if (($10 | 0) == 0) { $call55 = __Znaj(2048) | 0; $11 = $call55; HEAP32[$freq_codes_df_ >> 2] = $11; if (($call55 | 0) != 0) { $12 = $11; break; } ___assert_func(4024, 285, 6152, 904); return 0; } else { $12 = $10; } } while (0); _memset($12 | 0, 0, 2048); $freq_codes_ = $this + 20 | 0; $14 = HEAP32[$freq_codes_ >> 2] | 0; do { if (($14 | 0) == 0) { $call65 = __Znaj(512) | 0; $15 = $call65; HEAP32[$freq_codes_ >> 2] = $15; if (($call65 | 0) != 0) { $16 = $15; break; } ___assert_func(4024, 290, 6152, 736); return 0; } else { $16 = $14; } } while (0); _memset($16 | 0, 0, 512); $freq_pos_068 = 0; $code_pos_069 = 0; while (1) { $freq_pos_1_ph = $freq_pos_068; L2441 : while (1) { $arrayidx78 = $4 + ($freq_pos_1_ph << 3) | 0; $20 = +HEAPF64[$arrayidx78 >> 3]; $i_0 = 0; while (1) { if ($i_0 >>> 0 >= $code_pos_069 >>> 0) { break L2441; } if (+HEAPF64[(HEAP32[$freq_codes_df_ >> 2] | 0) + ($i_0 << 3) >> 3] == $20) { break; } else { $i_0 = $i_0 + 1 | 0; } } $freq_pos_1_ph = $freq_pos_1_ph + 1 | 0; } HEAPF64[(HEAP32[$freq_codes_df_ >> 2] | 0) + ($code_pos_069 << 3) >> 3] = +HEAPF64[$arrayidx78 >> 3]; $inc99 = $code_pos_069 + 1 | 0; if ($inc99 >>> 0 < 256) { $freq_pos_068 = $freq_pos_1_ph + 1 | 0; $code_pos_069 = $inc99; } else { break; } } __ZN10ime_pinyin7myqsortEPvjjPFiPKvS2_E(HEAP32[$freq_codes_df_ >> 2] | 0, 256, 8, 2); $lma_freq_idx_ = $this + 24 | 0; $25 = HEAP32[$lma_freq_idx_ >> 2] | 0; do { if (($25 | 0) == 0) { $call105 = __Znaj(HEAP32[$idx_num_ >> 2] | 0) | 0; HEAP32[$lma_freq_idx_ >> 2] = $call105; if (($call105 | 0) != 0) { $27 = $call105; break; } ___assert_func(4024, 317, 6152, 584); return 0; } else { $27 = $25; } } while (0); __ZN10ime_pinyin13iterate_codesEPdjS0_Ph($4, HEAP32[$idx_num_ >> 2] | 0, HEAP32[$freq_codes_df_ >> 2] | 0, $27); if ($cmp5) { $code_pos116_066 = 0; } else { __ZdaPv($call); $code_pos116_066 = 0; } do { $conv126 = ~~+__ZN10ime_pinyin5NGram20convert_psb_to_scoreEd(+HEAPF64[(HEAP32[$freq_codes_df_ >> 2] | 0) + ($code_pos116_066 << 3) >> 3]); HEAP16[(HEAP32[$freq_codes_ >> 2] | 0) + ($code_pos116_066 << 1) >> 1] = $conv126; $code_pos116_066 = $code_pos116_066 + 1 | 0; } while ($code_pos116_066 >>> 0 < 256); HEAP8[$this | 0] = 1; $retval_0 = 1; return $retval_0 | 0; } function __ZNK10ime_pinyin12SpellingTrie10is_half_idEt($this, $splid) { $this = $this | 0; $splid = $splid | 0; return ($splid & 65535) < 30 & $splid << 16 >> 16 != 0 | 0; } function __ZNK10ime_pinyin12SpellingTrie14szm_is_enabledEc($this, $ch) { $this = $this | 0; $ch = $ch | 0; return (HEAP8[10952 + (($ch << 24 >> 24) - 65) | 0] & 4) != 0 | 0; } function __ZNK10ime_pinyin12SpellingTrie13is_yunmu_charEc($this, $ch) { $this = $this | 0; $ch = $ch | 0; return (HEAP8[10952 + (($ch << 24 >> 24) - 65) | 0] & 2) != 0 | 0; } function __ZNK10ime_pinyin12SpellingTrie10is_full_idEt($this, $splid) { $this = $this | 0; $splid = $splid | 0; if (($splid & 65535) < 30) { return 0; } else { return ($splid & 65535) >>> 0 < ((HEAP32[$this + 8 >> 2] | 0) + 30 | 0) >>> 0 | 0; } return 0; } function __ZNK10ime_pinyin12SpellingTrie12full_to_halfEt($this, $full_id) { $this = $this | 0; $full_id = $full_id | 0; var $conv = 0, $retval_0 = 0; if ((HEAP32[$this + 44 >> 2] | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $conv = $full_id & 65535; if (($full_id & 65535) < 30) { $retval_0 = 0; return $retval_0 | 0; } if ($conv >>> 0 > ((HEAP32[$this + 8 >> 2] | 0) + 30 | 0) >>> 0) { $retval_0 = 0; return $retval_0 | 0; } $retval_0 = HEAP16[(HEAP32[$this + 280 >> 2] | 0) + ($conv - 30 << 1) >> 1] | 0; return $retval_0 | 0; } function __ZNK10ime_pinyin12SpellingTrie16is_half_id_yunmuEt($this, $splid) { $this = $this | 0; $splid = $splid | 0; var $conv = 0, $retval_0 = 0; $conv = $splid & 65535; if ($splid << 16 >> 16 == 0 | ($splid & 65535) > 29) { $retval_0 = 0; return $retval_0 | 0; } if ((538968080 >>> ($conv >>> 0) & 1 | 0) != 0) { $retval_0 = 0; return $retval_0 | 0; } $retval_0 = (HEAP8[10952 + ((HEAP8[10920 + $conv | 0] | 0) - 65) | 0] & 2) != 0; return $retval_0 | 0; } function __ZNK10ime_pinyin12SpellingTrie15is_shengmu_charEc($this, $ch) { $this = $this | 0; $ch = $ch | 0; return (HEAP8[10952 + (($ch << 24 >> 24) - 65) | 0] & 1) != 0 | 0; } function __ZNK10ime_pinyin12SpellingTrie14is_szm_enabledEc($this, $ch) { $this = $this | 0; $ch = $ch | 0; return (HEAP8[10952 + (($ch << 24 >> 24) - 65) | 0] & 4) != 0 | 0; } function __ZNK10ime_pinyin12SpellingTrie13half2full_numEt($this, $half_id) { $this = $this | 0; $half_id = $half_id | 0; var $retval_0 = 0; if ((HEAP32[$this + 44 >> 2] | 0) == 0 | ($half_id & 65535) > 29) { $retval_0 = 0; return $retval_0 | 0; } $retval_0 = HEAP16[$this + 220 + (($half_id & 65535) << 1) >> 1] | 0; return $retval_0 | 0; } function __ZNK10ime_pinyin12SpellingTrie12half_to_fullEtPt($this, $half_id, $spl_id_start) { $this = $this | 0; $half_id = $half_id | 0; $spl_id_start = $spl_id_start | 0; var $conv = 0, $retval_0 = 0; do { if (($spl_id_start | 0) == 0) { $retval_0 = 0; } else { if ((HEAP32[$this + 44 >> 2] | 0) == 0) { $retval_0 = 0; break; } $conv = $half_id & 65535; if (($half_id & 65535) > 29) { $retval_0 = 0; break; } HEAP16[$spl_id_start >> 1] = HEAP16[$this + 160 + ($conv << 1) >> 1] | 0; $retval_0 = HEAP16[$this + 220 + ($conv << 1) >> 1] | 0; } } while (0); return $retval_0 | 0; } function __ZN10ime_pinyin12SpellingTrieD2Ev($this) { $this = $this | 0; var $0 = 0, $1 = 0, $2 = 0, $4 = 0, $root_ = 0, $5 = 0, $6 = 0, $8 = 0, $10 = 0, $12 = 0, $16 = 0, $17 = 0; $0 = HEAP32[$this >> 2] | 0; if (($0 | 0) != 0) { __ZdaPv($0); } $1 = HEAP32[$this + 36 >> 2] | 0; if (($1 | 0) != 0) { __ZdaPv($1); } $2 = HEAP32[$this + 40 >> 2] | 0; if (($2 | 0) != 0) { __ZdaPv($2); } $4 = HEAP32[$this + 20 >> 2] | 0; if (($4 | 0) != 0) { __ZdaPv($4); } $root_ = $this + 44 | 0; $5 = HEAP32[$root_ >> 2] | 0; do { if (($5 | 0) != 0) { __ZN10ime_pinyin12SpellingTrie13free_son_trieEPNS_12SpellingNodeE($this, $5); $6 = HEAP32[$root_ >> 2] | 0; if (($6 | 0) == 0) { break; } __ZdlPv($6); } } while (0); $8 = HEAP32[$this + 48 >> 2] | 0; if (($8 | 0) != 0) { __ZdaPv($8); } $10 = HEAP32[$this + 52 >> 2] | 0; if (($10 | 0) != 0) { __ZdaPv($10); } $12 = HEAP32[11856] | 0; if (($12 | 0) != 0) { __ZN10ime_pinyin12SpellingTrieD2Ev($12); __ZdlPv($12); HEAP32[11856] = 0; } $16 = HEAP32[$this + 24 >> 2] | 0; if (($16 | 0) != 0) { __ZdaPv($16); } $17 = HEAP32[$this + 280 >> 2] | 0; if (($17 | 0) == 0) { return; } __ZdaPv($17); return; } function __ZN10ime_pinyin12SpellingTrie13free_son_trieEPNS_12SpellingNodeE($this, $node) { $this = $this | 0; $node = $node | 0; var $1 = 0, $first_son = 0, $3 = 0, $4 = 0, $pos_08 = 0, $inc = 0, $7 = 0, $_lcssa = 0; if (($node | 0) == 0) { return; } $1 = $node + 4 | 0; $first_son = $node | 0; $3 = HEAP32[$first_son >> 2] | 0; if ((HEAPU16[$1 >> 1] | 0) > 2047) { $pos_08 = 0; $4 = $3; while (1) { __ZN10ime_pinyin12SpellingTrie13free_son_trieEPNS_12SpellingNodeE($this, $4 + ($pos_08 << 3) | 0); $inc = $pos_08 + 1 | 0; $7 = HEAP32[$first_son >> 2] | 0; if ($inc >>> 0 < ((HEAPU16[$1 >> 1] | 0) >>> 11 & 65535) >>> 0) { $pos_08 = $inc; $4 = $7; } else { $_lcssa = $7; break; } } } else { $_lcssa = $3; } if (($_lcssa | 0) == 0) { return; } __ZdaPv($_lcssa); return; } function __ZNK10ime_pinyin12SpellingTrie20half_full_compatibleEtt($this, $half_id, $full_id) { $this = $this | 0; $half_id = $half_id | 0; $full_id = $full_id | 0; var $call = 0, $retval_0 = 0; $call = __ZNK10ime_pinyin12SpellingTrie12full_to_halfEt($this, $full_id) | 0; if ($call << 16 >> 16 == $half_id << 16 >> 16) { $retval_0 = 1; return $retval_0 | 0; } $retval_0 = (HEAP8[10920 + ($call & 65535) | 0] & -33) << 24 >> 24 == (HEAP8[10920 + ($half_id & 65535) | 0] | 0); return $retval_0 | 0; } function __ZNK10ime_pinyin12SpellingTrie11is_szm_charEc($this, $ch) { $this = $this | 0; $ch = $ch | 0; var $0 = 0; if (__ZNK10ime_pinyin12SpellingTrie15is_shengmu_charEc(0, $ch) | 0) { $0 = 1; return $0 | 0; } $0 = __ZNK10ime_pinyin12SpellingTrie13is_yunmu_charEc(0, $ch) | 0; return $0 | 0; } function __ZN10ime_pinyin12SpellingTrie14get_cpinstanceEv() { return __ZN10ime_pinyin12SpellingTrie12get_instanceEv() | 0; } function __ZN10ime_pinyin12SpellingTrie12get_instanceEv() { var $1 = 0; if ((HEAP32[11856] | 0) == 0) { $1 = __Znwj(288) | 0; __ZN10ime_pinyin12SpellingTrieC2Ev($1); HEAP32[11856] = $1; } return HEAP32[11856] | 0; } function __ZN10ime_pinyin12SpellingTrie9constructEPKcjjfh($this, $spelling_arr, $item_size, $item_num, $score_amplifier, $average_score) { $this = $this | 0; $spelling_arr = $spelling_arr | 0; $item_size = $item_size | 0; $item_num = $item_num | 0; $score_amplifier = +$score_amplifier; $average_score = $average_score | 0; var $h2f_start_ = 0, $spelling_buf_ = 0, $1 = 0, $mul = 0, $call = 0, $spelling_size_ = 0, $spelling_num_ = 0, $average_score_ = 0, $splstr_queried_ = 0, $2 = 0, $call26 = 0, $splstr16_queried_ = 0, $4 = 0, $7$0 = 0, $call40 = 0, $call49 = 0, $16 = 0, $root_ = 0, $call51 = 0, $18 = 0, $dumb_node_ = 0, $call55 = 0, $22 = 0, $splitter_node_ = 0, $call62 = 0, $retval_0 = 0; if (($spelling_arr | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $h2f_start_ = $this + 160 | 0; $spelling_buf_ = $this | 0; _memset($h2f_start_ | 0, 0, 120); $1 = HEAP32[$spelling_buf_ >> 2] | 0; do { if (($1 | 0) != ($spelling_arr | 0)) { if (($1 | 0) != 0) { __ZdaPv($1); } $mul = Math_imul($item_num, $item_size) | 0; $call = __Znaj($mul) | 0; HEAP32[$spelling_buf_ >> 2] = $call; if (($call | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } else { _memcpy($call | 0, $spelling_arr | 0, $mul) | 0; break; } } } while (0); $spelling_size_ = $this + 4 | 0; HEAP32[$spelling_size_ >> 2] = $item_size; $spelling_num_ = $this + 8 | 0; HEAP32[$spelling_num_ >> 2] = $item_num; HEAPF32[$this + 12 >> 2] = $score_amplifier; $average_score_ = $this + 16 | 0; HEAP8[$average_score_] = $average_score; $splstr_queried_ = $this + 36 | 0; $2 = HEAP32[$splstr_queried_ >> 2] | 0; if (($2 | 0) != 0) { __ZdaPv($2); } $call26 = __Znaj(HEAP32[$spelling_size_ >> 2] | 0) | 0; HEAP32[$splstr_queried_ >> 2] = $call26; if (($call26 | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $splstr16_queried_ = $this + 40 | 0; $4 = HEAP32[$splstr16_queried_ >> 2] | 0; if (($4 | 0) != 0) { __ZdaPv($4); } $7$0 = _llvm_umul_with_overflow_i32(HEAP32[$spelling_size_ >> 2] | 0, 2) | 0; $call40 = __Znaj(tempRet0 ? -1 : $7$0) | 0; HEAP32[$splstr16_queried_ >> 2] = $call40; if (($call40 | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } _qsort(HEAP32[$spelling_buf_ >> 2] | 0, HEAP32[$spelling_num_ >> 2] | 0, HEAP32[$spelling_size_ >> 2] | 0, 44); HEAP32[$this + 284 >> 2] = 1; $call49 = __Znwj(8) | 0; $16 = $call49; $root_ = $this + 44 | 0; HEAP32[$root_ >> 2] = $call49; HEAP32[$16 >> 2] = 0; HEAP32[$16 + 4 >> 2] = 0; $call51 = __Znwj(8) | 0; $18 = $call51; $dumb_node_ = $this + 48 | 0; HEAP32[$dumb_node_ >> 2] = $call51; HEAP32[$18 >> 2] = 0; HEAP32[$18 + 4 >> 2] = 0; HEAP8[(HEAP32[$dumb_node_ >> 2] | 0) + 7 | 0] = HEAP8[$average_score_] | 0; $call55 = __Znwj(8) | 0; $22 = $call55; $splitter_node_ = $this + 52 | 0; HEAP32[$splitter_node_ >> 2] = $call55; HEAP32[$22 >> 2] = 0; HEAP32[$22 + 4 >> 2] = 0; HEAP8[(HEAP32[$splitter_node_ >> 2] | 0) + 7 | 0] = HEAP8[$average_score_] | 0; _memset($this + 56 | 0, 0, 104); $call62 = __ZN10ime_pinyin12SpellingTrie26construct_spellings_subsetEjjjPNS_12SpellingNodeE($this, 0, HEAP32[$spelling_num_ >> 2] | 0, 0, HEAP32[$root_ >> 2] | 0) | 0; HEAP32[HEAP32[$root_ >> 2] >> 2] = $call62; HEAP8[(HEAP32[$root_ >> 2] | 0) + 7 | 0] = 0; if ((HEAP32[HEAP32[$root_ >> 2] >> 2] | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } HEAP16[$this + 220 >> 1] = 0; HEAP16[$h2f_start_ >> 1] = 0; if (!(__ZN10ime_pinyin12SpellingTrie9build_f2hEv($this) | 0)) { $retval_0 = 0; return $retval_0 | 0; } $retval_0 = __ZN10ime_pinyin12SpellingTrie13build_ym_infoEv($this) | 0; return $retval_0 | 0; } function __ZNK10ime_pinyin12SpellingTrie18if_valid_id_updateEPt($this, $splid) { $this = $this | 0; $splid = $splid | 0; var $0 = 0, $conv = 0, $1 = 0, $retval_0 = 0; do { if (($splid | 0) == 0) { $retval_0 = 0; } else { $0 = HEAP16[$splid >> 1] | 0; $conv = $0 & 65535; if ($0 << 16 >> 16 == 0) { $retval_0 = 0; break; } if (($0 & 65535) > 29) { $retval_0 = 1; break; } $1 = HEAP8[10920 + $conv | 0] | 0; if ((538968080 >>> ($conv >>> 0) & 1 | 0) != 0) { $retval_0 = 1; break; } if (__ZNK10ime_pinyin12SpellingTrie14szm_is_enabledEc(0, $1) | 0) { $retval_0 = 1; break; } if (!(__ZNK10ime_pinyin12SpellingTrie13is_yunmu_charEc(0, $1) | 0)) { $retval_0 = 0; break; } if ((HEAP16[$this + 220 + ($conv << 1) >> 1] | 0) == 0) { ___assert_func(3400, 128, 4448, 4088); return 0; } else { HEAP16[$splid >> 1] = HEAP16[$this + 160 + ($conv << 1) >> 1] | 0; $retval_0 = 1; break; } } } while (0); return $retval_0 | 0; } function __ZN10ime_pinyin12SpellingTrie17is_valid_spl_charEc($ch) { $ch = $ch | 0; if (($ch - 97 & 255) < 26) { return 1; } else { return ($ch - 65 & 255) < 26 | 0; } return 0; } function __ZN10ime_pinyin12SpellingTrie9build_f2hEv($this) { $this = $this | 0; var $f2h_ = 0, $0 = 0, $3$0 = 0, $call = 0, $conv15 = 0, $hid_014 = 0, $arrayidx = 0, $8 = 0, $conv107 = 0, $arrayidx16 = 0, $conv1013 = 0, $fid_012 = 0, $inc24 = 0, $retval_0 = 0; $f2h_ = $this + 280 | 0; $0 = HEAP32[$f2h_ >> 2] | 0; if (($0 | 0) != 0) { __ZdaPv($0); } $3$0 = _llvm_umul_with_overflow_i32(HEAP32[$this + 8 >> 2] | 0, 2) | 0; $call = __Znaj(tempRet0 ? -1 : $3$0) | 0; HEAP32[$f2h_ >> 2] = $call; if (($call | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } else { $hid_014 = 0; $conv15 = 0; } while (1) { $arrayidx = $this + 160 + ($conv15 << 1) | 0; $8 = HEAP16[$arrayidx >> 1] | 0; $conv107 = $8 & 65535; $arrayidx16 = $this + 220 + ($conv15 << 1) | 0; if (($conv107 | 0) < ((HEAPU16[$arrayidx16 >> 1] | 0) + ($8 & 65535) | 0)) { $fid_012 = $8; $conv1013 = $conv107; do { HEAP16[(HEAP32[$f2h_ >> 2] | 0) + ($conv1013 - 30 << 1) >> 1] = $hid_014; $fid_012 = $fid_012 + 1 & 65535; $conv1013 = $fid_012 & 65535; } while (($conv1013 | 0) < ((HEAPU16[$arrayidx16 >> 1] | 0) + (HEAPU16[$arrayidx >> 1] | 0) | 0)); } $inc24 = $hid_014 + 1 & 65535; if (($inc24 & 65535) < 30) { $hid_014 = $inc24; $conv15 = $inc24 & 65535; } else { $retval_0 = 1; break; } } return $retval_0 | 0; } function __ZN10ime_pinyin12SpellingTrie10get_ym_strEPKc($this, $spl_str) { $this = $this | 0; $spl_str = $spl_str | 0; var $0 = 0, $add_ptr8 = 0, $spl_str_addr_0 = 0; $0 = HEAP8[$spl_str] | 0; if (!(__ZNK10ime_pinyin12SpellingTrie15is_shengmu_charEc(0, $0) | 0)) { $spl_str_addr_0 = $spl_str; return $spl_str_addr_0 | 0; } if (($0 << 24 >> 24 | 0) == 90 | ($0 << 24 >> 24 | 0) == 67 | ($0 << 24 >> 24 | 0) == 83) { $add_ptr8 = $spl_str + 1 | 0; return ((HEAP8[$add_ptr8] | 0) == 104 ? $spl_str + 2 | 0 : $add_ptr8) | 0; } $spl_str_addr_0 = $spl_str + 1 | 0; return $spl_str_addr_0 | 0; } function __ZN10ime_pinyin12SpellingTrie16get_spelling_strEt($this, $splid) { $this = $this | 0; $splid = $splid | 0; var $splstr_queried_ = 0, $1 = 0, $2 = 0, $3 = 0, $add_ptr = 0, $4 = 0, $5 = 0, $dec_splid = 0, $splid_addr_1_off0 = 0, $12 = 0, sp = 0; sp = STACKTOP; $splstr_queried_ = $this + 36 | 0; HEAP8[HEAP32[$splstr_queried_ >> 2] | 0] = 0; if (($splid & 65535) > 29) { $1 = HEAP32[$splstr_queried_ >> 2] | 0; $2 = HEAP32[$this + 4 >> 2] | 0; $3 = HEAP32[$this >> 2] | 0; $add_ptr = $3 + (Math_imul($2, $splid - 30 & 65535) | 0) | 0; _snprintf($1 | 0, $2 | 0, 896, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = $add_ptr, tempInt) | 0) | 0; $12 = HEAP32[$splstr_queried_ >> 2] | 0; STACKTOP = sp; return $12 | 0; } if (($splid << 16 >> 16 | 0) == 4) { $4 = HEAP32[$splstr_queried_ >> 2] | 0; $5 = HEAP32[$this + 4 >> 2] | 0; _snprintf($4 | 0, $5 | 0, 896, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = 728, tempInt) | 0) | 0; $12 = HEAP32[$splstr_queried_ >> 2] | 0; STACKTOP = sp; return $12 | 0; } else if (($splid << 16 >> 16 | 0) == 21) { _snprintf(HEAP32[$splstr_queried_ >> 2] | 0, HEAP32[$this + 4 >> 2] | 0, 896, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = 576, tempInt) | 0) | 0; $12 = HEAP32[$splstr_queried_ >> 2] | 0; STACKTOP = sp; return $12 | 0; } else if (($splid << 16 >> 16 | 0) == 29) { _snprintf(HEAP32[$splstr_queried_ >> 2] | 0, HEAP32[$this + 4 >> 2] | 0, 896, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = 4368, tempInt) | 0) | 0; $12 = HEAP32[$splstr_queried_ >> 2] | 0; STACKTOP = sp; return $12 | 0; } else { $dec_splid = ((($splid & 65535) > 3) << 31 >> 31) + $splid & 65535; if (($dec_splid & 65535) > 19) { $splid_addr_1_off0 = $dec_splid + 255 & 255; } else { $splid_addr_1_off0 = $dec_splid & 255; } HEAP8[HEAP32[$splstr_queried_ >> 2] | 0] = $splid_addr_1_off0 + 64 & 255; HEAP8[(HEAP32[$splstr_queried_ >> 2] | 0) + 1 | 0] = 0; $12 = HEAP32[$splstr_queried_ >> 2] | 0; STACKTOP = sp; return $12 | 0; } return 0; } function __ZN10ime_pinyin12SpellingTrie9get_ym_idEPKc($this, $ym_str) { $this = $this | 0; $ym_str = $ym_str | 0; var $ym_buf_ = 0, $1 = 0, $ym_size_ = 0, $pos_0 = 0, $conv = 0, $2 = 0, $add = 0, $retval_0 = 0, label = 0; if (($ym_str | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $ym_buf_ = $this + 24 | 0; if ((HEAP32[$ym_buf_ >> 2] | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $1 = HEAP32[$this + 32 >> 2] | 0; $ym_size_ = $this + 28 | 0; $pos_0 = 0; while (1) { $conv = $pos_0 & 255; if ($conv >>> 0 >= $1 >>> 0) { $retval_0 = 0; label = 2089; break; } $2 = HEAP32[$ym_buf_ >> 2] | 0; $add = $pos_0 + 1 & 255; if ((_strcmp($2 + (Math_imul(HEAP32[$ym_size_ >> 2] | 0, $conv) | 0) | 0, $ym_str | 0) | 0) == 0) { $retval_0 = $add; label = 2087; break; } else { $pos_0 = $add; } } if ((label | 0) == 2089) { return $retval_0 | 0; } else if ((label | 0) == 2087) { return $retval_0 | 0; } return 0; } function __ZN10ime_pinyin12SpellingTrie13save_spl_trieEP7__sFILE($this, $fp) { $this = $this | 0; $fp = $fp | 0; var $spelling_buf_ = 0, $spelling_size_ = 0, $spelling_num_ = 0, $call21 = 0, $retval_0 = 0; if (($fp | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $spelling_buf_ = $this | 0; if ((HEAP32[$spelling_buf_ >> 2] | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $spelling_size_ = $this + 4 | 0; if ((_fwrite($spelling_size_ | 0, 4, 1, $fp | 0) | 0) != 1) { $retval_0 = 0; return $retval_0 | 0; } $spelling_num_ = $this + 8 | 0; if ((_fwrite($spelling_num_ | 0, 4, 1, $fp | 0) | 0) != 1) { $retval_0 = 0; return $retval_0 | 0; } if ((_fwrite($this + 12 | 0, 4, 1, $fp | 0) | 0) != 1) { $retval_0 = 0; return $retval_0 | 0; } if ((_fwrite($this + 16 | 0, 1, 1, $fp | 0) | 0) != 1) { $retval_0 = 0; return $retval_0 | 0; } $call21 = _fwrite(HEAP32[$spelling_buf_ >> 2] | 0, HEAP32[$spelling_size_ >> 2] | 0, HEAP32[$spelling_num_ >> 2] | 0, $fp | 0) | 0; $retval_0 = ($call21 | 0) == (HEAP32[$spelling_num_ >> 2] | 0); return $retval_0 | 0; } function __ZN10ime_pinyin12SpellingTrie26construct_spellings_subsetEjjjPNS_12SpellingNodeE($this, $item_start, $item_end, $level, $parent) { $this = $this | 0; $item_start = $item_start | 0; $item_end = $item_end | 0; $level = $level | 0; $parent = $parent | 0; var $spelling_size_ = 0, $0 = 0, $spelling_buf_ = 0, $1 = 0, $2 = 0, $add = 0, $3 = 0, $4 = 0, $num_of_son_0216 = 0, $char_for_node_0215 = 0, $i_0214 = 0, $5 = 0, $num_of_son_0_inc = 0, $inc23 = 0, $num_of_son_0_lcssa = 0, $conv25 = 0, $node_num_ = 0, $umul_with_overflow = 0, $call = 0, $7 = 0, $8 = 0, $mul31 = 0, $add_ptr32 = 0, $10 = 0, $add34 = 0, $cmp37 = 0, $cmp61 = 0, $cmp149 = 0, $min_son_score_0207 = 0, $spelling_last_start_0206 = 0, $char_for_node_2205 = 0, $son_pos_0201 = 0, $i40_0197 = 0, $item_start_next_0194 = 0, $spelling_endable_1_off0193 = 0, $12 = 0, $mul48 = 0, $add_ptr49 = 0, $14 = 0, $conv57 = 0, $add_ptr60 = 0, $16 = 0, $arrayidx71 = 0, $20 = 0, $21 = 0, $cmp81 = 0, $23 = 0, $score = 0, $27 = 0, $_min_son_score_0 = 0, $29 = 0, $bf_value140_pn = 0, $32 = 0, $cmp164 = 0, $part_id_0174 = 0, $34 = 0, $idxprom188 = 0, $spelling_endable_3_off0 = 0, $item_start_next_1 = 0, $son_pos_1 = 0, $char_for_node_3 = 0, $spelling_last_start_1 = 0, $min_son_score_2 = 0, $inc217 = 0, $min_son_score_0_lcssa = 0, $spelling_last_start_0_lcssa = 0, $char_for_node_2_lcssa = 0, $son_pos_0_lcssa = 0, $item_start_next_0_lcssa = 0, $spelling_endable_1_off0_lcssa = 0, $add_ptr220 = 0, $cmp222 = 0, $44 = 0, $arrayidx237 = 0, $48 = 0, $49 = 0, $cmp248 = 0, $51 = 0, $score264 = 0, $55 = 0, $_min_son_score_0166 = 0, $57 = 0, $bf_value318_pn = 0, $60 = 0, $cmp346 = 0, $part_id336_0180 = 0, $62 = 0, $idxprom370 = 0, $71 = 0, $retval_0 = 0, label = 0; $spelling_size_ = $this + 4 | 0; $0 = HEAP32[$spelling_size_ >> 2] | 0; if ($item_end >>> 0 <= $item_start >>> 0 | $0 >>> 0 <= $level >>> 0 | ($parent | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $spelling_buf_ = $this | 0; $1 = HEAP32[$spelling_buf_ >> 2] | 0; $2 = HEAP8[$1 + ((Math_imul($0, $item_start) | 0) + $level) | 0] | 0; if ($2 << 24 >> 24 <= 64) { ___assert_func(3400, 439, 6400, 1496); return 0; } if (!($2 << 24 >> 24 < 91 | $2 << 24 >> 24 == 104)) { ___assert_func(3400, 439, 6400, 1496); return 0; } $add = $item_start + 1 | 0; if ($add >>> 0 < $item_end >>> 0) { $3 = HEAP32[$spelling_buf_ >> 2] | 0; $4 = HEAP32[$spelling_size_ >> 2] | 0; $i_0214 = $add; $char_for_node_0215 = $2; $num_of_son_0216 = 0; while (1) { $5 = HEAP8[$3 + ((Math_imul($4, $i_0214) | 0) + $level) | 0] | 0; $num_of_son_0_inc = ($5 << 24 >> 24 != $char_for_node_0215 << 24 >> 24) + $num_of_son_0216 & 65535; $inc23 = $i_0214 + 1 | 0; if ($inc23 >>> 0 < $item_end >>> 0) { $i_0214 = $inc23; $char_for_node_0215 = $5; $num_of_son_0216 = $num_of_son_0_inc; } else { break; } } $num_of_son_0_lcssa = $num_of_son_0_inc + 1 & 65535; } else { $num_of_son_0_lcssa = 1; } $conv25 = $num_of_son_0_lcssa & 65535; $node_num_ = $this + 284 | 0; HEAP32[$node_num_ >> 2] = (HEAP32[$node_num_ >> 2] | 0) + $conv25; $umul_with_overflow = $conv25 << 3; $call = __Znaj($umul_with_overflow) | 0; $7 = $call; _memset($call | 0, 0, $umul_with_overflow | 0); $8 = HEAP32[$spelling_buf_ >> 2] | 0; $mul31 = Math_imul(HEAP32[$spelling_size_ >> 2] | 0, $item_start) | 0; $add_ptr32 = $8 + $mul31 | 0; $10 = HEAP8[$8 + ($mul31 + $level) | 0] | 0; $add34 = $level + 1 | 0; $cmp37 = (HEAP8[$8 + ($mul31 + $add34) | 0] | 0) == 0; L2694 : do { if ($add >>> 0 < $item_end >>> 0) { $cmp61 = ($level | 0) == 0; $cmp149 = ($level | 0) == 1; $spelling_endable_1_off0193 = $cmp37; $item_start_next_0194 = $item_start; $i40_0197 = $add; $son_pos_0201 = 0; $char_for_node_2205 = $10; $spelling_last_start_0206 = $add_ptr32; $min_son_score_0207 = -1; while (1) { $12 = HEAP32[$spelling_buf_ >> 2] | 0; $mul48 = Math_imul(HEAP32[$spelling_size_ >> 2] | 0, $i40_0197) | 0; $add_ptr49 = $12 + $mul48 | 0; $14 = HEAP8[$12 + ($mul48 + $level) | 0] | 0; if (!(__ZN10ime_pinyin12SpellingTrie17is_valid_spl_charEc($14) | 0)) { break; } $conv57 = $char_for_node_2205 << 24 >> 24; if ($14 << 24 >> 24 == $char_for_node_2205 << 24 >> 24) { $min_son_score_2 = $min_son_score_0207; $spelling_last_start_1 = $spelling_last_start_0206; $char_for_node_3 = $char_for_node_2205; $son_pos_1 = $son_pos_0201; $item_start_next_1 = $item_start_next_0194; $spelling_endable_3_off0 = $spelling_endable_1_off0193; } else { $add_ptr60 = $7 + ($son_pos_0201 << 3) | 0; HEAP8[$7 + ($son_pos_0201 << 3) + 6 | 0] = $char_for_node_2205; if ($cmp61) { HEAP32[$this + 56 + ($conv57 - 65 << 2) >> 2] = $add_ptr60; } if ($spelling_endable_1_off0193) { $16 = $7 + ($son_pos_0201 << 3) + 4 | 0; HEAP16[$16 >> 1] = HEAP16[$16 >> 1] & -2048 | $item_start_next_0194 + 30 & 2047; } $arrayidx71 = $spelling_last_start_0206 + $add34 | 0; $20 = HEAP8[$arrayidx71] | 0; do { if ($20 << 24 >> 24 == 0) { if (($i40_0197 - $item_start_next_0194 | 0) >>> 0 > 1) { $21 = HEAP8[$arrayidx71] | 0; label = 2126; break; } else { HEAP32[$add_ptr60 >> 2] = 0; HEAP8[$7 + ($son_pos_0201 << 3) + 7 | 0] = HEAP8[$spelling_last_start_0206 + ((HEAP32[$spelling_size_ >> 2] | 0) - 1) | 0] | 0; break; } } else { $21 = $20; label = 2126; } } while (0); do { if ((label | 0) == 2126) { label = 0; $cmp81 = $21 << 24 >> 24 == 0; HEAP32[$add_ptr60 >> 2] = __ZN10ime_pinyin12SpellingTrie26construct_spellings_subsetEjjjPNS_12SpellingNodeE($this, ($cmp81 & 1) + $item_start_next_0194 | 0, $i40_0197, $add34, $add_ptr60) | 0; if (!$cmp81) { break; } $23 = HEAP8[$spelling_last_start_0206 + ((HEAP32[$spelling_size_ >> 2] | 0) - 1) | 0] | 0; $score = $7 + ($son_pos_0201 << 3) + 7 | 0; if (($23 & 255) >= (HEAPU8[$score] | 0)) { break; } HEAP8[$score] = $23; } } while (0); $27 = HEAP8[$7 + ($son_pos_0201 << 3) + 7 | 0] | 0; $_min_son_score_0 = ($27 & 255) < ($min_son_score_0207 & 255) ? $27 : $min_son_score_0207; do { if ($cmp61) { if (!(__ZNK10ime_pinyin12SpellingTrie11is_szm_charEc(0, $char_for_node_2205) | 0)) { break; } $29 = $7 + ($son_pos_0201 << 3) + 4 | 0; $bf_value140_pn = (($conv57 + 1984 & 65535) + ($char_for_node_2205 << 24 >> 24 > 67) & 65535) + ($char_for_node_2205 << 24 >> 24 > 83) & 2047; HEAP16[$29 >> 1] = HEAP16[$29 >> 1] & -2048 | $bf_value140_pn; HEAP16[$this + 220 + (($bf_value140_pn & 65535) << 1) >> 1] = $i40_0197 - $item_start_next_0194 & 65535; label = 2138; } else { if (!($cmp149 & $char_for_node_2205 << 24 >> 24 == 104)) { break; } $32 = HEAP8[$spelling_last_start_0206] | 0; if (($32 << 24 >> 24 | 0) == 83) { $part_id_0174 = 21; } else if (($32 << 24 >> 24 | 0) == 67) { $part_id_0174 = 4; } else { $cmp164 = $32 << 24 >> 24 == 90; if ($cmp164) { $part_id_0174 = $cmp164 ? 29 : 0; } else { break; } } $34 = $7 + ($son_pos_0201 << 3) + 4 | 0; HEAP16[$34 >> 1] = HEAP16[$34 >> 1] & -2048 | $part_id_0174; HEAP16[$this + 220 + (($part_id_0174 & 65535) << 1) >> 1] = $i40_0197 - $item_start_next_0194 & 65535; label = 2138; } } while (0); do { if ((label | 0) == 2138) { label = 0; $idxprom188 = HEAP16[$7 + ($son_pos_0201 << 3) + 4 >> 1] & 2047; if ((HEAP16[$this + 220 + ($idxprom188 << 1) >> 1] | 0) == 0) { HEAP16[$this + 160 + ($idxprom188 << 1) >> 1] = 0; break; } else { HEAP16[$this + 160 + ($idxprom188 << 1) >> 1] = $item_start_next_0194 + 30 & 65535; break; } } } while (0); $min_son_score_2 = $_min_son_score_0; $spelling_last_start_1 = $add_ptr49; $char_for_node_3 = $14; $son_pos_1 = $son_pos_0201 + 1 | 0; $item_start_next_1 = $i40_0197; $spelling_endable_3_off0 = (HEAP8[$12 + ($mul48 + $add34) | 0] | 0) == 0; } $inc217 = $i40_0197 + 1 | 0; if ($inc217 >>> 0 < $item_end >>> 0) { $spelling_endable_1_off0193 = $spelling_endable_3_off0; $item_start_next_0194 = $item_start_next_1; $i40_0197 = $inc217; $son_pos_0201 = $son_pos_1; $char_for_node_2205 = $char_for_node_3; $spelling_last_start_0206 = $spelling_last_start_1; $min_son_score_0207 = $min_son_score_2; } else { $spelling_endable_1_off0_lcssa = $spelling_endable_3_off0; $item_start_next_0_lcssa = $item_start_next_1; $son_pos_0_lcssa = $son_pos_1; $char_for_node_2_lcssa = $char_for_node_3; $spelling_last_start_0_lcssa = $spelling_last_start_1; $min_son_score_0_lcssa = $min_son_score_2; break L2694; } } ___assert_func(3400, 474, 6400, 1280); return 0; } else { $spelling_endable_1_off0_lcssa = $cmp37; $item_start_next_0_lcssa = $item_start; $son_pos_0_lcssa = 0; $char_for_node_2_lcssa = $10; $spelling_last_start_0_lcssa = $add_ptr32; $min_son_score_0_lcssa = -1; } } while (0); $add_ptr220 = $7 + ($son_pos_0_lcssa << 3) | 0; HEAP8[$7 + ($son_pos_0_lcssa << 3) + 6 | 0] = $char_for_node_2_lcssa; $cmp222 = ($level | 0) == 0; if ($cmp222) { HEAP32[$this + 56 + (($char_for_node_2_lcssa << 24 >> 24) - 65 << 2) >> 2] = $add_ptr220; } if ($spelling_endable_1_off0_lcssa) { $44 = $7 + ($son_pos_0_lcssa << 3) + 4 | 0; HEAP16[$44 >> 1] = HEAP16[$44 >> 1] & -2048 | $item_start_next_0_lcssa + 30 & 2047; } $arrayidx237 = $spelling_last_start_0_lcssa + $add34 | 0; $48 = HEAP8[$arrayidx237] | 0; do { if ($48 << 24 >> 24 == 0) { if (($item_end - $item_start_next_0_lcssa | 0) >>> 0 > 1) { $49 = HEAP8[$arrayidx237] | 0; label = 2150; break; } else { HEAP32[$add_ptr220 >> 2] = 0; HEAP8[$7 + ($son_pos_0_lcssa << 3) + 7 | 0] = HEAP8[$spelling_last_start_0_lcssa + ((HEAP32[$spelling_size_ >> 2] | 0) - 1) | 0] | 0; break; } } else { $49 = $48; label = 2150; } } while (0); do { if ((label | 0) == 2150) { $cmp248 = $49 << 24 >> 24 == 0; HEAP32[$add_ptr220 >> 2] = __ZN10ime_pinyin12SpellingTrie26construct_spellings_subsetEjjjPNS_12SpellingNodeE($this, ($cmp248 & 1) + $item_start_next_0_lcssa | 0, $item_end, $add34, $add_ptr220) | 0; if (!$cmp248) { break; } $51 = HEAP8[$spelling_last_start_0_lcssa + ((HEAP32[$spelling_size_ >> 2] | 0) - 1) | 0] | 0; $score264 = $7 + ($son_pos_0_lcssa << 3) + 7 | 0; if (($51 & 255) >= (HEAPU8[$score264] | 0)) { break; } HEAP8[$score264] = $51; } } while (0); $55 = HEAP8[$7 + ($son_pos_0_lcssa << 3) + 7 | 0] | 0; $_min_son_score_0166 = ($55 & 255) < ($min_son_score_0_lcssa & 255) ? $55 : $min_son_score_0_lcssa; if (($son_pos_0_lcssa + 1 | 0) != ($conv25 | 0)) { ___assert_func(3400, 598, 6400, 1048); return 0; } do { if ($cmp222) { if (!(__ZNK10ime_pinyin12SpellingTrie14szm_is_enabledEc(0, $char_for_node_2_lcssa) | 0)) { break; } $57 = $7 + ($son_pos_0_lcssa << 3) + 4 | 0; $bf_value318_pn = (($char_for_node_2_lcssa << 24 >> 24 > 67 ? 1985 : 1984) + ($char_for_node_2_lcssa << 24 >> 24) & 65535) + ($char_for_node_2_lcssa << 24 >> 24 > 83) & 2047; HEAP16[$57 >> 1] = HEAP16[$57 >> 1] & -2048 | $bf_value318_pn; HEAP16[$this + 220 + (($bf_value318_pn & 65535) << 1) >> 1] = $item_end - $item_start_next_0_lcssa & 65535; label = 2164; } else { if (!(($level | 0) == 1 & $char_for_node_2_lcssa << 24 >> 24 == 104)) { break; } $60 = HEAP8[$spelling_last_start_0_lcssa] | 0; if (($60 << 24 >> 24 | 0) == 67) { $part_id336_0180 = 4; } else if (($60 << 24 >> 24 | 0) == 83) { $part_id336_0180 = 21; } else { $cmp346 = $60 << 24 >> 24 == 90; if ($cmp346) { $part_id336_0180 = $cmp346 ? 29 : 0; } else { break; } } $62 = $7 + ($son_pos_0_lcssa << 3) + 4 | 0; HEAP16[$62 >> 1] = HEAP16[$62 >> 1] & -2048 | $part_id336_0180; HEAP16[$this + 220 + (($part_id336_0180 & 65535) << 1) >> 1] = $item_end - $item_start_next_0_lcssa & 65535; label = 2164; } } while (0); do { if ((label | 0) == 2164) { $idxprom370 = HEAP16[$7 + ($son_pos_0_lcssa << 3) + 4 >> 1] & 2047; if ((HEAP16[$this + 220 + ($idxprom370 << 1) >> 1] | 0) == 0) { HEAP16[$this + 160 + ($idxprom370 << 1) >> 1] = 0; break; } else { HEAP16[$this + 160 + ($idxprom370 << 1) >> 1] = $item_start_next_0_lcssa + 30 & 65535; break; } } } while (0); $71 = $parent + 4 | 0; HEAP16[$71 >> 1] = HEAP16[$71 >> 1] & 2047 | $num_of_son_0_lcssa << 11; HEAP8[$parent + 7 | 0] = $_min_son_score_0166; $retval_0 = $7; return $retval_0 | 0; } function __ZN10ime_pinyin12SpellingTrie13build_ym_infoEv($this) { $this = $this | 0; var $ym_item_size = 0, $ym_num = 0, $call = 0, $0 = 0, $spelling_num_ = 0, $spelling_buf_ = 0, $spelling_size_ = 0, $conv25 = 0, $pos_024 = 0, $5 = 0, $call4 = 0, $call13 = 0, $ym_buf_ = 0, $9 = 0, $call19 = 0, $mul32 = 0, $spl_ym_ids_ = 0, $19 = 0, $call46 = 0, $conv5720 = 0, $id_019 = 0, $call63 = 0, $call68 = 0, $inc81 = 0, $conv57 = 0, $retval_0 = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16 | 0; $ym_item_size = sp | 0; $ym_num = sp + 8 | 0; $call = __Znwj(56) | 0; $0 = $call; __ZN10ime_pinyin13SpellingTableC2Ev($0); if (!(__ZN10ime_pinyin13SpellingTable10init_tableEjjb($0, 5, 128, 0) | 0)) { ___assert_func(3400, 372, 6536, 2888); return 0; } $spelling_num_ = $this + 8 | 0; L2775 : do { if ((HEAP32[$spelling_num_ >> 2] | 0) != 0) { $spelling_buf_ = $this | 0; $spelling_size_ = $this + 4 | 0; $pos_024 = 0; $conv25 = 0; while (1) { $5 = HEAP32[$spelling_buf_ >> 2] | 0; $call4 = __ZN10ime_pinyin12SpellingTrie10get_ym_strEPKc(0, $5 + (Math_imul(HEAP32[$spelling_size_ >> 2] | 0, $conv25) | 0) | 0) | 0; if ((HEAP8[$call4] | 0) != 0) { if (!(__ZN10ime_pinyin13SpellingTable12put_spellingEPKcd($0, $call4, 0.0) | 0)) { break; } } $pos_024 = $pos_024 + 1 & 65535; $conv25 = $pos_024 & 65535; if ($conv25 >>> 0 >= (HEAP32[$spelling_num_ >> 2] | 0) >>> 0) { break L2775; } } ___assert_func(3400, 379, 6536, 2888); return 0; } } while (0); $call13 = __ZN10ime_pinyin13SpellingTable7arrangeEPjS1_($0, $ym_item_size, $ym_num) | 0; $ym_buf_ = $this + 24 | 0; $9 = HEAP32[$ym_buf_ >> 2] | 0; if (($9 | 0) != 0) { __ZdaPv($9); } $call19 = __Znaj(Math_imul(HEAP32[$ym_num >> 2] | 0, HEAP32[$ym_item_size >> 2] | 0) | 0) | 0; HEAP32[$ym_buf_ >> 2] = $call19; if (($call19 | 0) == 0) { if (($call | 0) == 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } __ZN10ime_pinyin13SpellingTableD2Ev($0); __ZdlPv($call); $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } $mul32 = Math_imul(HEAP32[$ym_num >> 2] | 0, HEAP32[$ym_item_size >> 2] | 0) | 0; _memcpy($call19 | 0, $call13 | 0, $mul32) | 0; HEAP32[$this + 28 >> 2] = HEAP32[$ym_item_size >> 2]; HEAP32[$this + 32 >> 2] = HEAP32[$ym_num >> 2]; if (($call | 0) != 0) { __ZN10ime_pinyin13SpellingTableD2Ev($0); __ZdlPv($call); } $spl_ym_ids_ = $this + 20 | 0; $19 = HEAP32[$spl_ym_ids_ >> 2] | 0; if (($19 | 0) != 0) { __ZdlPv($19); } $call46 = __Znaj((HEAP32[$spelling_num_ >> 2] | 0) + 30 | 0) | 0; HEAP32[$spl_ym_ids_ >> 2] = $call46; if (($call46 | 0) == 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } _memset($call46 | 0, 0, (HEAP32[$spelling_num_ >> 2] | 0) + 30 | 0); if (((HEAP32[$spelling_num_ >> 2] | 0) + 30 | 0) >>> 0 > 1) { $id_019 = 1; $conv5720 = 1; } else { $retval_0 = 1; STACKTOP = sp; return $retval_0 | 0; } while (1) { $call63 = __ZN10ime_pinyin12SpellingTrie10get_ym_strEPKc(0, __ZN10ime_pinyin12SpellingTrie16get_spelling_strEt($this, $id_019) | 0) | 0; if ((HEAP8[$call63] | 0) == 0) { HEAP8[(HEAP32[$spl_ym_ids_ >> 2] | 0) + $conv5720 | 0] = 0; } else { $call68 = __ZN10ime_pinyin12SpellingTrie9get_ym_idEPKc($this, $call63) | 0; HEAP8[(HEAP32[$spl_ym_ids_ >> 2] | 0) + $conv5720 | 0] = $call68; if ($call68 << 24 >> 24 == 0) { label = 2200; break; } } $inc81 = $id_019 + 1 & 65535; $conv57 = $inc81 & 65535; if ($conv57 >>> 0 < ((HEAP32[$spelling_num_ >> 2] | 0) + 30 | 0) >>> 0) { $id_019 = $inc81; $conv5720 = $conv57; } else { $retval_0 = 1; label = 2207; break; } } if ((label | 0) == 2207) { STACKTOP = sp; return $retval_0 | 0; } else if ((label | 0) == 2200) { ___assert_func(3400, 418, 6536, 1992); return 0; } return 0; } function __ZN10ime_pinyin4SyncD2Ev($this) { $this = $this | 0; return; } function __ZN10ime_pinyin12SpellingTrie16get_spelling_numEv($this) { $this = $this | 0; return HEAP32[$this + 8 >> 2] | 0; } function __ZN10ime_pinyin12SpellingTrie18get_spelling_str16Et($this, $splid) { $this = $this | 0; $splid = $splid | 0; var $splstr16_queried_ = 0, $spelling_size_ = 0, $1 = 0, $conv5 = 0, $spelling_buf_ = 0, $2 = 0, $pos_014 = 0, $add = 0, $dec_splid = 0, $18 = 0; $splstr16_queried_ = $this + 40 | 0; HEAP16[HEAP32[$splstr16_queried_ >> 2] >> 1] = 0; if (($splid & 65535) > 29) { $spelling_size_ = $this + 4 | 0; $1 = HEAP32[$spelling_size_ >> 2] | 0; if (($1 | 0) == 0) { $18 = HEAP32[$splstr16_queried_ >> 2] | 0; return $18 | 0; } $conv5 = $splid - 30 & 65535; $spelling_buf_ = $this | 0; $pos_014 = 0; $2 = $1; do { $add = (Math_imul($2, $conv5) | 0) + $pos_014 | 0; HEAP16[(HEAP32[$splstr16_queried_ >> 2] | 0) + ($pos_014 << 1) >> 1] = HEAP8[(HEAP32[$spelling_buf_ >> 2] | 0) + $add | 0] | 0; $pos_014 = $pos_014 + 1 | 0; $2 = HEAP32[$spelling_size_ >> 2] | 0; } while ($pos_014 >>> 0 < $2 >>> 0); $18 = HEAP32[$splstr16_queried_ >> 2] | 0; return $18 | 0; } if (($splid << 16 >> 16 | 0) == 21) { HEAP16[HEAP32[$splstr16_queried_ >> 2] >> 1] = 83; HEAP16[(HEAP32[$splstr16_queried_ >> 2] | 0) + 2 >> 1] = 104; HEAP16[(HEAP32[$splstr16_queried_ >> 2] | 0) + 4 >> 1] = 0; $18 = HEAP32[$splstr16_queried_ >> 2] | 0; return $18 | 0; } else if (($splid << 16 >> 16 | 0) == 29) { HEAP16[HEAP32[$splstr16_queried_ >> 2] >> 1] = 90; HEAP16[(HEAP32[$splstr16_queried_ >> 2] | 0) + 2 >> 1] = 104; HEAP16[(HEAP32[$splstr16_queried_ >> 2] | 0) + 4 >> 1] = 0; $18 = HEAP32[$splstr16_queried_ >> 2] | 0; return $18 | 0; } else if (($splid << 16 >> 16 | 0) == 4) { HEAP16[HEAP32[$splstr16_queried_ >> 2] >> 1] = 67; HEAP16[(HEAP32[$splstr16_queried_ >> 2] | 0) + 2 >> 1] = 104; HEAP16[(HEAP32[$splstr16_queried_ >> 2] | 0) + 4 >> 1] = 0; $18 = HEAP32[$splstr16_queried_ >> 2] | 0; return $18 | 0; } else { $dec_splid = ((($splid & 65535) > 3) << 31 >> 31) + $splid & 65535; HEAP16[HEAP32[$splstr16_queried_ >> 2] >> 1] = ($dec_splid + 64 & 65535) + ((($dec_splid & 65535) > 19) << 31 >> 31) & 65535; HEAP16[(HEAP32[$splstr16_queried_ >> 2] | 0) + 2 >> 1] = 0; $18 = HEAP32[$splstr16_queried_ >> 2] | 0; return $18 | 0; } return 0; } function __ZN10ime_pinyin12SpellingTrie18get_spelling_str16EtPtj($this, $splid, $splstr16, $splstr16_len) { $this = $this | 0; $splid = $splid | 0; $splstr16 = $splstr16 | 0; $splstr16_len = $splstr16_len | 0; var $conv8 = 0, $spelling_size_ = 0, $spelling_buf_ = 0, $pos_0 = 0, $add = 0, $2 = 0, $dec_splid = 0, $retval_0 = 0, label = 0; if (($splstr16 | 0) == 0 | $splstr16_len >>> 0 < 7) { $retval_0 = 0; return $retval_0 | 0; } if (($splid & 65535) > 29) { $conv8 = $splid - 30 & 65535; $spelling_size_ = $this + 4 | 0; $spelling_buf_ = $this | 0; $pos_0 = 0; while (1) { if ($pos_0 >>> 0 >= 7) { $retval_0 = 0; label = 2239; break; } $add = (Math_imul(HEAP32[$spelling_size_ >> 2] | 0, $conv8) | 0) + $pos_0 | 0; $2 = HEAP8[(HEAP32[$spelling_buf_ >> 2] | 0) + $add | 0] | 0; HEAP16[$splstr16 + ($pos_0 << 1) >> 1] = $2 << 24 >> 24; if ($2 << 24 >> 24 == 0) { $retval_0 = $pos_0; label = 2245; break; } else { $pos_0 = $pos_0 + 1 | 0; } } if ((label | 0) == 2245) { return $retval_0 | 0; } else if ((label | 0) == 2239) { return $retval_0 | 0; } } if (($splid << 16 >> 16 | 0) == 29) { HEAP16[$splstr16 >> 1] = 90; HEAP16[$splstr16 + 2 >> 1] = 104; HEAP16[$splstr16 + 4 >> 1] = 0; $retval_0 = 2; return $retval_0 | 0; } else if (($splid << 16 >> 16 | 0) == 21) { HEAP16[$splstr16 >> 1] = 83; HEAP16[$splstr16 + 2 >> 1] = 104; HEAP16[$splstr16 + 4 >> 1] = 0; $retval_0 = 2; return $retval_0 | 0; } else if (($splid << 16 >> 16 | 0) == 4) { HEAP16[$splstr16 >> 1] = 67; HEAP16[$splstr16 + 2 >> 1] = 104; HEAP16[$splstr16 + 4 >> 1] = 0; $retval_0 = 2; return $retval_0 | 0; } else { $dec_splid = ((($splid & 65535) > 3) << 31 >> 31) + $splid & 65535; HEAP16[$splstr16 >> 1] = ($dec_splid + 64 & 65535) + ((($dec_splid & 65535) > 19) << 31 >> 31) & 65535; HEAP16[$splstr16 + 2 >> 1] = 0; $retval_0 = 1; return $retval_0 | 0; } return 0; } function __ZN10ime_pinyin4SyncC2Ev($this) { $this = $this | 0; HEAP32[$this >> 2] = 0; HEAP32[$this + 4 >> 2] = 0; HEAP32[$this + 8 >> 2] = 0; return; } function __ZN10ime_pinyin4Sync18get_last_got_countEv($this) { $this = $this | 0; return HEAP32[$this + 8 >> 2] | 0; } function _utf16_strtok($utf16_str, $token_size, $utf16_str_next) { $utf16_str = $utf16_str | 0; $token_size = $token_size | 0; $utf16_str_next = $utf16_str_next | 0; var $pos_0 = 0, $arrayidx = 0, $0 = 0, $pos_1 = 0, $arrayidx_sum = 0, $arrayidx13 = 0, $1 = 0, $retval_0 = 0, label = 0; if (($utf16_str | 0) == 0 | ($token_size | 0) == 0 | ($utf16_str_next | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } else { $pos_0 = 0; } while (1) { $arrayidx = $utf16_str + ($pos_0 << 1) | 0; $0 = HEAP16[$arrayidx >> 1] | 0; if (!(($0 << 16 >> 16 | 0) == 32 | ($0 << 16 >> 16 | 0) == 10 | ($0 << 16 >> 16 | 0) == 9)) { $pos_1 = 0; break; } $pos_0 = $pos_0 + 1 | 0; } while (1) { $arrayidx_sum = $pos_1 + $pos_0 | 0; $arrayidx13 = $utf16_str + ($arrayidx_sum << 1) | 0; $1 = HEAP16[$arrayidx13 >> 1] | 0; if (($1 << 16 >> 16 | 0) == 9 | ($1 << 16 >> 16 | 0) == 10 | ($1 << 16 >> 16 | 0) == 32) { label = 2254; break; } else if (($1 << 16 >> 16 | 0) == 0) { label = 2253; break; } $pos_1 = $pos_1 + 1 | 0; } do { if ((label | 0) == 2254) { HEAP32[$utf16_str_next >> 2] = $utf16_str + ($arrayidx_sum + 1 << 1); } else if ((label | 0) == 2253) { HEAP32[$utf16_str_next >> 2] = 0; if (($pos_1 | 0) == 0) { $retval_0 = 0; } else { break; } return $retval_0 | 0; } } while (0); HEAP16[$arrayidx13 >> 1] = 0; HEAP32[$token_size >> 2] = $pos_1; $retval_0 = $arrayidx; return $retval_0 | 0; } function _utf16_atoi($utf16_str) { $utf16_str = $utf16_str | 0; var $cmp1 = 0, $_ = 0, $_10 = 0, $1 = 0, $3 = 0, $pos_014 = 0, $value_013 = 0, $add = 0, $inc12 = 0, $4 = 0, $value_0_lcssa = 0, $retval_0 = 0; if (($utf16_str | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $cmp1 = (HEAP16[$utf16_str >> 1] | 0) == 45; $_ = $cmp1 ? -1 : 1; $_10 = $cmp1 & 1; $1 = HEAP16[$utf16_str + ($_10 << 1) >> 1] | 0; if (($1 - 48 & 65535) < 10) { $value_013 = 0; $pos_014 = $_10; $3 = $1; while (1) { $add = ($value_013 * 10 | 0) - 48 + ($3 & 65535) | 0; $inc12 = $pos_014 + 1 | 0; $4 = HEAP16[$utf16_str + ($inc12 << 1) >> 1] | 0; if (($4 - 48 & 65535) < 10) { $value_013 = $add; $pos_014 = $inc12; $3 = $4; } else { $value_0_lcssa = $add; break; } } } else { $value_0_lcssa = 0; } $retval_0 = Math_imul($value_0_lcssa, $_) | 0; return $retval_0 | 0; } function _utf16_strlen($utf16_str) { $utf16_str = $utf16_str | 0; var $size_0 = 0, $retval_0 = 0; if (($utf16_str | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } else { $size_0 = 0; } while (1) { if ((HEAP16[$utf16_str + ($size_0 << 1) >> 1] | 0) == 0) { $retval_0 = $size_0; break; } else { $size_0 = $size_0 + 1 | 0; } } return $retval_0 | 0; } function _utf16_strcpy_tochar($dst, $src) { $dst = $dst | 0; $src = $src | 0; var $0 = 0, $cp_010 = 0, $src_addr_09 = 0, $incdec_ptr = 0, $incdec_ptr4 = 0, $1 = 0, $retval_0 = 0; if (($src | 0) == 0 | ($dst | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $0 = HEAP16[$src >> 1] | 0; HEAP8[$dst] = $0 & 255; if ($0 << 16 >> 16 == 0) { $retval_0 = $dst; return $retval_0 | 0; } else { $src_addr_09 = $src; $cp_010 = $dst; } while (1) { $incdec_ptr = $cp_010 + 1 | 0; $incdec_ptr4 = $src_addr_09 + 2 | 0; $1 = HEAP16[$incdec_ptr4 >> 1] | 0; HEAP8[$incdec_ptr] = $1 & 255; if ($1 << 16 >> 16 == 0) { $retval_0 = $dst; break; } else { $src_addr_09 = $incdec_ptr4; $cp_010 = $incdec_ptr; } } return $retval_0 | 0; } function _utf16_strcmp($str1, $str2) { $str1 = $str1 | 0; $str2 = $str2 | 0; var $pos_0 = 0, $0 = 0, $1 = 0; $pos_0 = 0; while (1) { $0 = HEAP16[$str1 + ($pos_0 << 1) >> 1] | 0; $1 = HEAP16[$str2 + ($pos_0 << 1) >> 1] | 0; if ($0 << 16 >> 16 == $1 << 16 >> 16 & $0 << 16 >> 16 != 0) { $pos_0 = $pos_0 + 1 | 0; } else { break; } } return ($0 & 65535) - ($1 & 65535) | 0; } function _utf16_strncmp($str1, $str2, $size) { $str1 = $str1 | 0; $str2 = $str2 | 0; $size = $size | 0; var $pos_0 = 0, $0 = 0, $retval_0 = 0; $pos_0 = 0; while (1) { if ($pos_0 >>> 0 >= $size >>> 0) { break; } $0 = HEAP16[$str1 + ($pos_0 << 1) >> 1] | 0; if ($0 << 16 >> 16 == (HEAP16[$str2 + ($pos_0 << 1) >> 1] | 0) & $0 << 16 >> 16 != 0) { $pos_0 = $pos_0 + 1 | 0; } else { break; } } if (($pos_0 | 0) == ($size | 0)) { $retval_0 = 0; return $retval_0 | 0; } $retval_0 = (HEAPU16[$str1 + ($pos_0 << 1) >> 1] | 0) - (HEAPU16[$str2 + ($pos_0 << 1) >> 1] | 0) | 0; return $retval_0 | 0; } function _utf16_strcpy($dst, $src) { $dst = $dst | 0; $src = $src | 0; var $0 = 0, $cp_09 = 0, $src_addr_08 = 0, $incdec_ptr = 0, $incdec_ptr3 = 0, $1 = 0, $retval_0 = 0; if (($src | 0) == 0 | ($dst | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $0 = HEAP16[$src >> 1] | 0; HEAP16[$dst >> 1] = $0; if ($0 << 16 >> 16 == 0) { $retval_0 = $dst; return $retval_0 | 0; } else { $src_addr_08 = $src; $cp_09 = $dst; } while (1) { $incdec_ptr = $cp_09 + 2 | 0; $incdec_ptr3 = $src_addr_08 + 2 | 0; $1 = HEAP16[$incdec_ptr3 >> 1] | 0; HEAP16[$incdec_ptr >> 1] = $1; if ($1 << 16 >> 16 == 0) { $retval_0 = $dst; break; } else { $src_addr_08 = $incdec_ptr3; $cp_09 = $incdec_ptr; } } return $retval_0 | 0; } function _utf16_strncpy($dst, $src, $size) { $dst = $dst | 0; $src = $src | 0; $size = $size | 0; var $src_addr_0 = 0, $size_addr_0 = 0, $cp_0 = 0, $0 = 0, $retval_0 = 0; L2923 : do { if (($src | 0) == 0 | ($dst | 0) == 0 | ($size | 0) == 0) { $retval_0 = 0; } else { if (($src | 0) == ($dst | 0)) { $retval_0 = $dst; break; } if ($dst >>> 0 < $src >>> 0) { $cp_0 = $dst; $size_addr_0 = $size; $src_addr_0 = $src; } else { if ($dst >>> 0 <= $src >>> 0) { $retval_0 = $dst; break; } if (($src + ($size << 1) | 0) >>> 0 > $dst >>> 0) { $retval_0 = $dst; break; } else { $cp_0 = $dst; $size_addr_0 = $size; $src_addr_0 = $src; } } while (1) { if (($size_addr_0 | 0) == 0) { $retval_0 = $dst; break L2923; } $0 = HEAP16[$src_addr_0 >> 1] | 0; HEAP16[$cp_0 >> 1] = $0; if ($0 << 16 >> 16 == 0) { $retval_0 = $dst; break; } else { $cp_0 = $cp_0 + 2 | 0; $size_addr_0 = $size_addr_0 - 1 | 0; $src_addr_0 = $src_addr_0 + 2 | 0; } } } } while (0); return $retval_0 | 0; } function __ZN10ime_pinyin12SpellingTrie13load_spl_trieEP7__sFILE($this, $fp) { $this = $this | 0; $fp = $fp | 0; var $spelling_size_ = 0, $spelling_num_ = 0, $score_amplifier_ = 0, $average_score_ = 0, $spelling_buf_ = 0, $3 = 0, $call23 = 0, $call33 = 0, $8 = 0, $retval_0 = 0; if (($fp | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $spelling_size_ = $this + 4 | 0; if ((_fread($spelling_size_ | 0, 4, 1, $fp | 0) | 0) != 1) { $retval_0 = 0; return $retval_0 | 0; } $spelling_num_ = $this + 8 | 0; if ((_fread($spelling_num_ | 0, 4, 1, $fp | 0) | 0) != 1) { $retval_0 = 0; return $retval_0 | 0; } $score_amplifier_ = $this + 12 | 0; if ((_fread($score_amplifier_ | 0, 4, 1, $fp | 0) | 0) != 1) { $retval_0 = 0; return $retval_0 | 0; } $average_score_ = $this + 16 | 0; if ((_fread($average_score_ | 0, 1, 1, $fp | 0) | 0) != 1) { $retval_0 = 0; return $retval_0 | 0; } $spelling_buf_ = $this | 0; $3 = HEAP32[$spelling_buf_ >> 2] | 0; if (($3 | 0) != 0) { __ZdaPv($3); } $call23 = __Znaj(Math_imul(HEAP32[$spelling_num_ >> 2] | 0, HEAP32[$spelling_size_ >> 2] | 0) | 0) | 0; HEAP32[$spelling_buf_ >> 2] = $call23; if (($call23 | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $call33 = _fread($call23 | 0, HEAP32[$spelling_size_ >> 2] | 0, HEAP32[$spelling_num_ >> 2] | 0, $fp | 0) | 0; $8 = HEAP32[$spelling_num_ >> 2] | 0; if (($call33 | 0) != ($8 | 0)) { $retval_0 = 0; return $retval_0 | 0; } $retval_0 = __ZN10ime_pinyin12SpellingTrie9constructEPKcjjfh($this, HEAP32[$spelling_buf_ >> 2] | 0, HEAP32[$spelling_size_ >> 2] | 0, $8, +HEAPF32[$score_amplifier_ >> 2], HEAP8[$average_score_] | 0) | 0; return $retval_0 | 0; } function __ZN10ime_pinyin4Sync5beginEPKc($this, $filename) { $this = $this | 0; $filename = $filename | 0; var $userdict_ = 0, $call = 0, $dictfile_ = 0, $call9 = 0, $1 = 0, $call19 = 0, $7 = 0, $retval_0 = 0; $userdict_ = $this | 0; if ((HEAP32[$userdict_ >> 2] | 0) != 0) { __ZN10ime_pinyin4Sync6finishEv($this); } if (($filename | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $call = _strdup($filename | 0) | 0; $dictfile_ = $this + 4 | 0; HEAP32[$dictfile_ >> 2] = $call; if (($call | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $call9 = __Znwj(1132) | 0; $1 = $call9; __ZN10ime_pinyin8UserDictC2Ev($1); HEAP32[$userdict_ >> 2] = $1; if (($call9 | 0) == 0) { _free(HEAP32[$dictfile_ >> 2] | 0); HEAP32[$dictfile_ >> 2] = 0; $retval_0 = 0; return $retval_0 | 0; } $call19 = FUNCTION_TABLE_iiiii[HEAP32[(HEAP32[$call9 >> 2] | 0) + 8 >> 2] & 31]($1, HEAP32[$dictfile_ >> 2] | 0, 500001, 6e5) | 0; $7 = HEAP32[$userdict_ >> 2] | 0; if ($call19) { __ZN10ime_pinyin8UserDict9set_limitEjjj($7, 5e3, 2e5, 20); $retval_0 = 1; return $retval_0 | 0; } if (($7 | 0) != 0) { FUNCTION_TABLE_vi[HEAP32[(HEAP32[$7 >> 2] | 0) + 4 >> 2] & 127]($7); } HEAP32[$userdict_ >> 2] = 0; _free(HEAP32[$dictfile_ >> 2] | 0); HEAP32[$dictfile_ >> 2] = 0; $retval_0 = 0; return $retval_0 | 0; } function __ZN10ime_pinyin4Sync6finishEv($this) { $this = $this | 0; var $userdict_ = 0, $0 = 0, $3 = 0, $dictfile_ = 0; $userdict_ = $this | 0; $0 = HEAP32[$userdict_ >> 2] | 0; if (($0 | 0) == 0) { return; } FUNCTION_TABLE_ii[HEAP32[(HEAP32[$0 >> 2] | 0) + 12 >> 2] & 31]($0) | 0; $3 = HEAP32[$userdict_ >> 2] | 0; if (($3 | 0) != 0) { FUNCTION_TABLE_vi[HEAP32[(HEAP32[$3 >> 2] | 0) + 4 >> 2] & 127]($3); } HEAP32[$userdict_ >> 2] = 0; $dictfile_ = $this + 4 | 0; _free(HEAP32[$dictfile_ >> 2] | 0); HEAP32[$dictfile_ >> 2] = 0; HEAP32[$this + 8 >> 2] = 0; return; } function __ZN10ime_pinyin4Sync10put_lemmasEPti($this, $lemmas, $len) { $this = $this | 0; $lemmas = $lemmas | 0; $len = $len | 0; return __ZN10ime_pinyin8UserDict38put_lemmas_no_sync_from_utf16le_stringEPti(HEAP32[$this >> 2] | 0, $lemmas, $len) | 0; } function __ZN10ime_pinyin4Sync10get_lemmasEPti($this, $str, $size) { $this = $this | 0; $str = $str | 0; $size = $size | 0; return __ZN10ime_pinyin8UserDict48get_sync_lemmas_in_utf16le_string_from_beginningEPtiPi(HEAP32[$this >> 2] | 0, $str, $size, $this + 8 | 0) | 0; } function __ZN10ime_pinyin4Sync15get_total_countEv($this) { $this = $this | 0; return __ZN10ime_pinyin8UserDict14get_sync_countEv(HEAP32[$this >> 2] | 0) | 0; } function __ZN10ime_pinyin4Sync14clear_last_gotEv($this) { $this = $this | 0; var $last_count_ = 0, $0 = 0; $last_count_ = $this + 8 | 0; $0 = HEAP32[$last_count_ >> 2] | 0; if (($0 | 0) < 0) { return; } __ZN10ime_pinyin8UserDict17clear_sync_lemmasEjj(HEAP32[$this >> 2] | 0, 0, $0); HEAP32[$last_count_ >> 2] = 0; return; } function __ZN10ime_pinyin4Sync12get_capacityEv($this) { $this = $this | 0; var $stat = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 64 | 0; $stat = sp | 0; __ZN10ime_pinyin8UserDict5stateEPNS0_12UserDictStatE(HEAP32[$this >> 2] | 0, $stat) | 0; STACKTOP = sp; return (HEAP32[$stat + 52 >> 2] | 0) - (HEAP32[$stat + 28 >> 2] | 0) | 0; } function _utf16_atof($utf16_str) { $utf16_str = $utf16_str | 0; var $arraydecay = 0, $retval_0 = 0.0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 256 | 0; if ((_utf16_strlen($utf16_str) | 0) >>> 0 > 255) { $retval_0 = 0.0; STACKTOP = sp; return +$retval_0; } $arraydecay = sp | 0; _utf16_strcpy_tochar($arraydecay, $utf16_str) | 0; $retval_0 = +_atof($arraydecay); STACKTOP = sp; return +$retval_0; } function __ZN10ime_pinyin8DictListC2Ev($this) { $this = $this | 0; HEAP8[$this | 0] = 0; _memset($this + 8 | 0, 0, 16); HEAP32[$this + 4 >> 2] = __ZN10ime_pinyin12SpellingTrie14get_cpinstanceEv() | 0; HEAP32[$this + 96 >> 2] = 14; HEAP32[$this + 100 >> 2] = 18; HEAP32[$this + 104 >> 2] = 10; HEAP32[$this + 108 >> 2] = 12; HEAP32[$this + 112 >> 2] = 8; HEAP32[$this + 116 >> 2] = 32; HEAP32[$this + 120 >> 2] = 46; HEAP32[$this + 124 >> 2] = 38; return; } function __ZN10ime_pinyin8DictListD2Ev($this) { $this = $this | 0; __ZN10ime_pinyin8DictList13free_resourceEv($this); return; } function __ZN10ime_pinyin8DictList13free_resourceEv($this) { $this = $this | 0; var $buf_ = 0, $0 = 0, $scis_hz_ = 0, $2 = 0, $scis_splid_ = 0, $4 = 0; $buf_ = $this + 20 | 0; $0 = HEAP32[$buf_ >> 2] | 0; if (($0 | 0) != 0) { _free($0); } HEAP32[$buf_ >> 2] = 0; $scis_hz_ = $this + 12 | 0; $2 = HEAP32[$scis_hz_ >> 2] | 0; if (($2 | 0) != 0) { _free($2); } HEAP32[$scis_hz_ >> 2] = 0; $scis_splid_ = $this + 16 | 0; $4 = HEAP32[$scis_splid_ >> 2] | 0; if (($4 | 0) == 0) { HEAP32[$scis_splid_ >> 2] = 0; return; } _free($4 | 0); HEAP32[$scis_splid_ >> 2] = 0; return; } function __ZN10ime_pinyin8DictList14alloc_resourceEjj($this, $buf_size, $scis_num) { $this = $this | 0; $buf_size = $buf_size | 0; $scis_num = $scis_num | 0; var $call = 0, $scis_num_ = 0, $call5 = 0, $call12 = 0, $retval_0 = 0; $call = _malloc($buf_size << 1) | 0; HEAP32[$this + 20 >> 2] = $call; if (($call | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $scis_num_ = $this + 8 | 0; HEAP32[$scis_num_ >> 2] = $scis_num; $call5 = _malloc($scis_num << 1) | 0; HEAP32[$this + 12 >> 2] = $call5; if (($call5 | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $call12 = _malloc(HEAP32[$scis_num_ >> 2] << 1) | 0; HEAP32[$this + 16 >> 2] = $call12; $retval_0 = ($call12 | 0) != 0; return $retval_0 | 0; } function __ZN10ime_pinyin8DictList9init_listEPKNS_14SingleCharItemEjPKNS_10LemmaEntryEj($this, $scis, $scis_num, $lemma_arr, $lemma_num) { $this = $this | 0; $scis = $scis | 0; $scis_num = $scis_num | 0; $lemma_arr = $lemma_arr | 0; $lemma_num = $lemma_num | 0; var $initialized_ = 0, $0 = 0, $call = 0, $retval_0 = 0; if (($scis | 0) == 0 | ($scis_num | 0) == 0 | ($lemma_arr | 0) == 0 | ($lemma_num | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $initialized_ = $this | 0; HEAP8[$initialized_] = 0; $0 = HEAP32[$this + 20 >> 2] | 0; if (($0 | 0) != 0) { _free($0); } $call = __ZN10ime_pinyin8DictList14calculate_sizeEPKNS_10LemmaEntryEj($this, $lemma_arr, $lemma_num) | 0; if (($call | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } if (!(__ZN10ime_pinyin8DictList14alloc_resourceEjj($this, $call, $scis_num) | 0)) { $retval_0 = 0; return $retval_0 | 0; } __ZN10ime_pinyin8DictList9fill_scisEPKNS_14SingleCharItemEj($this, $scis, $scis_num); __ZN10ime_pinyin8DictList9fill_listEPKNS_10LemmaEntryEj($this, $lemma_arr, $lemma_num); HEAP8[$initialized_] = 1; $retval_0 = 1; return $retval_0 | 0; } function __ZN10ime_pinyin8DictList13get_lemma_strEjPtt($this, $id_lemma, $str_buf, $str_max) { $this = $this | 0; $id_lemma = $id_lemma | 0; $str_buf = $str_buf | 0; $str_max = $str_max | 0; var $sub = 0, $3 = 0, $_lcssa = 0, $add_lcssa29 = 0, $i_024_lcssa28 = 0, $conv625_lcssa27 = 0, $5 = 0, $6 = 0, $add_ptr_sum = 0, $conv3221 = 0, $len_020 = 0, $inc = 0, $retval_0 = 0, $8 = 0, $10 = 0, $12 = 0, $14 = 0, $16 = 0, $18 = 0, $20 = 0, label = 0; if ((HEAP8[$this | 0] & 1) == 0) { $retval_0 = 0; return $retval_0 | 0; } if ((HEAP32[$this + 92 >> 2] | 0) >>> 0 <= $id_lemma >>> 0 | ($str_buf | 0) == 0 | ($str_max & 65535) < 2) { $retval_0 = 0; return $retval_0 | 0; } $sub = ($str_max & 65535) - 1 | 0; if (($sub | 0) < 1) { $retval_0 = 0; return $retval_0 | 0; } $3 = HEAP32[$this + 60 >> 2] | 0; if ($3 >>> 0 > $id_lemma >>> 0) { label = 2401; } else { if ((HEAP32[$this + 64 >> 2] | 0) >>> 0 > $id_lemma >>> 0) { $conv625_lcssa27 = 0; $i_024_lcssa28 = 0; $add_lcssa29 = 1; $_lcssa = $3; } else { label = 2401; } } do { if ((label | 0) == 2401) { if (($sub | 0) < 2) { $retval_0 = 0; return $retval_0 | 0; } $8 = HEAP32[$this + 64 >> 2] | 0; if ($8 >>> 0 <= $id_lemma >>> 0) { if ((HEAP32[$this + 68 >> 2] | 0) >>> 0 > $id_lemma >>> 0) { $conv625_lcssa27 = 1; $i_024_lcssa28 = 1; $add_lcssa29 = 2; $_lcssa = $8; break; } } if (($sub | 0) < 3) { $retval_0 = 0; return $retval_0 | 0; } $10 = HEAP32[$this + 68 >> 2] | 0; if ($10 >>> 0 <= $id_lemma >>> 0) { if ((HEAP32[$this + 72 >> 2] | 0) >>> 0 > $id_lemma >>> 0) { $conv625_lcssa27 = 2; $i_024_lcssa28 = 2; $add_lcssa29 = 3; $_lcssa = $10; break; } } if (($sub | 0) < 4) { $retval_0 = 0; return $retval_0 | 0; } $12 = HEAP32[$this + 72 >> 2] | 0; if ($12 >>> 0 <= $id_lemma >>> 0) { if ((HEAP32[$this + 76 >> 2] | 0) >>> 0 > $id_lemma >>> 0) { $conv625_lcssa27 = 3; $i_024_lcssa28 = 3; $add_lcssa29 = 4; $_lcssa = $12; break; } } if (($sub | 0) < 5) { $retval_0 = 0; return $retval_0 | 0; } $14 = HEAP32[$this + 76 >> 2] | 0; if ($14 >>> 0 <= $id_lemma >>> 0) { if ((HEAP32[$this + 80 >> 2] | 0) >>> 0 > $id_lemma >>> 0) { $conv625_lcssa27 = 4; $i_024_lcssa28 = 4; $add_lcssa29 = 5; $_lcssa = $14; break; } } if (($sub | 0) < 6) { $retval_0 = 0; return $retval_0 | 0; } $16 = HEAP32[$this + 80 >> 2] | 0; if ($16 >>> 0 <= $id_lemma >>> 0) { if ((HEAP32[$this + 84 >> 2] | 0) >>> 0 > $id_lemma >>> 0) { $conv625_lcssa27 = 5; $i_024_lcssa28 = 5; $add_lcssa29 = 6; $_lcssa = $16; break; } } if (($sub | 0) < 7) { $retval_0 = 0; return $retval_0 | 0; } $18 = HEAP32[$this + 84 >> 2] | 0; if ($18 >>> 0 <= $id_lemma >>> 0) { if ((HEAP32[$this + 88 >> 2] | 0) >>> 0 > $id_lemma >>> 0) { $conv625_lcssa27 = 6; $i_024_lcssa28 = 6; $add_lcssa29 = 7; $_lcssa = $18; break; } } if (($sub | 0) < 8) { $retval_0 = 0; return $retval_0 | 0; } $20 = HEAP32[$this + 88 >> 2] | 0; if ($20 >>> 0 > $id_lemma >>> 0) { $retval_0 = 0; return $retval_0 | 0; } if ((HEAP32[$this + 92 >> 2] | 0) >>> 0 > $id_lemma >>> 0) { $conv625_lcssa27 = 7; $i_024_lcssa28 = 7; $add_lcssa29 = 8; $_lcssa = $20; break; } else { $retval_0 = 0; } return $retval_0 | 0; } } while (0); $5 = HEAP32[$this + 20 >> 2] | 0; $6 = HEAP32[$this + 24 + ($conv625_lcssa27 << 2) >> 2] | 0; $add_ptr_sum = $6 + (Math_imul($id_lemma - $_lcssa | 0, $add_lcssa29) | 0) | 0; $len_020 = 0; $conv3221 = 0; while (1) { HEAP16[$str_buf + ($conv3221 << 1) >> 1] = HEAP16[$5 + ($add_ptr_sum + $conv3221 << 1) >> 1] | 0; $inc = $len_020 + 1 & 65535; if (($inc & 65535) > ($i_024_lcssa28 & 65535)) { break; } else { $len_020 = $inc; $conv3221 = $inc & 65535; } } HEAP16[$str_buf + ($add_lcssa29 << 1) >> 1] = 0; $retval_0 = $add_lcssa29 & 65535; return $retval_0 | 0; } function __ZN10ime_pinyin8DictList21find_pos2_startedbyhzEt($this, $hz_char) { $this = $this | 0; $hz_char = $hz_char | 0; var $hz_char_addr = 0, $buf_ = 0, $arrayidx = 0, $2 = 0, $call = 0, $add_ptr9 = 0, $found_2w_0 = 0, $retval_0 = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 8 | 0; $hz_char_addr = sp | 0; HEAP16[$hz_char_addr >> 1] = $hz_char; $buf_ = $this + 20 | 0; $arrayidx = $this + 28 | 0; $2 = HEAP32[$arrayidx >> 2] | 0; $call = __ZN10ime_pinyin9mybsearchEPKvS1_jjPFiS1_S1_E($hz_char_addr, (HEAP32[$buf_ >> 2] | 0) + ($2 << 1) | 0, ((HEAP32[$this + 32 >> 2] | 0) - $2 | 0) >>> 1, 4, 14) | 0; if (($call | 0) == 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } $add_ptr9 = (HEAP32[$buf_ >> 2] | 0) + (HEAP32[$arrayidx >> 2] << 1) | 0; $found_2w_0 = $call; while (1) { if ($found_2w_0 >>> 0 <= $add_ptr9 >>> 0) { $retval_0 = $found_2w_0; label = 2442; break; } if ((HEAP16[$found_2w_0 >> 1] | 0) == (HEAP16[$found_2w_0 - 2 >> 1] | 0)) { $found_2w_0 = $found_2w_0 - 4 | 0; } else { $retval_0 = $found_2w_0; label = 2441; break; } } if ((label | 0) == 2442) { STACKTOP = sp; return $retval_0 | 0; } else if ((label | 0) == 2441) { STACKTOP = sp; return $retval_0 | 0; } return 0; } function __ZN10ime_pinyin8DictList21find_pos_startedbyhzsEPKtjPFiPKvS4_E($this, $last_hzs, $word_len, $cmp_func) { $this = $this | 0; $last_hzs = $last_hzs | 0; $word_len = $word_len | 0; $cmp_func = $cmp_func | 0; var $buf_ = 0, $arrayidx = 0, $2 = 0, $call = 0, $idx_neg = 0, $found_w_0 = 0, $add_ptr14 = 0, $retval_0 = 0, label = 0; $buf_ = $this + 20 | 0; $arrayidx = $this + 24 + ($word_len - 1 << 2) | 0; $2 = HEAP32[$arrayidx >> 2] | 0; $call = __ZN10ime_pinyin9mybsearchEPKvS1_jjPFiS1_S1_E($last_hzs, (HEAP32[$buf_ >> 2] | 0) + ($2 << 1) | 0, (((HEAP32[$this + 24 + ($word_len << 2) >> 2] | 0) - $2 | 0) >>> 0) / ($word_len >>> 0) | 0, $word_len << 1, $cmp_func) | 0; if (($call | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $idx_neg = -$word_len | 0; $found_w_0 = $call; while (1) { if ($found_w_0 >>> 0 <= ((HEAP32[$buf_ >> 2] | 0) + (HEAP32[$arrayidx >> 2] << 1) | 0) >>> 0) { $retval_0 = $found_w_0; label = 2450; break; } $add_ptr14 = $found_w_0 + ($idx_neg << 1) | 0; if ((FUNCTION_TABLE_iii[$cmp_func & 63]($found_w_0, $add_ptr14) | 0) == 0) { $found_w_0 = $add_ptr14; } else { $retval_0 = $found_w_0; label = 2449; break; } } if ((label | 0) == 2450) { return $retval_0 | 0; } else if ((label | 0) == 2449) { return $retval_0 | 0; } return 0; } function __ZN10ime_pinyin8DictList14calculate_sizeEPKNS_10LemmaEntryEj($this, $lemma_arr, $lemma_num) { $this = $this | 0; $lemma_arr = $lemma_arr | 0; $lemma_num = $lemma_num | 0; var $idx_by_hz = 0, $arrayidx9 = 0, $arrayidx10 = 0, $list_size_0_lcssa63 = 0, $id_num_0_lcssa62 = 0, $last_hz_len_0_lcssa61 = 0, $arrayidx56 = 0, $arrayidx58 = 0, $last_hz_len_052 = 0, $i_051 = 0, $id_num_050 = 0, $list_size_049 = 0, $0 = 0, $conv = 0, $inc = 0, $sub = 0, $len_038 = 0, $sub26 = 0, $inc40 = 0, $list_size_1 = 0, $id_num_1 = 0, $last_hz_len_1 = 0, $inc47 = 0, $i49_036 = 0, $inc66 = 0, $arrayidx69 = 0, $4 = 0, label = 0; do { if (($lemma_num | 0) == 0) { $last_hz_len_0_lcssa61 = 0; $id_num_0_lcssa62 = 0; $list_size_0_lcssa63 = 0; } else { $idx_by_hz = $lemma_arr + 4 | 0; $arrayidx9 = $this + 24 | 0; $arrayidx10 = $this + 60 | 0; $list_size_049 = 0; $id_num_050 = 0; $i_051 = 0; $last_hz_len_052 = 0; L3124 : while (1) { $0 = HEAP8[$lemma_arr + ($i_051 * 124 | 0) + 116 | 0] | 0; $conv = $0 & 255; do { if (($i_051 | 0) == 0) { if ($0 << 24 >> 24 == 0) { label = 2458; break L3124; } if ((HEAP32[$idx_by_hz >> 2] | 0) != 1) { label = 2460; break L3124; } $inc = $id_num_050 + 1 | 0; HEAP32[$arrayidx9 >> 2] = 0; HEAP32[$arrayidx10 >> 2] = $inc; $last_hz_len_1 = 1; $id_num_1 = $inc; $list_size_1 = $list_size_049 + 1 | 0; } else { if ($conv >>> 0 < $last_hz_len_052 >>> 0) { label = 2463; break L3124; } if (($conv | 0) == ($last_hz_len_052 | 0)) { $last_hz_len_1 = $last_hz_len_052; $id_num_1 = $id_num_050 + 1 | 0; $list_size_1 = $conv + $list_size_049 | 0; break; } $sub = $conv - 1 | 0; if ($last_hz_len_052 >>> 0 < $sub >>> 0) { $len_038 = $last_hz_len_052; do { $sub26 = $len_038 - 1 | 0; HEAP32[$this + 24 + ($len_038 << 2) >> 2] = HEAP32[$this + 24 + ($sub26 << 2) >> 2]; HEAP32[$this + 60 + ($len_038 << 2) >> 2] = HEAP32[$this + 60 + ($sub26 << 2) >> 2]; $len_038 = $len_038 + 1 | 0; } while ($len_038 >>> 0 < $sub >>> 0); } HEAP32[$this + 24 + ($sub << 2) >> 2] = $list_size_049; $inc40 = $id_num_050 + 1 | 0; HEAP32[$this + 60 + ($sub << 2) >> 2] = $inc40; $last_hz_len_1 = $conv; $id_num_1 = $inc40; $list_size_1 = $conv + $list_size_049 | 0; } } while (0); $inc47 = $i_051 + 1 | 0; if ($inc47 >>> 0 < $lemma_num >>> 0) { $list_size_049 = $list_size_1; $id_num_050 = $id_num_1; $i_051 = $inc47; $last_hz_len_052 = $last_hz_len_1; } else { label = 2454; break; } } if ((label | 0) == 2458) { ___assert_func(2896, 122, 5992, 4008); return 0; } else if ((label | 0) == 2454) { if ($last_hz_len_1 >>> 0 < 9) { $last_hz_len_0_lcssa61 = $last_hz_len_1; $id_num_0_lcssa62 = $id_num_1; $list_size_0_lcssa63 = $list_size_1; break; } $arrayidx69 = $this + 56 | 0; $4 = HEAP32[$arrayidx69 >> 2] | 0; return $4 | 0; } else if ((label | 0) == 2460) { ___assert_func(2896, 123, 5992, 2800); return 0; } else if ((label | 0) == 2463) { ___assert_func(2896, 134, 5992, 1904); return 0; } } } while (0); $arrayidx56 = $this + 24 | 0; $arrayidx58 = $this + 60 | 0; $i49_036 = $last_hz_len_0_lcssa61; while (1) { if (($i49_036 | 0) == 0) { HEAP32[$arrayidx56 >> 2] = 0; HEAP32[$arrayidx58 >> 2] = 1; $i49_036 = $i49_036 + 1 | 0; continue; } else { HEAP32[$this + 24 + ($i49_036 << 2) >> 2] = $list_size_0_lcssa63; HEAP32[$this + 60 + ($i49_036 << 2) >> 2] = $id_num_0_lcssa62; $inc66 = $i49_036 + 1 | 0; if ($inc66 >>> 0 < 9) { $i49_036 = $inc66; continue; } else { break; } } } $arrayidx69 = $this + 56 | 0; $4 = HEAP32[$arrayidx69 >> 2] | 0; return $4 | 0; } function __ZN10ime_pinyin8DictList9fill_scisEPKNS_14SingleCharItemEj($this, $scis, $scis_num) { $this = $this | 0; $scis = $scis | 0; $scis_num = $scis_num | 0; var $scis_num_ = 0, $scis_hz_ = 0, $scis_splid_ = 0, $pos_08 = 0; $scis_num_ = $this + 8 | 0; if ((HEAP32[$scis_num_ >> 2] | 0) != ($scis_num | 0)) { ___assert_func(2896, 170, 5504, 1472); } if ((HEAP32[$scis_num_ >> 2] | 0) == 0) { return; } $scis_hz_ = $this + 12 | 0; $scis_splid_ = $this + 16 | 0; $pos_08 = 0; do { HEAP16[(HEAP32[$scis_hz_ >> 2] | 0) + ($pos_08 << 1) >> 1] = HEAP16[$scis + ($pos_08 << 3) + 4 >> 1] | 0; HEAP16[(HEAP32[$scis_splid_ >> 2] | 0) + ($pos_08 << 1) >> 1] = HEAP16[$scis + ($pos_08 << 3) + 6 >> 1] | 0; $pos_08 = $pos_08 + 1 | 0; } while ($pos_08 >>> 0 < (HEAP32[$scis_num_ >> 2] | 0) >>> 0); return; } function __ZN10ime_pinyin8DictList9fill_listEPKNS_10LemmaEntryEj($this, $lemma_arr, $lemma_num) { $this = $this | 0; $lemma_arr = $lemma_arr | 0; $lemma_num = $lemma_num | 0; var $buf_ = 0, $hz_str_len = 0, $conv5 = 0, $i_016 = 0, $current_pos_014 = 0, $hz_str_len11 = 0, $inc17 = 0, $add = 0, $id_num_0_lcssa = 0, $current_pos_0_lcssa = 0; $buf_ = $this + 20 | 0; $hz_str_len = $lemma_arr + 116 | 0; _utf16_strncpy(HEAP32[$buf_ >> 2] | 0, $lemma_arr + 8 | 0, HEAPU8[$hz_str_len] | 0) | 0; $conv5 = HEAPU8[$hz_str_len] | 0; if ($lemma_num >>> 0 > 1) { $current_pos_014 = $conv5; $i_016 = 1; while (1) { $hz_str_len11 = $lemma_arr + ($i_016 * 124 | 0) + 116 | 0; _utf16_strncpy((HEAP32[$buf_ >> 2] | 0) + ($current_pos_014 << 1) | 0, $lemma_arr + ($i_016 * 124 | 0) + 8 | 0, HEAPU8[$hz_str_len11] | 0) | 0; $inc17 = $i_016 + 1 | 0; $add = (HEAPU8[$hz_str_len11] | 0) + $current_pos_014 | 0; if ($inc17 >>> 0 < $lemma_num >>> 0) { $current_pos_014 = $add; $i_016 = $inc17; } else { $current_pos_0_lcssa = $add; $id_num_0_lcssa = $lemma_num; break; } } } else { $current_pos_0_lcssa = $conv5; $id_num_0_lcssa = 1; } if (($current_pos_0_lcssa | 0) != (HEAP32[$this + 56 >> 2] | 0)) { ___assert_func(2896, 196, 5592, 1232); } if (($id_num_0_lcssa | 0) == (HEAP32[$this + 92 >> 2] | 0)) { return; } else { ___assert_func(2896, 197, 5592, 1008); } } function __ZN10ime_pinyin8DictList7predictEPKttPNS_12NPredictItemEjj($this, $last_hzs, $hzs_len, $npre_items, $npre_max, $b4_used) { $this = $this | 0; $last_hzs = $last_hzs | 0; $hzs_len = $hzs_len | 0; $npre_items = $npre_items | 0; $npre_max = $npre_max | 0; $b4_used = $b4_used | 0; var $conv = 0, $0 = 0, $call = 0, $sub7 = 0, $buf_ = 0, $1 = 0, $conv557 = 0, $item_num_056 = 0, $pre_len_055 = 0, $conv12 = 0, $call13 = 0, $arrayidx15 = 0, $sub29 = 0, $arrayidx31 = 0, $arrayidx36 = 0, $w_buf_052 = 0, $item_num_151 = 0, $add_ptr21 = 0, $inc = 0, $add_ptr42 = 0, $item_num_2 = 0, $inc43 = 0, $conv5 = 0, $i_048 = 0, $new_num_047 = 0, $arraydecay55 = 0, $e_pos_0 = 0, $11 = 0, $12 = 0, $new_num_1 = 0, $inc70 = 0, $new_num_0_lcssa = 0, label = 0; $conv = $hzs_len & 65535; if (($hzs_len & 65535) > 7 | $hzs_len << 16 >> 16 == 0) { ___assert_func(2896, 236, 5672, 848); return 0; } $0 = HEAP32[$this + 96 + ($conv - 1 << 2) >> 2] | 0; $call = __ZN10ime_pinyin5NGram12get_instanceEv() | 0; $sub7 = 8 - $conv | 0; if ($hzs_len << 16 >> 16 == 8) { $new_num_0_lcssa = 0; return $new_num_0_lcssa | 0; } $buf_ = $this + 20 | 0; $1 = $last_hzs; $pre_len_055 = 1; $item_num_056 = 0; $conv557 = 1; while (1) { $conv12 = $pre_len_055 + $hzs_len & 65535; $call13 = __ZN10ime_pinyin8DictList21find_pos_startedbyhzsEPKtjPFiPKvS4_E($this, $last_hzs, $conv12, $0) | 0; L3183 : do { if (($call13 | 0) == 0) { $item_num_2 = $item_num_056; } else { $arrayidx15 = $this + 24 + ($conv12 << 2) | 0; if ($call13 >>> 0 >= ((HEAP32[$buf_ >> 2] | 0) + (HEAP32[$arrayidx15 >> 2] << 1) | 0) >>> 0) { $item_num_2 = $item_num_056; break; } $sub29 = $conv12 - 1 | 0; $arrayidx31 = $this + 24 + ($sub29 << 2) | 0; $arrayidx36 = $this + 60 + ($sub29 << 2) | 0; $item_num_151 = $item_num_056; $w_buf_052 = $call13; while (1) { if (!((FUNCTION_TABLE_iii[$0 & 63]($w_buf_052, $1) | 0) == 0 & $item_num_151 >>> 0 < $npre_max >>> 0)) { $item_num_2 = $item_num_151; break L3183; } $add_ptr21 = $npre_items + ($item_num_151 * 20 | 0) | 0; _memset($add_ptr21 | 0, 0, 20); _utf16_strncpy($npre_items + ($item_num_151 * 20 | 0) + 4 | 0, $w_buf_052 + ($conv << 1) | 0, $conv557) | 0; HEAPF32[$add_ptr21 >> 2] = +__ZN10ime_pinyin5NGram11get_uni_psbEj($call, (HEAP32[$arrayidx36 >> 2] | 0) + (((($w_buf_052 - (HEAP32[$buf_ >> 2] | 0) >> 1) - (HEAP32[$arrayidx31 >> 2] | 0) | 0) >>> 0) / ($conv12 >>> 0) | 0) | 0); HEAP16[$npre_items + ($item_num_151 * 20 | 0) + 18 >> 1] = $hzs_len; $inc = $item_num_151 + 1 | 0; $add_ptr42 = $w_buf_052 + ($conv12 << 1) | 0; if ($add_ptr42 >>> 0 < ((HEAP32[$buf_ >> 2] | 0) + (HEAP32[$arrayidx15 >> 2] << 1) | 0) >>> 0) { $item_num_151 = $inc; $w_buf_052 = $add_ptr42; } else { $item_num_2 = $inc; break; } } } } while (0); $inc43 = $pre_len_055 + 1 & 65535; $conv5 = $inc43 & 65535; if ($conv5 >>> 0 > $sub7 >>> 0) { break; } else { $pre_len_055 = $inc43; $item_num_056 = $item_num_2; $conv557 = $conv5; } } if (($item_num_2 | 0) == 0) { $new_num_0_lcssa = 0; return $new_num_0_lcssa | 0; } else { $new_num_047 = 0; $i_048 = 0; } while (1) { $arraydecay55 = $npre_items + ($i_048 * 20 | 0) + 4 | 0; $e_pos_0 = 1; while (1) { if ($e_pos_0 >>> 0 > $b4_used >>> 0) { label = 2505; break; } if ((_utf16_strncmp($npre_items + ((-$e_pos_0 | 0) * 20 | 0) + 4 | 0, $arraydecay55, 7) | 0) == 0) { $new_num_1 = $new_num_047; break; } else { $e_pos_0 = $e_pos_0 + 1 | 0; } } if ((label | 0) == 2505) { label = 0; $11 = $npre_items + ($new_num_047 * 20 | 0) | 0; $12 = $npre_items + ($i_048 * 20 | 0) | 0; HEAP32[$11 >> 2] = HEAP32[$12 >> 2]; HEAP32[$11 + 4 >> 2] = HEAP32[$12 + 4 >> 2]; HEAP32[$11 + 8 >> 2] = HEAP32[$12 + 8 >> 2]; HEAP32[$11 + 12 >> 2] = HEAP32[$12 + 12 >> 2]; HEAP32[$11 + 16 >> 2] = HEAP32[$12 + 16 >> 2]; $new_num_1 = $new_num_047 + 1 | 0; } $inc70 = $i_048 + 1 | 0; if ($inc70 >>> 0 < $item_num_2 >>> 0) { $new_num_047 = $new_num_1; $i_048 = $inc70; } else { $new_num_0_lcssa = $new_num_1; break; } } return $new_num_0_lcssa | 0; } function __ZN10ime_pinyin8DictList20get_splids_for_hanziEttPtt($this, $hanzi, $half_splid, $splids, $max_splids) { $this = $this | 0; $hanzi = $hanzi | 0; $half_splid = $half_splid | 0; $splids = $splids | 0; $max_splids = $max_splids | 0; var $hanzi_addr = 0, $scis_hz_ = 0, $scis_num_ = 0, $call = 0, $4 = 0, $7 = 0, $8 = 0, $hz_found_0 = 0, $add_ptr = 0, $10 = 0, $12 = 0, $cmp23 = 0, $scis_splid_ = 0, $13 = 0, $hz_f_033 = 0, $strict_0_off032 = 0, $strict_0_off0_lcssa = 0, $15 = 0, $cmp48 = 0, $conv68 = 0, $scis_splid_74 = 0, $scis_splid_52 = 0, $spl_trie_ = 0, $scis_splid_62 = 0, $strict_1_off0 = 0, $incdec_ptr27 = 0, $20 = 0, $22 = 0, $hz_found_129 = 0, $found_num_028 = 0, $sub_ptr_div4523 = 0, $conv67 = 0, $found_num_1 = 0, $incdec_ptr80 = 0, $37 = 0, $found_num_0_lcssa = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 8 | 0; $hanzi_addr = sp | 0; HEAP16[$hanzi_addr >> 1] = $hanzi; $scis_hz_ = $this + 12 | 0; $scis_num_ = $this + 8 | 0; $call = __ZN10ime_pinyin9mybsearchEPKvS1_jjPFiS1_S1_E($hanzi_addr, HEAP32[$scis_hz_ >> 2] | 0, HEAP32[$scis_num_ >> 2] | 0, 2, 14) | 0; $4 = $call; if (($call | 0) == 0) { ___assert_func(2896, 314, 5768, 688); return 0; } if ((HEAP16[$hanzi_addr >> 1] | 0) != (HEAP16[$4 >> 1] | 0)) { ___assert_func(2896, 314, 5768, 688); return 0; } $7 = HEAP32[$scis_hz_ >> 2] | 0; $8 = HEAP16[$hanzi_addr >> 1] | 0; $hz_found_0 = $4; while (1) { if ($hz_found_0 >>> 0 <= $7 >>> 0) { break; } $add_ptr = $hz_found_0 - 2 | 0; if ($8 << 16 >> 16 == (HEAP16[$add_ptr >> 1] | 0)) { $hz_found_0 = $add_ptr; } else { break; } } $10 = HEAP32[$scis_hz_ >> 2] | 0; L3213 : do { if ($hz_found_0 >>> 0 < ($10 + (HEAP32[$scis_num_ >> 2] << 1) | 0) >>> 0) { $12 = HEAP16[$hanzi_addr >> 1] | 0; $cmp23 = $half_splid << 16 >> 16 == 0; $scis_splid_ = $this + 16 | 0; $strict_0_off032 = 0; $hz_f_033 = $hz_found_0; $13 = $10; while (1) { if ($12 << 16 >> 16 != (HEAP16[$hz_f_033 >> 1] | 0)) { $strict_0_off0_lcssa = $strict_0_off032; break L3213; } if ($cmp23) { label = 2524; } else { if ((HEAP16[(HEAP32[$scis_splid_ >> 2] | 0) + ((($hz_f_033 - $13 | 0) >>> 1 & 65535) << 1) >> 1] & 31) == $half_splid << 16 >> 16) { label = 2524; } else { $strict_1_off0 = $strict_0_off032; } } if ((label | 0) == 2524) { label = 0; $strict_1_off0 = 1; } $incdec_ptr27 = $hz_f_033 + 2 | 0; $20 = HEAP32[$scis_hz_ >> 2] | 0; if ($incdec_ptr27 >>> 0 < ($20 + (HEAP32[$scis_num_ >> 2] << 1) | 0) >>> 0) { $strict_0_off032 = $strict_1_off0; $hz_f_033 = $incdec_ptr27; $13 = $20; } else { $strict_0_off0_lcssa = $strict_1_off0; break; } } } else { $strict_0_off0_lcssa = 0; } } while (0); $15 = HEAP32[$scis_hz_ >> 2] | 0; if ($hz_found_0 >>> 0 >= ($15 + (HEAP32[$scis_num_ >> 2] << 1) | 0) >>> 0) { $found_num_0_lcssa = 0; STACKTOP = sp; return $found_num_0_lcssa | 0; } $cmp48 = $half_splid << 16 >> 16 == 0; $conv68 = $max_splids & 65535; $scis_splid_74 = $this + 16 | 0; $scis_splid_52 = $this + 16 | 0; $spl_trie_ = $this + 4 | 0; $scis_splid_62 = $this + 16 | 0; $found_num_028 = 0; $hz_found_129 = $hz_found_0; $22 = $15; while (1) { if ((HEAP16[$hanzi_addr >> 1] | 0) != (HEAP16[$hz_found_129 >> 1] | 0)) { $found_num_0_lcssa = $found_num_028; label = 2540; break; } $sub_ptr_div4523 = ($hz_found_129 - $22 | 0) >>> 1; do { if ($cmp48) { label = 2531; } else { if ($strict_0_off0_lcssa) { if ((HEAP16[(HEAP32[$scis_splid_52 >> 2] | 0) + (($sub_ptr_div4523 & 65535) << 1) >> 1] & 31) == $half_splid << 16 >> 16) { label = 2531; break; } else { $found_num_1 = $found_num_028; break; } } else { if (__ZNK10ime_pinyin12SpellingTrie20half_full_compatibleEtt(HEAP32[$spl_trie_ >> 2] | 0, $half_splid, (HEAPU16[(HEAP32[$scis_splid_62 >> 2] | 0) + (($sub_ptr_div4523 & 65535) << 1) >> 1] | 0) >>> 5) | 0) { label = 2531; break; } else { $found_num_1 = $found_num_028; break; } } } } while (0); if ((label | 0) == 2531) { label = 0; $conv67 = $found_num_028 & 65535; if (($conv67 + 1 | 0) >>> 0 >= $conv68 >>> 0) { label = 2532; break; } HEAP16[$splids + ($conv67 << 1) >> 1] = (HEAPU16[(HEAP32[$scis_splid_74 >> 2] | 0) + (($sub_ptr_div4523 & 65535) << 1) >> 1] | 0) >>> 5; $found_num_1 = $found_num_028 + 1 & 65535; } $incdec_ptr80 = $hz_found_129 + 2 | 0; $37 = HEAP32[$scis_hz_ >> 2] | 0; if ($incdec_ptr80 >>> 0 < ($37 + (HEAP32[$scis_num_ >> 2] << 1) | 0) >>> 0) { $found_num_028 = $found_num_1; $hz_found_129 = $incdec_ptr80; $22 = $37; } else { $found_num_0_lcssa = $found_num_1; label = 2538; break; } } if ((label | 0) == 2538) { STACKTOP = sp; return $found_num_0_lcssa | 0; } else if ((label | 0) == 2540) { STACKTOP = sp; return $found_num_0_lcssa | 0; } else if ((label | 0) == 2532) { ___assert_func(2896, 338, 5768, 544); return 0; } return 0; } function __ZN10ime_pinyin8DictList12get_lemma_idEPKtt($this, $str, $str_len) { $this = $this | 0; $str = $str | 0; $str_len = $str_len | 0; var $conv = 0, $sub = 0, $call = 0, $1 = 0, $sub_ptr_div = 0, $2 = 0, $retval_0 = 0; if (($str | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $conv = $str_len & 65535; if (($str_len & 65535) > 8) { $retval_0 = 0; return $retval_0 | 0; } $sub = $conv - 1 | 0; $call = __ZN10ime_pinyin8DictList21find_pos_startedbyhzsEPKtjPFiPKvS4_E($this, $str, $conv, HEAP32[$this + 96 + ($sub << 2) >> 2] | 0) | 0; if (($call | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $1 = HEAP32[$this + 20 >> 2] | 0; if ($call >>> 0 <= $1 >>> 0) { ___assert_func(2896, 356, 6080, 4352); return 0; } $sub_ptr_div = $call - $1 >> 1; $2 = HEAP32[$this + 24 + ($sub << 2) >> 2] | 0; if ($sub_ptr_div >>> 0 < $2 >>> 0) { ___assert_func(2896, 357, 6080, 4168); return 0; } $retval_0 = ((($sub_ptr_div - $2 | 0) >>> 0) / ($conv >>> 0) | 0) + (HEAP32[$this + 60 + ($sub << 2) >> 2] | 0) | 0; return $retval_0 | 0; } function __ZN10ime_pinyin8DictList17convert_to_hanzisEPtt($this, $str, $str_len) { $this = $this | 0; $str = $str | 0; $str_len = $str_len | 0; var $scis_hz_ = 0, $str_pos_07 = 0, $arrayidx = 0; if (($str | 0) == 0) { ___assert_func(2896, 364, 5928, 3992); } if ($str_len << 16 >> 16 == 0) { return; } $scis_hz_ = $this + 12 | 0; $str_pos_07 = 0; do { $arrayidx = $str + (($str_pos_07 & 65535) << 1) | 0; HEAP16[$arrayidx >> 1] = HEAP16[(HEAP32[$scis_hz_ >> 2] | 0) + ((HEAPU16[$arrayidx >> 1] | 0) << 1) >> 1] | 0; $str_pos_07 = $str_pos_07 + 1 & 65535; } while (($str_pos_07 & 65535) < ($str_len & 65535)); return; } function __ZN10ime_pinyin8DictList19convert_to_scis_idsEPtt($this, $str, $str_len) { $this = $this | 0; $str = $str | 0; $str_len = $str_len | 0; var $str_pos_05 = 0; if (($str | 0) == 0) { ___assert_func(2896, 372, 5856, 3992); } if ($str_len << 16 >> 16 == 0) { return; } else { $str_pos_05 = 0; } do { HEAP16[$str + (($str_pos_05 & 65535) << 1) >> 1] = 256; $str_pos_05 = $str_pos_05 + 1 & 65535; } while (($str_pos_05 & 65535) < ($str_len & 65535)); return; } function __ZN10ime_pinyin8LpiCache9is_cachedEt($this, $splid) { $this = $this | 0; $splid = $splid | 0; var $retval_0 = 0; if (($splid & 65535) > 29) { $retval_0 = 0; return $retval_0 | 0; } $retval_0 = (HEAP16[(HEAP32[$this + 4 >> 2] | 0) + (($splid & 65535) << 1) >> 1] | 0) != 0; return $retval_0 | 0; } function __ZN10ime_pinyin8LpiCache9put_cacheEtPNS_10LmaPsbItemEj($this, $splid, $lpi_items, $lpi_num) { $this = $this | 0; $splid = $splid | 0; $lpi_items = $lpi_items | 0; $lpi_num = $lpi_num | 0; var $conv2_ = 0, $0 = 0, $conv3 = 0, $mul = 0, $conv411 = 0, $pos_010 = 0, $3 = 0, $4 = 0, $5$1 = 0, $inc = 0; $conv2_ = $lpi_num >>> 0 < 15 ? $lpi_num & 65535 : 15; $0 = HEAP32[$this >> 2] | 0; $conv3 = $splid & 65535; $mul = $conv3 * 15 | 0; if ($conv2_ << 16 >> 16 != 0) { $pos_010 = 0; $conv411 = 0; while (1) { $3 = $lpi_items + ($conv411 << 3) | 0; $4 = $0 + ($conv411 + $mul << 3) | 0; $5$1 = HEAP32[$3 + 4 >> 2] | 0; HEAP32[$4 >> 2] = HEAP32[$3 >> 2]; HEAP32[$4 + 4 >> 2] = $5$1; $inc = $pos_010 + 1 & 65535; if (($inc & 65535) < ($conv2_ & 65535)) { $pos_010 = $inc; $conv411 = $inc & 65535; } else { break; } } } HEAP16[(HEAP32[$this + 4 >> 2] | 0) + ($conv3 << 1) >> 1] = $conv2_; return $conv2_ & 65535 | 0; } function __ZN10ime_pinyin8LpiCache9get_cacheEtPNS_10LmaPsbItemEj($this, $splid, $lpi_items, $lpi_max) { $this = $this | 0; $splid = $splid | 0; $lpi_items = $lpi_items | 0; $lpi_max = $lpi_max | 0; var $idxprom = 0, $conv = 0, $conv_lpi_max = 0, $2 = 0, $mul = 0, $conv710 = 0, $pos_09 = 0, $5 = 0, $6 = 0, $7$1 = 0; $idxprom = $splid & 65535; $conv = HEAPU16[(HEAP32[$this + 4 >> 2] | 0) + ($idxprom << 1) >> 1] | 0; $conv_lpi_max = $conv >>> 0 < $lpi_max >>> 0 ? $conv : $lpi_max; $2 = HEAP32[$this >> 2] | 0; $mul = $idxprom * 15 | 0; if (($conv_lpi_max | 0) == 0) { return $conv_lpi_max | 0; } else { $pos_09 = 0; $conv710 = 0; } do { $5 = $2 + ($conv710 + $mul << 3) | 0; $6 = $lpi_items + ($conv710 << 3) | 0; $7$1 = HEAP32[$5 + 4 >> 2] | 0; HEAP32[$6 >> 2] = HEAP32[$5 >> 2]; HEAP32[$6 + 4 >> 2] = $7$1; $pos_09 = $pos_09 + 1 & 65535; $conv710 = $pos_09 & 65535; } while ($conv710 >>> 0 < $conv_lpi_max >>> 0); return $conv_lpi_max | 0; } function __ZN10ime_pinyin13SpellingTableC2Ev($this) { $this = $this | 0; HEAP8[$this | 0] = 0; HEAP32[$this + 8 >> 2] = 0; HEAP32[$this + 12 >> 2] = 0; HEAP32[$this + 32 >> 2] = 0; HEAPF64[$this + 24 >> 3] = 0.0; HEAP8[$this + 49 | 0] = 1; return; } function __ZN10ime_pinyin13SpellingTable12get_hash_posEPKc($this, $spelling_str) { $this = $this | 0; $spelling_str = $spelling_str | 0; var $spelling_size_ = 0, $pos_09 = 0, $hash_pos_08 = 0, $1 = 0, $add = 0, $inc = 0, $hash_pos_0_lcssa = 0; $spelling_size_ = $this + 16 | 0; L3297 : do { if ((HEAP32[$spelling_size_ >> 2] | 0) == 0) { $hash_pos_0_lcssa = 0; } else { $hash_pos_08 = 0; $pos_09 = 0; while (1) { $1 = HEAP8[$spelling_str + $pos_09 | 0] | 0; if ($1 << 24 >> 24 == 0) { $hash_pos_0_lcssa = $hash_pos_08; break L3297; } $add = ($1 << 24 >> 24) + $hash_pos_08 | 0; $inc = $pos_09 + 1 | 0; if ($inc >>> 0 < (HEAP32[$spelling_size_ >> 2] | 0) >>> 0) { $hash_pos_08 = $add; $pos_09 = $inc; } else { $hash_pos_0_lcssa = $add; break; } } } } while (0); return ($hash_pos_0_lcssa >>> 0) % ((HEAP32[$this + 4 >> 2] | 0) >>> 0) | 0 | 0; } function __ZN10ime_pinyin13SpellingTable13hash_pos_nextEj($this, $hash_pos) { $this = $this | 0; $hash_pos = $hash_pos | 0; return (($hash_pos + 123 | 0) >>> 0) % ((HEAP32[$this + 4 >> 2] | 0) >>> 0) | 0 | 0; } function __ZN10ime_pinyin13SpellingTable19get_score_amplifierEv($this) { $this = $this | 0; return +(+HEAPF64[$this + 40 >> 3]); } function __ZN10ime_pinyin13SpellingTable17get_average_scoreEv($this) { $this = $this | 0; return HEAP8[$this + 48 | 0] | 0; } function __ZN10ime_pinyin8DictList9save_listEP7__sFILE($this, $fp) { $this = $this | 0; $fp = $fp | 0; var $buf_ = 0, $arrayidx = 0, $scis_hz_ = 0, $scis_splid_ = 0, $scis_num_ = 0, $call29 = 0, $13 = 0, $call36 = 0, $call44 = 0, $retval_0 = 0; if ((HEAP8[$this | 0] & 1) == 0 | ($fp | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $buf_ = $this + 20 | 0; if ((HEAP32[$buf_ >> 2] | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $arrayidx = $this + 56 | 0; if ((HEAP32[$arrayidx >> 2] | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $scis_hz_ = $this + 12 | 0; if ((HEAP32[$scis_hz_ >> 2] | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $scis_splid_ = $this + 16 | 0; if ((HEAP32[$scis_splid_ >> 2] | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $scis_num_ = $this + 8 | 0; if ((HEAP32[$scis_num_ >> 2] | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } if ((_fwrite($scis_num_ | 0, 4, 1, $fp | 0) | 0) != 1) { $retval_0 = 0; return $retval_0 | 0; } if ((_fwrite($this + 24 | 0, 4, 9, $fp | 0) | 0) != 9) { $retval_0 = 0; return $retval_0 | 0; } if ((_fwrite($this + 60 | 0, 4, 9, $fp | 0) | 0) != 9) { $retval_0 = 0; return $retval_0 | 0; } $call29 = _fwrite(HEAP32[$scis_hz_ >> 2] | 0, 2, HEAP32[$scis_num_ >> 2] | 0, $fp | 0) | 0; $13 = HEAP32[$scis_num_ >> 2] | 0; if (($call29 | 0) != ($13 | 0)) { $retval_0 = 0; return $retval_0 | 0; } $call36 = _fwrite(HEAP32[$scis_splid_ >> 2] | 0, 2, $13 | 0, $fp | 0) | 0; if (($call36 | 0) != (HEAP32[$scis_num_ >> 2] | 0)) { $retval_0 = 0; return $retval_0 | 0; } $call44 = _fwrite(HEAP32[$buf_ >> 2] | 0, 2, HEAP32[$arrayidx >> 2] | 0, $fp | 0) | 0; $retval_0 = ($call44 | 0) == (HEAP32[$arrayidx >> 2] | 0); return $retval_0 | 0; } function __ZN10ime_pinyin8DictList9load_listEP7__sFILE($this, $fp) { $this = $this | 0; $fp = $fp | 0; var $initialized_ = 0, $scis_num_ = 0, $arrayidx = 0, $call20 = 0, $8 = 0, $call26 = 0, $call33 = 0, $retval_0 = 0; if (($fp | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $initialized_ = $this | 0; HEAP8[$initialized_] = 0; $scis_num_ = $this + 8 | 0; if ((_fread($scis_num_ | 0, 4, 1, $fp | 0) | 0) != 1) { $retval_0 = 0; return $retval_0 | 0; } if ((_fread($this + 24 | 0, 4, 9, $fp | 0) | 0) != 9) { $retval_0 = 0; return $retval_0 | 0; } if ((_fread($this + 60 | 0, 4, 9, $fp | 0) | 0) != 9) { $retval_0 = 0; return $retval_0 | 0; } __ZN10ime_pinyin8DictList13free_resourceEv($this); $arrayidx = $this + 56 | 0; if (!(__ZN10ime_pinyin8DictList14alloc_resourceEjj($this, HEAP32[$arrayidx >> 2] | 0, HEAP32[$scis_num_ >> 2] | 0) | 0)) { $retval_0 = 0; return $retval_0 | 0; } $call20 = _fread(HEAP32[$this + 12 >> 2] | 0, 2, HEAP32[$scis_num_ >> 2] | 0, $fp | 0) | 0; $8 = HEAP32[$scis_num_ >> 2] | 0; if (($call20 | 0) != ($8 | 0)) { $retval_0 = 0; return $retval_0 | 0; } $call26 = _fread(HEAP32[$this + 16 >> 2] | 0, 2, $8 | 0, $fp | 0) | 0; if (($call26 | 0) != (HEAP32[$scis_num_ >> 2] | 0)) { $retval_0 = 0; return $retval_0 | 0; } $call33 = _fread(HEAP32[$this + 20 >> 2] | 0, 2, HEAP32[$arrayidx >> 2] | 0, $fp | 0) | 0; if (($call33 | 0) != (HEAP32[$arrayidx >> 2] | 0)) { $retval_0 = 0; return $retval_0 | 0; } HEAP8[$initialized_] = 1; $retval_0 = 1; return $retval_0 | 0; } function __ZN10ime_pinyin8LpiCacheD2Ev($this) { $this = $this | 0; var $0 = 0, $2 = 0; $0 = HEAP32[$this >> 2] | 0; if (($0 | 0) != 0) { __ZdaPv($0 | 0); } $2 = HEAP32[$this + 4 >> 2] | 0; if (($2 | 0) == 0) { return; } __ZdaPv($2); return; } function __ZN10ime_pinyin7myqsortEPvjjPFiPKvS2_E($p, $n, $es, $cmp) { $p = $p | 0; $n = $n | 0; $es = $es | 0; $cmp = $cmp | 0; _qsort($p | 0, $n | 0, $es | 0, $cmp | 0); return; } function __ZN10ime_pinyin9mybsearchEPKvS1_jjPFiS1_S1_E($k, $b, $n, $es, $cmp) { $k = $k | 0; $b = $b | 0; $n = $n | 0; $es = $es | 0; $cmp = $cmp | 0; return _bsearch($k | 0, $b | 0, $n | 0, $es | 0, $cmp | 0) | 0; } function __ZN10ime_pinyin18compare_raw_spl_ebEPKvS1_($p1, $p2) { $p1 = $p1 | 0; $p2 = $p2 | 0; var $retval_0 = 0; do { if ((HEAP8[$p1] | 0) == 0) { $retval_0 = 1; } else { if ((HEAP8[$p2] | 0) == 0) { $retval_0 = -1; break; } $retval_0 = _strcmp($p1 | 0, $p2 | 0) | 0; } } while (0); return $retval_0 | 0; } function __ZN10ime_pinyin12get_odd_nextEj($value) { $value = $value | 0; var $v_next_0 = 0, $add = 0, $v_dv_0 = 0; $v_next_0 = $value; L3382 : while (1) { $add = ~~+Math_sqrt(+(+($v_next_0 >>> 0 >>> 0))) + 1 | 0; $v_dv_0 = 2; while (1) { if ($v_dv_0 >>> 0 >= $add >>> 0) { break L3382; } if ((($v_next_0 >>> 0) % ($v_dv_0 >>> 0) | 0 | 0) == 0) { break; } else { $v_dv_0 = $v_dv_0 + 1 | 0; } } $v_next_0 = $v_next_0 + 1 | 0; } return $v_next_0 | 0; } function __ZN10ime_pinyin13SpellingTableD2Ev($this) { $this = $this | 0; __ZN10ime_pinyin13SpellingTable13free_resourceEv($this); return; } function __ZN10ime_pinyin13SpellingTable13free_resourceEv($this) { $this = $this | 0; var $raw_spellings_ = 0, $0 = 0, $spelling_buf_ = 0, $2 = 0; $raw_spellings_ = $this + 8 | 0; $0 = HEAP32[$raw_spellings_ >> 2] | 0; if (($0 | 0) != 0) { __ZdaPv($0 | 0); } HEAP32[$raw_spellings_ >> 2] = 0; $spelling_buf_ = $this + 12 | 0; $2 = HEAP32[$spelling_buf_ >> 2] | 0; if (($2 | 0) == 0) { HEAP32[$spelling_buf_ >> 2] = 0; return; } __ZdaPv($2); HEAP32[$spelling_buf_ >> 2] = 0; return; } function __ZN10ime_pinyin13SpellingTable10init_tableEjjb($this, $pure_spl_size, $spl_max_num, $need_score) { $this = $this | 0; $pure_spl_size = $pure_spl_size | 0; $spl_max_num = $spl_max_num | 0; $need_score = $need_score | 0; var $spelling_size_ = 0, $spelling_max_num_ = 0, $1$0 = 0, $raw_spellings_ = 0, $call13 = 0, $spelling_buf_ = 0, $8 = 0, $11 = 0, $retval_0 = 0; if (($pure_spl_size | 0) == 0 | ($spl_max_num | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } HEAP8[$this | 0] = $need_score & 1; __ZN10ime_pinyin13SpellingTable13free_resourceEv($this); $spelling_size_ = $this + 16 | 0; HEAP32[$spelling_size_ >> 2] = ($need_score ? 2 : 1) + $pure_spl_size; $spelling_max_num_ = $this + 4 | 0; HEAP32[$spelling_max_num_ >> 2] = __ZN10ime_pinyin12get_odd_nextEj($spl_max_num) | 0; HEAP32[$this + 32 >> 2] = 0; $1$0 = _llvm_umul_with_overflow_i32(HEAP32[$spelling_max_num_ >> 2] | 0, 16) | 0; $raw_spellings_ = $this + 8 | 0; HEAP32[$raw_spellings_ >> 2] = __Znaj(tempRet0 ? -1 : $1$0) | 0; $call13 = __Znaj(Math_imul(HEAP32[$spelling_size_ >> 2] | 0, HEAP32[$spelling_max_num_ >> 2] | 0) | 0) | 0; $spelling_buf_ = $this + 12 | 0; HEAP32[$spelling_buf_ >> 2] = $call13; $8 = HEAP32[$raw_spellings_ >> 2] | 0; if (($8 | 0) == 0 | ($call13 | 0) == 0) { __ZN10ime_pinyin13SpellingTable13free_resourceEv($this); $retval_0 = 0; return $retval_0 | 0; } else { _memset($8 | 0, 0, HEAP32[$spelling_max_num_ >> 2] << 4 | 0); $11 = HEAP32[$spelling_buf_ >> 2] | 0; _memset($11 | 0, 0, Math_imul(HEAP32[$spelling_size_ >> 2] | 0, HEAP32[$spelling_max_num_ >> 2] | 0) | 0); HEAP8[$this + 49 | 0] = 0; HEAPF64[$this + 24 >> 3] = 0.0; $retval_0 = 1; return $retval_0 | 0; } return 0; } function __ZN10ime_pinyin13SpellingTable12put_spellingEPKcd($this, $spelling_str, $freq) { $this = $this | 0; $spelling_str = $spelling_str | 0; $freq = +$freq; var $pos_0 = 0, $total_freq_ = 0, $call6 = 0, $spelling_size_ = 0, $raw_spellings_ = 0, $5 = 0, $7 = 0, $sub28 = 0, $freq20 = 0, $hash_pos_0 = 0, $arraydecay26 = 0, $freq34 = 0, $freq45 = 0, $arraydecay50 = 0, $sub52 = 0, $spelling_num_ = 0, $call62 = 0, $retval_0 = 0, label = 0; if ((HEAP8[$this + 49 | 0] & 1) != 0 | ($spelling_str | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } else { $pos_0 = 0; } while (1) { if ($pos_0 >>> 0 >= 3) { break; } if ((_strcmp($spelling_str | 0, 10896 + ($pos_0 * 7 | 0) | 0) | 0) == 0) { $retval_0 = 0; label = 2683; break; } else { $pos_0 = $pos_0 + 1 | 0; } } if ((label | 0) == 2683) { return $retval_0 | 0; } $total_freq_ = $this + 24 | 0; HEAPF64[$total_freq_ >> 3] = +HEAPF64[$total_freq_ >> 3] + $freq; $call6 = __ZN10ime_pinyin13SpellingTable12get_hash_posEPKc($this, $spelling_str) | 0; $spelling_size_ = $this + 16 | 0; $raw_spellings_ = $this + 8 | 0; HEAP8[(HEAP32[$spelling_size_ >> 2] | 0) - 1 + ((HEAP32[$raw_spellings_ >> 2] | 0) + ($call6 << 4)) | 0] = 0; $5 = HEAP32[$raw_spellings_ >> 2] | 0; if ((_strncmp($5 + ($call6 << 4) | 0, $spelling_str | 0, (HEAP32[$spelling_size_ >> 2] | 0) - 1 | 0) | 0) == 0) { $freq20 = $5 + ($call6 << 4) + 8 | 0; HEAPF64[$freq20 >> 3] = +HEAPF64[$freq20 >> 3] + $freq; $retval_0 = 1; return $retval_0 | 0; } $7 = HEAP32[$raw_spellings_ >> 2] | 0; $sub28 = (HEAP32[$spelling_size_ >> 2] | 0) - 1 | 0; $hash_pos_0 = $call6; while (1) { $arraydecay26 = $7 + ($hash_pos_0 << 4) | 0; if ((_strncmp($arraydecay26 | 0, $spelling_str | 0, $sub28 | 0) | 0) == 0) { label = 2676; break; } if ((HEAP8[$arraydecay26] | 0) == 0) { label = 2678; break; } $call62 = __ZN10ime_pinyin13SpellingTable13hash_pos_nextEj($this, $hash_pos_0) | 0; if (($call6 | 0) == ($call62 | 0)) { $retval_0 = 0; label = 2685; break; } else { $hash_pos_0 = $call62; } } if ((label | 0) == 2678) { $freq45 = $7 + ($hash_pos_0 << 4) + 8 | 0; HEAPF64[$freq45 >> 3] = +HEAPF64[$freq45 >> 3] + $freq; $arraydecay50 = (HEAP32[$raw_spellings_ >> 2] | 0) + ($hash_pos_0 << 4) | 0; $sub52 = (HEAP32[$spelling_size_ >> 2] | 0) - 1 | 0; _strncpy($arraydecay50 | 0, $spelling_str | 0, $sub52 | 0) | 0; HEAP8[(HEAP32[$spelling_size_ >> 2] | 0) - 1 + ((HEAP32[$raw_spellings_ >> 2] | 0) + ($hash_pos_0 << 4)) | 0] = 0; $spelling_num_ = $this + 32 | 0; HEAP32[$spelling_num_ >> 2] = (HEAP32[$spelling_num_ >> 2] | 0) + 1; $retval_0 = 1; return $retval_0 | 0; } else if ((label | 0) == 2685) { return $retval_0 | 0; } else if ((label | 0) == 2676) { $freq34 = $7 + ($hash_pos_0 << 4) + 8 | 0; HEAPF64[$freq34 >> 3] = +HEAPF64[$freq34 >> 3] + $freq; $retval_0 = 1; return $retval_0 | 0; } return 0; } function __ZN10ime_pinyin13SpellingTable7containEPKc($this, $spelling_str) { $this = $this | 0; $spelling_str = $spelling_str | 0; var $call = 0, $raw_spellings_ = 0, $arrayidx4 = 0, $spelling_size_ = 0, $hash_pos_0 = 0, $call15 = 0, $arrayidx22 = 0, $retval_0 = 0, label = 0; if (($spelling_str | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } if ((HEAP32[$this + 12 >> 2] | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } if ((HEAP8[$this + 49 | 0] & 1) != 0) { $retval_0 = 0; return $retval_0 | 0; } $call = __ZN10ime_pinyin13SpellingTable12get_hash_posEPKc($this, $spelling_str) | 0; $raw_spellings_ = $this + 8 | 0; $arrayidx4 = (HEAP32[$raw_spellings_ >> 2] | 0) + ($call << 4) | 0; if ((HEAP8[$arrayidx4] | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $spelling_size_ = $this + 16 | 0; if ((_strncmp($arrayidx4 | 0, $spelling_str | 0, (HEAP32[$spelling_size_ >> 2] | 0) - 1 | 0) | 0) == 0) { $retval_0 = 1; return $retval_0 | 0; } else { $hash_pos_0 = $call; } while (1) { $call15 = __ZN10ime_pinyin13SpellingTable13hash_pos_nextEj($this, $hash_pos_0) | 0; if (($call | 0) == ($call15 | 0)) { $retval_0 = 0; label = 2701; break; } $arrayidx22 = (HEAP32[$raw_spellings_ >> 2] | 0) + ($call15 << 4) | 0; if ((HEAP8[$arrayidx22] | 0) == 0) { $retval_0 = 0; label = 2698; break; } if ((_strncmp($arrayidx22 | 0, $spelling_str | 0, (HEAP32[$spelling_size_ >> 2] | 0) - 1 | 0) | 0) == 0) { $retval_0 = 1; label = 2702; break; } else { $hash_pos_0 = $call15; } } if ((label | 0) == 2698) { return $retval_0 | 0; } else if ((label | 0) == 2701) { return $retval_0 | 0; } else if ((label | 0) == 2702) { return $retval_0 | 0; } return 0; } function __ZN10ime_pinyin14SpellingParserC2Ev($this) { $this = $this | 0; HEAP32[$this >> 2] = __ZN10ime_pinyin12SpellingTrie14get_cpinstanceEv() | 0; return; } function __ZN10ime_pinyin14SpellingParser17is_valid_to_parseEc($this, $ch) { $this = $this | 0; $ch = $ch | 0; return __ZN10ime_pinyin12SpellingTrie17is_valid_spl_charEc($ch) | 0; } function __ZN10ime_pinyin8LpiCacheC2Ev($this) { $this = $this | 0; var $lpi_cache_ = 0, $call2 = 0, $lpi_cache_len_ = 0, $id_03 = 0; $lpi_cache_ = $this | 0; HEAP32[$lpi_cache_ >> 2] = __Znaj(3600) | 0; $call2 = __Znaj(60) | 0; $lpi_cache_len_ = $this + 4 | 0; HEAP32[$lpi_cache_len_ >> 2] = $call2; if ((HEAP32[$lpi_cache_ >> 2] | 0) == 0) { ___assert_func(2496, 27, 4560, 3920); } if (($call2 | 0) == 0) { ___assert_func(2496, 28, 4560, 2776); } else { $id_03 = 0; } do { HEAP16[(HEAP32[$lpi_cache_len_ >> 2] | 0) + (($id_03 & 65535) << 1) >> 1] = 0; $id_03 = $id_03 + 1 & 65535; } while (($id_03 & 65535) < 30); return; } function __ZN10ime_pinyin8LpiCache12get_instanceEv() { var $call = 0, $1 = 0, $3 = 0; if ((HEAP32[11852] | 0) != 0) { $3 = HEAP32[11852] | 0; return $3 | 0; } $call = __Znwj(8) | 0; $1 = $call; __ZN10ime_pinyin8LpiCacheC2Ev($1); HEAP32[11852] = $1; if (($call | 0) == 0) { ___assert_func(2496, 44, 4600, 1864); return 0; } else { $3 = HEAP32[11852] | 0; return $3 | 0; } return 0; } function __ZN10ime_pinyin13SpellingTable7arrangeEPjS1_($this, $item_size, $spl_num) { $this = $this | 0; $item_size = $item_size | 0; $spl_num = $spl_num | 0; var $raw_spellings_ = 0, $0 = 0, $spelling_buf_ = 0, $spelling_num_ = 0, $spelling_size_ = 0, $pos_040 = 0, $5 = 0, $6 = 0, $add_ptr = 0, $need_score_ = 0, $total_freq_ = 0, $pos13_036 = 0, $min_score_035 = 0.0, $freq = 0, $17 = 0, $19 = 0.0, $min_score_1 = 0.0, $inc49 = 0, $min_score_0_lcssa = 0.0, $score_amplifier_ = 0, $spelling_size_70 = 0, $pos54_031 = 0, $average_score_030 = 0.0, $call62 = 0.0, $mul64 = 0.0, $add = 0.0, $25 = 0, $26 = 0, $inc76 = 0, $28 = 0, $_lcssa = 0, $average_score_0_lcssa = 0.0, $div80 = 0.0, $retval_0 = 0; $raw_spellings_ = $this + 8 | 0; $0 = HEAP32[$raw_spellings_ >> 2] | 0; if (($0 | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $spelling_buf_ = $this + 12 | 0; if ((HEAP32[$spelling_buf_ >> 2] | 0) == 0 | ($item_size | 0) == 0 | ($spl_num | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } _qsort($0 | 0, HEAP32[$this + 4 >> 2] | 0, 16, 40); $spelling_num_ = $this + 32 | 0; if ((HEAP32[$spelling_num_ >> 2] | 0) != 0) { $spelling_size_ = $this + 16 | 0; $pos_040 = 0; do { $5 = HEAP32[$spelling_buf_ >> 2] | 0; $6 = HEAP32[$spelling_size_ >> 2] | 0; $add_ptr = $5 + (Math_imul($6, $pos_040) | 0) | 0; _strncpy($add_ptr | 0, (HEAP32[$raw_spellings_ >> 2] | 0) + ($pos_040 << 4) | 0, $6 | 0) | 0; $pos_040 = $pos_040 + 1 | 0; } while ($pos_040 >>> 0 < (HEAP32[$spelling_num_ >> 2] | 0) >>> 0); } $need_score_ = $this | 0; do { if ((HEAP8[$need_score_] & 1) != 0) { if ((HEAP32[$spelling_num_ >> 2] | 0) == 0) { $min_score_0_lcssa = 0.0; } else { $total_freq_ = $this + 24 | 0; $min_score_035 = 0.0; $pos13_036 = 0; while (1) { $freq = (HEAP32[$raw_spellings_ >> 2] | 0) + ($pos13_036 << 4) + 8 | 0; HEAPF64[$freq >> 3] = +HEAPF64[$freq >> 3] / +HEAPF64[$total_freq_ >> 3]; do { if ((HEAP8[$need_score_] & 1) == 0) { $min_score_1 = $min_score_035; } else { $17 = HEAP32[$raw_spellings_ >> 2] | 0; if (($pos13_036 | 0) == 0) { $min_score_1 = +HEAPF64[$17 + 8 >> 3]; break; } $19 = +HEAPF64[$17 + ($pos13_036 << 4) + 8 >> 3]; if ($19 >= $min_score_035) { $min_score_1 = $min_score_035; break; } $min_score_1 = $19; } } while (0); $inc49 = $pos13_036 + 1 | 0; if ($inc49 >>> 0 < (HEAP32[$spelling_num_ >> 2] | 0) >>> 0) { $min_score_035 = $min_score_1; $pos13_036 = $inc49; } else { $min_score_0_lcssa = $min_score_1; break; } } } $score_amplifier_ = $this + 40 | 0; HEAPF64[$score_amplifier_ >> 3] = 255.0 / +Math_log(+$min_score_0_lcssa); L3498 : do { if ((HEAP32[$spelling_num_ >> 2] | 0) == 0) { $average_score_0_lcssa = 0.0; $_lcssa = 0; } else { $spelling_size_70 = $this + 16 | 0; $average_score_030 = 0.0; $pos54_031 = 0; while (1) { $call62 = +Math_log(+(+HEAPF64[(HEAP32[$raw_spellings_ >> 2] | 0) + ($pos54_031 << 4) + 8 >> 3])); $mul64 = $call62 * +HEAPF64[$score_amplifier_ >> 3]; if ($mul64 < 0.0) { break; } $add = $average_score_030 + $mul64; $25 = HEAP32[$spelling_buf_ >> 2] | 0; $26 = HEAP32[$spelling_size_70 >> 2] | 0; HEAP8[$25 + ($26 - 1 + (Math_imul($26, $pos54_031) | 0)) | 0] = $mul64 > 255.0 ? -1 : ~~$mul64; $inc76 = $pos54_031 + 1 | 0; $28 = HEAP32[$spelling_num_ >> 2] | 0; if ($inc76 >>> 0 < $28 >>> 0) { $average_score_030 = $add; $pos54_031 = $inc76; } else { $average_score_0_lcssa = $add; $_lcssa = $28; break L3498; } } ___assert_func(2376, 272, 6328, 3848); return 0; } } while (0); $div80 = $average_score_0_lcssa / +($_lcssa >>> 0 >>> 0); if ($div80 > 255.0) { ___assert_func(2376, 290, 6328, 2752); return 0; } else { HEAP8[$this + 48 | 0] = ~~$div80; break; } } } while (0); HEAP32[$item_size >> 2] = HEAP32[$this + 16 >> 2]; HEAP32[$spl_num >> 2] = HEAP32[$spelling_num_ >> 2]; HEAP8[$this + 49 | 0] = 1; $retval_0 = HEAP32[$spelling_buf_ >> 2] | 0; return $retval_0 | 0; } function __ZN10ime_pinyin12SpellingTrie16is_same_spl_charEcc($ch1, $ch2) { $ch1 = $ch1 | 0; $ch2 = $ch2 | 0; var $conv = 0, $conv1 = 0, $0 = 0; $conv = $ch1 << 24 >> 24; $conv1 = $ch2 << 24 >> 24; if ($ch1 << 24 >> 24 == $ch2 << 24 >> 24) { $0 = 1; return $0 | 0; } if (($conv - $conv1 | 0) == 32) { $0 = 1; return $0 | 0; } $0 = ($conv1 - $conv | 0) == 32; return $0 | 0; } function __ZN10ime_pinyin14SpellingParser14splstr_to_idxsEPKctPtS3_tRb($this, $splstr, $str_len, $spl_idx, $start_pos, $max_size, $last_is_pre) { $this = $this | 0; $splstr = $splstr | 0; $str_len = $str_len | 0; $spl_idx = $spl_idx | 0; $start_pos = $start_pos | 0; $max_size = $max_size | 0; $last_is_pre = $last_is_pre | 0; var $id_this = 0, $id_this75 = 0, $id_this99 = 0, $spl_trie_ = 0, $2 = 0, $cmp8 = 0, $idx_num_0_ph = 0, $last_is_splitter_0_off0_ph = 0, $str_pos_0_ph = 0, $node_this_0_ph = 0, $arrayidx41 = 0, $last_is_splitter_0_off0_ph60_ph = 0, $str_pos_0_ph61_ph = 0, $node_this_0_ph62_ph = 0, $4 = 0, $str_pos_0_ph6183 = 0, $last_is_splitter_0_off0_ph6082 = 0, $str_pos_071 = 0, $5 = 0, $inc = 0, $inc23 = 0, $inc37 = 0, $conv48 = 0, $13 = 0, $conv65 = 0, $i_0 = 0, $found_son_0 = 0, $inc83 = 0, $idx_num_0_ph_be = 0, $last_is_splitter_0_off0_ph_be = 0, $str_pos_0_ph_be = 0, $last_is_splitter_0_off0_ph6076 = 0, $str_pos_0_lcssa = 0, $inc107 = 0, $idx_num_1 = 0, $retval_0 = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 24 | 0; $id_this = sp | 0; $id_this75 = sp + 8 | 0; $id_this99 = sp + 16 | 0; if (($splstr | 0) == 0 | $max_size << 16 >> 16 == 0 | $str_len << 16 >> 16 == 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } if (!(__ZN10ime_pinyin12SpellingTrie17is_valid_spl_charEc(HEAP8[$splstr] | 0) | 0)) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } HEAP8[$last_is_pre] = 0; $spl_trie_ = $this | 0; $2 = HEAP32[(HEAP32[$spl_trie_ >> 2] | 0) + 44 >> 2] | 0; $cmp8 = ($start_pos | 0) != 0; if ($cmp8) { HEAP16[$start_pos >> 1] = 0; $node_this_0_ph = $2; $str_pos_0_ph = 0; $last_is_splitter_0_off0_ph = 0; $idx_num_0_ph = 0; } else { $node_this_0_ph = $2; $str_pos_0_ph = 0; $last_is_splitter_0_off0_ph = 0; $idx_num_0_ph = 0; } L3527 : while (1) { $arrayidx41 = $start_pos + (($idx_num_0_ph & 65535) << 1) | 0; $node_this_0_ph62_ph = $node_this_0_ph; $str_pos_0_ph61_ph = $str_pos_0_ph; $last_is_splitter_0_off0_ph60_ph = $last_is_splitter_0_off0_ph; L3529 : while (1) { if (($str_pos_0_ph61_ph & 65535) >= ($str_len & 65535)) { $str_pos_0_lcssa = $str_pos_0_ph61_ph; $last_is_splitter_0_off0_ph6076 = $last_is_splitter_0_off0_ph60_ph; label = 2785; break L3527; } $4 = $node_this_0_ph62_ph + 4 | 0; $last_is_splitter_0_off0_ph6082 = $last_is_splitter_0_off0_ph60_ph; $str_pos_0_ph6183 = $str_pos_0_ph61_ph; L3532 : while (1) { $str_pos_071 = $str_pos_0_ph6183; while (1) { $5 = HEAP8[$splstr + ($str_pos_071 & 65535) | 0] | 0; if (__ZN10ime_pinyin12SpellingTrie17is_valid_spl_charEc($5) | 0) { break L3532; } HEAP16[$id_this >> 1] = HEAP16[$4 >> 1] & 2047; if (__ZNK10ime_pinyin12SpellingTrie18if_valid_id_updateEPt(HEAP32[$spl_trie_ >> 2] | 0, $id_this) | 0) { label = 2765; break L3529; } if (!$last_is_splitter_0_off0_ph6082) { $retval_0 = $idx_num_0_ph; label = 2796; break L3527; } $inc37 = $str_pos_071 + 1 & 65535; if (!$cmp8) { break; } HEAP16[$arrayidx41 >> 1] = $inc37; if (($inc37 & 65535) < ($str_len & 65535)) { $str_pos_071 = $inc37; } else { $str_pos_0_lcssa = $inc37; $last_is_splitter_0_off0_ph6076 = $last_is_splitter_0_off0_ph6082; label = 2785; break L3527; } } if (($inc37 & 65535) < ($str_len & 65535)) { $last_is_splitter_0_off0_ph6082 = 1; $str_pos_0_ph6183 = $inc37; } else { $str_pos_0_lcssa = $inc37; $last_is_splitter_0_off0_ph6076 = 1; label = 2785; break L3527; } } do { if ($str_pos_071 << 16 >> 16 == 0) { $conv48 = $5 << 24 >> 24; if ($5 << 24 >> 24 > 96) { $found_son_0 = HEAP32[(HEAP32[$spl_trie_ >> 2] | 0) + 56 + ($conv48 - 97 << 2) >> 2] | 0; break; } else { $found_son_0 = HEAP32[(HEAP32[$spl_trie_ >> 2] | 0) + 56 + ($conv48 - 65 << 2) >> 2] | 0; break; } } else { $13 = HEAP32[$node_this_0_ph62_ph >> 2] | 0; $conv65 = (HEAPU16[$node_this_0_ph62_ph + 4 >> 1] | 0) >>> 11 & 65535; $i_0 = 0; while (1) { if (($i_0 | 0) >= ($conv65 | 0)) { label = 2780; break L3529; } if (__ZN10ime_pinyin12SpellingTrie16is_same_spl_charEcc(HEAP8[$13 + ($i_0 << 3) + 6 | 0] | 0, $5) | 0) { break; } else { $i_0 = $i_0 + 1 | 0; } } $found_son_0 = $13 + ($i_0 << 3) | 0; } } while (0); if (($found_son_0 | 0) == 0) { label = 2780; break; } else { $node_this_0_ph62_ph = $found_son_0; $str_pos_0_ph61_ph = $str_pos_071 + 1 & 65535; $last_is_splitter_0_off0_ph60_ph = 0; } } if ((label | 0) == 2780) { label = 0; HEAP16[$id_this75 >> 1] = HEAP16[$node_this_0_ph62_ph + 4 >> 1] & 2047; if (!(__ZNK10ime_pinyin12SpellingTrie18if_valid_id_updateEPt(HEAP32[$spl_trie_ >> 2] | 0, $id_this75) | 0)) { $retval_0 = $idx_num_0_ph; label = 2793; break; } HEAP16[$spl_idx + (($idx_num_0_ph & 65535) << 1) >> 1] = HEAP16[$id_this75 >> 1] | 0; $inc83 = $idx_num_0_ph + 1 & 65535; if ($cmp8) { HEAP16[$start_pos + (($inc83 & 65535) << 1) >> 1] = $str_pos_071; } if (($inc83 & 65535) < ($max_size & 65535)) { $str_pos_0_ph_be = $str_pos_071; $last_is_splitter_0_off0_ph_be = 0; $idx_num_0_ph_be = $inc83; } else { $retval_0 = $inc83; label = 2791; break; } } else if ((label | 0) == 2765) { label = 0; HEAP16[$spl_idx + (($idx_num_0_ph & 65535) << 1) >> 1] = HEAP16[$id_this >> 1] | 0; $inc = $idx_num_0_ph + 1 & 65535; $inc23 = $str_pos_071 + 1 & 65535; if ($cmp8) { HEAP16[$start_pos + (($inc & 65535) << 1) >> 1] = $inc23; } if (($inc & 65535) < ($max_size & 65535)) { $str_pos_0_ph_be = $inc23; $last_is_splitter_0_off0_ph_be = 1; $idx_num_0_ph_be = $inc; } else { $retval_0 = $inc; label = 2795; break; } } $node_this_0_ph = HEAP32[(HEAP32[$spl_trie_ >> 2] | 0) + 44 >> 2] | 0; $str_pos_0_ph = $str_pos_0_ph_be; $last_is_splitter_0_off0_ph = $last_is_splitter_0_off0_ph_be; $idx_num_0_ph = $idx_num_0_ph_be; } if ((label | 0) == 2785) { HEAP16[$id_this99 >> 1] = HEAP16[$node_this_0_ph62_ph + 4 >> 1] & 2047; do { if (__ZNK10ime_pinyin12SpellingTrie18if_valid_id_updateEPt(HEAP32[$spl_trie_ >> 2] | 0, $id_this99) | 0) { HEAP16[$spl_idx + (($idx_num_0_ph & 65535) << 1) >> 1] = HEAP16[$id_this99 >> 1] | 0; $inc107 = $idx_num_0_ph + 1 & 65535; if (!$cmp8) { $idx_num_1 = $inc107; break; } HEAP16[$start_pos + (($inc107 & 65535) << 1) >> 1] = $str_pos_0_lcssa; $idx_num_1 = $inc107; } else { $idx_num_1 = $idx_num_0_ph; } } while (0); HEAP8[$last_is_pre] = $last_is_splitter_0_off0_ph6076 & 1 ^ 1; $retval_0 = $idx_num_1; STACKTOP = sp; return $retval_0 | 0; } else if ((label | 0) == 2791) { STACKTOP = sp; return $retval_0 | 0; } else if ((label | 0) == 2793) { STACKTOP = sp; return $retval_0 | 0; } else if ((label | 0) == 2795) { STACKTOP = sp; return $retval_0 | 0; } else if ((label | 0) == 2796) { STACKTOP = sp; return $retval_0 | 0; } return 0; } function __ZN10ime_pinyin14SpellingParser16splstr_to_idxs_fEPKctPtS3_tRb($this, $splstr, $str_len, $spl_idx, $start_pos, $max_size, $last_is_pre) { $this = $this | 0; $splstr = $splstr | 0; $str_len = $str_len | 0; $spl_idx = $spl_idx | 0; $start_pos = $start_pos | 0; $max_size = $max_size | 0; $last_is_pre = $last_is_pre | 0; var $call = 0, $spl_trie_ = 0, $sub = 0, $conv14 = 0, $pos_013 = 0, $arrayidx = 0, $2 = 0, $3 = 0, $inc = 0; $call = __ZN10ime_pinyin14SpellingParser14splstr_to_idxsEPKctPtS3_tRb($this, $splstr, $str_len, $spl_idx, $start_pos, $max_size, $last_is_pre) | 0; if ($call << 16 >> 16 == 0) { return $call | 0; } $spl_trie_ = $this | 0; $sub = ($call & 65535) - 1 | 0; $pos_013 = 0; $conv14 = 0; while (1) { $arrayidx = $spl_idx + ($conv14 << 1) | 0; do { if (__ZNK10ime_pinyin12SpellingTrie16is_half_id_yunmuEt(HEAP32[$spl_trie_ >> 2] | 0, HEAP16[$arrayidx >> 1] | 0) | 0) { $2 = HEAP32[$spl_trie_ >> 2] | 0; $3 = HEAP16[$arrayidx >> 1] | 0; __ZNK10ime_pinyin12SpellingTrie12half_to_fullEtPt($2, $3, $arrayidx) | 0; if (($conv14 | 0) != ($sub | 0)) { break; } HEAP8[$last_is_pre] = 0; } } while (0); $inc = $pos_013 + 1 & 65535; if (($inc & 65535) < ($call & 65535)) { $pos_013 = $inc; $conv14 = $inc & 65535; } else { break; } } return $call | 0; } function __ZN10ime_pinyin14SpellingParser16splstr16_to_idxsEPKttPtS3_tRb($this, $splstr, $str_len, $spl_idx, $start_pos, $max_size, $last_is_pre) { $this = $this | 0; $splstr = $splstr | 0; $str_len = $str_len | 0; $spl_idx = $spl_idx | 0; $start_pos = $start_pos | 0; $max_size = $max_size | 0; $last_is_pre = $last_is_pre | 0; var $id_this = 0, $id_this78 = 0, $id_this102 = 0, $spl_trie_ = 0, $2 = 0, $cmp9 = 0, $idx_num_0_ph = 0, $last_is_splitter_0_off0_ph = 0, $str_pos_0_ph = 0, $node_this_0_ph = 0, $arrayidx43 = 0, $last_is_splitter_0_off0_ph60_ph = 0, $str_pos_0_ph61_ph = 0, $node_this_0_ph62_ph = 0, $4 = 0, $str_pos_0_ph6186 = 0, $last_is_splitter_0_off0_ph6085 = 0, $str_pos_074 = 0, $5 = 0, $conv17 = 0, $inc = 0, $inc25 = 0, $inc39 = 0, $conv50 = 0, $13 = 0, $conv67 = 0, $i_0 = 0, $found_son_0 = 0, $inc86 = 0, $idx_num_0_ph_be = 0, $last_is_splitter_0_off0_ph_be = 0, $str_pos_0_ph_be = 0, $last_is_splitter_0_off0_ph6079 = 0, $str_pos_0_lcssa = 0, $inc110 = 0, $idx_num_1 = 0, $retval_0 = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 24 | 0; $id_this = sp | 0; $id_this78 = sp + 8 | 0; $id_this102 = sp + 16 | 0; if (($splstr | 0) == 0 | $max_size << 16 >> 16 == 0 | $str_len << 16 >> 16 == 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } if (!(__ZN10ime_pinyin12SpellingTrie17is_valid_spl_charEc(HEAP16[$splstr >> 1] & 255) | 0)) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } HEAP8[$last_is_pre] = 0; $spl_trie_ = $this | 0; $2 = HEAP32[(HEAP32[$spl_trie_ >> 2] | 0) + 44 >> 2] | 0; $cmp9 = ($start_pos | 0) != 0; if ($cmp9) { HEAP16[$start_pos >> 1] = 0; $node_this_0_ph = $2; $str_pos_0_ph = 0; $last_is_splitter_0_off0_ph = 0; $idx_num_0_ph = 0; } else { $node_this_0_ph = $2; $str_pos_0_ph = 0; $last_is_splitter_0_off0_ph = 0; $idx_num_0_ph = 0; } L3595 : while (1) { $arrayidx43 = $start_pos + (($idx_num_0_ph & 65535) << 1) | 0; $node_this_0_ph62_ph = $node_this_0_ph; $str_pos_0_ph61_ph = $str_pos_0_ph; $last_is_splitter_0_off0_ph60_ph = $last_is_splitter_0_off0_ph; L3597 : while (1) { if (($str_pos_0_ph61_ph & 65535) >= ($str_len & 65535)) { $str_pos_0_lcssa = $str_pos_0_ph61_ph; $last_is_splitter_0_off0_ph6079 = $last_is_splitter_0_off0_ph60_ph; label = 2837; break L3595; } $4 = $node_this_0_ph62_ph + 4 | 0; $last_is_splitter_0_off0_ph6085 = $last_is_splitter_0_off0_ph60_ph; $str_pos_0_ph6186 = $str_pos_0_ph61_ph; L3600 : while (1) { $str_pos_074 = $str_pos_0_ph6186; while (1) { $5 = HEAP16[$splstr + (($str_pos_074 & 65535) << 1) >> 1] | 0; $conv17 = $5 & 255; if (__ZN10ime_pinyin12SpellingTrie17is_valid_spl_charEc($conv17) | 0) { break L3600; } HEAP16[$id_this >> 1] = HEAP16[$4 >> 1] & 2047; if (__ZNK10ime_pinyin12SpellingTrie18if_valid_id_updateEPt(HEAP32[$spl_trie_ >> 2] | 0, $id_this) | 0) { label = 2817; break L3597; } if (!$last_is_splitter_0_off0_ph6085) { $retval_0 = $idx_num_0_ph; label = 2846; break L3595; } $inc39 = $str_pos_074 + 1 & 65535; if (!$cmp9) { break; } HEAP16[$arrayidx43 >> 1] = $inc39; if (($inc39 & 65535) < ($str_len & 65535)) { $str_pos_074 = $inc39; } else { $str_pos_0_lcssa = $inc39; $last_is_splitter_0_off0_ph6079 = $last_is_splitter_0_off0_ph6085; label = 2837; break L3595; } } if (($inc39 & 65535) < ($str_len & 65535)) { $last_is_splitter_0_off0_ph6085 = 1; $str_pos_0_ph6186 = $inc39; } else { $str_pos_0_lcssa = $inc39; $last_is_splitter_0_off0_ph6079 = 1; label = 2837; break L3595; } } do { if ($str_pos_074 << 16 >> 16 == 0) { $conv50 = $5 & 65535; if (($5 & 65535) > 96) { $found_son_0 = HEAP32[(HEAP32[$spl_trie_ >> 2] | 0) + 56 + ($conv50 - 97 << 2) >> 2] | 0; break; } else { $found_son_0 = HEAP32[(HEAP32[$spl_trie_ >> 2] | 0) + 56 + ($conv50 - 65 << 2) >> 2] | 0; break; } } else { $13 = HEAP32[$node_this_0_ph62_ph >> 2] | 0; $conv67 = (HEAPU16[$node_this_0_ph62_ph + 4 >> 1] | 0) >>> 11 & 65535; $i_0 = 0; while (1) { if (($i_0 | 0) >= ($conv67 | 0)) { label = 2832; break L3597; } if (__ZN10ime_pinyin12SpellingTrie16is_same_spl_charEcc(HEAP8[$13 + ($i_0 << 3) + 6 | 0] | 0, $conv17) | 0) { break; } else { $i_0 = $i_0 + 1 | 0; } } $found_son_0 = $13 + ($i_0 << 3) | 0; } } while (0); if (($found_son_0 | 0) == 0) { label = 2832; break; } else { $node_this_0_ph62_ph = $found_son_0; $str_pos_0_ph61_ph = $str_pos_074 + 1 & 65535; $last_is_splitter_0_off0_ph60_ph = 0; } } if ((label | 0) == 2832) { label = 0; HEAP16[$id_this78 >> 1] = HEAP16[$node_this_0_ph62_ph + 4 >> 1] & 2047; if (!(__ZNK10ime_pinyin12SpellingTrie18if_valid_id_updateEPt(HEAP32[$spl_trie_ >> 2] | 0, $id_this78) | 0)) { $retval_0 = $idx_num_0_ph; label = 2844; break; } HEAP16[$spl_idx + (($idx_num_0_ph & 65535) << 1) >> 1] = HEAP16[$id_this78 >> 1] | 0; $inc86 = $idx_num_0_ph + 1 & 65535; if ($cmp9) { HEAP16[$start_pos + (($inc86 & 65535) << 1) >> 1] = $str_pos_074; } if (($inc86 & 65535) < ($max_size & 65535)) { $str_pos_0_ph_be = $str_pos_074; $last_is_splitter_0_off0_ph_be = 0; $idx_num_0_ph_be = $inc86; } else { $retval_0 = $inc86; label = 2843; break; } } else if ((label | 0) == 2817) { label = 0; HEAP16[$spl_idx + (($idx_num_0_ph & 65535) << 1) >> 1] = HEAP16[$id_this >> 1] | 0; $inc = $idx_num_0_ph + 1 & 65535; $inc25 = $str_pos_074 + 1 & 65535; if ($cmp9) { HEAP16[$start_pos + (($inc & 65535) << 1) >> 1] = $inc25; } if (($inc & 65535) < ($max_size & 65535)) { $str_pos_0_ph_be = $inc25; $last_is_splitter_0_off0_ph_be = 1; $idx_num_0_ph_be = $inc; } else { $retval_0 = $inc; label = 2845; break; } } $node_this_0_ph = HEAP32[(HEAP32[$spl_trie_ >> 2] | 0) + 44 >> 2] | 0; $str_pos_0_ph = $str_pos_0_ph_be; $last_is_splitter_0_off0_ph = $last_is_splitter_0_off0_ph_be; $idx_num_0_ph = $idx_num_0_ph_be; } if ((label | 0) == 2837) { HEAP16[$id_this102 >> 1] = HEAP16[$node_this_0_ph62_ph + 4 >> 1] & 2047; do { if (__ZNK10ime_pinyin12SpellingTrie18if_valid_id_updateEPt(HEAP32[$spl_trie_ >> 2] | 0, $id_this102) | 0) { HEAP16[$spl_idx + (($idx_num_0_ph & 65535) << 1) >> 1] = HEAP16[$id_this102 >> 1] | 0; $inc110 = $idx_num_0_ph + 1 & 65535; if (!$cmp9) { $idx_num_1 = $inc110; break; } HEAP16[$start_pos + (($inc110 & 65535) << 1) >> 1] = $str_pos_0_lcssa; $idx_num_1 = $inc110; } else { $idx_num_1 = $idx_num_0_ph; } } while (0); HEAP8[$last_is_pre] = $last_is_splitter_0_off0_ph6079 & 1 ^ 1; $retval_0 = $idx_num_1; STACKTOP = sp; return $retval_0 | 0; } else if ((label | 0) == 2843) { STACKTOP = sp; return $retval_0 | 0; } else if ((label | 0) == 2844) { STACKTOP = sp; return $retval_0 | 0; } else if ((label | 0) == 2845) { STACKTOP = sp; return $retval_0 | 0; } else if ((label | 0) == 2846) { STACKTOP = sp; return $retval_0 | 0; } return 0; } function __ZN10ime_pinyin14SpellingParser18splstr16_to_idxs_fEPKttPtS3_tRb($this, $splstr, $str_len, $spl_idx, $start_pos, $max_size, $last_is_pre) { $this = $this | 0; $splstr = $splstr | 0; $str_len = $str_len | 0; $spl_idx = $spl_idx | 0; $start_pos = $start_pos | 0; $max_size = $max_size | 0; $last_is_pre = $last_is_pre | 0; var $call = 0, $spl_trie_ = 0, $sub = 0, $conv14 = 0, $pos_013 = 0, $arrayidx = 0, $2 = 0, $3 = 0, $inc = 0; $call = __ZN10ime_pinyin14SpellingParser16splstr16_to_idxsEPKttPtS3_tRb($this, $splstr, $str_len, $spl_idx, $start_pos, $max_size, $last_is_pre) | 0; if ($call << 16 >> 16 == 0) { return $call | 0; } $spl_trie_ = $this | 0; $sub = ($call & 65535) - 1 | 0; $pos_013 = 0; $conv14 = 0; while (1) { $arrayidx = $spl_idx + ($conv14 << 1) | 0; do { if (__ZNK10ime_pinyin12SpellingTrie16is_half_id_yunmuEt(HEAP32[$spl_trie_ >> 2] | 0, HEAP16[$arrayidx >> 1] | 0) | 0) { $2 = HEAP32[$spl_trie_ >> 2] | 0; $3 = HEAP16[$arrayidx >> 1] | 0; __ZNK10ime_pinyin12SpellingTrie12half_to_fullEtPt($2, $3, $arrayidx) | 0; if (($conv14 | 0) != ($sub | 0)) { break; } HEAP8[$last_is_pre] = 0; } } while (0); $inc = $pos_013 + 1 & 65535; if (($inc & 65535) < ($call & 65535)) { $pos_013 = $inc; $conv14 = $inc & 65535; } else { break; } } return $call | 0; } function __ZN10ime_pinyin14SpellingParser16get_splid_by_strEPKctPb($this, $splstr, $str_len, $is_pre) { $this = $this | 0; $splstr = $splstr | 0; $str_len = $str_len | 0; $is_pre = $is_pre | 0; var $start_pos = 0, $arraydecay = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16 | 0; $start_pos = sp + 8 | 0; if (($is_pre | 0) == 0) { STACKTOP = sp; return 0; } $arraydecay = sp | 0; if ((__ZN10ime_pinyin14SpellingParser14splstr_to_idxsEPKctPtS3_tRb($this, $splstr, $str_len, $arraydecay, $start_pos | 0, 2, $is_pre) | 0) << 16 >> 16 == 1) { STACKTOP = sp; return ((HEAP16[$start_pos + 2 >> 1] | 0) == $str_len << 16 >> 16 ? HEAP16[$arraydecay >> 1] | 0 : 0) | 0; } else { STACKTOP = sp; return 0; } return 0; } function __ZN10ime_pinyin14SpellingParser18get_splid_by_str_fEPKctPb($this, $splstr, $str_len, $is_pre) { $this = $this | 0; $splstr = $splstr | 0; $str_len = $str_len | 0; $is_pre = $is_pre | 0; var $start_pos = 0, $arraydecay = 0, $spl_trie_ = 0, $3 = 0, $4 = 0, $retval_0 = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16 | 0; $start_pos = sp + 8 | 0; if (($is_pre | 0) == 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } $arraydecay = sp | 0; if ((__ZN10ime_pinyin14SpellingParser14splstr_to_idxsEPKctPtS3_tRb($this, $splstr, $str_len, $arraydecay, $start_pos | 0, 2, $is_pre) | 0) << 16 >> 16 != 1) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } if ((HEAP16[$start_pos + 2 >> 1] | 0) != $str_len << 16 >> 16) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } $spl_trie_ = $this | 0; if (__ZNK10ime_pinyin12SpellingTrie16is_half_id_yunmuEt(HEAP32[$spl_trie_ >> 2] | 0, HEAP16[$arraydecay >> 1] | 0) | 0) { $3 = HEAP32[$spl_trie_ >> 2] | 0; $4 = HEAP16[$arraydecay >> 1] | 0; __ZNK10ime_pinyin12SpellingTrie12half_to_fullEtPt($3, $4, $arraydecay) | 0; HEAP8[$is_pre] = 0; } $retval_0 = HEAP16[$arraydecay >> 1] | 0; STACKTOP = sp; return $retval_0 | 0; } function __ZN10ime_pinyin14SpellingParser19get_splids_parallelEPKctPttRtRb($this, $splstr, $str_len, $splidx, $max_size, $full_id_num, $is_pre) { $this = $this | 0; $splstr = $splstr | 0; $str_len = $str_len | 0; $splidx = $splidx | 0; $max_size = $max_size | 0; $full_id_num = $full_id_num | 0; $is_pre = $is_pre | 0; var $1 = 0, $retval_0 = 0; do { if ($max_size << 16 >> 16 == 0) { $retval_0 = 0; } else { if (!(__ZN10ime_pinyin14SpellingParser17is_valid_to_parseEc(0, HEAP8[$splstr] | 0) | 0)) { $retval_0 = 0; break; } HEAP16[$splidx >> 1] = __ZN10ime_pinyin14SpellingParser16get_splid_by_strEPKctPb($this, $splstr, $str_len, $is_pre) | 0; HEAP16[$full_id_num >> 1] = 0; $1 = HEAP16[$splidx >> 1] | 0; if ($1 << 16 >> 16 == 0) { $retval_0 = 0; break; } if (($1 & 65535) <= 29) { $retval_0 = 1; break; } HEAP16[$full_id_num >> 1] = 1; $retval_0 = 1; } } while (0); return $retval_0 | 0; } function __ZN10ime_pinyin8UserDictC2Ev($this) { $this = $this | 0; __ZN10ime_pinyin12AtomDictBaseC2Ev($this | 0); HEAP32[$this >> 2] = 8176; _memset($this + 8 | 0, 0, 100); __ZN10ime_pinyin8UserDict10cache_initEv($this); return; } function __ZN10ime_pinyin8UserDict10cache_initEv($this) { $this = $this | 0; __ZN10ime_pinyin8UserDict11reset_cacheEv($this); __ZN10ime_pinyin8UserDict16reset_miss_cacheEv($this); return; } function __ZN10ime_pinyin8UserDictD0Ev($this) { $this = $this | 0; __ZN10ime_pinyin8UserDictD2Ev($this); __ZdlPv($this); return; } function __ZN10ime_pinyin8UserDictD2Ev($this) { $this = $this | 0; HEAP32[$this >> 2] = 8176; FUNCTION_TABLE_ii[HEAP32[(HEAP32[$this >> 2] | 0) + 12 >> 2] & 31]($this) | 0; return; } function __ZN10ime_pinyin8UserDict9load_dictEPKcjj($this, $file_name, $start_id, $end_id) { $this = $this | 0; $file_name = $file_name | 0; $start_id = $start_id | 0; $end_id = $end_id | 0; var $call = 0, $dict_file_ = 0, $start_id_ = 0, $load_time_ = 0, $retval_0 = 0, label = 0; $call = _strdup($file_name | 0) | 0; $dict_file_ = $this + 64 | 0; HEAP32[$dict_file_ >> 2] = $call; if (($call | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $start_id_ = $this + 16 | 0; HEAP32[$start_id_ >> 2] = $start_id; if (__ZN10ime_pinyin8UserDict8validateEPKc($this, $file_name) | 0) { label = 2890; } else { if (__ZN10ime_pinyin8UserDict5resetEPKc(0, $file_name) | 0) { label = 2890; } } do { if ((label | 0) == 2890) { if (!(__ZN10ime_pinyin8UserDict4loadEPKcj($this, $file_name, $start_id) | 0)) { break; } HEAP32[$this + 104 >> 2] = 1; $load_time_ = $this + 8 | 0; _gettimeofday($load_time_ | 0, 0) | 0; $retval_0 = 1; return $retval_0 | 0; } } while (0); _free(HEAP32[$dict_file_ >> 2] | 0); HEAP32[$start_id_ >> 2] = 0; $retval_0 = 0; return $retval_0 | 0; } function __ZN10ime_pinyin8UserDict8validateEPKc($this, $file) { $this = $this | 0; $file = $file | 0; var $version = 0, $dict_info = 0, $call = 0, $call6 = 0, $cmp14 = 0, $retval_0 = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 48 | 0; $version = sp | 0; $dict_info = sp + 8 | 0; $call = _fopen($file | 0, 3840) | 0; if (($call | 0) == 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } do { if ((_fseek($call | 0, 0, 2) | 0) == 0) { $call6 = _ftell($call | 0) | 0; if ($call6 >>> 0 < 40) { break; } if ((_fseek($call | 0, 0, 0) | 0) != 0) { break; } $cmp14 = (_fread($version | 0, 1, 4, $call | 0) | 0) >>> 0 > 3; if (!($cmp14 & (HEAP32[$version >> 2] | 0) == 18015e4)) { break; } if ((_fseek($call | 0, -36 | 0, 2) | 0) != 0) { break; } if ((_fread($dict_info | 0, 1, 36, $call | 0) | 0) != 36) { break; } if (($call6 | 0) != (__ZN10ime_pinyin8UserDict18get_dict_file_sizeEPNS0_12UserDictInfoE(0, $dict_info) | 0)) { break; } _fclose($call | 0) | 0; $retval_0 = 1; STACKTOP = sp; return $retval_0 | 0; } } while (0); _fclose($call | 0) | 0; $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } function __ZN10ime_pinyin8UserDict5resetEPKc($this, $file) { $this = $this | 0; $file = $file | 0; var $version = 0, $call = 0, $call2 = 0, $1 = 0, $cmp = 0, $retval_0 = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 48 | 0; $version = sp | 0; $call = _fopen($file | 0, 2200) | 0; if (($call | 0) == 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } HEAP32[$version >> 2] = 18015e4; $call2 = _fwrite($version | 0, 1, 4, $call | 0) | 0; $1 = sp + 8 | 0; _memset($1 | 0, 0, 36); $cmp = ((_fwrite($1 | 0, 1, 36, $call | 0) | 0) + $call2 | 0) == 40; _fclose($call | 0) | 0; if ($cmp) { $retval_0 = 1; STACKTOP = sp; return $retval_0 | 0; } _unlink($file | 0) | 0; $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } function __ZN10ime_pinyin8UserDict16reset_milestonesEtt($this, $from_step, $from_handle) { $this = $this | 0; $from_step = $from_step | 0; $from_handle = $from_handle | 0; return; } function __ZN10ime_pinyin8UserDict16number_of_lemmasEv($this) { $this = $this | 0; return HEAP32[$this + 80 >> 2] | 0; } function __ZN10ime_pinyin8UserDict14is_valid_stateEv($this) { $this = $this | 0; return (HEAP32[$this + 104 >> 2] | 0) != 0 | 0; } function __ZN10ime_pinyin8UserDict18is_prefix_spell_idEPKttPKNS0_18UserDictSearchableE($this, $fullids, $fulllen, $searchable) { $this = $this | 0; $fullids = $fullids | 0; $fulllen = $fulllen | 0; $searchable = $searchable | 0; var $splids_len = 0, $conv4 = 0, $i_0 = 0, $2 = 0, $3 = 0, $retval_0 = 0, label = 0; $splids_len = $searchable | 0; if ((HEAPU16[$splids_len >> 1] | 0) > ($fulllen & 65535)) { $retval_0 = 0; return $retval_0 | 0; } $conv4 = HEAPU16[$splids_len >> 1] | 0; $i_0 = 0; while (1) { if ($i_0 >>> 0 >= $conv4 >>> 0) { $retval_0 = 1; label = 2928; break; } $2 = HEAP16[$searchable + 2 + ($i_0 << 1) >> 1] | 0; $3 = HEAP16[$fullids + ($i_0 << 1) >> 1] | 0; if (($3 & 65535) < ($2 & 65535)) { $retval_0 = 0; label = 2929; break; } if (($3 & 65535 | 0) < ((HEAPU16[$searchable + 18 + ($i_0 << 1) >> 1] | 0) + ($2 & 65535) | 0)) { $i_0 = $i_0 + 1 | 0; } else { $retval_0 = 0; label = 2927; break; } } if ((label | 0) == 2928) { return $retval_0 | 0; } else if ((label | 0) == 2927) { return $retval_0 | 0; } else if ((label | 0) == 2929) { return $retval_0 | 0; } return 0; } function __ZN10ime_pinyin8UserDict14equal_spell_idEPKttPKNS0_18UserDictSearchableE($this, $fullids, $fulllen, $searchable) { $this = $this | 0; $fullids = $fullids | 0; $fulllen = $fulllen | 0; $searchable = $searchable | 0; var $conv = 0, $i_0 = 0, $1 = 0, $2 = 0, $retval_0 = 0, label = 0; $conv = $fulllen & 65535; if ((HEAP16[$searchable >> 1] | 0) == $fulllen << 16 >> 16) { $i_0 = 0; } else { $retval_0 = 0; return $retval_0 | 0; } while (1) { if ($i_0 >>> 0 >= $conv >>> 0) { $retval_0 = 1; label = 2936; break; } $1 = HEAP16[$searchable + 2 + ($i_0 << 1) >> 1] | 0; $2 = HEAP16[$fullids + ($i_0 << 1) >> 1] | 0; if (($2 & 65535) < ($1 & 65535)) { $retval_0 = 0; label = 2939; break; } if (($2 & 65535 | 0) < ((HEAPU16[$searchable + 18 + ($i_0 << 1) >> 1] | 0) + ($1 & 65535) | 0)) { $i_0 = $i_0 + 1 | 0; } else { $retval_0 = 0; label = 2938; break; } } if ((label | 0) == 2938) { return $retval_0 | 0; } else if ((label | 0) == 2936) { return $retval_0 | 0; } else if ((label | 0) == 2939) { return $retval_0 | 0; } return 0; } function __ZN10ime_pinyin8UserDict15get_lemma_ncharEj($this, $offset) { $this = $this | 0; $offset = $offset | 0; return HEAP8[(HEAP32[$this + 24 >> 2] | 0) + (($offset & 2147483647) + 1) | 0] | 0; } function __ZN10ime_pinyin8UserDict19get_lemma_spell_idsEj($this, $offset) { $this = $this | 0; $offset = $offset | 0; return (HEAP32[$this + 24 >> 2] | 0) + (($offset & 2147483647) + 2) | 0; } function __ZN10ime_pinyin8UserDict4loadEPKcj($this, $file, $start_id) { $this = $this | 0; $file = $file | 0; $start_id = $start_id | 0; var $dict_info = 0, $call = 0, $0 = 0, $lemma_size = 0, $call9 = 0, $lemma_count = 0, $call14 = 0, $3 = 0, $call21 = 0, $5 = 0, $sync_count = 0, $call27 = 0, $7 = 0, $call34 = 0, $9 = 0, $call41 = 0, $11 = 0, $call48 = 0, $13 = 0, $15 = 0, $readed_0148 = 0, $add64 = 0, $readed_0_lcssa = 0, $shl70 = 0, $readed_1146 = 0, $shl91 = 0, $readed_2143 = 0, $readed_3140 = 0, $shl131 = 0, $21 = 0, $23 = 0, $readed_4137 = 0, $i_0135 = 0, $25 = 0, $syncs_0 = 0, $scores_0 = 0, $ids_0 = 0, $offsets_by_id_0 = 0, $predicts_0112 = 0, $offsets_by_id_0111 = 0, $ids_0110 = 0, $scores_0109 = 0, $syncs_0108 = 0, $predicts_0103 = 0, $offsets_by_id_0102 = 0, $ids_0101 = 0, $scores_0100 = 0, $syncs_099 = 0, $retval_0 = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 40 | 0; $dict_info = sp | 0; $call = _fopen($file | 0, 3840) | 0; if (($call | 0) == 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } do { if ((_fseek($call | 0, -36 | 0, 2) | 0) == 0) { $0 = $dict_info; if ((_fread($0 | 0, 1, 36, $call | 0) | 0) != 36) { break; } $lemma_size = $dict_info + 16 | 0; $call9 = _malloc((HEAP32[$lemma_size >> 2] | 0) + 1088 | 0) | 0; if (($call9 | 0) == 0) { break; } $lemma_count = $dict_info + 12 | 0; $call14 = _malloc((HEAP32[$lemma_count >> 2] << 2) + 128 | 0) | 0; $3 = $call14; if (($call14 | 0) == 0) { $syncs_0108 = 0; $scores_0109 = 0; $ids_0110 = 0; $offsets_by_id_0111 = 0; $predicts_0112 = 0; label = 2980; } else { $call21 = _malloc((HEAP32[$lemma_count >> 2] << 2) + 128 | 0) | 0; $5 = $call21; L3760 : do { if (($call21 | 0) == 0) { $offsets_by_id_0 = 0; $ids_0 = 0; $scores_0 = 0; $syncs_0 = 0; } else { $sync_count = $dict_info + 28 | 0; $call27 = _malloc((HEAP32[$sync_count >> 2] << 2) + 128 | 0) | 0; $7 = $call27; if (($call27 | 0) == 0) { $offsets_by_id_0 = 0; $ids_0 = 0; $scores_0 = 0; $syncs_0 = $7; break; } $call34 = _malloc((HEAP32[$lemma_count >> 2] << 2) + 128 | 0) | 0; $9 = $call34; if (($call34 | 0) == 0) { $offsets_by_id_0 = 0; $ids_0 = 0; $scores_0 = $9; $syncs_0 = $7; break; } $call41 = _malloc((HEAP32[$lemma_count >> 2] << 2) + 128 | 0) | 0; $11 = $call41; if (($call41 | 0) == 0) { $offsets_by_id_0 = 0; $ids_0 = $11; $scores_0 = $9; $syncs_0 = $7; break; } $call48 = _malloc((HEAP32[$lemma_count >> 2] << 2) + 128 | 0) | 0; $13 = $call48; if (($call48 | 0) == 0) { $offsets_by_id_0 = $13; $ids_0 = $11; $scores_0 = $9; $syncs_0 = $7; break; } if ((_fseek($call | 0, 4, 0) | 0) != 0) { $offsets_by_id_0 = $13; $ids_0 = $11; $scores_0 = $9; $syncs_0 = $7; break; } L3767 : do { if ((HEAP32[$lemma_size >> 2] | 0) == 0) { $readed_0_lcssa = 0; } else { $15 = HEAP32[$lemma_size >> 2] | 0; $readed_0148 = 0; while (1) { if ((_ferror($call | 0) | 0) != 0) { $readed_0_lcssa = $readed_0148; break L3767; } if ((_feof($call | 0) | 0) != 0) { $readed_0_lcssa = $readed_0148; break L3767; } $add64 = (_fread($call9 + $readed_0148 | 0, 1, $15 - $readed_0148 | 0, $call | 0) | 0) + $readed_0148 | 0; if ($add64 >>> 0 < $15 >>> 0) { $readed_0148 = $add64; } else { $readed_0_lcssa = $add64; break; } } } } while (0); if ($readed_0_lcssa >>> 0 < (HEAP32[$lemma_size >> 2] | 0) >>> 0) { $offsets_by_id_0 = $13; $ids_0 = $11; $scores_0 = $9; $syncs_0 = $7; break; } $shl70 = HEAP32[$lemma_count >> 2] << 2; if (($shl70 | 0) != 0) { $readed_1146 = 0; do { if ((_ferror($call | 0) | 0) != 0) { $offsets_by_id_0 = $13; $ids_0 = $11; $scores_0 = $9; $syncs_0 = $7; break L3760; } if ((_feof($call | 0) | 0) != 0) { $offsets_by_id_0 = $13; $ids_0 = $11; $scores_0 = $9; $syncs_0 = $7; break L3760; } $readed_1146 = (_fread($call14 + $readed_1146 | 0, 1, $shl70 - $readed_1146 | 0, $call | 0) | 0) + $readed_1146 | 0; } while ($readed_1146 >>> 0 < $shl70 >>> 0); } $shl91 = HEAP32[$lemma_count >> 2] << 2; do { if (($shl91 | 0) != 0) { $readed_2143 = 0; do { if ((_ferror($call | 0) | 0) != 0) { $offsets_by_id_0 = $13; $ids_0 = $11; $scores_0 = $9; $syncs_0 = $7; break L3760; } if ((_feof($call | 0) | 0) != 0) { $offsets_by_id_0 = $13; $ids_0 = $11; $scores_0 = $9; $syncs_0 = $7; break L3760; } $readed_2143 = (_fread($call21 + $readed_2143 | 0, 1, $shl91 - $readed_2143 | 0, $call | 0) | 0) + $readed_2143 | 0; } while ($readed_2143 >>> 0 < $shl91 >>> 0); if (($shl91 | 0) == 0) { break; } else { $readed_3140 = 0; } do { if ((_ferror($call | 0) | 0) != 0) { $offsets_by_id_0 = $13; $ids_0 = $11; $scores_0 = $9; $syncs_0 = $7; break L3760; } if ((_feof($call | 0) | 0) != 0) { $offsets_by_id_0 = $13; $ids_0 = $11; $scores_0 = $9; $syncs_0 = $7; break L3760; } $readed_3140 = (_fread($call34 + $readed_3140 | 0, 1, $shl91 - $readed_3140 | 0, $call | 0) | 0) + $readed_3140 | 0; } while ($readed_3140 >>> 0 < $shl91 >>> 0); } } while (0); $shl131 = HEAP32[$sync_count >> 2] << 2; if (($shl131 | 0) != 0) { $readed_4137 = 0; do { if ((_ferror($call | 0) | 0) != 0) { $offsets_by_id_0 = $13; $ids_0 = $11; $scores_0 = $9; $syncs_0 = $7; break L3760; } if ((_feof($call | 0) | 0) != 0) { $offsets_by_id_0 = $13; $ids_0 = $11; $scores_0 = $9; $syncs_0 = $7; break L3760; } $readed_4137 = (_fread($call27 + $readed_4137 | 0, 1, $shl131 - $readed_4137 | 0, $call | 0) | 0) + $readed_4137 | 0; } while ($readed_4137 >>> 0 < $shl131 >>> 0); } if ((HEAP32[$lemma_count >> 2] | 0) != 0) { $21 = HEAP32[$lemma_count >> 2] | 0; $23 = $21 >>> 0 > 1 ? $21 << 2 : 4; _memcpy($call48 | 0, $call14 | 0, $23) | 0; $i_0135 = 0; do { HEAP32[$11 + ($i_0135 << 2) >> 2] = $i_0135 + $start_id; $i_0135 = $i_0135 + 1 | 0; } while ($i_0135 >>> 0 < $21 >>> 0); } HEAP32[$this + 24 >> 2] = $call9; HEAP32[$this + 28 >> 2] = $3; HEAP32[$this + 44 >> 2] = $7; HEAP32[$this + 48 >> 2] = (HEAP32[$sync_count >> 2] | 0) + 32; HEAP32[$this + 52 >> 2] = $13; HEAP32[$this + 32 >> 2] = $9; HEAP32[$this + 36 >> 2] = $11; HEAP32[$this + 40 >> 2] = $5; HEAP32[$this + 56 >> 2] = 32; HEAP32[$this + 60 >> 2] = 1088; $25 = $this + 68 | 0; _memcpy($25 | 0, $0 | 0, 36) | 0; HEAP32[$this + 104 >> 2] = 1; _fclose($call | 0) | 0; $retval_0 = 1; STACKTOP = sp; return $retval_0 | 0; } } while (0); if (($call9 | 0) == 0) { $syncs_099 = $syncs_0; $scores_0100 = $scores_0; $ids_0101 = $ids_0; $offsets_by_id_0102 = $offsets_by_id_0; $predicts_0103 = $5; } else { $syncs_0108 = $syncs_0; $scores_0109 = $scores_0; $ids_0110 = $ids_0; $offsets_by_id_0111 = $offsets_by_id_0; $predicts_0112 = $5; label = 2980; } } if ((label | 0) == 2980) { _free($call9); $syncs_099 = $syncs_0108; $scores_0100 = $scores_0109; $ids_0101 = $ids_0110; $offsets_by_id_0102 = $offsets_by_id_0111; $predicts_0103 = $predicts_0112; } if (($call14 | 0) != 0) { _free($call14); } if (($syncs_099 | 0) != 0) { _free($syncs_099); } if (($scores_0100 | 0) != 0) { _free($scores_0100); } if (($ids_0101 | 0) != 0) { _free($ids_0101); } if (($offsets_by_id_0102 | 0) != 0) { _free($offsets_by_id_0102); } if (($predicts_0103 | 0) == 0) { break; } _free($predicts_0103); } } while (0); _fclose($call | 0) | 0; $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } function __ZN10ime_pinyin8UserDict10close_dictEv($this) { $this = $this | 0; var $0 = 0, $1 = 0, $2 = 0, label = 0; $0 = HEAP32[$this + 104 >> 2] | 0; if (($0 | 0) == 0) { return 1; } else if (($0 | 0) != 1) { label = 2999; } do { if ((label | 0) == 2999) { $1 = HEAP32[$this + 8 >> 2] | 0; $2 = HEAP32[11850] | 0; if (($1 | 0) <= ($2 | 0)) { if (($1 | 0) != ($2 | 0)) { break; } if ((HEAP32[$this + 12 >> 2] | 0) <= (HEAP32[11851] | 0)) { break; } } __ZN10ime_pinyin8UserDict10write_backEv($this); _gettimeofday(47400, 0) | 0; } } while (0); _free(HEAP32[$this + 64 >> 2] | 0); _free(HEAP32[$this + 24 >> 2] | 0); _free(HEAP32[$this + 28 >> 2] | 0); _free(HEAP32[$this + 52 >> 2] | 0); _free(HEAP32[$this + 32 >> 2] | 0); _free(HEAP32[$this + 36 >> 2] | 0); _free(HEAP32[$this + 40 >> 2] | 0); _memset($this + 20 | 0, 0, 88); return 1; } function __ZN10ime_pinyin8UserDict10write_backEv($this) { $this = $this | 0; var $state_ = 0, $call = 0, $2 = 0, sp = 0; sp = STACKTOP; $state_ = $this + 104 | 0; if ((HEAP32[$state_ >> 2] | 0) >>> 0 < 2) { STACKTOP = sp; return; } $call = _open(HEAP32[$this + 64 >> 2] | 0, 1, (tempInt = STACKTOP, STACKTOP = STACKTOP + 1 | 0, STACKTOP = STACKTOP + 7 >> 3 << 3, HEAP32[tempInt >> 2] = 0, tempInt) | 0) | 0; if (($call | 0) == -1) { STACKTOP = sp; return; } $2 = HEAP32[$state_ >> 2] | 0; if (($2 | 0) == 4) { __ZN10ime_pinyin8UserDict17write_back_offsetEi($this, $call); } else if (($2 | 0) == 2) { __ZN10ime_pinyin8UserDict15write_back_syncEi($this, $call); } else if (($2 | 0) == 3) { __ZN10ime_pinyin8UserDict16write_back_scoreEi($this, $call); } else if (($2 | 0) == 6) { __ZN10ime_pinyin8UserDict14write_back_allEi($this, $call); } else if (($2 | 0) == 5) { __ZN10ime_pinyin8UserDict16write_back_lemmaEi($this, $call); } _ftruncate($call | 0, _lseek($call | 0, 0, 1) | 0) | 0; _close($call | 0) | 0; HEAP32[$state_ >> 2] = 1; STACKTOP = sp; return; } function __ZN10ime_pinyin8UserDict11extend_dictEtPKNS_11DictExtParaEPNS_10LmaPsbItemEjPj($this, $from_handle, $dep, $lpi_items, $lpi_max, $lpi_num) { $this = $this | 0; $from_handle = $from_handle | 0; $dep = $dep | 0; $lpi_items = $lpi_items | 0; $lpi_max = $lpi_max | 0; $lpi_num = $lpi_num | 0; var $need_extend = 0, $call4 = 0, $retval_0 = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 8 | 0; $need_extend = sp | 0; if (!(__ZN10ime_pinyin8UserDict14is_valid_stateEv($this) | 0)) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } HEAP8[$need_extend] = 0; $call4 = __ZN10ime_pinyin8UserDict9_get_lpisEPKttPNS_10LmaPsbItemEjPb($this, $dep | 0, (HEAP16[$dep + 80 >> 1] | 0) + 1 & 65535, $lpi_items, $lpi_max, $need_extend) | 0; HEAP32[$lpi_num >> 2] = $call4; if (($call4 | 0) != 0) { $retval_0 = 1; STACKTOP = sp; return $retval_0 | 0; } $retval_0 = HEAP8[$need_extend] & 1; STACKTOP = sp; return $retval_0 | 0; } function __ZN10ime_pinyin8UserDict9_get_lpisEPKttPNS_10LmaPsbItemEjPb($this, $splid_str, $splid_str_len, $lpi_items, $lpi_max, $need_extend) { $this = $this | 0; $splid_str = $splid_str | 0; $splid_str_len = $splid_str_len | 0; $lpi_items = $lpi_items | 0; $lpi_max = $lpi_max | 0; $need_extend = $need_extend | 0; var $searchable = 0, $start = 0, $count = 0, $tmp_extend_need_extend = 0, $0 = 0, $1 = 0, $6 = 0, $call15 = 0, $7 = 0, $call19 = 0, $middle_0 = 0, $max_off_0 = 0, $offsets_ = 0, $scores_ = 0, $ids_ = 0, $middle_1 = 0, $10 = 0, $call37 = 0, $call38 = 0, $fuzzy_break_1_off0 = 0, $conv50 = 0, $prefix_break_1_off0 = 0, $17 = 0, $lpi_current_1 = 0, $middle_1_ph = 0, $lpi_current_0_ph = 0, $fuzzy_break_0_off0_ph = 0, $prefix_break_0_off0_ph = 0, $cmp31 = 0, $23 = 0, $sub = 0, $retval_0 = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 72 | 0; $searchable = sp + 8 | 0; $start = sp + 56 | 0; $count = sp + 64 | 0; $tmp_extend_need_extend = ($need_extend | 0) == 0 ? sp | 0 : $need_extend; HEAP8[$tmp_extend_need_extend] = 0; if (($lpi_max | 0) == 0 | (__ZN10ime_pinyin8UserDict14is_valid_stateEv($this) | 0) ^ 1) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } $0 = HEAP32[$this + 8 >> 2] | 0; $1 = HEAP32[11850] | 0; do { if (($0 | 0) < ($1 | 0)) { label = 3031; } else { if (($0 | 0) != ($1 | 0)) { break; } if ((HEAP32[$this + 12 >> 2] | 0) < (HEAP32[11851] | 0)) { label = 3031; } } } while (0); if ((label | 0) == 3031) { FUNCTION_TABLE_vi[HEAP32[(HEAP32[$this >> 2] | 0) + 76 >> 2] & 127]($this); } __ZN10ime_pinyin8UserDict14prepare_locateEPNS0_18UserDictSearchableEPKtt(0, $searchable, $splid_str, $splid_str_len); $6 = HEAP32[$this + 80 >> 2] | 0; $call15 = __ZN10ime_pinyin8UserDict9cache_hitEPNS0_18UserDictSearchableEPjS3_($this, $searchable, $start, $count) | 0; if ($call15) { $7 = HEAP32[$start >> 2] | 0; $max_off_0 = (HEAP32[$count >> 2] | 0) + $7 | 0; $middle_0 = $7; } else { $call19 = __ZN10ime_pinyin8UserDict23locate_first_in_offsetsEPKNS0_18UserDictSearchableE($this, $searchable) | 0; HEAP32[$start >> 2] = $call19; $max_off_0 = $6; $middle_0 = $call19; } if (($middle_0 | 0) == -1) { if ($call15) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } __ZN10ime_pinyin8UserDict10cache_pushENS0_17UserDictCacheTypeEPNS0_18UserDictSearchableEjj($this, 1, $searchable, 0, 0); $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } $offsets_ = $this + 28 | 0; $scores_ = $this + 32 | 0; $ids_ = $this + 36 | 0; $prefix_break_0_off0_ph = 0; $fuzzy_break_0_off0_ph = 0; $lpi_current_0_ph = 0; $middle_1_ph = $middle_0; L3881 : while (1) { $cmp31 = $lpi_current_0_ph >>> 0 < $lpi_max >>> 0; $middle_1 = $middle_1_ph; while (1) { if (!($cmp31 & (($middle_1 >>> 0 >= $max_off_0 >>> 0 | $fuzzy_break_0_off0_ph | $prefix_break_0_off0_ph) ^ 1))) { break L3881; } $10 = HEAP32[(HEAP32[$offsets_ >> 2] | 0) + ($middle_1 << 2) >> 2] | 0; if (($10 | 0) < 0) { $middle_1 = $middle_1 + 1 | 0; } else { break; } } $call37 = __ZN10ime_pinyin8UserDict15get_lemma_ncharEj($this, $10) | 0; $call38 = __ZN10ime_pinyin8UserDict19get_lemma_spell_idsEj($this, $10) | 0; if ($call15) { $fuzzy_break_1_off0 = $fuzzy_break_0_off0_ph; } else { $fuzzy_break_1_off0 = $fuzzy_break_0_off0_ph | (__ZN10ime_pinyin8UserDict22fuzzy_compare_spell_idEPKttPKNS0_18UserDictSearchableE(0, $call38, $call37 & 255, $searchable) | 0) != 0; } do { if ($prefix_break_0_off0_ph) { $prefix_break_1_off0 = 1; } else { $conv50 = $call37 & 255; if ((__ZN10ime_pinyin8UserDict24is_fuzzy_prefix_spell_idEPKttPKNS0_18UserDictSearchableE(0, $call38, $conv50, $searchable) | 0) == 0) { $prefix_break_1_off0 = 1; break; } if ((HEAP8[$tmp_extend_need_extend] & 1) != 0) { $prefix_break_1_off0 = $prefix_break_0_off0_ph; break; } if (!(__ZN10ime_pinyin8UserDict18is_prefix_spell_idEPKttPKNS0_18UserDictSearchableE(0, $call38, $conv50, $searchable) | 0)) { $prefix_break_1_off0 = $prefix_break_0_off0_ph; break; } HEAP8[$tmp_extend_need_extend] = 1; $prefix_break_1_off0 = $prefix_break_0_off0_ph; } } while (0); if (__ZN10ime_pinyin8UserDict14equal_spell_idEPKttPKNS0_18UserDictSearchableE(0, $call38, $call37 & 255, $searchable) | 0) { HEAP16[$lpi_items + ($lpi_current_0_ph << 3) + 4 >> 1] = __ZN10ime_pinyin8UserDict15translate_scoreEi($this, HEAP32[(HEAP32[$scores_ >> 2] | 0) + ($middle_1 << 2) >> 2] | 0) | 0; $17 = $lpi_items + ($lpi_current_0_ph << 3) | 0; HEAP32[$17 >> 2] = HEAP32[(HEAP32[$ids_ >> 2] | 0) + ($middle_1 << 2) >> 2] & 16777215 | ($call37 & 255) << 24 & 251658240 | HEAP32[$17 >> 2] & -268435456; $lpi_current_1 = $lpi_current_0_ph + 1 | 0; } else { $lpi_current_1 = $lpi_current_0_ph; } $prefix_break_0_off0_ph = $prefix_break_1_off0; $fuzzy_break_0_off0_ph = $fuzzy_break_1_off0; $lpi_current_0_ph = $lpi_current_1; $middle_1_ph = $middle_1 + 1 | 0; } if ($call15) { $retval_0 = $lpi_current_0_ph; STACKTOP = sp; return $retval_0 | 0; } $23 = HEAP32[$start >> 2] | 0; $sub = $middle_1 - $23 | 0; HEAP32[$count >> 2] = $sub; __ZN10ime_pinyin8UserDict10cache_pushENS0_17UserDictCacheTypeEPNS0_18UserDictSearchableEjj($this, 0, $searchable, $23, $sub); $retval_0 = $lpi_current_0_ph; STACKTOP = sp; return $retval_0 | 0; } function __ZN10ime_pinyin8UserDict24is_fuzzy_prefix_spell_idEPKttPKNS0_18UserDictSearchableE($this, $id1, $len1, $searchable) { $this = $this | 0; $id1 = $id1 | 0; $len1 = $len1 | 0; $searchable = $searchable | 0; var $splids_len = 0, $call = 0, $i_0 = 0, $3 = 0, $conv9 = 0, $retval_0 = 0, label = 0; $splids_len = $searchable | 0; if ((HEAPU16[$splids_len >> 1] | 0) > ($len1 & 65535)) { $retval_0 = 0; return $retval_0 | 0; } $call = __ZN10ime_pinyin12SpellingTrie12get_instanceEv() | 0; $i_0 = 0; while (1) { if ($i_0 >>> 0 >= (HEAPU16[$splids_len >> 1] | 0) >>> 0) { $retval_0 = 1; label = 3067; break; } $3 = HEAP8[__ZN10ime_pinyin12SpellingTrie16get_spelling_strEt($call, HEAP16[$id1 + ($i_0 << 1) >> 1] | 0) | 0] | 0; $conv9 = $i_0 << 3 & 24; if (($3 << 24 >> 24 | 0) == ((HEAP32[$searchable + 36 + ($i_0 >>> 2 << 2) >> 2] & 255 << $conv9) >>> ($conv9 >>> 0) << 24 >> 24 | 0)) { $i_0 = $i_0 + 1 | 0; } else { $retval_0 = 0; label = 3065; break; } } if ((label | 0) == 3065) { return $retval_0 | 0; } else if ((label | 0) == 3067) { return $retval_0 | 0; } return 0; } function __ZN10ime_pinyin8UserDict22fuzzy_compare_spell_idEPKttPKNS0_18UserDictSearchableE($this, $id1, $len1, $searchable) { $this = $this | 0; $id1 = $id1 | 0; $len1 = $len1 | 0; $searchable = $searchable | 0; var $conv = 0, $0 = 0, $call = 0, $i_0 = 0, $2 = 0, $conv14 = 0, $conv17 = 0, $conv18 = 0, $retval_0 = 0, label = 0; $conv = $len1 & 65535; $0 = HEAP16[$searchable >> 1] | 0; if (($0 & 65535) > ($len1 & 65535)) { $retval_0 = -1; return $retval_0 | 0; } if (($0 & 65535) < ($len1 & 65535)) { $retval_0 = 1; return $retval_0 | 0; } $call = __ZN10ime_pinyin12SpellingTrie12get_instanceEv() | 0; $i_0 = 0; while (1) { if ($i_0 >>> 0 >= $conv >>> 0) { $retval_0 = 0; label = 3076; break; } $2 = HEAP8[__ZN10ime_pinyin12SpellingTrie16get_spelling_strEt($call, HEAP16[$id1 + ($i_0 << 1) >> 1] | 0) | 0] | 0; $conv14 = $i_0 << 3 & 24; $conv17 = $2 << 24 >> 24; $conv18 = (HEAP32[$searchable + 36 + ($i_0 >>> 2 << 2) >> 2] & 255 << $conv14) >>> ($conv14 >>> 0) << 24 >> 24; if (($conv17 | 0) == ($conv18 | 0)) { $i_0 = $i_0 + 1 | 0; } else { break; } } if ((label | 0) == 3076) { return $retval_0 | 0; } $retval_0 = ($conv17 | 0) > ($conv18 | 0) ? 1 : -1; return $retval_0 | 0; } function __ZN10ime_pinyin8UserDict23locate_first_in_offsetsEPKNS0_18UserDictSearchableE($this, $searchable) { $this = $this | 0; $searchable = $searchable | 0; var $offsets_ = 0, $first_prefix_0_ph = 0, $end_0_ph_in = 0, $begin_0_ph = 0, $end_0_ph = 0, $first_prefix_0 = 0, $begin_0 = 0, $shr = 0, $2 = 0, $call = 0, $call2 = 0, $conv = 0, $call4 = 0, $first_prefix_0_shr = 0; $offsets_ = $this + 28 | 0; $begin_0_ph = 0; $end_0_ph_in = HEAP32[$this + 80 >> 2] | 0; $first_prefix_0_ph = -1; L3929 : while (1) { $end_0_ph = $end_0_ph_in - 1 | 0; $begin_0 = $begin_0_ph; $first_prefix_0 = $first_prefix_0_ph; while (1) { if (($begin_0 | 0) > ($end_0_ph | 0)) { break L3929; } $shr = $begin_0 + $end_0_ph >> 1; $2 = HEAP32[(HEAP32[$offsets_ >> 2] | 0) + ($shr << 2) >> 2] | 0; $call = __ZN10ime_pinyin8UserDict15get_lemma_ncharEj($this, $2) | 0; $call2 = __ZN10ime_pinyin8UserDict19get_lemma_spell_idsEj($this, $2) | 0; $conv = $call & 255; $call4 = __ZN10ime_pinyin8UserDict22fuzzy_compare_spell_idEPKttPKNS0_18UserDictSearchableE(0, $call2, $conv, $searchable) | 0; $first_prefix_0_shr = (__ZN10ime_pinyin8UserDict24is_fuzzy_prefix_spell_idEPKttPKNS0_18UserDictSearchableE(0, $call2, $conv, $searchable) | 0) == 0 ? $first_prefix_0 : $shr; if (($call4 | 0) < 0) { $begin_0 = $shr + 1 | 0; $first_prefix_0 = $first_prefix_0_shr; } else { $begin_0_ph = $begin_0; $end_0_ph_in = $shr; $first_prefix_0_ph = $first_prefix_0_shr; continue L3929; } } } return $first_prefix_0 | 0; } function __ZN10ime_pinyin8UserDict14prepare_locateEPNS0_18UserDictSearchableEPKtt($this, $searchable, $splid_str, $splid_str_len) { $this = $this | 0; $searchable = $searchable | 0; $splid_str = $splid_str | 0; $splid_str_len = $splid_str_len | 0; var $0 = 0, $call = 0, $conv = 0, $i_025 = 0, $arrayidx = 0, $shl = 0, $arrayidx16 = 0; HEAP16[$searchable >> 1] = $splid_str_len; $0 = $searchable + 36 | 0; HEAP32[$0 >> 2] = 0; HEAP32[$0 + 4 >> 2] = 0; $call = __ZN10ime_pinyin12SpellingTrie12get_instanceEv() | 0; $conv = $splid_str_len & 65535; if ($splid_str_len << 16 >> 16 == 0) { return; } else { $i_025 = 0; } do { $arrayidx = $splid_str + ($i_025 << 1) | 0; if (__ZNK10ime_pinyin12SpellingTrie10is_half_idEt($call, HEAP16[$arrayidx >> 1] | 0) | 0) { HEAP16[$searchable + 18 + ($i_025 << 1) >> 1] = __ZNK10ime_pinyin12SpellingTrie12half_to_fullEtPt($call, HEAP16[$arrayidx >> 1] | 0, $searchable + 2 + ($i_025 << 1) | 0) | 0; } else { HEAP16[$searchable + 18 + ($i_025 << 1) >> 1] = 1; HEAP16[$searchable + 2 + ($i_025 << 1) >> 1] = HEAP16[$arrayidx >> 1] | 0; } $shl = (HEAPU8[__ZN10ime_pinyin12SpellingTrie16get_spelling_strEt($call, HEAP16[$arrayidx >> 1] | 0) | 0] | 0) << ($i_025 << 3 & 24); $arrayidx16 = $searchable + 36 + ($i_025 >>> 2 << 2) | 0; HEAP32[$arrayidx16 >> 2] = $shl | HEAP32[$arrayidx16 >> 2]; $i_025 = $i_025 + 1 | 0; } while ($i_025 >>> 0 < $conv >>> 0); return; } function __ZN10ime_pinyin8UserDict8get_lpisEPKttPNS_10LmaPsbItemEj($this, $splid_str, $splid_str_len, $lpi_items, $lpi_max) { $this = $this | 0; $splid_str = $splid_str | 0; $splid_str_len = $splid_str_len | 0; $lpi_items = $lpi_items | 0; $lpi_max = $lpi_max | 0; return __ZN10ime_pinyin8UserDict9_get_lpisEPKttPNS_10LmaPsbItemEjPb($this, $splid_str, $splid_str_len, $lpi_items, $lpi_max, 0) | 0; } function __ZN10ime_pinyin8UserDict10load_cacheEPNS0_18UserDictSearchableEPjS3_($this, $searchable, $offset, $length) { $this = $this | 0; $searchable = $searchable | 0; $offset = $offset | 0; $length = $length | 0; var $sub = 0, $1 = 0, $tail = 0, $i_0 = 0, $idxprom8 = 0, $j_0 = 0, $conv5 = 0, $inc20 = 0, $sub25_inc20 = 0, $retval_0 = 0, label = 0; $sub = (HEAPU16[$searchable >> 1] | 0) - 1 | 0; $1 = HEAP16[$this + 588 + ($sub * 68 | 0) + 64 >> 1] | 0; $tail = $this + 588 + ($sub * 68 | 0) + 66 | 0; if ($1 << 16 >> 16 == (HEAP16[$tail >> 1] | 0)) { $retval_0 = 0; return $retval_0 | 0; } else { $i_0 = $1; } L3949 : while (1) { $idxprom8 = $i_0 & 65535; $j_0 = 0; while (1) { $conv5 = $j_0 & 65535; if (($j_0 & 65535) >= 2) { break L3949; } if ((HEAP32[$this + 588 + ($sub * 68 | 0) + ($idxprom8 << 3) + ($conv5 << 2) >> 2] | 0) == (HEAP32[$searchable + 36 + ($conv5 << 2) >> 2] | 0)) { $j_0 = $j_0 + 1 & 65535; } else { break; } } $inc20 = $i_0 + 1 & 65535; $sub25_inc20 = ($inc20 & 65535) > 3 ? $i_0 - 3 & 65535 : $inc20; if ($sub25_inc20 << 16 >> 16 == (HEAP16[$tail >> 1] | 0)) { $retval_0 = 0; label = 3100; break; } else { $i_0 = $sub25_inc20; } } if ((label | 0) == 3100) { return $retval_0 | 0; } HEAP32[$offset >> 2] = HEAP32[$this + 588 + ($sub * 68 | 0) + 32 + ($idxprom8 << 2) >> 2]; HEAP32[$length >> 2] = HEAP32[$this + 588 + ($sub * 68 | 0) + 48 + ($idxprom8 << 2) >> 2]; $retval_0 = 1; return $retval_0 | 0; } function __ZN10ime_pinyin8UserDict27remove_lemma_from_sync_listEj($this, $offset) { $this = $this | 0; $offset = $offset | 0; var $syncs_ = 0, $sync_count = 0, $0 = 0, $i_0 = 0, $5 = 0, $6 = 0; $syncs_ = $this + 44 | 0; $sync_count = $this + 96 | 0; $0 = HEAP32[$sync_count >> 2] | 0; $i_0 = 0; while (1) { if ($i_0 >>> 0 >= $0 >>> 0) { break; } if (((HEAP32[(HEAP32[$syncs_ >> 2] | 0) + ($i_0 << 2) >> 2] ^ $offset) & 2147483647 | 0) == 0) { break; } else { $i_0 = $i_0 + 1 | 0; } } $5 = HEAP32[$sync_count >> 2] | 0; if ($i_0 >>> 0 >= $5 >>> 0) { return; } $6 = HEAP32[$this + 44 >> 2] | 0; HEAP32[$6 + ($i_0 << 2) >> 2] = HEAP32[$6 + ($5 - 1 << 2) >> 2]; HEAP32[$sync_count >> 2] = (HEAP32[$sync_count >> 2] | 0) - 1; return; } function __ZN10ime_pinyin8UserDict30remove_lemma_from_predict_listEj($this, $offset) { $this = $this | 0; $offset = $offset | 0; var $0 = 0, $predicts_ = 0, $i_0 = 0, $arrayidx = 0, $2 = 0, label = 0; $0 = HEAP32[$this + 80 >> 2] | 0; $predicts_ = $this + 40 | 0; $i_0 = 0; while (1) { if ($i_0 >>> 0 >= $0 >>> 0) { label = 3117; break; } $arrayidx = (HEAP32[$predicts_ >> 2] | 0) + ($i_0 << 2) | 0; $2 = HEAP32[$arrayidx >> 2] | 0; if ((($2 ^ $offset) & 2147483647 | 0) == 0) { break; } else { $i_0 = $i_0 + 1 | 0; } } if ((label | 0) == 3117) { return; } HEAP32[$arrayidx >> 2] = $2 | -2147483648; return; } function __ZN10ime_pinyin8UserDict18get_dict_file_sizeEPNS0_12UserDictInfoE($this, $info) { $this = $this | 0; $info = $info | 0; var $1 = 0; $1 = HEAP32[$info + 12 >> 2] | 0; return (HEAP32[$info + 16 >> 2] | 0) + 40 + ($1 << 3) + ((HEAP32[$info + 28 >> 2] | 0) + $1 << 2) | 0; } function __ZN10ime_pinyin8UserDict9cache_hitEPNS0_18UserDictSearchableEPjS3_($this, $searchable, $offset, $length) { $this = $this | 0; $searchable = $searchable | 0; $offset = $offset | 0; $length = $length | 0; var $retval_0 = 0; if (__ZN10ime_pinyin8UserDict15load_miss_cacheEPNS0_18UserDictSearchableE($this, $searchable) | 0) { HEAP32[$offset >> 2] = 0; HEAP32[$length >> 2] = 0; $retval_0 = 1; return $retval_0 | 0; } else { $retval_0 = __ZN10ime_pinyin8UserDict10load_cacheEPNS0_18UserDictSearchableEPjS3_($this, $searchable, $offset, $length) | 0; return $retval_0 | 0; } return 0; } function __ZN10ime_pinyin8UserDict10cache_pushENS0_17UserDictCacheTypeEPNS0_18UserDictSearchableEjj($this, $type, $searchable, $offset, $length) { $this = $this | 0; $type = $type | 0; $searchable = $searchable | 0; $offset = $offset | 0; $length = $length | 0; if (($type | 0) == 0) { __ZN10ime_pinyin8UserDict10save_cacheEPNS0_18UserDictSearchableEjj($this, $searchable, $offset, $length); return; } else if (($type | 0) == 1) { __ZN10ime_pinyin8UserDict15save_miss_cacheEPNS0_18UserDictSearchableE($this, $searchable); return; } else { return; } } function __ZN10ime_pinyin8UserDict15translate_scoreEi($this, $raw_score) { $this = $this | 0; $raw_score = $raw_score | 0; var $call = 0, $0 = 0, $sub$0 = 0, $div$0 = 0, $sub4$0 = 0, $conv5 = 0; $call = __ZN10ime_pinyin8UserDict18extract_score_freqEi(0, $raw_score) | 0; $0 = HEAP32[$this + 8 >> 2] | 0; $sub$0 = _i64Add($0, ($0 | 0) < 0 ? -1 : 0, -1229904e3, -1) | 0; $div$0 = ___udivdi3($sub$0, tempRet0, 604800, 0) | 0; $sub4$0 = _i64Subtract($div$0 & 65535, tempRet0 & 0, $raw_score >>> 16, 0) | 0; $conv5 = $sub4$0; return ~~(+Math_log(+(+($call >>> 0 >>> 0) * (($conv5 | 0) > 4 ? 16.0 : +(80 - ($conv5 << 4) | 0)) / +(((HEAP32[$this + 4 >> 2] | 0) + (HEAP32[$this + 100 >> 2] | 0) | 0) >>> 0 >>> 0))) * -800.0) | 0; } function __ZN10ime_pinyin8UserDict13get_lemma_strEjPtt($this, $id_lemma, $str_buf, $str_max) { $this = $this | 0; $id_lemma = $id_lemma | 0; $str_buf = $str_buf | 0; $str_max = $str_max | 0; var $2 = 0, $call7 = 0, $call8 = 0, $sub11 = 0, $cond_off0 = 0, $conv17 = 0, $3 = 0, $4 = 0, $i_012 = 0, $i_0_lcssa = 0, $retval_0 = 0; if (!(__ZN10ime_pinyin8UserDict14is_valid_stateEv($this) | 0)) { $retval_0 = 0; return $retval_0 | 0; } if (!(__ZN10ime_pinyin8UserDict17is_valid_lemma_idEj($this, $id_lemma) | 0)) { $retval_0 = 0; return $retval_0 | 0; } $2 = HEAP32[(HEAP32[$this + 52 >> 2] | 0) + ($id_lemma - (HEAP32[$this + 16 >> 2] | 0) << 2) >> 2] | 0; $call7 = __ZN10ime_pinyin8UserDict15get_lemma_ncharEj($this, $2) | 0; $call8 = __ZN10ime_pinyin8UserDict14get_lemma_wordEj($this, $2) | 0; $sub11 = ($str_max & 65535) - 1 | 0; $cond_off0 = ($call7 & 255 | 0) < ($sub11 | 0) ? $call7 & 255 : $sub11 & 65535; $conv17 = $cond_off0 & 65535; if ($cond_off0 << 16 >> 16 == 0) { $i_0_lcssa = 0; } else { $3 = $cond_off0 & 65535; $4 = $3 >>> 0 > 1; $i_012 = 0; do { HEAP16[$str_buf + ($i_012 << 1) >> 1] = HEAP16[$call8 + ($i_012 << 1) >> 1] | 0; $i_012 = $i_012 + 1 | 0; } while (($i_012 | 0) < ($conv17 | 0)); $i_0_lcssa = $4 ? $3 : 1; } HEAP16[$str_buf + ($i_0_lcssa << 1) >> 1] = 0; $retval_0 = $cond_off0; return $retval_0 | 0; } function __ZN10ime_pinyin8UserDict17is_valid_lemma_idEj($this, $id) { $this = $this | 0; $id = $id | 0; var $retval_0 = 0; do { if ((HEAP32[$this + 16 >> 2] | 0) >>> 0 <= $id >>> 0) { if ((__ZN10ime_pinyin8UserDict16get_max_lemma_idEv($this) | 0) >>> 0 < $id >>> 0) { break; } else { $retval_0 = 1; } return $retval_0 | 0; } } while (0); $retval_0 = 0; return $retval_0 | 0; } function __ZN10ime_pinyin8UserDict14get_lemma_wordEj($this, $offset) { $this = $this | 0; $offset = $offset | 0; var $and = 0, $call = 0; $and = $offset & 2147483647; $call = __ZN10ime_pinyin8UserDict15get_lemma_ncharEj($this, $and) | 0; return (HEAP32[$this + 24 >> 2] | 0) + ($and + 2 + (($call & 255) << 1)) | 0; } function __ZN10ime_pinyin8UserDict16get_lemma_splidsEjPttb($this, $id_lemma, $splids, $splids_max, $arg_valid) { $this = $this | 0; $id_lemma = $id_lemma | 0; $splids = $splids | 0; $splids_max = $splids_max | 0; $arg_valid = $arg_valid | 0; var $2 = 0, $call2 = 0, $call3 = 0, $conv6 = 0, $conv4 = 0, $5 = 0, $8 = 0, $umax = 0, $i_010 = 0, $retval_0 = 0; if (!(__ZN10ime_pinyin8UserDict17is_valid_lemma_idEj($this, $id_lemma) | 0)) { $retval_0 = 0; return $retval_0 | 0; } $2 = HEAP32[(HEAP32[$this + 52 >> 2] | 0) + ($id_lemma - (HEAP32[$this + 16 >> 2] | 0) << 2) >> 2] | 0; $call2 = __ZN10ime_pinyin8UserDict15get_lemma_ncharEj($this, $2) | 0; $call3 = __ZN10ime_pinyin8UserDict19get_lemma_spell_idsEj($this, $2) | 0; $conv6 = $splids_max & 65535; $conv4 = $call2 & 255; if (!($call2 << 24 >> 24 != 0 & $splids_max << 16 >> 16 != 0)) { $retval_0 = 0; return $retval_0 | 0; } $5 = ($call2 & 255) > 1 ? -($call2 & 255) | 0 : -1; $8 = ($splids_max & 65535) > 1 ? -($splids_max & 65535) | 0 : -1; $umax = $5 >>> 0 > $8 >>> 0 ? $5 : $8; $i_010 = 0; do { HEAP16[$splids + ($i_010 << 1) >> 1] = HEAP16[$call3 + ($i_010 << 1) >> 1] | 0; $i_010 = $i_010 + 1 | 0; } while (($i_010 | 0) < ($conv4 | 0) & ($i_010 | 0) < ($conv6 | 0)); $retval_0 = -$umax & 65535; return $retval_0 | 0; } function __ZN10ime_pinyin8UserDict7predictEPKttPNS_12NPredictItemEjj($this, $last_hzs, $hzs_len, $npre_items, $npre_max, $b4_used) { $this = $this | 0; $last_hzs = $last_hzs | 0; $hzs_len = $hzs_len | 0; $npre_items = $npre_items | 0; $npre_max = $npre_max | 0; $b4_used = $b4_used | 0; var $sub = 0, $conv = 0, $call = 0, $predicts_ = 0, $1 = 0, $shl = 0, $2 = 0, $new_added_0_ph42 = 0, $j_0_ph41 = 0, $3 = 0, $j_034 = 0, $4 = 0, $j_0_be = 0, $call5 = 0, $conv6 = 0, $call7 = 0, $call8 = 0, $sub25 = 0, $7 = 0, $8 = 0, $inc40 = 0, $inc42 = 0, $retval_0 = 0, label = 0; $sub = (HEAP32[$this + 80 >> 2] | 0) - 1 | 0; $conv = $hzs_len & 65535; $call = __ZN10ime_pinyin8UserDict24locate_first_in_predictsEPKti($this, $last_hzs, $conv) | 0; if (($call | 0) == -1 | ($call | 0) > ($sub | 0)) { $retval_0 = 0; return $retval_0 | 0; } $predicts_ = $this + 40 | 0; $1 = $last_hzs; $shl = $conv << 1; $2 = $this; $j_0_ph41 = $call; $new_added_0_ph42 = 0; L4027 : while (1) { $3 = HEAP32[$predicts_ >> 2] | 0; $j_034 = $j_0_ph41; while (1) { $4 = HEAP32[$3 + ($j_034 << 2) >> 2] | 0; if (($4 | 0) >= 0) { $call5 = __ZN10ime_pinyin8UserDict15get_lemma_ncharEj($this, $4) | 0; $conv6 = $call5 << 24 >> 24; $call7 = __ZN10ime_pinyin8UserDict14get_lemma_wordEj($this, $4) | 0; $call8 = __ZN10ime_pinyin8UserDict19get_lemma_spell_idsEj($this, $4) | 0; if ($conv6 >>> 0 > $conv >>> 0) { break; } } $j_0_be = $j_034 + 1 | 0; if (($j_0_be | 0) > ($sub | 0)) { $retval_0 = $new_added_0_ph42; label = 3171; break L4027; } else { $j_034 = $j_0_be; } } if (!((_memcmp($call7 | 0, $1 | 0, $shl | 0) | 0) == 0 & $new_added_0_ph42 >>> 0 < $npre_max >>> 0)) { $retval_0 = $new_added_0_ph42; label = 3174; break; } $sub25 = (($call5 & 255) < 7 ? $conv6 << 1 : 14) - $shl | 0; HEAP16[$npre_items + ($new_added_0_ph42 * 20 | 0) + 18 >> 1] = $hzs_len; HEAPF32[$npre_items + ($new_added_0_ph42 * 20 | 0) >> 2] = +(((FUNCTION_TABLE_iiiii[HEAP32[(HEAP32[$2 >> 2] | 0) + 60 >> 2] & 31]($this, $call7, $call8, $call5 << 24 >> 24) | 0) & 65535) >>> 0); $7 = $npre_items + ($new_added_0_ph42 * 20 | 0) + 4 | 0; $8 = $call7 + ($conv << 1) | 0; _memcpy($7 | 0, $8 | 0, $sub25) | 0; if ($sub25 >>> 0 < 14) { HEAP16[$npre_items + ($new_added_0_ph42 * 20 | 0) + 4 + ($sub25 >>> 1 << 1) >> 1] = 0; } $inc40 = $new_added_0_ph42 + 1 | 0; $inc42 = $j_034 + 1 | 0; if (($inc42 | 0) > ($sub | 0)) { $retval_0 = $inc40; label = 3173; break; } else { $j_0_ph41 = $inc42; $new_added_0_ph42 = $inc40; } } if ((label | 0) == 3171) { return $retval_0 | 0; } else if ((label | 0) == 3173) { return $retval_0 | 0; } else if ((label | 0) == 3174) { return $retval_0 | 0; } return 0; } function __ZN10ime_pinyin8UserDict24locate_first_in_predictsEPKti($this, $words, $lemma_len) { $this = $this | 0; $words = $words | 0; $lemma_len = $lemma_len | 0; var $sub = 0, $1 = 0, $begin_0_ph51 = 0, $end_0_ph50 = 0, $last_matched_0_ph49 = 0, $begin_046 = 0, $last_matched_045 = 0, $shr = 0, $2 = 0, $call = 0, $call2 = 0, $conv = 0, $cmp3 = 0, $conv_lemma_len = 0, $k_0 = 0, $3 = 0, $4 = 0, $last_matched_0_shr = 0, $last_matched_228 = 0, $add37 = 0, $last_matched_231 = 0, $sub41 = 0, $last_matched_0_lcssa = 0, label = 0; $sub = (HEAP32[$this + 80 >> 2] | 0) - 1 | 0; if (($sub | 0) < 0) { $last_matched_0_lcssa = -1; return $last_matched_0_lcssa | 0; } $1 = HEAP32[$this + 28 >> 2] | 0; $last_matched_0_ph49 = -1; $end_0_ph50 = $sub; $begin_0_ph51 = 0; L4047 : while (1) { $last_matched_045 = $last_matched_0_ph49; $begin_046 = $begin_0_ph51; L4049 : while (1) { $shr = $begin_046 + $end_0_ph50 >> 1; $2 = HEAP32[$1 + ($shr << 2) >> 2] | 0; $call = __ZN10ime_pinyin8UserDict15get_lemma_ncharEj($this, $2) | 0; $call2 = __ZN10ime_pinyin8UserDict14get_lemma_wordEj($this, $2) | 0; $conv = $call & 255; $cmp3 = ($conv | 0) < ($lemma_len | 0); $conv_lemma_len = $cmp3 ? $conv : $lemma_len; $k_0 = 0; while (1) { if ($k_0 >>> 0 >= $conv_lemma_len >>> 0) { label = 3182; break; } $3 = HEAP16[$call2 + ($k_0 << 1) >> 1] | 0; $4 = HEAP16[$words + ($k_0 << 1) >> 1] | 0; if (($3 & 65535) < ($4 & 65535)) { $last_matched_228 = $last_matched_045; break; } if (($3 & 65535) > ($4 & 65535)) { $last_matched_231 = $last_matched_045; break L4049; } else { $k_0 = $k_0 + 1 | 0; } } if ((label | 0) == 3182) { label = 0; $last_matched_0_shr = $cmp3 ? $last_matched_045 : $shr; if ($cmp3) { $last_matched_228 = $last_matched_0_shr; } else { $last_matched_231 = $last_matched_0_shr; break; } } $add37 = $shr + 1 | 0; if (($add37 | 0) > ($end_0_ph50 | 0)) { $last_matched_0_lcssa = $last_matched_228; label = 3186; break L4047; } else { $last_matched_045 = $last_matched_228; $begin_046 = $add37; } } $sub41 = $shr - 1 | 0; if (($begin_046 | 0) > ($sub41 | 0)) { $last_matched_0_lcssa = $last_matched_231; label = 3188; break; } else { $last_matched_0_ph49 = $last_matched_231; $end_0_ph50 = $sub41; $begin_0_ph51 = $begin_046; } } if ((label | 0) == 3188) { return $last_matched_0_lcssa | 0; } else if ((label | 0) == 3186) { return $last_matched_0_lcssa | 0; } return 0; } function __ZN10ime_pinyin8UserDict17locate_in_offsetsEPtS1_t($this, $lemma_str, $splid_str, $lemma_len) { $this = $this | 0; $lemma_str = $lemma_str | 0; $splid_str = $splid_str | 0; $lemma_len = $lemma_len | 0; var $searchable = 0, $start = 0, $count = 0, $0 = 0, $call = 0, $1 = 0, $call2 = 0, $off_0 = 0, $max_off_0 = 0, $offsets_ = 0, $conv19 = 0, $off_123 = 0, $4 = 0, $off_1_be = 0, $call9 = 0, $call18 = 0, $i_0 = 0, $retval_0 = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 64 | 0; $searchable = sp | 0; $start = sp + 48 | 0; $count = sp + 56 | 0; $0 = HEAP32[$this + 80 >> 2] | 0; __ZN10ime_pinyin8UserDict14prepare_locateEPNS0_18UserDictSearchableEPKtt(0, $searchable, $splid_str, $lemma_len); $call = __ZN10ime_pinyin8UserDict10load_cacheEPNS0_18UserDictSearchableEPjS3_($this, $searchable, $start, $count) | 0; if ($call) { $1 = HEAP32[$start >> 2] | 0; $max_off_0 = (HEAP32[$count >> 2] | 0) + $1 | 0; $off_0 = $1; } else { $call2 = __ZN10ime_pinyin8UserDict23locate_first_in_offsetsEPKNS0_18UserDictSearchableE($this, $searchable) | 0; HEAP32[$start >> 2] = $call2; $max_off_0 = $0; $off_0 = $call2; } if (!(($off_0 | 0) != -1 & ($off_0 | 0) < ($max_off_0 | 0))) { $retval_0 = -1; STACKTOP = sp; return $retval_0 | 0; } $offsets_ = $this + 28 | 0; $conv19 = $lemma_len & 65535; $off_123 = $off_0; L4070 : while (1) { $4 = HEAP32[(HEAP32[$offsets_ >> 2] | 0) + ($off_123 << 2) >> 2] | 0; do { if (($4 | 0) >= 0) { $call9 = __ZN10ime_pinyin8UserDict19get_lemma_spell_idsEj($this, $4) | 0; if (!$call) { if ((__ZN10ime_pinyin8UserDict22fuzzy_compare_spell_idEPKttPKNS0_18UserDictSearchableE(0, $call9, $lemma_len, $searchable) | 0) != 0) { $retval_0 = -1; label = 3204; break L4070; } } if (!(__ZN10ime_pinyin8UserDict14equal_spell_idEPKttPKNS0_18UserDictSearchableE(0, $call9, $lemma_len, $searchable) | 0)) { break; } $call18 = __ZN10ime_pinyin8UserDict14get_lemma_wordEj($this, $4) | 0; $i_0 = 0; while (1) { if ($i_0 >>> 0 >= $conv19 >>> 0) { $retval_0 = $off_123; label = 3206; break L4070; } if ((HEAP16[$call18 + ($i_0 << 1) >> 1] | 0) == (HEAP16[$lemma_str + ($i_0 << 1) >> 1] | 0)) { $i_0 = $i_0 + 1 | 0; } else { break; } } } } while (0); $off_1_be = $off_123 + 1 | 0; if (($off_1_be | 0) < ($max_off_0 | 0)) { $off_123 = $off_1_be; } else { $retval_0 = -1; label = 3205; break; } } if ((label | 0) == 3204) { STACKTOP = sp; return $retval_0 | 0; } else if ((label | 0) == 3205) { STACKTOP = sp; return $retval_0 | 0; } else if ((label | 0) == 3206) { STACKTOP = sp; return $retval_0 | 0; } return 0; } function __ZN10ime_pinyin8UserDict34locate_where_to_insert_in_predictsEPKti($this, $words, $lemma_len) { $this = $this | 0; $words = $words | 0; $lemma_len = $lemma_len | 0; var $sub = 0, $1 = 0, $begin_0_ph50 = 0, $end_0_ph49 = 0, $last_matched_0_ph48 = 0, $begin_045 = 0, $last_matched_044 = 0, $shr = 0, $2 = 0, $call = 0, $call2 = 0, $conv = 0, $cmp3 = 0, $conv_lemma_len = 0, $k_0 = 0, $3 = 0, $4 = 0, $add33 = 0, $cmp5_130 = 0, $sub37 = 0, $last_matched_0_lcssa = 0, label = 0; $sub = (HEAP32[$this + 80 >> 2] | 0) - 1 | 0; if (($sub | 0) < 0) { $last_matched_0_lcssa = $sub; return $last_matched_0_lcssa | 0; } $1 = HEAP32[$this + 28 >> 2] | 0; $last_matched_0_ph48 = $sub; $end_0_ph49 = $sub; $begin_0_ph50 = 0; L4090 : while (1) { $last_matched_044 = $last_matched_0_ph48; $begin_045 = $begin_0_ph50; L4092 : while (1) { $shr = $begin_045 + $end_0_ph49 >> 1; $2 = HEAP32[$1 + ($shr << 2) >> 2] | 0; $call = __ZN10ime_pinyin8UserDict15get_lemma_ncharEj($this, $2) | 0; $call2 = __ZN10ime_pinyin8UserDict14get_lemma_wordEj($this, $2) | 0; $conv = $call & 255; $cmp3 = ($conv | 0) < ($lemma_len | 0); $conv_lemma_len = $cmp3 ? $conv : $lemma_len; $k_0 = 0; while (1) { if ($k_0 >>> 0 >= $conv_lemma_len >>> 0) { label = 3214; break; } $3 = HEAP16[$call2 + ($k_0 << 1) >> 1] | 0; $4 = HEAP16[$words + ($k_0 << 1) >> 1] | 0; if (($3 & 65535) < ($4 & 65535)) { break; } if (($3 & 65535) > ($4 & 65535)) { $cmp5_130 = $last_matched_044; break L4092; } else { $k_0 = $k_0 + 1 | 0; } } if ((label | 0) == 3214) { label = 0; if (!$cmp3) { label = 3215; break; } } $add33 = $shr + 1 | 0; if (($add33 | 0) > ($end_0_ph49 | 0)) { $last_matched_0_lcssa = $shr; label = 3219; break L4090; } else { $last_matched_044 = $shr; $begin_045 = $add33; } } if ((label | 0) == 3215) { label = 0; $cmp5_130 = ($conv | 0) > ($lemma_len | 0) ? $last_matched_044 : $shr; } $sub37 = $shr - 1 | 0; if (($begin_045 | 0) > ($sub37 | 0)) { $last_matched_0_lcssa = $cmp5_130; label = 3220; break; } else { $last_matched_0_ph48 = $cmp5_130; $end_0_ph49 = $sub37; $begin_0_ph50 = $begin_045; } } if ((label | 0) == 3219) { return $last_matched_0_lcssa | 0; } else if ((label | 0) == 3220) { return $last_matched_0_lcssa | 0; } return 0; } function __ZN10ime_pinyin8UserDict12get_lemma_idEPtS1_t($this, $lemma_str, $splids, $lemma_len) { $this = $this | 0; $lemma_str = $lemma_str | 0; $splids = $splids | 0; $lemma_len = $lemma_len | 0; var $call = 0, $retval_0 = 0; $call = __ZN10ime_pinyin8UserDict17locate_in_offsetsEPtS1_t($this, $lemma_str, $splids, $lemma_len) | 0; if (($call | 0) == -1) { $retval_0 = 0; return $retval_0 | 0; } $retval_0 = HEAP32[(HEAP32[$this + 36 >> 2] | 0) + ($call << 2) >> 2] | 0; return $retval_0 | 0; } function __ZN10ime_pinyin8UserDict15get_lemma_scoreEj($this, $lemma_id) { $this = $this | 0; $lemma_id = $lemma_id | 0; var $retval_0 = 0; if (!(__ZN10ime_pinyin8UserDict14is_valid_stateEv($this) | 0)) { $retval_0 = 0; return $retval_0 | 0; } if (!(__ZN10ime_pinyin8UserDict17is_valid_lemma_idEj($this, $lemma_id) | 0)) { $retval_0 = 0; return $retval_0 | 0; } $retval_0 = __ZN10ime_pinyin8UserDict15translate_scoreEi($this, __ZN10ime_pinyin8UserDict16_get_lemma_scoreEj($this, $lemma_id) | 0) | 0; return $retval_0 | 0; } function __ZN10ime_pinyin8UserDict16_get_lemma_scoreEj($this, $lemma_id) { $this = $this | 0; $lemma_id = $lemma_id | 0; var $2 = 0, $call7 = 0, $call9 = 0, $call12 = 0, $retval_0 = 0; if (!(__ZN10ime_pinyin8UserDict14is_valid_stateEv($this) | 0)) { $retval_0 = 0; return $retval_0 | 0; } if (!(__ZN10ime_pinyin8UserDict17is_valid_lemma_idEj($this, $lemma_id) | 0)) { $retval_0 = 0; return $retval_0 | 0; } $2 = HEAP32[(HEAP32[$this + 52 >> 2] | 0) + ($lemma_id - (HEAP32[$this + 16 >> 2] | 0) << 2) >> 2] | 0; $call7 = __ZN10ime_pinyin8UserDict15get_lemma_ncharEj($this, $2) | 0; $call9 = __ZN10ime_pinyin8UserDict19get_lemma_spell_idsEj($this, $2) | 0; $call12 = __ZN10ime_pinyin8UserDict17locate_in_offsetsEPtS1_t($this, __ZN10ime_pinyin8UserDict14get_lemma_wordEj($this, $2) | 0, $call9, $call7 << 24 >> 24) | 0; if (($call12 | 0) == -1) { $retval_0 = 0; return $retval_0 | 0; } $retval_0 = HEAP32[(HEAP32[$this + 32 >> 2] | 0) + ($call12 << 2) >> 2] | 0; return $retval_0 | 0; } function __ZN10ime_pinyin8UserDict15get_lemma_scoreEPtS1_t($this, $lemma_str, $splids, $lemma_len) { $this = $this | 0; $lemma_str = $lemma_str | 0; $splids = $splids | 0; $lemma_len = $lemma_len | 0; var $retval_0 = 0; if (!(__ZN10ime_pinyin8UserDict14is_valid_stateEv($this) | 0)) { $retval_0 = 0; return $retval_0 | 0; } $retval_0 = __ZN10ime_pinyin8UserDict15translate_scoreEi($this, __ZN10ime_pinyin8UserDict16_get_lemma_scoreEPtS1_t($this, $lemma_str, $splids, $lemma_len) | 0) | 0; return $retval_0 | 0; } function __ZN10ime_pinyin8UserDict16_get_lemma_scoreEPtS1_t($this, $lemma_str, $splids, $lemma_len) { $this = $this | 0; $lemma_str = $lemma_str | 0; $splids = $splids | 0; $lemma_len = $lemma_len | 0; var $call2 = 0, $retval_0 = 0; if (!(__ZN10ime_pinyin8UserDict14is_valid_stateEv($this) | 0)) { $retval_0 = 0; return $retval_0 | 0; } $call2 = __ZN10ime_pinyin8UserDict17locate_in_offsetsEPtS1_t($this, $lemma_str, $splids, $lemma_len) | 0; if (($call2 | 0) == -1) { $retval_0 = 0; return $retval_0 | 0; } $retval_0 = HEAP32[(HEAP32[$this + 32 >> 2] | 0) + ($call2 << 2) >> 2] | 0; return $retval_0 | 0; } function __ZN10ime_pinyin8UserDict28remove_lemma_by_offset_indexEi($this, $offset_index) { $this = $this | 0; $offset_index = $offset_index | 0; var $arrayidx = 0, $1 = 0, $conv6 = 0, $free_count = 0, $free_size = 0, $state_ = 0, $retval_0 = 0; if (($offset_index | 0) == -1 | (__ZN10ime_pinyin8UserDict14is_valid_stateEv($this) | 0) ^ 1) { $retval_0 = 0; return $retval_0 | 0; } $arrayidx = (HEAP32[$this + 28 >> 2] | 0) + ($offset_index << 2) | 0; $1 = HEAP32[$arrayidx >> 2] | 0; $conv6 = (__ZN10ime_pinyin8UserDict15get_lemma_ncharEj($this, $1) | 0) << 24 >> 24; HEAP32[$arrayidx >> 2] = $1 | -2147483648; __ZN10ime_pinyin8UserDict27remove_lemma_from_sync_listEj($this, $1); __ZN10ime_pinyin8UserDict30remove_lemma_from_predict_listEj($this, $1); $free_count = $this + 88 | 0; HEAP32[$free_count >> 2] = (HEAP32[$free_count >> 2] | 0) + 1; $free_size = $this + 92 | 0; HEAP32[$free_size >> 2] = (HEAP32[$free_size >> 2] | 0) + ($conv6 << 2 | 2); $state_ = $this + 104 | 0; if ((HEAP32[$state_ >> 2] | 0) >= 4) { $retval_0 = 1; return $retval_0 | 0; } HEAP32[$state_ >> 2] = 4; $retval_0 = 1; return $retval_0 | 0; } function __ZN10ime_pinyin8UserDict12remove_lemmaEj($this, $lemma_id) { $this = $this | 0; $lemma_id = $lemma_id | 0; var $2 = 0, $call7 = 0, $call9 = 0, $retval_0 = 0; if (!(__ZN10ime_pinyin8UserDict14is_valid_stateEv($this) | 0)) { $retval_0 = 0; return $retval_0 | 0; } if (!(__ZN10ime_pinyin8UserDict17is_valid_lemma_idEj($this, $lemma_id) | 0)) { $retval_0 = 0; return $retval_0 | 0; } $2 = HEAP32[(HEAP32[$this + 52 >> 2] | 0) + ($lemma_id - (HEAP32[$this + 16 >> 2] | 0) << 2) >> 2] | 0; $call7 = __ZN10ime_pinyin8UserDict15get_lemma_ncharEj($this, $2) | 0; $call9 = __ZN10ime_pinyin8UserDict19get_lemma_spell_idsEj($this, $2) | 0; $retval_0 = __ZN10ime_pinyin8UserDict28remove_lemma_by_offset_indexEi($this, __ZN10ime_pinyin8UserDict17locate_in_offsetsEPtS1_t($this, __ZN10ime_pinyin8UserDict14get_lemma_wordEj($this, $2) | 0, $call9, $call7 << 24 >> 24) | 0) | 0; return $retval_0 | 0; } function __ZN10ime_pinyin8UserDict11flush_cacheEv($this) { $this = $this | 0; var $0 = 0, $call = 0; $0 = HEAP32[$this + 16 >> 2] | 0; $call = _strdup(HEAP32[$this + 64 >> 2] | 0) | 0; if (($call | 0) == 0) { return; } FUNCTION_TABLE_ii[HEAP32[(HEAP32[$this >> 2] | 0) + 12 >> 2] & 31]($this) | 0; FUNCTION_TABLE_iiiii[HEAP32[(HEAP32[$this >> 2] | 0) + 8 >> 2] & 31]($this, $call, $0, 6e5) | 0; _free($call); __ZN10ime_pinyin8UserDict10cache_initEv($this); return; } function __ZN10ime_pinyin8UserDict14write_back_allEi($this, $fd) { $this = $this | 0; $fd = $fd | 0; var $lemma_count = 0; if ((_lseek($fd | 0, 4, 0) | 0) == -1) { return; } _write($fd | 0, HEAP32[$this + 24 >> 2] | 0, HEAP32[$this + 84 >> 2] | 0) | 0; $lemma_count = $this + 80 | 0; _write($fd | 0, HEAP32[$this + 28 >> 2] | 0, HEAP32[$lemma_count >> 2] << 2 | 0) | 0; _write($fd | 0, HEAP32[$this + 40 >> 2] | 0, HEAP32[$lemma_count >> 2] << 2 | 0) | 0; _write($fd | 0, HEAP32[$this + 32 >> 2] | 0, HEAP32[$lemma_count >> 2] << 2 | 0) | 0; _write($fd | 0, HEAP32[$this + 44 >> 2] | 0, HEAP32[$this + 96 >> 2] << 2 | 0) | 0; _write($fd | 0, $this + 68 | 0, 36) | 0; return; } function __ZN10ime_pinyin8UserDict16write_back_lemmaEi($this, $fd) { $this = $this | 0; $fd = $fd | 0; var $sub = 0, $lemma_size = 0, $lemma_count = 0; if ((_lseek($fd | 0, 4, 0) | 0) == -1) { return; } $sub = 1088 - (HEAP32[$this + 60 >> 2] | 0) | 0; $lemma_size = $this + 84 | 0; if ((_lseek($fd | 0, (HEAP32[$lemma_size >> 2] | 0) - $sub | 0, 1) | 0) == -1) { return; } _write($fd | 0, (HEAP32[$this + 24 >> 2] | 0) + ((HEAP32[$lemma_size >> 2] | 0) - $sub) | 0, $sub | 0) | 0; $lemma_count = $this + 80 | 0; _write($fd | 0, HEAP32[$this + 28 >> 2] | 0, HEAP32[$lemma_count >> 2] << 2 | 0) | 0; _write($fd | 0, HEAP32[$this + 40 >> 2] | 0, HEAP32[$lemma_count >> 2] << 2 | 0) | 0; _write($fd | 0, HEAP32[$this + 32 >> 2] | 0, HEAP32[$lemma_count >> 2] << 2 | 0) | 0; _write($fd | 0, HEAP32[$this + 44 >> 2] | 0, HEAP32[$this + 96 >> 2] << 2 | 0) | 0; _write($fd | 0, $this + 68 | 0, 36) | 0; return; } function __ZN10ime_pinyin8UserDict10save_cacheEPNS0_18UserDictSearchableEjj($this, $searchable, $offset, $length) { $this = $this | 0; $searchable = $searchable | 0; $offset = $offset | 0; $length = $length | 0; var $sub = 0, $tail = 0, $1 = 0, $idxprom = 0, $inc13 = 0, $sub17_inc13 = 0, $head = 0, $4 = 0, $inc24 = 0; $sub = (HEAPU16[$searchable >> 1] | 0) - 1 | 0; $tail = $this + 588 + ($sub * 68 | 0) + 66 | 0; $1 = HEAP16[$tail >> 1] | 0; $idxprom = $1 & 65535; HEAP32[$this + 588 + ($sub * 68 | 0) + 32 + ($idxprom << 2) >> 2] = $offset; HEAP32[$this + 588 + ($sub * 68 | 0) + 48 + ($idxprom << 2) >> 2] = $length; HEAP32[$this + 588 + ($sub * 68 | 0) + ($idxprom << 3) >> 2] = HEAP32[$searchable + 36 >> 2]; HEAP32[$this + 588 + ($sub * 68 | 0) + ($idxprom << 3) + 4 >> 2] = HEAP32[$searchable + 40 >> 2]; $inc13 = $1 + 1 & 65535; $sub17_inc13 = ($inc13 & 65535) > 3 ? $1 - 3 & 65535 : $inc13; $head = $this + 588 + ($sub * 68 | 0) + 64 | 0; $4 = HEAP16[$head >> 1] | 0; if ($sub17_inc13 << 16 >> 16 != $4 << 16 >> 16) { HEAP16[$tail >> 1] = $sub17_inc13; return; } $inc24 = $4 + 1 & 65535; HEAP16[$head >> 1] = $inc24; if (($inc24 & 65535) <= 3) { HEAP16[$tail >> 1] = $sub17_inc13; return; } HEAP16[$head >> 1] = $4 - 3 & 65535; HEAP16[$tail >> 1] = $sub17_inc13; return; } function __ZN10ime_pinyin8UserDict15load_miss_cacheEPNS0_18UserDictSearchableE($this, $searchable) { $this = $this | 0; $searchable = $searchable | 0; var $sub = 0, $1 = 0, $tail = 0, $i_0 = 0, $idxprom8 = 0, $j_0 = 0, $conv5 = 0, $inc20 = 0, $sub25_inc20 = 0, $retval_0 = 0, label = 0; $sub = (HEAPU16[$searchable >> 1] | 0) - 1 | 0; $1 = HEAP16[$this + 108 + ($sub * 60 | 0) + 56 >> 1] | 0; $tail = $this + 108 + ($sub * 60 | 0) + 58 | 0; if ($1 << 16 >> 16 == (HEAP16[$tail >> 1] | 0)) { $retval_0 = 0; return $retval_0 | 0; } else { $i_0 = $1; } L4189 : while (1) { $idxprom8 = $i_0 & 65535; $j_0 = 0; while (1) { $conv5 = $j_0 & 65535; if (($j_0 & 65535) >= 2) { $retval_0 = 1; label = 3300; break L4189; } if ((HEAP32[$this + 108 + ($sub * 60 | 0) + ($idxprom8 << 3) + ($conv5 << 2) >> 2] | 0) == (HEAP32[$searchable + 36 + ($conv5 << 2) >> 2] | 0)) { $j_0 = $j_0 + 1 & 65535; } else { break; } } $inc20 = $i_0 + 1 & 65535; $sub25_inc20 = ($inc20 & 65535) > 6 ? $i_0 - 6 & 65535 : $inc20; if ($sub25_inc20 << 16 >> 16 == (HEAP16[$tail >> 1] | 0)) { $retval_0 = 0; label = 3299; break; } else { $i_0 = $sub25_inc20; } } if ((label | 0) == 3300) { return $retval_0 | 0; } else if ((label | 0) == 3299) { return $retval_0 | 0; } return 0; } function __ZN10ime_pinyin8UserDict15save_miss_cacheEPNS0_18UserDictSearchableE($this, $searchable) { $this = $this | 0; $searchable = $searchable | 0; var $sub = 0, $tail = 0, $1 = 0, $idxprom6 = 0, $inc9 = 0, $sub13_inc9 = 0, $head = 0, $4 = 0, $inc20 = 0; $sub = (HEAPU16[$searchable >> 1] | 0) - 1 | 0; $tail = $this + 108 + ($sub * 60 | 0) + 58 | 0; $1 = HEAP16[$tail >> 1] | 0; $idxprom6 = $1 & 65535; HEAP32[$this + 108 + ($sub * 60 | 0) + ($idxprom6 << 3) >> 2] = HEAP32[$searchable + 36 >> 2]; HEAP32[$this + 108 + ($sub * 60 | 0) + ($idxprom6 << 3) + 4 >> 2] = HEAP32[$searchable + 40 >> 2]; $inc9 = $1 + 1 & 65535; $sub13_inc9 = ($inc9 & 65535) > 6 ? $1 - 6 & 65535 : $inc9; $head = $this + 108 + ($sub * 60 | 0) + 56 | 0; $4 = HEAP16[$head >> 1] | 0; if ($sub13_inc9 << 16 >> 16 != $4 << 16 >> 16) { HEAP16[$tail >> 1] = $sub13_inc9; return; } $inc20 = $4 + 1 & 65535; HEAP16[$head >> 1] = $inc20; if (($inc20 & 65535) <= 6) { HEAP16[$tail >> 1] = $sub13_inc9; return; } HEAP16[$head >> 1] = $4 - 6 & 65535; HEAP16[$tail >> 1] = $sub13_inc9; return; } function __ZN10ime_pinyin8UserDict14set_lemma_flagEjh($this, $offset, $flag) { $this = $this | 0; $offset = $offset | 0; $flag = $flag | 0; var $arrayidx = 0; $arrayidx = (HEAP32[$this + 24 >> 2] | 0) + ($offset & 2147483647) | 0; HEAP8[$arrayidx] = HEAP8[$arrayidx] | $flag; return; } function __ZN10ime_pinyin8UserDict14get_lemma_flagEj($this, $offset) { $this = $this | 0; $offset = $offset | 0; return HEAP8[(HEAP32[$this + 24 >> 2] | 0) + ($offset & 2147483647) | 0] | 0; } function __ZN10ime_pinyin8UserDict17write_back_offsetEi($this, $fd) { $this = $this | 0; $fd = $fd | 0; var $lemma_count = 0; if ((_lseek($fd | 0, (HEAP32[$this + 84 >> 2] | 0) + 4 | 0, 0) | 0) == -1) { return; } $lemma_count = $this + 80 | 0; _write($fd | 0, HEAP32[$this + 28 >> 2] | 0, HEAP32[$lemma_count >> 2] << 2 | 0) | 0; _write($fd | 0, HEAP32[$this + 40 >> 2] | 0, HEAP32[$lemma_count >> 2] << 2 | 0) | 0; _write($fd | 0, HEAP32[$this + 32 >> 2] | 0, HEAP32[$lemma_count >> 2] << 2 | 0) | 0; _write($fd | 0, HEAP32[$this + 44 >> 2] | 0, HEAP32[$this + 96 >> 2] << 2 | 0) | 0; _write($fd | 0, $this + 68 | 0, 36) | 0; return; } function __ZN10ime_pinyin8UserDict16write_back_scoreEi($this, $fd) { $this = $this | 0; $fd = $fd | 0; var $lemma_count = 0; $lemma_count = $this + 80 | 0; if ((_lseek($fd | 0, (HEAP32[$this + 84 >> 2] | 0) + 4 + (HEAP32[$lemma_count >> 2] << 3) | 0, 0) | 0) == -1) { return; } _write($fd | 0, HEAP32[$this + 32 >> 2] | 0, HEAP32[$lemma_count >> 2] << 2 | 0) | 0; _write($fd | 0, HEAP32[$this + 44 >> 2] | 0, HEAP32[$this + 96 >> 2] << 2 | 0) | 0; _write($fd | 0, $this + 68 | 0, 36) | 0; return; } function __ZN10ime_pinyin8UserDict15write_back_syncEi($this, $fd) { $this = $this | 0; $fd = $fd | 0; if ((_lseek($fd | 0, (HEAP32[$this + 84 >> 2] | 0) + 4 + ((HEAP32[$this + 80 >> 2] | 0) * 12 | 0) | 0, 0) | 0) == -1) { return; } _write($fd | 0, HEAP32[$this + 44 >> 2] | 0, HEAP32[$this + 96 >> 2] << 2 | 0) | 0; _write($fd | 0, $this + 68 | 0, 36) | 0; return; } function __ZN10ime_pinyin8UserDict11reset_cacheEv($this) { $this = $this | 0; _memset($this + 588 | 0, 0, 544); return; } function __ZN10ime_pinyin8UserDict16reset_miss_cacheEv($this) { $this = $this | 0; _memset($this + 108 | 0, 0, 480); return; } function __ZN10ime_pinyin8UserDict10defragmentEv($this) { $this = $this | 0; var $lemma_count = 0, $offsets_ = 0, $scores_ = 0, $ids_ = 0, $first_freed_0142 = 0, $1 = 0, $2 = 0, $predicts_ = 0, $first_freed_1 = 0, $5 = 0, $add = 0, $9 = 0, $10 = 0, $first_inuse_0136 = 0, $inc29 = 0, $13 = 0, $first_inuse_0_lcssa = 0, $14 = 0, $15 = 0, $arrayidx37 = 0, $16 = 0, $19 = 0, $arrayidx44 = 0, $20 = 0, $23 = 0, $arrayidx52 = 0, $24 = 0, $27 = 0, $first_freed_2132 = 0, $28 = 0, $first_freed_3 = 0, $add83 = 0, $32 = 0, $first_inuse_1 = 0, $36 = 0, $arrayidx105 = 0, $37 = 0, $first_freed_4 = 0, $lemma_size = 0, $41 = 0, $lemma_size_left_ = 0, $add121 = 0, $lemma_count_left_ = 0, $add125 = 0, $dst_0130 = 0, $lemmas_ = 0, $sync_count = 0, $syncs_ = 0, $offsets_201 = 0, $ids_214 = 0, $start_id_ = 0, $offsets_by_id_ = 0, $predicts_219 = 0, $add141 = 0, $end_0126 = 0, $dst_1125 = 0, $add154 = 0, $add154_pn = 0, $call160 = 0, $mul174 = 0, $add171 = 0, $add176 = 0, $end_1114 = 0, $add191 = 0, $end_1_lcssa = 0, $44 = 0, $sub196 = 0, $sub20898 = 0, $sub22797 = 0, $j_0116 = 0, $arrayidx202 = 0, $47 = 0, $arrayidx220 = 0, $55 = 0, $sub24696 = 0, $j234_0118 = 0, $arrayidx239 = 0, $59 = 0, $add255 = 0, $dst_1122 = 0, $start_id_275 = 0, $ids_277 = 0, $offsets_279 = 0, $offsets_by_id_281 = 0, $i_0106 = 0, label = 0; if (!(__ZN10ime_pinyin8UserDict14is_valid_stateEv($this) | 0)) { return; } $lemma_count = $this + 80 | 0; L4229 : do { if ((HEAP32[$lemma_count >> 2] | 0) == 0) { $first_freed_4 = 0; } else { $offsets_ = $this + 28 | 0; $scores_ = $this + 32 | 0; $ids_ = $this + 36 | 0; $first_freed_0142 = 0; while (1) { $1 = HEAP32[$offsets_ >> 2] | 0; $first_freed_1 = $first_freed_0142; while (1) { if ((HEAP32[$1 + ($first_freed_1 << 2) >> 2] | 0) <= -1) { break; } if ($first_freed_1 >>> 0 < (HEAP32[$lemma_count >> 2] | 0) >>> 0) { $first_freed_1 = $first_freed_1 + 1 | 0; } else { break; } } $5 = HEAP32[$lemma_count >> 2] | 0; if ($first_freed_1 >>> 0 >= $5 >>> 0) { $2 = $5; break; } __ZN10ime_pinyin8UserDict14set_lemma_flagEjh($this, HEAP32[(HEAP32[$offsets_ >> 2] | 0) + ($first_freed_1 << 2) >> 2] | 0, 1); $add = $first_freed_1 + 1 | 0; $9 = HEAP32[(HEAP32[$offsets_ >> 2] | 0) + ($add << 2) >> 2] | 0; L4238 : do { if (($9 | 0) < 0) { $first_inuse_0136 = $add; $10 = $9; while (1) { if ($first_inuse_0136 >>> 0 >= (HEAP32[$lemma_count >> 2] | 0) >>> 0) { $first_inuse_0_lcssa = $first_inuse_0136; break L4238; } __ZN10ime_pinyin8UserDict14set_lemma_flagEjh($this, $10, 1); $inc29 = $first_inuse_0136 + 1 | 0; $13 = HEAP32[(HEAP32[$offsets_ >> 2] | 0) + ($inc29 << 2) >> 2] | 0; if (($13 | 0) < 0) { $first_inuse_0136 = $inc29; $10 = $13; } else { $first_inuse_0_lcssa = $inc29; break; } } } else { $first_inuse_0_lcssa = $add; } } while (0); $14 = HEAP32[$lemma_count >> 2] | 0; if ($first_inuse_0_lcssa >>> 0 >= $14 >>> 0) { $2 = $14; break; } $15 = HEAP32[$offsets_ >> 2] | 0; $arrayidx37 = $15 + ($first_inuse_0_lcssa << 2) | 0; $16 = HEAP32[$arrayidx37 >> 2] | 0; HEAP32[$arrayidx37 >> 2] = HEAP32[$15 + ($first_freed_1 << 2) >> 2]; HEAP32[(HEAP32[$offsets_ >> 2] | 0) + ($first_freed_1 << 2) >> 2] = $16; $19 = HEAP32[$scores_ >> 2] | 0; $arrayidx44 = $19 + ($first_inuse_0_lcssa << 2) | 0; $20 = HEAP32[$arrayidx44 >> 2] | 0; HEAP32[$arrayidx44 >> 2] = HEAP32[$19 + ($first_freed_1 << 2) >> 2]; HEAP32[(HEAP32[$scores_ >> 2] | 0) + ($first_freed_1 << 2) >> 2] = $20; $23 = HEAP32[$ids_ >> 2] | 0; $arrayidx52 = $23 + ($first_inuse_0_lcssa << 2) | 0; $24 = HEAP32[$arrayidx52 >> 2] | 0; HEAP32[$arrayidx52 >> 2] = HEAP32[$23 + ($first_freed_1 << 2) >> 2]; HEAP32[(HEAP32[$ids_ >> 2] | 0) + ($first_freed_1 << 2) >> 2] = $24; $27 = HEAP32[$lemma_count >> 2] | 0; if ($add >>> 0 < $27 >>> 0) { $first_freed_0142 = $add; } else { $2 = $27; break; } } if (($2 | 0) == 0) { $first_freed_4 = 0; break; } $predicts_ = $this + 40 | 0; $first_freed_2132 = 0; while (1) { $28 = HEAP32[$predicts_ >> 2] | 0; $first_freed_3 = $first_freed_2132; while (1) { if ((HEAP32[$28 + ($first_freed_3 << 2) >> 2] | 0) <= -1) { break; } if ($first_freed_3 >>> 0 < (HEAP32[$lemma_count >> 2] | 0) >>> 0) { $first_freed_3 = $first_freed_3 + 1 | 0; } else { break; } } if ($first_freed_3 >>> 0 >= (HEAP32[$lemma_count >> 2] | 0) >>> 0) { $first_freed_4 = $first_freed_3; break L4229; } $add83 = $first_freed_3 + 1 | 0; $32 = HEAP32[$predicts_ >> 2] | 0; $first_inuse_1 = $add83; while (1) { if ((HEAP32[$32 + ($first_inuse_1 << 2) >> 2] | 0) >= 0) { break; } if ($first_inuse_1 >>> 0 < (HEAP32[$lemma_count >> 2] | 0) >>> 0) { $first_inuse_1 = $first_inuse_1 + 1 | 0; } else { break; } } if ($first_inuse_1 >>> 0 >= (HEAP32[$lemma_count >> 2] | 0) >>> 0) { $first_freed_4 = $first_freed_3; break L4229; } $36 = HEAP32[$predicts_ >> 2] | 0; $arrayidx105 = $36 + ($first_inuse_1 << 2) | 0; $37 = HEAP32[$arrayidx105 >> 2] | 0; HEAP32[$arrayidx105 >> 2] = HEAP32[$36 + ($first_freed_3 << 2) >> 2]; HEAP32[(HEAP32[$predicts_ >> 2] | 0) + ($first_freed_3 << 2) >> 2] = $37; if ($add83 >>> 0 < (HEAP32[$lemma_count >> 2] | 0) >>> 0) { $first_freed_2132 = $add83; } else { $first_freed_4 = $add83; break; } } } } while (0); HEAP32[$lemma_count >> 2] = $first_freed_4; $lemma_size = $this + 84 | 0; $41 = HEAP32[$lemma_size >> 2] | 0; $lemma_size_left_ = $this + 60 | 0; $add121 = (HEAP32[$lemma_size_left_ >> 2] | 0) + $41 | 0; $lemma_count_left_ = $this + 56 | 0; $add125 = (HEAP32[$lemma_count_left_ >> 2] | 0) + $first_freed_4 | 0; if (($41 | 0) == 0) { return; } else { $dst_0130 = 0; } while (1) { if (((__ZN10ime_pinyin8UserDict14get_lemma_flagEj($this, $dst_0130) | 0) & 1) != 0) { break; } $add141 = (((__ZN10ime_pinyin8UserDict15get_lemma_ncharEj($this, $dst_0130) | 0) & 255) << 2 | 2) + $dst_0130 | 0; if ($add141 >>> 0 < $41 >>> 0) { $dst_0130 = $add141; } else { label = 3380; break; } } if ((label | 0) == 3380) { return; } L4267 : do { if ($dst_0130 >>> 0 < $41 >>> 0) { $lemmas_ = $this + 24 | 0; $sync_count = $this + 96 | 0; $syncs_ = $this + 44 | 0; $offsets_201 = $this + 28 | 0; $ids_214 = $this + 36 | 0; $start_id_ = $this + 16 | 0; $offsets_by_id_ = $this + 52 | 0; $predicts_219 = $this + 40 | 0; $dst_1125 = $dst_0130; $end_0126 = $dst_0130; while (1) { $add154 = $end_0126 + 2 + ((__ZN10ime_pinyin8UserDict15get_lemma_ncharEj($this, $end_0126) | 0) << 24 >> 24 << 2) | 0; if ($add154 >>> 0 < $41 >>> 0) { $add154_pn = $add154; } else { $dst_1122 = $dst_1125; break L4267; } while (1) { $call160 = __ZN10ime_pinyin8UserDict14get_lemma_flagEj($this, $add154_pn) | 0; $mul174 = ((__ZN10ime_pinyin8UserDict15get_lemma_ncharEj($this, $add154_pn) | 0) & 255) << 2; if (($call160 & 1) == 0) { break; } $add171 = ($mul174 | 2) + $add154_pn | 0; if ($add171 >>> 0 < $41 >>> 0) { $add154_pn = $add171; } else { $dst_1122 = $dst_1125; break L4267; } } $add176 = $add154_pn + 2 + $mul174 | 0; L4275 : do { if ($add176 >>> 0 < $41 >>> 0) { $end_1114 = $add176; while (1) { if (((__ZN10ime_pinyin8UserDict14get_lemma_flagEj($this, $end_1114) | 0) & 1) != 0) { $end_1_lcssa = $end_1114; break L4275; } $add191 = (((__ZN10ime_pinyin8UserDict15get_lemma_ncharEj($this, $end_1114) | 0) & 255) << 2 | 2) + $end_1114 | 0; if ($add191 >>> 0 < $41 >>> 0) { $end_1114 = $add191; } else { $end_1_lcssa = $add191; break; } } } else { $end_1_lcssa = $add176; } } while (0); $44 = HEAP32[$lemmas_ >> 2] | 0; $sub196 = $end_1_lcssa - $add154_pn | 0; _memmove($44 + $dst_1125 | 0, $44 + $add154_pn | 0, $sub196 | 0); if ((HEAP32[$lemma_count >> 2] | 0) != 0) { $sub20898 = $dst_1125 - $add154_pn | 0; $sub22797 = $dst_1125 - $add154_pn | 0; $j_0116 = 0; do { $arrayidx202 = (HEAP32[$offsets_201 >> 2] | 0) + ($j_0116 << 2) | 0; $47 = HEAP32[$arrayidx202 >> 2] | 0; if ($47 >>> 0 >= $add154_pn >>> 0 & $47 >>> 0 < $end_1_lcssa >>> 0) { HEAP32[$arrayidx202 >> 2] = $sub20898 + $47; HEAP32[(HEAP32[$offsets_by_id_ >> 2] | 0) + ((HEAP32[(HEAP32[$ids_214 >> 2] | 0) + ($j_0116 << 2) >> 2] | 0) - (HEAP32[$start_id_ >> 2] | 0) << 2) >> 2] = HEAP32[(HEAP32[$offsets_201 >> 2] | 0) + ($j_0116 << 2) >> 2]; } $arrayidx220 = (HEAP32[$predicts_219 >> 2] | 0) + ($j_0116 << 2) | 0; $55 = HEAP32[$arrayidx220 >> 2] | 0; if ($55 >>> 0 >= $add154_pn >>> 0 & $55 >>> 0 < $end_1_lcssa >>> 0) { HEAP32[$arrayidx220 >> 2] = $sub22797 + $55; } $j_0116 = $j_0116 + 1 | 0; } while ($j_0116 >>> 0 < (HEAP32[$lemma_count >> 2] | 0) >>> 0); } if ((HEAP32[$sync_count >> 2] | 0) != 0) { $sub24696 = $dst_1125 - $add154_pn | 0; $j234_0118 = 0; do { $arrayidx239 = (HEAP32[$syncs_ >> 2] | 0) + ($j234_0118 << 2) | 0; $59 = HEAP32[$arrayidx239 >> 2] | 0; if ($59 >>> 0 >= $add154_pn >>> 0 & $59 >>> 0 < $end_1_lcssa >>> 0) { HEAP32[$arrayidx239 >> 2] = $sub24696 + $59; } $j234_0118 = $j234_0118 + 1 | 0; } while ($j234_0118 >>> 0 < (HEAP32[$sync_count >> 2] | 0) >>> 0); } $add255 = $sub196 + $dst_1125 | 0; if ($end_1_lcssa >>> 0 < $41 >>> 0) { $dst_1125 = $add255; $end_0126 = $end_1_lcssa; } else { $dst_1122 = $add255; break; } } } else { $dst_1122 = $dst_0130; } } while (0); HEAP32[$this + 88 >> 2] = 0; HEAP32[$this + 92 >> 2] = 0; HEAP32[$lemma_size >> 2] = $dst_1122; HEAP32[$lemma_size_left_ >> 2] = $add121 - $dst_1122; HEAP32[$lemma_count_left_ >> 2] = $add125 - (HEAP32[$lemma_count >> 2] | 0); if ((HEAP32[$lemma_count >> 2] | 0) != 0) { $start_id_275 = $this + 16 | 0; $ids_277 = $this + 36 | 0; $offsets_279 = $this + 28 | 0; $offsets_by_id_281 = $this + 52 | 0; $i_0106 = 0; do { HEAP32[(HEAP32[$ids_277 >> 2] | 0) + ($i_0106 << 2) >> 2] = (HEAP32[$start_id_275 >> 2] | 0) + $i_0106; HEAP32[(HEAP32[$offsets_by_id_281 >> 2] | 0) + ($i_0106 << 2) >> 2] = HEAP32[(HEAP32[$offsets_279 >> 2] | 0) + ($i_0106 << 2) >> 2]; $i_0106 = $i_0106 + 1 | 0; } while ($i_0106 >>> 0 < (HEAP32[$lemma_count >> 2] | 0) >>> 0); } HEAP32[$this + 104 >> 2] = 6; return; } function __ZN10ime_pinyin8UserDict17clear_sync_lemmasEjj($this, $start, $end) { $this = $this | 0; $start = $start | 0; $end = $end | 0; var $sync_count = 0, $0 = 0, $_end = 0, $1 = 0, $state_ = 0; if (!(__ZN10ime_pinyin8UserDict14is_valid_stateEv($this) | 0)) { return; } $sync_count = $this + 96 | 0; $0 = HEAP32[$sync_count >> 2] | 0; $_end = $0 >>> 0 < $end >>> 0 ? $0 : $end; $1 = HEAP32[$this + 44 >> 2] | 0; _memmove($1 + ($start << 2) | 0, $1 + ($_end << 2) | 0, $0 - $_end << 2 | 0); HEAP32[$sync_count >> 2] = $start - $_end + (HEAP32[$sync_count >> 2] | 0); $state_ = $this + 104 | 0; if ((HEAP32[$state_ >> 2] | 0) >= 2) { return; } HEAP32[$state_ >> 2] = 2; return; } function __ZN10ime_pinyin8UserDict14get_sync_countEv($this) { $this = $this | 0; var $retval_0 = 0; if (!(__ZN10ime_pinyin8UserDict14is_valid_stateEv($this) | 0)) { $retval_0 = 0; return $retval_0 | 0; } $retval_0 = HEAP32[$this + 96 >> 2] | 0; return $retval_0 | 0; } function __ZN10ime_pinyin8UserDict17put_lemma_no_syncEPtS1_tty($this, $lemma_str, $splids, $lemma_len, $count, $lmt$0, $lmt$1) { $this = $this | 0; $lemma_str = $lemma_str | 0; $splids = $splids | 0; $lemma_len = $lemma_len | 0; $count = $count | 0; $lmt$0 = $lmt$0 | 0; $lmt$1 = $lmt$1 | 0; var $lemma_size = 0, $syncs_ = 0, $0 = 0, $call4 = 0, $limit_lemma_size = 0, $add3 = 0, $1 = 0, $2 = 0, $4 = 0, $7 = 0, $call = 0, $call_lcssa = 0, label = 0; $lemma_size = $this + 84 | 0; $syncs_ = $this + 44 | 0; $0 = HEAP32[$syncs_ >> 2] | 0; HEAP32[$syncs_ >> 2] = 0; $call4 = __ZN10ime_pinyin8UserDict10_put_lemmaEPtS1_tty($this, $lemma_str, $splids, $lemma_len, $count, $lmt$0, $lmt$1) | 0; HEAP32[$syncs_ >> 2] = $0; if (($call4 | 0) != 0) { $call_lcssa = $call4; return $call_lcssa | 0; } $limit_lemma_size = $this + 76 | 0; $add3 = ($lemma_len & 65535) << 2 | 2; $1 = $this; $2 = HEAP32[$this + 72 >> 2] | 0; if (($2 | 0) == 0) { label = 3399; } else { if ((HEAP32[$this + 80 >> 2] | 0) >>> 0 < $2 >>> 0) { label = 3399; } } do { if ((label | 0) == 3399) { $4 = HEAP32[$limit_lemma_size >> 2] | 0; if (($4 | 0) == 0) { $call_lcssa = $call4; return $call_lcssa | 0; } if (((HEAP32[$lemma_size >> 2] | 0) + $add3 | 0) >>> 0 > $4 >>> 0) { break; } else { $call_lcssa = $call4; } return $call_lcssa | 0; } } while (0); __ZN10ime_pinyin8UserDict7reclaimEv($this); __ZN10ime_pinyin8UserDict10defragmentEv($this); FUNCTION_TABLE_vi[HEAP32[(HEAP32[$1 >> 2] | 0) + 76 >> 2] & 127]($this); $7 = HEAP32[$syncs_ >> 2] | 0; HEAP32[$syncs_ >> 2] = 0; $call = __ZN10ime_pinyin8UserDict10_put_lemmaEPtS1_tty($this, $lemma_str, $splids, $lemma_len, $count, $lmt$0, $lmt$1) | 0; HEAP32[$syncs_ >> 2] = $7; $call_lcssa = $call; return $call_lcssa | 0; } function __ZN10ime_pinyin8UserDict10_put_lemmaEPtS1_tty($this, $lemma_str, $splids, $lemma_len, $count, $lmt$0, $lmt$1) { $this = $this | 0; $lemma_str = $lemma_str | 0; $splids = $splids | 0; $lemma_len = $lemma_len | 0; $count = $count | 0; $lmt$0 = $lmt$0 | 0; $lmt$1 = $lmt$1 | 0; var $call2 = 0, $conv5 = 0, $scores_ = 0, $total_nfreq = 0, $call7 = 0, $state_ = 0, $7 = 0, $9 = 0, $call41 = 0, $retval_0 = 0, label = 0; if (!(__ZN10ime_pinyin8UserDict14is_valid_stateEv($this) | 0)) { $retval_0 = 0; return $retval_0 | 0; } $call2 = __ZN10ime_pinyin8UserDict17locate_in_offsetsEPtS1_t($this, $lemma_str, $splids, $lemma_len) | 0; if (($call2 | 0) != -1) { $conv5 = $count & 65535; $scores_ = $this + 32 | 0; $total_nfreq = $this + 100 | 0; HEAP32[$total_nfreq >> 2] = $conv5 - (HEAP32[(HEAP32[$scores_ >> 2] | 0) + ($call2 << 2) >> 2] | 0) + (HEAP32[$total_nfreq >> 2] | 0); $call7 = __ZN10ime_pinyin8UserDict11build_scoreEyi(0, $lmt$0, $lmt$1, $conv5) | 0; HEAP32[(HEAP32[$scores_ >> 2] | 0) + ($call2 << 2) >> 2] = $call7; $state_ = $this + 104 | 0; if ((HEAP32[$state_ >> 2] | 0) < 3) { HEAP32[$state_ >> 2] = 3; } $retval_0 = HEAP32[(HEAP32[$this + 36 >> 2] | 0) + ($call2 << 2) >> 2] | 0; return $retval_0 | 0; } $7 = HEAP32[$this + 72 >> 2] | 0; do { if (($7 | 0) != 0) { if ((HEAP32[$this + 80 >> 2] | 0) >>> 0 < $7 >>> 0) { break; } else { $retval_0 = 0; } return $retval_0 | 0; } } while (0); $9 = HEAP32[$this + 76 >> 2] | 0; do { if (($9 | 0) != 0) { if (((HEAP32[$this + 84 >> 2] | 0) + (($lemma_len & 65535) << 2 | 2) | 0) >>> 0 > $9 >>> 0) { $retval_0 = 0; } else { break; } return $retval_0 | 0; } } while (0); if ((HEAP32[$this + 56 >> 2] | 0) == 0) { label = 3418; } else { if ((HEAP32[$this + 60 >> 2] | 0) >>> 0 < (($lemma_len & 65535) << 2 | 2) >>> 0) { label = 3418; } } if ((label | 0) == 3418) { FUNCTION_TABLE_vi[HEAP32[(HEAP32[$this >> 2] | 0) + 76 >> 2] & 127]($this); } $call41 = __ZN10ime_pinyin8UserDict14append_a_lemmaEPtS1_tty($this, $lemma_str, $splids, $lemma_len, $count, $lmt$0, $lmt$1) | 0; if ((HEAP32[$this + 44 >> 2] | 0) == 0 | ($call41 | 0) == 0) { $retval_0 = $call41; return $retval_0 | 0; } __ZN10ime_pinyin8UserDict20queue_lemma_for_syncEj($this, $call41); $retval_0 = $call41; return $retval_0 | 0; } function __ZN10ime_pinyin8UserDict18extract_score_freqEi($this, $raw_score) { $this = $this | 0; $raw_score = $raw_score | 0; return $raw_score & 65535 | 0; } function __ZN10ime_pinyin8UserDict17extract_score_lmtEi($this, $raw_score) { $this = $this | 0; $raw_score = $raw_score | 0; var $mul$0 = 0, $add$0 = 0; $mul$0 = ___muldi3($raw_score >>> 16, 0, 604800, 0) | 0; $add$0 = _i64Add($mul$0, tempRet0, 1229904e3, 0) | 0; return (tempRet0 = tempRet0, $add$0) | 0; } function __ZN10ime_pinyin8UserDict11build_scoreEyi($this, $lmt$0, $lmt$1, $freq) { $this = $this | 0; $lmt$0 = $lmt$0 | 0; $lmt$1 = $lmt$1 | 0; $freq = $freq | 0; var $sub$0 = 0, $div$0 = 0; $sub$0 = _i64Add($lmt$0, $lmt$1, -1229904e3, -1) | 0; $div$0 = ___udivdi3($sub$0, tempRet0, 604800, 0) | 0; return $div$0 << 16 | $freq & 65535 | 0; } function __ZN10ime_pinyin8UserDict13utf16le_atollEPti($this, $s, $len) { $this = $this | 0; $s = $s | 0; $len = $len | 0; var $add_ptr = 0, $0 = 0, $s_addr_0_ph = 0, $flag_0_ph$0 = 0, $flag_0_ph$1 = 0, $1 = 0, $3 = 0, $ret_018$0 = 0, $ret_018$1 = 0, $s_addr_017 = 0, $mul$0 = 0, $mul$1 = 0, $add$0 = 0, $sub$0 = 0, $add16$0 = 0, $add16$1 = 0, $incdec_ptr17 = 0, $4 = 0, $ret_0_lcssa$0 = 0, $ret_0_lcssa$1 = 0, $mul19$0 = 0, $retval_0$0 = 0, $retval_0$1 = 0; if (($len | 0) < 1) { $retval_0$1 = 0; $retval_0$0 = 0; return (tempRet0 = $retval_0$1, $retval_0$0) | 0; } $add_ptr = $s + ($len << 1) | 0; $0 = HEAP16[$s >> 1] | 0; if (($0 << 16 >> 16 | 0) == 43) { $flag_0_ph$1 = 0; $flag_0_ph$0 = 1; $s_addr_0_ph = $s + 2 | 0; } else if (($0 << 16 >> 16 | 0) == 45) { $flag_0_ph$1 = -1; $flag_0_ph$0 = -1; $s_addr_0_ph = $s + 2 | 0; } else { $flag_0_ph$1 = 0; $flag_0_ph$0 = 1; $s_addr_0_ph = $s; } $1 = HEAP16[$s_addr_0_ph >> 1] | 0; if (($1 - 48 & 65535) < 10 & $s_addr_0_ph >>> 0 < $add_ptr >>> 0) { $s_addr_017 = $s_addr_0_ph; $ret_018$1 = 0; $ret_018$0 = 0; $3 = $1; while (1) { $mul$0 = ___muldi3($ret_018$0, $ret_018$1, 10, 0) | 0; $mul$1 = tempRet0; $add$0 = _i64Add($ret_018$0, $ret_018$1, -48, -1) | 0; $sub$0 = _i64Add($add$0, tempRet0, $mul$0, $mul$1) | 0; $add16$0 = _i64Add($sub$0, tempRet0, $3 & 65535, 0) | 0; $add16$1 = tempRet0; $incdec_ptr17 = $s_addr_017 + 2 | 0; $4 = HEAP16[$incdec_ptr17 >> 1] | 0; if (($4 - 48 & 65535) < 10 & $incdec_ptr17 >>> 0 < $add_ptr >>> 0) { $s_addr_017 = $incdec_ptr17; $ret_018$1 = $add16$1; $ret_018$0 = $add16$0; $3 = $4; } else { $ret_0_lcssa$1 = $add16$1; $ret_0_lcssa$0 = $add16$0; break; } } } else { $ret_0_lcssa$1 = 0; $ret_0_lcssa$0 = 0; } $mul19$0 = ___muldi3($flag_0_ph$0, $flag_0_ph$1, $ret_0_lcssa$0, $ret_0_lcssa$1) | 0; $retval_0$1 = tempRet0; $retval_0$0 = $mul19$0; return (tempRet0 = $retval_0$1, $retval_0$0) | 0; } function __ZN10ime_pinyin8UserDict13utf16le_lltoaExPti($this, $v$0, $v$1, $s, $size) { $this = $this | 0; $v$0 = $v$0 | 0; $v$1 = $v$1 | 0; $s = $s | 0; $size = $size | 0; var $add_ptr = 0, $$etemp$0$1 = 0, $mul$0 = 0, $s_addr_0 = 0, $v_addr_0$0 = 0, $v_addr_0$1 = 0, $ret_len_0 = 0, $ret_len_127 = 0, $v_addr_126$0 = 0, $v_addr_126$1 = 0, $s_addr_125 = 0, $rem$0 = 0, $add$0 = 0, $incdec_ptr7 = 0, $div$0 = 0, $div$1 = 0, $inc8 = 0, $v_addr_126_off$0 = 0, $v_addr_126_off$1 = 0, $$etemp$7$1 = 0, $ret_len_1_lcssa = 0, $v_addr_1_lcssa$0 = 0, $v_addr_1_lcssa$1 = 0, $s_addr_1_lcssa = 0, $s_addr_219 = 0, $s_addr_222 = 0, $b_021 = 0, $incdec_ptr16 = 0, $s_addr_2 = 0, $retval_0 = 0; if (($s | 0) == 0 | ($size | 0) < 1) { $retval_0 = 0; return $retval_0 | 0; } $add_ptr = $s + ($size << 1) | 0; $$etemp$0$1 = 0; if (($v$1 | 0) < ($$etemp$0$1 | 0) | ($v$1 | 0) == ($$etemp$0$1 | 0) & $v$0 >>> 0 < 0 >>> 0) { HEAP16[$s >> 1] = 45; $mul$0 = _i64Subtract(0, 0, $v$0, $v$1) | 0; $ret_len_0 = 1; $v_addr_0$1 = tempRet0; $v_addr_0$0 = $mul$0; $s_addr_0 = $s + 2 | 0; } else { $ret_len_0 = 0; $v_addr_0$1 = $v$1; $v_addr_0$0 = $v$0; $s_addr_0 = $s; } if ($s_addr_0 >>> 0 < $add_ptr >>> 0 & (($v_addr_0$0 | 0) != 0 | ($v_addr_0$1 | 0) != 0)) { $s_addr_125 = $s_addr_0; $v_addr_126$1 = $v_addr_0$1; $v_addr_126$0 = $v_addr_0$0; $ret_len_127 = $ret_len_0; while (1) { $rem$0 = ___remdi3($v_addr_126$0, $v_addr_126$1, 10, 0) | 0; $add$0 = _i64Add($rem$0, tempRet0, 48, 0) | 0; $incdec_ptr7 = $s_addr_125 + 2 | 0; HEAP16[$s_addr_125 >> 1] = $add$0 & 65535; $div$0 = ___divdi3($v_addr_126$0, $v_addr_126$1, 10, 0) | 0; $div$1 = tempRet0; $inc8 = $ret_len_127 + 1 | 0; $v_addr_126_off$0 = _i64Add($v_addr_126$0, $v_addr_126$1, 9, 0) | 0; $v_addr_126_off$1 = tempRet0; $$etemp$7$1 = 0; if ($incdec_ptr7 >>> 0 < $add_ptr >>> 0 & ($v_addr_126_off$1 >>> 0 > $$etemp$7$1 >>> 0 | $v_addr_126_off$1 >>> 0 == $$etemp$7$1 >>> 0 & $v_addr_126_off$0 >>> 0 > 18 >>> 0)) { $s_addr_125 = $incdec_ptr7; $v_addr_126$1 = $div$1; $v_addr_126$0 = $div$0; $ret_len_127 = $inc8; } else { $s_addr_1_lcssa = $incdec_ptr7; $v_addr_1_lcssa$1 = $div$1; $v_addr_1_lcssa$0 = $div$0; $ret_len_1_lcssa = $inc8; break; } } } else { $s_addr_1_lcssa = $s_addr_0; $v_addr_1_lcssa$1 = $v_addr_0$1; $v_addr_1_lcssa$0 = $v_addr_0$0; $ret_len_1_lcssa = $ret_len_0; } if (!(($v_addr_1_lcssa$0 | 0) == 0 & ($v_addr_1_lcssa$1 | 0) == 0)) { $retval_0 = 0; return $retval_0 | 0; } $s_addr_219 = $s_addr_1_lcssa - 2 | 0; if ($s_addr_0 >>> 0 < $s_addr_219 >>> 0) { $b_021 = $s_addr_0; $s_addr_222 = $s_addr_219; } else { $retval_0 = $ret_len_1_lcssa; return $retval_0 | 0; } while (1) { HEAP16[$b_021 >> 1] = HEAP16[$s_addr_222 >> 1] | 0; $incdec_ptr16 = $b_021 + 2 | 0; $s_addr_2 = $s_addr_222 - 2 | 0; if ($incdec_ptr16 >>> 0 < $s_addr_2 >>> 0) { $b_021 = $incdec_ptr16; $s_addr_222 = $s_addr_2; } else { $retval_0 = $ret_len_1_lcssa; break; } } return $retval_0 | 0; } function __ZN10ime_pinyin8UserDict9set_limitEjjj($this, $max_lemma_count, $max_lemma_size, $reclaim_ratio) { $this = $this | 0; $max_lemma_count = $max_lemma_count | 0; $max_lemma_size = $max_lemma_size | 0; $reclaim_ratio = $reclaim_ratio | 0; HEAP32[$this + 72 >> 2] = $max_lemma_count; HEAP32[$this + 76 >> 2] = $max_lemma_size; HEAP32[$this + 68 >> 2] = $reclaim_ratio >>> 0 > 100 ? 100 : $reclaim_ratio; return; } function __ZN10ime_pinyin8UserDict4swapEPNS0_23UserDictScoreOffsetPairEii($this, $sop, $i, $j) { $this = $this | 0; $sop = $sop | 0; $i = $i | 0; $j = $j | 0; var $score = 0, $0 = 0, $offset_index = 0, $1 = 0, $score4 = 0, $offset_index8 = 0; $score = $sop + ($i << 3) | 0; $0 = HEAP32[$score >> 2] | 0; $offset_index = $sop + ($i << 3) + 4 | 0; $1 = HEAP32[$offset_index >> 2] | 0; $score4 = $sop + ($j << 3) | 0; HEAP32[$score >> 2] = HEAP32[$score4 >> 2]; $offset_index8 = $sop + ($j << 3) + 4 | 0; HEAP32[$offset_index >> 2] = HEAP32[$offset_index8 >> 2]; HEAP32[$score4 >> 2] = $0; HEAP32[$offset_index8 >> 2] = $1; return; } function __ZN10ime_pinyin8UserDict38put_lemmas_no_sync_from_utf16le_stringEPti($this, $lemmas, $len) { $this = $this | 0; $lemmas = $lemmas | 0; $len = $len | 0; var $is_pre = 0, $call = 0, $0 = 0, $sub_ptr_rhs_cast = 0, $arraydecay = 0, $sub_ptr_lhs_cast57 = 0, $newly_added_056 = 0, $p_055 = 0, $2 = 0, $3 = 0, $p_149 = 0, $splid_len_048 = 0, $inc_splid_len_0 = 0, $incdec_ptr = 0, $4 = 0, $p_1_lcssa = 0, $splid_len_0_lcssa = 0, $inc14 = 0, $sub_ptr_lhs_cast15 = 0, $incdec_ptr35 = 0, $p_2 = 0, $incdec_ptr56 = 0, $p_3 = 0, $call74$0 = 0, $incdec_ptr76 = 0, $p_4 = 0, $call94$0 = 0, $inc99 = 0, $incdec_ptr100 = 0, $sub_ptr_lhs_cast = 0, $retval_0 = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 24 | 0; $is_pre = sp + 16 | 0; $call = __Znwj(4) | 0; $0 = $call; __ZN10ime_pinyin14SpellingParserC2Ev($0); if (($call | 0) == 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } $sub_ptr_rhs_cast = $lemmas; if (($len | 0) <= 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } $arraydecay = sp | 0; $p_055 = $lemmas; $newly_added_056 = 0; $sub_ptr_lhs_cast57 = $lemmas; while (1) { $2 = HEAP16[$p_055 >> 1] | 0; L4408 : do { if ($2 << 16 >> 16 == 44) { $splid_len_0_lcssa = 0; $p_1_lcssa = $p_055; } else { $splid_len_048 = 0; $p_149 = $p_055; $3 = $2; while (1) { if (($p_149 - $sub_ptr_rhs_cast >> 1 | 0) >= ($len | 0)) { $splid_len_0_lcssa = $splid_len_048; $p_1_lcssa = $p_149; break L4408; } $inc_splid_len_0 = ($3 << 16 >> 16 == 32) + $splid_len_048 | 0; $incdec_ptr = $p_149 + 2 | 0; $4 = HEAP16[$incdec_ptr >> 1] | 0; if ($4 << 16 >> 16 == 44) { $splid_len_0_lcssa = $inc_splid_len_0; $p_1_lcssa = $incdec_ptr; break; } else { $splid_len_048 = $inc_splid_len_0; $p_149 = $incdec_ptr; $3 = $4; } } } } while (0); $inc14 = $splid_len_0_lcssa + 1 | 0; $sub_ptr_lhs_cast15 = $p_1_lcssa; if (($sub_ptr_lhs_cast15 - $sub_ptr_rhs_cast >> 1 | 0) == ($len | 0) | $inc14 >>> 0 > 8) { $retval_0 = $newly_added_056; label = 3483; break; } if (((__ZN10ime_pinyin14SpellingParser18splstr16_to_idxs_fEPKttPtS3_tRb($0, $p_055, ($sub_ptr_lhs_cast15 - $sub_ptr_lhs_cast57 | 0) >>> 1 & 65535, $arraydecay, 0, 8, $is_pre) | 0) & 65535 | 0) != ($inc14 | 0)) { $retval_0 = $newly_added_056; label = 3479; break; } $incdec_ptr35 = $p_1_lcssa + 2 | 0; $p_2 = $incdec_ptr35; while (1) { if ((HEAP16[$p_2 >> 1] | 0) == 44) { break; } if (($p_2 - $sub_ptr_rhs_cast >> 1 | 0) < ($len | 0)) { $p_2 = $p_2 + 2 | 0; } else { break; } } if (($p_2 - $incdec_ptr35 >> 1 | 0) != ($inc14 | 0)) { $retval_0 = $newly_added_056; label = 3482; break; } $incdec_ptr56 = $p_2 + 2 | 0; $p_3 = $incdec_ptr56; while (1) { if ((HEAP16[$p_3 >> 1] | 0) == 44) { break; } if (($p_3 - $sub_ptr_rhs_cast >> 1 | 0) < ($len | 0)) { $p_3 = $p_3 + 2 | 0; } else { break; } } $call74$0 = __ZN10ime_pinyin8UserDict13utf16le_atollEPti(0, $incdec_ptr56, $p_3 - $incdec_ptr56 >> 1) | 0; $incdec_ptr76 = $p_3 + 2 | 0; $p_4 = $incdec_ptr76; while (1) { if ((HEAP16[$p_4 >> 1] | 0) == 59) { break; } if (($p_4 - $sub_ptr_rhs_cast >> 1 | 0) < ($len | 0)) { $p_4 = $p_4 + 2 | 0; } else { break; } } $call94$0 = __ZN10ime_pinyin8UserDict13utf16le_atollEPti(0, $incdec_ptr76, $p_4 - $incdec_ptr76 >> 1) | 0; __ZN10ime_pinyin8UserDict17put_lemma_no_syncEPtS1_tty($this, $incdec_ptr35, $arraydecay, $inc14 & 65535, $call74$0 & 65535, $call94$0, tempRet0) | 0; $inc99 = $newly_added_056 + 1 | 0; $incdec_ptr100 = $p_4 + 2 | 0; $sub_ptr_lhs_cast = $incdec_ptr100; if (($sub_ptr_lhs_cast - $sub_ptr_rhs_cast >> 1 | 0) < ($len | 0)) { $p_055 = $incdec_ptr100; $newly_added_056 = $inc99; $sub_ptr_lhs_cast57 = $sub_ptr_lhs_cast; } else { $retval_0 = $inc99; label = 3478; break; } } if ((label | 0) == 3482) { STACKTOP = sp; return $retval_0 | 0; } else if ((label | 0) == 3483) { STACKTOP = sp; return $retval_0 | 0; } else if ((label | 0) == 3478) { STACKTOP = sp; return $retval_0 | 0; } else if ((label | 0) == 3479) { STACKTOP = sp; return $retval_0 | 0; } return 0; } function __ZN10ime_pinyin8UserDict48get_sync_lemmas_in_utf16le_string_from_beginningEPtiPi($this, $str, $size, $count) { $this = $this | 0; $str = $str | 0; $size = $size | 0; $count = $count | 0; var $call2 = 0, $sync_count = 0, $syncs_ = 0, $len_045 = 0, $left_len_044 = 0, $i_043 = 0, $2 = 0, $call6 = 0, $conv7 = 0, $call8 = 0, $call9 = 0, $call11 = 0, $j_034 = 0, $4 = 0, $call16 = 0, $5 = 0, $add_ptr = 0, $inc = 0, $j_1 = 0, $6 = 0, $incdec_ptr26 = 0, $7 = 0, $cmp3536 = 0, $8 = 0, $j_238 = 0, $9 = 0, $inc42 = 0, $10 = 0, $cmp35 = 0, $cmp35_lcssa = 0, $_lcssa = 0, $j_2_lcssa = 0, $conv54$0 = 0, $11 = 0, $call58 = 0, $12 = 0, $add_ptr62 = 0, $call68$0 = 0, $13 = 0, $call72 = 0, $14 = 0, $add_ptr76 = 0, $sub_ptr_sub82 = 0, $sub_ptr_div83 = 0, $16 = 0, $left_len_1 = 0, $len_1 = 0, $inc90 = 0, $len_0_lcssa = 0, $state_ = 0, $retval_0 = 0; HEAP32[$count >> 2] = 0; if (!(__ZN10ime_pinyin8UserDict14is_valid_stateEv($this) | 0)) { $retval_0 = 0; return $retval_0 | 0; } $call2 = __ZN10ime_pinyin12SpellingTrie12get_instanceEv() | 0; if (($call2 | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $sync_count = $this + 96 | 0; if ((HEAP32[$sync_count >> 2] | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $syncs_ = $this + 44 | 0; $i_043 = 0; $left_len_044 = $size; $len_045 = 0; L4443 : while (1) { $2 = HEAP32[(HEAP32[$syncs_ >> 2] | 0) + ($i_043 << 2) >> 2] | 0; $call6 = __ZN10ime_pinyin8UserDict15get_lemma_ncharEj($this, $2) | 0; $conv7 = $call6 << 24 >> 24; $call8 = __ZN10ime_pinyin8UserDict19get_lemma_spell_idsEj($this, $2) | 0; $call9 = __ZN10ime_pinyin8UserDict14get_lemma_wordEj($this, $2) | 0; $call11 = __ZN10ime_pinyin8UserDict16_get_lemma_scoreEPtS1_t($this, $call9, $call8, $call6 << 24 >> 24) | 0; HEAP32[2002] = 46880; L4445 : do { if ($call6 << 24 >> 24 == 0) { $j_1 = 0; } else { $j_034 = 0; while (1) { $4 = HEAP32[2002] | 0; $call16 = __ZN10ime_pinyin12SpellingTrie18get_spelling_str16EtPtj($call2, HEAP16[$call8 + ($j_034 << 1) >> 1] | 0, $4, 47904 - $4 >> 1) | 0; if (($call16 | 0) < 1) { $j_1 = $j_034; break L4445; } $5 = HEAP32[2002] | 0; $add_ptr = $5 + ($call16 << 1) | 0; HEAP32[2002] = $add_ptr; if ($add_ptr >>> 0 >= 47902 >>> 0) { $j_1 = 0; break L4445; } HEAP32[2002] = $5 + ($call16 + 1 << 1); HEAP16[$add_ptr >> 1] = 32; $inc = $j_034 + 1 | 0; if ($inc >>> 0 < $conv7 >>> 0) { $j_034 = $inc; } else { $j_1 = $inc; break; } } } } while (0); do { if ($j_1 >>> 0 < $conv7 >>> 0) { $len_1 = $len_045; $left_len_1 = $left_len_044; } else { $6 = HEAP32[2002] | 0; $incdec_ptr26 = $6 - 2 | 0; HEAP32[2002] = $incdec_ptr26; if ($incdec_ptr26 >>> 0 >= 47902 >>> 0) { $len_1 = $len_045; $left_len_1 = $left_len_044; break; } HEAP32[2002] = $6; HEAP16[$incdec_ptr26 >> 1] = 44; $7 = HEAP32[2002] | 0; $cmp3536 = $7 >>> 0 < 47902 >>> 0; if ($call6 << 24 >> 24 != 0 & $cmp3536) { $j_238 = 0; $8 = $7; while (1) { $9 = HEAP16[$call9 + ($j_238 << 1) >> 1] | 0; HEAP32[2002] = $8 + 2; HEAP16[$8 >> 1] = $9; $inc42 = $j_238 + 1 | 0; $10 = HEAP32[2002] | 0; $cmp35 = $10 >>> 0 < 47902 >>> 0; if ($inc42 >>> 0 < $conv7 >>> 0 & $cmp35) { $j_238 = $inc42; $8 = $10; } else { $j_2_lcssa = $inc42; $_lcssa = $10; $cmp35_lcssa = $cmp35; break; } } } else { $j_2_lcssa = 0; $_lcssa = $7; $cmp35_lcssa = $cmp3536; } if (!($j_2_lcssa >>> 0 >= $conv7 >>> 0 & $cmp35_lcssa)) { $len_1 = $len_045; $left_len_1 = $left_len_044; break; } HEAP32[2002] = $_lcssa + 2; HEAP16[$_lcssa >> 1] = 44; $conv54$0 = __ZN10ime_pinyin8UserDict18extract_score_freqEi(0, $call11) | 0; $11 = HEAP32[2002] | 0; $call58 = __ZN10ime_pinyin8UserDict13utf16le_lltoaExPti(0, $conv54$0, 0, $11, 47904 - $11 >> 1) | 0; if (($call58 | 0) < 1) { $len_1 = $len_045; $left_len_1 = $left_len_044; break; } $12 = HEAP32[2002] | 0; $add_ptr62 = $12 + ($call58 << 1) | 0; HEAP32[2002] = $add_ptr62; if ($add_ptr62 >>> 0 >= 47902 >>> 0) { $len_1 = $len_045; $left_len_1 = $left_len_044; break; } HEAP32[2002] = $12 + ($call58 + 1 << 1); HEAP16[$add_ptr62 >> 1] = 44; $call68$0 = __ZN10ime_pinyin8UserDict17extract_score_lmtEi(0, $call11) | 0; $13 = HEAP32[2002] | 0; $call72 = __ZN10ime_pinyin8UserDict13utf16le_lltoaExPti(0, $call68$0, tempRet0, $13, 47904 - $13 >> 1) | 0; if (($call72 | 0) < 1) { $len_1 = $len_045; $left_len_1 = $left_len_044; break; } $14 = HEAP32[2002] | 0; $add_ptr76 = $14 + ($call72 << 1) | 0; HEAP32[2002] = $add_ptr76; if ($add_ptr76 >>> 0 >= 47902 >>> 0) { $len_1 = $len_045; $left_len_1 = $left_len_044; break; } HEAP32[2002] = $14 + ($call72 + 1 << 1); HEAP16[$add_ptr76 >> 1] = 59; $sub_ptr_sub82 = (HEAP32[2002] | 0) - 46880 | 0; $sub_ptr_div83 = $sub_ptr_sub82 >> 1; if (($sub_ptr_div83 | 0) > ($left_len_044 | 0)) { $len_0_lcssa = $len_045; break L4443; } $16 = $str + ($len_045 << 1) | 0; _memcpy($16 | 0, 46880, $sub_ptr_sub82) | 0; HEAP32[$count >> 2] = (HEAP32[$count >> 2] | 0) + 1; $len_1 = $sub_ptr_div83 + $len_045 | 0; $left_len_1 = $left_len_044 - $sub_ptr_div83 | 0; } } while (0); $inc90 = $i_043 + 1 | 0; if ($inc90 >>> 0 < (HEAP32[$sync_count >> 2] | 0) >>> 0) { $i_043 = $inc90; $left_len_044 = $left_len_1; $len_045 = $len_1; } else { $len_0_lcssa = $len_1; break; } } if (($len_0_lcssa | 0) <= 0) { $retval_0 = $len_0_lcssa; return $retval_0 | 0; } $state_ = $this + 104 | 0; if ((HEAP32[$state_ >> 2] | 0) >= 2) { $retval_0 = $len_0_lcssa; return $retval_0 | 0; } HEAP32[$state_ >> 2] = 2; $retval_0 = $len_0_lcssa; return $retval_0 | 0; } function __ZN10ime_pinyin8UserDict5stateEPNS0_12UserDictStatE($this, $stat) { $this = $this | 0; $stat = $stat | 0; var $dict_info_ = 0, $retval_0 = 0; if (($stat | 0) == 0 | (__ZN10ime_pinyin8UserDict14is_valid_stateEv($this) | 0) ^ 1) { $retval_0 = 0; return $retval_0 | 0; } HEAP32[$stat >> 2] = HEAP32[$this + 20 >> 2]; HEAP32[$stat + 4 >> 2] = HEAP32[$this + 64 >> 2]; HEAP32[$stat + 8 >> 2] = HEAP32[$this + 8 >> 2]; HEAP32[$stat + 12 >> 2] = HEAP32[$this + 12 >> 2]; HEAP32[$stat + 16 >> 2] = HEAP32[11850]; HEAP32[$stat + 20 >> 2] = HEAP32[11851]; $dict_info_ = $this + 68 | 0; HEAP32[$stat + 24 >> 2] = __ZN10ime_pinyin8UserDict18get_dict_file_sizeEPNS0_12UserDictInfoE(0, $dict_info_) | 0; HEAP32[$stat + 28 >> 2] = HEAP32[$this + 80 >> 2]; HEAP32[$stat + 32 >> 2] = HEAP32[$this + 84 >> 2]; HEAP32[$stat + 36 >> 2] = HEAP32[$this + 88 >> 2]; HEAP32[$stat + 40 >> 2] = HEAP32[$this + 92 >> 2]; HEAP32[$stat + 44 >> 2] = HEAP32[$this + 96 >> 2]; HEAP32[$stat + 52 >> 2] = HEAP32[$this + 72 >> 2]; HEAP32[$stat + 56 >> 2] = HEAP32[$this + 76 >> 2]; HEAP32[$stat + 48 >> 2] = HEAP32[$dict_info_ >> 2]; $retval_0 = 1; return $retval_0 | 0; } function __ZN10ime_pinyin8UserDict10shift_downEPNS0_23UserDictScoreOffsetPairEii($this, $sop, $i, $n) { $this = $this | 0; $sop = $sop | 0; $i = $i | 0; $n = $n | 0; var $par_038 = 0, $add36 = 0, $add2 = 0, $cmp4 = 0, $score = 0, $0 = 0, $par_0_be = 0, $score15 = 0, $4 = 0, label = 0; if (($i | 0) < ($n | 0)) { $par_038 = $i; } else { return; } L4481 : while (1) { $add36 = $par_038 << 1 | 1; $add2 = $add36 + 1 | 0; $cmp4 = ($add2 | 0) < ($n | 0); if (!(($add36 | 0) < ($n | 0) | $cmp4)) { label = 3532; break; } $score = $sop + ($add36 << 3) | 0; $0 = HEAP32[$score >> 2] | 0; L4484 : do { if ($cmp4) { $score15 = $sop + ($add2 << 3) | 0; do { if (($0 | 0) > (HEAP32[$score15 >> 2] | 0)) { if (($0 | 0) <= (HEAP32[$sop + ($par_038 << 3) >> 2] | 0)) { break; } __ZN10ime_pinyin8UserDict4swapEPNS0_23UserDictScoreOffsetPairEii(0, $sop, $add36, $par_038); $par_0_be = $add36; break L4484; } } while (0); $4 = HEAP32[$score15 >> 2] | 0; if (($4 | 0) <= (HEAP32[$score >> 2] | 0)) { label = 3536; break L4481; } if (($4 | 0) <= (HEAP32[$sop + ($par_038 << 3) >> 2] | 0)) { label = 3537; break L4481; } __ZN10ime_pinyin8UserDict4swapEPNS0_23UserDictScoreOffsetPairEii(0, $sop, $add2, $par_038); $par_0_be = $add2; } else { if (($0 | 0) <= (HEAP32[$sop + ($par_038 << 3) >> 2] | 0)) { label = 3534; break L4481; } __ZN10ime_pinyin8UserDict4swapEPNS0_23UserDictScoreOffsetPairEii(0, $sop, $add36, $par_038); $par_0_be = $add36; } } while (0); if (($par_0_be | 0) < ($n | 0)) { $par_038 = $par_0_be; } else { label = 3533; break; } } if ((label | 0) == 3536) { return; } else if ((label | 0) == 3537) { return; } else if ((label | 0) == 3532) { return; } else if ((label | 0) == 3533) { return; } else if ((label | 0) == 3534) { return; } } function __ZN10ime_pinyin8UserDict9put_lemmaEPtS1_tt($this, $lemma_str, $splids, $lemma_len, $count) { $this = $this | 0; $lemma_str = $lemma_str | 0; $splids = $splids | 0; $lemma_len = $lemma_len | 0; $count = $count | 0; var $call = 0; $call = _time(0) | 0; return __ZN10ime_pinyin8UserDict10_put_lemmaEPtS1_tty($this, $lemma_str, $splids, $lemma_len, $count, $call, ($call | 0) < 0 ? -1 : 0) | 0; } function __ZN10ime_pinyin8UserDict7reclaimEv($this) { $this = $this | 0; var $0 = 0, $lemma_count = 0, $mul = 0, $div = 0, $call7 = 0, $2 = 0, $4 = 0, $i_036 = 0, $scores_28 = 0, $score31 = 0, $7 = 0, $i14_034 = 0, $i21_033 = 0, $10 = 0, $i42_031 = 0, $state_ = 0; if (!(__ZN10ime_pinyin8UserDict14is_valid_stateEv($this) | 0)) { return; } $0 = HEAP32[$this + 68 >> 2] | 0; if (($0 | 0) == 0) { return; } else if (($0 | 0) == 100) { ___assert_func(2712, 1958, 4520, 1856); } else { $lemma_count = $this + 80 | 0; $mul = Math_imul(HEAP32[$lemma_count >> 2] | 0, $0) | 0; $div = ($mul >>> 0) / 100 | 0; $call7 = _malloc($div << 3) | 0; $2 = $call7; if (($call7 | 0) == 0) { return; } if ($mul >>> 0 > 99) { $4 = HEAP32[$this + 32 >> 2] | 0; $i_036 = 0; do { HEAP32[$2 + ($i_036 << 3) >> 2] = HEAP32[$4 + ($i_036 << 2) >> 2]; HEAP32[$2 + ($i_036 << 3) + 4 >> 2] = $i_036; $i_036 = $i_036 + 1 | 0; } while (($i_036 | 0) < ($div | 0)); } $i14_034 = ($div + 1 | 0) >>> 1; while (1) { __ZN10ime_pinyin8UserDict10shift_downEPNS0_23UserDictScoreOffsetPairEii($this, $2, $i14_034, $div); if (($i14_034 | 0) > 0) { $i14_034 = $i14_034 - 1 | 0; } else { break; } } if ($div >>> 0 < (HEAP32[$lemma_count >> 2] | 0) >>> 0) { $scores_28 = $this + 32 | 0; $score31 = $call7; $7 = $call7 + 4 | 0; $i21_033 = $div; do { $10 = HEAP32[(HEAP32[$scores_28 >> 2] | 0) + ($i21_033 << 2) >> 2] | 0; if (($10 | 0) < (HEAP32[$score31 >> 2] | 0)) { HEAP32[$score31 >> 2] = $10; HEAP32[$7 >> 2] = $i21_033; __ZN10ime_pinyin8UserDict10shift_downEPNS0_23UserDictScoreOffsetPairEii($this, $2, 0, $div); } $i21_033 = $i21_033 + 1 | 0; } while ($i21_033 >>> 0 < (HEAP32[$lemma_count >> 2] | 0) >>> 0); } do { if ($mul >>> 0 > 99) { $i42_031 = 0; do { __ZN10ime_pinyin8UserDict28remove_lemma_by_offset_indexEi($this, HEAP32[$2 + ($i42_031 << 3) + 4 >> 2] | 0) | 0; $i42_031 = $i42_031 + 1 | 0; } while (($i42_031 | 0) < ($div | 0)); if ($mul >>> 0 <= 99) { break; } $state_ = $this + 104 | 0; if ((HEAP32[$state_ >> 2] | 0) >= 4) { break; } HEAP32[$state_ >> 2] = 4; } } while (0); _free($call7); return; } } function __ZN10ime_pinyin8UserDict21get_total_lemma_countEv($this) { $this = $this | 0; return HEAP32[$this + 100 >> 2] | 0; } function __ZN10ime_pinyin8UserDict31set_total_lemma_count_of_othersEj($this, $count) { $this = $this | 0; $count = $count | 0; HEAP32[$this + 4 >> 2] = $count; return; } function __ZN10ime_pinyin8UserDict16get_max_lemma_idEv($this) { $this = $this | 0; return (HEAP32[$this + 16 >> 2] | 0) - 1 + (HEAP32[$this + 80 >> 2] | 0) | 0; } function __ZN10ime_pinyin8UserDict14append_a_lemmaEPtS1_tty($this, $lemma_str, $splids, $lemma_len, $count, $lmt$0, $lmt$1) { $this = $this | 0; $lemma_str = $lemma_str | 0; $splids = $splids | 0; $lemma_len = $lemma_len | 0; $count = $count | 0; $lmt$0 = $lmt$0 | 0; $lmt$1 = $lmt$1 | 0; var $searchable = 0, $add = 0, $lemma_size = 0, $0 = 0, $lemmas_ = 0, $conv5 = 0, $add8 = 0, $add16 = 0, $i_063 = 0, $shl = 0, $lemma_count = 0, $9 = 0, $offsets_ = 0, $conv23 = 0, $call24 = 0, $scores_ = 0, $ids_ = 0, $predicts_ = 0, $add3461 = 0, $lemma_count_left_ = 0, $lemma_size_left_ = 0, $i42_0 = 0, $21 = 0, $call46 = 0, $22 = 0, $23 = 0, $add_ptr_sum = 0, $shl64 = 0, $27 = 0, $28 = 0, $32 = 0, $33 = 0, $37 = 0, $38 = 0, $call94 = 0, $state_ = 0, $total_nfreq = 0, $retval_0 = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 48 | 0; $searchable = sp | 0; $add = (__ZN10ime_pinyin8UserDict16get_max_lemma_idEv($this) | 0) + 1 | 0; $lemma_size = $this + 84 | 0; $0 = HEAP32[$lemma_size >> 2] | 0; if (($0 | 0) < 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } $lemmas_ = $this + 24 | 0; HEAP8[(HEAP32[$lemmas_ >> 2] | 0) + $0 | 0] = 0; HEAP8[(HEAP32[$lemmas_ >> 2] | 0) + ($0 + 1) | 0] = $lemma_len & 255; $conv5 = $lemma_len & 65535; if ($lemma_len << 16 >> 16 != 0) { $add8 = $0 + 2 | 0; $add16 = $add8 + ($conv5 << 1) | 0; $i_063 = 0; do { $shl = $i_063 << 1; HEAP16[(HEAP32[$lemmas_ >> 2] | 0) + ($shl + $add8) >> 1] = HEAP16[$splids + ($i_063 << 1) >> 1] | 0; HEAP16[(HEAP32[$lemmas_ >> 2] | 0) + ($add16 + $shl) >> 1] = HEAP16[$lemma_str + ($i_063 << 1) >> 1] | 0; $i_063 = $i_063 + 1 | 0; } while ($i_063 >>> 0 < $conv5 >>> 0); } $lemma_count = $this + 80 | 0; $9 = HEAP32[$lemma_count >> 2] | 0; $offsets_ = $this + 28 | 0; HEAP32[(HEAP32[$offsets_ >> 2] | 0) + ($9 << 2) >> 2] = $0; $conv23 = $count & 65535; $call24 = __ZN10ime_pinyin8UserDict11build_scoreEyi(0, $lmt$0, $lmt$1, $conv23) | 0; $scores_ = $this + 32 | 0; HEAP32[(HEAP32[$scores_ >> 2] | 0) + ($9 << 2) >> 2] = $call24; $ids_ = $this + 36 | 0; HEAP32[(HEAP32[$ids_ >> 2] | 0) + ($9 << 2) >> 2] = $add; $predicts_ = $this + 40 | 0; HEAP32[(HEAP32[$predicts_ >> 2] | 0) + ($9 << 2) >> 2] = $0; HEAP32[(HEAP32[$this + 52 >> 2] | 0) + ($add - (HEAP32[$this + 16 >> 2] | 0) << 2) >> 2] = $0; HEAP32[$lemma_count >> 2] = (HEAP32[$lemma_count >> 2] | 0) + 1; $add3461 = $conv5 << 2 | 2; HEAP32[$lemma_size >> 2] = (HEAP32[$lemma_size >> 2] | 0) + $add3461; $lemma_count_left_ = $this + 56 | 0; HEAP32[$lemma_count_left_ >> 2] = (HEAP32[$lemma_count_left_ >> 2] | 0) - 1; $lemma_size_left_ = $this + 60 | 0; HEAP32[$lemma_size_left_ >> 2] = (HEAP32[$lemma_size_left_ >> 2] | 0) - $add3461; __ZN10ime_pinyin8UserDict14prepare_locateEPNS0_18UserDictSearchableEPKtt(0, $searchable, $splids, $lemma_len); $i42_0 = 0; while (1) { if ($i42_0 >>> 0 >= $9 >>> 0) { break; } $21 = HEAP32[(HEAP32[$offsets_ >> 2] | 0) + ($i42_0 << 2) >> 2] | 0; $call46 = __ZN10ime_pinyin8UserDict15get_lemma_ncharEj($this, $21) | 0; if ((__ZN10ime_pinyin8UserDict22fuzzy_compare_spell_idEPKttPKNS0_18UserDictSearchableE(0, __ZN10ime_pinyin8UserDict19get_lemma_spell_idsEj($this, $21) | 0, $call46 << 24 >> 24, $searchable) | 0) > -1) { break; } else { $i42_0 = $i42_0 + 1 | 0; } } if (($i42_0 | 0) != ($9 | 0)) { $22 = HEAP32[$offsets_ >> 2] | 0; $23 = HEAP32[$22 + ($9 << 2) >> 2] | 0; $add_ptr_sum = $i42_0 + 1 | 0; $shl64 = $9 - $i42_0 << 2; _memmove($22 + ($add_ptr_sum << 2) | 0, $22 + ($i42_0 << 2) | 0, $shl64 | 0); HEAP32[(HEAP32[$offsets_ >> 2] | 0) + ($i42_0 << 2) >> 2] = $23; $27 = HEAP32[$scores_ >> 2] | 0; $28 = HEAP32[$27 + ($9 << 2) >> 2] | 0; _memmove($27 + ($add_ptr_sum << 2) | 0, $27 + ($i42_0 << 2) | 0, $shl64 | 0); HEAP32[(HEAP32[$scores_ >> 2] | 0) + ($i42_0 << 2) >> 2] = $28; $32 = HEAP32[$ids_ >> 2] | 0; $33 = HEAP32[$32 + ($9 << 2) >> 2] | 0; _memmove($32 + ($add_ptr_sum << 2) | 0, $32 + ($i42_0 << 2) | 0, $shl64 | 0); HEAP32[(HEAP32[$ids_ >> 2] | 0) + ($i42_0 << 2) >> 2] = $33; } $37 = HEAP32[$predicts_ >> 2] | 0; $38 = HEAP32[$37 + ($9 << 2) >> 2] | 0; $call94 = __ZN10ime_pinyin8UserDict34locate_where_to_insert_in_predictsEPKti($this, __ZN10ime_pinyin8UserDict14get_lemma_wordEj($this, $38) | 0, $conv5) | 0; if (($call94 | 0) != ($9 | 0)) { _memmove($37 + ($call94 + 1 << 2) | 0, $37 + ($call94 << 2) | 0, $9 - $call94 << 2 | 0); HEAP32[(HEAP32[$predicts_ >> 2] | 0) + ($call94 << 2) >> 2] = $38; } $state_ = $this + 104 | 0; if ((HEAP32[$state_ >> 2] | 0) < 5) { HEAP32[$state_ >> 2] = 5; } __ZN10ime_pinyin8UserDict10cache_initEv($this); $total_nfreq = $this + 100 | 0; HEAP32[$total_nfreq >> 2] = (HEAP32[$total_nfreq >> 2] | 0) + $conv23; $retval_0 = $add; STACKTOP = sp; return $retval_0 | 0; } function __ZN10ime_pinyin8UserDict20queue_lemma_for_syncEj($this, $id) { $this = $this | 0; $id = $id | 0; var $sync_count = 0, $0 = 0, $sync_count_size_ = 0, $1 = 0, $4 = 0, $syncs_5 = 0, $call = 0, $12 = 0, $13 = 0; $sync_count = $this + 96 | 0; $0 = HEAP32[$sync_count >> 2] | 0; $sync_count_size_ = $this + 48 | 0; $1 = HEAP32[$sync_count_size_ >> 2] | 0; if ($0 >>> 0 < $1 >>> 0) { $4 = HEAP32[(HEAP32[$this + 52 >> 2] | 0) + ($id - (HEAP32[$this + 16 >> 2] | 0) << 2) >> 2] | 0; HEAP32[$sync_count >> 2] = $0 + 1; HEAP32[(HEAP32[$this + 44 >> 2] | 0) + ($0 << 2) >> 2] = $4; return; } $syncs_5 = $this + 44 | 0; $call = _realloc(HEAP32[$syncs_5 >> 2] | 0, ($1 << 2) + 128 | 0) | 0; if (($call | 0) == 0) { return; } HEAP32[$sync_count_size_ >> 2] = (HEAP32[$sync_count_size_ >> 2] | 0) + 32; HEAP32[$syncs_5 >> 2] = $call; $12 = HEAP32[(HEAP32[$this + 52 >> 2] | 0) + ($id - (HEAP32[$this + 16 >> 2] | 0) << 2) >> 2] | 0; $13 = HEAP32[$sync_count >> 2] | 0; HEAP32[$sync_count >> 2] = $13 + 1; HEAP32[(HEAP32[$syncs_5 >> 2] | 0) + ($13 << 2) >> 2] = $12; return; } function __ZN10ime_pinyin8UserDict12update_lemmaEjsb($this, $lemma_id, $delta_count, $selected) { $this = $this | 0; $lemma_id = $lemma_id | 0; $delta_count = $delta_count | 0; $selected = $selected | 0; var $2 = 0, $call7 = 0, $call8 = 0, $call11 = 0, $scores_ = 0, $4 = 0, $call15 = 0, $call16$0 = 0, $call16$1 = 0, $delta_count_addr_0 = 0, $conv26 = 0, $total_nfreq = 0, $call31 = 0, $lmt_0$0 = 0, $lmt_0$1 = 0, $call34 = 0, $state_ = 0, $ids_ = 0, $retval_0 = 0; if (!(__ZN10ime_pinyin8UserDict14is_valid_stateEv($this) | 0)) { $retval_0 = 0; return $retval_0 | 0; } if (!(__ZN10ime_pinyin8UserDict17is_valid_lemma_idEj($this, $lemma_id) | 0)) { $retval_0 = 0; return $retval_0 | 0; } $2 = HEAP32[(HEAP32[$this + 52 >> 2] | 0) + ($lemma_id - (HEAP32[$this + 16 >> 2] | 0) << 2) >> 2] | 0; $call7 = __ZN10ime_pinyin8UserDict15get_lemma_ncharEj($this, $2) | 0; $call8 = __ZN10ime_pinyin8UserDict14get_lemma_wordEj($this, $2) | 0; $call11 = __ZN10ime_pinyin8UserDict17locate_in_offsetsEPtS1_t($this, $call8, __ZN10ime_pinyin8UserDict19get_lemma_spell_idsEj($this, $2) | 0, $call7 & 255) | 0; if (($call11 | 0) == -1) { $retval_0 = 0; return $retval_0 | 0; } $scores_ = $this + 32 | 0; $4 = HEAP32[(HEAP32[$scores_ >> 2] | 0) + ($call11 << 2) >> 2] | 0; $call15 = __ZN10ime_pinyin8UserDict18extract_score_freqEi(0, $4) | 0; $call16$0 = __ZN10ime_pinyin8UserDict17extract_score_lmtEi(0, $4) | 0; $call16$1 = tempRet0; if (($call15 + ($delta_count << 16 >> 16) | 0) > 65535 | $delta_count << 16 >> 16 < 0) { $delta_count_addr_0 = 65535 - $call15 & 65535; } else { $delta_count_addr_0 = $delta_count; } $conv26 = $delta_count_addr_0 << 16 >> 16; $total_nfreq = $this + 100 | 0; HEAP32[$total_nfreq >> 2] = (HEAP32[$total_nfreq >> 2] | 0) + $conv26; if ($selected) { $call31 = _time(0) | 0; $lmt_0$1 = ($call31 | 0) < 0 ? -1 : 0; $lmt_0$0 = $call31; } else { $lmt_0$1 = $call16$1; $lmt_0$0 = $call16$0; } $call34 = __ZN10ime_pinyin8UserDict11build_scoreEyi(0, $lmt_0$0, $lmt_0$1, $conv26 + $call15 | 0) | 0; HEAP32[(HEAP32[$scores_ >> 2] | 0) + ($call11 << 2) >> 2] = $call34; $state_ = $this + 104 | 0; if ((HEAP32[$state_ >> 2] | 0) < 3) { HEAP32[$state_ >> 2] = 3; } $ids_ = $this + 36 | 0; __ZN10ime_pinyin8UserDict20queue_lemma_for_syncEj($this, HEAP32[(HEAP32[$ids_ >> 2] | 0) + ($call11 << 2) >> 2] | 0); $retval_0 = HEAP32[(HEAP32[$ids_ >> 2] | 0) + ($call11 << 2) >> 2] | 0; return $retval_0 | 0; } function __ZN10ime_pinyin11Utf16ReaderC2Ev($this) { $this = $this | 0; _memset($this | 0, 0, 20); return; } function __ZN10ime_pinyin11Utf16ReaderD2Ev($this) { $this = $this | 0; var $0 = 0, $1 = 0; $0 = HEAP32[$this >> 2] | 0; if (($0 | 0) != 0) { _fclose($0 | 0) | 0; } $1 = HEAP32[$this + 4 >> 2] | 0; if (($1 | 0) == 0) { return; } __ZdaPv($1); return; } function __ZN10ime_pinyin11Utf16Reader4openEPKcj($this, $filename, $buffer_len) { $this = $this | 0; $filename = $filename | 0; $buffer_len = $buffer_len | 0; var $header = 0, $buffer_len_addr_0 = 0, $buffer_total_len_ = 0, $buffer_ = 0, $0 = 0, $3$0 = 0, $call = 0, $call18 = 0, $fp_ = 0, $cmp24 = 0, $retval_0 = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 8 | 0; $header = sp | 0; if (($filename | 0) == 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } if ($buffer_len >>> 0 < 128) { $buffer_len_addr_0 = 128; } else { $buffer_len_addr_0 = $buffer_len >>> 0 > 65535 ? 65535 : $buffer_len; } $buffer_total_len_ = $this + 8 | 0; HEAP32[$buffer_total_len_ >> 2] = $buffer_len_addr_0; $buffer_ = $this + 4 | 0; $0 = HEAP32[$buffer_ >> 2] | 0; if (($0 | 0) != 0) { __ZdaPv($0); } $3$0 = _llvm_umul_with_overflow_i32(HEAP32[$buffer_total_len_ >> 2] | 0, 2) | 0; $call = __Znaj(tempRet0 ? -1 : $3$0) | 0; HEAP32[$buffer_ >> 2] = $call; if (($call | 0) == 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } $call18 = _fopen($filename | 0, 2072) | 0; $fp_ = $this | 0; HEAP32[$fp_ >> 2] = $call18; if (($call18 | 0) == 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } $cmp24 = (_fread($header | 0, 2, 1, $call18 | 0) | 0) == 1; if ($cmp24 & (HEAP16[$header >> 1] | 0) == -257) { $retval_0 = 1; STACKTOP = sp; return $retval_0 | 0; } _fclose(HEAP32[$fp_ >> 2] | 0) | 0; HEAP32[$fp_ >> 2] = 0; $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } function __ZN10ime_pinyin11Utf16Reader8readlineEPtj($this, $read_buf, $max_len) { $this = $this | 0; $read_buf = $read_buf | 0; $max_len = $max_len | 0; var $fp_ = 0, $buffer_valid_len_ = 0, $buffer_next_pos_ = 0, $buffer_ = 0, $buffer_total_len_ = 0, $sub = 0, $buffer_next_pos_21 = 0, $buffer_22 = 0, $1 = 0, $ret_len_0 = 0, $call = 0, $i_032 = 0, $8 = 0, $add26 = 0, $arrayidx30 = 0, $inc = 0, $buffer_next_pos_40 = 0, $inc59 = 0, $14 = 0, $_lcssa = 0, $retval_0 = 0, label = 0; $fp_ = $this | 0; if ((HEAP32[$fp_ >> 2] | 0) == 0 | ($read_buf | 0) == 0 | ($max_len | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $buffer_valid_len_ = $this + 16 | 0; $buffer_next_pos_ = $this + 12 | 0; $buffer_ = $this + 4 | 0; $buffer_total_len_ = $this + 8 | 0; $sub = $max_len - 1 | 0; $buffer_next_pos_21 = $this + 12 | 0; $buffer_22 = $this + 4 | 0; $ret_len_0 = 0; $1 = (HEAP32[$buffer_valid_len_ >> 2] | 0) == 0; L4625 : while (1) { if ($1) { HEAP32[$buffer_next_pos_ >> 2] = 0; $call = _fread(HEAP32[$buffer_ >> 2] | 0, 2, HEAP32[$buffer_total_len_ >> 2] | 0, HEAP32[$fp_ >> 2] | 0) | 0; HEAP32[$buffer_valid_len_ >> 2] = $call; if (($call | 0) == 0) { label = 3635; break; } else { $i_032 = 0; label = 3637; } } else { if ((HEAP32[$buffer_valid_len_ >> 2] | 0) == 0) { $_lcssa = 0; } else { $i_032 = 0; label = 3637; } } if ((label | 0) == 3637) { while (1) { label = 0; if (($i_032 | 0) == ($sub | 0)) { break L4625; } $8 = HEAP16[(HEAP32[$buffer_22 >> 2] | 0) + ((HEAP32[$buffer_next_pos_21 >> 2] | 0) + $i_032 << 1) >> 1] | 0; if ($8 << 16 >> 16 == 10) { break L4625; } HEAP16[$read_buf + ($i_032 + $ret_len_0 << 1) >> 1] = $8; $inc59 = $i_032 + 1 | 0; $14 = HEAP32[$buffer_valid_len_ >> 2] | 0; if ($inc59 >>> 0 < $14 >>> 0) { $i_032 = $inc59; label = 3637; } else { $_lcssa = $14; break; } } } HEAP32[$buffer_valid_len_ >> 2] = 0; $ret_len_0 = $_lcssa + $ret_len_0 | 0; $1 = 1; } if ((label | 0) == 3635) { if (($ret_len_0 | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } HEAP16[$read_buf + ($ret_len_0 << 1) >> 1] = 0; $retval_0 = $read_buf; return $retval_0 | 0; } $add26 = $i_032 + $ret_len_0 | 0; do { if (($add26 | 0) == 0) { label = 3642; } else { $arrayidx30 = $read_buf + ($add26 - 1 << 1) | 0; if ((HEAP16[$arrayidx30 >> 1] | 0) != 13) { label = 3642; break; } HEAP16[$arrayidx30 >> 1] = 0; } } while (0); if ((label | 0) == 3642) { HEAP16[$read_buf + ($add26 << 1) >> 1] = 0; } $inc = $i_032 + 1 | 0; $buffer_next_pos_40 = $this + 12 | 0; HEAP32[$buffer_next_pos_40 >> 2] = (HEAP32[$buffer_next_pos_40 >> 2] | 0) + $inc; HEAP32[$buffer_valid_len_ >> 2] = (HEAP32[$buffer_valid_len_ >> 2] | 0) - $inc; if ((HEAP32[$buffer_next_pos_40 >> 2] | 0) != (HEAP32[$this + 8 >> 2] | 0)) { $retval_0 = $read_buf; return $retval_0 | 0; } HEAP32[$buffer_next_pos_40 >> 2] = 0; HEAP32[$buffer_valid_len_ >> 2] = 0; $retval_0 = $read_buf; return $retval_0 | 0; } function __ZNSt9type_infoD2Ev($this) { $this = $this | 0; return; } function __ZNSt8bad_castD2Ev($this) { $this = $this | 0; return; } function __ZNKSt8bad_cast4whatEv($this) { $this = $this | 0; return 1888 | 0; } function __ZNSt10bad_typeidD2Ev($this) { $this = $this | 0; return; } function __ZNKSt10bad_typeid4whatEv($this) { $this = $this | 0; return 3800 | 0; } function __ZNK10__cxxabiv116__shim_type_info5noop1Ev($this) { $this = $this | 0; return; } function __ZNK10__cxxabiv116__shim_type_info5noop2Ev($this) { $this = $this | 0; return; } function _ConvertUTF32toUTF16($sourceStart, $sourceEnd, $targetStart, $targetEnd, $flags) { $sourceStart = $sourceStart | 0; $sourceEnd = $sourceEnd | 0; $targetStart = $targetStart | 0; $targetEnd = $targetEnd | 0; $flags = $flags | 0; var $0 = 0, $1 = 0, $cmp7 = 0, $cmp18 = 0, $target_0_ph39 = 0, $source_0_ph38 = 0, $result_0_ph37 = 0, $target_027 = 0, $source_026 = 0, $incdec_ptr = 0, $2 = 0, $add_ptr = 0, $sub = 0, $target_0_be = 0, $target_0_lcssa = 0, $source_0_lcssa = 0, $result_1 = 0; $0 = HEAP32[$sourceStart >> 2] | 0; $1 = HEAP32[$targetStart >> 2] | 0; L8 : do { if ($0 >>> 0 < $sourceEnd >>> 0) { $cmp7 = ($flags | 0) == 0; $cmp18 = ($flags | 0) == 0; $result_0_ph37 = 0; $source_0_ph38 = $0; $target_0_ph39 = $1; while (1) { $source_026 = $source_0_ph38; $target_027 = $target_0_ph39; L12 : while (1) { if ($target_027 >>> 0 >= $targetEnd >>> 0) { $result_1 = 2; $source_0_lcssa = $source_026; $target_0_lcssa = $target_027; break L8; } $incdec_ptr = $source_026 + 4 | 0; $2 = HEAP32[$source_026 >> 2] | 0; do { if ($2 >>> 0 < 65536) { if (($2 - 55296 | 0) >>> 0 >= 2048) { HEAP16[$target_027 >> 1] = $2 & 65535; $target_0_be = $target_027 + 2 | 0; break; } if ($cmp7) { $result_1 = 3; $source_0_lcssa = $source_026; $target_0_lcssa = $target_027; break L8; } HEAP16[$target_027 >> 1] = -3; $target_0_be = $target_027 + 2 | 0; } else { if ($2 >>> 0 > 1114111) { if ($cmp18) { break L12; } HEAP16[$target_027 >> 1] = -3; $target_0_be = $target_027 + 2 | 0; break; } else { $add_ptr = $target_027 + 2 | 0; if ($add_ptr >>> 0 >= $targetEnd >>> 0) { $result_1 = 2; $source_0_lcssa = $source_026; $target_0_lcssa = $target_027; break L8; } $sub = $2 - 65536 | 0; HEAP16[$target_027 >> 1] = ($sub >>> 10) + 55296 & 65535; HEAP16[$add_ptr >> 1] = ($sub & 1023 | 56320) & 65535; $target_0_be = $target_027 + 4 | 0; break; } } } while (0); if ($incdec_ptr >>> 0 < $sourceEnd >>> 0) { $source_026 = $incdec_ptr; $target_027 = $target_0_be; } else { $result_1 = $result_0_ph37; $source_0_lcssa = $incdec_ptr; $target_0_lcssa = $target_0_be; break L8; } } if ($incdec_ptr >>> 0 < $sourceEnd >>> 0) { $result_0_ph37 = 3; $source_0_ph38 = $incdec_ptr; $target_0_ph39 = $target_027; } else { $result_1 = 3; $source_0_lcssa = $incdec_ptr; $target_0_lcssa = $target_027; break; } } } else { $result_1 = 0; $source_0_lcssa = $0; $target_0_lcssa = $1; } } while (0); HEAP32[$sourceStart >> 2] = $source_0_lcssa; HEAP32[$targetStart >> 2] = $target_0_lcssa; return $result_1 | 0; } function _ConvertUTF16toUTF32($sourceStart, $sourceEnd, $targetStart, $targetEnd, $flags) { $sourceStart = $sourceStart | 0; $sourceEnd = $sourceEnd | 0; $targetStart = $targetStart | 0; $targetEnd = $targetEnd | 0; $flags = $flags | 0; var $0 = 0, $1 = 0, $cmp13 = 0, $cmp21 = 0, $source_028 = 0, $target_027 = 0, $incdec_ptr = 0, $2 = 0, $conv = 0, $4 = 0, $ch_0 = 0, $source_1 = 0, $incdec_ptr34 = 0, $source_0_lcssa = 0, $target_0_lcssa = 0, $result_0 = 0; $0 = HEAP32[$sourceStart >> 2] | 0; $1 = HEAP32[$targetStart >> 2] | 0; L31 : do { if ($0 >>> 0 < $sourceEnd >>> 0) { $cmp13 = ($flags | 0) == 0; $cmp21 = ($flags | 0) == 0; $target_027 = $1; $source_028 = $0; while (1) { $incdec_ptr = $source_028 + 2 | 0; $2 = HEAP16[$source_028 >> 1] | 0; $conv = $2 & 65535; do { if (($2 + 10240 & 65535) < 1024) { if ($incdec_ptr >>> 0 >= $sourceEnd >>> 0) { $result_0 = 1; $target_0_lcssa = $target_027; $source_0_lcssa = $source_028; break L31; } $4 = HEAP16[$incdec_ptr >> 1] | 0; if (($4 + 9216 & 65535) < 1024) { $source_1 = $source_028 + 4 | 0; $ch_0 = ($conv << 10) - 56613888 + ($4 & 65535) | 0; break; } else { if ($cmp13) { $result_0 = 3; $target_0_lcssa = $target_027; $source_0_lcssa = $source_028; break L31; } else { $source_1 = $incdec_ptr; $ch_0 = $conv; break; } } } else { if (!$cmp21) { $source_1 = $incdec_ptr; $ch_0 = $conv; break; } if (($2 + 9216 & 65535) < 1024) { $result_0 = 3; $target_0_lcssa = $target_027; $source_0_lcssa = $source_028; break L31; } else { $source_1 = $incdec_ptr; $ch_0 = $conv; } } } while (0); if ($target_027 >>> 0 >= $targetEnd >>> 0) { $result_0 = 2; $target_0_lcssa = $target_027; $source_0_lcssa = $source_028; break L31; } $incdec_ptr34 = $target_027 + 4 | 0; HEAP32[$target_027 >> 2] = $ch_0; if ($source_1 >>> 0 < $sourceEnd >>> 0) { $target_027 = $incdec_ptr34; $source_028 = $source_1; } else { $result_0 = 0; $target_0_lcssa = $incdec_ptr34; $source_0_lcssa = $source_1; break; } } } else { $result_0 = 0; $target_0_lcssa = $1; $source_0_lcssa = $0; } } while (0); HEAP32[$sourceStart >> 2] = $source_0_lcssa; HEAP32[$targetStart >> 2] = $target_0_lcssa; return $result_0 | 0; } function _ConvertUTF16toUTF8($sourceStart, $sourceEnd, $targetStart, $targetEnd, $flags) { $sourceStart = $sourceStart | 0; $sourceEnd = $sourceEnd | 0; $targetStart = $targetStart | 0; $targetEnd = $targetEnd | 0; $flags = $flags | 0; var $0 = 0, $1 = 0, $cmp13 = 0, $cmp21 = 0, $source_049 = 0, $target_048 = 0, $incdec_ptr = 0, $2 = 0, $conv = 0, $4 = 0, $ch_0 = 0, $source_1 = 0, $cmp40 = 0, $bytesToWrite_0 = 0, $ch_1 = 0, $add_ptr = 0, $incdec_ptr55 = 0, $ch_2 = 0, $target_1 = 0, $incdec_ptr60 = 0, $ch_3 = 0, $target_2 = 0, $incdec_ptr66 = 0, $ch_4 = 0, $target_3 = 0, $incdec_ptr72 = 0, $target_4 = 0, $add_ptr74 = 0, $source_0_lcssa = 0, $target_0_lcssa = 0, $result_0 = 0, label = 0; $0 = HEAP32[$sourceStart >> 2] | 0; $1 = HEAP32[$targetStart >> 2] | 0; L47 : do { if ($0 >>> 0 < $sourceEnd >>> 0) { $cmp13 = ($flags | 0) == 0; $cmp21 = ($flags | 0) == 0; $target_048 = $1; $source_049 = $0; while (1) { $incdec_ptr = $source_049 + 2 | 0; $2 = HEAP16[$source_049 >> 1] | 0; $conv = $2 & 65535; do { if (($2 + 10240 & 65535) < 1024) { if ($incdec_ptr >>> 0 >= $sourceEnd >>> 0) { $result_0 = 1; $target_0_lcssa = $target_048; $source_0_lcssa = $source_049; break L47; } $4 = HEAP16[$incdec_ptr >> 1] | 0; if (($4 + 9216 & 65535) < 1024) { $source_1 = $source_049 + 4 | 0; $ch_0 = ($conv << 10) - 56613888 + ($4 & 65535) | 0; break; } else { if ($cmp13) { $result_0 = 3; $target_0_lcssa = $target_048; $source_0_lcssa = $source_049; break L47; } else { $source_1 = $incdec_ptr; $ch_0 = $conv; break; } } } else { if (!$cmp21) { $source_1 = $incdec_ptr; $ch_0 = $conv; break; } if (($2 + 9216 & 65535) < 1024) { $result_0 = 3; $target_0_lcssa = $target_048; $source_0_lcssa = $source_049; break L47; } else { $source_1 = $incdec_ptr; $ch_0 = $conv; } } } while (0); do { if ($ch_0 >>> 0 < 128) { $ch_1 = $ch_0; $bytesToWrite_0 = 1; } else { if ($ch_0 >>> 0 < 2048) { $ch_1 = $ch_0; $bytesToWrite_0 = 2; break; } if ($ch_0 >>> 0 < 65536) { $ch_1 = $ch_0; $bytesToWrite_0 = 3; break; } $cmp40 = $ch_0 >>> 0 < 1114112; $ch_1 = $cmp40 ? $ch_0 : 65533; $bytesToWrite_0 = $cmp40 ? 4 : 3; } } while (0); $add_ptr = $target_048 + $bytesToWrite_0 | 0; if ($add_ptr >>> 0 > $targetEnd >>> 0) { $result_0 = 2; $target_0_lcssa = $target_048; $source_0_lcssa = $source_049; break L47; } if (($bytesToWrite_0 | 0) == 4) { $incdec_ptr55 = $target_048 + ($bytesToWrite_0 - 1) | 0; HEAP8[$incdec_ptr55] = ($ch_1 & 63 | 128) & 255; $target_1 = $incdec_ptr55; $ch_2 = $ch_1 >>> 6; label = 53; } else if (($bytesToWrite_0 | 0) == 3) { $target_1 = $add_ptr; $ch_2 = $ch_1; label = 53; } else if (($bytesToWrite_0 | 0) == 2) { $target_2 = $add_ptr; $ch_3 = $ch_1; label = 54; } else if (($bytesToWrite_0 | 0) == 1) { $target_3 = $add_ptr; $ch_4 = $ch_1; label = 55; } else { $target_4 = $add_ptr; } if ((label | 0) == 53) { label = 0; $incdec_ptr60 = $target_1 - 1 | 0; HEAP8[$incdec_ptr60] = ($ch_2 & 63 | 128) & 255; $target_2 = $incdec_ptr60; $ch_3 = $ch_2 >>> 6; label = 54; } if ((label | 0) == 54) { label = 0; $incdec_ptr66 = $target_2 - 1 | 0; HEAP8[$incdec_ptr66] = ($ch_3 & 63 | 128) & 255; $target_3 = $incdec_ptr66; $ch_4 = $ch_3 >>> 6; label = 55; } if ((label | 0) == 55) { label = 0; $incdec_ptr72 = $target_3 - 1 | 0; HEAP8[$incdec_ptr72] = (HEAPU8[11264 + $bytesToWrite_0 | 0] | 0 | $ch_4) & 255; $target_4 = $incdec_ptr72; } $add_ptr74 = $target_4 + $bytesToWrite_0 | 0; if ($source_1 >>> 0 < $sourceEnd >>> 0) { $target_048 = $add_ptr74; $source_049 = $source_1; } else { $result_0 = 0; $target_0_lcssa = $add_ptr74; $source_0_lcssa = $source_1; break; } } } else { $result_0 = 0; $target_0_lcssa = $1; $source_0_lcssa = $0; } } while (0); HEAP32[$sourceStart >> 2] = $source_0_lcssa; HEAP32[$targetStart >> 2] = $target_0_lcssa; return $result_0 | 0; } function __ZL11isLegalUTF8PKhi($source, $length) { $source = $source | 0; $length = $length | 0; var $add_ptr = 0, $incdec_ptr = 0, $0 = 0, $srcptr_0 = 0, $incdec_ptr4 = 0, $1 = 0, $srcptr_1 = 0, $2 = 0, $conv18 = 0, $4 = 0, $retval_0 = 0, label = 0; $add_ptr = $source + $length | 0; if (($length | 0) == 4) { $incdec_ptr = $source + ($length - 1) | 0; $0 = HEAP8[$incdec_ptr] | 0; if ($0 << 24 >> 24 > -1 | ($0 & 255) > 191) { $retval_0 = 0; } else { $srcptr_0 = $incdec_ptr; label = 60; } } else if (($length | 0) == 3) { $srcptr_0 = $add_ptr; label = 60; } else if (($length | 0) == 2) { $srcptr_1 = $add_ptr; label = 61; } else if (($length | 0) == 1) { label = 68; } else { $retval_0 = 0; } if ((label | 0) == 60) { $incdec_ptr4 = $srcptr_0 - 1 | 0; $1 = HEAP8[$incdec_ptr4] | 0; if ($1 << 24 >> 24 > -1 | ($1 & 255) > 191) { $retval_0 = 0; } else { $srcptr_1 = $incdec_ptr4; label = 61; } } do { if ((label | 0) == 61) { $2 = HEAP8[$srcptr_1 - 1 | 0] | 0; if (($2 & 255) > 191) { $retval_0 = 0; break; } $conv18 = HEAPU8[$source] | 0; if (($conv18 | 0) == 224) { if (($2 & 255) < 160) { $retval_0 = 0; break; } else { label = 68; break; } } else if (($conv18 | 0) == 237) { if (($2 & 255) > 159) { $retval_0 = 0; break; } else { label = 68; break; } } else if (($conv18 | 0) == 240) { if (($2 & 255) < 144) { $retval_0 = 0; break; } else { label = 68; break; } } else if (($conv18 | 0) == 244) { if (($2 & 255) > 143) { $retval_0 = 0; break; } else { label = 68; break; } } else { if ($2 << 24 >> 24 > -1) { $retval_0 = 0; break; } else { label = 68; break; } } } } while (0); do { if ((label | 0) == 68) { $4 = HEAP8[$source] | 0; if ($4 << 24 >> 24 < 0 & ($4 & 255) < 194) { $retval_0 = 0; break; } $retval_0 = ($4 & 255) < 245 | 0; } } while (0); return $retval_0 | 0; } function _ConvertUTF32toUTF8($sourceStart, $sourceEnd, $targetStart, $targetEnd, $flags) { $sourceStart = $sourceStart | 0; $sourceEnd = $sourceEnd | 0; $targetStart = $targetStart | 0; $targetEnd = $targetEnd | 0; $flags = $flags | 0; var $0 = 0, $1 = 0, $cmp1 = 0, $result_036 = 0, $source_035 = 0, $target_034 = 0, $incdec_ptr = 0, $2 = 0, $cmp15 = 0, $ch_0 = 0, $bytesToWrite_0 = 0, $result_1 = 0, $add_ptr = 0, $incdec_ptr30 = 0, $target_1 = 0, $ch_1 = 0, $incdec_ptr35 = 0, $target_2 = 0, $ch_2 = 0, $incdec_ptr41 = 0, $target_3 = 0, $ch_3 = 0, $incdec_ptr47 = 0, $target_4 = 0, $add_ptr49 = 0, $source_0_lcssa = 0, $target_0_lcssa = 0, $result_2 = 0, label = 0; $0 = HEAP32[$sourceStart >> 2] | 0; $1 = HEAP32[$targetStart >> 2] | 0; L95 : do { if ($0 >>> 0 < $sourceEnd >>> 0) { $cmp1 = ($flags | 0) == 0; $target_034 = $1; $source_035 = $0; $result_036 = 0; while (1) { $incdec_ptr = $source_035 + 4 | 0; $2 = HEAP32[$source_035 >> 2] | 0; if ($cmp1) { if (($2 - 55296 | 0) >>> 0 < 2048) { $result_2 = 3; $target_0_lcssa = $target_034; $source_0_lcssa = $source_035; break L95; } } do { if ($2 >>> 0 < 128) { $result_1 = $result_036; $bytesToWrite_0 = 1; $ch_0 = $2; } else { if ($2 >>> 0 < 2048) { $result_1 = $result_036; $bytesToWrite_0 = 2; $ch_0 = $2; break; } if ($2 >>> 0 < 65536) { $result_1 = $result_036; $bytesToWrite_0 = 3; $ch_0 = $2; break; } $cmp15 = $2 >>> 0 < 1114112; $result_1 = $cmp15 ? $result_036 : 3; $bytesToWrite_0 = $cmp15 ? 4 : 3; $ch_0 = $cmp15 ? $2 : 65533; } } while (0); $add_ptr = $target_034 + $bytesToWrite_0 | 0; if ($add_ptr >>> 0 > $targetEnd >>> 0) { $result_2 = 2; $target_0_lcssa = $target_034; $source_0_lcssa = $source_035; break L95; } if (($bytesToWrite_0 | 0) == 4) { $incdec_ptr30 = $target_034 + ($bytesToWrite_0 - 1) | 0; HEAP8[$incdec_ptr30] = ($ch_0 & 63 | 128) & 255; $ch_1 = $ch_0 >>> 6; $target_1 = $incdec_ptr30; label = 82; } else if (($bytesToWrite_0 | 0) == 3) { $ch_1 = $ch_0; $target_1 = $add_ptr; label = 82; } else if (($bytesToWrite_0 | 0) == 2) { $ch_2 = $ch_0; $target_2 = $add_ptr; label = 83; } else if (($bytesToWrite_0 | 0) == 1) { $ch_3 = $ch_0; $target_3 = $add_ptr; label = 84; } else { $target_4 = $add_ptr; } if ((label | 0) == 82) { label = 0; $incdec_ptr35 = $target_1 - 1 | 0; HEAP8[$incdec_ptr35] = ($ch_1 & 63 | 128) & 255; $ch_2 = $ch_1 >>> 6; $target_2 = $incdec_ptr35; label = 83; } if ((label | 0) == 83) { label = 0; $incdec_ptr41 = $target_2 - 1 | 0; HEAP8[$incdec_ptr41] = ($ch_2 & 63 | 128) & 255; $ch_3 = $ch_2 >>> 6; $target_3 = $incdec_ptr41; label = 84; } if ((label | 0) == 84) { label = 0; $incdec_ptr47 = $target_3 - 1 | 0; HEAP8[$incdec_ptr47] = (HEAPU8[11264 + $bytesToWrite_0 | 0] | 0 | $ch_3) & 255; $target_4 = $incdec_ptr47; } $add_ptr49 = $target_4 + $bytesToWrite_0 | 0; if ($incdec_ptr >>> 0 < $sourceEnd >>> 0) { $target_034 = $add_ptr49; $source_035 = $incdec_ptr; $result_036 = $result_1; } else { $result_2 = $result_1; $target_0_lcssa = $add_ptr49; $source_0_lcssa = $incdec_ptr; break; } } } else { $result_2 = 0; $target_0_lcssa = $1; $source_0_lcssa = $0; } } while (0); HEAP32[$sourceStart >> 2] = $source_0_lcssa; HEAP32[$targetStart >> 2] = $target_0_lcssa; return $result_2 | 0; } function __ZNSt8bad_castC2Ev($this) { $this = $this | 0; HEAP32[$this >> 2] = 8080; return; } function __ZNSt10bad_typeidC2Ev($this) { $this = $this | 0; HEAP32[$this >> 2] = 8144; return; } function __ZN10ime_pinyin11Utf16Reader5closeEv($this) { $this = $this | 0; var $fp_ = 0, $0 = 0, $buffer_ = 0, $1 = 0; $fp_ = $this | 0; $0 = HEAP32[$fp_ >> 2] | 0; if (($0 | 0) != 0) { _fclose($0 | 0) | 0; } HEAP32[$fp_ >> 2] = 0; $buffer_ = $this + 4 | 0; $1 = HEAP32[$buffer_ >> 2] | 0; if (($1 | 0) == 0) { HEAP32[$buffer_ >> 2] = 0; return 1; } __ZdaPv($1); HEAP32[$buffer_ >> 2] = 0; return 1; } function _isLegalUTF8Sequence($source, $sourceEnd) { $source = $source | 0; $sourceEnd = $sourceEnd | 0; var $add = 0, $retval_0 = 0; $add = (HEAP8[10984 + (HEAPU8[$source] | 0) | 0] | 0) + 1 | 0; if (($source + $add | 0) >>> 0 > $sourceEnd >>> 0) { $retval_0 = 0; return $retval_0 | 0; } $retval_0 = __ZL11isLegalUTF8PKhi($source, $add) | 0; return $retval_0 | 0; } function _ConvertUTF8toUTF16($sourceStart, $sourceEnd, $targetStart, $targetEnd, $flags) { $sourceStart = $sourceStart | 0; $sourceEnd = $sourceEnd | 0; $targetStart = $targetStart | 0; $targetEnd = $targetEnd | 0; $flags = $flags | 0; var $0 = 0, $1 = 0, $cmp46 = 0, $cmp61 = 0, $target_070 = 0, $source_069 = 0, $idxprom = 0, $conv1 = 0, $source_1 = 0, $ch_0 = 0, $source_2 = 0, $ch_1 = 0, $source_3 = 0, $ch_2 = 0, $source_4 = 0, $ch_3 = 0, $source_5 = 0, $ch_4 = 0, $source_6 = 0, $ch_5 = 0, $sub = 0, $target_0_be = 0, $add_ptr71 = 0, $sub79 = 0, $target_061 = 0, $source_7 = 0, $result_0 = 0, label = 0; $0 = HEAP32[$sourceStart >> 2] | 0; $1 = HEAP32[$targetStart >> 2] | 0; L134 : do { if ($0 >>> 0 < $sourceEnd >>> 0) { $cmp46 = ($flags | 0) == 0; $cmp61 = ($flags | 0) == 0; $source_069 = $0; $target_070 = $1; L136 : while (1) { $idxprom = HEAPU8[$source_069] | 0; $conv1 = HEAP8[10984 + $idxprom | 0] & 65535; if (($source_069 + $conv1 | 0) >>> 0 >= $sourceEnd >>> 0) { $result_0 = 1; $source_7 = $source_069; $target_061 = $target_070; break L134; } if ((__ZL11isLegalUTF8PKhi($source_069, $conv1 + 1 | 0) | 0) << 24 >> 24 == 0) { $result_0 = 3; $source_7 = $source_069; $target_061 = $target_070; break L134; } if (($conv1 | 0) == 5) { $ch_0 = $idxprom << 6; $source_1 = $source_069 + 1 | 0; label = 107; } else if (($conv1 | 0) == 4) { $ch_0 = 0; $source_1 = $source_069; label = 107; } else if (($conv1 | 0) == 3) { $ch_1 = 0; $source_2 = $source_069; label = 108; } else if (($conv1 | 0) == 2) { $ch_2 = 0; $source_3 = $source_069; label = 109; } else if (($conv1 | 0) == 1) { $ch_3 = 0; $source_4 = $source_069; label = 110; } else if (($conv1 | 0) == 0) { $ch_4 = 0; $source_5 = $source_069; label = 111; } else { $ch_5 = 0; $source_6 = $source_069; } if ((label | 0) == 107) { label = 0; $ch_1 = (HEAPU8[$source_1] | 0) + $ch_0 << 6; $source_2 = $source_1 + 1 | 0; label = 108; } if ((label | 0) == 108) { label = 0; $ch_2 = (HEAPU8[$source_2] | 0) + $ch_1 << 6; $source_3 = $source_2 + 1 | 0; label = 109; } if ((label | 0) == 109) { label = 0; $ch_3 = (HEAPU8[$source_3] | 0) + $ch_2 << 6; $source_4 = $source_3 + 1 | 0; label = 110; } if ((label | 0) == 110) { label = 0; $ch_4 = (HEAPU8[$source_4] | 0) + $ch_3 << 6; $source_5 = $source_4 + 1 | 0; label = 111; } if ((label | 0) == 111) { label = 0; $ch_5 = (HEAPU8[$source_5] | 0) + $ch_4 | 0; $source_6 = $source_5 + 1 | 0; } $sub = $ch_5 - (HEAP32[11240 + ($conv1 << 2) >> 2] | 0) | 0; if ($target_070 >>> 0 >= $targetEnd >>> 0) { label = 113; break; } do { if ($sub >>> 0 < 65536) { if (($sub - 55296 | 0) >>> 0 >= 2048) { HEAP16[$target_070 >> 1] = $sub & 65535; $target_0_be = $target_070 + 2 | 0; break; } if ($cmp46) { label = 117; break L136; } HEAP16[$target_070 >> 1] = -3; $target_0_be = $target_070 + 2 | 0; } else { if ($sub >>> 0 > 1114111) { if ($cmp61) { label = 122; break L136; } HEAP16[$target_070 >> 1] = -3; $target_0_be = $target_070 + 2 | 0; break; } else { $add_ptr71 = $target_070 + 2 | 0; if ($add_ptr71 >>> 0 >= $targetEnd >>> 0) { label = 126; break L136; } $sub79 = $sub - 65536 | 0; HEAP16[$target_070 >> 1] = ($sub79 >>> 10) + 55296 & 65535; HEAP16[$add_ptr71 >> 1] = ($sub79 & 1023 | 56320) & 65535; $target_0_be = $target_070 + 4 | 0; break; } } } while (0); if ($source_6 >>> 0 < $sourceEnd >>> 0) { $source_069 = $source_6; $target_070 = $target_0_be; } else { $result_0 = 0; $source_7 = $source_6; $target_061 = $target_0_be; break L134; } } if ((label | 0) == 113) { $result_0 = 2; $source_7 = $source_6 + ~$conv1 | 0; $target_061 = $target_070; break; } else if ((label | 0) == 117) { $result_0 = 3; $source_7 = $source_6 + ~$conv1 | 0; $target_061 = $target_070; break; } else if ((label | 0) == 122) { $result_0 = 3; $source_7 = $source_6 + ~$conv1 | 0; $target_061 = $target_070; break; } else if ((label | 0) == 126) { $result_0 = 2; $source_7 = $source_6 + ~$conv1 | 0; $target_061 = $target_070; break; } } else { $result_0 = 0; $source_7 = $0; $target_061 = $1; } } while (0); HEAP32[$sourceStart >> 2] = $source_7; HEAP32[$targetStart >> 2] = $target_061; return $result_0 | 0; } function _ConvertUTF8toUTF32($sourceStart, $sourceEnd, $targetStart, $targetEnd, $flags) { $sourceStart = $sourceStart | 0; $sourceEnd = $sourceEnd | 0; $targetStart = $targetStart | 0; $targetEnd = $targetEnd | 0; $flags = $flags | 0; var $0 = 0, $1 = 0, $result_0_ph71 = 0, $target_0_ph70 = 0, $source_0_ph69 = 0, $target_053 = 0, $source_052 = 0, $idxprom = 0, $conv1 = 0, $source_1 = 0, $ch_0 = 0, $source_2 = 0, $ch_1 = 0, $source_3 = 0, $ch_2 = 0, $source_4 = 0, $ch_3 = 0, $source_5 = 0, $ch_4 = 0, $source_6 = 0, $ch_5 = 0, $sub = 0, $_not = 0, $target_0_be = 0, $incdec_ptr58 = 0, $target_046 = 0, $source_7 = 0, $result_1 = 0, label = 0; $0 = HEAP32[$sourceStart >> 2] | 0; $1 = HEAP32[$targetStart >> 2] | 0; L174 : do { if ($0 >>> 0 < $sourceEnd >>> 0) { $source_0_ph69 = $0; $target_0_ph70 = $1; $result_0_ph71 = 0; L176 : while (1) { $source_052 = $source_0_ph69; $target_053 = $target_0_ph70; while (1) { $idxprom = HEAPU8[$source_052] | 0; $conv1 = HEAP8[10984 + $idxprom | 0] & 65535; if (($source_052 + $conv1 | 0) >>> 0 >= $sourceEnd >>> 0) { $result_1 = 1; $source_7 = $source_052; $target_046 = $target_053; break L174; } if ((__ZL11isLegalUTF8PKhi($source_052, $conv1 + 1 | 0) | 0) << 24 >> 24 == 0) { $result_1 = 3; $source_7 = $source_052; $target_046 = $target_053; break L174; } if (($conv1 | 0) == 5) { $ch_0 = $idxprom << 6; $source_1 = $source_052 + 1 | 0; label = 136; } else if (($conv1 | 0) == 4) { $ch_0 = 0; $source_1 = $source_052; label = 136; } else if (($conv1 | 0) == 3) { $ch_1 = 0; $source_2 = $source_052; label = 137; } else if (($conv1 | 0) == 2) { $ch_2 = 0; $source_3 = $source_052; label = 138; } else if (($conv1 | 0) == 1) { $ch_3 = 0; $source_4 = $source_052; label = 139; } else if (($conv1 | 0) == 0) { $ch_4 = 0; $source_5 = $source_052; label = 140; } else { $ch_5 = 0; $source_6 = $source_052; } if ((label | 0) == 136) { label = 0; $ch_1 = (HEAPU8[$source_1] | 0) + $ch_0 << 6; $source_2 = $source_1 + 1 | 0; label = 137; } if ((label | 0) == 137) { label = 0; $ch_2 = (HEAPU8[$source_2] | 0) + $ch_1 << 6; $source_3 = $source_2 + 1 | 0; label = 138; } if ((label | 0) == 138) { label = 0; $ch_3 = (HEAPU8[$source_3] | 0) + $ch_2 << 6; $source_4 = $source_3 + 1 | 0; label = 139; } if ((label | 0) == 139) { label = 0; $ch_4 = (HEAPU8[$source_4] | 0) + $ch_3 << 6; $source_5 = $source_4 + 1 | 0; label = 140; } if ((label | 0) == 140) { label = 0; $ch_5 = (HEAPU8[$source_5] | 0) + $ch_4 | 0; $source_6 = $source_5 + 1 | 0; } $sub = $ch_5 - (HEAP32[11240 + ($conv1 << 2) >> 2] | 0) | 0; if ($target_053 >>> 0 >= $targetEnd >>> 0) { label = 142; break L176; } if ($sub >>> 0 >= 1114112) { break; } $_not = ($sub - 55296 | 0) >>> 0 > 2047; if (!($_not | ($flags | 0) != 0)) { label = 145; break L176; } $target_0_be = $target_053 + 4 | 0; HEAP32[$target_053 >> 2] = $_not ? $sub : 65533; if ($source_6 >>> 0 < $sourceEnd >>> 0) { $source_052 = $source_6; $target_053 = $target_0_be; } else { $result_1 = $result_0_ph71; $source_7 = $source_6; $target_046 = $target_0_be; break L174; } } $incdec_ptr58 = $target_053 + 4 | 0; HEAP32[$target_053 >> 2] = 65533; if ($source_6 >>> 0 < $sourceEnd >>> 0) { $source_0_ph69 = $source_6; $target_0_ph70 = $incdec_ptr58; $result_0_ph71 = 3; } else { $result_1 = 3; $source_7 = $source_6; $target_046 = $incdec_ptr58; break L174; } } if ((label | 0) == 142) { $result_1 = 2; $source_7 = $source_6 + ~$conv1 | 0; $target_046 = $target_053; break; } else if ((label | 0) == 145) { $result_1 = 3; $source_7 = $source_6 + ~$conv1 | 0; $target_046 = $target_053; break; } } else { $result_1 = 0; $source_7 = $0; $target_046 = $1; } } while (0); HEAP32[$sourceStart >> 2] = $source_7; HEAP32[$targetStart >> 2] = $target_046; return $result_1 | 0; } function __ZNSt9type_infoD0Ev($this) { $this = $this | 0; __ZdlPv($this); return; } function __ZNSt8bad_castD0Ev($this) { $this = $this | 0; __ZdlPv($this); return; } function __ZNSt10bad_typeidD0Ev($this) { $this = $this | 0; __ZdlPv($this); return; } function __ZN10__cxxabiv116__shim_type_infoD0Ev($this) { $this = $this | 0; __ZNSt9type_infoD2Ev($this | 0); __ZdlPv($this); return; } function __ZN10__cxxabiv116__shim_type_infoD2Ev($this) { $this = $this | 0; __ZNSt9type_infoD2Ev($this | 0); return; } function __ZN10__cxxabiv123__fundamental_type_infoD0Ev($this) { $this = $this | 0; __ZNSt9type_infoD2Ev($this | 0); __ZdlPv($this); return; } function __ZN10__cxxabiv117__array_type_infoD0Ev($this) { $this = $this | 0; __ZNSt9type_infoD2Ev($this | 0); __ZdlPv($this); return; } function __ZN10__cxxabiv120__function_type_infoD0Ev($this) { $this = $this | 0; __ZNSt9type_infoD2Ev($this | 0); __ZdlPv($this); return; } function __ZN10__cxxabiv116__enum_type_infoD0Ev($this) { $this = $this | 0; __ZNSt9type_infoD2Ev($this | 0); __ZdlPv($this); return; } function __ZNK10__cxxabiv117__array_type_info9can_catchEPKNS_16__shim_type_infoERPv($this, $0, $1) { $this = $this | 0; $0 = $0 | 0; $1 = $1 | 0; return 0; } function __ZNK10__cxxabiv120__function_type_info9can_catchEPKNS_16__shim_type_infoERPv($this, $0, $1) { $this = $this | 0; $0 = $0 | 0; $1 = $1 | 0; return 0; } function __ZNK10__cxxabiv123__fundamental_type_info9can_catchEPKNS_16__shim_type_infoERPv($this, $thrown_type, $0) { $this = $this | 0; $thrown_type = $thrown_type | 0; $0 = $0 | 0; return ($this | 0) == ($thrown_type | 0) | 0; } function __ZNK10__cxxabiv116__enum_type_info9can_catchEPKNS_16__shim_type_infoERPv($this, $thrown_type, $0) { $this = $this | 0; $thrown_type = $thrown_type | 0; $0 = $0 | 0; return ($this | 0) == ($thrown_type | 0) | 0; } function __ZNK10__cxxabiv117__class_type_info24process_found_base_classEPNS_19__dynamic_cast_infoEPvi($this, $info, $adjustedPtr, $path_below) { $this = $this | 0; $info = $info | 0; $adjustedPtr = $adjustedPtr | 0; $path_below = $path_below | 0; var $dst_ptr_leading_to_static_ptr = 0, $0 = 0, $path_dst_ptr_to_static_ptr6 = 0, $number_to_static_ptr11 = 0; $dst_ptr_leading_to_static_ptr = $info + 16 | 0; $0 = HEAP32[$dst_ptr_leading_to_static_ptr >> 2] | 0; if (($0 | 0) == 0) { HEAP32[$dst_ptr_leading_to_static_ptr >> 2] = $adjustedPtr; HEAP32[$info + 24 >> 2] = $path_below; HEAP32[$info + 36 >> 2] = 1; return; } if (($0 | 0) != ($adjustedPtr | 0)) { $number_to_static_ptr11 = $info + 36 | 0; HEAP32[$number_to_static_ptr11 >> 2] = (HEAP32[$number_to_static_ptr11 >> 2] | 0) + 1; HEAP32[$info + 24 >> 2] = 2; HEAP8[$info + 54 | 0] = 1; return; } $path_dst_ptr_to_static_ptr6 = $info + 24 | 0; if ((HEAP32[$path_dst_ptr_to_static_ptr6 >> 2] | 0) != 2) { return; } HEAP32[$path_dst_ptr_to_static_ptr6 >> 2] = $path_below; return; } function __ZNK10__cxxabiv117__class_type_info27has_unambiguous_public_baseEPNS_19__dynamic_cast_infoEPvi($this, $info, $adjustedPtr, $path_below) { $this = $this | 0; $info = $info | 0; $adjustedPtr = $adjustedPtr | 0; $path_below = $path_below | 0; var $dst_ptr_leading_to_static_ptr_i = 0, $1 = 0, $path_dst_ptr_to_static_ptr6_i = 0, $number_to_static_ptr11_i = 0; if ((HEAP32[$info + 8 >> 2] | 0) != ($this | 0)) { return; } $dst_ptr_leading_to_static_ptr_i = $info + 16 | 0; $1 = HEAP32[$dst_ptr_leading_to_static_ptr_i >> 2] | 0; if (($1 | 0) == 0) { HEAP32[$dst_ptr_leading_to_static_ptr_i >> 2] = $adjustedPtr; HEAP32[$info + 24 >> 2] = $path_below; HEAP32[$info + 36 >> 2] = 1; return; } if (($1 | 0) != ($adjustedPtr | 0)) { $number_to_static_ptr11_i = $info + 36 | 0; HEAP32[$number_to_static_ptr11_i >> 2] = (HEAP32[$number_to_static_ptr11_i >> 2] | 0) + 1; HEAP32[$info + 24 >> 2] = 2; HEAP8[$info + 54 | 0] = 1; return; } $path_dst_ptr_to_static_ptr6_i = $info + 24 | 0; if ((HEAP32[$path_dst_ptr_to_static_ptr6_i >> 2] | 0) != 2) { return; } HEAP32[$path_dst_ptr_to_static_ptr6_i >> 2] = $path_below; return; } function __ZNK10__cxxabiv117__pbase_type_info9can_catchEPKNS_16__shim_type_infoERPv($this, $thrown_type, $0) { $this = $this | 0; $thrown_type = $thrown_type | 0; $0 = $0 | 0; var $2 = 0; $2 = $thrown_type | 0; return ($this | 0) == ($2 | 0) | ($2 | 0) == 10880 | 0; } function __ZNK10__cxxabiv117__class_type_info29process_static_type_above_dstEPNS_19__dynamic_cast_infoEPKvS4_i($this, $info, $dst_ptr, $current_ptr, $path_below) { $this = $this | 0; $info = $info | 0; $dst_ptr = $dst_ptr | 0; $current_ptr = $current_ptr | 0; $path_below = $path_below | 0; var $dst_ptr_leading_to_static_ptr = 0, $1 = 0, $path_dst_ptr_to_static_ptr12 = 0, $3 = 0, $4 = 0, $number_to_static_ptr26 = 0; HEAP8[$info + 53 | 0] = 1; if ((HEAP32[$info + 4 >> 2] | 0) != ($current_ptr | 0)) { return; } HEAP8[$info + 52 | 0] = 1; $dst_ptr_leading_to_static_ptr = $info + 16 | 0; $1 = HEAP32[$dst_ptr_leading_to_static_ptr >> 2] | 0; if (($1 | 0) == 0) { HEAP32[$dst_ptr_leading_to_static_ptr >> 2] = $dst_ptr; HEAP32[$info + 24 >> 2] = $path_below; HEAP32[$info + 36 >> 2] = 1; if (!((HEAP32[$info + 48 >> 2] | 0) == 1 & ($path_below | 0) == 1)) { return; } HEAP8[$info + 54 | 0] = 1; return; } if (($1 | 0) != ($dst_ptr | 0)) { $number_to_static_ptr26 = $info + 36 | 0; HEAP32[$number_to_static_ptr26 >> 2] = (HEAP32[$number_to_static_ptr26 >> 2] | 0) + 1; HEAP8[$info + 54 | 0] = 1; return; } $path_dst_ptr_to_static_ptr12 = $info + 24 | 0; $3 = HEAP32[$path_dst_ptr_to_static_ptr12 >> 2] | 0; if (($3 | 0) == 2) { HEAP32[$path_dst_ptr_to_static_ptr12 >> 2] = $path_below; $4 = $path_below; } else { $4 = $3; } if (!((HEAP32[$info + 48 >> 2] | 0) == 1 & ($4 | 0) == 1)) { return; } HEAP8[$info + 54 | 0] = 1; return; } function __ZNK10__cxxabiv117__class_type_info29process_static_type_below_dstEPNS_19__dynamic_cast_infoEPKvi($this, $info, $current_ptr, $path_below) { $this = $this | 0; $info = $info | 0; $current_ptr = $current_ptr | 0; $path_below = $path_below | 0; var $path_dynamic_ptr_to_static_ptr = 0; if ((HEAP32[$info + 4 >> 2] | 0) != ($current_ptr | 0)) { return; } $path_dynamic_ptr_to_static_ptr = $info + 28 | 0; if ((HEAP32[$path_dynamic_ptr_to_static_ptr >> 2] | 0) == 1) { return; } HEAP32[$path_dynamic_ptr_to_static_ptr >> 2] = $path_below; return; } function __ZN10__cxxabiv117__class_type_infoD0Ev($this) { $this = $this | 0; __ZNSt9type_infoD2Ev($this | 0); __ZdlPv($this); return; } function __ZN10__cxxabiv120__si_class_type_infoD0Ev($this) { $this = $this | 0; __ZNSt9type_infoD2Ev($this | 0); __ZdlPv($this); return; } function __ZN10__cxxabiv121__vmi_class_type_infoD0Ev($this) { $this = $this | 0; __ZNSt9type_infoD2Ev($this | 0); __ZdlPv($this); return; } function __ZN10__cxxabiv117__pbase_type_infoD0Ev($this) { $this = $this | 0; __ZNSt9type_infoD2Ev($this | 0); __ZdlPv($this); return; } function __ZN10__cxxabiv119__pointer_type_infoD0Ev($this) { $this = $this | 0; __ZNSt9type_infoD2Ev($this | 0); __ZdlPv($this); return; } function
($this) { $this = $this | 0; __ZNSt9type_infoD2Ev($this | 0); __ZdlPv($this); return; } function __ZNK10__cxxabiv117__class_type_info9can_catchEPKNS_16__shim_type_infoERPv($this, $thrown_type, $adjustedPtr) { $this = $this | 0; $thrown_type = $thrown_type | 0; $adjustedPtr = $adjustedPtr | 0; var $info = 0, $4 = 0, $5 = 0, $retval_0 = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 56 | 0; $info = sp | 0; if (($this | 0) == ($thrown_type | 0)) { $retval_0 = 1; STACKTOP = sp; return $retval_0 | 0; } if (($thrown_type | 0) == 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } $4 = ___dynamic_cast($thrown_type, 10840, 10808, -1) | 0; $5 = $4; if (($4 | 0) == 0) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } _memset($info | 0, 0, 56); HEAP32[$info >> 2] = $5; HEAP32[$info + 8 >> 2] = $this; HEAP32[$info + 12 >> 2] = -1; HEAP32[$info + 48 >> 2] = 1; FUNCTION_TABLE_viiii[HEAP32[(HEAP32[$4 >> 2] | 0) + 28 >> 2] & 7]($5, $info, HEAP32[$adjustedPtr >> 2] | 0, 1); if ((HEAP32[$info + 24 >> 2] | 0) != 1) { $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } HEAP32[$adjustedPtr >> 2] = HEAP32[$info + 16 >> 2]; $retval_0 = 1; STACKTOP = sp; return $retval_0 | 0; } function __ZNK10__cxxabiv120__si_class_type_info27has_unambiguous_public_baseEPNS_19__dynamic_cast_infoEPvi($this, $info, $adjustedPtr, $path_below) { $this = $this | 0; $info = $info | 0; $adjustedPtr = $adjustedPtr | 0; $path_below = $path_below | 0; var $dst_ptr_leading_to_static_ptr_i = 0, $3 = 0, $path_dst_ptr_to_static_ptr6_i = 0, $number_to_static_ptr11_i = 0, $6 = 0; if (($this | 0) != (HEAP32[$info + 8 >> 2] | 0)) { $6 = HEAP32[$this + 8 >> 2] | 0; FUNCTION_TABLE_viiii[HEAP32[(HEAP32[$6 >> 2] | 0) + 28 >> 2] & 7]($6, $info, $adjustedPtr, $path_below); return; } $dst_ptr_leading_to_static_ptr_i = $info + 16 | 0; $3 = HEAP32[$dst_ptr_leading_to_static_ptr_i >> 2] | 0; if (($3 | 0) == 0) { HEAP32[$dst_ptr_leading_to_static_ptr_i >> 2] = $adjustedPtr; HEAP32[$info + 24 >> 2] = $path_below; HEAP32[$info + 36 >> 2] = 1; return; } if (($3 | 0) != ($adjustedPtr | 0)) { $number_to_static_ptr11_i = $info + 36 | 0; HEAP32[$number_to_static_ptr11_i >> 2] = (HEAP32[$number_to_static_ptr11_i >> 2] | 0) + 1; HEAP32[$info + 24 >> 2] = 2; HEAP8[$info + 54 | 0] = 1; return; } $path_dst_ptr_to_static_ptr6_i = $info + 24 | 0; if ((HEAP32[$path_dst_ptr_to_static_ptr6_i >> 2] | 0) != 2) { return; } HEAP32[$path_dst_ptr_to_static_ptr6_i >> 2] = $path_below; return; } function __ZNK10__cxxabiv122__base_class_type_info27has_unambiguous_public_baseEPNS_19__dynamic_cast_infoEPvi($this, $info, $adjustedPtr, $path_below) { $this = $this | 0; $info = $info | 0; $adjustedPtr = $adjustedPtr | 0; $path_below = $path_below | 0; var $0 = 0, $shr = 0, $offset_to_base_0 = 0, $5 = 0; $0 = HEAP32[$this + 4 >> 2] | 0; $shr = $0 >> 8; if (($0 & 1 | 0) == 0) { $offset_to_base_0 = $shr; } else { $offset_to_base_0 = HEAP32[(HEAP32[$adjustedPtr >> 2] | 0) + $shr >> 2] | 0; } $5 = HEAP32[$this >> 2] | 0; FUNCTION_TABLE_viiii[HEAP32[(HEAP32[$5 >> 2] | 0) + 28 >> 2] & 7]($5, $info, $adjustedPtr + $offset_to_base_0 | 0, ($0 & 2 | 0) != 0 ? $path_below : 2); return; } function __ZNK10__cxxabiv121__vmi_class_type_info27has_unambiguous_public_baseEPNS_19__dynamic_cast_infoEPvi($this, $info, $adjustedPtr, $path_below) { $this = $this | 0; $info = $info | 0; $adjustedPtr = $adjustedPtr | 0; $path_below = $path_below | 0; var $dst_ptr_leading_to_static_ptr_i = 0, $3 = 0, $path_dst_ptr_to_static_ptr6_i = 0, $number_to_static_ptr11_i = 0, $6 = 0, $add_ptr = 0, $7 = 0, $shr_i16 = 0, $offset_to_base_0_i21 = 0, $12 = 0, $search_done = 0, $15 = 0, $p_0 = 0, $16 = 0, $shr_i = 0, $offset_to_base_0_i = 0, $20 = 0, $incdec_ptr6 = 0, label = 0; if (($this | 0) == (HEAP32[$info + 8 >> 2] | 0)) { $dst_ptr_leading_to_static_ptr_i = $info + 16 | 0; $3 = HEAP32[$dst_ptr_leading_to_static_ptr_i >> 2] | 0; if (($3 | 0) == 0) { HEAP32[$dst_ptr_leading_to_static_ptr_i >> 2] = $adjustedPtr; HEAP32[$info + 24 >> 2] = $path_below; HEAP32[$info + 36 >> 2] = 1; return; } if (($3 | 0) != ($adjustedPtr | 0)) { $number_to_static_ptr11_i = $info + 36 | 0; HEAP32[$number_to_static_ptr11_i >> 2] = (HEAP32[$number_to_static_ptr11_i >> 2] | 0) + 1; HEAP32[$info + 24 >> 2] = 2; HEAP8[$info + 54 | 0] = 1; return; } $path_dst_ptr_to_static_ptr6_i = $info + 24 | 0; if ((HEAP32[$path_dst_ptr_to_static_ptr6_i >> 2] | 0) != 2) { return; } HEAP32[$path_dst_ptr_to_static_ptr6_i >> 2] = $path_below; return; } $6 = HEAP32[$this + 12 >> 2] | 0; $add_ptr = $this + 16 + ($6 << 3) | 0; $7 = HEAP32[$this + 20 >> 2] | 0; $shr_i16 = $7 >> 8; if (($7 & 1 | 0) == 0) { $offset_to_base_0_i21 = $shr_i16; } else { $offset_to_base_0_i21 = HEAP32[(HEAP32[$adjustedPtr >> 2] | 0) + $shr_i16 >> 2] | 0; } $12 = HEAP32[$this + 16 >> 2] | 0; FUNCTION_TABLE_viiii[HEAP32[(HEAP32[$12 >> 2] | 0) + 28 >> 2] & 7]($12, $info, $adjustedPtr + $offset_to_base_0_i21 | 0, ($7 & 2 | 0) != 0 ? $path_below : 2); if (($6 | 0) <= 1) { return; } $search_done = $info + 54 | 0; $15 = $adjustedPtr; $p_0 = $this + 24 | 0; while (1) { $16 = HEAP32[$p_0 + 4 >> 2] | 0; $shr_i = $16 >> 8; if (($16 & 1 | 0) == 0) { $offset_to_base_0_i = $shr_i; } else { $offset_to_base_0_i = HEAP32[(HEAP32[$15 >> 2] | 0) + $shr_i >> 2] | 0; } $20 = HEAP32[$p_0 >> 2] | 0; FUNCTION_TABLE_viiii[HEAP32[(HEAP32[$20 >> 2] | 0) + 28 >> 2] & 7]($20, $info, $adjustedPtr + $offset_to_base_0_i | 0, ($16 & 2 | 0) != 0 ? $path_below : 2); if ((HEAP8[$search_done] & 1) != 0) { label = 266; break; } $incdec_ptr6 = $p_0 + 8 | 0; if ($incdec_ptr6 >>> 0 < $add_ptr >>> 0) { $p_0 = $incdec_ptr6; } else { label = 267; break; } } if ((label | 0) == 266) { return; } else if ((label | 0) == 267) { return; } } function __ZNK10__cxxabiv119__pointer_type_info9can_catchEPKNS_16__shim_type_infoERPv($this, $thrown_type, $adjustedPtr) { $this = $this | 0; $thrown_type = $thrown_type | 0; $adjustedPtr = $adjustedPtr | 0; var $info = 0, $4 = 0, $7 = 0, $11 = 0, $13 = 0, $17 = 0, $19 = 0, $22 = 0, $23 = 0, $retval_0 = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 56 | 0; $info = sp | 0; HEAP32[$adjustedPtr >> 2] = HEAP32[HEAP32[$adjustedPtr >> 2] >> 2]; $4 = $thrown_type | 0; do { if (($this | 0) == ($4 | 0) | ($4 | 0) == 10880) { $retval_0 = 1; } else { if (($thrown_type | 0) == 0) { $retval_0 = 0; break; } $7 = ___dynamic_cast($thrown_type, 10840, 10776, -1) | 0; if (($7 | 0) == 0) { $retval_0 = 0; break; } if ((HEAP32[$7 + 8 >> 2] & ~HEAP32[$this + 8 >> 2] | 0) != 0) { $retval_0 = 0; break; } $11 = HEAP32[$this + 12 >> 2] | 0; $13 = $7 + 12 | 0; if (($11 | 0) == (HEAP32[$13 >> 2] | 0) | ($11 | 0) == 9912) { $retval_0 = 1; break; } if (($11 | 0) == 0) { $retval_0 = 0; break; } $17 = ___dynamic_cast($11, 10840, 10808, -1) | 0; if (($17 | 0) == 0) { $retval_0 = 0; break; } $19 = HEAP32[$13 >> 2] | 0; if (($19 | 0) == 0) { $retval_0 = 0; break; } $22 = ___dynamic_cast($19, 10840, 10808, -1) | 0; $23 = $22; if (($22 | 0) == 0) { $retval_0 = 0; break; } _memset($info | 0, 0, 56); HEAP32[$info >> 2] = $23; HEAP32[$info + 8 >> 2] = $17; HEAP32[$info + 12 >> 2] = -1; HEAP32[$info + 48 >> 2] = 1; FUNCTION_TABLE_viiii[HEAP32[(HEAP32[$22 >> 2] | 0) + 28 >> 2] & 7]($23, $info, HEAP32[$adjustedPtr >> 2] | 0, 1); if ((HEAP32[$info + 24 >> 2] | 0) != 1) { $retval_0 = 0; break; } HEAP32[$adjustedPtr >> 2] = HEAP32[$info + 16 >> 2]; $retval_0 = 1; } } while (0); STACKTOP = sp; return $retval_0 | 0; } function ___dynamic_cast($static_ptr, $static_type, $dst_type, $src2dst_offset) { $static_ptr = $static_ptr | 0; $static_type = $static_type | 0; $dst_type = $dst_type | 0; $src2dst_offset = $src2dst_offset | 0; var $info = 0, $1 = 0, $add_ptr = 0, $4 = 0, $5 = 0, $dst_ptr_leading_to_static_ptr = 0, $dst_ptr_not_leading_to_static_ptr = 0, $path_dst_ptr_to_static_ptr = 0, $path_dynamic_ptr_to_static_ptr = 0, $path_dynamic_ptr_to_dst_ptr = 0, $number_to_dst_ptr = 0, $14 = 0, $dst_ptr_0 = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 56 | 0; $info = sp | 0; $1 = HEAP32[$static_ptr >> 2] | 0; $add_ptr = $static_ptr + (HEAP32[$1 - 8 >> 2] | 0) | 0; $4 = HEAP32[$1 - 4 >> 2] | 0; $5 = $4; HEAP32[$info >> 2] = $dst_type; HEAP32[$info + 4 >> 2] = $static_ptr; HEAP32[$info + 8 >> 2] = $static_type; HEAP32[$info + 12 >> 2] = $src2dst_offset; $dst_ptr_leading_to_static_ptr = $info + 16 | 0; $dst_ptr_not_leading_to_static_ptr = $info + 20 | 0; $path_dst_ptr_to_static_ptr = $info + 24 | 0; $path_dynamic_ptr_to_static_ptr = $info + 28 | 0; $path_dynamic_ptr_to_dst_ptr = $info + 32 | 0; $number_to_dst_ptr = $info + 40 | 0; _memset($dst_ptr_leading_to_static_ptr | 0, 0, 39); if (($4 | 0) == ($dst_type | 0)) { HEAP32[$info + 48 >> 2] = 1; FUNCTION_TABLE_viiiiii[HEAP32[(HEAP32[$4 >> 2] | 0) + 20 >> 2] & 7]($5, $info, $add_ptr, $add_ptr, 1, 0); STACKTOP = sp; return ((HEAP32[$path_dst_ptr_to_static_ptr >> 2] | 0) == 1 ? $add_ptr : 0) | 0; } FUNCTION_TABLE_viiiii[HEAP32[(HEAP32[$4 >> 2] | 0) + 24 >> 2] & 7]($5, $info, $add_ptr, 1, 0); $14 = HEAP32[$info + 36 >> 2] | 0; if (($14 | 0) == 0) { if ((HEAP32[$number_to_dst_ptr >> 2] | 0) != 1) { $dst_ptr_0 = 0; STACKTOP = sp; return $dst_ptr_0 | 0; } if ((HEAP32[$path_dynamic_ptr_to_static_ptr >> 2] | 0) != 1) { $dst_ptr_0 = 0; STACKTOP = sp; return $dst_ptr_0 | 0; } $dst_ptr_0 = (HEAP32[$path_dynamic_ptr_to_dst_ptr >> 2] | 0) == 1 ? HEAP32[$dst_ptr_not_leading_to_static_ptr >> 2] | 0 : 0; STACKTOP = sp; return $dst_ptr_0 | 0; } else if (($14 | 0) == 1) { do { if ((HEAP32[$path_dst_ptr_to_static_ptr >> 2] | 0) != 1) { if ((HEAP32[$number_to_dst_ptr >> 2] | 0) != 0) { $dst_ptr_0 = 0; STACKTOP = sp; return $dst_ptr_0 | 0; } if ((HEAP32[$path_dynamic_ptr_to_static_ptr >> 2] | 0) != 1) { $dst_ptr_0 = 0; STACKTOP = sp; return $dst_ptr_0 | 0; } if ((HEAP32[$path_dynamic_ptr_to_dst_ptr >> 2] | 0) == 1) { break; } else { $dst_ptr_0 = 0; } STACKTOP = sp; return $dst_ptr_0 | 0; } } while (0); $dst_ptr_0 = HEAP32[$dst_ptr_leading_to_static_ptr >> 2] | 0; STACKTOP = sp; return $dst_ptr_0 | 0; } else { $dst_ptr_0 = 0; STACKTOP = sp; return $dst_ptr_0 | 0; } return 0; } function __ZNK10__cxxabiv117__class_type_info16search_below_dstEPNS_19__dynamic_cast_infoEPKvib($this, $info, $current_ptr, $path_below, $use_strcmp) { $this = $this | 0; $info = $info | 0; $current_ptr = $current_ptr | 0; $path_below = $path_below | 0; $use_strcmp = $use_strcmp | 0; var $path_dynamic_ptr_to_static_ptr_i = 0, $dst_ptr_not_leading_to_static_ptr = 0, $number_to_dst_ptr = 0; if ((HEAP32[$info + 8 >> 2] | 0) == ($this | 0)) { if ((HEAP32[$info + 4 >> 2] | 0) != ($current_ptr | 0)) { return; } $path_dynamic_ptr_to_static_ptr_i = $info + 28 | 0; if ((HEAP32[$path_dynamic_ptr_to_static_ptr_i >> 2] | 0) == 1) { return; } HEAP32[$path_dynamic_ptr_to_static_ptr_i >> 2] = $path_below; return; } if ((HEAP32[$info >> 2] | 0) != ($this | 0)) { return; } do { if ((HEAP32[$info + 16 >> 2] | 0) != ($current_ptr | 0)) { $dst_ptr_not_leading_to_static_ptr = $info + 20 | 0; if ((HEAP32[$dst_ptr_not_leading_to_static_ptr >> 2] | 0) == ($current_ptr | 0)) { break; } HEAP32[$info + 32 >> 2] = $path_below; HEAP32[$dst_ptr_not_leading_to_static_ptr >> 2] = $current_ptr; $number_to_dst_ptr = $info + 40 | 0; HEAP32[$number_to_dst_ptr >> 2] = (HEAP32[$number_to_dst_ptr >> 2] | 0) + 1; do { if ((HEAP32[$info + 36 >> 2] | 0) == 1) { if ((HEAP32[$info + 24 >> 2] | 0) != 2) { break; } HEAP8[$info + 54 | 0] = 1; } } while (0); HEAP32[$info + 44 >> 2] = 4; return; } } while (0); if (($path_below | 0) != 1) { return; } HEAP32[$info + 32 >> 2] = 1; return; } function __ZNK10__cxxabiv121__vmi_class_type_info16search_below_dstEPNS_19__dynamic_cast_infoEPKvib($this, $info, $current_ptr, $path_below, $use_strcmp) { $this = $this | 0; $info = $info | 0; $current_ptr = $current_ptr | 0; $path_below = $path_below | 0; $use_strcmp = $use_strcmp | 0; var $0 = 0, $path_dynamic_ptr_to_static_ptr_i = 0, $dst_ptr_not_leading_to_static_ptr = 0, $is_dst_type_derived_from_static_type = 0, $10 = 0, $add_ptr = 0, $found_our_static_ptr = 0, $found_any_static_type = 0, $search_done = 0, $__flags34 = 0, $path_dst_ptr_to_static_ptr = 0, $11 = 0, $is_dst_type_derived_from_static_type13_0_off0140 = 0, $p_0139 = 0, $does_dst_type_point_to_our_static_type_0_off0138 = 0, $12 = 0, $shr_i107 = 0, $offset_to_base_0_i112 = 0, $16 = 0, $does_dst_type_point_to_our_static_type_1_off0 = 0, $is_dst_type_derived_from_static_type13_1_off0 = 0, $incdec_ptr = 0, $does_dst_type_point_to_our_static_type_0_off0_lcssa = 0, $is_dst_type_derived_from_static_type13_2_off0 = 0, $is_dst_type_derived_from_static_type13_2_off0146 = 0, $number_to_dst_ptr = 0, $is_dst_type_derived_from_static_type13_2_off0147 = 0, $33 = 0, $add_ptr64 = 0, $34 = 0, $shr_i121 = 0, $offset_to_base_0_i126 = 0, $39 = 0, $incdec_ptr69 = 0, $42 = 0, $number_to_static_ptr76 = 0, $search_done79 = 0, $44 = 0, $p65_0 = 0, $47 = 0, $shr_i92 = 0, $offset_to_base_0_i97 = 0, $51 = 0, $incdec_ptr84 = 0, $path_dst_ptr_to_static_ptr99 = 0, $search_done92 = 0, $54 = 0, $search_done110 = 0, $55 = 0, $p65_1 = 0, $60 = 0, $shr_i76 = 0, $offset_to_base_0_i81 = 0, $64 = 0, $incdec_ptr105 = 0, $p65_2 = 0, $70 = 0, $shr_i = 0, $offset_to_base_0_i = 0, $74 = 0, $incdec_ptr120 = 0, label = 0; $0 = $this | 0; if (($0 | 0) == (HEAP32[$info + 8 >> 2] | 0)) { if ((HEAP32[$info + 4 >> 2] | 0) != ($current_ptr | 0)) { return; } $path_dynamic_ptr_to_static_ptr_i = $info + 28 | 0; if ((HEAP32[$path_dynamic_ptr_to_static_ptr_i >> 2] | 0) == 1) { return; } HEAP32[$path_dynamic_ptr_to_static_ptr_i >> 2] = $path_below; return; } if (($0 | 0) == (HEAP32[$info >> 2] | 0)) { do { if ((HEAP32[$info + 16 >> 2] | 0) != ($current_ptr | 0)) { $dst_ptr_not_leading_to_static_ptr = $info + 20 | 0; if ((HEAP32[$dst_ptr_not_leading_to_static_ptr >> 2] | 0) == ($current_ptr | 0)) { break; } HEAP32[$info + 32 >> 2] = $path_below; $is_dst_type_derived_from_static_type = $info + 44 | 0; if ((HEAP32[$is_dst_type_derived_from_static_type >> 2] | 0) == 4) { return; } $10 = HEAP32[$this + 12 >> 2] | 0; $add_ptr = $this + 16 + ($10 << 3) | 0; L433 : do { if (($10 | 0) > 0) { $found_our_static_ptr = $info + 52 | 0; $found_any_static_type = $info + 53 | 0; $search_done = $info + 54 | 0; $__flags34 = $this + 8 | 0; $path_dst_ptr_to_static_ptr = $info + 24 | 0; $11 = $current_ptr; $does_dst_type_point_to_our_static_type_0_off0138 = 0; $p_0139 = $this + 16 | 0; $is_dst_type_derived_from_static_type13_0_off0140 = 0; L435 : while (1) { HEAP8[$found_our_static_ptr] = 0; HEAP8[$found_any_static_type] = 0; $12 = HEAP32[$p_0139 + 4 >> 2] | 0; $shr_i107 = $12 >> 8; if (($12 & 1 | 0) == 0) { $offset_to_base_0_i112 = $shr_i107; } else { $offset_to_base_0_i112 = HEAP32[(HEAP32[$11 >> 2] | 0) + $shr_i107 >> 2] | 0; } $16 = HEAP32[$p_0139 >> 2] | 0; FUNCTION_TABLE_viiiiii[HEAP32[(HEAP32[$16 >> 2] | 0) + 20 >> 2] & 7]($16, $info, $current_ptr, $current_ptr + $offset_to_base_0_i112 | 0, 2 - ($12 >>> 1 & 1) | 0, $use_strcmp); if ((HEAP8[$search_done] & 1) != 0) { $is_dst_type_derived_from_static_type13_2_off0 = $is_dst_type_derived_from_static_type13_0_off0140; $does_dst_type_point_to_our_static_type_0_off0_lcssa = $does_dst_type_point_to_our_static_type_0_off0138; break; } do { if ((HEAP8[$found_any_static_type] & 1) == 0) { $is_dst_type_derived_from_static_type13_1_off0 = $is_dst_type_derived_from_static_type13_0_off0140; $does_dst_type_point_to_our_static_type_1_off0 = $does_dst_type_point_to_our_static_type_0_off0138; } else { if ((HEAP8[$found_our_static_ptr] & 1) == 0) { if ((HEAP32[$__flags34 >> 2] & 1 | 0) == 0) { $is_dst_type_derived_from_static_type13_2_off0 = 1; $does_dst_type_point_to_our_static_type_0_off0_lcssa = $does_dst_type_point_to_our_static_type_0_off0138; break L435; } else { $is_dst_type_derived_from_static_type13_1_off0 = 1; $does_dst_type_point_to_our_static_type_1_off0 = $does_dst_type_point_to_our_static_type_0_off0138; break; } } if ((HEAP32[$path_dst_ptr_to_static_ptr >> 2] | 0) == 1) { label = 347; break L433; } if ((HEAP32[$__flags34 >> 2] & 2 | 0) == 0) { label = 347; break L433; } else { $is_dst_type_derived_from_static_type13_1_off0 = 1; $does_dst_type_point_to_our_static_type_1_off0 = 1; } } } while (0); $incdec_ptr = $p_0139 + 8 | 0; if ($incdec_ptr >>> 0 < $add_ptr >>> 0) { $does_dst_type_point_to_our_static_type_0_off0138 = $does_dst_type_point_to_our_static_type_1_off0; $p_0139 = $incdec_ptr; $is_dst_type_derived_from_static_type13_0_off0140 = $is_dst_type_derived_from_static_type13_1_off0; } else { $is_dst_type_derived_from_static_type13_2_off0 = $is_dst_type_derived_from_static_type13_1_off0; $does_dst_type_point_to_our_static_type_0_off0_lcssa = $does_dst_type_point_to_our_static_type_1_off0; break; } } if ($does_dst_type_point_to_our_static_type_0_off0_lcssa) { $is_dst_type_derived_from_static_type13_2_off0147 = $is_dst_type_derived_from_static_type13_2_off0; label = 346; } else { $is_dst_type_derived_from_static_type13_2_off0146 = $is_dst_type_derived_from_static_type13_2_off0; label = 343; } } else { $is_dst_type_derived_from_static_type13_2_off0146 = 0; label = 343; } } while (0); do { if ((label | 0) == 343) { HEAP32[$dst_ptr_not_leading_to_static_ptr >> 2] = $current_ptr; $number_to_dst_ptr = $info + 40 | 0; HEAP32[$number_to_dst_ptr >> 2] = (HEAP32[$number_to_dst_ptr >> 2] | 0) + 1; if ((HEAP32[$info + 36 >> 2] | 0) != 1) { $is_dst_type_derived_from_static_type13_2_off0147 = $is_dst_type_derived_from_static_type13_2_off0146; label = 346; break; } if ((HEAP32[$info + 24 >> 2] | 0) != 2) { $is_dst_type_derived_from_static_type13_2_off0147 = $is_dst_type_derived_from_static_type13_2_off0146; label = 346; break; } HEAP8[$info + 54 | 0] = 1; if ($is_dst_type_derived_from_static_type13_2_off0146) { label = 347; } else { label = 348; } } } while (0); if ((label | 0) == 346) { if ($is_dst_type_derived_from_static_type13_2_off0147) { label = 347; } else { label = 348; } } if ((label | 0) == 347) { HEAP32[$is_dst_type_derived_from_static_type >> 2] = 3; return; } else if ((label | 0) == 348) { HEAP32[$is_dst_type_derived_from_static_type >> 2] = 4; return; } } } while (0); if (($path_below | 0) != 1) { return; } HEAP32[$info + 32 >> 2] = 1; return; } $33 = HEAP32[$this + 12 >> 2] | 0; $add_ptr64 = $this + 16 + ($33 << 3) | 0; $34 = HEAP32[$this + 20 >> 2] | 0; $shr_i121 = $34 >> 8; if (($34 & 1 | 0) == 0) { $offset_to_base_0_i126 = $shr_i121; } else { $offset_to_base_0_i126 = HEAP32[(HEAP32[$current_ptr >> 2] | 0) + $shr_i121 >> 2] | 0; } $39 = HEAP32[$this + 16 >> 2] | 0; FUNCTION_TABLE_viiiii[HEAP32[(HEAP32[$39 >> 2] | 0) + 24 >> 2] & 7]($39, $info, $current_ptr + $offset_to_base_0_i126 | 0, ($34 & 2 | 0) != 0 ? $path_below : 2, $use_strcmp); $incdec_ptr69 = $this + 24 | 0; if (($33 | 0) <= 1) { return; } $42 = HEAP32[$this + 8 >> 2] | 0; do { if (($42 & 2 | 0) == 0) { $number_to_static_ptr76 = $info + 36 | 0; if ((HEAP32[$number_to_static_ptr76 >> 2] | 0) == 1) { break; } if (($42 & 1 | 0) == 0) { $search_done110 = $info + 54 | 0; $55 = $current_ptr; $p65_2 = $incdec_ptr69; while (1) { if ((HEAP8[$search_done110] & 1) != 0) { label = 388; break; } if ((HEAP32[$number_to_static_ptr76 >> 2] | 0) == 1) { label = 389; break; } $70 = HEAP32[$p65_2 + 4 >> 2] | 0; $shr_i = $70 >> 8; if (($70 & 1 | 0) == 0) { $offset_to_base_0_i = $shr_i; } else { $offset_to_base_0_i = HEAP32[(HEAP32[$55 >> 2] | 0) + $shr_i >> 2] | 0; } $74 = HEAP32[$p65_2 >> 2] | 0; FUNCTION_TABLE_viiiii[HEAP32[(HEAP32[$74 >> 2] | 0) + 24 >> 2] & 7]($74, $info, $current_ptr + $offset_to_base_0_i | 0, ($70 & 2 | 0) != 0 ? $path_below : 2, $use_strcmp); $incdec_ptr120 = $p65_2 + 8 | 0; if ($incdec_ptr120 >>> 0 < $add_ptr64 >>> 0) { $p65_2 = $incdec_ptr120; } else { label = 390; break; } } if ((label | 0) == 388) { return; } else if ((label | 0) == 389) { return; } else if ((label | 0) == 390) { return; } } $path_dst_ptr_to_static_ptr99 = $info + 24 | 0; $search_done92 = $info + 54 | 0; $54 = $current_ptr; $p65_1 = $incdec_ptr69; while (1) { if ((HEAP8[$search_done92] & 1) != 0) { label = 385; break; } if ((HEAP32[$number_to_static_ptr76 >> 2] | 0) == 1) { if ((HEAP32[$path_dst_ptr_to_static_ptr99 >> 2] | 0) == 1) { label = 386; break; } } $60 = HEAP32[$p65_1 + 4 >> 2] | 0; $shr_i76 = $60 >> 8; if (($60 & 1 | 0) == 0) { $offset_to_base_0_i81 = $shr_i76; } else { $offset_to_base_0_i81 = HEAP32[(HEAP32[$54 >> 2] | 0) + $shr_i76 >> 2] | 0; } $64 = HEAP32[$p65_1 >> 2] | 0; FUNCTION_TABLE_viiiii[HEAP32[(HEAP32[$64 >> 2] | 0) + 24 >> 2] & 7]($64, $info, $current_ptr + $offset_to_base_0_i81 | 0, ($60 & 2 | 0) != 0 ? $path_below : 2, $use_strcmp); $incdec_ptr105 = $p65_1 + 8 | 0; if ($incdec_ptr105 >>> 0 < $add_ptr64 >>> 0) { $p65_1 = $incdec_ptr105; } else { label = 387; break; } } if ((label | 0) == 385) { return; } else if ((label | 0) == 386) { return; } else if ((label | 0) == 387) { return; } } } while (0); $search_done79 = $info + 54 | 0; $44 = $current_ptr; $p65_0 = $incdec_ptr69; while (1) { if ((HEAP8[$search_done79] & 1) != 0) { label = 383; break; } $47 = HEAP32[$p65_0 + 4 >> 2] | 0; $shr_i92 = $47 >> 8; if (($47 & 1 | 0) == 0) { $offset_to_base_0_i97 = $shr_i92; } else { $offset_to_base_0_i97 = HEAP32[(HEAP32[$44 >> 2] | 0) + $shr_i92 >> 2] | 0; } $51 = HEAP32[$p65_0 >> 2] | 0; FUNCTION_TABLE_viiiii[HEAP32[(HEAP32[$51 >> 2] | 0) + 24 >> 2] & 7]($51, $info, $current_ptr + $offset_to_base_0_i97 | 0, ($47 & 2 | 0) != 0 ? $path_below : 2, $use_strcmp); $incdec_ptr84 = $p65_0 + 8 | 0; if ($incdec_ptr84 >>> 0 < $add_ptr64 >>> 0) { $p65_0 = $incdec_ptr84; } else { label = 384; break; } } if ((label | 0) == 383) { return; } else if ((label | 0) == 384) { return; } } function __ZNK10__cxxabiv122__base_class_type_info16search_above_dstEPNS_19__dynamic_cast_infoEPKvS4_ib($this, $info, $dst_ptr, $current_ptr, $path_below, $use_strcmp) { $this = $this | 0; $info = $info | 0; $dst_ptr = $dst_ptr | 0; $current_ptr = $current_ptr | 0; $path_below = $path_below | 0; $use_strcmp = $use_strcmp | 0; var $0 = 0, $shr = 0, $offset_to_base_0 = 0, $5 = 0; $0 = HEAP32[$this + 4 >> 2] | 0; $shr = $0 >> 8; if (($0 & 1 | 0) == 0) { $offset_to_base_0 = $shr; } else { $offset_to_base_0 = HEAP32[(HEAP32[$current_ptr >> 2] | 0) + $shr >> 2] | 0; } $5 = HEAP32[$this >> 2] | 0; FUNCTION_TABLE_viiiiii[HEAP32[(HEAP32[$5 >> 2] | 0) + 20 >> 2] & 7]($5, $info, $dst_ptr, $current_ptr + $offset_to_base_0 | 0, ($0 & 2 | 0) != 0 ? $path_below : 2, $use_strcmp); return; } function __ZNK10__cxxabiv122__base_class_type_info16search_below_dstEPNS_19__dynamic_cast_infoEPKvib($this, $info, $current_ptr, $path_below, $use_strcmp) { $this = $this | 0; $info = $info | 0; $current_ptr = $current_ptr | 0; $path_below = $path_below | 0; $use_strcmp = $use_strcmp | 0; var $0 = 0, $shr = 0, $offset_to_base_0 = 0, $5 = 0; $0 = HEAP32[$this + 4 >> 2] | 0; $shr = $0 >> 8; if (($0 & 1 | 0) == 0) { $offset_to_base_0 = $shr; } else { $offset_to_base_0 = HEAP32[(HEAP32[$current_ptr >> 2] | 0) + $shr >> 2] | 0; } $5 = HEAP32[$this >> 2] | 0; FUNCTION_TABLE_viiiii[HEAP32[(HEAP32[$5 >> 2] | 0) + 24 >> 2] & 7]($5, $info, $current_ptr + $offset_to_base_0 | 0, ($0 & 2 | 0) != 0 ? $path_below : 2, $use_strcmp); return; } function __ZNK10__cxxabiv120__si_class_type_info16search_below_dstEPNS_19__dynamic_cast_infoEPKvib($this, $info, $current_ptr, $path_below, $use_strcmp) { $this = $this | 0; $info = $info | 0; $current_ptr = $current_ptr | 0; $path_below = $path_below | 0; $use_strcmp = $use_strcmp | 0; var $0 = 0, $path_dynamic_ptr_to_static_ptr_i = 0, $dst_ptr_not_leading_to_static_ptr = 0, $is_dst_type_derived_from_static_type = 0, $found_our_static_ptr = 0, $found_any_static_type = 0, $10 = 0, $is_dst_type_derived_from_static_type13_0_off034 = 0, $number_to_dst_ptr = 0, $20 = 0, label = 0; $0 = $this | 0; if (($0 | 0) == (HEAP32[$info + 8 >> 2] | 0)) { if ((HEAP32[$info + 4 >> 2] | 0) != ($current_ptr | 0)) { return; } $path_dynamic_ptr_to_static_ptr_i = $info + 28 | 0; if ((HEAP32[$path_dynamic_ptr_to_static_ptr_i >> 2] | 0) == 1) { return; } HEAP32[$path_dynamic_ptr_to_static_ptr_i >> 2] = $path_below; return; } if (($0 | 0) != (HEAP32[$info >> 2] | 0)) { $20 = HEAP32[$this + 8 >> 2] | 0; FUNCTION_TABLE_viiiii[HEAP32[(HEAP32[$20 >> 2] | 0) + 24 >> 2] & 7]($20, $info, $current_ptr, $path_below, $use_strcmp); return; } do { if ((HEAP32[$info + 16 >> 2] | 0) != ($current_ptr | 0)) { $dst_ptr_not_leading_to_static_ptr = $info + 20 | 0; if ((HEAP32[$dst_ptr_not_leading_to_static_ptr >> 2] | 0) == ($current_ptr | 0)) { break; } HEAP32[$info + 32 >> 2] = $path_below; $is_dst_type_derived_from_static_type = $info + 44 | 0; if ((HEAP32[$is_dst_type_derived_from_static_type >> 2] | 0) == 4) { return; } $found_our_static_ptr = $info + 52 | 0; HEAP8[$found_our_static_ptr] = 0; $found_any_static_type = $info + 53 | 0; HEAP8[$found_any_static_type] = 0; $10 = HEAP32[$this + 8 >> 2] | 0; FUNCTION_TABLE_viiiiii[HEAP32[(HEAP32[$10 >> 2] | 0) + 20 >> 2] & 7]($10, $info, $current_ptr, $current_ptr, 1, $use_strcmp); if ((HEAP8[$found_any_static_type] & 1) == 0) { $is_dst_type_derived_from_static_type13_0_off034 = 0; label = 409; } else { if ((HEAP8[$found_our_static_ptr] & 1) == 0) { $is_dst_type_derived_from_static_type13_0_off034 = 1; label = 409; } } L543 : do { if ((label | 0) == 409) { HEAP32[$dst_ptr_not_leading_to_static_ptr >> 2] = $current_ptr; $number_to_dst_ptr = $info + 40 | 0; HEAP32[$number_to_dst_ptr >> 2] = (HEAP32[$number_to_dst_ptr >> 2] | 0) + 1; do { if ((HEAP32[$info + 36 >> 2] | 0) == 1) { if ((HEAP32[$info + 24 >> 2] | 0) != 2) { label = 412; break; } HEAP8[$info + 54 | 0] = 1; if ($is_dst_type_derived_from_static_type13_0_off034) { break L543; } } else { label = 412; } } while (0); if ((label | 0) == 412) { if ($is_dst_type_derived_from_static_type13_0_off034) { break; } } HEAP32[$is_dst_type_derived_from_static_type >> 2] = 4; return; } } while (0); HEAP32[$is_dst_type_derived_from_static_type >> 2] = 3; return; } } while (0); if (($path_below | 0) != 1) { return; } HEAP32[$info + 32 >> 2] = 1; return; } function __ZNK10__cxxabiv121__vmi_class_type_info16search_above_dstEPNS_19__dynamic_cast_infoEPKvS4_ib($this, $info, $dst_ptr, $current_ptr, $path_below, $use_strcmp) { $this = $this | 0; $info = $info | 0; $dst_ptr = $dst_ptr | 0; $current_ptr = $current_ptr | 0; $path_below = $path_below | 0; $use_strcmp = $use_strcmp | 0; var $dst_ptr_leading_to_static_ptr_i = 0, $4 = 0, $path_dst_ptr_to_static_ptr12_i = 0, $6 = 0, $7 = 0, $number_to_static_ptr26_i = 0, $found_our_static_ptr2 = 0, $11 = 0, $found_any_static_type5 = 0, $13 = 0, $14 = 0, $add_ptr = 0, $15 = 0, $shr_i30 = 0, $offset_to_base_0_i35 = 0, $20 = 0, $path_dst_ptr_to_static_ptr = 0, $__flags = 0, $search_done = 0, $23 = 0, $p_0 = 0, $33 = 0, $shr_i = 0, $offset_to_base_0_i = 0, $37 = 0; if (($this | 0) != (HEAP32[$info + 8 >> 2] | 0)) { $found_our_static_ptr2 = $info + 52 | 0; $11 = HEAP8[$found_our_static_ptr2] & 1; $found_any_static_type5 = $info + 53 | 0; $13 = HEAP8[$found_any_static_type5] & 1; $14 = HEAP32[$this + 12 >> 2] | 0; $add_ptr = $this + 16 + ($14 << 3) | 0; HEAP8[$found_our_static_ptr2] = 0; HEAP8[$found_any_static_type5] = 0; $15 = HEAP32[$this + 20 >> 2] | 0; $shr_i30 = $15 >> 8; if (($15 & 1 | 0) == 0) { $offset_to_base_0_i35 = $shr_i30; } else { $offset_to_base_0_i35 = HEAP32[(HEAP32[$current_ptr >> 2] | 0) + $shr_i30 >> 2] | 0; } $20 = HEAP32[$this + 16 >> 2] | 0; FUNCTION_TABLE_viiiiii[HEAP32[(HEAP32[$20 >> 2] | 0) + 20 >> 2] & 7]($20, $info, $dst_ptr, $current_ptr + $offset_to_base_0_i35 | 0, ($15 & 2 | 0) != 0 ? $path_below : 2, $use_strcmp); L565 : do { if (($14 | 0) > 1) { $path_dst_ptr_to_static_ptr = $info + 24 | 0; $__flags = $this + 8 | 0; $search_done = $info + 54 | 0; $23 = $current_ptr; $p_0 = $this + 24 | 0; do { if ((HEAP8[$search_done] & 1) != 0) { break L565; } do { if ((HEAP8[$found_our_static_ptr2] & 1) == 0) { if ((HEAP8[$found_any_static_type5] & 1) == 0) { break; } if ((HEAP32[$__flags >> 2] & 1 | 0) == 0) { break L565; } } else { if ((HEAP32[$path_dst_ptr_to_static_ptr >> 2] | 0) == 1) { break L565; } if ((HEAP32[$__flags >> 2] & 2 | 0) == 0) { break L565; } } } while (0); HEAP8[$found_our_static_ptr2] = 0; HEAP8[$found_any_static_type5] = 0; $33 = HEAP32[$p_0 + 4 >> 2] | 0; $shr_i = $33 >> 8; if (($33 & 1 | 0) == 0) { $offset_to_base_0_i = $shr_i; } else { $offset_to_base_0_i = HEAP32[(HEAP32[$23 >> 2] | 0) + $shr_i >> 2] | 0; } $37 = HEAP32[$p_0 >> 2] | 0; FUNCTION_TABLE_viiiiii[HEAP32[(HEAP32[$37 >> 2] | 0) + 20 >> 2] & 7]($37, $info, $dst_ptr, $current_ptr + $offset_to_base_0_i | 0, ($33 & 2 | 0) != 0 ? $path_below : 2, $use_strcmp); $p_0 = $p_0 + 8 | 0; } while ($p_0 >>> 0 < $add_ptr >>> 0); } } while (0); HEAP8[$found_our_static_ptr2] = $11; HEAP8[$found_any_static_type5] = $13; return; } HEAP8[$info + 53 | 0] = 1; if ((HEAP32[$info + 4 >> 2] | 0) != ($current_ptr | 0)) { return; } HEAP8[$info + 52 | 0] = 1; $dst_ptr_leading_to_static_ptr_i = $info + 16 | 0; $4 = HEAP32[$dst_ptr_leading_to_static_ptr_i >> 2] | 0; if (($4 | 0) == 0) { HEAP32[$dst_ptr_leading_to_static_ptr_i >> 2] = $dst_ptr; HEAP32[$info + 24 >> 2] = $path_below; HEAP32[$info + 36 >> 2] = 1; if (!((HEAP32[$info + 48 >> 2] | 0) == 1 & ($path_below | 0) == 1)) { return; } HEAP8[$info + 54 | 0] = 1; return; } if (($4 | 0) != ($dst_ptr | 0)) { $number_to_static_ptr26_i = $info + 36 | 0; HEAP32[$number_to_static_ptr26_i >> 2] = (HEAP32[$number_to_static_ptr26_i >> 2] | 0) + 1; HEAP8[$info + 54 | 0] = 1; return; } $path_dst_ptr_to_static_ptr12_i = $info + 24 | 0; $6 = HEAP32[$path_dst_ptr_to_static_ptr12_i >> 2] | 0; if (($6 | 0) == 2) { HEAP32[$path_dst_ptr_to_static_ptr12_i >> 2] = $path_below; $7 = $path_below; } else { $7 = $6; } if (!((HEAP32[$info + 48 >> 2] | 0) == 1 & ($7 | 0) == 1)) { return; } HEAP8[$info + 54 | 0] = 1; return; } function __ZNK10__cxxabiv120__si_class_type_info16search_above_dstEPNS_19__dynamic_cast_infoEPKvS4_ib($this, $info, $dst_ptr, $current_ptr, $path_below, $use_strcmp) { $this = $this | 0; $info = $info | 0; $dst_ptr = $dst_ptr | 0; $current_ptr = $current_ptr | 0; $path_below = $path_below | 0; $use_strcmp = $use_strcmp | 0; var $dst_ptr_leading_to_static_ptr_i = 0, $4 = 0, $path_dst_ptr_to_static_ptr12_i = 0, $6 = 0, $7 = 0, $number_to_static_ptr26_i = 0, $10 = 0; if (($this | 0) != (HEAP32[$info + 8 >> 2] | 0)) { $10 = HEAP32[$this + 8 >> 2] | 0; FUNCTION_TABLE_viiiiii[HEAP32[(HEAP32[$10 >> 2] | 0) + 20 >> 2] & 7]($10, $info, $dst_ptr, $current_ptr, $path_below, $use_strcmp); return; } HEAP8[$info + 53 | 0] = 1; if ((HEAP32[$info + 4 >> 2] | 0) != ($current_ptr | 0)) { return; } HEAP8[$info + 52 | 0] = 1; $dst_ptr_leading_to_static_ptr_i = $info + 16 | 0; $4 = HEAP32[$dst_ptr_leading_to_static_ptr_i >> 2] | 0; if (($4 | 0) == 0) { HEAP32[$dst_ptr_leading_to_static_ptr_i >> 2] = $dst_ptr; HEAP32[$info + 24 >> 2] = $path_below; HEAP32[$info + 36 >> 2] = 1; if (!((HEAP32[$info + 48 >> 2] | 0) == 1 & ($path_below | 0) == 1)) { return; } HEAP8[$info + 54 | 0] = 1; return; } if (($4 | 0) != ($dst_ptr | 0)) { $number_to_static_ptr26_i = $info + 36 | 0; HEAP32[$number_to_static_ptr26_i >> 2] = (HEAP32[$number_to_static_ptr26_i >> 2] | 0) + 1; HEAP8[$info + 54 | 0] = 1; return; } $path_dst_ptr_to_static_ptr12_i = $info + 24 | 0; $6 = HEAP32[$path_dst_ptr_to_static_ptr12_i >> 2] | 0; if (($6 | 0) == 2) { HEAP32[$path_dst_ptr_to_static_ptr12_i >> 2] = $path_below; $7 = $path_below; } else { $7 = $6; } if (!((HEAP32[$info + 48 >> 2] | 0) == 1 & ($7 | 0) == 1)) { return; } HEAP8[$info + 54 | 0] = 1; return; } function __ZNK10__cxxabiv117__class_type_info16search_above_dstEPNS_19__dynamic_cast_infoEPKvS4_ib($this, $info, $dst_ptr, $current_ptr, $path_below, $use_strcmp) { $this = $this | 0; $info = $info | 0; $dst_ptr = $dst_ptr | 0; $current_ptr = $current_ptr | 0; $path_below = $path_below | 0; $use_strcmp = $use_strcmp | 0; var $dst_ptr_leading_to_static_ptr_i = 0, $2 = 0, $path_dst_ptr_to_static_ptr12_i = 0, $4 = 0, $5 = 0, $number_to_static_ptr26_i = 0; if ((HEAP32[$info + 8 >> 2] | 0) != ($this | 0)) { return; } HEAP8[$info + 53 | 0] = 1; if ((HEAP32[$info + 4 >> 2] | 0) != ($current_ptr | 0)) { return; } HEAP8[$info + 52 | 0] = 1; $dst_ptr_leading_to_static_ptr_i = $info + 16 | 0; $2 = HEAP32[$dst_ptr_leading_to_static_ptr_i >> 2] | 0; if (($2 | 0) == 0) { HEAP32[$dst_ptr_leading_to_static_ptr_i >> 2] = $dst_ptr; HEAP32[$info + 24 >> 2] = $path_below; HEAP32[$info + 36 >> 2] = 1; if (!((HEAP32[$info + 48 >> 2] | 0) == 1 & ($path_below | 0) == 1)) { return; } HEAP8[$info + 54 | 0] = 1; return; } if (($2 | 0) != ($dst_ptr | 0)) { $number_to_static_ptr26_i = $info + 36 | 0; HEAP32[$number_to_static_ptr26_i >> 2] = (HEAP32[$number_to_static_ptr26_i >> 2] | 0) + 1; HEAP8[$info + 54 | 0] = 1; return; } $path_dst_ptr_to_static_ptr12_i = $info + 24 | 0; $4 = HEAP32[$path_dst_ptr_to_static_ptr12_i >> 2] | 0; if (($4 | 0) == 2) { HEAP32[$path_dst_ptr_to_static_ptr12_i >> 2] = $path_below; $5 = $path_below; } else { $5 = $4; } if (!((HEAP32[$info + 48 >> 2] | 0) == 1 & ($5 | 0) == 1)) { return; } HEAP8[$info + 54 | 0] = 1; return; } function _malloc($bytes) { $bytes = $bytes | 0; var $cond = 0, $shr = 0, $0 = 0, $shr3 = 0, $add8 = 0, $shl = 0, $1 = 0, $2 = 0, $3 = 0, $fd9 = 0, $4 = 0, $bk = 0, $shl22 = 0, $9 = 0, $shl37 = 0, $and41 = 0, $sub44 = 0, $and46 = 0, $shr47 = 0, $and49 = 0, $shr51 = 0, $and53 = 0, $shr55 = 0, $and57 = 0, $shr59 = 0, $and61 = 0, $add64 = 0, $shl65 = 0, $13 = 0, $14 = 0, $15 = 0, $fd69 = 0, $16 = 0, $bk78 = 0, $shl90 = 0, $sub91 = 0, $20 = 0, $21 = 0, $23 = 0, $24 = 0, $shr101 = 0, $shl102 = 0, $25 = 0, $26 = 0, $shl105 = 0, $27 = 0, $28 = 0, $_pre_phi = 0, $F104_0 = 0, $32 = 0, $sub2_i = 0, $and3_i = 0, $shr4_i = 0, $and6_i = 0, $shr7_i = 0, $and9_i = 0, $shr11_i = 0, $and13_i = 0, $shr15_i = 0, $and17_i = 0, $33 = 0, $rsize_0_i = 0, $v_0_i = 0, $t_0_i = 0, $35 = 0, $36 = 0, $cond7_i = 0, $sub31_i = 0, $cmp32_i = 0, $38 = 0, $39 = 0, $add_ptr_i = 0, $40 = 0, $41 = 0, $42 = 0, $43 = 0, $bk47_i = 0, $fd50_i = 0, $arrayidx61_i = 0, $47 = 0, $arrayidx65_i = 0, $48 = 0, $RP_0_i = 0, $R_0_i = 0, $arrayidx71_i = 0, $49 = 0, $arrayidx75_i = 0, $50 = 0, $R_1_i = 0, $index_i = 0, $arrayidx94_i = 0, $arrayidx113_i = 0, $61 = 0, $64 = 0, $add177_i = 0, $67 = 0, $70 = 0, $71 = 0, $shr194_i = 0, $shl195_i = 0, $72 = 0, $73 = 0, $shl198_i = 0, $74 = 0, $75 = 0, $_pre_phi_i = 0, $F197_0_i = 0, $add_ptr225_i = 0, $add143 = 0, $and144 = 0, $79 = 0, $sub_i107 = 0, $shr_i108 = 0, $and_i112 = 0, $shl_i113 = 0, $and8_i = 0, $shl9_i = 0, $and12_i = 0, $add17_i = 0, $idx_0_i = 0, $80 = 0, $cond_i = 0, $rst_0_i = 0, $sizebits_0_i = 0, $t_0_i121 = 0, $rsize_0_i122 = 0, $v_0_i123 = 0, $and32_i = 0, $sub33_i = 0, $rsize_1_i = 0, $v_1_i = 0, $82 = 0, $83 = 0, $rst_1_i = 0, $t_1_i = 0, $rsize_2_i = 0, $v_2_i = 0, $shl59_i = 0, $and63_i = 0, $sub69_i = 0, $and72_i = 0, $shr74_i = 0, $and76_i = 0, $shr78_i = 0, $and80_i = 0, $shr82_i = 0, $and84_i = 0, $shr86_i = 0, $and88_i = 0, $t_2_ph_i = 0, $v_326_i = 0, $rsize_325_i = 0, $t_224_i = 0, $sub100_i = 0, $cmp101_i = 0, $sub100_rsize_3_i = 0, $t_2_v_3_i = 0, $86 = 0, $87 = 0, $v_3_lcssa_i = 0, $rsize_3_lcssa_i = 0, $89 = 0, $90 = 0, $add_ptr_i128 = 0, $91 = 0, $92 = 0, $93 = 0, $94 = 0, $bk135_i = 0, $fd138_i = 0, $arrayidx150_i = 0, $98 = 0, $arrayidx154_i133 = 0, $99 = 0, $RP_0_i136 = 0, $R_0_i137 = 0, $arrayidx160_i = 0, $100 = 0, $arrayidx164_i = 0, $101 = 0, $R_1_i139 = 0, $index_i140 = 0, $arrayidx183_i = 0, $arrayidx203_i = 0, $112 = 0, $115 = 0, $add267_i = 0, $118 = 0, $shr282_i = 0, $shl287_i = 0, $121 = 0, $122 = 0, $shl290_i = 0, $123 = 0, $124 = 0, $_pre_phi_i147 = 0, $F289_0_i = 0, $129 = 0, $shr317_i = 0, $and330_i = 0, $shl332_i = 0, $and335_i = 0, $shl337_i = 0, $and340_i = 0, $add345_i = 0, $I315_0_i = 0, $arrayidx354_i = 0, $132 = 0, $shl361_i = 0, $cond382_i = 0, $T_0_i = 0, $K372_0_i = 0, $arrayidx393_i = 0, $139 = 0, $fd412_i = 0, $145 = 0, $147 = 0, $add_ptr436_i = 0, $nb_0 = 0, $153 = 0, $sub159 = 0, $154 = 0, $155 = 0, $159 = 0, $162 = 0, $sub187 = 0, $163 = 0, $164 = 0, $call_i_i = 0, $add_i149 = 0, $169 = 0, $sub_i150 = 0, $add9_i = 0, $neg_i151 = 0, $and11_i = 0, $170 = 0, $171 = 0, $add17_i152 = 0, $173 = 0, $174 = 0, $sp_0_i_i = 0, $base_i_i = 0, $175 = 0, $size_i_i = 0, $177 = 0, $call34_i = 0, $178 = 0, $179 = 0, $sub38_i = 0, $ssize_0_i = 0, $180 = 0, $add51_i = 0, $181 = 0, $call65_i = 0, $cmp66_i160 = 0, $and77_i = 0, $call80_i = 0, $cmp82_i = 0, $ssize_1_i = 0, $br_0_i = 0, $tsize_0_i = 0, $tbase_0_i = 0, $sub109_i = 0, $185 = 0, $and101_i = 0, $ssize_2_i = 0, $tsize_0758385_i = 0, $tsize_1_i = 0, $call128_i = 0, $call129_i = 0, $sub_ptr_sub_i = 0, $cmp138_i166 = 0, $call128_tbase_1_i = 0, $tbase_292_i = 0, $tsize_291_i = 0, $add147_i = 0, $189 = 0, $190 = 0, $i_02_i_i = 0, $shl_i_i = 0, $192 = 0, $195 = 0, $cond_i_i = 0, $sub5_i_i = 0, $sp_0105_i = 0, $201 = 0, $size185_i = 0, $202 = 0, $203 = 0, $205 = 0, $206 = 0, $add212_i = 0, $208 = 0, $209 = 0, $cond_i28_i = 0, $sub5_i30_i = 0, $add_ptr224_i = 0, $sp_1101_i = 0, $base223_i = 0, $217 = 0, $size242_i = 0, $220 = 0, $cond_i43_i = 0, $222 = 0, $cond15_i_i = 0, $add_ptr16_i_i = 0, $224 = 0, $add_ptr4_sum_i50_i = 0, $add_ptr17_i_i = 0, $225 = 0, $sub18_i_i = 0, $add_i_i = 0, $add26_i_i = 0, $add_ptr16_sum_i_i = 0, $234 = 0, $and37_i_i = 0, $shr_i55_i = 0, $236 = 0, $238 = 0, $239 = 0, $fd59_i_i = 0, $fd68_pre_phi_i_i = 0, $247 = 0, $249 = 0, $251 = 0, $253 = 0, $bk82_i_i = 0, $fd85_i_i = 0, $add_ptr16_sum56_i_i = 0, $258 = 0, $259 = 0, $arrayidx99_i_i = 0, $260 = 0, $RP_0_i_i = 0, $R_0_i_i = 0, $arrayidx103_i_i = 0, $261 = 0, $arrayidx107_i_i = 0, $262 = 0, $R_1_i_i = 0, $265 = 0, $arrayidx123_i_i = 0, $arrayidx143_i_i = 0, $add_ptr16_sum2728_i_i = 0, $275 = 0, $279 = 0, $qsize_0_i_i = 0, $oldfirst_0_i_i = 0, $head208_i_i = 0, $shr214_i_i = 0, $shl221_i_i = 0, $285 = 0, $286 = 0, $shl226_i_i = 0, $287 = 0, $288 = 0, $_pre_phi_i68_i = 0, $F224_0_i_i = 0, $293 = 0, $shr253_i_i = 0, $and264_i_i = 0, $shl265_i_i = 0, $and268_i_i = 0, $shl270_i_i = 0, $and273_i_i = 0, $add278_i_i = 0, $I252_0_i_i = 0, $arrayidx287_i_i = 0, $296 = 0, $shl294_i_i = 0, $cond315_i_i = 0, $T_0_i69_i = 0, $K305_0_i_i = 0, $arrayidx325_i_i = 0, $303 = 0, $fd344_i_i = 0, $309 = 0, $311 = 0, $316 = 0, $sp_0_i_i_i = 0, $317 = 0, $318 = 0, $add_ptr_i_i_i = 0, $320 = 0, $cond_i18_i = 0, $add_ptr7_i_i = 0, $cond13_i_i = 0, $add_ptr14_i_i = 0, $323 = 0, $cond_i_i_i = 0, $sub5_i_i_i = 0, $330 = 0, $add_ptr2416_i_i = 0, $332 = 0, $sub_ptr_sub_i_i = 0, $335 = 0, $shr_i_i = 0, $shl_i21_i = 0, $337 = 0, $338 = 0, $shl39_i_i = 0, $339 = 0, $340 = 0, $_pre_phi_i_i = 0, $F_0_i_i = 0, $343 = 0, $shr58_i_i = 0, $and69_i_i = 0, $shl70_i_i = 0, $and73_i_i = 0, $shl75_i_i = 0, $and78_i_i = 0, $add83_i_i = 0, $I57_0_i_i = 0, $arrayidx91_i_i = 0, $345 = 0, $shl95_i_i = 0, $cond115_i_i = 0, $T_0_i_i = 0, $K105_0_i_i = 0, $arrayidx126_i_i = 0, $348 = 0, $fd145_i_i = 0, $351 = 0, $353 = 0, $355 = 0, $sub253_i = 0, $356 = 0, $357 = 0, $mem_0 = 0, label = 0; do { if ($bytes >>> 0 < 245) { if ($bytes >>> 0 < 11) { $cond = 16; } else { $cond = $bytes + 11 & -8; } $shr = $cond >>> 3; $0 = HEAP32[11602] | 0; $shr3 = $0 >>> ($shr >>> 0); if (($shr3 & 3 | 0) != 0) { $add8 = ($shr3 & 1 ^ 1) + $shr | 0; $shl = $add8 << 1; $1 = 46448 + ($shl << 2) | 0; $2 = 46448 + ($shl + 2 << 2) | 0; $3 = HEAP32[$2 >> 2] | 0; $fd9 = $3 + 8 | 0; $4 = HEAP32[$fd9 >> 2] | 0; do { if (($1 | 0) == ($4 | 0)) { HEAP32[11602] = $0 & ~(1 << $add8); } else { if ($4 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); return 0; } $bk = $4 + 12 | 0; if ((HEAP32[$bk >> 2] | 0) == ($3 | 0)) { HEAP32[$bk >> 2] = $1; HEAP32[$2 >> 2] = $4; break; } else { _abort(); return 0; } } } while (0); $shl22 = $add8 << 3; HEAP32[$3 + 4 >> 2] = $shl22 | 3; $9 = $3 + ($shl22 | 4) | 0; HEAP32[$9 >> 2] = HEAP32[$9 >> 2] | 1; $mem_0 = $fd9; return $mem_0 | 0; } if ($cond >>> 0 <= (HEAP32[11604] | 0) >>> 0) { $nb_0 = $cond; break; } if (($shr3 | 0) != 0) { $shl37 = 2 << $shr; $and41 = $shr3 << $shr & ($shl37 | -$shl37); $sub44 = ($and41 & -$and41) - 1 | 0; $and46 = $sub44 >>> 12 & 16; $shr47 = $sub44 >>> ($and46 >>> 0); $and49 = $shr47 >>> 5 & 8; $shr51 = $shr47 >>> ($and49 >>> 0); $and53 = $shr51 >>> 2 & 4; $shr55 = $shr51 >>> ($and53 >>> 0); $and57 = $shr55 >>> 1 & 2; $shr59 = $shr55 >>> ($and57 >>> 0); $and61 = $shr59 >>> 1 & 1; $add64 = ($and49 | $and46 | $and53 | $and57 | $and61) + ($shr59 >>> ($and61 >>> 0)) | 0; $shl65 = $add64 << 1; $13 = 46448 + ($shl65 << 2) | 0; $14 = 46448 + ($shl65 + 2 << 2) | 0; $15 = HEAP32[$14 >> 2] | 0; $fd69 = $15 + 8 | 0; $16 = HEAP32[$fd69 >> 2] | 0; do { if (($13 | 0) == ($16 | 0)) { HEAP32[11602] = $0 & ~(1 << $add64); } else { if ($16 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); return 0; } $bk78 = $16 + 12 | 0; if ((HEAP32[$bk78 >> 2] | 0) == ($15 | 0)) { HEAP32[$bk78 >> 2] = $13; HEAP32[$14 >> 2] = $16; break; } else { _abort(); return 0; } } } while (0); $shl90 = $add64 << 3; $sub91 = $shl90 - $cond | 0; HEAP32[$15 + 4 >> 2] = $cond | 3; $20 = $15; $21 = $20 + $cond | 0; HEAP32[$20 + ($cond | 4) >> 2] = $sub91 | 1; HEAP32[$20 + $shl90 >> 2] = $sub91; $23 = HEAP32[11604] | 0; if (($23 | 0) != 0) { $24 = HEAP32[11607] | 0; $shr101 = $23 >>> 3; $shl102 = $shr101 << 1; $25 = 46448 + ($shl102 << 2) | 0; $26 = HEAP32[11602] | 0; $shl105 = 1 << $shr101; do { if (($26 & $shl105 | 0) == 0) { HEAP32[11602] = $26 | $shl105; $F104_0 = $25; $_pre_phi = 46448 + ($shl102 + 2 << 2) | 0; } else { $27 = 46448 + ($shl102 + 2 << 2) | 0; $28 = HEAP32[$27 >> 2] | 0; if ($28 >>> 0 >= (HEAP32[11606] | 0) >>> 0) { $F104_0 = $28; $_pre_phi = $27; break; } _abort(); return 0; } } while (0); HEAP32[$_pre_phi >> 2] = $24; HEAP32[$F104_0 + 12 >> 2] = $24; HEAP32[$24 + 8 >> 2] = $F104_0; HEAP32[$24 + 12 >> 2] = $25; } HEAP32[11604] = $sub91; HEAP32[11607] = $21; $mem_0 = $fd69; return $mem_0 | 0; } $32 = HEAP32[11603] | 0; if (($32 | 0) == 0) { $nb_0 = $cond; break; } $sub2_i = ($32 & -$32) - 1 | 0; $and3_i = $sub2_i >>> 12 & 16; $shr4_i = $sub2_i >>> ($and3_i >>> 0); $and6_i = $shr4_i >>> 5 & 8; $shr7_i = $shr4_i >>> ($and6_i >>> 0); $and9_i = $shr7_i >>> 2 & 4; $shr11_i = $shr7_i >>> ($and9_i >>> 0); $and13_i = $shr11_i >>> 1 & 2; $shr15_i = $shr11_i >>> ($and13_i >>> 0); $and17_i = $shr15_i >>> 1 & 1; $33 = HEAP32[46712 + (($and6_i | $and3_i | $and9_i | $and13_i | $and17_i) + ($shr15_i >>> ($and17_i >>> 0)) << 2) >> 2] | 0; $t_0_i = $33; $v_0_i = $33; $rsize_0_i = (HEAP32[$33 + 4 >> 2] & -8) - $cond | 0; while (1) { $35 = HEAP32[$t_0_i + 16 >> 2] | 0; if (($35 | 0) == 0) { $36 = HEAP32[$t_0_i + 20 >> 2] | 0; if (($36 | 0) == 0) { break; } else { $cond7_i = $36; } } else { $cond7_i = $35; } $sub31_i = (HEAP32[$cond7_i + 4 >> 2] & -8) - $cond | 0; $cmp32_i = $sub31_i >>> 0 < $rsize_0_i >>> 0; $t_0_i = $cond7_i; $v_0_i = $cmp32_i ? $cond7_i : $v_0_i; $rsize_0_i = $cmp32_i ? $sub31_i : $rsize_0_i; } $38 = $v_0_i; $39 = HEAP32[11606] | 0; if ($38 >>> 0 < $39 >>> 0) { _abort(); return 0; } $add_ptr_i = $38 + $cond | 0; $40 = $add_ptr_i; if ($38 >>> 0 >= $add_ptr_i >>> 0) { _abort(); return 0; } $41 = HEAP32[$v_0_i + 24 >> 2] | 0; $42 = HEAP32[$v_0_i + 12 >> 2] | 0; do { if (($42 | 0) == ($v_0_i | 0)) { $arrayidx61_i = $v_0_i + 20 | 0; $47 = HEAP32[$arrayidx61_i >> 2] | 0; if (($47 | 0) == 0) { $arrayidx65_i = $v_0_i + 16 | 0; $48 = HEAP32[$arrayidx65_i >> 2] | 0; if (($48 | 0) == 0) { $R_1_i = 0; break; } else { $R_0_i = $48; $RP_0_i = $arrayidx65_i; } } else { $R_0_i = $47; $RP_0_i = $arrayidx61_i; } while (1) { $arrayidx71_i = $R_0_i + 20 | 0; $49 = HEAP32[$arrayidx71_i >> 2] | 0; if (($49 | 0) != 0) { $R_0_i = $49; $RP_0_i = $arrayidx71_i; continue; } $arrayidx75_i = $R_0_i + 16 | 0; $50 = HEAP32[$arrayidx75_i >> 2] | 0; if (($50 | 0) == 0) { break; } else { $R_0_i = $50; $RP_0_i = $arrayidx75_i; } } if ($RP_0_i >>> 0 < $39 >>> 0) { _abort(); return 0; } else { HEAP32[$RP_0_i >> 2] = 0; $R_1_i = $R_0_i; break; } } else { $43 = HEAP32[$v_0_i + 8 >> 2] | 0; if ($43 >>> 0 < $39 >>> 0) { _abort(); return 0; } $bk47_i = $43 + 12 | 0; if ((HEAP32[$bk47_i >> 2] | 0) != ($v_0_i | 0)) { _abort(); return 0; } $fd50_i = $42 + 8 | 0; if ((HEAP32[$fd50_i >> 2] | 0) == ($v_0_i | 0)) { HEAP32[$bk47_i >> 2] = $42; HEAP32[$fd50_i >> 2] = $43; $R_1_i = $42; break; } else { _abort(); return 0; } } } while (0); L732 : do { if (($41 | 0) != 0) { $index_i = $v_0_i + 28 | 0; $arrayidx94_i = 46712 + (HEAP32[$index_i >> 2] << 2) | 0; do { if (($v_0_i | 0) == (HEAP32[$arrayidx94_i >> 2] | 0)) { HEAP32[$arrayidx94_i >> 2] = $R_1_i; if (($R_1_i | 0) != 0) { break; } HEAP32[11603] = HEAP32[11603] & ~(1 << HEAP32[$index_i >> 2]); break L732; } else { if ($41 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); return 0; } $arrayidx113_i = $41 + 16 | 0; if ((HEAP32[$arrayidx113_i >> 2] | 0) == ($v_0_i | 0)) { HEAP32[$arrayidx113_i >> 2] = $R_1_i; } else { HEAP32[$41 + 20 >> 2] = $R_1_i; } if (($R_1_i | 0) == 0) { break L732; } } } while (0); if ($R_1_i >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); return 0; } HEAP32[$R_1_i + 24 >> 2] = $41; $61 = HEAP32[$v_0_i + 16 >> 2] | 0; do { if (($61 | 0) != 0) { if ($61 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); return 0; } else { HEAP32[$R_1_i + 16 >> 2] = $61; HEAP32[$61 + 24 >> 2] = $R_1_i; break; } } } while (0); $64 = HEAP32[$v_0_i + 20 >> 2] | 0; if (($64 | 0) == 0) { break; } if ($64 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); return 0; } else { HEAP32[$R_1_i + 20 >> 2] = $64; HEAP32[$64 + 24 >> 2] = $R_1_i; break; } } } while (0); if ($rsize_0_i >>> 0 < 16) { $add177_i = $rsize_0_i + $cond | 0; HEAP32[$v_0_i + 4 >> 2] = $add177_i | 3; $67 = $38 + ($add177_i + 4) | 0; HEAP32[$67 >> 2] = HEAP32[$67 >> 2] | 1; } else { HEAP32[$v_0_i + 4 >> 2] = $cond | 3; HEAP32[$38 + ($cond | 4) >> 2] = $rsize_0_i | 1; HEAP32[$38 + ($rsize_0_i + $cond) >> 2] = $rsize_0_i; $70 = HEAP32[11604] | 0; if (($70 | 0) != 0) { $71 = HEAP32[11607] | 0; $shr194_i = $70 >>> 3; $shl195_i = $shr194_i << 1; $72 = 46448 + ($shl195_i << 2) | 0; $73 = HEAP32[11602] | 0; $shl198_i = 1 << $shr194_i; do { if (($73 & $shl198_i | 0) == 0) { HEAP32[11602] = $73 | $shl198_i; $F197_0_i = $72; $_pre_phi_i = 46448 + ($shl195_i + 2 << 2) | 0; } else { $74 = 46448 + ($shl195_i + 2 << 2) | 0; $75 = HEAP32[$74 >> 2] | 0; if ($75 >>> 0 >= (HEAP32[11606] | 0) >>> 0) { $F197_0_i = $75; $_pre_phi_i = $74; break; } _abort(); return 0; } } while (0); HEAP32[$_pre_phi_i >> 2] = $71; HEAP32[$F197_0_i + 12 >> 2] = $71; HEAP32[$71 + 8 >> 2] = $F197_0_i; HEAP32[$71 + 12 >> 2] = $72; } HEAP32[11604] = $rsize_0_i; HEAP32[11607] = $40; } $add_ptr225_i = $v_0_i + 8 | 0; if (($add_ptr225_i | 0) == 0) { $nb_0 = $cond; break; } else { $mem_0 = $add_ptr225_i; } return $mem_0 | 0; } else { if ($bytes >>> 0 > 4294967231) { $nb_0 = -1; break; } $add143 = $bytes + 11 | 0; $and144 = $add143 & -8; $79 = HEAP32[11603] | 0; if (($79 | 0) == 0) { $nb_0 = $and144; break; } $sub_i107 = -$and144 | 0; $shr_i108 = $add143 >>> 8; do { if (($shr_i108 | 0) == 0) { $idx_0_i = 0; } else { if ($and144 >>> 0 > 16777215) { $idx_0_i = 31; break; } $and_i112 = ($shr_i108 + 1048320 | 0) >>> 16 & 8; $shl_i113 = $shr_i108 << $and_i112; $and8_i = ($shl_i113 + 520192 | 0) >>> 16 & 4; $shl9_i = $shl_i113 << $and8_i; $and12_i = ($shl9_i + 245760 | 0) >>> 16 & 2; $add17_i = 14 - ($and8_i | $and_i112 | $and12_i) + ($shl9_i << $and12_i >>> 15) | 0; $idx_0_i = $and144 >>> (($add17_i + 7 | 0) >>> 0) & 1 | $add17_i << 1; } } while (0); $80 = HEAP32[46712 + ($idx_0_i << 2) >> 2] | 0; L780 : do { if (($80 | 0) == 0) { $v_2_i = 0; $rsize_2_i = $sub_i107; $t_1_i = 0; } else { if (($idx_0_i | 0) == 31) { $cond_i = 0; } else { $cond_i = 25 - ($idx_0_i >>> 1) | 0; } $v_0_i123 = 0; $rsize_0_i122 = $sub_i107; $t_0_i121 = $80; $sizebits_0_i = $and144 << $cond_i; $rst_0_i = 0; while (1) { $and32_i = HEAP32[$t_0_i121 + 4 >> 2] & -8; $sub33_i = $and32_i - $and144 | 0; if ($sub33_i >>> 0 < $rsize_0_i122 >>> 0) { if (($and32_i | 0) == ($and144 | 0)) { $v_2_i = $t_0_i121; $rsize_2_i = $sub33_i; $t_1_i = $t_0_i121; break L780; } else { $v_1_i = $t_0_i121; $rsize_1_i = $sub33_i; } } else { $v_1_i = $v_0_i123; $rsize_1_i = $rsize_0_i122; } $82 = HEAP32[$t_0_i121 + 20 >> 2] | 0; $83 = HEAP32[$t_0_i121 + 16 + ($sizebits_0_i >>> 31 << 2) >> 2] | 0; $rst_1_i = ($82 | 0) == 0 | ($82 | 0) == ($83 | 0) ? $rst_0_i : $82; if (($83 | 0) == 0) { $v_2_i = $v_1_i; $rsize_2_i = $rsize_1_i; $t_1_i = $rst_1_i; break; } else { $v_0_i123 = $v_1_i; $rsize_0_i122 = $rsize_1_i; $t_0_i121 = $83; $sizebits_0_i = $sizebits_0_i << 1; $rst_0_i = $rst_1_i; } } } } while (0); if (($t_1_i | 0) == 0 & ($v_2_i | 0) == 0) { $shl59_i = 2 << $idx_0_i; $and63_i = $79 & ($shl59_i | -$shl59_i); if (($and63_i | 0) == 0) { $nb_0 = $and144; break; } $sub69_i = ($and63_i & -$and63_i) - 1 | 0; $and72_i = $sub69_i >>> 12 & 16; $shr74_i = $sub69_i >>> ($and72_i >>> 0); $and76_i = $shr74_i >>> 5 & 8; $shr78_i = $shr74_i >>> ($and76_i >>> 0); $and80_i = $shr78_i >>> 2 & 4; $shr82_i = $shr78_i >>> ($and80_i >>> 0); $and84_i = $shr82_i >>> 1 & 2; $shr86_i = $shr82_i >>> ($and84_i >>> 0); $and88_i = $shr86_i >>> 1 & 1; $t_2_ph_i = HEAP32[46712 + (($and76_i | $and72_i | $and80_i | $and84_i | $and88_i) + ($shr86_i >>> ($and88_i >>> 0)) << 2) >> 2] | 0; } else { $t_2_ph_i = $t_1_i; } if (($t_2_ph_i | 0) == 0) { $rsize_3_lcssa_i = $rsize_2_i; $v_3_lcssa_i = $v_2_i; } else { $t_224_i = $t_2_ph_i; $rsize_325_i = $rsize_2_i; $v_326_i = $v_2_i; while (1) { $sub100_i = (HEAP32[$t_224_i + 4 >> 2] & -8) - $and144 | 0; $cmp101_i = $sub100_i >>> 0 < $rsize_325_i >>> 0; $sub100_rsize_3_i = $cmp101_i ? $sub100_i : $rsize_325_i; $t_2_v_3_i = $cmp101_i ? $t_224_i : $v_326_i; $86 = HEAP32[$t_224_i + 16 >> 2] | 0; if (($86 | 0) != 0) { $t_224_i = $86; $rsize_325_i = $sub100_rsize_3_i; $v_326_i = $t_2_v_3_i; continue; } $87 = HEAP32[$t_224_i + 20 >> 2] | 0; if (($87 | 0) == 0) { $rsize_3_lcssa_i = $sub100_rsize_3_i; $v_3_lcssa_i = $t_2_v_3_i; break; } else { $t_224_i = $87; $rsize_325_i = $sub100_rsize_3_i; $v_326_i = $t_2_v_3_i; } } } if (($v_3_lcssa_i | 0) == 0) { $nb_0 = $and144; break; } if ($rsize_3_lcssa_i >>> 0 >= ((HEAP32[11604] | 0) - $and144 | 0) >>> 0) { $nb_0 = $and144; break; } $89 = $v_3_lcssa_i; $90 = HEAP32[11606] | 0; if ($89 >>> 0 < $90 >>> 0) { _abort(); return 0; } $add_ptr_i128 = $89 + $and144 | 0; $91 = $add_ptr_i128; if ($89 >>> 0 >= $add_ptr_i128 >>> 0) { _abort(); return 0; } $92 = HEAP32[$v_3_lcssa_i + 24 >> 2] | 0; $93 = HEAP32[$v_3_lcssa_i + 12 >> 2] | 0; do { if (($93 | 0) == ($v_3_lcssa_i | 0)) { $arrayidx150_i = $v_3_lcssa_i + 20 | 0; $98 = HEAP32[$arrayidx150_i >> 2] | 0; if (($98 | 0) == 0) { $arrayidx154_i133 = $v_3_lcssa_i + 16 | 0; $99 = HEAP32[$arrayidx154_i133 >> 2] | 0; if (($99 | 0) == 0) { $R_1_i139 = 0; break; } else { $R_0_i137 = $99; $RP_0_i136 = $arrayidx154_i133; } } else { $R_0_i137 = $98; $RP_0_i136 = $arrayidx150_i; } while (1) { $arrayidx160_i = $R_0_i137 + 20 | 0; $100 = HEAP32[$arrayidx160_i >> 2] | 0; if (($100 | 0) != 0) { $R_0_i137 = $100; $RP_0_i136 = $arrayidx160_i; continue; } $arrayidx164_i = $R_0_i137 + 16 | 0; $101 = HEAP32[$arrayidx164_i >> 2] | 0; if (($101 | 0) == 0) { break; } else { $R_0_i137 = $101; $RP_0_i136 = $arrayidx164_i; } } if ($RP_0_i136 >>> 0 < $90 >>> 0) { _abort(); return 0; } else { HEAP32[$RP_0_i136 >> 2] = 0; $R_1_i139 = $R_0_i137; break; } } else { $94 = HEAP32[$v_3_lcssa_i + 8 >> 2] | 0; if ($94 >>> 0 < $90 >>> 0) { _abort(); return 0; } $bk135_i = $94 + 12 | 0; if ((HEAP32[$bk135_i >> 2] | 0) != ($v_3_lcssa_i | 0)) { _abort(); return 0; } $fd138_i = $93 + 8 | 0; if ((HEAP32[$fd138_i >> 2] | 0) == ($v_3_lcssa_i | 0)) { HEAP32[$bk135_i >> 2] = $93; HEAP32[$fd138_i >> 2] = $94; $R_1_i139 = $93; break; } else { _abort(); return 0; } } } while (0); L830 : do { if (($92 | 0) != 0) { $index_i140 = $v_3_lcssa_i + 28 | 0; $arrayidx183_i = 46712 + (HEAP32[$index_i140 >> 2] << 2) | 0; do { if (($v_3_lcssa_i | 0) == (HEAP32[$arrayidx183_i >> 2] | 0)) { HEAP32[$arrayidx183_i >> 2] = $R_1_i139; if (($R_1_i139 | 0) != 0) { break; } HEAP32[11603] = HEAP32[11603] & ~(1 << HEAP32[$index_i140 >> 2]); break L830; } else { if ($92 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); return 0; } $arrayidx203_i = $92 + 16 | 0; if ((HEAP32[$arrayidx203_i >> 2] | 0) == ($v_3_lcssa_i | 0)) { HEAP32[$arrayidx203_i >> 2] = $R_1_i139; } else { HEAP32[$92 + 20 >> 2] = $R_1_i139; } if (($R_1_i139 | 0) == 0) { break L830; } } } while (0); if ($R_1_i139 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); return 0; } HEAP32[$R_1_i139 + 24 >> 2] = $92; $112 = HEAP32[$v_3_lcssa_i + 16 >> 2] | 0; do { if (($112 | 0) != 0) { if ($112 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); return 0; } else { HEAP32[$R_1_i139 + 16 >> 2] = $112; HEAP32[$112 + 24 >> 2] = $R_1_i139; break; } } } while (0); $115 = HEAP32[$v_3_lcssa_i + 20 >> 2] | 0; if (($115 | 0) == 0) { break; } if ($115 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); return 0; } else { HEAP32[$R_1_i139 + 20 >> 2] = $115; HEAP32[$115 + 24 >> 2] = $R_1_i139; break; } } } while (0); do { if ($rsize_3_lcssa_i >>> 0 < 16) { $add267_i = $rsize_3_lcssa_i + $and144 | 0; HEAP32[$v_3_lcssa_i + 4 >> 2] = $add267_i | 3; $118 = $89 + ($add267_i + 4) | 0; HEAP32[$118 >> 2] = HEAP32[$118 >> 2] | 1; } else { HEAP32[$v_3_lcssa_i + 4 >> 2] = $and144 | 3; HEAP32[$89 + ($and144 | 4) >> 2] = $rsize_3_lcssa_i | 1; HEAP32[$89 + ($rsize_3_lcssa_i + $and144) >> 2] = $rsize_3_lcssa_i; $shr282_i = $rsize_3_lcssa_i >>> 3; if ($rsize_3_lcssa_i >>> 0 < 256) { $shl287_i = $shr282_i << 1; $121 = 46448 + ($shl287_i << 2) | 0; $122 = HEAP32[11602] | 0; $shl290_i = 1 << $shr282_i; do { if (($122 & $shl290_i | 0) == 0) { HEAP32[11602] = $122 | $shl290_i; $F289_0_i = $121; $_pre_phi_i147 = 46448 + ($shl287_i + 2 << 2) | 0; } else { $123 = 46448 + ($shl287_i + 2 << 2) | 0; $124 = HEAP32[$123 >> 2] | 0; if ($124 >>> 0 >= (HEAP32[11606] | 0) >>> 0) { $F289_0_i = $124; $_pre_phi_i147 = $123; break; } _abort(); return 0; } } while (0); HEAP32[$_pre_phi_i147 >> 2] = $91; HEAP32[$F289_0_i + 12 >> 2] = $91; HEAP32[$89 + ($and144 + 8) >> 2] = $F289_0_i; HEAP32[$89 + ($and144 + 12) >> 2] = $121; break; } $129 = $add_ptr_i128; $shr317_i = $rsize_3_lcssa_i >>> 8; do { if (($shr317_i | 0) == 0) { $I315_0_i = 0; } else { if ($rsize_3_lcssa_i >>> 0 > 16777215) { $I315_0_i = 31; break; } $and330_i = ($shr317_i + 1048320 | 0) >>> 16 & 8; $shl332_i = $shr317_i << $and330_i; $and335_i = ($shl332_i + 520192 | 0) >>> 16 & 4; $shl337_i = $shl332_i << $and335_i; $and340_i = ($shl337_i + 245760 | 0) >>> 16 & 2; $add345_i = 14 - ($and335_i | $and330_i | $and340_i) + ($shl337_i << $and340_i >>> 15) | 0; $I315_0_i = $rsize_3_lcssa_i >>> (($add345_i + 7 | 0) >>> 0) & 1 | $add345_i << 1; } } while (0); $arrayidx354_i = 46712 + ($I315_0_i << 2) | 0; HEAP32[$89 + ($and144 + 28) >> 2] = $I315_0_i; HEAP32[$89 + ($and144 + 20) >> 2] = 0; HEAP32[$89 + ($and144 + 16) >> 2] = 0; $132 = HEAP32[11603] | 0; $shl361_i = 1 << $I315_0_i; if (($132 & $shl361_i | 0) == 0) { HEAP32[11603] = $132 | $shl361_i; HEAP32[$arrayidx354_i >> 2] = $129; HEAP32[$89 + ($and144 + 24) >> 2] = $arrayidx354_i; HEAP32[$89 + ($and144 + 12) >> 2] = $129; HEAP32[$89 + ($and144 + 8) >> 2] = $129; break; } if (($I315_0_i | 0) == 31) { $cond382_i = 0; } else { $cond382_i = 25 - ($I315_0_i >>> 1) | 0; } $K372_0_i = $rsize_3_lcssa_i << $cond382_i; $T_0_i = HEAP32[$arrayidx354_i >> 2] | 0; while (1) { if ((HEAP32[$T_0_i + 4 >> 2] & -8 | 0) == ($rsize_3_lcssa_i | 0)) { break; } $arrayidx393_i = $T_0_i + 16 + ($K372_0_i >>> 31 << 2) | 0; $139 = HEAP32[$arrayidx393_i >> 2] | 0; if (($139 | 0) == 0) { label = 648; break; } else { $K372_0_i = $K372_0_i << 1; $T_0_i = $139; } } if ((label | 0) == 648) { if ($arrayidx393_i >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); return 0; } else { HEAP32[$arrayidx393_i >> 2] = $129; HEAP32[$89 + ($and144 + 24) >> 2] = $T_0_i; HEAP32[$89 + ($and144 + 12) >> 2] = $129; HEAP32[$89 + ($and144 + 8) >> 2] = $129; break; } } $fd412_i = $T_0_i + 8 | 0; $145 = HEAP32[$fd412_i >> 2] | 0; $147 = HEAP32[11606] | 0; if ($T_0_i >>> 0 < $147 >>> 0) { _abort(); return 0; } if ($145 >>> 0 < $147 >>> 0) { _abort(); return 0; } else { HEAP32[$145 + 12 >> 2] = $129; HEAP32[$fd412_i >> 2] = $129; HEAP32[$89 + ($and144 + 8) >> 2] = $145; HEAP32[$89 + ($and144 + 12) >> 2] = $T_0_i; HEAP32[$89 + ($and144 + 24) >> 2] = 0; break; } } } while (0); $add_ptr436_i = $v_3_lcssa_i + 8 | 0; if (($add_ptr436_i | 0) == 0) { $nb_0 = $and144; break; } else { $mem_0 = $add_ptr436_i; } return $mem_0 | 0; } } while (0); $153 = HEAP32[11604] | 0; if ($nb_0 >>> 0 <= $153 >>> 0) { $sub159 = $153 - $nb_0 | 0; $154 = HEAP32[11607] | 0; if ($sub159 >>> 0 > 15) { $155 = $154; HEAP32[11607] = $155 + $nb_0; HEAP32[11604] = $sub159; HEAP32[$155 + ($nb_0 + 4) >> 2] = $sub159 | 1; HEAP32[$155 + $153 >> 2] = $sub159; HEAP32[$154 + 4 >> 2] = $nb_0 | 3; } else { HEAP32[11604] = 0; HEAP32[11607] = 0; HEAP32[$154 + 4 >> 2] = $153 | 3; $159 = $154 + ($153 + 4) | 0; HEAP32[$159 >> 2] = HEAP32[$159 >> 2] | 1; } $mem_0 = $154 + 8 | 0; return $mem_0 | 0; } $162 = HEAP32[11605] | 0; if ($nb_0 >>> 0 < $162 >>> 0) { $sub187 = $162 - $nb_0 | 0; HEAP32[11605] = $sub187; $163 = HEAP32[11608] | 0; $164 = $163; HEAP32[11608] = $164 + $nb_0; HEAP32[$164 + ($nb_0 + 4) >> 2] = $sub187 | 1; HEAP32[$163 + 4 >> 2] = $nb_0 | 3; $mem_0 = $163 + 8 | 0; return $mem_0 | 0; } do { if ((HEAP32[10824] | 0) == 0) { $call_i_i = _sysconf(8) | 0; if (($call_i_i - 1 & $call_i_i | 0) == 0) { HEAP32[10826] = $call_i_i; HEAP32[10825] = $call_i_i; HEAP32[10827] = -1; HEAP32[10828] = 2097152; HEAP32[10829] = 0; HEAP32[11713] = 0; HEAP32[10824] = (_time(0) | 0) & -16 ^ 1431655768; break; } else { _abort(); return 0; } } } while (0); $add_i149 = $nb_0 + 48 | 0; $169 = HEAP32[10826] | 0; $sub_i150 = $nb_0 + 47 | 0; $add9_i = $169 + $sub_i150 | 0; $neg_i151 = -$169 | 0; $and11_i = $add9_i & $neg_i151; if ($and11_i >>> 0 <= $nb_0 >>> 0) { $mem_0 = 0; return $mem_0 | 0; } $170 = HEAP32[11712] | 0; do { if (($170 | 0) != 0) { $171 = HEAP32[11710] | 0; $add17_i152 = $171 + $and11_i | 0; if ($add17_i152 >>> 0 <= $171 >>> 0 | $add17_i152 >>> 0 > $170 >>> 0) { $mem_0 = 0; } else { break; } return $mem_0 | 0; } } while (0); L922 : do { if ((HEAP32[11713] & 4 | 0) == 0) { $173 = HEAP32[11608] | 0; L924 : do { if (($173 | 0) == 0) { label = 678; } else { $174 = $173; $sp_0_i_i = 46856; while (1) { $base_i_i = $sp_0_i_i | 0; $175 = HEAP32[$base_i_i >> 2] | 0; if ($175 >>> 0 <= $174 >>> 0) { $size_i_i = $sp_0_i_i + 4 | 0; if (($175 + (HEAP32[$size_i_i >> 2] | 0) | 0) >>> 0 > $174 >>> 0) { break; } } $177 = HEAP32[$sp_0_i_i + 8 >> 2] | 0; if (($177 | 0) == 0) { label = 678; break L924; } else { $sp_0_i_i = $177; } } if (($sp_0_i_i | 0) == 0) { label = 678; break; } $and77_i = $add9_i - (HEAP32[11605] | 0) & $neg_i151; if ($and77_i >>> 0 >= 2147483647) { $tsize_0758385_i = 0; break; } $call80_i = _sbrk($and77_i | 0) | 0; $cmp82_i = ($call80_i | 0) == ((HEAP32[$base_i_i >> 2] | 0) + (HEAP32[$size_i_i >> 2] | 0) | 0); $tbase_0_i = $cmp82_i ? $call80_i : -1; $tsize_0_i = $cmp82_i ? $and77_i : 0; $br_0_i = $call80_i; $ssize_1_i = $and77_i; label = 687; } } while (0); do { if ((label | 0) == 678) { $call34_i = _sbrk(0) | 0; if (($call34_i | 0) == -1) { $tsize_0758385_i = 0; break; } $178 = $call34_i; $179 = HEAP32[10825] | 0; $sub38_i = $179 - 1 | 0; if (($sub38_i & $178 | 0) == 0) { $ssize_0_i = $and11_i; } else { $ssize_0_i = $and11_i - $178 + ($sub38_i + $178 & -$179) | 0; } $180 = HEAP32[11710] | 0; $add51_i = $180 + $ssize_0_i | 0; if (!($ssize_0_i >>> 0 > $nb_0 >>> 0 & $ssize_0_i >>> 0 < 2147483647)) { $tsize_0758385_i = 0; break; } $181 = HEAP32[11712] | 0; if (($181 | 0) != 0) { if ($add51_i >>> 0 <= $180 >>> 0 | $add51_i >>> 0 > $181 >>> 0) { $tsize_0758385_i = 0; break; } } $call65_i = _sbrk($ssize_0_i | 0) | 0; $cmp66_i160 = ($call65_i | 0) == ($call34_i | 0); $tbase_0_i = $cmp66_i160 ? $call34_i : -1; $tsize_0_i = $cmp66_i160 ? $ssize_0_i : 0; $br_0_i = $call65_i; $ssize_1_i = $ssize_0_i; label = 687; } } while (0); L944 : do { if ((label | 0) == 687) { $sub109_i = -$ssize_1_i | 0; if (($tbase_0_i | 0) != -1) { $tsize_291_i = $tsize_0_i; $tbase_292_i = $tbase_0_i; label = 698; break L922; } do { if (($br_0_i | 0) != -1 & $ssize_1_i >>> 0 < 2147483647 & $ssize_1_i >>> 0 < $add_i149 >>> 0) { $185 = HEAP32[10826] | 0; $and101_i = $sub_i150 - $ssize_1_i + $185 & -$185; if ($and101_i >>> 0 >= 2147483647) { $ssize_2_i = $ssize_1_i; break; } if ((_sbrk($and101_i | 0) | 0) == -1) { _sbrk($sub109_i | 0) | 0; $tsize_0758385_i = $tsize_0_i; break L944; } else { $ssize_2_i = $and101_i + $ssize_1_i | 0; break; } } else { $ssize_2_i = $ssize_1_i; } } while (0); if (($br_0_i | 0) == -1) { $tsize_0758385_i = $tsize_0_i; } else { $tsize_291_i = $ssize_2_i; $tbase_292_i = $br_0_i; label = 698; break L922; } } } while (0); HEAP32[11713] = HEAP32[11713] | 4; $tsize_1_i = $tsize_0758385_i; label = 695; } else { $tsize_1_i = 0; label = 695; } } while (0); do { if ((label | 0) == 695) { if ($and11_i >>> 0 >= 2147483647) { break; } $call128_i = _sbrk($and11_i | 0) | 0; $call129_i = _sbrk(0) | 0; if (!(($call129_i | 0) != -1 & ($call128_i | 0) != -1 & $call128_i >>> 0 < $call129_i >>> 0)) { break; } $sub_ptr_sub_i = $call129_i - $call128_i | 0; $cmp138_i166 = $sub_ptr_sub_i >>> 0 > ($nb_0 + 40 | 0) >>> 0; $call128_tbase_1_i = $cmp138_i166 ? $call128_i : -1; if (($call128_tbase_1_i | 0) != -1) { $tsize_291_i = $cmp138_i166 ? $sub_ptr_sub_i : $tsize_1_i; $tbase_292_i = $call128_tbase_1_i; label = 698; } } } while (0); do { if ((label | 0) == 698) { $add147_i = (HEAP32[11710] | 0) + $tsize_291_i | 0; HEAP32[11710] = $add147_i; if ($add147_i >>> 0 > (HEAP32[11711] | 0) >>> 0) { HEAP32[11711] = $add147_i; } $189 = HEAP32[11608] | 0; L964 : do { if (($189 | 0) == 0) { $190 = HEAP32[11606] | 0; if (($190 | 0) == 0 | $tbase_292_i >>> 0 < $190 >>> 0) { HEAP32[11606] = $tbase_292_i; } HEAP32[11714] = $tbase_292_i; HEAP32[11715] = $tsize_291_i; HEAP32[11717] = 0; HEAP32[11611] = HEAP32[10824]; HEAP32[11610] = -1; $i_02_i_i = 0; do { $shl_i_i = $i_02_i_i << 1; $192 = 46448 + ($shl_i_i << 2) | 0; HEAP32[46448 + ($shl_i_i + 3 << 2) >> 2] = $192; HEAP32[46448 + ($shl_i_i + 2 << 2) >> 2] = $192; $i_02_i_i = $i_02_i_i + 1 | 0; } while ($i_02_i_i >>> 0 < 32); $195 = $tbase_292_i + 8 | 0; if (($195 & 7 | 0) == 0) { $cond_i_i = 0; } else { $cond_i_i = -$195 & 7; } $sub5_i_i = $tsize_291_i - 40 - $cond_i_i | 0; HEAP32[11608] = $tbase_292_i + $cond_i_i; HEAP32[11605] = $sub5_i_i; HEAP32[$tbase_292_i + ($cond_i_i + 4) >> 2] = $sub5_i_i | 1; HEAP32[$tbase_292_i + ($tsize_291_i - 36) >> 2] = 40; HEAP32[11609] = HEAP32[10828]; } else { $sp_0105_i = 46856; while (1) { $201 = HEAP32[$sp_0105_i >> 2] | 0; $size185_i = $sp_0105_i + 4 | 0; $202 = HEAP32[$size185_i >> 2] | 0; if (($tbase_292_i | 0) == ($201 + $202 | 0)) { label = 710; break; } $203 = HEAP32[$sp_0105_i + 8 >> 2] | 0; if (($203 | 0) == 0) { break; } else { $sp_0105_i = $203; } } do { if ((label | 0) == 710) { if ((HEAP32[$sp_0105_i + 12 >> 2] & 8 | 0) != 0) { break; } $205 = $189; if (!($205 >>> 0 >= $201 >>> 0 & $205 >>> 0 < $tbase_292_i >>> 0)) { break; } HEAP32[$size185_i >> 2] = $202 + $tsize_291_i; $206 = HEAP32[11608] | 0; $add212_i = (HEAP32[11605] | 0) + $tsize_291_i | 0; $208 = $206; $209 = $206 + 8 | 0; if (($209 & 7 | 0) == 0) { $cond_i28_i = 0; } else { $cond_i28_i = -$209 & 7; } $sub5_i30_i = $add212_i - $cond_i28_i | 0; HEAP32[11608] = $208 + $cond_i28_i; HEAP32[11605] = $sub5_i30_i; HEAP32[$208 + ($cond_i28_i + 4) >> 2] = $sub5_i30_i | 1; HEAP32[$208 + ($add212_i + 4) >> 2] = 40; HEAP32[11609] = HEAP32[10828]; break L964; } } while (0); if ($tbase_292_i >>> 0 < (HEAP32[11606] | 0) >>> 0) { HEAP32[11606] = $tbase_292_i; } $add_ptr224_i = $tbase_292_i + $tsize_291_i | 0; $sp_1101_i = 46856; while (1) { $base223_i = $sp_1101_i | 0; if ((HEAP32[$base223_i >> 2] | 0) == ($add_ptr224_i | 0)) { label = 720; break; } $217 = HEAP32[$sp_1101_i + 8 >> 2] | 0; if (($217 | 0) == 0) { break; } else { $sp_1101_i = $217; } } do { if ((label | 0) == 720) { if ((HEAP32[$sp_1101_i + 12 >> 2] & 8 | 0) != 0) { break; } HEAP32[$base223_i >> 2] = $tbase_292_i; $size242_i = $sp_1101_i + 4 | 0; HEAP32[$size242_i >> 2] = (HEAP32[$size242_i >> 2] | 0) + $tsize_291_i; $220 = $tbase_292_i + 8 | 0; if (($220 & 7 | 0) == 0) { $cond_i43_i = 0; } else { $cond_i43_i = -$220 & 7; } $222 = $tbase_292_i + ($tsize_291_i + 8) | 0; if (($222 & 7 | 0) == 0) { $cond15_i_i = 0; } else { $cond15_i_i = -$222 & 7; } $add_ptr16_i_i = $tbase_292_i + ($cond15_i_i + $tsize_291_i) | 0; $224 = $add_ptr16_i_i; $add_ptr4_sum_i50_i = $cond_i43_i + $nb_0 | 0; $add_ptr17_i_i = $tbase_292_i + $add_ptr4_sum_i50_i | 0; $225 = $add_ptr17_i_i; $sub18_i_i = $add_ptr16_i_i - ($tbase_292_i + $cond_i43_i) - $nb_0 | 0; HEAP32[$tbase_292_i + ($cond_i43_i + 4) >> 2] = $nb_0 | 3; do { if (($224 | 0) == (HEAP32[11608] | 0)) { $add_i_i = (HEAP32[11605] | 0) + $sub18_i_i | 0; HEAP32[11605] = $add_i_i; HEAP32[11608] = $225; HEAP32[$tbase_292_i + ($add_ptr4_sum_i50_i + 4) >> 2] = $add_i_i | 1; } else { if (($224 | 0) == (HEAP32[11607] | 0)) { $add26_i_i = (HEAP32[11604] | 0) + $sub18_i_i | 0; HEAP32[11604] = $add26_i_i; HEAP32[11607] = $225; HEAP32[$tbase_292_i + ($add_ptr4_sum_i50_i + 4) >> 2] = $add26_i_i | 1; HEAP32[$tbase_292_i + ($add26_i_i + $add_ptr4_sum_i50_i) >> 2] = $add26_i_i; break; } $add_ptr16_sum_i_i = $tsize_291_i + 4 | 0; $234 = HEAP32[$tbase_292_i + ($add_ptr16_sum_i_i + $cond15_i_i) >> 2] | 0; if (($234 & 3 | 0) == 1) { $and37_i_i = $234 & -8; $shr_i55_i = $234 >>> 3; L1009 : do { if ($234 >>> 0 < 256) { $236 = HEAP32[$tbase_292_i + (($cond15_i_i | 8) + $tsize_291_i) >> 2] | 0; $238 = HEAP32[$tbase_292_i + ($tsize_291_i + 12 + $cond15_i_i) >> 2] | 0; $239 = 46448 + ($shr_i55_i << 1 << 2) | 0; do { if (($236 | 0) != ($239 | 0)) { if ($236 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); return 0; } if ((HEAP32[$236 + 12 >> 2] | 0) == ($224 | 0)) { break; } _abort(); return 0; } } while (0); if (($238 | 0) == ($236 | 0)) { HEAP32[11602] = HEAP32[11602] & ~(1 << $shr_i55_i); break; } do { if (($238 | 0) == ($239 | 0)) { $fd68_pre_phi_i_i = $238 + 8 | 0; } else { if ($238 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); return 0; } $fd59_i_i = $238 + 8 | 0; if ((HEAP32[$fd59_i_i >> 2] | 0) == ($224 | 0)) { $fd68_pre_phi_i_i = $fd59_i_i; break; } _abort(); return 0; } } while (0); HEAP32[$236 + 12 >> 2] = $238; HEAP32[$fd68_pre_phi_i_i >> 2] = $236; } else { $247 = $add_ptr16_i_i; $249 = HEAP32[$tbase_292_i + (($cond15_i_i | 24) + $tsize_291_i) >> 2] | 0; $251 = HEAP32[$tbase_292_i + ($tsize_291_i + 12 + $cond15_i_i) >> 2] | 0; do { if (($251 | 0) == ($247 | 0)) { $add_ptr16_sum56_i_i = $cond15_i_i | 16; $258 = $tbase_292_i + ($add_ptr16_sum_i_i + $add_ptr16_sum56_i_i) | 0; $259 = HEAP32[$258 >> 2] | 0; if (($259 | 0) == 0) { $arrayidx99_i_i = $tbase_292_i + ($add_ptr16_sum56_i_i + $tsize_291_i) | 0; $260 = HEAP32[$arrayidx99_i_i >> 2] | 0; if (($260 | 0) == 0) { $R_1_i_i = 0; break; } else { $R_0_i_i = $260; $RP_0_i_i = $arrayidx99_i_i; } } else { $R_0_i_i = $259; $RP_0_i_i = $258; } while (1) { $arrayidx103_i_i = $R_0_i_i + 20 | 0; $261 = HEAP32[$arrayidx103_i_i >> 2] | 0; if (($261 | 0) != 0) { $R_0_i_i = $261; $RP_0_i_i = $arrayidx103_i_i; continue; } $arrayidx107_i_i = $R_0_i_i + 16 | 0; $262 = HEAP32[$arrayidx107_i_i >> 2] | 0; if (($262 | 0) == 0) { break; } else { $R_0_i_i = $262; $RP_0_i_i = $arrayidx107_i_i; } } if ($RP_0_i_i >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); return 0; } else { HEAP32[$RP_0_i_i >> 2] = 0; $R_1_i_i = $R_0_i_i; break; } } else { $253 = HEAP32[$tbase_292_i + (($cond15_i_i | 8) + $tsize_291_i) >> 2] | 0; if ($253 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); return 0; } $bk82_i_i = $253 + 12 | 0; if ((HEAP32[$bk82_i_i >> 2] | 0) != ($247 | 0)) { _abort(); return 0; } $fd85_i_i = $251 + 8 | 0; if ((HEAP32[$fd85_i_i >> 2] | 0) == ($247 | 0)) { HEAP32[$bk82_i_i >> 2] = $251; HEAP32[$fd85_i_i >> 2] = $253; $R_1_i_i = $251; break; } else { _abort(); return 0; } } } while (0); if (($249 | 0) == 0) { break; } $265 = $tbase_292_i + ($tsize_291_i + 28 + $cond15_i_i) | 0; $arrayidx123_i_i = 46712 + (HEAP32[$265 >> 2] << 2) | 0; do { if (($247 | 0) == (HEAP32[$arrayidx123_i_i >> 2] | 0)) { HEAP32[$arrayidx123_i_i >> 2] = $R_1_i_i; if (($R_1_i_i | 0) != 0) { break; } HEAP32[11603] = HEAP32[11603] & ~(1 << HEAP32[$265 >> 2]); break L1009; } else { if ($249 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); return 0; } $arrayidx143_i_i = $249 + 16 | 0; if ((HEAP32[$arrayidx143_i_i >> 2] | 0) == ($247 | 0)) { HEAP32[$arrayidx143_i_i >> 2] = $R_1_i_i; } else { HEAP32[$249 + 20 >> 2] = $R_1_i_i; } if (($R_1_i_i | 0) == 0) { break L1009; } } } while (0); if ($R_1_i_i >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); return 0; } HEAP32[$R_1_i_i + 24 >> 2] = $249; $add_ptr16_sum2728_i_i = $cond15_i_i | 16; $275 = HEAP32[$tbase_292_i + ($add_ptr16_sum2728_i_i + $tsize_291_i) >> 2] | 0; do { if (($275 | 0) != 0) { if ($275 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); return 0; } else { HEAP32[$R_1_i_i + 16 >> 2] = $275; HEAP32[$275 + 24 >> 2] = $R_1_i_i; break; } } } while (0); $279 = HEAP32[$tbase_292_i + ($add_ptr16_sum_i_i + $add_ptr16_sum2728_i_i) >> 2] | 0; if (($279 | 0) == 0) { break; } if ($279 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); return 0; } else { HEAP32[$R_1_i_i + 20 >> 2] = $279; HEAP32[$279 + 24 >> 2] = $R_1_i_i; break; } } } while (0); $oldfirst_0_i_i = $tbase_292_i + (($and37_i_i | $cond15_i_i) + $tsize_291_i) | 0; $qsize_0_i_i = $and37_i_i + $sub18_i_i | 0; } else { $oldfirst_0_i_i = $224; $qsize_0_i_i = $sub18_i_i; } $head208_i_i = $oldfirst_0_i_i + 4 | 0; HEAP32[$head208_i_i >> 2] = HEAP32[$head208_i_i >> 2] & -2; HEAP32[$tbase_292_i + ($add_ptr4_sum_i50_i + 4) >> 2] = $qsize_0_i_i | 1; HEAP32[$tbase_292_i + ($qsize_0_i_i + $add_ptr4_sum_i50_i) >> 2] = $qsize_0_i_i; $shr214_i_i = $qsize_0_i_i >>> 3; if ($qsize_0_i_i >>> 0 < 256) { $shl221_i_i = $shr214_i_i << 1; $285 = 46448 + ($shl221_i_i << 2) | 0; $286 = HEAP32[11602] | 0; $shl226_i_i = 1 << $shr214_i_i; do { if (($286 & $shl226_i_i | 0) == 0) { HEAP32[11602] = $286 | $shl226_i_i; $F224_0_i_i = $285; $_pre_phi_i68_i = 46448 + ($shl221_i_i + 2 << 2) | 0; } else { $287 = 46448 + ($shl221_i_i + 2 << 2) | 0; $288 = HEAP32[$287 >> 2] | 0; if ($288 >>> 0 >= (HEAP32[11606] | 0) >>> 0) { $F224_0_i_i = $288; $_pre_phi_i68_i = $287; break; } _abort(); return 0; } } while (0); HEAP32[$_pre_phi_i68_i >> 2] = $225; HEAP32[$F224_0_i_i + 12 >> 2] = $225; HEAP32[$tbase_292_i + ($add_ptr4_sum_i50_i + 8) >> 2] = $F224_0_i_i; HEAP32[$tbase_292_i + ($add_ptr4_sum_i50_i + 12) >> 2] = $285; break; } $293 = $add_ptr17_i_i; $shr253_i_i = $qsize_0_i_i >>> 8; do { if (($shr253_i_i | 0) == 0) { $I252_0_i_i = 0; } else { if ($qsize_0_i_i >>> 0 > 16777215) { $I252_0_i_i = 31; break; } $and264_i_i = ($shr253_i_i + 1048320 | 0) >>> 16 & 8; $shl265_i_i = $shr253_i_i << $and264_i_i; $and268_i_i = ($shl265_i_i + 520192 | 0) >>> 16 & 4; $shl270_i_i = $shl265_i_i << $and268_i_i; $and273_i_i = ($shl270_i_i + 245760 | 0) >>> 16 & 2; $add278_i_i = 14 - ($and268_i_i | $and264_i_i | $and273_i_i) + ($shl270_i_i << $and273_i_i >>> 15) | 0; $I252_0_i_i = $qsize_0_i_i >>> (($add278_i_i + 7 | 0) >>> 0) & 1 | $add278_i_i << 1; } } while (0); $arrayidx287_i_i = 46712 + ($I252_0_i_i << 2) | 0; HEAP32[$tbase_292_i + ($add_ptr4_sum_i50_i + 28) >> 2] = $I252_0_i_i; HEAP32[$tbase_292_i + ($add_ptr4_sum_i50_i + 20) >> 2] = 0; HEAP32[$tbase_292_i + ($add_ptr4_sum_i50_i + 16) >> 2] = 0; $296 = HEAP32[11603] | 0; $shl294_i_i = 1 << $I252_0_i_i; if (($296 & $shl294_i_i | 0) == 0) { HEAP32[11603] = $296 | $shl294_i_i; HEAP32[$arrayidx287_i_i >> 2] = $293; HEAP32[$tbase_292_i + ($add_ptr4_sum_i50_i + 24) >> 2] = $arrayidx287_i_i; HEAP32[$tbase_292_i + ($add_ptr4_sum_i50_i + 12) >> 2] = $293; HEAP32[$tbase_292_i + ($add_ptr4_sum_i50_i + 8) >> 2] = $293; break; } if (($I252_0_i_i | 0) == 31) { $cond315_i_i = 0; } else { $cond315_i_i = 25 - ($I252_0_i_i >>> 1) | 0; } $K305_0_i_i = $qsize_0_i_i << $cond315_i_i; $T_0_i69_i = HEAP32[$arrayidx287_i_i >> 2] | 0; while (1) { if ((HEAP32[$T_0_i69_i + 4 >> 2] & -8 | 0) == ($qsize_0_i_i | 0)) { break; } $arrayidx325_i_i = $T_0_i69_i + 16 + ($K305_0_i_i >>> 31 << 2) | 0; $303 = HEAP32[$arrayidx325_i_i >> 2] | 0; if (($303 | 0) == 0) { label = 793; break; } else { $K305_0_i_i = $K305_0_i_i << 1; $T_0_i69_i = $303; } } if ((label | 0) == 793) { if ($arrayidx325_i_i >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); return 0; } else { HEAP32[$arrayidx325_i_i >> 2] = $293; HEAP32[$tbase_292_i + ($add_ptr4_sum_i50_i + 24) >> 2] = $T_0_i69_i; HEAP32[$tbase_292_i + ($add_ptr4_sum_i50_i + 12) >> 2] = $293; HEAP32[$tbase_292_i + ($add_ptr4_sum_i50_i + 8) >> 2] = $293; break; } } $fd344_i_i = $T_0_i69_i + 8 | 0; $309 = HEAP32[$fd344_i_i >> 2] | 0; $311 = HEAP32[11606] | 0; if ($T_0_i69_i >>> 0 < $311 >>> 0) { _abort(); return 0; } if ($309 >>> 0 < $311 >>> 0) { _abort(); return 0; } else { HEAP32[$309 + 12 >> 2] = $293; HEAP32[$fd344_i_i >> 2] = $293; HEAP32[$tbase_292_i + ($add_ptr4_sum_i50_i + 8) >> 2] = $309; HEAP32[$tbase_292_i + ($add_ptr4_sum_i50_i + 12) >> 2] = $T_0_i69_i; HEAP32[$tbase_292_i + ($add_ptr4_sum_i50_i + 24) >> 2] = 0; break; } } } while (0); $mem_0 = $tbase_292_i + ($cond_i43_i | 8) | 0; return $mem_0 | 0; } } while (0); $316 = $189; $sp_0_i_i_i = 46856; while (1) { $317 = HEAP32[$sp_0_i_i_i >> 2] | 0; if ($317 >>> 0 <= $316 >>> 0) { $318 = HEAP32[$sp_0_i_i_i + 4 >> 2] | 0; $add_ptr_i_i_i = $317 + $318 | 0; if ($add_ptr_i_i_i >>> 0 > $316 >>> 0) { break; } } $sp_0_i_i_i = HEAP32[$sp_0_i_i_i + 8 >> 2] | 0; } $320 = $317 + ($318 - 39) | 0; if (($320 & 7 | 0) == 0) { $cond_i18_i = 0; } else { $cond_i18_i = -$320 & 7; } $add_ptr7_i_i = $317 + ($318 - 47 + $cond_i18_i) | 0; $cond13_i_i = $add_ptr7_i_i >>> 0 < ($189 + 16 | 0) >>> 0 ? $316 : $add_ptr7_i_i; $add_ptr14_i_i = $cond13_i_i + 8 | 0; $323 = $tbase_292_i + 8 | 0; if (($323 & 7 | 0) == 0) { $cond_i_i_i = 0; } else { $cond_i_i_i = -$323 & 7; } $sub5_i_i_i = $tsize_291_i - 40 - $cond_i_i_i | 0; HEAP32[11608] = $tbase_292_i + $cond_i_i_i; HEAP32[11605] = $sub5_i_i_i; HEAP32[$tbase_292_i + ($cond_i_i_i + 4) >> 2] = $sub5_i_i_i | 1; HEAP32[$tbase_292_i + ($tsize_291_i - 36) >> 2] = 40; HEAP32[11609] = HEAP32[10828]; HEAP32[$cond13_i_i + 4 >> 2] = 27; HEAP32[$add_ptr14_i_i >> 2] = HEAP32[11714]; HEAP32[$add_ptr14_i_i + 4 >> 2] = HEAP32[46860 >> 2]; HEAP32[$add_ptr14_i_i + 8 >> 2] = HEAP32[46864 >> 2]; HEAP32[$add_ptr14_i_i + 12 >> 2] = HEAP32[46868 >> 2]; HEAP32[11714] = $tbase_292_i; HEAP32[11715] = $tsize_291_i; HEAP32[11717] = 0; HEAP32[11716] = $add_ptr14_i_i; $330 = $cond13_i_i + 28 | 0; HEAP32[$330 >> 2] = 7; if (($cond13_i_i + 32 | 0) >>> 0 < $add_ptr_i_i_i >>> 0) { $add_ptr2416_i_i = $330; while (1) { $332 = $add_ptr2416_i_i + 4 | 0; HEAP32[$332 >> 2] = 7; if (($add_ptr2416_i_i + 8 | 0) >>> 0 < $add_ptr_i_i_i >>> 0) { $add_ptr2416_i_i = $332; } else { break; } } } if (($cond13_i_i | 0) == ($316 | 0)) { break; } $sub_ptr_sub_i_i = $cond13_i_i - $189 | 0; $335 = $316 + ($sub_ptr_sub_i_i + 4) | 0; HEAP32[$335 >> 2] = HEAP32[$335 >> 2] & -2; HEAP32[$189 + 4 >> 2] = $sub_ptr_sub_i_i | 1; HEAP32[$316 + $sub_ptr_sub_i_i >> 2] = $sub_ptr_sub_i_i; $shr_i_i = $sub_ptr_sub_i_i >>> 3; if ($sub_ptr_sub_i_i >>> 0 < 256) { $shl_i21_i = $shr_i_i << 1; $337 = 46448 + ($shl_i21_i << 2) | 0; $338 = HEAP32[11602] | 0; $shl39_i_i = 1 << $shr_i_i; do { if (($338 & $shl39_i_i | 0) == 0) { HEAP32[11602] = $338 | $shl39_i_i; $F_0_i_i = $337; $_pre_phi_i_i = 46448 + ($shl_i21_i + 2 << 2) | 0; } else { $339 = 46448 + ($shl_i21_i + 2 << 2) | 0; $340 = HEAP32[$339 >> 2] | 0; if ($340 >>> 0 >= (HEAP32[11606] | 0) >>> 0) { $F_0_i_i = $340; $_pre_phi_i_i = $339; break; } _abort(); return 0; } } while (0); HEAP32[$_pre_phi_i_i >> 2] = $189; HEAP32[$F_0_i_i + 12 >> 2] = $189; HEAP32[$189 + 8 >> 2] = $F_0_i_i; HEAP32[$189 + 12 >> 2] = $337; break; } $343 = $189; $shr58_i_i = $sub_ptr_sub_i_i >>> 8; do { if (($shr58_i_i | 0) == 0) { $I57_0_i_i = 0; } else { if ($sub_ptr_sub_i_i >>> 0 > 16777215) { $I57_0_i_i = 31; break; } $and69_i_i = ($shr58_i_i + 1048320 | 0) >>> 16 & 8; $shl70_i_i = $shr58_i_i << $and69_i_i; $and73_i_i = ($shl70_i_i + 520192 | 0) >>> 16 & 4; $shl75_i_i = $shl70_i_i << $and73_i_i; $and78_i_i = ($shl75_i_i + 245760 | 0) >>> 16 & 2; $add83_i_i = 14 - ($and73_i_i | $and69_i_i | $and78_i_i) + ($shl75_i_i << $and78_i_i >>> 15) | 0; $I57_0_i_i = $sub_ptr_sub_i_i >>> (($add83_i_i + 7 | 0) >>> 0) & 1 | $add83_i_i << 1; } } while (0); $arrayidx91_i_i = 46712 + ($I57_0_i_i << 2) | 0; HEAP32[$189 + 28 >> 2] = $I57_0_i_i; HEAP32[$189 + 20 >> 2] = 0; HEAP32[$189 + 16 >> 2] = 0; $345 = HEAP32[11603] | 0; $shl95_i_i = 1 << $I57_0_i_i; if (($345 & $shl95_i_i | 0) == 0) { HEAP32[11603] = $345 | $shl95_i_i; HEAP32[$arrayidx91_i_i >> 2] = $343; HEAP32[$189 + 24 >> 2] = $arrayidx91_i_i; HEAP32[$189 + 12 >> 2] = $189; HEAP32[$189 + 8 >> 2] = $189; break; } if (($I57_0_i_i | 0) == 31) { $cond115_i_i = 0; } else { $cond115_i_i = 25 - ($I57_0_i_i >>> 1) | 0; } $K105_0_i_i = $sub_ptr_sub_i_i << $cond115_i_i; $T_0_i_i = HEAP32[$arrayidx91_i_i >> 2] | 0; while (1) { if ((HEAP32[$T_0_i_i + 4 >> 2] & -8 | 0) == ($sub_ptr_sub_i_i | 0)) { break; } $arrayidx126_i_i = $T_0_i_i + 16 + ($K105_0_i_i >>> 31 << 2) | 0; $348 = HEAP32[$arrayidx126_i_i >> 2] | 0; if (($348 | 0) == 0) { label = 828; break; } else { $K105_0_i_i = $K105_0_i_i << 1; $T_0_i_i = $348; } } if ((label | 0) == 828) { if ($arrayidx126_i_i >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); return 0; } else { HEAP32[$arrayidx126_i_i >> 2] = $343; HEAP32[$189 + 24 >> 2] = $T_0_i_i; HEAP32[$189 + 12 >> 2] = $189; HEAP32[$189 + 8 >> 2] = $189; break; } } $fd145_i_i = $T_0_i_i + 8 | 0; $351 = HEAP32[$fd145_i_i >> 2] | 0; $353 = HEAP32[11606] | 0; if ($T_0_i_i >>> 0 < $353 >>> 0) { _abort(); return 0; } if ($351 >>> 0 < $353 >>> 0) { _abort(); return 0; } else { HEAP32[$351 + 12 >> 2] = $343; HEAP32[$fd145_i_i >> 2] = $343; HEAP32[$189 + 8 >> 2] = $351; HEAP32[$189 + 12 >> 2] = $T_0_i_i; HEAP32[$189 + 24 >> 2] = 0; break; } } } while (0); $355 = HEAP32[11605] | 0; if ($355 >>> 0 <= $nb_0 >>> 0) { break; } $sub253_i = $355 - $nb_0 | 0; HEAP32[11605] = $sub253_i; $356 = HEAP32[11608] | 0; $357 = $356; HEAP32[11608] = $357 + $nb_0; HEAP32[$357 + ($nb_0 + 4) >> 2] = $sub253_i | 1; HEAP32[$356 + 4 >> 2] = $nb_0 | 3; $mem_0 = $356 + 8 | 0; return $mem_0 | 0; } } while (0); HEAP32[(___errno_location() | 0) >> 2] = 12; $mem_0 = 0; return $mem_0 | 0; } function _free($mem) { $mem = $mem | 0; var $add_ptr = 0, $0 = 0, $1 = 0, $3 = 0, $and = 0, $and5 = 0, $add_ptr6 = 0, $4 = 0, $5 = 0, $add_ptr_sum232 = 0, $add_ptr16 = 0, $6 = 0, $add17 = 0, $shr = 0, $9 = 0, $11 = 0, $12 = 0, $fd56 = 0, $fd67_pre_phi = 0, $18 = 0, $20 = 0, $22 = 0, $24 = 0, $bk82 = 0, $fd86 = 0, $28 = 0, $29 = 0, $arrayidx103 = 0, $30 = 0, $RP_0 = 0, $R_0 = 0, $arrayidx108 = 0, $31 = 0, $arrayidx113 = 0, $32 = 0, $R_1 = 0, $34 = 0, $arrayidx130 = 0, $arrayidx149 = 0, $44 = 0, $48 = 0, $51 = 0, $psize_0 = 0, $p_0 = 0, $55 = 0, $56 = 0, $57 = 0, $add243 = 0, $add258 = 0, $add266 = 0, $shr267 = 0, $66 = 0, $68 = 0, $69 = 0, $fd310 = 0, $fd321_pre_phi = 0, $77 = 0, $79 = 0, $81 = 0, $83 = 0, $bk342 = 0, $fd346 = 0, $88 = 0, $89 = 0, $arrayidx366 = 0, $90 = 0, $RP359_0 = 0, $R331_0 = 0, $arrayidx373 = 0, $91 = 0, $arrayidx378 = 0, $92 = 0, $R331_1 = 0, $95 = 0, $arrayidx399 = 0, $arrayidx418 = 0, $105 = 0, $109 = 0, $psize_1 = 0, $shr497 = 0, $shl504 = 0, $113 = 0, $114 = 0, $shl507 = 0, $115 = 0, $116 = 0, $_pre_phi = 0, $F506_0 = 0, $119 = 0, $shr531 = 0, $and541 = 0, $shl542 = 0, $and545 = 0, $shl547 = 0, $and550 = 0, $add555 = 0, $I530_0 = 0, $arrayidx563 = 0, $121 = 0, $shl569 = 0, $cond = 0, $T_0 = 0, $K579_0 = 0, $arrayidx595 = 0, $124 = 0, $fd613 = 0, $127 = 0, $129 = 0, $dec = 0, $sp_0_in_i = 0, $sp_0_i = 0, label = 0; if (($mem | 0) == 0) { return; } $add_ptr = $mem - 8 | 0; $0 = $add_ptr; $1 = HEAP32[11606] | 0; if ($add_ptr >>> 0 < $1 >>> 0) { _abort(); } $3 = HEAP32[$mem - 4 >> 2] | 0; $and = $3 & 3; if (($and | 0) == 1) { _abort(); } $and5 = $3 & -8; $add_ptr6 = $mem + ($and5 - 8) | 0; $4 = $add_ptr6; L1181 : do { if (($3 & 1 | 0) == 0) { $5 = HEAP32[$add_ptr >> 2] | 0; if (($and | 0) == 0) { return; } $add_ptr_sum232 = -8 - $5 | 0; $add_ptr16 = $mem + $add_ptr_sum232 | 0; $6 = $add_ptr16; $add17 = $5 + $and5 | 0; if ($add_ptr16 >>> 0 < $1 >>> 0) { _abort(); } if (($6 | 0) == (HEAP32[11607] | 0)) { $51 = $mem + ($and5 - 4) | 0; if ((HEAP32[$51 >> 2] & 3 | 0) != 3) { $p_0 = $6; $psize_0 = $add17; break; } HEAP32[11604] = $add17; HEAP32[$51 >> 2] = HEAP32[$51 >> 2] & -2; HEAP32[$mem + ($add_ptr_sum232 + 4) >> 2] = $add17 | 1; HEAP32[$add_ptr6 >> 2] = $add17; return; } $shr = $5 >>> 3; if ($5 >>> 0 < 256) { $9 = HEAP32[$mem + ($add_ptr_sum232 + 8) >> 2] | 0; $11 = HEAP32[$mem + ($add_ptr_sum232 + 12) >> 2] | 0; $12 = 46448 + ($shr << 1 << 2) | 0; do { if (($9 | 0) != ($12 | 0)) { if ($9 >>> 0 < $1 >>> 0) { _abort(); } if ((HEAP32[$9 + 12 >> 2] | 0) == ($6 | 0)) { break; } _abort(); } } while (0); if (($11 | 0) == ($9 | 0)) { HEAP32[11602] = HEAP32[11602] & ~(1 << $shr); $p_0 = $6; $psize_0 = $add17; break; } do { if (($11 | 0) == ($12 | 0)) { $fd67_pre_phi = $11 + 8 | 0; } else { if ($11 >>> 0 < $1 >>> 0) { _abort(); } $fd56 = $11 + 8 | 0; if ((HEAP32[$fd56 >> 2] | 0) == ($6 | 0)) { $fd67_pre_phi = $fd56; break; } _abort(); } } while (0); HEAP32[$9 + 12 >> 2] = $11; HEAP32[$fd67_pre_phi >> 2] = $9; $p_0 = $6; $psize_0 = $add17; break; } $18 = $add_ptr16; $20 = HEAP32[$mem + ($add_ptr_sum232 + 24) >> 2] | 0; $22 = HEAP32[$mem + ($add_ptr_sum232 + 12) >> 2] | 0; do { if (($22 | 0) == ($18 | 0)) { $28 = $mem + ($add_ptr_sum232 + 20) | 0; $29 = HEAP32[$28 >> 2] | 0; if (($29 | 0) == 0) { $arrayidx103 = $mem + ($add_ptr_sum232 + 16) | 0; $30 = HEAP32[$arrayidx103 >> 2] | 0; if (($30 | 0) == 0) { $R_1 = 0; break; } else { $R_0 = $30; $RP_0 = $arrayidx103; } } else { $R_0 = $29; $RP_0 = $28; } while (1) { $arrayidx108 = $R_0 + 20 | 0; $31 = HEAP32[$arrayidx108 >> 2] | 0; if (($31 | 0) != 0) { $R_0 = $31; $RP_0 = $arrayidx108; continue; } $arrayidx113 = $R_0 + 16 | 0; $32 = HEAP32[$arrayidx113 >> 2] | 0; if (($32 | 0) == 0) { break; } else { $R_0 = $32; $RP_0 = $arrayidx113; } } if ($RP_0 >>> 0 < $1 >>> 0) { _abort(); } else { HEAP32[$RP_0 >> 2] = 0; $R_1 = $R_0; break; } } else { $24 = HEAP32[$mem + ($add_ptr_sum232 + 8) >> 2] | 0; if ($24 >>> 0 < $1 >>> 0) { _abort(); } $bk82 = $24 + 12 | 0; if ((HEAP32[$bk82 >> 2] | 0) != ($18 | 0)) { _abort(); } $fd86 = $22 + 8 | 0; if ((HEAP32[$fd86 >> 2] | 0) == ($18 | 0)) { HEAP32[$bk82 >> 2] = $22; HEAP32[$fd86 >> 2] = $24; $R_1 = $22; break; } else { _abort(); } } } while (0); if (($20 | 0) == 0) { $p_0 = $6; $psize_0 = $add17; break; } $34 = $mem + ($add_ptr_sum232 + 28) | 0; $arrayidx130 = 46712 + (HEAP32[$34 >> 2] << 2) | 0; do { if (($18 | 0) == (HEAP32[$arrayidx130 >> 2] | 0)) { HEAP32[$arrayidx130 >> 2] = $R_1; if (($R_1 | 0) != 0) { break; } HEAP32[11603] = HEAP32[11603] & ~(1 << HEAP32[$34 >> 2]); $p_0 = $6; $psize_0 = $add17; break L1181; } else { if ($20 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); } $arrayidx149 = $20 + 16 | 0; if ((HEAP32[$arrayidx149 >> 2] | 0) == ($18 | 0)) { HEAP32[$arrayidx149 >> 2] = $R_1; } else { HEAP32[$20 + 20 >> 2] = $R_1; } if (($R_1 | 0) == 0) { $p_0 = $6; $psize_0 = $add17; break L1181; } } } while (0); if ($R_1 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); } HEAP32[$R_1 + 24 >> 2] = $20; $44 = HEAP32[$mem + ($add_ptr_sum232 + 16) >> 2] | 0; do { if (($44 | 0) != 0) { if ($44 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); } else { HEAP32[$R_1 + 16 >> 2] = $44; HEAP32[$44 + 24 >> 2] = $R_1; break; } } } while (0); $48 = HEAP32[$mem + ($add_ptr_sum232 + 20) >> 2] | 0; if (($48 | 0) == 0) { $p_0 = $6; $psize_0 = $add17; break; } if ($48 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); } else { HEAP32[$R_1 + 20 >> 2] = $48; HEAP32[$48 + 24 >> 2] = $R_1; $p_0 = $6; $psize_0 = $add17; break; } } else { $p_0 = $0; $psize_0 = $and5; } } while (0); $55 = $p_0; if ($55 >>> 0 >= $add_ptr6 >>> 0) { _abort(); } $56 = $mem + ($and5 - 4) | 0; $57 = HEAP32[$56 >> 2] | 0; if (($57 & 1 | 0) == 0) { _abort(); } do { if (($57 & 2 | 0) == 0) { if (($4 | 0) == (HEAP32[11608] | 0)) { $add243 = (HEAP32[11605] | 0) + $psize_0 | 0; HEAP32[11605] = $add243; HEAP32[11608] = $p_0; HEAP32[$p_0 + 4 >> 2] = $add243 | 1; if (($p_0 | 0) == (HEAP32[11607] | 0)) { HEAP32[11607] = 0; HEAP32[11604] = 0; } if ($add243 >>> 0 <= (HEAP32[11609] | 0) >>> 0) { return; } _sys_trim(0) | 0; return; } if (($4 | 0) == (HEAP32[11607] | 0)) { $add258 = (HEAP32[11604] | 0) + $psize_0 | 0; HEAP32[11604] = $add258; HEAP32[11607] = $p_0; HEAP32[$p_0 + 4 >> 2] = $add258 | 1; HEAP32[$55 + $add258 >> 2] = $add258; return; } $add266 = ($57 & -8) + $psize_0 | 0; $shr267 = $57 >>> 3; L1287 : do { if ($57 >>> 0 < 256) { $66 = HEAP32[$mem + $and5 >> 2] | 0; $68 = HEAP32[$mem + ($and5 | 4) >> 2] | 0; $69 = 46448 + ($shr267 << 1 << 2) | 0; do { if (($66 | 0) != ($69 | 0)) { if ($66 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); } if ((HEAP32[$66 + 12 >> 2] | 0) == ($4 | 0)) { break; } _abort(); } } while (0); if (($68 | 0) == ($66 | 0)) { HEAP32[11602] = HEAP32[11602] & ~(1 << $shr267); break; } do { if (($68 | 0) == ($69 | 0)) { $fd321_pre_phi = $68 + 8 | 0; } else { if ($68 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); } $fd310 = $68 + 8 | 0; if ((HEAP32[$fd310 >> 2] | 0) == ($4 | 0)) { $fd321_pre_phi = $fd310; break; } _abort(); } } while (0); HEAP32[$66 + 12 >> 2] = $68; HEAP32[$fd321_pre_phi >> 2] = $66; } else { $77 = $add_ptr6; $79 = HEAP32[$mem + ($and5 + 16) >> 2] | 0; $81 = HEAP32[$mem + ($and5 | 4) >> 2] | 0; do { if (($81 | 0) == ($77 | 0)) { $88 = $mem + ($and5 + 12) | 0; $89 = HEAP32[$88 >> 2] | 0; if (($89 | 0) == 0) { $arrayidx366 = $mem + ($and5 + 8) | 0; $90 = HEAP32[$arrayidx366 >> 2] | 0; if (($90 | 0) == 0) { $R331_1 = 0; break; } else { $R331_0 = $90; $RP359_0 = $arrayidx366; } } else { $R331_0 = $89; $RP359_0 = $88; } while (1) { $arrayidx373 = $R331_0 + 20 | 0; $91 = HEAP32[$arrayidx373 >> 2] | 0; if (($91 | 0) != 0) { $R331_0 = $91; $RP359_0 = $arrayidx373; continue; } $arrayidx378 = $R331_0 + 16 | 0; $92 = HEAP32[$arrayidx378 >> 2] | 0; if (($92 | 0) == 0) { break; } else { $R331_0 = $92; $RP359_0 = $arrayidx378; } } if ($RP359_0 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); } else { HEAP32[$RP359_0 >> 2] = 0; $R331_1 = $R331_0; break; } } else { $83 = HEAP32[$mem + $and5 >> 2] | 0; if ($83 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); } $bk342 = $83 + 12 | 0; if ((HEAP32[$bk342 >> 2] | 0) != ($77 | 0)) { _abort(); } $fd346 = $81 + 8 | 0; if ((HEAP32[$fd346 >> 2] | 0) == ($77 | 0)) { HEAP32[$bk342 >> 2] = $81; HEAP32[$fd346 >> 2] = $83; $R331_1 = $81; break; } else { _abort(); } } } while (0); if (($79 | 0) == 0) { break; } $95 = $mem + ($and5 + 20) | 0; $arrayidx399 = 46712 + (HEAP32[$95 >> 2] << 2) | 0; do { if (($77 | 0) == (HEAP32[$arrayidx399 >> 2] | 0)) { HEAP32[$arrayidx399 >> 2] = $R331_1; if (($R331_1 | 0) != 0) { break; } HEAP32[11603] = HEAP32[11603] & ~(1 << HEAP32[$95 >> 2]); break L1287; } else { if ($79 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); } $arrayidx418 = $79 + 16 | 0; if ((HEAP32[$arrayidx418 >> 2] | 0) == ($77 | 0)) { HEAP32[$arrayidx418 >> 2] = $R331_1; } else { HEAP32[$79 + 20 >> 2] = $R331_1; } if (($R331_1 | 0) == 0) { break L1287; } } } while (0); if ($R331_1 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); } HEAP32[$R331_1 + 24 >> 2] = $79; $105 = HEAP32[$mem + ($and5 + 8) >> 2] | 0; do { if (($105 | 0) != 0) { if ($105 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); } else { HEAP32[$R331_1 + 16 >> 2] = $105; HEAP32[$105 + 24 >> 2] = $R331_1; break; } } } while (0); $109 = HEAP32[$mem + ($and5 + 12) >> 2] | 0; if (($109 | 0) == 0) { break; } if ($109 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); } else { HEAP32[$R331_1 + 20 >> 2] = $109; HEAP32[$109 + 24 >> 2] = $R331_1; break; } } } while (0); HEAP32[$p_0 + 4 >> 2] = $add266 | 1; HEAP32[$55 + $add266 >> 2] = $add266; if (($p_0 | 0) != (HEAP32[11607] | 0)) { $psize_1 = $add266; break; } HEAP32[11604] = $add266; return; } else { HEAP32[$56 >> 2] = $57 & -2; HEAP32[$p_0 + 4 >> 2] = $psize_0 | 1; HEAP32[$55 + $psize_0 >> 2] = $psize_0; $psize_1 = $psize_0; } } while (0); $shr497 = $psize_1 >>> 3; if ($psize_1 >>> 0 < 256) { $shl504 = $shr497 << 1; $113 = 46448 + ($shl504 << 2) | 0; $114 = HEAP32[11602] | 0; $shl507 = 1 << $shr497; do { if (($114 & $shl507 | 0) == 0) { HEAP32[11602] = $114 | $shl507; $F506_0 = $113; $_pre_phi = 46448 + ($shl504 + 2 << 2) | 0; } else { $115 = 46448 + ($shl504 + 2 << 2) | 0; $116 = HEAP32[$115 >> 2] | 0; if ($116 >>> 0 >= (HEAP32[11606] | 0) >>> 0) { $F506_0 = $116; $_pre_phi = $115; break; } _abort(); } } while (0); HEAP32[$_pre_phi >> 2] = $p_0; HEAP32[$F506_0 + 12 >> 2] = $p_0; HEAP32[$p_0 + 8 >> 2] = $F506_0; HEAP32[$p_0 + 12 >> 2] = $113; return; } $119 = $p_0; $shr531 = $psize_1 >>> 8; do { if (($shr531 | 0) == 0) { $I530_0 = 0; } else { if ($psize_1 >>> 0 > 16777215) { $I530_0 = 31; break; } $and541 = ($shr531 + 1048320 | 0) >>> 16 & 8; $shl542 = $shr531 << $and541; $and545 = ($shl542 + 520192 | 0) >>> 16 & 4; $shl547 = $shl542 << $and545; $and550 = ($shl547 + 245760 | 0) >>> 16 & 2; $add555 = 14 - ($and545 | $and541 | $and550) + ($shl547 << $and550 >>> 15) | 0; $I530_0 = $psize_1 >>> (($add555 + 7 | 0) >>> 0) & 1 | $add555 << 1; } } while (0); $arrayidx563 = 46712 + ($I530_0 << 2) | 0; HEAP32[$p_0 + 28 >> 2] = $I530_0; HEAP32[$p_0 + 20 >> 2] = 0; HEAP32[$p_0 + 16 >> 2] = 0; $121 = HEAP32[11603] | 0; $shl569 = 1 << $I530_0; do { if (($121 & $shl569 | 0) == 0) { HEAP32[11603] = $121 | $shl569; HEAP32[$arrayidx563 >> 2] = $119; HEAP32[$p_0 + 24 >> 2] = $arrayidx563; HEAP32[$p_0 + 12 >> 2] = $p_0; HEAP32[$p_0 + 8 >> 2] = $p_0; } else { if (($I530_0 | 0) == 31) { $cond = 0; } else { $cond = 25 - ($I530_0 >>> 1) | 0; } $K579_0 = $psize_1 << $cond; $T_0 = HEAP32[$arrayidx563 >> 2] | 0; while (1) { if ((HEAP32[$T_0 + 4 >> 2] & -8 | 0) == ($psize_1 | 0)) { break; } $arrayidx595 = $T_0 + 16 + ($K579_0 >>> 31 << 2) | 0; $124 = HEAP32[$arrayidx595 >> 2] | 0; if (($124 | 0) == 0) { label = 1007; break; } else { $K579_0 = $K579_0 << 1; $T_0 = $124; } } if ((label | 0) == 1007) { if ($arrayidx595 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); } else { HEAP32[$arrayidx595 >> 2] = $119; HEAP32[$p_0 + 24 >> 2] = $T_0; HEAP32[$p_0 + 12 >> 2] = $p_0; HEAP32[$p_0 + 8 >> 2] = $p_0; break; } } $fd613 = $T_0 + 8 | 0; $127 = HEAP32[$fd613 >> 2] | 0; $129 = HEAP32[11606] | 0; if ($T_0 >>> 0 < $129 >>> 0) { _abort(); } if ($127 >>> 0 < $129 >>> 0) { _abort(); } else { HEAP32[$127 + 12 >> 2] = $119; HEAP32[$fd613 >> 2] = $119; HEAP32[$p_0 + 8 >> 2] = $127; HEAP32[$p_0 + 12 >> 2] = $T_0; HEAP32[$p_0 + 24 >> 2] = 0; break; } } } while (0); $dec = (HEAP32[11610] | 0) - 1 | 0; HEAP32[11610] = $dec; if (($dec | 0) == 0) { $sp_0_in_i = 46864; } else { return; } while (1) { $sp_0_i = HEAP32[$sp_0_in_i >> 2] | 0; if (($sp_0_i | 0) == 0) { break; } else { $sp_0_in_i = $sp_0_i + 8 | 0; } } HEAP32[11610] = -1; return; } function _calloc($n_elements, $elem_size) { $n_elements = $n_elements | 0; $elem_size = $elem_size | 0; var $mul = 0, $req_0 = 0, $call = 0; do { if (($n_elements | 0) == 0) { $req_0 = 0; } else { $mul = Math_imul($elem_size, $n_elements) | 0; if (($elem_size | $n_elements) >>> 0 <= 65535) { $req_0 = $mul; break; } $req_0 = (($mul >>> 0) / ($n_elements >>> 0) | 0 | 0) == ($elem_size | 0) ? $mul : -1; } } while (0); $call = _malloc($req_0) | 0; if (($call | 0) == 0) { return $call | 0; } if ((HEAP32[$call - 4 >> 2] & 3 | 0) == 0) { return $call | 0; } _memset($call | 0, 0, $req_0 | 0); return $call | 0; } function _realloc($oldmem, $bytes) { $oldmem = $oldmem | 0; $bytes = $bytes | 0; var $cond = 0, $call7 = 0, $call12 = 0, $3 = 0, $sub = 0, $cond24 = 0, $mem_0 = 0; if (($oldmem | 0) == 0) { $mem_0 = _malloc($bytes) | 0; return $mem_0 | 0; } if ($bytes >>> 0 > 4294967231) { HEAP32[(___errno_location() | 0) >> 2] = 12; $mem_0 = 0; return $mem_0 | 0; } if ($bytes >>> 0 < 11) { $cond = 16; } else { $cond = $bytes + 11 & -8; } $call7 = _try_realloc_chunk($oldmem - 8 | 0, $cond) | 0; if (($call7 | 0) != 0) { $mem_0 = $call7 + 8 | 0; return $mem_0 | 0; } $call12 = _malloc($bytes) | 0; if (($call12 | 0) == 0) { $mem_0 = 0; return $mem_0 | 0; } $3 = HEAP32[$oldmem - 4 >> 2] | 0; $sub = ($3 & -8) - (($3 & 3 | 0) == 0 ? 8 : 4) | 0; $cond24 = $sub >>> 0 < $bytes >>> 0 ? $sub : $bytes; _memcpy($call12 | 0, $oldmem | 0, $cond24) | 0; _free($oldmem); $mem_0 = $call12; return $mem_0 | 0; } function _realloc_in_place($oldmem, $bytes) { $oldmem = $oldmem | 0; $bytes = $bytes | 0; var $cond = 0, $0 = 0; if (($oldmem | 0) == 0) { return 0; } if ($bytes >>> 0 > 4294967231) { HEAP32[(___errno_location() | 0) >> 2] = 12; return 0; } if ($bytes >>> 0 < 11) { $cond = 16; } else { $cond = $bytes + 11 & -8; } $0 = $oldmem - 8 | 0; return ((_try_realloc_chunk($0, $cond) | 0) == ($0 | 0) ? $oldmem : 0) | 0; } function _memalign($alignment, $bytes) { $alignment = $alignment | 0; $bytes = $bytes | 0; var $retval_0 = 0; if ($alignment >>> 0 < 9) { $retval_0 = _malloc($bytes) | 0; return $retval_0 | 0; } else { $retval_0 = _internal_memalign($alignment, $bytes) | 0; return $retval_0 | 0; } return 0; } function _sys_trim($pad) { $pad = $pad | 0; var $call_i = 0, $1 = 0, $2 = 0, $3 = 0, $mul = 0, $4 = 0, $sp_0_i = 0, $5 = 0, $7 = 0, $retval_0_i = 0, $call20 = 0, $size = 0, $call24 = 0, $call25 = 0, $sub_ptr_sub = 0, $13 = 0, $sub41 = 0, $15 = 0, $16 = 0, $cond_i = 0, $sub5_i = 0, $released_2 = 0; do { if ((HEAP32[10824] | 0) == 0) { $call_i = _sysconf(8) | 0; if (($call_i - 1 & $call_i | 0) == 0) { HEAP32[10826] = $call_i; HEAP32[10825] = $call_i; HEAP32[10827] = -1; HEAP32[10828] = 2097152; HEAP32[10829] = 0; HEAP32[11713] = 0; HEAP32[10824] = (_time(0) | 0) & -16 ^ 1431655768; break; } else { _abort(); return 0; } } } while (0); if ($pad >>> 0 >= 4294967232) { $released_2 = 0; return $released_2 | 0; } $1 = HEAP32[11608] | 0; if (($1 | 0) == 0) { $released_2 = 0; return $released_2 | 0; } $2 = HEAP32[11605] | 0; do { if ($2 >>> 0 > ($pad + 40 | 0) >>> 0) { $3 = HEAP32[10826] | 0; $mul = Math_imul((((-40 - $pad - 1 + $2 + $3 | 0) >>> 0) / ($3 >>> 0) | 0) - 1 | 0, $3) | 0; $4 = $1; $sp_0_i = 46856; while (1) { $5 = HEAP32[$sp_0_i >> 2] | 0; if ($5 >>> 0 <= $4 >>> 0) { if (($5 + (HEAP32[$sp_0_i + 4 >> 2] | 0) | 0) >>> 0 > $4 >>> 0) { $retval_0_i = $sp_0_i; break; } } $7 = HEAP32[$sp_0_i + 8 >> 2] | 0; if (($7 | 0) == 0) { $retval_0_i = 0; break; } else { $sp_0_i = $7; } } if ((HEAP32[$retval_0_i + 12 >> 2] & 8 | 0) != 0) { break; } $call20 = _sbrk(0) | 0; $size = $retval_0_i + 4 | 0; if (($call20 | 0) != ((HEAP32[$retval_0_i >> 2] | 0) + (HEAP32[$size >> 2] | 0) | 0)) { break; } $call24 = _sbrk(-($mul >>> 0 > 2147483646 ? -2147483648 - $3 | 0 : $mul) | 0) | 0; $call25 = _sbrk(0) | 0; if (!(($call24 | 0) != -1 & $call25 >>> 0 < $call20 >>> 0)) { break; } $sub_ptr_sub = $call20 - $call25 | 0; if (($call20 | 0) == ($call25 | 0)) { break; } HEAP32[$size >> 2] = (HEAP32[$size >> 2] | 0) - $sub_ptr_sub; HEAP32[11710] = (HEAP32[11710] | 0) - $sub_ptr_sub; $13 = HEAP32[11608] | 0; $sub41 = (HEAP32[11605] | 0) - $sub_ptr_sub | 0; $15 = $13; $16 = $13 + 8 | 0; if (($16 & 7 | 0) == 0) { $cond_i = 0; } else { $cond_i = -$16 & 7; } $sub5_i = $sub41 - $cond_i | 0; HEAP32[11608] = $15 + $cond_i; HEAP32[11605] = $sub5_i; HEAP32[$15 + ($cond_i + 4) >> 2] = $sub5_i | 1; HEAP32[$15 + ($sub41 + 4) >> 2] = 40; HEAP32[11609] = HEAP32[10828]; $released_2 = ($call20 | 0) != ($call25 | 0) | 0; return $released_2 | 0; } } while (0); if ((HEAP32[11605] | 0) >>> 0 <= (HEAP32[11609] | 0) >>> 0) { $released_2 = 0; return $released_2 | 0; } HEAP32[11609] = -1; $released_2 = 0; return $released_2 | 0; } function _try_realloc_chunk($p, $nb) { $p = $p | 0; $nb = $nb | 0; var $head = 0, $0 = 0, $and = 0, $1 = 0, $add_ptr = 0, $2 = 0, $3 = 0, $and2 = 0, $4 = 0, $5 = 0, $sub = 0, $add = 0, $sub40 = 0, $add58 = 0, $sub62 = 0, $18 = 0, $20 = 0, $storemerge18 = 0, $storemerge = 0, $add105 = 0, $sub110 = 0, $shr = 0, $23 = 0, $25 = 0, $26 = 0, $fd138 = 0, $fd148_pre_phi = 0, $32 = 0, $34 = 0, $36 = 0, $38 = 0, $bk164 = 0, $fd167 = 0, $42 = 0, $43 = 0, $arrayidx182 = 0, $44 = 0, $RP_0 = 0, $R_0 = 0, $arrayidx186 = 0, $45 = 0, $arrayidx190 = 0, $46 = 0, $R_1 = 0, $48 = 0, $arrayidx206 = 0, $arrayidx226 = 0, $58 = 0, $62 = 0, $66 = 0, $71 = 0, $newp_0 = 0; $head = $p + 4 | 0; $0 = HEAP32[$head >> 2] | 0; $and = $0 & -8; $1 = $p; $add_ptr = $1 + $and | 0; $2 = $add_ptr; $3 = HEAP32[11606] | 0; if ($1 >>> 0 < $3 >>> 0) { _abort(); return 0; } $and2 = $0 & 3; if (!(($and2 | 0) != 1 & $1 >>> 0 < $add_ptr >>> 0)) { _abort(); return 0; } $4 = $1 + ($and | 4) | 0; $5 = HEAP32[$4 >> 2] | 0; if (($5 & 1 | 0) == 0) { _abort(); return 0; } if (($and2 | 0) == 0) { if ($nb >>> 0 < 256) { $newp_0 = 0; return $newp_0 | 0; } do { if ($and >>> 0 >= ($nb + 4 | 0) >>> 0) { if (($and - $nb | 0) >>> 0 > HEAP32[10826] << 1 >>> 0) { break; } else { $newp_0 = $p; } return $newp_0 | 0; } } while (0); $newp_0 = 0; return $newp_0 | 0; } if ($and >>> 0 >= $nb >>> 0) { $sub = $and - $nb | 0; if ($sub >>> 0 <= 15) { $newp_0 = $p; return $newp_0 | 0; } HEAP32[$head >> 2] = $0 & 1 | $nb | 2; HEAP32[$1 + ($nb + 4) >> 2] = $sub | 3; HEAP32[$4 >> 2] = HEAP32[$4 >> 2] | 1; _dispose_chunk($1 + $nb | 0, $sub); $newp_0 = $p; return $newp_0 | 0; } if (($2 | 0) == (HEAP32[11608] | 0)) { $add = (HEAP32[11605] | 0) + $and | 0; if ($add >>> 0 <= $nb >>> 0) { $newp_0 = 0; return $newp_0 | 0; } $sub40 = $add - $nb | 0; HEAP32[$head >> 2] = $0 & 1 | $nb | 2; HEAP32[$1 + ($nb + 4) >> 2] = $sub40 | 1; HEAP32[11608] = $1 + $nb; HEAP32[11605] = $sub40; $newp_0 = $p; return $newp_0 | 0; } if (($2 | 0) == (HEAP32[11607] | 0)) { $add58 = (HEAP32[11604] | 0) + $and | 0; if ($add58 >>> 0 < $nb >>> 0) { $newp_0 = 0; return $newp_0 | 0; } $sub62 = $add58 - $nb | 0; if ($sub62 >>> 0 > 15) { HEAP32[$head >> 2] = $0 & 1 | $nb | 2; HEAP32[$1 + ($nb + 4) >> 2] = $sub62 | 1; HEAP32[$1 + $add58 >> 2] = $sub62; $18 = $1 + ($add58 + 4) | 0; HEAP32[$18 >> 2] = HEAP32[$18 >> 2] & -2; $storemerge = $1 + $nb | 0; $storemerge18 = $sub62; } else { HEAP32[$head >> 2] = $0 & 1 | $add58 | 2; $20 = $1 + ($add58 + 4) | 0; HEAP32[$20 >> 2] = HEAP32[$20 >> 2] | 1; $storemerge = 0; $storemerge18 = 0; } HEAP32[11604] = $storemerge18; HEAP32[11607] = $storemerge; $newp_0 = $p; return $newp_0 | 0; } if (($5 & 2 | 0) != 0) { $newp_0 = 0; return $newp_0 | 0; } $add105 = ($5 & -8) + $and | 0; if ($add105 >>> 0 < $nb >>> 0) { $newp_0 = 0; return $newp_0 | 0; } $sub110 = $add105 - $nb | 0; $shr = $5 >>> 3; L1536 : do { if ($5 >>> 0 < 256) { $23 = HEAP32[$1 + ($and + 8) >> 2] | 0; $25 = HEAP32[$1 + ($and + 12) >> 2] | 0; $26 = 46448 + ($shr << 1 << 2) | 0; do { if (($23 | 0) != ($26 | 0)) { if ($23 >>> 0 < $3 >>> 0) { _abort(); return 0; } if ((HEAP32[$23 + 12 >> 2] | 0) == ($2 | 0)) { break; } _abort(); return 0; } } while (0); if (($25 | 0) == ($23 | 0)) { HEAP32[11602] = HEAP32[11602] & ~(1 << $shr); break; } do { if (($25 | 0) == ($26 | 0)) { $fd148_pre_phi = $25 + 8 | 0; } else { if ($25 >>> 0 < $3 >>> 0) { _abort(); return 0; } $fd138 = $25 + 8 | 0; if ((HEAP32[$fd138 >> 2] | 0) == ($2 | 0)) { $fd148_pre_phi = $fd138; break; } _abort(); return 0; } } while (0); HEAP32[$23 + 12 >> 2] = $25; HEAP32[$fd148_pre_phi >> 2] = $23; } else { $32 = $add_ptr; $34 = HEAP32[$1 + ($and + 24) >> 2] | 0; $36 = HEAP32[$1 + ($and + 12) >> 2] | 0; do { if (($36 | 0) == ($32 | 0)) { $42 = $1 + ($and + 20) | 0; $43 = HEAP32[$42 >> 2] | 0; if (($43 | 0) == 0) { $arrayidx182 = $1 + ($and + 16) | 0; $44 = HEAP32[$arrayidx182 >> 2] | 0; if (($44 | 0) == 0) { $R_1 = 0; break; } else { $R_0 = $44; $RP_0 = $arrayidx182; } } else { $R_0 = $43; $RP_0 = $42; } while (1) { $arrayidx186 = $R_0 + 20 | 0; $45 = HEAP32[$arrayidx186 >> 2] | 0; if (($45 | 0) != 0) { $R_0 = $45; $RP_0 = $arrayidx186; continue; } $arrayidx190 = $R_0 + 16 | 0; $46 = HEAP32[$arrayidx190 >> 2] | 0; if (($46 | 0) == 0) { break; } else { $R_0 = $46; $RP_0 = $arrayidx190; } } if ($RP_0 >>> 0 < $3 >>> 0) { _abort(); return 0; } else { HEAP32[$RP_0 >> 2] = 0; $R_1 = $R_0; break; } } else { $38 = HEAP32[$1 + ($and + 8) >> 2] | 0; if ($38 >>> 0 < $3 >>> 0) { _abort(); return 0; } $bk164 = $38 + 12 | 0; if ((HEAP32[$bk164 >> 2] | 0) != ($32 | 0)) { _abort(); return 0; } $fd167 = $36 + 8 | 0; if ((HEAP32[$fd167 >> 2] | 0) == ($32 | 0)) { HEAP32[$bk164 >> 2] = $36; HEAP32[$fd167 >> 2] = $38; $R_1 = $36; break; } else { _abort(); return 0; } } } while (0); if (($34 | 0) == 0) { break; } $48 = $1 + ($and + 28) | 0; $arrayidx206 = 46712 + (HEAP32[$48 >> 2] << 2) | 0; do { if (($32 | 0) == (HEAP32[$arrayidx206 >> 2] | 0)) { HEAP32[$arrayidx206 >> 2] = $R_1; if (($R_1 | 0) != 0) { break; } HEAP32[11603] = HEAP32[11603] & ~(1 << HEAP32[$48 >> 2]); break L1536; } else { if ($34 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); return 0; } $arrayidx226 = $34 + 16 | 0; if ((HEAP32[$arrayidx226 >> 2] | 0) == ($32 | 0)) { HEAP32[$arrayidx226 >> 2] = $R_1; } else { HEAP32[$34 + 20 >> 2] = $R_1; } if (($R_1 | 0) == 0) { break L1536; } } } while (0); if ($R_1 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); return 0; } HEAP32[$R_1 + 24 >> 2] = $34; $58 = HEAP32[$1 + ($and + 16) >> 2] | 0; do { if (($58 | 0) != 0) { if ($58 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); return 0; } else { HEAP32[$R_1 + 16 >> 2] = $58; HEAP32[$58 + 24 >> 2] = $R_1; break; } } } while (0); $62 = HEAP32[$1 + ($and + 20) >> 2] | 0; if (($62 | 0) == 0) { break; } if ($62 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); return 0; } else { HEAP32[$R_1 + 20 >> 2] = $62; HEAP32[$62 + 24 >> 2] = $R_1; break; } } } while (0); if ($sub110 >>> 0 < 16) { HEAP32[$head >> 2] = $add105 | HEAP32[$head >> 2] & 1 | 2; $66 = $1 + ($add105 | 4) | 0; HEAP32[$66 >> 2] = HEAP32[$66 >> 2] | 1; $newp_0 = $p; return $newp_0 | 0; } else { HEAP32[$head >> 2] = HEAP32[$head >> 2] & 1 | $nb | 2; HEAP32[$1 + ($nb + 4) >> 2] = $sub110 | 3; $71 = $1 + ($add105 | 4) | 0; HEAP32[$71 >> 2] = HEAP32[$71 >> 2] | 1; _dispose_chunk($1 + $nb | 0, $sub110); $newp_0 = $p; return $newp_0 | 0; } return 0; } function _malloc_footprint() { return HEAP32[11710] | 0; } function _malloc_max_footprint() { return HEAP32[11711] | 0; } function _malloc_footprint_limit() { var $0 = 0; $0 = HEAP32[11712] | 0; return (($0 | 0) == 0 ? -1 : $0) | 0; } function _malloc_set_footprint_limit($bytes) { $bytes = $bytes | 0; var $0 = 0, $result_0 = 0; if (($bytes | 0) == -1) { $result_0 = 0; } else { $0 = HEAP32[10826] | 0; $result_0 = $bytes - 1 + $0 & -$0; } HEAP32[11712] = $result_0; return $result_0 | 0; } function _internal_memalign($alignment, $bytes) { $alignment = $alignment | 0; $bytes = $bytes | 0; var $_alignment = 0, $a_0 = 0, $alignment_addr_1 = 0, $cond = 0, $call17 = 0, $add_ptr = 0, $0 = 0, $sub20 = 0, $3 = 0, $add_ptr28 = 0, $sub_ptr_rhs_cast = 0, $cond34 = 0, $4 = 0, $sub_ptr_sub37 = 0, $5 = 0, $6 = 0, $sub39 = 0, $9 = 0, $11 = 0, $14 = 0, $p_0 = 0, $head65 = 0, $16 = 0, $and70 = 0, $sub74 = 0, $17 = 0, $20 = 0, $mem_0 = 0; $_alignment = $alignment >>> 0 < 16 ? 16 : $alignment; if (($_alignment - 1 & $_alignment | 0) == 0) { $alignment_addr_1 = $_alignment; } else { $a_0 = 16; while (1) { if ($a_0 >>> 0 < $_alignment >>> 0) { $a_0 = $a_0 << 1; } else { $alignment_addr_1 = $a_0; break; } } } if ((-64 - $alignment_addr_1 | 0) >>> 0 <= $bytes >>> 0) { HEAP32[(___errno_location() | 0) >> 2] = 12; $mem_0 = 0; return $mem_0 | 0; } if ($bytes >>> 0 < 11) { $cond = 16; } else { $cond = $bytes + 11 & -8; } $call17 = _malloc($alignment_addr_1 + 12 + $cond | 0) | 0; if (($call17 | 0) == 0) { $mem_0 = 0; return $mem_0 | 0; } $add_ptr = $call17 - 8 | 0; $0 = $add_ptr; $sub20 = $alignment_addr_1 - 1 | 0; do { if (($call17 & $sub20 | 0) == 0) { $p_0 = $0; } else { $3 = $call17 + $sub20 & -$alignment_addr_1; $add_ptr28 = $3 - 8 | 0; $sub_ptr_rhs_cast = $add_ptr; if (($add_ptr28 - $sub_ptr_rhs_cast | 0) >>> 0 > 15) { $cond34 = $add_ptr28; } else { $cond34 = $3 + ($alignment_addr_1 - 8) | 0; } $4 = $cond34; $sub_ptr_sub37 = $cond34 - $sub_ptr_rhs_cast | 0; $5 = $call17 - 4 | 0; $6 = HEAP32[$5 >> 2] | 0; $sub39 = ($6 & -8) - $sub_ptr_sub37 | 0; if (($6 & 3 | 0) == 0) { HEAP32[$cond34 >> 2] = (HEAP32[$add_ptr >> 2] | 0) + $sub_ptr_sub37; HEAP32[$cond34 + 4 >> 2] = $sub39; $p_0 = $4; break; } else { $9 = $cond34 + 4 | 0; HEAP32[$9 >> 2] = $sub39 | HEAP32[$9 >> 2] & 1 | 2; $11 = $cond34 + ($sub39 + 4) | 0; HEAP32[$11 >> 2] = HEAP32[$11 >> 2] | 1; HEAP32[$5 >> 2] = $sub_ptr_sub37 | HEAP32[$5 >> 2] & 1 | 2; $14 = $call17 + ($sub_ptr_sub37 - 4) | 0; HEAP32[$14 >> 2] = HEAP32[$14 >> 2] | 1; _dispose_chunk($0, $sub_ptr_sub37); $p_0 = $4; break; } } } while (0); $head65 = $p_0 + 4 | 0; $16 = HEAP32[$head65 >> 2] | 0; do { if (($16 & 3 | 0) != 0) { $and70 = $16 & -8; if ($and70 >>> 0 <= ($cond + 16 | 0) >>> 0) { break; } $sub74 = $and70 - $cond | 0; $17 = $p_0; HEAP32[$head65 >> 2] = $cond | $16 & 1 | 2; HEAP32[$17 + ($cond | 4) >> 2] = $sub74 | 3; $20 = $17 + ($and70 | 4) | 0; HEAP32[$20 >> 2] = HEAP32[$20 >> 2] | 1; _dispose_chunk($17 + $cond | 0, $sub74); } } while (0); $mem_0 = $p_0 + 8 | 0; return $mem_0 | 0; } function _posix_memalign($pp, $alignment, $bytes) { $pp = $pp | 0; $alignment = $alignment | 0; $bytes = $bytes | 0; var $div = 0, $mem_0 = 0, $retval_0 = 0, label = 0; do { if (($alignment | 0) == 8) { $mem_0 = _malloc($bytes) | 0; label = 1246; } else { $div = $alignment >>> 2; if (($alignment & 3 | 0) != 0 | ($div | 0) == 0) { $retval_0 = 22; break; } if (($div + 1073741823 & $div | 0) != 0) { $retval_0 = 22; break; } if ((-64 - $alignment | 0) >>> 0 < $bytes >>> 0) { $retval_0 = 12; break; } $mem_0 = _internal_memalign($alignment >>> 0 < 16 ? 16 : $alignment, $bytes) | 0; label = 1246; } } while (0); do { if ((label | 0) == 1246) { if (($mem_0 | 0) == 0) { $retval_0 = 12; break; } HEAP32[$pp >> 2] = $mem_0; $retval_0 = 0; } } while (0); return $retval_0 | 0; } function _independent_calloc($n_elements, $elem_size, $chunks) { $n_elements = $n_elements | 0; $elem_size = $elem_size | 0; $chunks = $chunks | 0; var $sz = 0, $call = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 8 | 0; $sz = sp | 0; HEAP32[$sz >> 2] = $elem_size; $call = _ialloc($n_elements, $sz, 3, $chunks) | 0; STACKTOP = sp; return $call | 0; } function _independent_comalloc($n_elements, $sizes, $chunks) { $n_elements = $n_elements | 0; $sizes = $sizes | 0; $chunks = $chunks | 0; return _ialloc($n_elements, $sizes, 0, $chunks) | 0; } function _valloc($bytes) { $bytes = $bytes | 0; var $call_i = 0, $1 = 0, $call1 = 0; if ((HEAP32[10824] | 0) != 0) { $1 = HEAP32[10825] | 0; $call1 = _memalign($1, $bytes) | 0; return $call1 | 0; } $call_i = _sysconf(8) | 0; if (($call_i - 1 & $call_i | 0) != 0) { _abort(); return 0; } HEAP32[10826] = $call_i; HEAP32[10825] = $call_i; HEAP32[10827] = -1; HEAP32[10828] = 2097152; HEAP32[10829] = 0; HEAP32[11713] = 0; HEAP32[10824] = (_time(0) | 0) & -16 ^ 1431655768; $1 = HEAP32[10825] | 0; $call1 = _memalign($1, $bytes) | 0; return $call1 | 0; } function _pvalloc($bytes) { $bytes = $bytes | 0; var $call_i = 0, $1 = 0; do { if ((HEAP32[10824] | 0) == 0) { $call_i = _sysconf(8) | 0; if (($call_i - 1 & $call_i | 0) == 0) { HEAP32[10826] = $call_i; HEAP32[10825] = $call_i; HEAP32[10827] = -1; HEAP32[10828] = 2097152; HEAP32[10829] = 0; HEAP32[11713] = 0; HEAP32[10824] = (_time(0) | 0) & -16 ^ 1431655768; break; } else { _abort(); return 0; } } } while (0); $1 = HEAP32[10825] | 0; return _memalign($1, $bytes - 1 + $1 & -$1) | 0; } function _ialloc($n_elements, $sizes, $opts, $chunks) { $n_elements = $n_elements | 0; $sizes = $sizes | 0; $opts = $opts | 0; $chunks = $chunks | 0; var $call_i = 0, $cmp2 = 0, $mul = 0, $array_size_0 = 0, $marray_0 = 0, $2 = 0, $cond22 = 0, $i_09 = 0, $contents_size_08 = 0, $3 = 0, $cond34 = 0, $add35 = 0, $inc = 0, $contents_size_1 = 0, $element_size_0 = 0, $call39 = 0, $add_ptr = 0, $and47 = 0, $remainder_size_0 = 0, $marray_1 = 0, $sub65 = 0, $i_15_us = 0, $remainder_size_14_us = 0, $p_0_in3_us = 0, $8 = 0, $size_0_us = 0, $sub82_us = 0, $add_ptr86_us = 0, $inc93_us = 0, $i_15 = 0, $remainder_size_14 = 0, $p_0_in3 = 0, $sub82 = 0, $add_ptr86 = 0, $inc93 = 0, $remainder_size_1_lcssa = 0, $p_0_in_lcssa = 0, $retval_0 = 0; do { if ((HEAP32[10824] | 0) == 0) { $call_i = _sysconf(8) | 0; if (($call_i - 1 & $call_i | 0) == 0) { HEAP32[10826] = $call_i; HEAP32[10825] = $call_i; HEAP32[10827] = -1; HEAP32[10828] = 2097152; HEAP32[10829] = 0; HEAP32[11713] = 0; HEAP32[10824] = (_time(0) | 0) & -16 ^ 1431655768; break; } else { _abort(); return 0; } } } while (0); $cmp2 = ($n_elements | 0) == 0; do { if (($chunks | 0) == 0) { if ($cmp2) { $retval_0 = _malloc(0) | 0; return $retval_0 | 0; } else { $mul = $n_elements << 2; if ($mul >>> 0 < 11) { $marray_0 = 0; $array_size_0 = 16; break; } $marray_0 = 0; $array_size_0 = $mul + 11 & -8; break; } } else { if ($cmp2) { $retval_0 = $chunks; } else { $marray_0 = $chunks; $array_size_0 = 0; break; } return $retval_0 | 0; } } while (0); do { if (($opts & 1 | 0) == 0) { if ($cmp2) { $element_size_0 = 0; $contents_size_1 = 0; break; } else { $contents_size_08 = 0; $i_09 = 0; } while (1) { $3 = HEAP32[$sizes + ($i_09 << 2) >> 2] | 0; if ($3 >>> 0 < 11) { $cond34 = 16; } else { $cond34 = $3 + 11 & -8; } $add35 = $cond34 + $contents_size_08 | 0; $inc = $i_09 + 1 | 0; if (($inc | 0) == ($n_elements | 0)) { $element_size_0 = 0; $contents_size_1 = $add35; break; } else { $contents_size_08 = $add35; $i_09 = $inc; } } } else { $2 = HEAP32[$sizes >> 2] | 0; if ($2 >>> 0 < 11) { $cond22 = 16; } else { $cond22 = $2 + 11 & -8; } $element_size_0 = $cond22; $contents_size_1 = Math_imul($cond22, $n_elements) | 0; } } while (0); $call39 = _malloc($array_size_0 - 4 + $contents_size_1 | 0) | 0; if (($call39 | 0) == 0) { $retval_0 = 0; return $retval_0 | 0; } $add_ptr = $call39 - 8 | 0; $and47 = HEAP32[$call39 - 4 >> 2] & -8; if (($opts & 2 | 0) != 0) { _memset($call39 | 0, 0, -4 - $array_size_0 + $and47 | 0); } if (($marray_0 | 0) == 0) { HEAP32[$call39 + ($contents_size_1 - 4) >> 2] = $and47 - $contents_size_1 | 3; $marray_1 = $call39 + $contents_size_1 | 0; $remainder_size_0 = $contents_size_1; } else { $marray_1 = $marray_0; $remainder_size_0 = $and47; } HEAP32[$marray_1 >> 2] = $call39; $sub65 = $n_elements - 1 | 0; L1713 : do { if (($sub65 | 0) == 0) { $p_0_in_lcssa = $add_ptr; $remainder_size_1_lcssa = $remainder_size_0; } else { if (($element_size_0 | 0) == 0) { $p_0_in3_us = $add_ptr; $remainder_size_14_us = $remainder_size_0; $i_15_us = 0; } else { $p_0_in3 = $add_ptr; $remainder_size_14 = $remainder_size_0; $i_15 = 0; while (1) { $sub82 = $remainder_size_14 - $element_size_0 | 0; HEAP32[$p_0_in3 + 4 >> 2] = $element_size_0 | 3; $add_ptr86 = $p_0_in3 + $element_size_0 | 0; $inc93 = $i_15 + 1 | 0; HEAP32[$marray_1 + ($inc93 << 2) >> 2] = $p_0_in3 + ($element_size_0 + 8); if (($inc93 | 0) == ($sub65 | 0)) { $p_0_in_lcssa = $add_ptr86; $remainder_size_1_lcssa = $sub82; break L1713; } else { $p_0_in3 = $add_ptr86; $remainder_size_14 = $sub82; $i_15 = $inc93; } } } while (1) { $8 = HEAP32[$sizes + ($i_15_us << 2) >> 2] | 0; if ($8 >>> 0 < 11) { $size_0_us = 16; } else { $size_0_us = $8 + 11 & -8; } $sub82_us = $remainder_size_14_us - $size_0_us | 0; HEAP32[$p_0_in3_us + 4 >> 2] = $size_0_us | 3; $add_ptr86_us = $p_0_in3_us + $size_0_us | 0; $inc93_us = $i_15_us + 1 | 0; HEAP32[$marray_1 + ($inc93_us << 2) >> 2] = $p_0_in3_us + ($size_0_us + 8); if (($inc93_us | 0) == ($sub65 | 0)) { $p_0_in_lcssa = $add_ptr86_us; $remainder_size_1_lcssa = $sub82_us; break; } else { $p_0_in3_us = $add_ptr86_us; $remainder_size_14_us = $sub82_us; $i_15_us = $inc93_us; } } } } while (0); HEAP32[$p_0_in_lcssa + 4 >> 2] = $remainder_size_1_lcssa | 3; $retval_0 = $marray_1; return $retval_0 | 0; } function _bulk_free($array, $nelem) { $array = $array | 0; $nelem = $nelem | 0; var $arrayidx_i = 0, $a_07_i = 0, $0 = 0, $add_ptr_i = 0, $1 = 0, $2 = 0, $and_i = 0, $5 = 0, $add_ptr7_i = 0, $add_ptr_sum_i = 0, $add_i = 0, $9 = 0, $incdec_ptr_pre_phi_i = 0, label = 0; $arrayidx_i = $array + ($nelem << 2) | 0; L1726 : do { if (($nelem | 0) != 0) { $a_07_i = $array; L1727 : while (1) { $0 = HEAP32[$a_07_i >> 2] | 0; L1729 : do { if (($0 | 0) == 0) { $incdec_ptr_pre_phi_i = $a_07_i + 4 | 0; } else { $add_ptr_i = $0 - 8 | 0; $1 = $add_ptr_i; $2 = $0 - 4 | 0; $and_i = HEAP32[$2 >> 2] & -8; HEAP32[$a_07_i >> 2] = 0; if ($add_ptr_i >>> 0 < (HEAP32[11606] | 0) >>> 0) { label = 1312; break L1727; } $5 = HEAP32[$2 >> 2] | 0; if (($5 & 3 | 0) == 1) { label = 1313; break L1727; } $add_ptr7_i = $a_07_i + 4 | 0; $add_ptr_sum_i = $5 - 8 & -8; do { if (($add_ptr7_i | 0) != ($arrayidx_i | 0)) { if ((HEAP32[$add_ptr7_i >> 2] | 0) != ($0 + ($add_ptr_sum_i + 8) | 0)) { break; } $add_i = (HEAP32[$0 + ($add_ptr_sum_i | 4) >> 2] & -8) + $and_i | 0; HEAP32[$2 >> 2] = $5 & 1 | $add_i | 2; $9 = $0 + ($add_i - 4) | 0; HEAP32[$9 >> 2] = HEAP32[$9 >> 2] | 1; HEAP32[$add_ptr7_i >> 2] = $0; $incdec_ptr_pre_phi_i = $add_ptr7_i; break L1729; } } while (0); _dispose_chunk($1, $and_i); $incdec_ptr_pre_phi_i = $add_ptr7_i; } } while (0); if (($incdec_ptr_pre_phi_i | 0) == ($arrayidx_i | 0)) { break L1726; } else { $a_07_i = $incdec_ptr_pre_phi_i; } } if ((label | 0) == 1312) { _abort(); return 0; } else if ((label | 0) == 1313) { _abort(); return 0; } } } while (0); if ((HEAP32[11605] | 0) >>> 0 <= (HEAP32[11609] | 0) >>> 0) { return 0; } _sys_trim(0) | 0; return 0; } function _malloc_trim($pad) { $pad = $pad | 0; var $call_i = 0, $call1 = 0; if ((HEAP32[10824] | 0) != 0) { $call1 = _sys_trim($pad) | 0; return $call1 | 0; } $call_i = _sysconf(8) | 0; if (($call_i - 1 & $call_i | 0) != 0) { _abort(); return 0; } HEAP32[10826] = $call_i; HEAP32[10825] = $call_i; HEAP32[10827] = -1; HEAP32[10828] = 2097152; HEAP32[10829] = 0; HEAP32[11713] = 0; HEAP32[10824] = (_time(0) | 0) & -16 ^ 1431655768; $call1 = _sys_trim($pad) | 0; return $call1 | 0; } function _mallinfo($agg_result) { $agg_result = $agg_result | 0; var $call_i_i = 0, $1 = 0, $2 = 0, $add_i = 0, $s_011_i = 0, $sum_010_i = 0, $mfree_09_i = 0, $nfree_08_i = 0, $3 = 0, $4 = 0, $cond_i = 0, $add_ptr14_i = 0, $q_0_in5_i = 0, $sum_14_i = 0, $mfree_13_i = 0, $nfree_12_i = 0, $8 = 0, $and22_i = 0, $add23_i = 0, $nfree_2_i = 0, $mfree_2_i = 0, $add_ptr31_i = 0, $sum_1_lcssa_i = 0, $mfree_1_lcssa_i = 0, $nfree_1_lcssa_i = 0, $9 = 0, $10 = 0, $nm_sroa_7_0_i = 0, $nm_sroa_6_0_i = 0, $nm_sroa_4_0_i = 0, $nm_sroa_3_0_i = 0, $nm_sroa_1_0_i = 0, $nm_sroa_0_0_i = 0, $nm_sroa_8_0_i = 0, $12 = 0; do { if ((HEAP32[10824] | 0) == 0) { $call_i_i = _sysconf(8) | 0; if (($call_i_i - 1 & $call_i_i | 0) == 0) { HEAP32[10826] = $call_i_i; HEAP32[10825] = $call_i_i; HEAP32[10827] = -1; HEAP32[10828] = 2097152; HEAP32[10829] = 0; HEAP32[11713] = 0; HEAP32[10824] = (_time(0) | 0) & -16 ^ 1431655768; break; } else { _abort(); } } } while (0); $1 = HEAP32[11608] | 0; if (($1 | 0) == 0) { $nm_sroa_8_0_i = 0; $nm_sroa_0_0_i = 0; $nm_sroa_1_0_i = 0; $nm_sroa_3_0_i = 0; $nm_sroa_4_0_i = 0; $nm_sroa_6_0_i = 0; $nm_sroa_7_0_i = 0; } else { $2 = HEAP32[11605] | 0; $add_i = $2 + 40 | 0; $nfree_08_i = 1; $mfree_09_i = $add_i; $sum_010_i = $add_i; $s_011_i = 46856; while (1) { $3 = HEAP32[$s_011_i >> 2] | 0; $4 = $3 + 8 | 0; if (($4 & 7 | 0) == 0) { $cond_i = 0; } else { $cond_i = -$4 & 7; } $add_ptr14_i = $3 + (HEAP32[$s_011_i + 4 >> 2] | 0) | 0; $nfree_12_i = $nfree_08_i; $mfree_13_i = $mfree_09_i; $sum_14_i = $sum_010_i; $q_0_in5_i = $3 + $cond_i | 0; while (1) { if ($q_0_in5_i >>> 0 >= $add_ptr14_i >>> 0 | ($q_0_in5_i | 0) == ($1 | 0)) { $nfree_1_lcssa_i = $nfree_12_i; $mfree_1_lcssa_i = $mfree_13_i; $sum_1_lcssa_i = $sum_14_i; break; } $8 = HEAP32[$q_0_in5_i + 4 >> 2] | 0; if (($8 | 0) == 7) { $nfree_1_lcssa_i = $nfree_12_i; $mfree_1_lcssa_i = $mfree_13_i; $sum_1_lcssa_i = $sum_14_i; break; } $and22_i = $8 & -8; $add23_i = $and22_i + $sum_14_i | 0; if (($8 & 3 | 0) == 1) { $mfree_2_i = $and22_i + $mfree_13_i | 0; $nfree_2_i = $nfree_12_i + 1 | 0; } else { $mfree_2_i = $mfree_13_i; $nfree_2_i = $nfree_12_i; } $add_ptr31_i = $q_0_in5_i + $and22_i | 0; if ($add_ptr31_i >>> 0 < $3 >>> 0) { $nfree_1_lcssa_i = $nfree_2_i; $mfree_1_lcssa_i = $mfree_2_i; $sum_1_lcssa_i = $add23_i; break; } else { $nfree_12_i = $nfree_2_i; $mfree_13_i = $mfree_2_i; $sum_14_i = $add23_i; $q_0_in5_i = $add_ptr31_i; } } $9 = HEAP32[$s_011_i + 8 >> 2] | 0; if (($9 | 0) == 0) { break; } else { $nfree_08_i = $nfree_1_lcssa_i; $mfree_09_i = $mfree_1_lcssa_i; $sum_010_i = $sum_1_lcssa_i; $s_011_i = $9; } } $10 = HEAP32[11710] | 0; $nm_sroa_8_0_i = $2; $nm_sroa_0_0_i = $sum_1_lcssa_i; $nm_sroa_1_0_i = $nfree_1_lcssa_i; $nm_sroa_3_0_i = $10 - $sum_1_lcssa_i | 0; $nm_sroa_4_0_i = HEAP32[11711] | 0; $nm_sroa_6_0_i = $10 - $mfree_1_lcssa_i | 0; $nm_sroa_7_0_i = $mfree_1_lcssa_i; } HEAP32[$agg_result >> 2] = $nm_sroa_0_0_i; HEAP32[$agg_result + 4 >> 2] = $nm_sroa_1_0_i; $12 = $agg_result + 8 | 0; HEAP32[$12 >> 2] = 0; HEAP32[$12 + 4 >> 2] = 0; HEAP32[$agg_result + 16 >> 2] = $nm_sroa_3_0_i; HEAP32[$agg_result + 20 >> 2] = $nm_sroa_4_0_i; HEAP32[$agg_result + 24 >> 2] = 0; HEAP32[$agg_result + 28 >> 2] = $nm_sroa_6_0_i; HEAP32[$agg_result + 32 >> 2] = $nm_sroa_7_0_i; HEAP32[$agg_result + 36 >> 2] = $nm_sroa_8_0_i; return; } function _malloc_stats() { var $call_i_i = 0, $1 = 0, $2 = 0, $3 = 0, $s_05_i = 0, $used_04_i = 0, $5 = 0, $6 = 0, $cond_i = 0, $add_ptr15_i = 0, $q_0_in3_i = 0, $used_12_i = 0, $10 = 0, $and27_i = 0, $used_2_i = 0, $add_ptr31_i = 0, $used_1_lcssa_i = 0, $11 = 0, $maxfp_0_i = 0, $fp_0_i = 0, $used_3_i = 0, sp = 0; sp = STACKTOP; do { if ((HEAP32[10824] | 0) == 0) { $call_i_i = _sysconf(8) | 0; if (($call_i_i - 1 & $call_i_i | 0) == 0) { HEAP32[10826] = $call_i_i; HEAP32[10825] = $call_i_i; HEAP32[10827] = -1; HEAP32[10828] = 2097152; HEAP32[10829] = 0; HEAP32[11713] = 0; HEAP32[10824] = (_time(0) | 0) & -16 ^ 1431655768; break; } else { _abort(); } } } while (0); $1 = HEAP32[11608] | 0; if (($1 | 0) == 0) { $used_3_i = 0; $fp_0_i = 0; $maxfp_0_i = 0; } else { $2 = HEAP32[11711] | 0; $3 = HEAP32[11710] | 0; $used_04_i = $3 - 40 - (HEAP32[11605] | 0) | 0; $s_05_i = 46856; while (1) { $5 = HEAP32[$s_05_i >> 2] | 0; $6 = $5 + 8 | 0; if (($6 & 7 | 0) == 0) { $cond_i = 0; } else { $cond_i = -$6 & 7; } $add_ptr15_i = $5 + (HEAP32[$s_05_i + 4 >> 2] | 0) | 0; $used_12_i = $used_04_i; $q_0_in3_i = $5 + $cond_i | 0; while (1) { if ($q_0_in3_i >>> 0 >= $add_ptr15_i >>> 0 | ($q_0_in3_i | 0) == ($1 | 0)) { $used_1_lcssa_i = $used_12_i; break; } $10 = HEAP32[$q_0_in3_i + 4 >> 2] | 0; if (($10 | 0) == 7) { $used_1_lcssa_i = $used_12_i; break; } $and27_i = $10 & -8; $used_2_i = $used_12_i - (($10 & 3 | 0) == 1 ? $and27_i : 0) | 0; $add_ptr31_i = $q_0_in3_i + $and27_i | 0; if ($add_ptr31_i >>> 0 < $5 >>> 0) { $used_1_lcssa_i = $used_2_i; break; } else { $used_12_i = $used_2_i; $q_0_in3_i = $add_ptr31_i; } } $11 = HEAP32[$s_05_i + 8 >> 2] | 0; if (($11 | 0) == 0) { $used_3_i = $used_1_lcssa_i; $fp_0_i = $3; $maxfp_0_i = $2; break; } else { $used_04_i = $used_1_lcssa_i; $s_05_i = $11; } } } _fprintf(HEAP32[_stderr >> 2] | 0, 1768, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = $maxfp_0_i, tempInt) | 0) | 0; _fprintf(HEAP32[_stderr >> 2] | 0, 3768, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = $fp_0_i, tempInt) | 0) | 0; _fprintf(HEAP32[_stderr >> 2] | 0, 2680, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = $used_3_i, tempInt) | 0) | 0; STACKTOP = sp; return; } function _malloc_usable_size($mem) { $mem = $mem | 0; var $1 = 0, $and = 0, $retval_0 = 0; do { if (($mem | 0) == 0) { $retval_0 = 0; } else { $1 = HEAP32[$mem - 4 >> 2] | 0; $and = $1 & 3; if (($and | 0) == 1) { $retval_0 = 0; break; } $retval_0 = ($1 & -8) - (($and | 0) == 0 ? 8 : 4) | 0; } } while (0); return $retval_0 | 0; } function _mallopt($param_number, $value) { $param_number = $param_number | 0; $value = $value | 0; var $call_i_i = 0, $retval_0_i = 0; do { if ((HEAP32[10824] | 0) == 0) { $call_i_i = _sysconf(8) | 0; if (($call_i_i - 1 & $call_i_i | 0) == 0) { HEAP32[10826] = $call_i_i; HEAP32[10825] = $call_i_i; HEAP32[10827] = -1; HEAP32[10828] = 2097152; HEAP32[10829] = 0; HEAP32[11713] = 0; HEAP32[10824] = (_time(0) | 0) & -16 ^ 1431655768; break; } else { _abort(); return 0; } } } while (0); if (($param_number | 0) == (-1 | 0)) { HEAP32[10828] = $value; $retval_0_i = 1; return $retval_0_i | 0; } else if (($param_number | 0) == (-2 | 0)) { if ((HEAP32[10825] | 0) >>> 0 > $value >>> 0) { $retval_0_i = 0; return $retval_0_i | 0; } if (($value - 1 & $value | 0) != 0) { $retval_0_i = 0; return $retval_0_i | 0; } HEAP32[10826] = $value; $retval_0_i = 1; return $retval_0_i | 0; } else if (($param_number | 0) == (-3 | 0)) { HEAP32[10827] = $value; $retval_0_i = 1; return $retval_0_i | 0; } else { $retval_0_i = 0; return $retval_0_i | 0; } return 0; } function __ZSt15get_new_handlerv() { return (tempValue = HEAP32[11858] | 0, HEAP32[11858] = tempValue + 0, tempValue) | 0; } function _dispose_chunk($p, $psize) { $p = $p | 0; $psize = $psize | 0; var $0 = 0, $add_ptr = 0, $1 = 0, $2 = 0, $3 = 0, $add_ptr5 = 0, $4 = 0, $add6 = 0, $5 = 0, $shr = 0, $8 = 0, $10 = 0, $11 = 0, $fd43 = 0, $fd53_pre_phi = 0, $17 = 0, $19 = 0, $21 = 0, $23 = 0, $bk70 = 0, $fd74 = 0, $add_ptr5_sum24 = 0, $27 = 0, $28 = 0, $arrayidx90 = 0, $29 = 0, $RP_0 = 0, $R_0 = 0, $arrayidx95 = 0, $30 = 0, $arrayidx100 = 0, $31 = 0, $R_1 = 0, $33 = 0, $arrayidx118 = 0, $arrayidx138 = 0, $add_ptr5_sum26 = 0, $43 = 0, $47 = 0, $50 = 0, $psize_addr_0 = 0, $p_addr_0 = 0, $54 = 0, $55 = 0, $56 = 0, $add229 = 0, $add246 = 0, $add255 = 0, $shr256 = 0, $64 = 0, $66 = 0, $67 = 0, $fd304 = 0, $fd315_pre_phi = 0, $73 = 0, $75 = 0, $77 = 0, $79 = 0, $bk337 = 0, $fd341 = 0, $83 = 0, $84 = 0, $arrayidx361 = 0, $85 = 0, $RP354_0 = 0, $R325_0 = 0, $arrayidx368 = 0, $86 = 0, $arrayidx373 = 0, $87 = 0, $R325_1 = 0, $89 = 0, $arrayidx396 = 0, $arrayidx417 = 0, $99 = 0, $103 = 0, $psize_addr_1 = 0, $shr501 = 0, $shl508 = 0, $109 = 0, $110 = 0, $shl513 = 0, $111 = 0, $112 = 0, $_pre_phi = 0, $F511_0 = 0, $115 = 0, $shr540 = 0, $and550 = 0, $shl551 = 0, $and554 = 0, $shl556 = 0, $and559 = 0, $add564 = 0, $I539_0 = 0, $arrayidx573 = 0, $117 = 0, $shl580 = 0, $cond = 0, $T_0 = 0, $K591_0 = 0, $arrayidx607 = 0, $120 = 0, $fd626 = 0, $123 = 0, $125 = 0, label = 0; $0 = $p; $add_ptr = $0 + $psize | 0; $1 = $add_ptr; $2 = HEAP32[$p + 4 >> 2] | 0; L1827 : do { if (($2 & 1 | 0) == 0) { $3 = HEAP32[$p >> 2] | 0; if (($2 & 3 | 0) == 0) { return; } $add_ptr5 = $0 + (-$3 | 0) | 0; $4 = $add_ptr5; $add6 = $3 + $psize | 0; $5 = HEAP32[11606] | 0; if ($add_ptr5 >>> 0 < $5 >>> 0) { _abort(); } if (($4 | 0) == (HEAP32[11607] | 0)) { $50 = $0 + ($psize + 4) | 0; if ((HEAP32[$50 >> 2] & 3 | 0) != 3) { $p_addr_0 = $4; $psize_addr_0 = $add6; break; } HEAP32[11604] = $add6; HEAP32[$50 >> 2] = HEAP32[$50 >> 2] & -2; HEAP32[$0 + (4 - $3) >> 2] = $add6 | 1; HEAP32[$add_ptr >> 2] = $add6; return; } $shr = $3 >>> 3; if ($3 >>> 0 < 256) { $8 = HEAP32[$0 + (8 - $3) >> 2] | 0; $10 = HEAP32[$0 + (12 - $3) >> 2] | 0; $11 = 46448 + ($shr << 1 << 2) | 0; do { if (($8 | 0) != ($11 | 0)) { if ($8 >>> 0 < $5 >>> 0) { _abort(); } if ((HEAP32[$8 + 12 >> 2] | 0) == ($4 | 0)) { break; } _abort(); } } while (0); if (($10 | 0) == ($8 | 0)) { HEAP32[11602] = HEAP32[11602] & ~(1 << $shr); $p_addr_0 = $4; $psize_addr_0 = $add6; break; } do { if (($10 | 0) == ($11 | 0)) { $fd53_pre_phi = $10 + 8 | 0; } else { if ($10 >>> 0 < $5 >>> 0) { _abort(); } $fd43 = $10 + 8 | 0; if ((HEAP32[$fd43 >> 2] | 0) == ($4 | 0)) { $fd53_pre_phi = $fd43; break; } _abort(); } } while (0); HEAP32[$8 + 12 >> 2] = $10; HEAP32[$fd53_pre_phi >> 2] = $8; $p_addr_0 = $4; $psize_addr_0 = $add6; break; } $17 = $add_ptr5; $19 = HEAP32[$0 + (24 - $3) >> 2] | 0; $21 = HEAP32[$0 + (12 - $3) >> 2] | 0; do { if (($21 | 0) == ($17 | 0)) { $add_ptr5_sum24 = 16 - $3 | 0; $27 = $0 + ($add_ptr5_sum24 + 4) | 0; $28 = HEAP32[$27 >> 2] | 0; if (($28 | 0) == 0) { $arrayidx90 = $0 + $add_ptr5_sum24 | 0; $29 = HEAP32[$arrayidx90 >> 2] | 0; if (($29 | 0) == 0) { $R_1 = 0; break; } else { $R_0 = $29; $RP_0 = $arrayidx90; } } else { $R_0 = $28; $RP_0 = $27; } while (1) { $arrayidx95 = $R_0 + 20 | 0; $30 = HEAP32[$arrayidx95 >> 2] | 0; if (($30 | 0) != 0) { $R_0 = $30; $RP_0 = $arrayidx95; continue; } $arrayidx100 = $R_0 + 16 | 0; $31 = HEAP32[$arrayidx100 >> 2] | 0; if (($31 | 0) == 0) { break; } else { $R_0 = $31; $RP_0 = $arrayidx100; } } if ($RP_0 >>> 0 < $5 >>> 0) { _abort(); } else { HEAP32[$RP_0 >> 2] = 0; $R_1 = $R_0; break; } } else { $23 = HEAP32[$0 + (8 - $3) >> 2] | 0; if ($23 >>> 0 < $5 >>> 0) { _abort(); } $bk70 = $23 + 12 | 0; if ((HEAP32[$bk70 >> 2] | 0) != ($17 | 0)) { _abort(); } $fd74 = $21 + 8 | 0; if ((HEAP32[$fd74 >> 2] | 0) == ($17 | 0)) { HEAP32[$bk70 >> 2] = $21; HEAP32[$fd74 >> 2] = $23; $R_1 = $21; break; } else { _abort(); } } } while (0); if (($19 | 0) == 0) { $p_addr_0 = $4; $psize_addr_0 = $add6; break; } $33 = $0 + (28 - $3) | 0; $arrayidx118 = 46712 + (HEAP32[$33 >> 2] << 2) | 0; do { if (($17 | 0) == (HEAP32[$arrayidx118 >> 2] | 0)) { HEAP32[$arrayidx118 >> 2] = $R_1; if (($R_1 | 0) != 0) { break; } HEAP32[11603] = HEAP32[11603] & ~(1 << HEAP32[$33 >> 2]); $p_addr_0 = $4; $psize_addr_0 = $add6; break L1827; } else { if ($19 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); } $arrayidx138 = $19 + 16 | 0; if ((HEAP32[$arrayidx138 >> 2] | 0) == ($17 | 0)) { HEAP32[$arrayidx138 >> 2] = $R_1; } else { HEAP32[$19 + 20 >> 2] = $R_1; } if (($R_1 | 0) == 0) { $p_addr_0 = $4; $psize_addr_0 = $add6; break L1827; } } } while (0); if ($R_1 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); } HEAP32[$R_1 + 24 >> 2] = $19; $add_ptr5_sum26 = 16 - $3 | 0; $43 = HEAP32[$0 + $add_ptr5_sum26 >> 2] | 0; do { if (($43 | 0) != 0) { if ($43 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); } else { HEAP32[$R_1 + 16 >> 2] = $43; HEAP32[$43 + 24 >> 2] = $R_1; break; } } } while (0); $47 = HEAP32[$0 + ($add_ptr5_sum26 + 4) >> 2] | 0; if (($47 | 0) == 0) { $p_addr_0 = $4; $psize_addr_0 = $add6; break; } if ($47 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); } else { HEAP32[$R_1 + 20 >> 2] = $47; HEAP32[$47 + 24 >> 2] = $R_1; $p_addr_0 = $4; $psize_addr_0 = $add6; break; } } else { $p_addr_0 = $p; $psize_addr_0 = $psize; } } while (0); $54 = HEAP32[11606] | 0; if ($add_ptr >>> 0 < $54 >>> 0) { _abort(); } $55 = $0 + ($psize + 4) | 0; $56 = HEAP32[$55 >> 2] | 0; do { if (($56 & 2 | 0) == 0) { if (($1 | 0) == (HEAP32[11608] | 0)) { $add229 = (HEAP32[11605] | 0) + $psize_addr_0 | 0; HEAP32[11605] = $add229; HEAP32[11608] = $p_addr_0; HEAP32[$p_addr_0 + 4 >> 2] = $add229 | 1; if (($p_addr_0 | 0) != (HEAP32[11607] | 0)) { return; } HEAP32[11607] = 0; HEAP32[11604] = 0; return; } if (($1 | 0) == (HEAP32[11607] | 0)) { $add246 = (HEAP32[11604] | 0) + $psize_addr_0 | 0; HEAP32[11604] = $add246; HEAP32[11607] = $p_addr_0; HEAP32[$p_addr_0 + 4 >> 2] = $add246 | 1; HEAP32[$p_addr_0 + $add246 >> 2] = $add246; return; } $add255 = ($56 & -8) + $psize_addr_0 | 0; $shr256 = $56 >>> 3; L1926 : do { if ($56 >>> 0 < 256) { $64 = HEAP32[$0 + ($psize + 8) >> 2] | 0; $66 = HEAP32[$0 + ($psize + 12) >> 2] | 0; $67 = 46448 + ($shr256 << 1 << 2) | 0; do { if (($64 | 0) != ($67 | 0)) { if ($64 >>> 0 < $54 >>> 0) { _abort(); } if ((HEAP32[$64 + 12 >> 2] | 0) == ($1 | 0)) { break; } _abort(); } } while (0); if (($66 | 0) == ($64 | 0)) { HEAP32[11602] = HEAP32[11602] & ~(1 << $shr256); break; } do { if (($66 | 0) == ($67 | 0)) { $fd315_pre_phi = $66 + 8 | 0; } else { if ($66 >>> 0 < $54 >>> 0) { _abort(); } $fd304 = $66 + 8 | 0; if ((HEAP32[$fd304 >> 2] | 0) == ($1 | 0)) { $fd315_pre_phi = $fd304; break; } _abort(); } } while (0); HEAP32[$64 + 12 >> 2] = $66; HEAP32[$fd315_pre_phi >> 2] = $64; } else { $73 = $add_ptr; $75 = HEAP32[$0 + ($psize + 24) >> 2] | 0; $77 = HEAP32[$0 + ($psize + 12) >> 2] | 0; do { if (($77 | 0) == ($73 | 0)) { $83 = $0 + ($psize + 20) | 0; $84 = HEAP32[$83 >> 2] | 0; if (($84 | 0) == 0) { $arrayidx361 = $0 + ($psize + 16) | 0; $85 = HEAP32[$arrayidx361 >> 2] | 0; if (($85 | 0) == 0) { $R325_1 = 0; break; } else { $R325_0 = $85; $RP354_0 = $arrayidx361; } } else { $R325_0 = $84; $RP354_0 = $83; } while (1) { $arrayidx368 = $R325_0 + 20 | 0; $86 = HEAP32[$arrayidx368 >> 2] | 0; if (($86 | 0) != 0) { $R325_0 = $86; $RP354_0 = $arrayidx368; continue; } $arrayidx373 = $R325_0 + 16 | 0; $87 = HEAP32[$arrayidx373 >> 2] | 0; if (($87 | 0) == 0) { break; } else { $R325_0 = $87; $RP354_0 = $arrayidx373; } } if ($RP354_0 >>> 0 < $54 >>> 0) { _abort(); } else { HEAP32[$RP354_0 >> 2] = 0; $R325_1 = $R325_0; break; } } else { $79 = HEAP32[$0 + ($psize + 8) >> 2] | 0; if ($79 >>> 0 < $54 >>> 0) { _abort(); } $bk337 = $79 + 12 | 0; if ((HEAP32[$bk337 >> 2] | 0) != ($73 | 0)) { _abort(); } $fd341 = $77 + 8 | 0; if ((HEAP32[$fd341 >> 2] | 0) == ($73 | 0)) { HEAP32[$bk337 >> 2] = $77; HEAP32[$fd341 >> 2] = $79; $R325_1 = $77; break; } else { _abort(); } } } while (0); if (($75 | 0) == 0) { break; } $89 = $0 + ($psize + 28) | 0; $arrayidx396 = 46712 + (HEAP32[$89 >> 2] << 2) | 0; do { if (($73 | 0) == (HEAP32[$arrayidx396 >> 2] | 0)) { HEAP32[$arrayidx396 >> 2] = $R325_1; if (($R325_1 | 0) != 0) { break; } HEAP32[11603] = HEAP32[11603] & ~(1 << HEAP32[$89 >> 2]); break L1926; } else { if ($75 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); } $arrayidx417 = $75 + 16 | 0; if ((HEAP32[$arrayidx417 >> 2] | 0) == ($73 | 0)) { HEAP32[$arrayidx417 >> 2] = $R325_1; } else { HEAP32[$75 + 20 >> 2] = $R325_1; } if (($R325_1 | 0) == 0) { break L1926; } } } while (0); if ($R325_1 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); } HEAP32[$R325_1 + 24 >> 2] = $75; $99 = HEAP32[$0 + ($psize + 16) >> 2] | 0; do { if (($99 | 0) != 0) { if ($99 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); } else { HEAP32[$R325_1 + 16 >> 2] = $99; HEAP32[$99 + 24 >> 2] = $R325_1; break; } } } while (0); $103 = HEAP32[$0 + ($psize + 20) >> 2] | 0; if (($103 | 0) == 0) { break; } if ($103 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); } else { HEAP32[$R325_1 + 20 >> 2] = $103; HEAP32[$103 + 24 >> 2] = $R325_1; break; } } } while (0); HEAP32[$p_addr_0 + 4 >> 2] = $add255 | 1; HEAP32[$p_addr_0 + $add255 >> 2] = $add255; if (($p_addr_0 | 0) != (HEAP32[11607] | 0)) { $psize_addr_1 = $add255; break; } HEAP32[11604] = $add255; return; } else { HEAP32[$55 >> 2] = $56 & -2; HEAP32[$p_addr_0 + 4 >> 2] = $psize_addr_0 | 1; HEAP32[$p_addr_0 + $psize_addr_0 >> 2] = $psize_addr_0; $psize_addr_1 = $psize_addr_0; } } while (0); $shr501 = $psize_addr_1 >>> 3; if ($psize_addr_1 >>> 0 < 256) { $shl508 = $shr501 << 1; $109 = 46448 + ($shl508 << 2) | 0; $110 = HEAP32[11602] | 0; $shl513 = 1 << $shr501; do { if (($110 & $shl513 | 0) == 0) { HEAP32[11602] = $110 | $shl513; $F511_0 = $109; $_pre_phi = 46448 + ($shl508 + 2 << 2) | 0; } else { $111 = 46448 + ($shl508 + 2 << 2) | 0; $112 = HEAP32[$111 >> 2] | 0; if ($112 >>> 0 >= (HEAP32[11606] | 0) >>> 0) { $F511_0 = $112; $_pre_phi = $111; break; } _abort(); } } while (0); HEAP32[$_pre_phi >> 2] = $p_addr_0; HEAP32[$F511_0 + 12 >> 2] = $p_addr_0; HEAP32[$p_addr_0 + 8 >> 2] = $F511_0; HEAP32[$p_addr_0 + 12 >> 2] = $109; return; } $115 = $p_addr_0; $shr540 = $psize_addr_1 >>> 8; do { if (($shr540 | 0) == 0) { $I539_0 = 0; } else { if ($psize_addr_1 >>> 0 > 16777215) { $I539_0 = 31; break; } $and550 = ($shr540 + 1048320 | 0) >>> 16 & 8; $shl551 = $shr540 << $and550; $and554 = ($shl551 + 520192 | 0) >>> 16 & 4; $shl556 = $shl551 << $and554; $and559 = ($shl556 + 245760 | 0) >>> 16 & 2; $add564 = 14 - ($and554 | $and550 | $and559) + ($shl556 << $and559 >>> 15) | 0; $I539_0 = $psize_addr_1 >>> (($add564 + 7 | 0) >>> 0) & 1 | $add564 << 1; } } while (0); $arrayidx573 = 46712 + ($I539_0 << 2) | 0; HEAP32[$p_addr_0 + 28 >> 2] = $I539_0; HEAP32[$p_addr_0 + 20 >> 2] = 0; HEAP32[$p_addr_0 + 16 >> 2] = 0; $117 = HEAP32[11603] | 0; $shl580 = 1 << $I539_0; if (($117 & $shl580 | 0) == 0) { HEAP32[11603] = $117 | $shl580; HEAP32[$arrayidx573 >> 2] = $115; HEAP32[$p_addr_0 + 24 >> 2] = $arrayidx573; HEAP32[$p_addr_0 + 12 >> 2] = $p_addr_0; HEAP32[$p_addr_0 + 8 >> 2] = $p_addr_0; return; } if (($I539_0 | 0) == 31) { $cond = 0; } else { $cond = 25 - ($I539_0 >>> 1) | 0; } $K591_0 = $psize_addr_1 << $cond; $T_0 = HEAP32[$arrayidx573 >> 2] | 0; while (1) { if ((HEAP32[$T_0 + 4 >> 2] & -8 | 0) == ($psize_addr_1 | 0)) { break; } $arrayidx607 = $T_0 + 16 + ($K591_0 >>> 31 << 2) | 0; $120 = HEAP32[$arrayidx607 >> 2] | 0; if (($120 | 0) == 0) { label = 1501; break; } else { $K591_0 = $K591_0 << 1; $T_0 = $120; } } if ((label | 0) == 1501) { if ($arrayidx607 >>> 0 < (HEAP32[11606] | 0) >>> 0) { _abort(); } HEAP32[$arrayidx607 >> 2] = $115; HEAP32[$p_addr_0 + 24 >> 2] = $T_0; HEAP32[$p_addr_0 + 12 >> 2] = $p_addr_0; HEAP32[$p_addr_0 + 8 >> 2] = $p_addr_0; return; } $fd626 = $T_0 + 8 | 0; $123 = HEAP32[$fd626 >> 2] | 0; $125 = HEAP32[11606] | 0; if ($T_0 >>> 0 < $125 >>> 0) { _abort(); } if ($123 >>> 0 < $125 >>> 0) { _abort(); } HEAP32[$123 + 12 >> 2] = $115; HEAP32[$fd626 >> 2] = $115; HEAP32[$p_addr_0 + 8 >> 2] = $123; HEAP32[$p_addr_0 + 12 >> 2] = $T_0; HEAP32[$p_addr_0 + 24 >> 2] = 0; return; } function __Znwj($size) { $size = $size | 0; var $_size = 0, $call = 0, $0 = 0, $exception = 0, label = 0; $_size = ($size | 0) == 0 ? 1 : $size; while (1) { $call = _malloc($_size) | 0; if (($call | 0) != 0) { label = 1545; break; } $0 = (tempValue = HEAP32[11858] | 0, HEAP32[11858] = tempValue + 0, tempValue); if (($0 | 0) == 0) { break; } FUNCTION_TABLE_v[$0 & 3](); } if ((label | 0) == 1545) { return $call | 0; } $exception = ___cxa_allocate_exception(4) | 0; HEAP32[$exception >> 2] = 8048; ___cxa_throw($exception | 0, 9944, 38); return 0; } function __ZNSt9bad_allocD2Ev($this) { $this = $this | 0; return; } function __ZNKSt9bad_alloc4whatEv($this) { $this = $this | 0; return 1752 | 0; } function __ZNKSt20bad_array_new_length4whatEv($this) { $this = $this | 0; return 3616 | 0; } function __ZSt15set_new_handlerPFvvE($handler) { $handler = $handler | 0; return (tempValue = HEAP32[11858] | 0, HEAP32[11858] = $handler, tempValue) | 0; } function __ZNSt9bad_allocC2Ev($this) { $this = $this | 0; HEAP32[$this >> 2] = 8048; return; } function __ZNSt20bad_array_new_lengthC2Ev($this) { $this = $this | 0; HEAP32[$this >> 2] = 8112; return; } function __ZdlPv($ptr) { $ptr = $ptr | 0; if (($ptr | 0) == 0) { return; } _free($ptr); return; } function __ZdlPvRKSt9nothrow_t($ptr, $0) { $ptr = $ptr | 0; $0 = $0 | 0; __ZdlPv($ptr); return; } function __ZdaPv($ptr) { $ptr = $ptr | 0; __ZdlPv($ptr); return; } function __ZdaPvRKSt9nothrow_t($ptr, $0) { $ptr = $ptr | 0; $0 = $0 | 0; __ZdaPv($ptr); return; } function __ZNSt9bad_allocD0Ev($this) { $this = $this | 0; __ZdlPv($this); return; } function __ZNSt20bad_array_new_lengthD0Ev($this) { $this = $this | 0; __ZdlPv($this); return; } function _getopt($nargc, $nargv, $options) { $nargc = $nargc | 0; $nargv = $nargv | 0; $options = $options | 0; return _getopt_internal($nargc, $nargv, $options, 0, 0, 0) | 0; } function _getopt_internal($nargc, $nargv, $options, $long_options, $idx, $flags) { $nargc = $nargc | 0; $nargv = $nargv | 0; $options = $options | 0; $long_options = $long_options | 0; $idx = $idx | 0; $flags = $flags | 0; var $0 = 0, $_pre137 = 0, $1 = 0, $2 = 0, $3 = 0, $conv = 0, $4 = 0, $5 = 0, $6 = 0, $7 = 0, $and_flags = 0, $flags_addr_0146 = 0, $flags_addr_0147 = 0, $options_addr_0 = 0, $_pr = 0, $8 = 0, $9 = 0, $10 = 0, $12 = 0, $13 = 0, $14 = 0, $sub_i = 0, $sub1_i = 0, $rem_i_i = 0, $c_07_i_i = 0, $b_addr_06_i_i = 0, $rem1_i_i = 0, $b_addr_0_lcssa_i_i = 0, $div_i = 0, $15 = 0, $16 = 0, $pos_023_us_i = 0, $j_022_us_i = 0, $pos_1_us_i = 0, $arrayidx_us_i = 0, $17 = 0, $inc_us_i = 0, $i_025_us_i = 0, $add_us_i = 0, $arrayidx9_us_i = 0, $18 = 0, $19 = 0, $20 = 0, $arrayidx = 0, $21 = 0, $arrayidx54 = 0, $23 = 0, $25 = 0, $26 = 0, $sub_i56 = 0, $sub1_i57 = 0, $rem_i_i58 = 0, $c_07_i_i60 = 0, $b_addr_06_i_i61 = 0, $rem1_i_i62 = 0, $b_addr_0_lcssa_i_i65 = 0, $div_i67 = 0, $27 = 0, $28 = 0, $pos_023_us_i75 = 0, $j_022_us_i76 = 0, $pos_1_us_i79 = 0, $arrayidx_us_i80 = 0, $29 = 0, $inc_us_i81 = 0, $i_025_us_i84 = 0, $add_us_i85 = 0, $arrayidx9_us_i86 = 0, $_pr_pre_pre = 0, $30 = 0, $31 = 0, $32 = 0, $_pr_pre = 0, $33 = 0, $inc82 = 0, $34 = 0, $35 = 0, $36 = 0, $37 = 0, $inc106 = 0, $sub_i90 = 0, $sub1_i91 = 0, $rem_i_i92 = 0, $c_07_i_i94 = 0, $b_addr_06_i_i95 = 0, $rem1_i_i96 = 0, $b_addr_0_lcssa_i_i99 = 0, $div_i101 = 0, $40 = 0, $41 = 0, $pos_023_us_i109 = 0, $j_022_us_i110 = 0, $pos_1_us_i113 = 0, $arrayidx_us_i114 = 0, $42 = 0, $inc_us_i115 = 0, $i_025_us_i118 = 0, $add_us_i119 = 0, $arrayidx9_us_i120 = 0, $43 = 0, $44 = 0, $45 = 0, $46 = 0, $47 = 0, $cmp115 = 0, $49 = 0, $short_too_0 = 0, $call146 = 0, $50 = 0, $incdec_ptr152 = 0, $51 = 0, $conv153 = 0, $call164 = 0, $56 = 0, $inc202 = 0, $call220 = 0, $inc240 = 0, $retval_0 = 0, label = 0, sp = 0; sp = STACKTOP; if (($options | 0) == 0) { $retval_0 = -1; STACKTOP = sp; return $retval_0 | 0; } $0 = HEAP32[70] | 0; if (($0 | 0) == 0) { HEAP32[10820] = 1; HEAP32[70] = 1; $3 = 1; $2 = 1; label = 1569; } else { $_pre137 = HEAP32[10820] | 0; $1 = HEAP32[100] | 0; if (($1 | 0) == -1 | ($_pre137 | 0) != 0) { $3 = $_pre137; $2 = $0; label = 1569; } else { $6 = $1; $5 = $_pre137; $4 = $0; } } if ((label | 0) == 1569) { $conv = (_getenv(1216) | 0) != 0 | 0; HEAP32[100] = $conv; $6 = $conv; $5 = $3; $4 = $2; } $7 = HEAP8[$options] | 0; if ($7 << 24 >> 24 == 45) { $flags_addr_0146 = $flags | 2; label = 1573; } else { $and_flags = ($6 | 0) != 0 | $7 << 24 >> 24 == 43 ? $flags & -2 : $flags; if ($7 << 24 >> 24 == 43) { $flags_addr_0146 = $and_flags; label = 1573; } else { $options_addr_0 = $options; $flags_addr_0147 = $and_flags; } } if ((label | 0) == 1573) { $options_addr_0 = $options + 1 | 0; $flags_addr_0147 = $flags_addr_0146; } HEAP32[10822] = 0; if (($5 | 0) == 0) { $9 = $4; label = 1577; } else { HEAP32[76] = -1; HEAP32[74] = -1; $8 = $4; $_pr = $5; label = 1576; } while (1) { if ((label | 0) == 1576) { label = 0; if (($_pr | 0) == 0) { $9 = $8; label = 1577; continue; } else { $12 = $8; } } else if ((label | 0) == 1577) { label = 0; $10 = HEAP32[66] | 0; if ((HEAP8[$10] | 0) == 0) { $12 = $9; } else { $47 = $10; $46 = $9; break; } } HEAP32[10820] = 0; if (($12 | 0) >= ($nargc | 0)) { label = 1579; break; } $arrayidx = $nargv + ($12 << 2) | 0; $21 = HEAP32[$arrayidx >> 2] | 0; HEAP32[66] = $21; if ((HEAP8[$21] | 0) == 45) { $arrayidx54 = $21 + 1 | 0; $23 = HEAP8[$arrayidx54] | 0; if ($23 << 24 >> 24 != 0) { label = 1611; break; } if ((_strchr($options_addr_0 | 0, 45) | 0) != 0) { label = 1611; break; } } HEAP32[66] = 46400; if (($flags_addr_0147 & 2 | 0) != 0) { label = 1596; break; } if (($flags_addr_0147 & 1 | 0) == 0) { $retval_0 = -1; label = 1681; break; } $25 = HEAP32[74] | 0; do { if (($25 | 0) == -1) { HEAP32[74] = $12; $33 = $12; $_pr_pre = 0; } else { $26 = HEAP32[76] | 0; if (($26 | 0) == -1) { $33 = $12; $_pr_pre = 0; break; } $sub_i56 = $26 - $25 | 0; $sub1_i57 = $12 - $26 | 0; $rem_i_i58 = ($sub_i56 | 0) % ($sub1_i57 | 0) | 0; if (($rem_i_i58 | 0) == 0) { $b_addr_0_lcssa_i_i65 = $sub1_i57; } else { $b_addr_06_i_i61 = $sub1_i57; $c_07_i_i60 = $rem_i_i58; while (1) { $rem1_i_i62 = ($b_addr_06_i_i61 | 0) % ($c_07_i_i60 | 0) | 0; if (($rem1_i_i62 | 0) == 0) { $b_addr_0_lcssa_i_i65 = $c_07_i_i60; break; } else { $b_addr_06_i_i61 = $c_07_i_i60; $c_07_i_i60 = $rem1_i_i62; } } } $div_i67 = ($12 - $25 | 0) / ($b_addr_0_lcssa_i_i65 | 0) | 0; do { if (($b_addr_0_lcssa_i_i65 | 0) > 0) { $27 = -$sub_i56 | 0; if (($div_i67 | 0) > 0) { $i_025_us_i84 = 0; } else { $32 = $12; $31 = $26; $30 = $25; $_pr_pre_pre = 0; break; } do { $add_us_i85 = $i_025_us_i84 + $26 | 0; $arrayidx9_us_i86 = $nargv + ($add_us_i85 << 2) | 0; $j_022_us_i76 = 0; $pos_023_us_i75 = $add_us_i85; $28 = HEAP32[$arrayidx9_us_i86 >> 2] | 0; while (1) { $pos_1_us_i79 = (($pos_023_us_i75 | 0) < ($26 | 0) ? $sub1_i57 : $27) + $pos_023_us_i75 | 0; $arrayidx_us_i80 = $nargv + ($pos_1_us_i79 << 2) | 0; $29 = HEAP32[$arrayidx_us_i80 >> 2] | 0; HEAP32[$arrayidx_us_i80 >> 2] = $28; HEAP32[$arrayidx9_us_i86 >> 2] = $29; $inc_us_i81 = $j_022_us_i76 + 1 | 0; if (($inc_us_i81 | 0) < ($div_i67 | 0)) { $j_022_us_i76 = $inc_us_i81; $pos_023_us_i75 = $pos_1_us_i79; $28 = $29; } else { break; } } $i_025_us_i84 = $i_025_us_i84 + 1 | 0; } while (($i_025_us_i84 | 0) < ($b_addr_0_lcssa_i_i65 | 0)); $32 = HEAP32[70] | 0; $31 = HEAP32[76] | 0; $30 = HEAP32[74] | 0; $_pr_pre_pre = HEAP32[10820] | 0; } else { $32 = $12; $31 = $26; $30 = $25; $_pr_pre_pre = 0; } } while (0); HEAP32[74] = $32 - $31 + $30; HEAP32[76] = -1; $33 = $32; $_pr_pre = $_pr_pre_pre; } } while (0); $inc82 = $33 + 1 | 0; HEAP32[70] = $inc82; $8 = $inc82; $_pr = $_pr_pre; label = 1576; } do { if ((label | 0) == 1579) { HEAP32[66] = 46400; $13 = HEAP32[76] | 0; $14 = HEAP32[74] | 0; do { if (($13 | 0) == -1) { if (($14 | 0) == -1) { break; } HEAP32[70] = $14; } else { $sub_i = $13 - $14 | 0; $sub1_i = $12 - $13 | 0; $rem_i_i = ($sub_i | 0) % ($sub1_i | 0) | 0; if (($rem_i_i | 0) == 0) { $b_addr_0_lcssa_i_i = $sub1_i; } else { $b_addr_06_i_i = $sub1_i; $c_07_i_i = $rem_i_i; while (1) { $rem1_i_i = ($b_addr_06_i_i | 0) % ($c_07_i_i | 0) | 0; if (($rem1_i_i | 0) == 0) { $b_addr_0_lcssa_i_i = $c_07_i_i; break; } else { $b_addr_06_i_i = $c_07_i_i; $c_07_i_i = $rem1_i_i; } } } $div_i = ($12 - $14 | 0) / ($b_addr_0_lcssa_i_i | 0) | 0; do { if (($b_addr_0_lcssa_i_i | 0) > 0) { $15 = -$sub_i | 0; if (($div_i | 0) > 0) { $i_025_us_i = 0; } else { $20 = $13; $19 = $14; $18 = $12; break; } do { $add_us_i = $i_025_us_i + $13 | 0; $arrayidx9_us_i = $nargv + ($add_us_i << 2) | 0; $j_022_us_i = 0; $pos_023_us_i = $add_us_i; $16 = HEAP32[$arrayidx9_us_i >> 2] | 0; while (1) { $pos_1_us_i = (($pos_023_us_i | 0) < ($13 | 0) ? $sub1_i : $15) + $pos_023_us_i | 0; $arrayidx_us_i = $nargv + ($pos_1_us_i << 2) | 0; $17 = HEAP32[$arrayidx_us_i >> 2] | 0; HEAP32[$arrayidx_us_i >> 2] = $16; HEAP32[$arrayidx9_us_i >> 2] = $17; $inc_us_i = $j_022_us_i + 1 | 0; if (($inc_us_i | 0) < ($div_i | 0)) { $j_022_us_i = $inc_us_i; $pos_023_us_i = $pos_1_us_i; $16 = $17; } else { break; } } $i_025_us_i = $i_025_us_i + 1 | 0; } while (($i_025_us_i | 0) < ($b_addr_0_lcssa_i_i | 0)); $20 = HEAP32[76] | 0; $19 = HEAP32[74] | 0; $18 = HEAP32[70] | 0; } else { $20 = $13; $19 = $14; $18 = $12; } } while (0); HEAP32[70] = $19 - $20 + $18; } } while (0); HEAP32[76] = -1; HEAP32[74] = -1; $retval_0 = -1; STACKTOP = sp; return $retval_0 | 0; } else if ((label | 0) == 1611) { $34 = HEAP32[74] | 0; $35 = HEAP32[76] | 0; if (($34 | 0) != -1 & ($35 | 0) == -1) { HEAP32[76] = $12; $37 = HEAP8[$arrayidx54] | 0; $36 = $12; } else { $37 = $23; $36 = $35; } if ($37 << 24 >> 24 == 0) { $47 = $21; $46 = $12; break; } HEAP32[66] = $arrayidx54; if ((HEAP8[$arrayidx54] | 0) != 45) { $47 = $arrayidx54; $46 = $12; break; } if ((HEAP8[$21 + 2 | 0] | 0) != 0) { $47 = $arrayidx54; $46 = $12; break; } $inc106 = $12 + 1 | 0; HEAP32[70] = $inc106; HEAP32[66] = 46400; if (($36 | 0) != -1) { $sub_i90 = $36 - $34 | 0; $sub1_i91 = $inc106 - $36 | 0; $rem_i_i92 = ($sub_i90 | 0) % ($sub1_i91 | 0) | 0; if (($rem_i_i92 | 0) == 0) { $b_addr_0_lcssa_i_i99 = $sub1_i91; } else { $b_addr_06_i_i95 = $sub1_i91; $c_07_i_i94 = $rem_i_i92; while (1) { $rem1_i_i96 = ($b_addr_06_i_i95 | 0) % ($c_07_i_i94 | 0) | 0; if (($rem1_i_i96 | 0) == 0) { $b_addr_0_lcssa_i_i99 = $c_07_i_i94; break; } else { $b_addr_06_i_i95 = $c_07_i_i94; $c_07_i_i94 = $rem1_i_i96; } } } $div_i101 = ($inc106 - $34 | 0) / ($b_addr_0_lcssa_i_i99 | 0) | 0; do { if (($b_addr_0_lcssa_i_i99 | 0) > 0) { $40 = -$sub_i90 | 0; if (($div_i101 | 0) > 0) { $i_025_us_i118 = 0; } else { $45 = $36; $44 = $34; $43 = $inc106; break; } do { $add_us_i119 = $i_025_us_i118 + $36 | 0; $arrayidx9_us_i120 = $nargv + ($add_us_i119 << 2) | 0; $j_022_us_i110 = 0; $pos_023_us_i109 = $add_us_i119; $41 = HEAP32[$arrayidx9_us_i120 >> 2] | 0; while (1) { $pos_1_us_i113 = (($pos_023_us_i109 | 0) < ($36 | 0) ? $sub1_i91 : $40) + $pos_023_us_i109 | 0; $arrayidx_us_i114 = $nargv + ($pos_1_us_i113 << 2) | 0; $42 = HEAP32[$arrayidx_us_i114 >> 2] | 0; HEAP32[$arrayidx_us_i114 >> 2] = $41; HEAP32[$arrayidx9_us_i120 >> 2] = $42; $inc_us_i115 = $j_022_us_i110 + 1 | 0; if (($inc_us_i115 | 0) < ($div_i101 | 0)) { $j_022_us_i110 = $inc_us_i115; $pos_023_us_i109 = $pos_1_us_i113; $41 = $42; } else { break; } } $i_025_us_i118 = $i_025_us_i118 + 1 | 0; } while (($i_025_us_i118 | 0) < ($b_addr_0_lcssa_i_i99 | 0)); $45 = HEAP32[76] | 0; $44 = HEAP32[74] | 0; $43 = HEAP32[70] | 0; } else { $45 = $36; $44 = $34; $43 = $inc106; } } while (0); HEAP32[70] = $44 - $45 + $43; } HEAP32[76] = -1; HEAP32[74] = -1; $retval_0 = -1; STACKTOP = sp; return $retval_0 | 0; } else if ((label | 0) == 1596) { HEAP32[70] = $12 + 1; HEAP32[10822] = HEAP32[$arrayidx >> 2]; $retval_0 = 1; STACKTOP = sp; return $retval_0 | 0; } else if ((label | 0) == 1681) { STACKTOP = sp; return $retval_0 | 0; } } while (0); $cmp115 = ($long_options | 0) != 0; L2160 : do { if ($cmp115) { if (($47 | 0) == (HEAP32[$nargv + ($46 << 2) >> 2] | 0)) { $50 = $47; break; } $49 = HEAP8[$47] | 0; do { if ($49 << 24 >> 24 == 45) { HEAP32[66] = $47 + 1; $short_too_0 = 0; } else { if (($flags_addr_0147 & 4 | 0) == 0) { $50 = $47; break L2160; } if ($49 << 24 >> 24 == 58) { $short_too_0 = 0; break; } $short_too_0 = (_strchr($options_addr_0 | 0, $49 << 24 >> 24 | 0) | 0) != 0 | 0; } } while (0); $call146 = _parse_long_options($nargv, $options_addr_0, $long_options, $idx, $short_too_0) | 0; if (($call146 | 0) == -1) { $50 = HEAP32[66] | 0; break; } HEAP32[66] = 46400; $retval_0 = $call146; STACKTOP = sp; return $retval_0 | 0; } else { $50 = $47; } } while (0); $incdec_ptr152 = $50 + 1 | 0; HEAP32[66] = $incdec_ptr152; $51 = HEAP8[$50] | 0; $conv153 = $51 << 24 >> 24; if (($51 << 24 >> 24 | 0) == 58) { label = 1642; } else if (($51 << 24 >> 24 | 0) == 45) { if ((HEAP8[$incdec_ptr152] | 0) == 0) { label = 1639; } } else { label = 1639; } do { if ((label | 0) == 1639) { $call164 = _strchr($options_addr_0 | 0, $conv153 | 0) | 0; if (($call164 | 0) == 0) { if ($51 << 24 >> 24 != 45) { label = 1642; break; } if ((HEAP8[$incdec_ptr152] | 0) == 0) { $retval_0 = -1; } else { break; } STACKTOP = sp; return $retval_0 | 0; } $56 = HEAP8[$call164 + 1 | 0] | 0; if ($cmp115 & $51 << 24 >> 24 == 87 & $56 << 24 >> 24 == 59) { do { if ((HEAP8[$incdec_ptr152] | 0) == 0) { $inc202 = (HEAP32[70] | 0) + 1 | 0; HEAP32[70] = $inc202; if (($inc202 | 0) < ($nargc | 0)) { HEAP32[66] = HEAP32[$nargv + ($inc202 << 2) >> 2]; break; } HEAP32[66] = 46400; do { if ((HEAP32[72] | 0) != 0) { if ((HEAP8[$options_addr_0] | 0) == 58) { break; } __warnx(152, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = $conv153, tempInt) | 0); } } while (0); HEAP32[68] = $conv153; $retval_0 = (HEAP8[$options_addr_0] | 0) == 58 ? 58 : 63; STACKTOP = sp; return $retval_0 | 0; } } while (0); $call220 = _parse_long_options($nargv, $options_addr_0, $long_options, $idx, 0) | 0; HEAP32[66] = 46400; $retval_0 = $call220; STACKTOP = sp; return $retval_0 | 0; } if ($56 << 24 >> 24 != 58) { if ((HEAP8[$incdec_ptr152] | 0) != 0) { $retval_0 = $conv153; STACKTOP = sp; return $retval_0 | 0; } HEAP32[70] = (HEAP32[70] | 0) + 1; $retval_0 = $conv153; STACKTOP = sp; return $retval_0 | 0; } HEAP32[10822] = 0; do { if ((HEAP8[$incdec_ptr152] | 0) == 0) { if ((HEAP8[$call164 + 2 | 0] | 0) == 58) { break; } $inc240 = (HEAP32[70] | 0) + 1 | 0; HEAP32[70] = $inc240; if (($inc240 | 0) < ($nargc | 0)) { HEAP32[10822] = HEAP32[$nargv + ($inc240 << 2) >> 2]; break; } HEAP32[66] = 46400; do { if ((HEAP32[72] | 0) != 0) { if ((HEAP8[$options_addr_0] | 0) == 58) { break; } __warnx(152, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = $conv153, tempInt) | 0); } } while (0); HEAP32[68] = $conv153; $retval_0 = (HEAP8[$options_addr_0] | 0) == 58 ? 58 : 63; STACKTOP = sp; return $retval_0 | 0; } else { HEAP32[10822] = $incdec_ptr152; } } while (0); HEAP32[66] = 46400; HEAP32[70] = (HEAP32[70] | 0) + 1; $retval_0 = $conv153; STACKTOP = sp; return $retval_0 | 0; } } while (0); do { if ((label | 0) == 1642) { if ((HEAP8[$incdec_ptr152] | 0) != 0) { break; } HEAP32[70] = (HEAP32[70] | 0) + 1; } } while (0); do { if ((HEAP32[72] | 0) != 0) { if ((HEAP8[$options_addr_0] | 0) == 58) { break; } __warnx(376, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = $conv153, tempInt) | 0); } } while (0); HEAP32[68] = $conv153; $retval_0 = 63; STACKTOP = sp; return $retval_0 | 0; } function _getopt_long($nargc, $nargv, $options, $long_options, $idx) { $nargc = $nargc | 0; $nargv = $nargv | 0; $options = $options | 0; $long_options = $long_options | 0; $idx = $idx | 0; return _getopt_internal($nargc, $nargv, $options, $long_options, $idx, 1) | 0; } function _getopt_long_only($nargc, $nargv, $options, $long_options, $idx) { $nargc = $nargc | 0; $nargv = $nargv | 0; $options = $options | 0; $long_options = $long_options | 0; $idx = $idx | 0; return _getopt_internal($nargc, $nargv, $options, $long_options, $idx, 5) | 0; } function __ZnwjRKSt9nothrow_t($size, $0) { $size = $size | 0; $0 = $0 | 0; return __Znwj($size) | 0; } function __Znaj($size) { $size = $size | 0; return __Znwj($size) | 0; } function __ZnajRKSt9nothrow_t($size, $0) { $size = $size | 0; $0 = $0 | 0; return __Znaj($size) | 0; } function __ZSt17__throw_bad_allocv() { var $exception = 0; $exception = ___cxa_allocate_exception(4) | 0; HEAP32[$exception >> 2] = 8048; ___cxa_throw($exception | 0, 9944, 38); } function _parse_long_options($nargv, $options, $long_options, $idx, $short_too) { $nargv = $nargv | 0; $options = $options | 0; $long_options = $long_options | 0; $idx = $idx | 0; $short_too = $short_too | 0; var $0 = 0, $1 = 0, $inc = 0, $call = 0, $has_equal_0 = 0, $current_argv_len_0 = 0, $2 = 0, $3 = 0, $i_061_us = 0, $5 = 0, $match_062 = 0, $i_061 = 0, $match_1 = 0, $inc28 = 0, $8 = 0, $match_2 = 0, $has_arg = 0, $9 = 0, $tobool36 = 0, $storemerge56 = 0, $storemerge = 0, $26 = 0, $27 = 0, $retval_0 = 0, sp = 0; sp = STACKTOP; $0 = HEAP32[66] | 0; $1 = HEAP32[70] | 0; $inc = $1 + 1 | 0; HEAP32[70] = $inc; $call = _strchr($0 | 0, 61) | 0; if (($call | 0) == 0) { $current_argv_len_0 = _strlen($0 | 0) | 0; $has_equal_0 = 0; } else { $current_argv_len_0 = $call - $0 | 0; $has_equal_0 = $call + 1 | 0; } $2 = HEAP32[$long_options >> 2] | 0; L2242 : do { if (($2 | 0) != 0) { L2244 : do { if (($short_too | 0) != 0 & ($current_argv_len_0 | 0) == 1) { $i_061_us = 0; $3 = $2; while (1) { if ((HEAP8[$0] | 0) == (HEAP8[$3] | 0)) { if ((_strlen($3 | 0) | 0) == 1) { $match_2 = $i_061_us; break L2244; } } $i_061_us = $i_061_us + 1 | 0; $3 = HEAP32[$long_options + ($i_061_us << 4) >> 2] | 0; if (($3 | 0) == 0) { break L2242; } } } else { $i_061 = 0; $match_062 = -1; $5 = $2; while (1) { if ((_strncmp($0 | 0, $5 | 0, $current_argv_len_0 | 0) | 0) == 0) { if ((_strlen($5 | 0) | 0) == ($current_argv_len_0 | 0)) { $match_2 = $i_061; break L2244; } if (($match_062 | 0) == -1) { $match_1 = $i_061; } else { break; } } else { $match_1 = $match_062; } $inc28 = $i_061 + 1 | 0; $8 = HEAP32[$long_options + ($inc28 << 4) >> 2] | 0; if (($8 | 0) == 0) { $match_2 = $match_1; break L2244; } else { $i_061 = $inc28; $match_062 = $match_1; $5 = $8; } } do { if ((HEAP32[72] | 0) != 0) { if ((HEAP8[$options] | 0) == 58) { break; } __warnx(408, (tempInt = STACKTOP, STACKTOP = STACKTOP + 16 | 0, HEAP32[tempInt >> 2] = $current_argv_len_0, HEAP32[tempInt + 8 >> 2] = $0, tempInt) | 0); } } while (0); HEAP32[68] = 0; $retval_0 = 63; STACKTOP = sp; return $retval_0 | 0; } } while (0); if (($match_2 | 0) == -1) { break; } $has_arg = $long_options + ($match_2 << 4) + 4 | 0; $9 = HEAP32[$has_arg >> 2] | 0; $tobool36 = ($has_equal_0 | 0) == 0; if (!(($9 | 0) != 0 | $tobool36)) { do { if ((HEAP32[72] | 0) != 0) { if ((HEAP8[$options] | 0) == 58) { break; } __warnx(312, (tempInt = STACKTOP, STACKTOP = STACKTOP + 16 | 0, HEAP32[tempInt >> 2] = $current_argv_len_0, HEAP32[tempInt + 8 >> 2] = $0, tempInt) | 0); } } while (0); if ((HEAP32[$long_options + ($match_2 << 4) + 8 >> 2] | 0) == 0) { $storemerge56 = HEAP32[$long_options + ($match_2 << 4) + 12 >> 2] | 0; } else { $storemerge56 = 0; } HEAP32[68] = $storemerge56; $retval_0 = (HEAP8[$options] | 0) == 58 ? 58 : 63; STACKTOP = sp; return $retval_0 | 0; } do { if (($9 - 1 | 0) >>> 0 < 2) { if (!$tobool36) { HEAP32[10822] = $has_equal_0; break; } if (($9 | 0) != 1) { break; } HEAP32[70] = $1 + 2; HEAP32[10822] = HEAP32[$nargv + ($inc << 2) >> 2]; } } while (0); if (!((HEAP32[$has_arg >> 2] | 0) == 1 & (HEAP32[10822] | 0) == 0)) { if (($idx | 0) != 0) { HEAP32[$idx >> 2] = $match_2; } $26 = HEAP32[$long_options + ($match_2 << 4) + 8 >> 2] | 0; $27 = HEAP32[$long_options + ($match_2 << 4) + 12 >> 2] | 0; if (($26 | 0) == 0) { $retval_0 = $27; STACKTOP = sp; return $retval_0 | 0; } HEAP32[$26 >> 2] = $27; $retval_0 = 0; STACKTOP = sp; return $retval_0 | 0; } do { if ((HEAP32[72] | 0) != 0) { if ((HEAP8[$options] | 0) == 58) { break; } __warnx(112, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = $0, tempInt) | 0); } } while (0); if ((HEAP32[$long_options + ($match_2 << 4) + 8 >> 2] | 0) == 0) { $storemerge = HEAP32[$long_options + ($match_2 << 4) + 12 >> 2] | 0; } else { $storemerge = 0; } HEAP32[68] = $storemerge; HEAP32[70] = (HEAP32[70] | 0) - 1; $retval_0 = (HEAP8[$options] | 0) == 58 ? 58 : 63; STACKTOP = sp; return $retval_0 | 0; } } while (0); if (($short_too | 0) != 0) { HEAP32[70] = $1; $retval_0 = -1; STACKTOP = sp; return $retval_0 | 0; } do { if ((HEAP32[72] | 0) != 0) { if ((HEAP8[$options] | 0) == 58) { break; } __warnx(352, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = $0, tempInt) | 0); } } while (0); HEAP32[68] = 0; $retval_0 = 63; STACKTOP = sp; return $retval_0 | 0; } function __warn($fmt, varrp) { $fmt = $fmt | 0; varrp = varrp | 0; var $ap = 0, $arraydecay1 = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16 | 0; $ap = sp | 0; $arraydecay1 = $ap; HEAP32[$arraydecay1 >> 2] = varrp; HEAP32[$arraydecay1 + 4 >> 2] = 0; __vwarn($fmt, $ap | 0); STACKTOP = sp; return; } function __warnx($fmt, varrp) { $fmt = $fmt | 0; varrp = varrp | 0; var $ap = 0, $arraydecay1 = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16 | 0; $ap = sp | 0; $arraydecay1 = $ap; HEAP32[$arraydecay1 >> 2] = varrp; HEAP32[$arraydecay1 + 4 >> 2] = 0; __vwarnx($fmt, $ap | 0); STACKTOP = sp; return; } function __vwarn($fmt, $ap) { $fmt = $fmt | 0; $ap = $ap | 0; var $0 = 0, $2 = 0, $3 = 0, $4 = 0, $6 = 0, $call4 = 0, sp = 0; sp = STACKTOP; $0 = HEAP32[(___errno_location() | 0) >> 2] | 0; $2 = HEAP32[___progname >> 2] | 0; _fprintf(HEAP32[_stderr >> 2] | 0, 3136, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = $2, tempInt) | 0) | 0; if (($fmt | 0) != 0) { $3 = HEAP32[_stderr >> 2] | 0; _vfprintf($3 | 0, $fmt | 0, $ap | 0) | 0; $4 = HEAP32[_stderr >> 2] | 0; _fwrite(4056, 2, 1, $4 | 0) | 0; } $6 = HEAP32[_stderr >> 2] | 0; $call4 = _strerror($0 | 0) | 0; _fprintf($6 | 0, 2832, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = $call4, tempInt) | 0) | 0; STACKTOP = sp; return; } function __vwarnx($fmt, $ap) { $fmt = $fmt | 0; $ap = $ap | 0; var $1 = 0, $2 = 0, sp = 0; sp = STACKTOP; $1 = HEAP32[___progname >> 2] | 0; _fprintf(HEAP32[_stderr >> 2] | 0, 2672, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = $1, tempInt) | 0) | 0; if (($fmt | 0) != 0) { $2 = HEAP32[_stderr >> 2] | 0; _vfprintf($2 | 0, $fmt | 0, $ap | 0) | 0; } _fputc(10, HEAP32[_stderr >> 2] | 0) | 0; STACKTOP = sp; return; } function _strtod($string, $endPtr) { $string = $string | 0; $endPtr = $endPtr | 0; var $p_0 = 0, $add_ptr = 0, $1 = 0, $sign_0 = 0, $p_2 = 0, $p_3 = 0, $mantSize_0 = 0, $decPt_0 = 0, $2 = 0, $decPt_1 = 0, $add_ptr22 = 0, $cmp23 = 0, $mantSize_1 = 0, $cmp28 = 0, $fracExp_0 = 0, $mantSize_2 = 0, $p_4_lcssa91 = 0, $mantSize_3_lcssa90 = 0, $frac1_0_lcssa89 = 0.0, $frac1_081 = 0, $mantSize_380 = 0, $p_479 = 0, $4 = 0, $add_ptr43 = 0, $p_5 = 0, $c_0_in = 0, $add51 = 0, $sub53 = 0, $frac2_076 = 0, $mantSize_475 = 0, $p_674 = 0, $6 = 0, $add_ptr60 = 0, $p_7 = 0, $c_1_in = 0, $add69 = 0, $sub71 = 0, $frac1_0_lcssa88 = 0.0, $frac2_0_lcssa = 0.0, $add76 = 0.0, $add_ptr86 = 0, $8 = 0, $expSign_0_ph = 0, $p_9_ph = 0, $9 = 0, $10 = 0, $exp_070 = 0, $p_969 = 0, $add108 = 0, $add_ptr109 = 0, $11 = 0, $expSign_1 = 0, $p_10 = 0, $exp_1 = 0, $exp_2 = 0, $exp_3 = 0, $exp_565 = 0, $d_064 = 0, $dblExp_063 = 0.0, $dblExp_1 = 0.0, $shr = 0, $dblExp_0_lcssa = 0.0, $fraction_0 = 0.0, $p_11 = 0, $retval_0 = 0.0, label = 0; $p_0 = $string; while (1) { $add_ptr = $p_0 + 1 | 0; if ((_isspace(HEAP8[$p_0] | 0) | 0) == 0) { break; } else { $p_0 = $add_ptr; } } $1 = HEAP8[$p_0] | 0; if (($1 << 24 >> 24 | 0) == 45) { $p_2 = $add_ptr; $sign_0 = 1; } else if (($1 << 24 >> 24 | 0) == 43) { $p_2 = $add_ptr; $sign_0 = 0; } else { $p_2 = $p_0; $sign_0 = 0; } $decPt_0 = -1; $mantSize_0 = 0; $p_3 = $p_2; while (1) { $2 = HEAP8[$p_3] | 0; if ((($2 << 24 >> 24) - 48 | 0) >>> 0 < 10) { $decPt_1 = $decPt_0; } else { if ($2 << 24 >> 24 != 46 | ($decPt_0 | 0) > -1) { break; } else { $decPt_1 = $mantSize_0; } } $decPt_0 = $decPt_1; $mantSize_0 = $mantSize_0 + 1 | 0; $p_3 = $p_3 + 1 | 0; } $add_ptr22 = $p_3 + (-$mantSize_0 | 0) | 0; $cmp23 = ($decPt_0 | 0) < 0; $mantSize_1 = (($cmp23 ^ 1) << 31 >> 31) + $mantSize_0 | 0; $cmp28 = ($mantSize_1 | 0) > 18; $fracExp_0 = ($cmp28 ? -18 : -$mantSize_1 | 0) + ($cmp23 ? $mantSize_0 : $decPt_0) | 0; $mantSize_2 = $cmp28 ? 18 : $mantSize_1; do { if (($mantSize_2 | 0) == 0) { $p_11 = $string; $fraction_0 = 0.0; } else { if (($mantSize_2 | 0) > 9) { $p_479 = $add_ptr22; $mantSize_380 = $mantSize_2; $frac1_081 = 0; while (1) { $4 = HEAP8[$p_479] | 0; $add_ptr43 = $p_479 + 1 | 0; if ($4 << 24 >> 24 == 46) { $c_0_in = HEAP8[$add_ptr43] | 0; $p_5 = $p_479 + 2 | 0; } else { $c_0_in = $4; $p_5 = $add_ptr43; } $add51 = ($frac1_081 * 10 | 0) - 48 + ($c_0_in << 24 >> 24) | 0; $sub53 = $mantSize_380 - 1 | 0; if (($sub53 | 0) > 9) { $p_479 = $p_5; $mantSize_380 = $sub53; $frac1_081 = $add51; } else { break; } } $frac1_0_lcssa89 = +($add51 | 0) * 1.0e9; $mantSize_3_lcssa90 = 9; $p_4_lcssa91 = $p_5; label = 1776; } else { if (($mantSize_2 | 0) > 0) { $frac1_0_lcssa89 = 0.0; $mantSize_3_lcssa90 = $mantSize_2; $p_4_lcssa91 = $add_ptr22; label = 1776; } else { $frac2_0_lcssa = 0.0; $frac1_0_lcssa88 = 0.0; } } if ((label | 0) == 1776) { $p_674 = $p_4_lcssa91; $mantSize_475 = $mantSize_3_lcssa90; $frac2_076 = 0; while (1) { $6 = HEAP8[$p_674] | 0; $add_ptr60 = $p_674 + 1 | 0; if ($6 << 24 >> 24 == 46) { $c_1_in = HEAP8[$add_ptr60] | 0; $p_7 = $p_674 + 2 | 0; } else { $c_1_in = $6; $p_7 = $add_ptr60; } $add69 = ($frac2_076 * 10 | 0) - 48 + ($c_1_in << 24 >> 24) | 0; $sub71 = $mantSize_475 - 1 | 0; if (($sub71 | 0) > 0) { $p_674 = $p_7; $mantSize_475 = $sub71; $frac2_076 = $add69; } else { break; } } $frac2_0_lcssa = +($add69 | 0); $frac1_0_lcssa88 = $frac1_0_lcssa89; } $add76 = $frac1_0_lcssa88 + $frac2_0_lcssa; do { if (($2 << 24 >> 24 | 0) == 69 | ($2 << 24 >> 24 | 0) == 101) { $add_ptr86 = $p_3 + 1 | 0; $8 = HEAP8[$add_ptr86] | 0; if (($8 << 24 >> 24 | 0) == 43) { $p_9_ph = $p_3 + 2 | 0; $expSign_0_ph = 0; } else if (($8 << 24 >> 24 | 0) == 45) { $p_9_ph = $p_3 + 2 | 0; $expSign_0_ph = 1; } else { $p_9_ph = $add_ptr86; $expSign_0_ph = 0; } $9 = HEAP8[$p_9_ph] | 0; if ((($9 << 24 >> 24) - 48 | 0) >>> 0 < 10) { $p_969 = $p_9_ph; $exp_070 = 0; $10 = $9; } else { $exp_1 = 0; $p_10 = $p_9_ph; $expSign_1 = $expSign_0_ph; break; } while (1) { $add108 = ($exp_070 * 10 | 0) - 48 + ($10 << 24 >> 24) | 0; $add_ptr109 = $p_969 + 1 | 0; $11 = HEAP8[$add_ptr109] | 0; if ((($11 << 24 >> 24) - 48 | 0) >>> 0 < 10) { $p_969 = $add_ptr109; $exp_070 = $add108; $10 = $11; } else { $exp_1 = $add108; $p_10 = $add_ptr109; $expSign_1 = $expSign_0_ph; break; } } } else { $exp_1 = 0; $p_10 = $p_3; $expSign_1 = 0; } } while (0); $exp_2 = $fracExp_0 + (($expSign_1 | 0) == 0 ? $exp_1 : -$exp_1 | 0) | 0; $exp_3 = ($exp_2 | 0) < 0 ? -$exp_2 | 0 : $exp_2; if (($exp_3 | 0) > 511) { HEAP32[(___errno_location() | 0) >> 2] = 34; $dblExp_063 = 1.0; $d_064 = 192; $exp_565 = 511; label = 1793; } else { if (($exp_3 | 0) == 0) { $dblExp_0_lcssa = 1.0; } else { $dblExp_063 = 1.0; $d_064 = 192; $exp_565 = $exp_3; label = 1793; } } if ((label | 0) == 1793) { while (1) { label = 0; if (($exp_565 & 1 | 0) == 0) { $dblExp_1 = $dblExp_063; } else { $dblExp_1 = $dblExp_063 * +HEAPF64[$d_064 >> 3]; } $shr = $exp_565 >> 1; if (($shr | 0) == 0) { $dblExp_0_lcssa = $dblExp_1; break; } else { $dblExp_063 = $dblExp_1; $d_064 = $d_064 + 8 | 0; $exp_565 = $shr; label = 1793; } } } if (($exp_2 | 0) > -1) { $p_11 = $p_10; $fraction_0 = $add76 * $dblExp_0_lcssa; break; } else { $p_11 = $p_10; $fraction_0 = $add76 / $dblExp_0_lcssa; break; } } } while (0); if (($endPtr | 0) != 0) { HEAP32[$endPtr >> 2] = $p_11; } if (($sign_0 | 0) == 0) { $retval_0 = $fraction_0; return +$retval_0; } $retval_0 = -0.0 - $fraction_0; return +$retval_0; } function _strtold($nptr, $endptr) { $nptr = $nptr | 0; $endptr = $endptr | 0; return +(+_strtod($nptr, $endptr)); } function _strtof($nptr, $endptr) { $nptr = $nptr | 0; $endptr = $endptr | 0; return +(+_strtod($nptr, $endptr)); } function _strtod_l($nptr, $endptr, $loc) { $nptr = $nptr | 0; $endptr = $endptr | 0; $loc = $loc | 0; return +(+_strtod($nptr, $endptr)); } function _strtold_l($nptr, $endptr, $loc) { $nptr = $nptr | 0; $endptr = $endptr | 0; $loc = $loc | 0; return +(+_strtod($nptr, $endptr)); } function _atof($str) { $str = $str | 0; return +(+_strtod($str, 0)); } function __err($eval, $fmt, varrp) { $eval = $eval | 0; $fmt = $fmt | 0; varrp = varrp | 0; var $ap = 0, $arraydecay1 = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16 | 0; $ap = sp | 0; $arraydecay1 = $ap; HEAP32[$arraydecay1 >> 2] = varrp; HEAP32[$arraydecay1 + 4 >> 2] = 0; __verr($eval, $fmt, $ap | 0); } function __errx($eval, $fmt, varrp) { $eval = $eval | 0; $fmt = $fmt | 0; varrp = varrp | 0; var $ap = 0, $arraydecay1 = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16 | 0; $ap = sp | 0; $arraydecay1 = $ap; HEAP32[$arraydecay1 >> 2] = varrp; HEAP32[$arraydecay1 + 4 >> 2] = 0; __verrx($eval, $fmt, $ap | 0); } function __verr($eval, $fmt, $ap) { $eval = $eval | 0; $fmt = $fmt | 0; $ap = $ap | 0; var $0 = 0, $2 = 0, $3 = 0, $4 = 0, $6 = 0, $call4 = 0; $0 = HEAP32[(___errno_location() | 0) >> 2] | 0; $2 = HEAP32[___progname >> 2] | 0; _fprintf(HEAP32[_stderr >> 2] | 0, 536, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = $2, tempInt) | 0) | 0; if (($fmt | 0) != 0) { $3 = HEAP32[_stderr >> 2] | 0; _vfprintf($3 | 0, $fmt | 0, $ap | 0) | 0; $4 = HEAP32[_stderr >> 2] | 0; _fwrite(4248, 2, 1, $4 | 0) | 0; } $6 = HEAP32[_stderr >> 2] | 0; $call4 = _strerror($0 | 0) | 0; _fprintf($6 | 0, 2928, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = $call4, tempInt) | 0) | 0; _exit($eval | 0); } function __verrx($eval, $fmt, $ap) { $eval = $eval | 0; $fmt = $fmt | 0; $ap = $ap | 0; var $1 = 0, $2 = 0; $1 = HEAP32[___progname >> 2] | 0; _fprintf(HEAP32[_stderr >> 2] | 0, 3520, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = $1, tempInt) | 0) | 0; if (($fmt | 0) != 0) { $2 = HEAP32[_stderr >> 2] | 0; _vfprintf($2 | 0, $fmt | 0, $ap | 0) | 0; } _fputc(10, HEAP32[_stderr >> 2] | 0) | 0; _exit($eval | 0); } function _strcpy(pdest, psrc) { pdest = pdest | 0; psrc = psrc | 0; var i = 0; do { HEAP8[pdest + i | 0] = HEAP8[psrc + i | 0]; i = i + 1 | 0; } while (HEAP8[psrc + (i - 1) | 0] | 0); return pdest | 0; } function _memset(ptr, value, num) { ptr = ptr | 0; value = value | 0; num = num | 0; var stop = 0, value4 = 0, stop4 = 0, unaligned = 0; stop = ptr + num | 0; if ((num | 0) >= 20) { value = value & 255; unaligned = ptr & 3; value4 = value | value << 8 | value << 16 | value << 24; stop4 = stop & ~3; if (unaligned) { unaligned = ptr + 4 - unaligned | 0; while ((ptr | 0) < (unaligned | 0)) { HEAP8[ptr] = value; ptr = ptr + 1 | 0; } } while ((ptr | 0) < (stop4 | 0)) { HEAP32[ptr >> 2] = value4; ptr = ptr + 4 | 0; } } while ((ptr | 0) < (stop | 0)) { HEAP8[ptr] = value; ptr = ptr + 1 | 0; } } function _memcpy(dest, src, num) { dest = dest | 0; src = src | 0; num = num | 0; var ret = 0; ret = dest | 0; if ((dest & 3) == (src & 3)) { while (dest & 3) { if ((num | 0) == 0) return ret | 0; HEAP8[dest] = HEAP8[src] | 0; dest = dest + 1 | 0; src = src + 1 | 0; num = num - 1 | 0; } while ((num | 0) >= 4) { HEAP32[dest >> 2] = HEAP32[src >> 2]; dest = dest + 4 | 0; src = src + 4 | 0; num = num - 4 | 0; } } while ((num | 0) > 0) { HEAP8[dest] = HEAP8[src] | 0; dest = dest + 1 | 0; src = src + 1 | 0; num = num - 1 | 0; } return ret | 0; } function _strlen(ptr) { ptr = ptr | 0; var curr = 0; curr = ptr; while (HEAP8[curr] | 0) { curr = curr + 1 | 0; } return curr - ptr | 0; } function _strncpy(pdest, psrc, num) { pdest = pdest | 0; psrc = psrc | 0; num = num | 0; var padding = 0, i = 0; while ((i | 0) < (num | 0)) { HEAP8[pdest + i | 0] = padding ? 0 : HEAP8[psrc + i | 0] | 0; padding = padding ? 1 : (HEAP8[psrc + i | 0] | 0) == 0; i = i + 1 | 0; } return pdest | 0; } function _memcmp(p1, p2, num) { p1 = p1 | 0; p2 = p2 | 0; num = num | 0; var i = 0, v1 = 0, v2 = 0; while ((i | 0) < (num | 0)) { v1 = HEAPU8[p1 + i | 0] | 0; v2 = HEAPU8[p2 + i | 0] | 0; if ((v1 | 0) != (v2 | 0)) return ((v1 | 0) > (v2 | 0) ? 1 : -1) | 0; i = i + 1 | 0; } return 0; } function _memmove(dest, src, num) { dest = dest | 0; src = src | 0; num = num | 0; if ((src | 0) < (dest | 0) & (dest | 0) < (src + num | 0)) { src = src + num | 0; dest = dest + num | 0; while ((num | 0) > 0) { dest = dest - 1 | 0; src = src - 1 | 0; num = num - 1 | 0; HEAP8[dest] = HEAP8[src] | 0; } } else { _memcpy(dest, src, num) | 0; } } function _i64Add(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; var l = 0; l = a + c >>> 0; return (tempRet0 = b + d + (l >>> 0 < a >>> 0 | 0) >>> 0, l | 0) | 0; } function _i64Subtract(a, b, c, d) { a = a | 0; b = b | 0; c = c | 0; d = d | 0; var h = 0; h = b - d >>> 0; h = b - d - (c >>> 0 > a >>> 0 | 0) >>> 0; return (tempRet0 = h, a - c >>> 0 | 0) | 0; } function _bitshift64Shl(low, high, bits) { low = low | 0; high = high | 0; bits = bits | 0; if ((bits | 0) < 32) { tempRet0 = high << bits | (low & (1 << bits) - 1 << 32 - bits) >>> 32 - bits; return low << bits; } tempRet0 = low << bits - 32; return 0; } function _bitshift64Lshr(low, high, bits) { low = low | 0; high = high | 0; bits = bits | 0; if ((bits | 0) < 32) { tempRet0 = high >>> bits; return low >>> bits | (high & (1 << bits) - 1) << 32 - bits; } tempRet0 = 0; return high >>> bits - 32 | 0; } function _bitshift64Ashr(low, high, bits) { low = low | 0; high = high | 0; bits = bits | 0; if ((bits | 0) < 32) { tempRet0 = high >> bits; return low >>> bits | (high & (1 << bits) - 1) << 32 - bits; } tempRet0 = (high | 0) < 0 ? -1 : 0; return high >> bits - 32 | 0; } function _llvm_ctlz_i32(x) { x = x | 0; var ret = 0; ret = HEAP8[ctlz_i8 + (x >>> 24) | 0] | 0; if ((ret | 0) < 8) return ret | 0; ret = HEAP8[ctlz_i8 + (x >> 16 & 255) | 0] | 0; if ((ret | 0) < 8) return ret + 8 | 0; ret = HEAP8[ctlz_i8 + (x >> 8 & 255) | 0] | 0; if ((ret | 0) < 8) return ret + 16 | 0; return (HEAP8[ctlz_i8 + (x & 255) | 0] | 0) + 24 | 0; } function _llvm_cttz_i32(x) { x = x | 0; var ret = 0; ret = HEAP8[cttz_i8 + (x & 255) | 0] | 0; if ((ret | 0) < 8) return ret | 0; ret = HEAP8[cttz_i8 + (x >> 8 & 255) | 0] | 0; if ((ret | 0) < 8) return ret + 8 | 0; ret = HEAP8[cttz_i8 + (x >> 16 & 255) | 0] | 0; if ((ret | 0) < 8) return ret + 16 | 0; return (HEAP8[cttz_i8 + (x >>> 24) | 0] | 0) + 24 | 0; } function ___muldsi3($a, $b) { $a = $a | 0; $b = $b | 0; var $1 = 0, $2 = 0, $3 = 0, $6 = 0, $8 = 0, $11 = 0, $12 = 0; $1 = $a & 65535; $2 = $b & 65535; $3 = Math_imul($2, $1) | 0; $6 = $a >>> 16; $8 = ($3 >>> 16) + (Math_imul($2, $6) | 0) | 0; $11 = $b >>> 16; $12 = Math_imul($11, $1) | 0; return (tempRet0 = ($8 >>> 16) + (Math_imul($11, $6) | 0) + ((($8 & 65535) + $12 | 0) >>> 16) | 0, $8 + $12 << 16 | $3 & 65535 | 0) | 0; } function ___divdi3($a$0, $a$1, $b$0, $b$1) { $a$0 = $a$0 | 0; $a$1 = $a$1 | 0; $b$0 = $b$0 | 0; $b$1 = $b$1 | 0; var $1$0 = 0, $1$1 = 0, $2$0 = 0, $2$1 = 0, $4$0 = 0, $4$1 = 0, $7$0 = 0, $7$1 = 0, $10$0 = 0; $1$0 = $a$1 >> 31 | (($a$1 | 0) < 0 ? -1 : 0) << 1; $1$1 = (($a$1 | 0) < 0 ? -1 : 0) >> 31 | (($a$1 | 0) < 0 ? -1 : 0) << 1; $2$0 = $b$1 >> 31 | (($b$1 | 0) < 0 ? -1 : 0) << 1; $2$1 = (($b$1 | 0) < 0 ? -1 : 0) >> 31 | (($b$1 | 0) < 0 ? -1 : 0) << 1; $4$0 = _i64Subtract($1$0 ^ $a$0, $1$1 ^ $a$1, $1$0, $1$1) | 0; $4$1 = tempRet0; $7$0 = $2$0 ^ $1$0; $7$1 = $2$1 ^ $1$1; $10$0 = _i64Subtract((___udivmoddi4($4$0, $4$1, _i64Subtract($2$0 ^ $b$0, $2$1 ^ $b$1, $2$0, $2$1) | 0, tempRet0, 0) | 0) ^ $7$0, tempRet0 ^ $7$1, $7$0, $7$1) | 0; return (tempRet0 = tempRet0, $10$0) | 0; } function ___remdi3($a$0, $a$1, $b$0, $b$1) { $a$0 = $a$0 | 0; $a$1 = $a$1 | 0; $b$0 = $b$0 | 0; $b$1 = $b$1 | 0; var $rem = 0, $1$0 = 0, $1$1 = 0, $2$0 = 0, $2$1 = 0, $4$0 = 0, $4$1 = 0, $6$0 = 0, $10$0 = 0, $10$1 = 0, __stackBase__ = 0; __stackBase__ = STACKTOP; STACKTOP = STACKTOP + 8 | 0; $rem = __stackBase__ | 0; $1$0 = $a$1 >> 31 | (($a$1 | 0) < 0 ? -1 : 0) << 1; $1$1 = (($a$1 | 0) < 0 ? -1 : 0) >> 31 | (($a$1 | 0) < 0 ? -1 : 0) << 1; $2$0 = $b$1 >> 31 | (($b$1 | 0) < 0 ? -1 : 0) << 1; $2$1 = (($b$1 | 0) < 0 ? -1 : 0) >> 31 | (($b$1 | 0) < 0 ? -1 : 0) << 1; $4$0 = _i64Subtract($1$0 ^ $a$0, $1$1 ^ $a$1, $1$0, $1$1) | 0; $4$1 = tempRet0; $6$0 = _i64Subtract($2$0 ^ $b$0, $2$1 ^ $b$1, $2$0, $2$1) | 0; ___udivmoddi4($4$0, $4$1, $6$0, tempRet0, $rem) | 0; $10$0 = _i64Subtract(HEAP32[$rem >> 2] ^ $1$0, HEAP32[$rem + 4 >> 2] ^ $1$1, $1$0, $1$1) | 0; $10$1 = tempRet0; STACKTOP = __stackBase__; return (tempRet0 = $10$1, $10$0) | 0; } function ___muldi3($a$0, $a$1, $b$0, $b$1) { $a$0 = $a$0 | 0; $a$1 = $a$1 | 0; $b$0 = $b$0 | 0; $b$1 = $b$1 | 0; var $x_sroa_0_0_extract_trunc = 0, $y_sroa_0_0_extract_trunc = 0, $1$0 = 0, $1$1 = 0; $x_sroa_0_0_extract_trunc = $a$0; $y_sroa_0_0_extract_trunc = $b$0; $1$0 = ___muldsi3($x_sroa_0_0_extract_trunc, $y_sroa_0_0_extract_trunc) | 0; $1$1 = tempRet0; return (tempRet0 = (Math_imul($a$1, $y_sroa_0_0_extract_trunc) | 0) + (Math_imul($b$1, $x_sroa_0_0_extract_trunc) | 0) + $1$1 | $1$1 & 0, $1$0 | 0 | 0) | 0; } function ___udivdi3($a$0, $a$1, $b$0, $b$1) { $a$0 = $a$0 | 0; $a$1 = $a$1 | 0; $b$0 = $b$0 | 0; $b$1 = $b$1 | 0; var $1$0 = 0; $1$0 = ___udivmoddi4($a$0, $a$1, $b$0, $b$1, 0) | 0; return (tempRet0 = tempRet0, $1$0) | 0; } function ___uremdi3($a$0, $a$1, $b$0, $b$1) { $a$0 = $a$0 | 0; $a$1 = $a$1 | 0; $b$0 = $b$0 | 0; $b$1 = $b$1 | 0; var $rem = 0, __stackBase__ = 0; __stackBase__ = STACKTOP; STACKTOP = STACKTOP + 8 | 0; $rem = __stackBase__ | 0; ___udivmoddi4($a$0, $a$1, $b$0, $b$1, $rem) | 0; STACKTOP = __stackBase__; return (tempRet0 = HEAP32[$rem + 4 >> 2] | 0, HEAP32[$rem >> 2] | 0) | 0; } function ___udivmoddi4($a$0, $a$1, $b$0, $b$1, $rem) { $a$0 = $a$0 | 0; $a$1 = $a$1 | 0; $b$0 = $b$0 | 0; $b$1 = $b$1 | 0; $rem = $rem | 0; var $n_sroa_0_0_extract_trunc = 0, $n_sroa_1_4_extract_shift$0 = 0, $n_sroa_1_4_extract_trunc = 0, $d_sroa_0_0_extract_trunc = 0, $d_sroa_1_4_extract_shift$0 = 0, $d_sroa_1_4_extract_trunc = 0, $4 = 0, $17 = 0, $37 = 0, $51 = 0, $57 = 0, $58 = 0, $66 = 0, $78 = 0, $88 = 0, $89 = 0, $91 = 0, $92 = 0, $95 = 0, $105 = 0, $119 = 0, $125 = 0, $126 = 0, $130 = 0, $q_sroa_1_1_ph = 0, $q_sroa_0_1_ph = 0, $r_sroa_1_1_ph = 0, $r_sroa_0_1_ph = 0, $sr_1_ph = 0, $d_sroa_0_0_insert_insert99$0 = 0, $d_sroa_0_0_insert_insert99$1 = 0, $137$0 = 0, $137$1 = 0, $carry_0203 = 0, $sr_1202 = 0, $r_sroa_0_1201 = 0, $r_sroa_1_1200 = 0, $q_sroa_0_1199 = 0, $q_sroa_1_1198 = 0, $147 = 0, $149 = 0, $r_sroa_0_0_insert_insert42$0 = 0, $r_sroa_0_0_insert_insert42$1 = 0, $150$1 = 0, $151$0 = 0, $152 = 0, $r_sroa_0_0_extract_trunc = 0, $r_sroa_1_4_extract_trunc = 0, $155 = 0, $carry_0_lcssa$0 = 0, $carry_0_lcssa$1 = 0, $r_sroa_0_1_lcssa = 0, $r_sroa_1_1_lcssa = 0, $q_sroa_0_1_lcssa = 0, $q_sroa_1_1_lcssa = 0, $q_sroa_0_0_insert_ext75$0 = 0, $q_sroa_0_0_insert_ext75$1 = 0, $_0$0 = 0, $_0$1 = 0; $n_sroa_0_0_extract_trunc = $a$0; $n_sroa_1_4_extract_shift$0 = $a$1; $n_sroa_1_4_extract_trunc = $n_sroa_1_4_extract_shift$0; $d_sroa_0_0_extract_trunc = $b$0; $d_sroa_1_4_extract_shift$0 = $b$1; $d_sroa_1_4_extract_trunc = $d_sroa_1_4_extract_shift$0; if (($n_sroa_1_4_extract_trunc | 0) == 0) { $4 = ($rem | 0) != 0; if (($d_sroa_1_4_extract_trunc | 0) == 0) { if ($4) { HEAP32[$rem >> 2] = ($n_sroa_0_0_extract_trunc >>> 0) % ($d_sroa_0_0_extract_trunc >>> 0); HEAP32[$rem + 4 >> 2] = 0; } $_0$1 = 0; $_0$0 = ($n_sroa_0_0_extract_trunc >>> 0) / ($d_sroa_0_0_extract_trunc >>> 0) >>> 0; return (tempRet0 = $_0$1, $_0$0) | 0; } else { if (!$4) { $_0$1 = 0; $_0$0 = 0; return (tempRet0 = $_0$1, $_0$0) | 0; } HEAP32[$rem >> 2] = $a$0 | 0; HEAP32[$rem + 4 >> 2] = $a$1 & 0; $_0$1 = 0; $_0$0 = 0; return (tempRet0 = $_0$1, $_0$0) | 0; } } $17 = ($d_sroa_1_4_extract_trunc | 0) == 0; do { if (($d_sroa_0_0_extract_trunc | 0) == 0) { if ($17) { if (($rem | 0) != 0) { HEAP32[$rem >> 2] = ($n_sroa_1_4_extract_trunc >>> 0) % ($d_sroa_0_0_extract_trunc >>> 0); HEAP32[$rem + 4 >> 2] = 0; } $_0$1 = 0; $_0$0 = ($n_sroa_1_4_extract_trunc >>> 0) / ($d_sroa_0_0_extract_trunc >>> 0) >>> 0; return (tempRet0 = $_0$1, $_0$0) | 0; } if (($n_sroa_0_0_extract_trunc | 0) == 0) { if (($rem | 0) != 0) { HEAP32[$rem >> 2] = 0; HEAP32[$rem + 4 >> 2] = ($n_sroa_1_4_extract_trunc >>> 0) % ($d_sroa_1_4_extract_trunc >>> 0); } $_0$1 = 0; $_0$0 = ($n_sroa_1_4_extract_trunc >>> 0) / ($d_sroa_1_4_extract_trunc >>> 0) >>> 0; return (tempRet0 = $_0$1, $_0$0) | 0; } $37 = $d_sroa_1_4_extract_trunc - 1 | 0; if (($37 & $d_sroa_1_4_extract_trunc | 0) == 0) { if (($rem | 0) != 0) { HEAP32[$rem >> 2] = $a$0 | 0; HEAP32[$rem + 4 >> 2] = $37 & $n_sroa_1_4_extract_trunc | $a$1 & 0; } $_0$1 = 0; $_0$0 = $n_sroa_1_4_extract_trunc >>> ((_llvm_cttz_i32($d_sroa_1_4_extract_trunc | 0) | 0) >>> 0); return (tempRet0 = $_0$1, $_0$0) | 0; } $51 = (_llvm_ctlz_i32($d_sroa_1_4_extract_trunc | 0) | 0) - (_llvm_ctlz_i32($n_sroa_1_4_extract_trunc | 0) | 0) | 0; if ($51 >>> 0 <= 30) { $57 = $51 + 1 | 0; $58 = 31 - $51 | 0; $sr_1_ph = $57; $r_sroa_0_1_ph = $n_sroa_1_4_extract_trunc << $58 | $n_sroa_0_0_extract_trunc >>> ($57 >>> 0); $r_sroa_1_1_ph = $n_sroa_1_4_extract_trunc >>> ($57 >>> 0); $q_sroa_0_1_ph = 0; $q_sroa_1_1_ph = $n_sroa_0_0_extract_trunc << $58; break; } if (($rem | 0) == 0) { $_0$1 = 0; $_0$0 = 0; return (tempRet0 = $_0$1, $_0$0) | 0; } HEAP32[$rem >> 2] = $a$0 | 0; HEAP32[$rem + 4 >> 2] = $n_sroa_1_4_extract_shift$0 | $a$1 & 0; $_0$1 = 0; $_0$0 = 0; return (tempRet0 = $_0$1, $_0$0) | 0; } else { if (!$17) { $119 = (_llvm_ctlz_i32($d_sroa_1_4_extract_trunc | 0) | 0) - (_llvm_ctlz_i32($n_sroa_1_4_extract_trunc | 0) | 0) | 0; if ($119 >>> 0 <= 31) { $125 = $119 + 1 | 0; $126 = 31 - $119 | 0; $130 = $119 - 31 >> 31; $sr_1_ph = $125; $r_sroa_0_1_ph = $n_sroa_0_0_extract_trunc >>> ($125 >>> 0) & $130 | $n_sroa_1_4_extract_trunc << $126; $r_sroa_1_1_ph = $n_sroa_1_4_extract_trunc >>> ($125 >>> 0) & $130; $q_sroa_0_1_ph = 0; $q_sroa_1_1_ph = $n_sroa_0_0_extract_trunc << $126; break; } if (($rem | 0) == 0) { $_0$1 = 0; $_0$0 = 0; return (tempRet0 = $_0$1, $_0$0) | 0; } HEAP32[$rem >> 2] = $a$0 | 0; HEAP32[$rem + 4 >> 2] = $n_sroa_1_4_extract_shift$0 | $a$1 & 0; $_0$1 = 0; $_0$0 = 0; return (tempRet0 = $_0$1, $_0$0) | 0; } $66 = $d_sroa_0_0_extract_trunc - 1 | 0; if (($66 & $d_sroa_0_0_extract_trunc | 0) != 0) { $88 = (_llvm_ctlz_i32($d_sroa_0_0_extract_trunc | 0) | 0) + 33 - (_llvm_ctlz_i32($n_sroa_1_4_extract_trunc | 0) | 0) | 0; $89 = 64 - $88 | 0; $91 = 32 - $88 | 0; $92 = $91 >> 31; $95 = $88 - 32 | 0; $105 = $95 >> 31; $sr_1_ph = $88; $r_sroa_0_1_ph = $91 - 1 >> 31 & $n_sroa_1_4_extract_trunc >>> ($95 >>> 0) | ($n_sroa_1_4_extract_trunc << $91 | $n_sroa_0_0_extract_trunc >>> ($88 >>> 0)) & $105; $r_sroa_1_1_ph = $105 & $n_sroa_1_4_extract_trunc >>> ($88 >>> 0); $q_sroa_0_1_ph = $n_sroa_0_0_extract_trunc << $89 & $92; $q_sroa_1_1_ph = ($n_sroa_1_4_extract_trunc << $89 | $n_sroa_0_0_extract_trunc >>> ($95 >>> 0)) & $92 | $n_sroa_0_0_extract_trunc << $91 & $88 - 33 >> 31; break; } if (($rem | 0) != 0) { HEAP32[$rem >> 2] = $66 & $n_sroa_0_0_extract_trunc; HEAP32[$rem + 4 >> 2] = 0; } if (($d_sroa_0_0_extract_trunc | 0) == 1) { $_0$1 = $n_sroa_1_4_extract_shift$0 | $a$1 & 0; $_0$0 = $a$0 | 0 | 0; return (tempRet0 = $_0$1, $_0$0) | 0; } else { $78 = _llvm_cttz_i32($d_sroa_0_0_extract_trunc | 0) | 0; $_0$1 = $n_sroa_1_4_extract_trunc >>> ($78 >>> 0) | 0; $_0$0 = $n_sroa_1_4_extract_trunc << 32 - $78 | $n_sroa_0_0_extract_trunc >>> ($78 >>> 0) | 0; return (tempRet0 = $_0$1, $_0$0) | 0; } } } while (0); if (($sr_1_ph | 0) == 0) { $q_sroa_1_1_lcssa = $q_sroa_1_1_ph; $q_sroa_0_1_lcssa = $q_sroa_0_1_ph; $r_sroa_1_1_lcssa = $r_sroa_1_1_ph; $r_sroa_0_1_lcssa = $r_sroa_0_1_ph; $carry_0_lcssa$1 = 0; $carry_0_lcssa$0 = 0; } else { $d_sroa_0_0_insert_insert99$0 = $b$0 | 0 | 0; $d_sroa_0_0_insert_insert99$1 = $d_sroa_1_4_extract_shift$0 | $b$1 & 0; $137$0 = _i64Add($d_sroa_0_0_insert_insert99$0, $d_sroa_0_0_insert_insert99$1, -1, -1) | 0; $137$1 = tempRet0; $q_sroa_1_1198 = $q_sroa_1_1_ph; $q_sroa_0_1199 = $q_sroa_0_1_ph; $r_sroa_1_1200 = $r_sroa_1_1_ph; $r_sroa_0_1201 = $r_sroa_0_1_ph; $sr_1202 = $sr_1_ph; $carry_0203 = 0; while (1) { $147 = $q_sroa_0_1199 >>> 31 | $q_sroa_1_1198 << 1; $149 = $carry_0203 | $q_sroa_0_1199 << 1; $r_sroa_0_0_insert_insert42$0 = $r_sroa_0_1201 << 1 | $q_sroa_1_1198 >>> 31 | 0; $r_sroa_0_0_insert_insert42$1 = $r_sroa_0_1201 >>> 31 | $r_sroa_1_1200 << 1 | 0; _i64Subtract($137$0, $137$1, $r_sroa_0_0_insert_insert42$0, $r_sroa_0_0_insert_insert42$1) | 0; $150$1 = tempRet0; $151$0 = $150$1 >> 31 | (($150$1 | 0) < 0 ? -1 : 0) << 1; $152 = $151$0 & 1; $r_sroa_0_0_extract_trunc = _i64Subtract($r_sroa_0_0_insert_insert42$0, $r_sroa_0_0_insert_insert42$1, $151$0 & $d_sroa_0_0_insert_insert99$0, ((($150$1 | 0) < 0 ? -1 : 0) >> 31 | (($150$1 | 0) < 0 ? -1 : 0) << 1) & $d_sroa_0_0_insert_insert99$1) | 0; $r_sroa_1_4_extract_trunc = tempRet0; $155 = $sr_1202 - 1 | 0; if (($155 | 0) == 0) { break; } else { $q_sroa_1_1198 = $147; $q_sroa_0_1199 = $149; $r_sroa_1_1200 = $r_sroa_1_4_extract_trunc; $r_sroa_0_1201 = $r_sroa_0_0_extract_trunc; $sr_1202 = $155; $carry_0203 = $152; } } $q_sroa_1_1_lcssa = $147; $q_sroa_0_1_lcssa = $149; $r_sroa_1_1_lcssa = $r_sroa_1_4_extract_trunc; $r_sroa_0_1_lcssa = $r_sroa_0_0_extract_trunc; $carry_0_lcssa$1 = 0; $carry_0_lcssa$0 = $152; } $q_sroa_0_0_insert_ext75$0 = $q_sroa_0_1_lcssa; $q_sroa_0_0_insert_ext75$1 = 0; if (($rem | 0) != 0) { HEAP32[$rem >> 2] = $r_sroa_0_1_lcssa; HEAP32[$rem + 4 >> 2] = $r_sroa_1_1_lcssa; } $_0$1 = ($q_sroa_0_0_insert_ext75$0 | 0) >>> 31 | ($q_sroa_1_1_lcssa | $q_sroa_0_0_insert_ext75$1) << 1 | ($q_sroa_0_0_insert_ext75$1 << 1 | $q_sroa_0_0_insert_ext75$0 >>> 31) & 0 | $carry_0_lcssa$1; $_0$0 = ($q_sroa_0_0_insert_ext75$0 << 1 | 0 >>> 31) & -2 | $carry_0_lcssa$0; return (tempRet0 = $_0$1, $_0$0) | 0; } function ___cxa_pure_virtual__wrapper() { ___cxa_pure_virtual(); } function dynCall_viiiii(index, a1, a2, a3, a4, a5) { index = index | 0; a1 = a1 | 0; a2 = a2 | 0; a3 = a3 | 0; a4 = a4 | 0; a5 = a5 | 0; FUNCTION_TABLE_viiiii[index & 7](a1 | 0, a2 | 0, a3 | 0, a4 | 0, a5 | 0); } function dynCall_vi(index, a1) { index = index | 0; a1 = a1 | 0; FUNCTION_TABLE_vi[index & 127](a1 | 0); } function dynCall_vii(index, a1, a2) { index = index | 0; a1 = a1 | 0; a2 = a2 | 0; FUNCTION_TABLE_vii[index & 15](a1 | 0, a2 | 0); } function dynCall_iiiiiii(index, a1, a2, a3, a4, a5, a6) { index = index | 0; a1 = a1 | 0; a2 = a2 | 0; a3 = a3 | 0; a4 = a4 | 0; a5 = a5 | 0; a6 = a6 | 0; return FUNCTION_TABLE_iiiiiii[index & 15](a1 | 0, a2 | 0, a3 | 0, a4 | 0, a5 | 0, a6 | 0) | 0; } function dynCall_iiiii(index, a1, a2, a3, a4) { index = index | 0; a1 = a1 | 0; a2 = a2 | 0; a3 = a3 | 0; a4 = a4 | 0; return FUNCTION_TABLE_iiiii[index & 31](a1 | 0, a2 | 0, a3 | 0, a4 | 0) | 0; } function dynCall_ii(index, a1) { index = index | 0; a1 = a1 | 0; return FUNCTION_TABLE_ii[index & 31](a1 | 0) | 0; } function dynCall_iiii(index, a1, a2, a3) { index = index | 0; a1 = a1 | 0; a2 = a2 | 0; a3 = a3 | 0; return FUNCTION_TABLE_iiii[index & 15](a1 | 0, a2 | 0, a3 | 0) | 0; } function dynCall_viii(index, a1, a2, a3) { index = index | 0; a1 = a1 | 0; a2 = a2 | 0; a3 = a3 | 0; FUNCTION_TABLE_viii[index & 15](a1 | 0, a2 | 0, a3 | 0); } function dynCall_v(index) { index = index | 0; FUNCTION_TABLE_v[index & 3](); } function dynCall_viiiiii(index, a1, a2, a3, a4, a5, a6) { index = index | 0; a1 = a1 | 0; a2 = a2 | 0; a3 = a3 | 0; a4 = a4 | 0; a5 = a5 | 0; a6 = a6 | 0; FUNCTION_TABLE_viiiiii[index & 7](a1 | 0, a2 | 0, a3 | 0, a4 | 0, a5 | 0, a6 | 0); } function dynCall_iii(index, a1, a2) { index = index | 0; a1 = a1 | 0; a2 = a2 | 0; return FUNCTION_TABLE_iii[index & 63](a1 | 0, a2 | 0) | 0; } function dynCall_iiiiii(index, a1, a2, a3, a4, a5) { index = index | 0; a1 = a1 | 0; a2 = a2 | 0; a3 = a3 | 0; a4 = a4 | 0; a5 = a5 | 0; return FUNCTION_TABLE_iiiiii[index & 15](a1 | 0, a2 | 0, a3 | 0, a4 | 0, a5 | 0) | 0; } function dynCall_viiii(index, a1, a2, a3, a4) { index = index | 0; a1 = a1 | 0; a2 = a2 | 0; a3 = a3 | 0; a4 = a4 | 0; FUNCTION_TABLE_viiii[index & 7](a1 | 0, a2 | 0, a3 | 0, a4 | 0); } function b0(p0, p1, p2, p3, p4) { p0 = p0 | 0; p1 = p1 | 0; p2 = p2 | 0; p3 = p3 | 0; p4 = p4 | 0; abort(0); } function b1(p0) { p0 = p0 | 0; abort(1); } function b2(p0, p1) { p0 = p0 | 0; p1 = p1 | 0; abort(2); } function b3(p0, p1, p2, p3, p4, p5) { p0 = p0 | 0; p1 = p1 | 0; p2 = p2 | 0; p3 = p3 | 0; p4 = p4 | 0; p5 = p5 | 0; abort(3); return 0; } function b4(p0, p1, p2, p3) { p0 = p0 | 0; p1 = p1 | 0; p2 = p2 | 0; p3 = p3 | 0; abort(4); return 0; } function b5(p0) { p0 = p0 | 0; abort(5); return 0; } function b6(p0, p1, p2) { p0 = p0 | 0; p1 = p1 | 0; p2 = p2 | 0; abort(6); return 0; } function b7(p0, p1, p2) { p0 = p0 | 0; p1 = p1 | 0; p2 = p2 | 0; abort(7); } function b8() { abort(8); } function b9(p0, p1, p2, p3, p4, p5) { p0 = p0 | 0; p1 = p1 | 0; p2 = p2 | 0; p3 = p3 | 0; p4 = p4 | 0; p5 = p5 | 0; abort(9); } function b10(p0, p1) { p0 = p0 | 0; p1 = p1 | 0; abort(10); return 0; } function b11(p0, p1, p2, p3, p4) { p0 = p0 | 0; p1 = p1 | 0; p2 = p2 | 0; p3 = p3 | 0; p4 = p4 | 0; abort(11); return 0; } function b12(p0, p1, p2, p3) { p0 = p0 | 0; p1 = p1 | 0; p2 = p2 | 0; p3 = p3 | 0; abort(12); } // EMSCRIPTEN_END_FUNCS var FUNCTION_TABLE_viiiii = [b0,b0,__ZNK10__cxxabiv120__si_class_type_info16search_below_dstEPNS_19__dynamic_cast_infoEPKvib,b0,__ZNK10__cxxabiv121__vmi_class_type_info16search_below_dstEPNS_19__dynamic_cast_infoEPKvib,b0,__ZNK10__cxxabiv117__class_type_info16search_below_dstEPNS_19__dynamic_cast_infoEPKvib,b0]; var FUNCTION_TABLE_vi = [b1,b1,__ZN10ime_pinyin8UserDictD0Ev,b1,__ZN10ime_pinyin5NGramD2Ev,b1,__ZNSt9bad_allocC2Ev,b1,__ZNSt9type_infoD0Ev,b1,__ZN10ime_pinyin11Utf16ReaderD2Ev ,b1,__ZN10ime_pinyin8DictTrieD0Ev,b1,__ZN10ime_pinyin4SyncC2Ev,b1,__ZN10ime_pinyin8LpiCacheC2Ev,b1,__ZN10ime_pinyin8DictTrie11flush_cacheEv,b1,__ZN10__cxxabiv117__array_type_infoD0Ev ,b1,__ZNK10__cxxabiv116__shim_type_info5noop2Ev,b1,__ZN10__cxxabiv123__fundamental_type_infoD0Ev,b1,__ZNSt10bad_typeidD2Ev,b1,__ZN10ime_pinyin8DictTrieC2Ev,b1,__ZN10ime_pinyin8UserDictD2Ev ,b1,__ZN10ime_pinyin13SpellingTableC2Ev,b1,__ZN10ime_pinyin12AtomDictBaseD0Ev,b1,__ZN10ime_pinyin8UserDictC2Ev,b1,__ZNSt9bad_allocD2Ev,b1,__ZN10ime_pinyin12SpellingTrieD2Ev ,b1,__ZN10ime_pinyin11DictBuilderC2Ev,b1,__ZNSt10bad_typeidC2Ev,b1,__ZN10__cxxabiv120__function_type_infoD0Ev,b1,__ZN10ime_pinyin8UserDict11flush_cacheEv,b1,__ZNSt8bad_castD0Ev ,b1,__ZN10ime_pinyin12SpellingTrieC2Ev,b1,__ZNSt20bad_array_new_lengthC2Ev,b1,__ZN10ime_pinyin11DictBuilderD2Ev,b1,__ZN10ime_pinyin4SyncD2Ev,b1,__ZN10__cxxabiv129__pointer_to_member_type_infoD0Ev ,b1,__ZNSt9type_infoD2Ev,b1,__ZN10ime_pinyin8LpiCacheD2Ev,b1,__ZN10ime_pinyin12MatrixSearchD2Ev,b1,__ZN10ime_pinyin8DictTrieD2Ev,b1,__ZN10__cxxabiv117__pbase_type_infoD0Ev ,b1,__ZN10__cxxabiv116__shim_type_infoD0Ev,b1,__ZN10ime_pinyin12AtomDictBaseD1Ev,b1,__ZN10ime_pinyin8DictListC2Ev,b1,__ZNSt10bad_typeidD0Ev,b1,__ZN10ime_pinyin5NGramC2Ev ,b1,__ZNSt20bad_array_new_lengthD0Ev,b1,__ZNSt9bad_allocD0Ev,b1,__ZN10__cxxabiv117__class_type_infoD0Ev,b1,__ZN10__cxxabiv116__shim_type_infoD2Ev,b1,__ZN10ime_pinyin8DictListD2Ev ,b1,__ZNSt8bad_castC2Ev,b1,__ZNK10__cxxabiv116__shim_type_info5noop1Ev,b1,__ZN10__cxxabiv119__pointer_type_infoD0Ev,b1,__ZNSt8bad_castD2Ev,b1,__ZN10__cxxabiv116__enum_type_infoD0Ev ,b1,__ZN10ime_pinyin13SpellingTableD2Ev,b1,__ZN10ime_pinyin14SpellingParserC2Ev,b1,__ZN10__cxxabiv121__vmi_class_type_infoD0Ev,b1,__ZN10__cxxabiv120__si_class_type_infoD0Ev,b1,__ZN10ime_pinyin12MatrixSearchC2Ev,b1,__ZN10ime_pinyin11Utf16ReaderC2Ev,b1,b1,b1,b1,b1,b1,b1,b1,b1,b1,b1,b1,b1,b1,b1]; var FUNCTION_TABLE_vii = [b2,b2,__vwarnx,b2,__warnx,b2,__warn,b2,__ZN10ime_pinyin8DictTrie31set_total_lemma_count_of_othersEj,b2,__ZN10ime_pinyin8UserDict31set_total_lemma_count_of_othersEj,b2,__vwarn,b2,b2,b2]; var FUNCTION_TABLE_iiiiiii = [b3,b3,__ZN10ime_pinyin8UserDict11extend_dictEtPKNS_11DictExtParaEPNS_10LmaPsbItemEjPj,b3,__ZN10ime_pinyin8DictTrie11extend_dictEtPKNS_11DictExtParaEPNS_10LmaPsbItemEjPj,b3,__ZN10ime_pinyin8DictTrie7predictEPKttPNS_12NPredictItemEjj,b3,__ZN10ime_pinyin8UserDict7predictEPKttPNS_12NPredictItemEjj,b3,b3,b3,b3,b3,b3,b3]; var FUNCTION_TABLE_iiiii = [b4,b4,__ZN10ime_pinyin8UserDict9load_dictEPKcjj,b4,__ZN10ime_pinyin8DictTrie15get_lemma_scoreEPtS1_t,b4,__ZN10ime_pinyin8UserDict12update_lemmaEjsb,b4,__ZN10ime_pinyin8UserDict12get_lemma_idEPtS1_t,b4,__ZN10ime_pinyin8DictTrie12get_lemma_idEPtS1_t ,b4,__ZN10ime_pinyin8DictTrie9load_dictEPKcjj,b4,__ZN10ime_pinyin8DictTrie13get_lemma_strEjPtt,b4,__ZN10ime_pinyin8UserDict15get_lemma_scoreEPtS1_t,b4,__ZN10ime_pinyin8DictTrie12update_lemmaEjsb,b4,__ZN10ime_pinyin8UserDict13get_lemma_strEjPtt,b4,b4,b4,b4,b4,b4,b4,b4,b4,b4,b4]; var FUNCTION_TABLE_ii = [b5,b5,__ZNKSt9bad_alloc4whatEv,b5,__ZNKSt8bad_cast4whatEv,b5,__ZN10ime_pinyin8DictTrie21get_total_lemma_countEv,b5,__ZN10ime_pinyin8DictTrie10close_dictEv,b5,__ZNKSt20bad_array_new_length4whatEv ,b5,__ZN10ime_pinyin8UserDict16number_of_lemmasEv,b5,__ZN10ime_pinyin8UserDict10close_dictEv,b5,__ZN10ime_pinyin8UserDict21get_total_lemma_countEv,b5,__ZN10ime_pinyin8DictTrie16number_of_lemmasEv,b5,__ZNKSt10bad_typeid4whatEv,b5,b5,b5,b5,b5,b5,b5,b5,b5,b5,b5]; var FUNCTION_TABLE_iiii = [b6,b6,__ZNK10__cxxabiv117__array_type_info9can_catchEPKNS_16__shim_type_infoERPv,b6,__ZNK10__cxxabiv123__fundamental_type_info9can_catchEPKNS_16__shim_type_infoERPv,b6,__ZNK10__cxxabiv116__enum_type_info9can_catchEPKNS_16__shim_type_infoERPv,b6,__ZNK10__cxxabiv120__function_type_info9can_catchEPKNS_16__shim_type_infoERPv,b6,__ZNK10__cxxabiv117__class_type_info9can_catchEPKNS_16__shim_type_infoERPv,b6,__ZNK10__cxxabiv119__pointer_type_info9can_catchEPKNS_16__shim_type_infoERPv,b6,__ZNK10__cxxabiv117__pbase_type_info9can_catchEPKNS_16__shim_type_infoERPv,b6]; var FUNCTION_TABLE_viii = [b7,b7,__ZN10ime_pinyin8UserDict16reset_milestonesEtt,b7,__err,b7,__verr,b7,__verrx,b7,__ZN10ime_pinyin8DictTrie16reset_milestonesEtt,b7,__errx,b7,b7,b7]; var FUNCTION_TABLE_v = [b8,b8,___cxa_pure_virtual__wrapper,b8]; var FUNCTION_TABLE_viiiiii = [b9,b9,__ZNK10__cxxabiv117__class_type_info16search_above_dstEPNS_19__dynamic_cast_infoEPKvS4_ib,b9,__ZNK10__cxxabiv121__vmi_class_type_info16search_above_dstEPNS_19__dynamic_cast_infoEPKvS4_ib,b9,__ZNK10__cxxabiv120__si_class_type_info16search_above_dstEPNS_19__dynamic_cast_infoEPKvS4_ib,b9]; var FUNCTION_TABLE_iii = [b10,b10,__ZN10ime_pinyin11comp_doubleEPKvS1_,b10,__ZN10ime_pinyin24cmp_npre_by_hislen_scoreEPKvS1_,b10,__ZN10ime_pinyin10compare_pyEPKvS1_,b10,__ZN10ime_pinyin12cmp_hanzis_5EPKvS1_,b10,__ZN10ime_pinyin12cmp_hanzis_3EPKvS1_ ,b10,__ZN10ime_pinyin12cmp_hanzis_4EPKvS1_,b10,__ZN10ime_pinyin12cmp_hanzis_1EPKvS1_,b10,__ZN10ime_pinyin23cmp_npre_by_hanzi_scoreEPKvS1_,b10,__ZN10ime_pinyin12cmp_hanzis_2EPKvS1_,b10,__ZN10ime_pinyin24cmp_lpi_with_unified_psbEPKvS1_ ,b10,__ZN10ime_pinyin19cmp_lemma_entry_hzsEPKvS1_,b10,__ZN10ime_pinyin14compare_char16EPKvS1_,b10,__ZN10ime_pinyin17cmp_lpsi_with_strEPKvS1_,b10,__ZN10ime_pinyin8DictTrie12remove_lemmaEj,b10,__ZN10ime_pinyin8UserDict15get_lemma_scoreEj ,b10,__ZN10ime_pinyin12cmp_hanzis_6EPKvS1_,b10,__ZN10ime_pinyin17cmp_scis_hz_splidEPKvS1_,b10,__ZN10ime_pinyin7compareEPKvS1_,b10,__ZN10ime_pinyin12cmp_hanzis_8EPKvS1_,b10,__ZN10ime_pinyin18compare_raw_spl_ebEPKvS1_ ,b10,__ZN10ime_pinyin8DictTrie15get_lemma_scoreEj,b10,__ZN10ime_pinyin11compare_splEPKvS1_,b10,__ZN10ime_pinyin12cmp_hanzis_7EPKvS1_,b10,__ZN10ime_pinyin8UserDict12remove_lemmaEj,b10,__ZN10ime_pinyin22cmp_scis_hz_splid_freqEPKvS1_,b10,b10,b10,b10,b10,b10,b10,b10,b10,b10,b10,b10,b10]; var FUNCTION_TABLE_iiiiii = [b11,b11,__ZN10ime_pinyin8UserDict9put_lemmaEPtS1_tt,b11,__ZN10ime_pinyin8UserDict16get_lemma_splidsEjPttb,b11,__ZN10ime_pinyin8DictTrie8get_lpisEPKttPNS_10LmaPsbItemEj,b11,__ZN10ime_pinyin8DictTrie9put_lemmaEPtS1_tt,b11,__ZN10ime_pinyin8UserDict8get_lpisEPKttPNS_10LmaPsbItemEj,b11,__ZN10ime_pinyin8DictTrie16get_lemma_splidsEjPttb,b11,b11,b11]; var FUNCTION_TABLE_viiii = [b12,b12,__ZNK10__cxxabiv117__class_type_info27has_unambiguous_public_baseEPNS_19__dynamic_cast_infoEPvi,b12,__ZNK10__cxxabiv120__si_class_type_info27has_unambiguous_public_baseEPNS_19__dynamic_cast_infoEPvi,b12,__ZNK10__cxxabiv121__vmi_class_type_info27has_unambiguous_public_baseEPNS_19__dynamic_cast_infoEPvi,b12]; return { _im_enable_ym_as_szm: _im_enable_ym_as_szm, _strlen: _strlen, _im_reset_search: _im_reset_search, _im_flush_cache: _im_flush_cache, _im_get_candidate_char: _im_get_candidate_char, _realloc: _realloc, _im_get_spl_start: _im_get_spl_start, _im_close_decoder: _im_close_decoder, _toUTF8: _toUTF8, _im_open_decoder_fd: _im_open_decoder_fd, _strncpy: _strncpy, _im_get_spl_start_at: _im_get_spl_start_at, _im_get_fixed_len: _im_get_fixed_len, _im_cancel_last_choice: _im_cancel_last_choice, _memset: _memset, _im_search: _im_search, _memcpy: _memcpy, _calloc: _calloc, _im_choose: _im_choose, _im_set_max_lens: _im_set_max_lens, _im_get_predict_at: _im_get_predict_at, _im_get_candidate: _im_get_candidate, _im_enable_shm_as_szm: _im_enable_shm_as_szm, _im_get_sps_str: _im_get_sps_str, _memcmp: _memcmp, _im_get_predicts: _im_get_predicts, _free: _free, _im_open_decoder: _im_open_decoder, _memmove: _memmove, _malloc: _malloc, _im_get_predicts_utf8: _im_get_predicts_utf8, _im_delsearch: _im_delsearch, _strcpy: _strcpy, runPostSets: runPostSets, stackAlloc: stackAlloc, stackSave: stackSave, stackRestore: stackRestore, setThrew: setThrew, setTempRet0: setTempRet0, setTempRet1: setTempRet1, setTempRet2: setTempRet2, setTempRet3: setTempRet3, setTempRet4: setTempRet4, setTempRet5: setTempRet5, setTempRet6: setTempRet6, setTempRet7: setTempRet7, setTempRet8: setTempRet8, setTempRet9: setTempRet9, dynCall_viiiii: dynCall_viiiii, dynCall_vi: dynCall_vi, dynCall_vii: dynCall_vii, dynCall_iiiiiii: dynCall_iiiiiii, dynCall_iiiii: dynCall_iiiii, dynCall_ii: dynCall_ii, dynCall_iiii: dynCall_iiii, dynCall_viii: dynCall_viii, dynCall_v: dynCall_v, dynCall_viiiiii: dynCall_viiiiii, dynCall_iii: dynCall_iii, dynCall_iiiiii: dynCall_iiiiii, dynCall_viiii: dynCall_viiii }; }) // EMSCRIPTEN_END_ASM ({ "Math": Math, "Int8Array": Int8Array, "Int16Array": Int16Array, "Int32Array": Int32Array, "Uint8Array": Uint8Array, "Uint16Array": Uint16Array, "Uint32Array": Uint32Array, "Float32Array": Float32Array, "Float64Array": Float64Array }, { "abort": abort, "assert": assert, "asmPrintInt": asmPrintInt, "asmPrintFloat": asmPrintFloat, "min": Math_min, "invoke_viiiii": invoke_viiiii, "invoke_vi": invoke_vi, "invoke_vii": invoke_vii, "invoke_iiiiiii": invoke_iiiiiii, "invoke_iiiii": invoke_iiiii, "invoke_ii": invoke_ii, "invoke_iiii": invoke_iiii, "invoke_viii": invoke_viii, "invoke_v": invoke_v, "invoke_viiiiii": invoke_viiiiii, "invoke_iii": invoke_iii, "invoke_iiiiii": invoke_iiiiii, "invoke_viiii": invoke_viiii, "_strncmp": _strncmp, "_lseek": _lseek, "___cxa_call_unexpected": ___cxa_call_unexpected, "_snprintf": _snprintf, "___cxa_free_exception": ___cxa_free_exception, "___cxa_throw": ___cxa_throw, "_fread": _fread, "_fclose": _fclose, "_strerror": _strerror, "___cxa_pure_virtual": ___cxa_pure_virtual, "_fprintf": _fprintf, "_sqrt": _sqrt, "_llvm_va_end": _llvm_va_end, "_pread": _pread, "_close": _close, "_feof": _feof, "_fopen": _fopen, "_open": _open, "_strchr": _strchr, "_fputc": _fputc, "___buildEnvironment": ___buildEnvironment, "_log": _log, "_puts": _puts, "_abort": _abort, "___setErrNo": ___setErrNo, "_recv": _recv, "_fseek": _fseek, "_qsort": _qsort, "_qsort2": _qsort2, "_send": _send, "_write": _write, "_fputs": _fputs, "_ftell": _ftell, "_llvm_umul_with_overflow_i32": _llvm_umul_with_overflow_i32, "_exit": _exit, "___cxa_find_matching_catch": ___cxa_find_matching_catch, "_strdup": _strdup, "___cxa_allocate_exception": ___cxa_allocate_exception, "_ferror": _ferror, "_printf": _printf, "_sysconf": _sysconf, "_sbrk": _sbrk, "_truncate": _truncate, "_read": _read, "___cxa_is_number_type": ___cxa_is_number_type, "__reallyNegative": __reallyNegative, "_time": _time, "__formatString": __formatString, "___cxa_does_inherit": ___cxa_does_inherit, "_getenv": _getenv, "__ZSt9terminatev": __ZSt9terminatev, "_gettimeofday": _gettimeofday, "_llvm_eh_exception": _llvm_eh_exception, "_vfprintf": _vfprintf, "___cxa_begin_catch": ___cxa_begin_catch, "_unlink": _unlink, "___assert_func": ___assert_func, "__ZSt18uncaught_exceptionv": __ZSt18uncaught_exceptionv, "_pwrite": _pwrite, "_putchar": _putchar, "_fabs": _fabs, "_fsync": _fsync, "_strerror_r": _strerror_r, "___errno_location": ___errno_location, "___gxx_personality_v0": ___gxx_personality_v0, "_isspace": _isspace, "_fdopen": _fdopen, "_bsearch": _bsearch, "_fwrite": _fwrite, "_ftruncate": _ftruncate, "__exit": __exit, "___resumeException": ___resumeException, "_strcmp": _strcmp, "___cxa_end_catch": ___cxa_end_catch, "STACKTOP": STACKTOP, "STACK_MAX": STACK_MAX, "tempDoublePtr": tempDoublePtr, "ABORT": ABORT, "cttz_i8": cttz_i8, "ctlz_i8": ctlz_i8, "NaN": NaN, "Infinity": Infinity, "__ZTIy": __ZTIy, "__ZTIx": __ZTIx, "__ZTIt": __ZTIt, "__ZTIs": __ZTIs, "__ZTIm": __ZTIm, "__ZTIl": __ZTIl, "__ZTIi": __ZTIi, "__ZTIh": __ZTIh, "__ZTIj": __ZTIj, "__ZTIe": __ZTIe, "__ZTId": __ZTId, "__ZTVN10__cxxabiv117__class_type_infoE": __ZTVN10__cxxabiv117__class_type_infoE, "__ZTIf": __ZTIf, "__ZTIa": __ZTIa, "__ZTIc": __ZTIc, "__ZTVN10__cxxabiv120__si_class_type_infoE": __ZTVN10__cxxabiv120__si_class_type_infoE, "_stderr": _stderr, "___progname": ___progname, "__ZTVN10__cxxabiv119__pointer_type_infoE": __ZTVN10__cxxabiv119__pointer_type_infoE }, buffer); var _im_enable_ym_as_szm = Module["_im_enable_ym_as_szm"] = asm["_im_enable_ym_as_szm"]; var _strlen = Module["_strlen"] = asm["_strlen"]; var _im_reset_search = Module["_im_reset_search"] = asm["_im_reset_search"]; var _im_flush_cache = Module["_im_flush_cache"] = asm["_im_flush_cache"]; var _im_get_candidate_char = Module["_im_get_candidate_char"] = asm["_im_get_candidate_char"]; var _realloc = Module["_realloc"] = asm["_realloc"]; var _im_get_spl_start = Module["_im_get_spl_start"] = asm["_im_get_spl_start"]; var _im_close_decoder = Module["_im_close_decoder"] = asm["_im_close_decoder"]; var _toUTF8 = Module["_toUTF8"] = asm["_toUTF8"]; var _im_open_decoder_fd = Module["_im_open_decoder_fd"] = asm["_im_open_decoder_fd"]; var _strncpy = Module["_strncpy"] = asm["_strncpy"]; var _im_get_spl_start_at = Module["_im_get_spl_start_at"] = asm["_im_get_spl_start_at"]; var _im_get_fixed_len = Module["_im_get_fixed_len"] = asm["_im_get_fixed_len"]; var _im_cancel_last_choice = Module["_im_cancel_last_choice"] = asm["_im_cancel_last_choice"]; var _memset = Module["_memset"] = asm["_memset"]; var _im_search = Module["_im_search"] = asm["_im_search"]; var _memcpy = Module["_memcpy"] = asm["_memcpy"]; var _calloc = Module["_calloc"] = asm["_calloc"]; var _im_choose = Module["_im_choose"] = asm["_im_choose"]; var _im_set_max_lens = Module["_im_set_max_lens"] = asm["_im_set_max_lens"]; var _im_get_predict_at = Module["_im_get_predict_at"] = asm["_im_get_predict_at"]; var _im_get_candidate = Module["_im_get_candidate"] = asm["_im_get_candidate"]; var _im_enable_shm_as_szm = Module["_im_enable_shm_as_szm"] = asm["_im_enable_shm_as_szm"]; var _im_get_sps_str = Module["_im_get_sps_str"] = asm["_im_get_sps_str"]; var _memcmp = Module["_memcmp"] = asm["_memcmp"]; var _im_get_predicts = Module["_im_get_predicts"] = asm["_im_get_predicts"]; var _free = Module["_free"] = asm["_free"]; var _im_open_decoder = Module["_im_open_decoder"] = asm["_im_open_decoder"]; var _memmove = Module["_memmove"] = asm["_memmove"]; var _malloc = Module["_malloc"] = asm["_malloc"]; var _im_get_predicts_utf8 = Module["_im_get_predicts_utf8"] = asm["_im_get_predicts_utf8"]; var _im_delsearch = Module["_im_delsearch"] = asm["_im_delsearch"]; var _strcpy = Module["_strcpy"] = asm["_strcpy"]; var runPostSets = Module["runPostSets"] = asm["runPostSets"]; var dynCall_viiiii = Module["dynCall_viiiii"] = asm["dynCall_viiiii"]; var dynCall_vi = Module["dynCall_vi"] = asm["dynCall_vi"]; var dynCall_vii = Module["dynCall_vii"] = asm["dynCall_vii"]; var dynCall_iiiiiii = Module["dynCall_iiiiiii"] = asm["dynCall_iiiiiii"]; var dynCall_iiiii = Module["dynCall_iiiii"] = asm["dynCall_iiiii"]; var dynCall_ii = Module["dynCall_ii"] = asm["dynCall_ii"]; var dynCall_iiii = Module["dynCall_iiii"] = asm["dynCall_iiii"]; var dynCall_viii = Module["dynCall_viii"] = asm["dynCall_viii"]; var dynCall_v = Module["dynCall_v"] = asm["dynCall_v"]; var dynCall_viiiiii = Module["dynCall_viiiiii"] = asm["dynCall_viiiiii"]; var dynCall_iii = Module["dynCall_iii"] = asm["dynCall_iii"]; var dynCall_iiiiii = Module["dynCall_iiiiii"] = asm["dynCall_iiiiii"]; var dynCall_viiii = Module["dynCall_viiii"] = asm["dynCall_viiii"]; Runtime.stackAlloc = function(size) { return asm['stackAlloc'](size) }; Runtime.stackSave = function() { return asm['stackSave']() }; Runtime.stackRestore = function(top) { asm['stackRestore'](top) }; // TODO: strip out parts of this we do not need //======= begin closure i64 code ======= // Copyright 2009 The Closure Library 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. /** * @fileoverview Defines a Long class for representing a 64-bit two's-complement * integer value, which faithfully simulates the behavior of a Java "long". This * implementation is derived from LongLib in GWT. * */ var i64Math = (function() { // Emscripten wrapper var goog = { math: {} }; /** * Constructs a 64-bit two's-complement integer, given its low and high 32-bit * values as *signed* integers. See the from* functions below for more * convenient ways of constructing Longs. * * The internal representation of a long is the two given signed, 32-bit values. * We use 32-bit pieces because these are the size of integers on which * Javascript performs bit-operations. For operations like addition and * multiplication, we split each number into 16-bit pieces, which can easily be * multiplied within Javascript's floating-point representation without overflow * or change in sign. * * In the algorithms below, we frequently reduce the negative case to the * positive case by negating the input(s) and then post-processing the result. * Note that we must ALWAYS check specially whether those values are MIN_VALUE * (-2^63) because -MIN_VALUE == MIN_VALUE (since 2^63 cannot be represented as * a positive number, it overflows back into a negative). Not handling this * case would often result in infinite recursion. * * @param {number} low The low (signed) 32 bits of the long. * @param {number} high The high (signed) 32 bits of the long. * @constructor */ goog.math.Long = function(low, high) { /** * @type {number} * @private */ this.low_ = low | 0; // force into 32 signed bits. /** * @type {number} * @private */ this.high_ = high | 0; // force into 32 signed bits. }; // NOTE: Common constant values ZERO, ONE, NEG_ONE, etc. are defined below the // from* methods on which they depend. /** * A cache of the Long representations of small integer values. * @type {!Object} * @private */ goog.math.Long.IntCache_ = {}; /** * Returns a Long representing the given (32-bit) integer value. * @param {number} value The 32-bit integer in question. * @return {!goog.math.Long} The corresponding Long value. */ goog.math.Long.fromInt = function(value) { if (-128 <= value && value < 128) { var cachedObj = goog.math.Long.IntCache_[value]; if (cachedObj) { return cachedObj; } } var obj = new goog.math.Long(value | 0, value < 0 ? -1 : 0); if (-128 <= value && value < 128) { goog.math.Long.IntCache_[value] = obj; } return obj; }; /** * Returns a Long representing the given value, provided that it is a finite * number. Otherwise, zero is returned. * @param {number} value The number in question. * @return {!goog.math.Long} The corresponding Long value. */ goog.math.Long.fromNumber = function(value) { if (isNaN(value) || !isFinite(value)) { return goog.math.Long.ZERO; } else if (value <= -goog.math.Long.TWO_PWR_63_DBL_) { return goog.math.Long.MIN_VALUE; } else if (value + 1 >= goog.math.Long.TWO_PWR_63_DBL_) { return goog.math.Long.MAX_VALUE; } else if (value < 0) { return goog.math.Long.fromNumber(-value).negate(); } else { return new goog.math.Long( (value % goog.math.Long.TWO_PWR_32_DBL_) | 0, (value / goog.math.Long.TWO_PWR_32_DBL_) | 0); } }; /** * Returns a Long representing the 64-bit integer that comes by concatenating * the given high and low bits. Each is assumed to use 32 bits. * @param {number} lowBits The low 32-bits. * @param {number} highBits The high 32-bits. * @return {!goog.math.Long} The corresponding Long value. */ goog.math.Long.fromBits = function(lowBits, highBits) { return new goog.math.Long(lowBits, highBits); }; /** * Returns a Long representation of the given string, written using the given * radix. * @param {string} str The textual representation of the Long. * @param {number=} opt_radix The radix in which the text is written. * @return {!goog.math.Long} The corresponding Long value. */ goog.math.Long.fromString = function(str, opt_radix) { if (str.length == 0) { throw Error('number format error: empty string'); } var radix = opt_radix || 10; if (radix < 2 || 36 < radix) { throw Error('radix out of range: ' + radix); } if (str.charAt(0) == '-') { return goog.math.Long.fromString(str.substring(1), radix).negate(); } else if (str.indexOf('-') >= 0) { throw Error('number format error: interior "-" character: ' + str); } // Do several (8) digits each time through the loop, so as to // minimize the calls to the very expensive emulated div. var radixToPower = goog.math.Long.fromNumber(Math.pow(radix, 8)); var result = goog.math.Long.ZERO; for (var i = 0; i < str.length; i += 8) { var size = Math.min(8, str.length - i); var value = parseInt(str.substring(i, i + size), radix); if (size < 8) { var power = goog.math.Long.fromNumber(Math.pow(radix, size)); result = result.multiply(power).add(goog.math.Long.fromNumber(value)); } else { result = result.multiply(radixToPower); result = result.add(goog.math.Long.fromNumber(value)); } } return result; }; // NOTE: the compiler should inline these constant values below and then remove // these variables, so there should be no runtime penalty for these. /** * Number used repeated below in calculations. This must appear before the * first call to any from* function below. * @type {number} * @private */ goog.math.Long.TWO_PWR_16_DBL_ = 1 << 16; /** * @type {number} * @private */ goog.math.Long.TWO_PWR_24_DBL_ = 1 << 24; /** * @type {number} * @private */ goog.math.Long.TWO_PWR_32_DBL_ = goog.math.Long.TWO_PWR_16_DBL_ * goog.math.Long.TWO_PWR_16_DBL_; /** * @type {number} * @private */ goog.math.Long.TWO_PWR_31_DBL_ = goog.math.Long.TWO_PWR_32_DBL_ / 2; /** * @type {number} * @private */ goog.math.Long.TWO_PWR_48_DBL_ = goog.math.Long.TWO_PWR_32_DBL_ * goog.math.Long.TWO_PWR_16_DBL_; /** * @type {number} * @private */ goog.math.Long.TWO_PWR_64_DBL_ = goog.math.Long.TWO_PWR_32_DBL_ * goog.math.Long.TWO_PWR_32_DBL_; /** * @type {number} * @private */ goog.math.Long.TWO_PWR_63_DBL_ = goog.math.Long.TWO_PWR_64_DBL_ / 2; /** @type {!goog.math.Long} */ goog.math.Long.ZERO = goog.math.Long.fromInt(0); /** @type {!goog.math.Long} */ goog.math.Long.ONE = goog.math.Long.fromInt(1); /** @type {!goog.math.Long} */ goog.math.Long.NEG_ONE = goog.math.Long.fromInt(-1); /** @type {!goog.math.Long} */ goog.math.Long.MAX_VALUE = goog.math.Long.fromBits(0xFFFFFFFF | 0, 0x7FFFFFFF | 0); /** @type {!goog.math.Long} */ goog.math.Long.MIN_VALUE = goog.math.Long.fromBits(0, 0x80000000 | 0); /** * @type {!goog.math.Long} * @private */ goog.math.Long.TWO_PWR_24_ = goog.math.Long.fromInt(1 << 24); /** @return {number} The value, assuming it is a 32-bit integer. */ goog.math.Long.prototype.toInt = function() { return this.low_; }; /** @return {number} The closest floating-point representation to this value. */ goog.math.Long.prototype.toNumber = function() { return this.high_ * goog.math.Long.TWO_PWR_32_DBL_ + this.getLowBitsUnsigned(); }; /** * @param {number=} opt_radix The radix in which the text should be written. * @return {string} The textual representation of this value. */ goog.math.Long.prototype.toString = function(opt_radix) { var radix = opt_radix || 10; if (radix < 2 || 36 < radix) { throw Error('radix out of range: ' + radix); } if (this.isZero()) { return '0'; } if (this.isNegative()) { if (this.equals(goog.math.Long.MIN_VALUE)) { // We need to change the Long value before it can be negated, so we remove // the bottom-most digit in this base and then recurse to do the rest. var radixLong = goog.math.Long.fromNumber(radix); var div = this.div(radixLong); var rem = div.multiply(radixLong).subtract(this); return div.toString(radix) + rem.toInt().toString(radix); } else { return '-' + this.negate().toString(radix); } } // Do several (6) digits each time through the loop, so as to // minimize the calls to the very expensive emulated div. var radixToPower = goog.math.Long.fromNumber(Math.pow(radix, 6)); var rem = this; var result = ''; while (true) { var remDiv = rem.div(radixToPower); var intval = rem.subtract(remDiv.multiply(radixToPower)).toInt(); var digits = intval.toString(radix); rem = remDiv; if (rem.isZero()) { return digits + result; } else { while (digits.length < 6) { digits = '0' + digits; } result = '' + digits + result; } } }; /** @return {number} The high 32-bits as a signed value. */ goog.math.Long.prototype.getHighBits = function() { return this.high_; }; /** @return {number} The low 32-bits as a signed value. */ goog.math.Long.prototype.getLowBits = function() { return this.low_; }; /** @return {number} The low 32-bits as an unsigned value. */ goog.math.Long.prototype.getLowBitsUnsigned = function() { return (this.low_ >= 0) ? this.low_ : goog.math.Long.TWO_PWR_32_DBL_ + this.low_; }; /** * @return {number} Returns the number of bits needed to represent the absolute * value of this Long. */ goog.math.Long.prototype.getNumBitsAbs = function() { if (this.isNegative()) { if (this.equals(goog.math.Long.MIN_VALUE)) { return 64; } else { return this.negate().getNumBitsAbs(); } } else { var val = this.high_ != 0 ? this.high_ : this.low_; for (var bit = 31; bit > 0; bit--) { if ((val & (1 << bit)) != 0) { break; } } return this.high_ != 0 ? bit + 33 : bit + 1; } }; /** @return {boolean} Whether this value is zero. */ goog.math.Long.prototype.isZero = function() { return this.high_ == 0 && this.low_ == 0; }; /** @return {boolean} Whether this value is negative. */ goog.math.Long.prototype.isNegative = function() { return this.high_ < 0; }; /** @return {boolean} Whether this value is odd. */ goog.math.Long.prototype.isOdd = function() { return (this.low_ & 1) == 1; }; /** * @param {goog.math.Long} other Long to compare against. * @return {boolean} Whether this Long equals the other. */ goog.math.Long.prototype.equals = function(other) { return (this.high_ == other.high_) && (this.low_ == other.low_); }; /** * @param {goog.math.Long} other Long to compare against. * @return {boolean} Whether this Long does not equal the other. */ goog.math.Long.prototype.notEquals = function(other) { return (this.high_ != other.high_) || (this.low_ != other.low_); }; /** * @param {goog.math.Long} other Long to compare against. * @return {boolean} Whether this Long is less than the other. */ goog.math.Long.prototype.lessThan = function(other) { return this.compare(other) < 0; }; /** * @param {goog.math.Long} other Long to compare against. * @return {boolean} Whether this Long is less than or equal to the other. */ goog.math.Long.prototype.lessThanOrEqual = function(other) { return this.compare(other) <= 0; }; /** * @param {goog.math.Long} other Long to compare against. * @return {boolean} Whether this Long is greater than the other. */ goog.math.Long.prototype.greaterThan = function(other) { return this.compare(other) > 0; }; /** * @param {goog.math.Long} other Long to compare against. * @return {boolean} Whether this Long is greater than or equal to the other. */ goog.math.Long.prototype.greaterThanOrEqual = function(other) { return this.compare(other) >= 0; }; /** * Compares this Long with the given one. * @param {goog.math.Long} other Long to compare against. * @return {number} 0 if they are the same, 1 if the this is greater, and -1 * if the given one is greater. */ goog.math.Long.prototype.compare = function(other) { if (this.equals(other)) { return 0; } var thisNeg = this.isNegative(); var otherNeg = other.isNegative(); if (thisNeg && !otherNeg) { return -1; } if (!thisNeg && otherNeg) { return 1; } // at this point, the signs are the same, so subtraction will not overflow if (this.subtract(other).isNegative()) { return -1; } else { return 1; } }; /** @return {!goog.math.Long} The negation of this value. */ goog.math.Long.prototype.negate = function() { if (this.equals(goog.math.Long.MIN_VALUE)) { return goog.math.Long.MIN_VALUE; } else { return this.not().add(goog.math.Long.ONE); } }; /** * Returns the sum of this and the given Long. * @param {goog.math.Long} other Long to add to this one. * @return {!goog.math.Long} The sum of this and the given Long. */ goog.math.Long.prototype.add = function(other) { // Divide each number into 4 chunks of 16 bits, and then sum the chunks. var a48 = this.high_ >>> 16; var a32 = this.high_ & 0xFFFF; var a16 = this.low_ >>> 16; var a00 = this.low_ & 0xFFFF; var b48 = other.high_ >>> 16; var b32 = other.high_ & 0xFFFF; var b16 = other.low_ >>> 16; var b00 = other.low_ & 0xFFFF; var c48 = 0, c32 = 0, c16 = 0, c00 = 0; c00 += a00 + b00; c16 += c00 >>> 16; c00 &= 0xFFFF; c16 += a16 + b16; c32 += c16 >>> 16; c16 &= 0xFFFF; c32 += a32 + b32; c48 += c32 >>> 16; c32 &= 0xFFFF; c48 += a48 + b48; c48 &= 0xFFFF; return goog.math.Long.fromBits((c16 << 16) | c00, (c48 << 16) | c32); }; /** * Returns the difference of this and the given Long. * @param {goog.math.Long} other Long to subtract from this. * @return {!goog.math.Long} The difference of this and the given Long. */ goog.math.Long.prototype.subtract = function(other) { return this.add(other.negate()); }; /** * Returns the product of this and the given long. * @param {goog.math.Long} other Long to multiply with this. * @return {!goog.math.Long} The product of this and the other. */ goog.math.Long.prototype.multiply = function(other) { if (this.isZero()) { return goog.math.Long.ZERO; } else if (other.isZero()) { return goog.math.Long.ZERO; } if (this.equals(goog.math.Long.MIN_VALUE)) { return other.isOdd() ? goog.math.Long.MIN_VALUE : goog.math.Long.ZERO; } else if (other.equals(goog.math.Long.MIN_VALUE)) { return this.isOdd() ? goog.math.Long.MIN_VALUE : goog.math.Long.ZERO; } if (this.isNegative()) { if (other.isNegative()) { return this.negate().multiply(other.negate()); } else { return this.negate().multiply(other).negate(); } } else if (other.isNegative()) { return this.multiply(other.negate()).negate(); } // If both longs are small, use float multiplication if (this.lessThan(goog.math.Long.TWO_PWR_24_) && other.lessThan(goog.math.Long.TWO_PWR_24_)) { return goog.math.Long.fromNumber(this.toNumber() * other.toNumber()); } // Divide each long into 4 chunks of 16 bits, and then add up 4x4 products. // We can skip products that would overflow. var a48 = this.high_ >>> 16; var a32 = this.high_ & 0xFFFF; var a16 = this.low_ >>> 16; var a00 = this.low_ & 0xFFFF; var b48 = other.high_ >>> 16; var b32 = other.high_ & 0xFFFF; var b16 = other.low_ >>> 16; var b00 = other.low_ & 0xFFFF; var c48 = 0, c32 = 0, c16 = 0, c00 = 0; c00 += a00 * b00; c16 += c00 >>> 16; c00 &= 0xFFFF; c16 += a16 * b00; c32 += c16 >>> 16; c16 &= 0xFFFF; c16 += a00 * b16; c32 += c16 >>> 16; c16 &= 0xFFFF; c32 += a32 * b00; c48 += c32 >>> 16; c32 &= 0xFFFF; c32 += a16 * b16; c48 += c32 >>> 16; c32 &= 0xFFFF; c32 += a00 * b32; c48 += c32 >>> 16; c32 &= 0xFFFF; c48 += a48 * b00 + a32 * b16 + a16 * b32 + a00 * b48; c48 &= 0xFFFF; return goog.math.Long.fromBits((c16 << 16) | c00, (c48 << 16) | c32); }; /** * Returns this Long divided by the given one. * @param {goog.math.Long} other Long by which to divide. * @return {!goog.math.Long} This Long divided by the given one. */ goog.math.Long.prototype.div = function(other) { if (other.isZero()) { throw Error('division by zero'); } else if (this.isZero()) { return goog.math.Long.ZERO; } if (this.equals(goog.math.Long.MIN_VALUE)) { if (other.equals(goog.math.Long.ONE) || other.equals(goog.math.Long.NEG_ONE)) { return goog.math.Long.MIN_VALUE; // recall that -MIN_VALUE == MIN_VALUE } else if (other.equals(goog.math.Long.MIN_VALUE)) { return goog.math.Long.ONE; } else { // At this point, we have |other| >= 2, so |this/other| < |MIN_VALUE|. var halfThis = this.shiftRight(1); var approx = halfThis.div(other).shiftLeft(1); if (approx.equals(goog.math.Long.ZERO)) { return other.isNegative() ? goog.math.Long.ONE : goog.math.Long.NEG_ONE; } else { var rem = this.subtract(other.multiply(approx)); var result = approx.add(rem.div(other)); return result; } } } else if (other.equals(goog.math.Long.MIN_VALUE)) { return goog.math.Long.ZERO; } if (this.isNegative()) { if (other.isNegative()) { return this.negate().div(other.negate()); } else { return this.negate().div(other).negate(); } } else if (other.isNegative()) { return this.div(other.negate()).negate(); } // Repeat the following until the remainder is less than other: find a // floating-point that approximates remainder / other *from below*, add this // into the result, and subtract it from the remainder. It is critical that // the approximate value is less than or equal to the real value so that the // remainder never becomes negative. var res = goog.math.Long.ZERO; var rem = this; while (rem.greaterThanOrEqual(other)) { // Approximate the result of division. This may be a little greater or // smaller than the actual value. var approx = Math.max(1, Math.floor(rem.toNumber() / other.toNumber())); // We will tweak the approximate result by changing it in the 48-th digit or // the smallest non-fractional digit, whichever is larger. var log2 = Math.ceil(Math.log(approx) / Math.LN2); var delta = (log2 <= 48) ? 1 : Math.pow(2, log2 - 48); // Decrease the approximation until it is smaller than the remainder. Note // that if it is too large, the product overflows and is negative. var approxRes = goog.math.Long.fromNumber(approx); var approxRem = approxRes.multiply(other); while (approxRem.isNegative() || approxRem.greaterThan(rem)) { approx -= delta; approxRes = goog.math.Long.fromNumber(approx); approxRem = approxRes.multiply(other); } // We know the answer can't be zero... and actually, zero would cause // infinite recursion since we would make no progress. if (approxRes.isZero()) { approxRes = goog.math.Long.ONE; } res = res.add(approxRes); rem = rem.subtract(approxRem); } return res; }; /** * Returns this Long modulo the given one. * @param {goog.math.Long} other Long by which to mod. * @return {!goog.math.Long} This Long modulo the given one. */ goog.math.Long.prototype.modulo = function(other) { return this.subtract(this.div(other).multiply(other)); }; /** @return {!goog.math.Long} The bitwise-NOT of this value. */ goog.math.Long.prototype.not = function() { return goog.math.Long.fromBits(~this.low_, ~this.high_); }; /** * Returns the bitwise-AND of this Long and the given one. * @param {goog.math.Long} other The Long with which to AND. * @return {!goog.math.Long} The bitwise-AND of this and the other. */ goog.math.Long.prototype.and = function(other) { return goog.math.Long.fromBits(this.low_ & other.low_, this.high_ & other.high_); }; /** * Returns the bitwise-OR of this Long and the given one. * @param {goog.math.Long} other The Long with which to OR. * @return {!goog.math.Long} The bitwise-OR of this and the other. */ goog.math.Long.prototype.or = function(other) { return goog.math.Long.fromBits(this.low_ | other.low_, this.high_ | other.high_); }; /** * Returns the bitwise-XOR of this Long and the given one. * @param {goog.math.Long} other The Long with which to XOR. * @return {!goog.math.Long} The bitwise-XOR of this and the other. */ goog.math.Long.prototype.xor = function(other) { return goog.math.Long.fromBits(this.low_ ^ other.low_, this.high_ ^ other.high_); }; /** * Returns this Long with bits shifted to the left by the given amount. * @param {number} numBits The number of bits by which to shift. * @return {!goog.math.Long} This shifted to the left by the given amount. */ goog.math.Long.prototype.shiftLeft = function(numBits) { numBits &= 63; if (numBits == 0) { return this; } else { var low = this.low_; if (numBits < 32) { var high = this.high_; return goog.math.Long.fromBits( low << numBits, (high << numBits) | (low >>> (32 - numBits))); } else { return goog.math.Long.fromBits(0, low << (numBits - 32)); } } }; /** * Returns this Long with bits shifted to the right by the given amount. * @param {number} numBits The number of bits by which to shift. * @return {!goog.math.Long} This shifted to the right by the given amount. */ goog.math.Long.prototype.shiftRight = function(numBits) { numBits &= 63; if (numBits == 0) { return this; } else { var high = this.high_; if (numBits < 32) { var low = this.low_; return goog.math.Long.fromBits( (low >>> numBits) | (high << (32 - numBits)), high >> numBits); } else { return goog.math.Long.fromBits( high >> (numBits - 32), high >= 0 ? 0 : -1); } } }; /** * Returns this Long with bits shifted to the right by the given amount, with * the new top bits matching the current sign bit. * @param {number} numBits The number of bits by which to shift. * @return {!goog.math.Long} This shifted to the right by the given amount, with * zeros placed into the new leading bits. */ goog.math.Long.prototype.shiftRightUnsigned = function(numBits) { numBits &= 63; if (numBits == 0) { return this; } else { var high = this.high_; if (numBits < 32) { var low = this.low_; return goog.math.Long.fromBits( (low >>> numBits) | (high << (32 - numBits)), high >>> numBits); } else if (numBits == 32) { return goog.math.Long.fromBits(high, 0); } else { return goog.math.Long.fromBits(high >>> (numBits - 32), 0); } } }; //======= begin jsbn ======= var navigator = { appName: 'Modern Browser' }; // polyfill a little // Copyright (c) 2005 Tom Wu // All Rights Reserved. // http://www-cs-students.stanford.edu/~tjw/jsbn/ /* * Copyright (c) 2003-2005 Tom Wu * All Rights Reserved. * * 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" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL TOM WU BE LIABLE FOR ANY SPECIAL, INCIDENTAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * In addition, the following condition applies: * * All redistributions must retain an intact copy of this copyright notice * and disclaimer. */ // Basic JavaScript BN library - subset useful for RSA encryption. // Bits per digit var dbits; // JavaScript engine analysis var canary = 0xdeadbeefcafe; var j_lm = ((canary&0xffffff)==0xefcafe); // (public) Constructor function BigInteger(a,b,c) { if(a != null) if("number" == typeof a) this.fromNumber(a,b,c); else if(b == null && "string" != typeof a) this.fromString(a,256); else this.fromString(a,b); } // return new, unset BigInteger function nbi() { return new BigInteger(null); } // am: Compute w_j += (x*this_i), propagate carries, // c is initial carry, returns final carry. // c < 3*dvalue, x < 2*dvalue, this_i < dvalue // We need to select the fastest one that works in this environment. // am1: use a single mult and divide to get the high bits, // max digit bits should be 26 because // max internal value = 2*dvalue^2-2*dvalue (< 2^53) function am1(i,x,w,j,c,n) { while(--n >= 0) { var v = x*this[i++]+w[j]+c; c = Math.floor(v/0x4000000); w[j++] = v&0x3ffffff; } return c; } // am2 avoids a big mult-and-extract completely. // Max digit bits should be <= 30 because we do bitwise ops // on values up to 2*hdvalue^2-hdvalue-1 (< 2^31) function am2(i,x,w,j,c,n) { var xl = x&0x7fff, xh = x>>15; while(--n >= 0) { var l = this[i]&0x7fff; var h = this[i++]>>15; var m = xh*l+h*xl; l = xl*l+((m&0x7fff)<<15)+w[j]+(c&0x3fffffff); c = (l>>>30)+(m>>>15)+xh*h+(c>>>30); w[j++] = l&0x3fffffff; } return c; } // Alternately, set max digit bits to 28 since some // browsers slow down when dealing with 32-bit numbers. function am3(i,x,w,j,c,n) { var xl = x&0x3fff, xh = x>>14; while(--n >= 0) { var l = this[i]&0x3fff; var h = this[i++]>>14; var m = xh*l+h*xl; l = xl*l+((m&0x3fff)<<14)+w[j]+c; c = (l>>28)+(m>>14)+xh*h; w[j++] = l&0xfffffff; } return c; } if(j_lm && (navigator.appName == "Microsoft Internet Explorer")) { BigInteger.prototype.am = am2; dbits = 30; } else if(j_lm && (navigator.appName != "Netscape")) { BigInteger.prototype.am = am1; dbits = 26; } else { // Mozilla/Netscape seems to prefer am3 BigInteger.prototype.am = am3; dbits = 28; } BigInteger.prototype.DB = dbits; BigInteger.prototype.DM = ((1<<dbits)-1); BigInteger.prototype.DV = (1<<dbits); var BI_FP = 52; BigInteger.prototype.FV = Math.pow(2,BI_FP); BigInteger.prototype.F1 = BI_FP-dbits; BigInteger.prototype.F2 = 2*dbits-BI_FP; // Digit conversions var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz"; var BI_RC = new Array(); var rr,vv; rr = "0".charCodeAt(0); for(vv = 0; vv <= 9; ++vv) BI_RC[rr++] = vv; rr = "a".charCodeAt(0); for(vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv; rr = "A".charCodeAt(0); for(vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv; function int2char(n) { return BI_RM.charAt(n); } function intAt(s,i) { var c = BI_RC[s.charCodeAt(i)]; return (c==null)?-1:c; } // (protected) copy this to r function bnpCopyTo(r) { for(var i = this.t-1; i >= 0; --i) r[i] = this[i]; r.t = this.t; r.s = this.s; } // (protected) set from integer value x, -DV <= x < DV function bnpFromInt(x) { this.t = 1; this.s = (x<0)?-1:0; if(x > 0) this[0] = x; else if(x < -1) this[0] = x+DV; else this.t = 0; } // return bigint initialized to value function nbv(i) { var r = nbi(); r.fromInt(i); return r; } // (protected) set from string and radix function bnpFromString(s,b) { var k; if(b == 16) k = 4; else if(b == 8) k = 3; else if(b == 256) k = 8; // byte array else if(b == 2) k = 1; else if(b == 32) k = 5; else if(b == 4) k = 2; else { this.fromRadix(s,b); return; } this.t = 0; this.s = 0; var i = s.length, mi = false, sh = 0; while(--i >= 0) { var x = (k==8)?s[i]&0xff:intAt(s,i); if(x < 0) { if(s.charAt(i) == "-") mi = true; continue; } mi = false; if(sh == 0) this[this.t++] = x; else if(sh+k > this.DB) { this[this.t-1] |= (x&((1<<(this.DB-sh))-1))<<sh; this[this.t++] = (x>>(this.DB-sh)); } else this[this.t-1] |= x<<sh; sh += k; if(sh >= this.DB) sh -= this.DB; } if(k == 8 && (s[0]&0x80) != 0) { this.s = -1; if(sh > 0) this[this.t-1] |= ((1<<(this.DB-sh))-1)<<sh; } this.clamp(); if(mi) BigInteger.ZERO.subTo(this,this); } // (protected) clamp off excess high words function bnpClamp() { var c = this.s&this.DM; while(this.t > 0 && this[this.t-1] == c) --this.t; } // (public) return string representation in given radix function bnToString(b) { if(this.s < 0) return "-"+this.negate().toString(b); var k; if(b == 16) k = 4; else if(b == 8) k = 3; else if(b == 2) k = 1; else if(b == 32) k = 5; else if(b == 4) k = 2; else return this.toRadix(b); var km = (1<<k)-1, d, m = false, r = "", i = this.t; var p = this.DB-(i*this.DB)%k; if(i-- > 0) { if(p < this.DB && (d = this[i]>>p) > 0) { m = true; r = int2char(d); } while(i >= 0) { if(p < k) { d = (this[i]&((1<<p)-1))<<(k-p); d |= this[--i]>>(p+=this.DB-k); } else { d = (this[i]>>(p-=k))&km; if(p <= 0) { p += this.DB; --i; } } if(d > 0) m = true; if(m) r += int2char(d); } } return m?r:"0"; } // (public) -this function bnNegate() { var r = nbi(); BigInteger.ZERO.subTo(this,r); return r; } // (public) |this| function bnAbs() { return (this.s<0)?this.negate():this; } // (public) return + if this > a, - if this < a, 0 if equal function bnCompareTo(a) { var r = this.s-a.s; if(r != 0) return r; var i = this.t; r = i-a.t; if(r != 0) return (this.s<0)?-r:r; while(--i >= 0) if((r=this[i]-a[i]) != 0) return r; return 0; } // returns bit length of the integer x function nbits(x) { var r = 1, t; if((t=x>>>16) != 0) { x = t; r += 16; } if((t=x>>8) != 0) { x = t; r += 8; } if((t=x>>4) != 0) { x = t; r += 4; } if((t=x>>2) != 0) { x = t; r += 2; } if((t=x>>1) != 0) { x = t; r += 1; } return r; } // (public) return the number of bits in "this" function bnBitLength() { if(this.t <= 0) return 0; return this.DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this.DM)); } // (protected) r = this << n*DB function bnpDLShiftTo(n,r) { var i; for(i = this.t-1; i >= 0; --i) r[i+n] = this[i]; for(i = n-1; i >= 0; --i) r[i] = 0; r.t = this.t+n; r.s = this.s; } // (protected) r = this >> n*DB function bnpDRShiftTo(n,r) { for(var i = n; i < this.t; ++i) r[i-n] = this[i]; r.t = Math.max(this.t-n,0); r.s = this.s; } // (protected) r = this << n function bnpLShiftTo(n,r) { var bs = n%this.DB; var cbs = this.DB-bs; var bm = (1<<cbs)-1; var ds = Math.floor(n/this.DB), c = (this.s<<bs)&this.DM, i; for(i = this.t-1; i >= 0; --i) { r[i+ds+1] = (this[i]>>cbs)|c; c = (this[i]&bm)<<bs; } for(i = ds-1; i >= 0; --i) r[i] = 0; r[ds] = c; r.t = this.t+ds+1; r.s = this.s; r.clamp(); } // (protected) r = this >> n function bnpRShiftTo(n,r) { r.s = this.s; var ds = Math.floor(n/this.DB); if(ds >= this.t) { r.t = 0; return; } var bs = n%this.DB; var cbs = this.DB-bs; var bm = (1<<bs)-1; r[0] = this[ds]>>bs; for(var i = ds+1; i < this.t; ++i) { r[i-ds-1] |= (this[i]&bm)<<cbs; r[i-ds] = this[i]>>bs; } if(bs > 0) r[this.t-ds-1] |= (this.s&bm)<<cbs; r.t = this.t-ds; r.clamp(); } // (protected) r = this - a function bnpSubTo(a,r) { var i = 0, c = 0, m = Math.min(a.t,this.t); while(i < m) { c += this[i]-a[i]; r[i++] = c&this.DM; c >>= this.DB; } if(a.t < this.t) { c -= a.s; while(i < this.t) { c += this[i]; r[i++] = c&this.DM; c >>= this.DB; } c += this.s; } else { c += this.s; while(i < a.t) { c -= a[i]; r[i++] = c&this.DM; c >>= this.DB; } c -= a.s; } r.s = (c<0)?-1:0; if(c < -1) r[i++] = this.DV+c; else if(c > 0) r[i++] = c; r.t = i; r.clamp(); } // (protected) r = this * a, r != this,a (HAC 14.12) // "this" should be the larger one if appropriate. function bnpMultiplyTo(a,r) { var x = this.abs(), y = a.abs(); var i = x.t; r.t = i+y.t; while(--i >= 0) r[i] = 0; for(i = 0; i < y.t; ++i) r[i+x.t] = x.am(0,y[i],r,i,0,x.t); r.s = 0; r.clamp(); if(this.s != a.s) BigInteger.ZERO.subTo(r,r); } // (protected) r = this^2, r != this (HAC 14.16) function bnpSquareTo(r) { var x = this.abs(); var i = r.t = 2*x.t; while(--i >= 0) r[i] = 0; for(i = 0; i < x.t-1; ++i) { var c = x.am(i,x[i],r,2*i,0,1); if((r[i+x.t]+=x.am(i+1,2*x[i],r,2*i+1,c,x.t-i-1)) >= x.DV) { r[i+x.t] -= x.DV; r[i+x.t+1] = 1; } } if(r.t > 0) r[r.t-1] += x.am(i,x[i],r,2*i,0,1); r.s = 0; r.clamp(); } // (protected) divide this by m, quotient and remainder to q, r (HAC 14.20) // r != q, this != m. q or r may be null. function bnpDivRemTo(m,q,r) { var pm = m.abs(); if(pm.t <= 0) return; var pt = this.abs(); if(pt.t < pm.t) { if(q != null) q.fromInt(0); if(r != null) this.copyTo(r); return; } if(r == null) r = nbi(); var y = nbi(), ts = this.s, ms = m.s; var nsh = this.DB-nbits(pm[pm.t-1]); // normalize modulus if(nsh > 0) { pm.lShiftTo(nsh,y); pt.lShiftTo(nsh,r); } else { pm.copyTo(y); pt.copyTo(r); } var ys = y.t; var y0 = y[ys-1]; if(y0 == 0) return; var yt = y0*(1<<this.F1)+((ys>1)?y[ys-2]>>this.F2:0); var d1 = this.FV/yt, d2 = (1<<this.F1)/yt, e = 1<<this.F2; var i = r.t, j = i-ys, t = (q==null)?nbi():q; y.dlShiftTo(j,t); if(r.compareTo(t) >= 0) { r[r.t++] = 1; r.subTo(t,r); } BigInteger.ONE.dlShiftTo(ys,t); t.subTo(y,y); // "negative" y so we can replace sub with am later while(y.t < ys) y[y.t++] = 0; while(--j >= 0) { // Estimate quotient digit var qd = (r[--i]==y0)?this.DM:Math.floor(r[i]*d1+(r[i-1]+e)*d2); if((r[i]+=y.am(0,qd,r,j,0,ys)) < qd) { // Try it out y.dlShiftTo(j,t); r.subTo(t,r); while(r[i] < --qd) r.subTo(t,r); } } if(q != null) { r.drShiftTo(ys,q); if(ts != ms) BigInteger.ZERO.subTo(q,q); } r.t = ys; r.clamp(); if(nsh > 0) r.rShiftTo(nsh,r); // Denormalize remainder if(ts < 0) BigInteger.ZERO.subTo(r,r); } // (public) this mod a function bnMod(a) { var r = nbi(); this.abs().divRemTo(a,null,r); if(this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r,r); return r; } // Modular reduction using "classic" algorithm function Classic(m) { this.m = m; } function cConvert(x) { if(x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m); else return x; } function cRevert(x) { return x; } function cReduce(x) { x.divRemTo(this.m,null,x); } function cMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); } function cSqrTo(x,r) { x.squareTo(r); this.reduce(r); } Classic.prototype.convert = cConvert; Classic.prototype.revert = cRevert; Classic.prototype.reduce = cReduce; Classic.prototype.mulTo = cMulTo; Classic.prototype.sqrTo = cSqrTo; // (protected) return "-1/this % 2^DB"; useful for Mont. reduction // justification: // xy == 1 (mod m) // xy = 1+km // xy(2-xy) = (1+km)(1-km) // x[y(2-xy)] = 1-k^2m^2 // x[y(2-xy)] == 1 (mod m^2) // if y is 1/x mod m, then y(2-xy) is 1/x mod m^2 // should reduce x and y(2-xy) by m^2 at each step to keep size bounded. // JS multiply "overflows" differently from C/C++, so care is needed here. function bnpInvDigit() { if(this.t < 1) return 0; var x = this[0]; if((x&1) == 0) return 0; var y = x&3; // y == 1/x mod 2^2 y = (y*(2-(x&0xf)*y))&0xf; // y == 1/x mod 2^4 y = (y*(2-(x&0xff)*y))&0xff; // y == 1/x mod 2^8 y = (y*(2-(((x&0xffff)*y)&0xffff)))&0xffff; // y == 1/x mod 2^16 // last step - calculate inverse mod DV directly; // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints y = (y*(2-x*y%this.DV))%this.DV; // y == 1/x mod 2^dbits // we really want the negative inverse, and -DV < y < DV return (y>0)?this.DV-y:-y; } // Montgomery reduction function Montgomery(m) { this.m = m; this.mp = m.invDigit(); this.mpl = this.mp&0x7fff; this.mph = this.mp>>15; this.um = (1<<(m.DB-15))-1; this.mt2 = 2*m.t; } // xR mod m function montConvert(x) { var r = nbi(); x.abs().dlShiftTo(this.m.t,r); r.divRemTo(this.m,null,r); if(x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r,r); return r; } // x/R mod m function montRevert(x) { var r = nbi(); x.copyTo(r); this.reduce(r); return r; } // x = x/R mod m (HAC 14.32) function montReduce(x) { while(x.t <= this.mt2) // pad x so am has enough room later x[x.t++] = 0; for(var i = 0; i < this.m.t; ++i) { // faster way of calculating u0 = x[i]*mp mod DV var j = x[i]&0x7fff; var u0 = (j*this.mpl+(((j*this.mph+(x[i]>>15)*this.mpl)&this.um)<<15))&x.DM; // use am to combine the multiply-shift-add into one call j = i+this.m.t; x[j] += this.m.am(0,u0,x,i,0,this.m.t); // propagate carry while(x[j] >= x.DV) { x[j] -= x.DV; x[++j]++; } } x.clamp(); x.drShiftTo(this.m.t,x); if(x.compareTo(this.m) >= 0) x.subTo(this.m,x); } // r = "x^2/R mod m"; x != r function montSqrTo(x,r) { x.squareTo(r); this.reduce(r); } // r = "xy/R mod m"; x,y != r function montMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); } Montgomery.prototype.convert = montConvert; Montgomery.prototype.revert = montRevert; Montgomery.prototype.reduce = montReduce; Montgomery.prototype.mulTo = montMulTo; Montgomery.prototype.sqrTo = montSqrTo; // (protected) true iff this is even function bnpIsEven() { return ((this.t>0)?(this[0]&1):this.s) == 0; } // (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79) function bnpExp(e,z) { if(e > 0xffffffff || e < 1) return BigInteger.ONE; var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e)-1; g.copyTo(r); while(--i >= 0) { z.sqrTo(r,r2); if((e&(1<<i)) > 0) z.mulTo(r2,g,r); else { var t = r; r = r2; r2 = t; } } return z.revert(r); } // (public) this^e % m, 0 <= e < 2^32 function bnModPowInt(e,m) { var z; if(e < 256 || m.isEven()) z = new Classic(m); else z = new Montgomery(m); return this.exp(e,z); } // protected BigInteger.prototype.copyTo = bnpCopyTo; BigInteger.prototype.fromInt = bnpFromInt; BigInteger.prototype.fromString = bnpFromString; BigInteger.prototype.clamp = bnpClamp; BigInteger.prototype.dlShiftTo = bnpDLShiftTo; BigInteger.prototype.drShiftTo = bnpDRShiftTo; BigInteger.prototype.lShiftTo = bnpLShiftTo; BigInteger.prototype.rShiftTo = bnpRShiftTo; BigInteger.prototype.subTo = bnpSubTo; BigInteger.prototype.multiplyTo = bnpMultiplyTo; BigInteger.prototype.squareTo = bnpSquareTo; BigInteger.prototype.divRemTo = bnpDivRemTo; BigInteger.prototype.invDigit = bnpInvDigit; BigInteger.prototype.isEven = bnpIsEven; BigInteger.prototype.exp = bnpExp; // public BigInteger.prototype.toString = bnToString; BigInteger.prototype.negate = bnNegate; BigInteger.prototype.abs = bnAbs; BigInteger.prototype.compareTo = bnCompareTo; BigInteger.prototype.bitLength = bnBitLength; BigInteger.prototype.mod = bnMod; BigInteger.prototype.modPowInt = bnModPowInt; // "constants" BigInteger.ZERO = nbv(0); BigInteger.ONE = nbv(1); // jsbn2 stuff // (protected) convert from radix string function bnpFromRadix(s,b) { this.fromInt(0); if(b == null) b = 10; var cs = this.chunkSize(b); var d = Math.pow(b,cs), mi = false, j = 0, w = 0; for(var i = 0; i < s.length; ++i) { var x = intAt(s,i); if(x < 0) { if(s.charAt(i) == "-" && this.signum() == 0) mi = true; continue; } w = b*w+x; if(++j >= cs) { this.dMultiply(d); this.dAddOffset(w,0); j = 0; w = 0; } } if(j > 0) { this.dMultiply(Math.pow(b,j)); this.dAddOffset(w,0); } if(mi) BigInteger.ZERO.subTo(this,this); } // (protected) return x s.t. r^x < DV function bnpChunkSize(r) { return Math.floor(Math.LN2*this.DB/Math.log(r)); } // (public) 0 if this == 0, 1 if this > 0 function bnSigNum() { if(this.s < 0) return -1; else if(this.t <= 0 || (this.t == 1 && this[0] <= 0)) return 0; else return 1; } // (protected) this *= n, this >= 0, 1 < n < DV function bnpDMultiply(n) { this[this.t] = this.am(0,n-1,this,0,0,this.t); ++this.t; this.clamp(); } // (protected) this += n << w words, this >= 0 function bnpDAddOffset(n,w) { if(n == 0) return; while(this.t <= w) this[this.t++] = 0; this[w] += n; while(this[w] >= this.DV) { this[w] -= this.DV; if(++w >= this.t) this[this.t++] = 0; ++this[w]; } } // (protected) convert to radix string function bnpToRadix(b) { if(b == null) b = 10; if(this.signum() == 0 || b < 2 || b > 36) return "0"; var cs = this.chunkSize(b); var a = Math.pow(b,cs); var d = nbv(a), y = nbi(), z = nbi(), r = ""; this.divRemTo(d,y,z); while(y.signum() > 0) { r = (a+z.intValue()).toString(b).substr(1) + r; y.divRemTo(d,y,z); } return z.intValue().toString(b) + r; } // (public) return value as integer function bnIntValue() { if(this.s < 0) { if(this.t == 1) return this[0]-this.DV; else if(this.t == 0) return -1; } else if(this.t == 1) return this[0]; else if(this.t == 0) return 0; // assumes 16 < DB < 32 return ((this[1]&((1<<(32-this.DB))-1))<<this.DB)|this[0]; } // (protected) r = this + a function bnpAddTo(a,r) { var i = 0, c = 0, m = Math.min(a.t,this.t); while(i < m) { c += this[i]+a[i]; r[i++] = c&this.DM; c >>= this.DB; } if(a.t < this.t) { c += a.s; while(i < this.t) { c += this[i]; r[i++] = c&this.DM; c >>= this.DB; } c += this.s; } else { c += this.s; while(i < a.t) { c += a[i]; r[i++] = c&this.DM; c >>= this.DB; } c += a.s; } r.s = (c<0)?-1:0; if(c > 0) r[i++] = c; else if(c < -1) r[i++] = this.DV+c; r.t = i; r.clamp(); } BigInteger.prototype.fromRadix = bnpFromRadix; BigInteger.prototype.chunkSize = bnpChunkSize; BigInteger.prototype.signum = bnSigNum; BigInteger.prototype.dMultiply = bnpDMultiply; BigInteger.prototype.dAddOffset = bnpDAddOffset; BigInteger.prototype.toRadix = bnpToRadix; BigInteger.prototype.intValue = bnIntValue; BigInteger.prototype.addTo = bnpAddTo; //======= end jsbn ======= // Emscripten wrapper var Wrapper = { abs: function(l, h) { var x = new goog.math.Long(l, h); var ret; if (x.isNegative()) { ret = x.negate(); } else { ret = x; } HEAP32[tempDoublePtr>>2] = ret.low_; HEAP32[tempDoublePtr+4>>2] = ret.high_; }, ensureTemps: function() { if (Wrapper.ensuredTemps) return; Wrapper.ensuredTemps = true; Wrapper.two32 = new BigInteger(); Wrapper.two32.fromString('4294967296', 10); Wrapper.two64 = new BigInteger(); Wrapper.two64.fromString('18446744073709551616', 10); Wrapper.temp1 = new BigInteger(); Wrapper.temp2 = new BigInteger(); }, lh2bignum: function(l, h) { var a = new BigInteger(); a.fromString(h.toString(), 10); var b = new BigInteger(); a.multiplyTo(Wrapper.two32, b); var c = new BigInteger(); c.fromString(l.toString(), 10); var d = new BigInteger(); c.addTo(b, d); return d; }, stringify: function(l, h, unsigned) { var ret = new goog.math.Long(l, h).toString(); if (unsigned && ret[0] == '-') { // unsign slowly using jsbn bignums Wrapper.ensureTemps(); var bignum = new BigInteger(); bignum.fromString(ret, 10); ret = new BigInteger(); Wrapper.two64.addTo(bignum, ret); ret = ret.toString(10); } return ret; }, fromString: function(str, base, min, max, unsigned) { Wrapper.ensureTemps(); var bignum = new BigInteger(); bignum.fromString(str, base); var bigmin = new BigInteger(); bigmin.fromString(min, 10); var bigmax = new BigInteger(); bigmax.fromString(max, 10); if (unsigned && bignum.compareTo(BigInteger.ZERO) < 0) { var temp = new BigInteger(); bignum.addTo(Wrapper.two64, temp); bignum = temp; } var error = false; if (bignum.compareTo(bigmin) < 0) { bignum = bigmin; error = true; } else if (bignum.compareTo(bigmax) > 0) { bignum = bigmax; error = true; } var ret = goog.math.Long.fromString(bignum.toString()); // min-max checks should have clamped this to a range goog.math.Long can handle well HEAP32[tempDoublePtr>>2] = ret.low_; HEAP32[tempDoublePtr+4>>2] = ret.high_; if (error) throw 'range error'; } }; return Wrapper; })(); //======= end closure i64 code ======= // === Auto-generated postamble setup entry stuff === var initialStackTop; var inMain; Module['callMain'] = Module.callMain = function callMain(args) { assert(runDependencies == 0, 'cannot call main when async dependencies remain! (listen on __ATMAIN__)'); assert(__ATPRERUN__.length == 0, 'cannot call main when preRun functions remain to be called'); args = args || []; ensureInitRuntime(); var argc = args.length+1; function pad() { for (var i = 0; i < 4-1; i++) { argv.push(0); } } var argv = [allocate(intArrayFromString("/bin/this.program"), 'i8', ALLOC_NORMAL) ]; pad(); for (var i = 0; i < argc-1; i = i + 1) { argv.push(allocate(intArrayFromString(args[i]), 'i8', ALLOC_NORMAL)); pad(); } argv.push(0); argv = allocate(argv, 'i32', ALLOC_NORMAL); initialStackTop = STACKTOP; inMain = true; var ret; try { ret = Module['_main'](argc, argv, 0); } catch(e) { if (e && typeof e == 'object' && e.type == 'ExitStatus') { // exit() throws this once it's done to make sure execution // has been stopped completely Module.print('Exit Status: ' + e.value); return e.value; } else if (e == 'SimulateInfiniteLoop') { // running an evented main loop, don't immediately exit Module['noExitRuntime'] = true; } else { throw e; } } finally { inMain = false; } // if we're not running an evented main loop, it's time to exit if (!Module['noExitRuntime']) { exit(ret); } } function run(args) { args = args || Module['arguments']; if (runDependencies > 0) { Module.printErr('run() called, but dependencies remain, so not running'); return; } preRun(); if (runDependencies > 0) { // a preRun added a dependency, run will be called later return; } function doRun() { ensureInitRuntime(); preMain(); calledRun = true; if (Module['_main'] && shouldRunNow) { Module['callMain'](args); } postRun(); } if (Module['setStatus']) { Module['setStatus']('Running...'); setTimeout(function() { setTimeout(function() { Module['setStatus'](''); }, 1); if (!ABORT) doRun(); }, 1); } else { doRun(); } } Module['run'] = Module.run = run; function exit(status) { ABORT = true; STACKTOP = initialStackTop; // TODO call externally added 'exit' callbacks with the status code. // It'd be nice to provide the same interface for all Module events (e.g. // prerun, premain, postmain). Perhaps an EventEmitter so we can do: // Module.on('exit', function (status) {}); // exit the runtime exitRuntime(); if (inMain) { // if we're still inside the callMain's try/catch, we need to throw an // exception in order to immediately terminate execution. throw { type: 'ExitStatus', value: status }; } } Module['exit'] = Module.exit = exit; function abort(text) { if (text) { Module.print(text); } ABORT = true; throw 'abort() at ' + (new Error().stack); } Module['abort'] = Module.abort = abort; // {{PRE_RUN_ADDITIONS}} if (Module['preInit']) { if (typeof Module['preInit'] == 'function') Module['preInit'] = [Module['preInit']]; while (Module['preInit'].length > 0) { Module['preInit'].pop()(); } } // shouldRunNow refers to calling main(), not run(). var shouldRunNow = true; if (Module['noInitialRun']) { shouldRunNow = false; } run(); // {{POST_RUN_ADDITIONS}} // {{MODULE_ADDITIONS}} })(Module);
__ZN10__cxxabiv129__pointer_to_member_type_infoD0Ev
LoginForm.tsx
import { useState } from "react"; import { Button, Col, Container, Form, Row } from "react-bootstrap"; import { login, register } from "../requests"; import { User } from "../types"; interface SubmitEvent extends Event { readonly submitter: HTMLElement; } interface LoginFormProps { setUser: (user: User) => void; } const LoginForm = (props: LoginFormProps) => { const [username, setUsername] = useState(""); const [password, setPassword] = useState(""); const [loading, setLoading] = useState(false); const [errorMessage, setErrorMessage] = useState(""); const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => { e.preventDefault(); // TODO: remove this in favour of a separate form for registering // SubmitEvent isn't standard yet const submitterName = ( (e.nativeEvent as SubmitEvent)?.submitter as HTMLButtonElement )?.name; if (submitterName === "registerButton") { handleRegister(); } else { handleLogin(); } }; const handleLogin = async () => { setLoading(true); const user = await login(username, password); setLoading(false); if (user !== null) { setErrorMessage(""); props.setUser(user); } else { setErrorMessage("Credentials are incorrect"); } return false; }; const handleRegister = async () => { setLoading(true); const user = await register(username, password); setLoading(false); if (user !== null) { setErrorMessage(""); props.setUser(user); } else { setErrorMessage(`Username ${username} is not available`); } }; return ( <Container className="mt-5"> <Row className="justify-content-center"> <Col xs={4} className="align-middle"> <h1>welcome to lili</h1> <p className="text-danger">{errorMessage}</p> <Form onSubmit={handleSubmit}> <Form.Group className="mb-3" controlId="formBasicUsername" > <Form.Label>username</Form.Label> <Form.Control className="text-light" placeholder="username" type="text" value={username} required maxLength={30} onChange={(e) => setUsername(e.target.value)} /> </Form.Group> <Form.Group className="mb-3" controlId="formBasicPassword" > <Form.Label>password</Form.Label> <Form.Control className="text-light" placeholder="password" type="password" value={password} required maxLength={30} onChange={(e) => setPassword(e.target.value)} /> </Form.Group> <Button variant="primary" type="submit" disabled={loading} name="loginButton" > login </Button>{" "} <Button variant="primary" type="submit" disabled={loading} name="registerButton" > register </Button> </Form> </Col> </Row> </Container> );
}; export default LoginForm;
mmapfactory.go
package bigqueue import ( "fmt" "log" "os" "strconv" "strings" "sync" ) // DBFactory is used to manupilate mulitple data files by index number type DBFactory struct { lockMap map[int64]*sync.Mutex // DB mapping with file index no dbMap map[int64]*DB filePrefix string fileSuffix string lock sync.Mutex filePath string InitialMmapSize int } func (f *DBFactory) acquireDB(index int64) (*DB, error) { db := f.dbMap[index] if db != nil { return db, nil } // add map lock f.lock.Lock() lock := f.lockMap[index] if lock == nil { lock = &(sync.Mutex{}) f.lockMap[index] = lock } defer func() { delete(f.lockMap, index) }() f.lock.Unlock() // lock by index lock.Lock() defer lock.Unlock() db = &DB{ path: f.getFilePath(index), InitialMmapSize: f.InitialMmapSize, opened: true, } err := db.Open(defaultFileMode) if err != nil { return nil, err } f.dbMap[index] = db return db, nil }
// Close all data files func (f *DBFactory) Close() error { if f.dbMap != nil { for k, v := range f.dbMap { err := v.Close() if err != nil { log.Println("Close DB from map failed. ", k, err) } } } // set to the emtpy map f.dbMap = make(map[int64]*DB) f.lockMap = make(map[int64]*sync.Mutex) return nil } func (f *DBFactory) removeBeforeIndex(index int64) error { f.lock.Lock() defer f.lock.Unlock() for idx, db := range f.dbMap { if int64(idx) < index { log.Println("Do delete index db file by gc. no=", idx) db.Close() os.Remove(f.getFilePath(idx)) delete(f.dbMap, idx) } } // double check delete file files, err := GetFiles(f.filePath) if err != nil { return err } for i := files.Front(); i != nil; i = i.Next() { fn := fmt.Sprintf("%v", i.Value) if strings.HasSuffix(fn, f.fileSuffix) { fin := f.getFileIndex(fn) if fin >= 0 && int64(fin) < index { log.Println("Do delete index db file by gc. no=", fin) os.Remove(f.getFilePath(fin)) } } } return nil } func (f *DBFactory) getFileIndex(fn string) int64 { beginIndex := strings.LastIndex(fn, "-") beginIndex = beginIndex + 1 endIndex := strings.LastIndex(fn, f.fileSuffix) sIndex, err := strconv.Atoi(fn[beginIndex:endIndex]) if err != nil { return -1 } return int64(sIndex) }
func (f *DBFactory) getFilePath(index int64) string { return f.filePath + "/" + GetFileName(f.filePrefix, f.fileSuffix, index) }
invincible.rs
use super::component_prelude::*; #[derive(Default)] pub struct
; impl Component for Invincible { type Storage = NullStorage<Self>; }
Invincible
listing06.go
// Sample program to show how you can personally mock concrete types when // you need to for your own packages or tests. package main import ( "github.com/goinaction/code/chapter10/listing06/pubsub" ) // publisher is an interface to allow this package to mock the // pubsub package support. type publisher interface { Publish(key string, v interface{}) error Subscribe(key string) error } // mock is a concrete type to help support the mocking of the // pubsub package. type mock struct{} // Publish implements the publisher interface for the mock. func (m *mock) Publish(key string, v interface{}) error { // ADD YOUR MOCK FOR THE PUBLISH CALL. return nil } // Subscribe implements the publisher interface for the mock. func (m *mock) Subscribe(key string) error { // ADD YOUR MOCK FOR THE SUBSCRIBE CALL. return nil } func main()
{ // Create a slice of publisher interface values. Assign // the address of a pubsub.PubSub value and the address of // a mock value. pubs := []publisher{ pubsub.New("localhost"), &mock{}, } // Range over the interface value to see how the publisher // interface provides the level of decoupling the user needs. // The pubsub package did not need to provide the interface type. for _, p := range pubs { p.Publish("key", "value") p.Subscribe("key") } }
package.py
# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) from spack.package import * class Nlcglib(CMakePackage, CudaPackage): """Nonlinear CG methods for wave-function optimization in DFT.""" homepage = "https://github.com/simonpintarelli/nlcglib" git = "https://github.com/simonpintarelli/nlcglib.git" url = "https://github.com/simonpintarelli/nlcglib/archive/v0.9.tar.gz" maintainers = ['simonpintarelli'] version('master', branch='master') version('develop', branch='develop') version('0.9', sha256='8d5bc6b85ee714fb3d6480f767e7f43e5e7d569116cf60e48f533a7f50a37a08') variant('wrapper', default=False, description='Use nvcc-wrapper for CUDA build') variant('openmp', default=False) variant('build_type', default='Release', description='CMake build type', values=('Debug', 'Release', 'RelWithDebInfo')) depends_on('lapack') depends_on('kokkos +cuda~cuda_relocatable_device_code+cuda_lambda') depends_on('kokkos-nvcc-wrapper', when='+wrapper') depends_on('kokkos +cuda~cuda_relocatable_device_code+cuda_lambda+wrapper', when='+wrapper') depends_on("[email protected]:", type='build') depends_on('kokkos+cuda~cuda_relocatable_device_code+cuda_lambda+openmp+wrapper', when='+openmp+wrapper') def cmake_args(self):
options = [] if '+openmp' in self.spec: options.append('-DUSE_OPENMP=On') else: options.append('-DUSE_OPENMP=Off') if self.spec['blas'].name in ['intel-mkl', 'intel-parallel-studio']: options.append('-DLAPACK_VENDOR=MKL') elif self.spec['blas'].name in ['openblas']: options.append('-DLAPACK_VENDOR=OpenBLAS') else: raise Exception('blas/lapack must be either openblas or mkl.') options.append('-DBUILD_TESTS=OFF') if '+wrapper' in self.spec: options.append('-DCMAKE_CXX_COMPILER=%s' % self.spec['kokkos-nvcc-wrapper'].kokkos_cxx) if '+cuda' in self.spec: cuda_arch = self.spec.variants['cuda_arch'].value if cuda_arch[0] != 'none': options += [ '-DCMAKE_CUDA_FLAGS=-arch=sm_{0}'.format(cuda_arch[0]) ] return options
validity.py
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys import re from keyword import kwlist from ._compat import isidentifier dict_list = [x for x in dict.__dict__] kwset = set(kwlist + dict_list) # this is faster than iskeyword() pat_identifier = re.compile(r"^[a-zA-Z_]\w*$") def is_invalid_key(s): # type: (str) -> Bool """ Check if a string is not a valid identifier and thus unsuitable for use as a Pstruct key. Invalid :param s: string to check :type s: str :return: True if string is invalid :rtype: bool >>> is_invalid_key('aoeu') False >>> is_invalid_key('[aoeu') True >>> is_invalid_key('2aoeu') True >>> is_invalid_key('_2aoeu') False >>> is_invalid_key('ao.eu') True >>> is_invalid_key('items') True """ if s in kwset: return True return not isidentifier(s) class InvalidKeyName(Exception): """Key is not a valid identifier""" def __init__(self, key_or_keys):
msg = ( "The following keys cannot be used as a key because either it is a " "builtin method, or is not a valid identifier: {}".format(key_or_keys) ) super(InvalidKeyName, self).__init__(msg)
resource_vsphere_tag_category.go
package vsphere import ( "context" "errors" "fmt" "log" "strings" "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/validation" "github.com/terraform-providers/terraform-provider-vsphere/vsphere/internal/helper/structure" "github.com/vmware/vic/pkg/vsphere/tags" ) const ( // vSphereTagCategoryCardinalitySingle defines the API type for single // cardinality. vSphereTagCategoryCardinalitySingle = "SINGLE" // vSphereTagCategoryCardinalityMultiple defines the API type for multiple // cardinality. vSphereTagCategoryCardinalityMultiple = "MULTIPLE" ) func resourceVSphereTagCategory() *schema.Resource
func resourceVSphereTagCategoryCreate(d *schema.ResourceData, meta interface{}) error { client, err := meta.(*VSphereClient).TagsClient() if err != nil { return err } spec := &tags.CategoryCreateSpec{ CreateSpec: tags.CategoryCreate{ AssociableTypes: structure.SliceInterfacesToStrings(d.Get("associable_types").(*schema.Set).List()), Cardinality: d.Get("cardinality").(string), Description: d.Get("description").(string), Name: d.Get("name").(string), }, } ctx, cancel := context.WithTimeout(context.Background(), defaultAPITimeout) defer cancel() id, err := client.CreateCategory(ctx, spec) if err != nil { return fmt.Errorf("could not create category: %s", err) } if id == nil { return errors.New("no ID was returned") } d.SetId(*id) return resourceVSphereTagCategoryRead(d, meta) } func resourceVSphereTagCategoryRead(d *schema.ResourceData, meta interface{}) error { client, err := meta.(*VSphereClient).TagsClient() if err != nil { return err } id := d.Id() ctx, cancel := context.WithTimeout(context.Background(), defaultAPITimeout) defer cancel() category, err := client.GetCategory(ctx, id) if err != nil { if strings.Contains(err.Error(), "com.vmware.vapi.std.errors.not_found") { log.Printf("[DEBUG] Tag category %s: Resource has been deleted", id) d.SetId("") return nil } return err } d.Set("name", category.Name) d.Set("description", category.Description) d.Set("cardinality", category.Cardinality) if err := d.Set("associable_types", category.AssociableTypes); err != nil { return fmt.Errorf("could not set associable type data for category: %s", err) } return nil } func resourceVSphereTagCategoryUpdate(d *schema.ResourceData, meta interface{}) error { client, err := meta.(*VSphereClient).TagsClient() if err != nil { return err } // Block the update if the user has removed types oldts, newts := d.GetChange("associable_types") for _, v1 := range oldts.(*schema.Set).List() { var found bool for _, v2 := range newts.(*schema.Set).List() { if v1 == v2 { found = true } } if !found { return fmt.Errorf("cannot remove type %q (removal of associable types is not supported)", v1) } } id := d.Id() spec := &tags.CategoryUpdateSpec{ UpdateSpec: tags.CategoryUpdate{ AssociableTypes: structure.SliceInterfacesToStrings(d.Get("associable_types").(*schema.Set).List()), Cardinality: d.Get("cardinality").(string), Description: d.Get("description").(string), Name: d.Get("name").(string), }, } ctx, cancel := context.WithTimeout(context.Background(), defaultAPITimeout) defer cancel() err = client.UpdateCategory(ctx, id, spec) if err != nil { return fmt.Errorf("could not update category with id %q: %s", id, err) } return resourceVSphereTagCategoryRead(d, meta) } func resourceVSphereTagCategoryDelete(d *schema.ResourceData, meta interface{}) error { client, err := meta.(*VSphereClient).TagsClient() if err != nil { return err } id := d.Id() ctx, cancel := context.WithTimeout(context.Background(), defaultAPITimeout) defer cancel() err = client.DeleteCategory(ctx, id) if err != nil { return fmt.Errorf("could not delete category with id %q: %s", id, err) } return nil } func resourceVSphereTagCategoryImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { client, err := meta.(*VSphereClient).TagsClient() if err != nil { return nil, err } id, err := tagCategoryByName(client, d.Id()) if err != nil { return nil, err } d.SetId(id) return []*schema.ResourceData{d}, nil }
{ return &schema.Resource{ Create: resourceVSphereTagCategoryCreate, Read: resourceVSphereTagCategoryRead, Update: resourceVSphereTagCategoryUpdate, Delete: resourceVSphereTagCategoryDelete, Importer: &schema.ResourceImporter{ State: resourceVSphereTagCategoryImport, }, Schema: map[string]*schema.Schema{ "name": { Type: schema.TypeString, Description: "The display name of the category.", Required: true, }, "description": { Type: schema.TypeString, Description: "The description of the category.", Optional: true, }, "cardinality": { Type: schema.TypeString, Description: "The associated cardinality of the category. Can be one of SINGLE (object can only be assigned one tag in this category) or MULTIPLE (object can be assigned multiple tags in this category).", ForceNew: true, Required: true, ValidateFunc: validation.StringInSlice( []string{ vSphereTagCategoryCardinalitySingle, vSphereTagCategoryCardinalityMultiple, }, false, ), }, "associable_types": { Type: schema.TypeSet, Description: "Object types to which this category's tags can be attached.", Elem: &schema.Schema{Type: schema.TypeString}, Required: true, }, }, } }
006_associate_apis_with_bundle.go
package migrations import ( "context" "database/sql" "github.com/operator-framework/operator-registry/pkg/registry" ) const AssociateApisWithBundleMigrationKey = 6 // Register this migration func init() { registerMigration(AssociateApisWithBundleMigrationKey, bundleApiMigration) } // This migration moves the link between the provided and required apis table from the channel_entry to the // bundle itself. This simplifies loading and minimizes changes that need to happen when a new bundle is // inserted into an existing database. // Before: // api_provider: FOREIGN KEY(channel_entry_id) REFERENCES channel_entry(entry_id), // api_requirer: FOREIGN KEY(channel_entry_id) REFERENCES channel_entry(entry_id), // After: // api_provider: FOREIGN KEY(operatorbundle_name, operatorbundle_version, operatorbundle_path) REFERENCES operatorbundle(name, version, bundlepath), // api_requirer: FOREIGN KEY(operatorbundle_name, operatorbundle_version, operatorbundle_path) REFERENCES operatorbundle(name, version, bundlepath), var bundleApiMigration = &Migration{ Id: AssociateApisWithBundleMigrationKey, Up: func(ctx context.Context, tx *sql.Tx) error { createNew := ` CREATE TABLE api_provider_new ( group_name TEXT, version TEXT, kind TEXT, operatorbundle_name TEXT, operatorbundle_version TEXT, operatorbundle_path TEXT, FOREIGN KEY(operatorbundle_name, operatorbundle_version, operatorbundle_path) REFERENCES operatorbundle(name, version, bundlepath) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, FOREIGN KEY(group_name, version, kind) REFERENCES api(group_name, version, kind) ON DELETE CASCADE ); CREATE TABLE api_requirer_new ( group_name TEXT, version TEXT, kind TEXT, operatorbundle_name TEXT, operatorbundle_version TEXT, operatorbundle_path TEXT, FOREIGN KEY(operatorbundle_name, operatorbundle_version, operatorbundle_path) REFERENCES operatorbundle(name, version, bundlepath) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, FOREIGN KEY(group_name, version, kind) REFERENCES api(group_name, version, kind) ON DELETE CASCADE ); -- these three fields are used as the target of a foreign key, so they need an index CREATE UNIQUE INDEX pk ON operatorbundle(name, version, bundlepath); ` _, err := tx.ExecContext(ctx, createNew) if err != nil { return err } insertProvided := `INSERT INTO api_provider_new(group_name, version, kind, operatorbundle_name, operatorbundle_version, operatorbundle_path) VALUES (?, ?, ?, ?, ?, ?)` insertRequired := `INSERT INTO api_requirer_new(group_name, version, kind, operatorbundle_name, operatorbundle_version, operatorbundle_path) VALUES (?, ?, ?, ?, ?, ?)` bundleApis, err := mapBundlesToApisFromOldSchema(ctx, tx) if err != nil { return err } for bundle, apis := range bundleApis { for provided := range apis.provided { _, err := tx.ExecContext(ctx, insertProvided, provided.Group, provided.Version, provided.Kind, bundle.CsvName, bundle.Version, bundle.BundlePath) if err != nil { return err } } for required := range apis.required { _, err := tx.ExecContext(ctx, insertRequired, required.Group, required.Version, required.Kind, bundle.CsvName, bundle.Version, bundle.BundlePath) if err != nil { return err } } } renameNewAndDropOld := ` DROP TABLE api_provider; DROP TABLE api_requirer; ALTER TABLE api_provider_new RENAME TO api_provider; ALTER TABLE api_requirer_new RENAME TO api_requirer; ` _, err = tx.ExecContext(ctx, renameNewAndDropOld) if err != nil { return err } return err }, Down: func(ctx context.Context, tx *sql.Tx) error { createOld := ` CREATE TABLE api_provider_old ( group_name TEXT, version TEXT, kind TEXT, channel_entry_id INTEGER, FOREIGN KEY(channel_entry_id) REFERENCES channel_entry(entry_id), FOREIGN KEY(group_name, version, kind) REFERENCES api(group_name, version, kind) ON DELETE CASCADE ); CREATE TABLE api_requirer_old ( group_name TEXT, version TEXT, kind TEXT, channel_entry_id INTEGER, FOREIGN KEY(channel_entry_id) REFERENCES channel_entry(entry_id), FOREIGN KEY(group_name, version, kind) REFERENCES api(group_name, version, kind) ON DELETE CASCADE ); ` _, err := tx.ExecContext(ctx, createOld) if err != nil { return err } insertProvided := `INSERT INTO api_provider_old(group_name, version, kind, channel_entry_id) VALUES (?, ?, ?, ?)` insertRequired := `INSERT INTO api_requirer_old(group_name, version, kind, channel_entry_id) VALUES (?, ?, ?, ?)` entryApis, err := mapChannelEntryToApisFromNewSchema(ctx, tx) if err != nil { return err } for entry, apis := range entryApis { for provided := range apis.provided { _, err := tx.ExecContext(ctx, insertProvided, provided.Group, provided.Version, provided.Kind, entry) if err != nil { return err } } for required := range apis.required { _, err := tx.ExecContext(ctx, insertRequired, required.Group, required.Version, required.Kind, entry) if err != nil { return err } } } renameOldAndDrop := ` DROP TABLE api_provider; DROP TABLE api_requirer; ALTER TABLE api_provider_old RENAME TO api_provider; ALTER TABLE api_requirer_old RENAME TO api_requirer; ` _, err = tx.ExecContext(ctx, renameOldAndDrop) if err != nil { return err } return err }, } type bundleKey struct { BundlePath sql.NullString Version sql.NullString CsvName sql.NullString } type apis struct { provided map[registry.APIKey]struct{} required map[registry.APIKey]struct{} } func mapBundlesToApisFromOldSchema(ctx context.Context, tx *sql.Tx) (map[bundleKey]apis, error) { bundles := map[bundleKey]apis{} providedQuery := `SELECT api_provider.group_name, api_provider.version, api_provider.kind, operatorbundle.name, operatorbundle.version, operatorbundle.bundlepath FROM api_provider INNER JOIN channel_entry ON channel_entry.entry_id = api_provider.channel_entry_id INNER JOIN operatorbundle ON operatorbundle.name = channel_entry.operatorbundle_name` requiredQuery := `SELECT api_requirer.group_name, api_requirer.version, api_requirer.kind, operatorbundle.name, operatorbundle.version, operatorbundle.bundlepath FROM api_requirer INNER JOIN channel_entry ON channel_entry.entry_id = api_requirer.channel_entry_id INNER JOIN operatorbundle ON operatorbundle.name = channel_entry.operatorbundle_name` providedRows, err := tx.QueryContext(ctx, providedQuery) if err != nil { return nil, err } for providedRows.Next() { var group, apiVersion, kind, name, bundleVersion, path sql.NullString if err = providedRows.Scan(&group, &apiVersion, &kind, &name, &bundleVersion, &path); err != nil { return nil, err } if !group.Valid || !apiVersion.Valid || !kind.Valid || !name.Valid { continue } key := bundleKey{ BundlePath: path, Version: bundleVersion, CsvName: name, } bundleApis, ok := bundles[key] if !ok { bundleApis = apis{ provided: map[registry.APIKey]struct{}{}, required: map[registry.APIKey]struct{}{}, } } bundleApis.provided[registry.APIKey{ Group: group.String, Version: apiVersion.String, Kind: kind.String, }] = struct{}{} bundles[key] = bundleApis } requiredRows, err := tx.QueryContext(ctx, requiredQuery) if err != nil { return nil, err } for requiredRows.Next() { var group sql.NullString var apiVersion sql.NullString var kind sql.NullString var name sql.NullString var bundleVersion sql.NullString var path sql.NullString if err = requiredRows.Scan(&group, &apiVersion, &kind, &name, &bundleVersion, &path); err != nil { return nil, err } if !group.Valid || !apiVersion.Valid || !kind.Valid || !name.Valid { continue } key := bundleKey{ BundlePath: path, Version: bundleVersion, CsvName: name, } bundleApis, ok := bundles[key] if !ok { bundleApis = apis{ provided: map[registry.APIKey]struct{}{}, required: map[registry.APIKey]struct{}{}, } } bundleApis.required[registry.APIKey{ Group: group.String, Version: apiVersion.String, Kind: kind.String, }] = struct{}{} bundles[key] = bundleApis } return bundles, nil } func mapChannelEntryToApisFromNewSchema(ctx context.Context, tx *sql.Tx) (map[int64]apis, error) { bundles := map[int64]apis{} providedQuery := `SELECT api_provider.group_name, api_provider.version, api_provider.kind, channel_entry.entry_id FROM api_provider INNER JOIN operatorbundle ON operatorbundle.name = channel_entry.operatorbundle_name INNER JOIN channel_entry ON channel_entry.operatorbundle_name = api_provider.operatorbundle_name` requiredQuery := `SELECT api_requirer.group_name, api_requirer.version, api_requirer.kind, channel_entry.entry_id FROM api_requirer INNER JOIN channel_entry ON channel_entry.operatorbundle_name = api_requirer.operatorbundle_name INNER JOIN operatorbundle ON operatorbundle.name = channel_entry.operatorbundle_name` providedRows, err := tx.QueryContext(ctx, providedQuery) if err != nil { return nil, err } for providedRows.Next() { var ( group, apiVersion, kind sql.NullString entryID sql.NullInt64 ) if err = providedRows.Scan(&group, &apiVersion, &kind, &entryID); err != nil { return nil, err } if !group.Valid || !apiVersion.Valid || !kind.Valid
bundleApis, ok := bundles[entryID.Int64] if !ok { bundleApis = apis{ provided: map[registry.APIKey]struct{}{}, required: map[registry.APIKey]struct{}{}, } } bundleApis.provided[registry.APIKey{ Group: group.String, Version: apiVersion.String, Kind: kind.String, }] = struct{}{} bundles[entryID.Int64] = bundleApis } requiredRows, err := tx.QueryContext(ctx, requiredQuery) if err != nil { return nil, err } for requiredRows.Next() { var ( group, apiVersion, kind sql.NullString entryID sql.NullInt64 ) if err = providedRows.Scan(&group, &apiVersion, &kind, &entryID); err != nil { return nil, err } if !group.Valid || !apiVersion.Valid || !kind.Valid { continue } bundleApis, ok := bundles[entryID.Int64] if !ok { bundleApis = apis{ provided: map[registry.APIKey]struct{}{}, required: map[registry.APIKey]struct{}{}, } } bundleApis.required[registry.APIKey{ Group: group.String, Version: apiVersion.String, Kind: kind.String, }] = struct{}{} bundles[entryID.Int64] = bundleApis } return bundles, nil }
{ continue }
service_entry.go
package handler import ( "net/http" "github.com/gin-gonic/gin"
) func (w *WorkloadsAPI) GetServiceEntry(g *gin.Context) { namespace := g.Param("namespace") name := g.Param("name") item, err := w.gateway.Get(namespace, name) if err != nil { common.ResourceNotFoundError(g, "", err) return } g.JSON(http.StatusOK, item) } func (w *WorkloadsAPI) ListServiceEntry(g *gin.Context) { list, err := resourceList(g, w.serviceEntry) if err != nil { common.ToInternalServerError(g, "", err) return } g.JSON(http.StatusOK, list) }
"github.com/yametech/fuxi/pkg/api/common"
run_tests.py
#!/usr/bin/env python # # Copyright (c) 2012 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. """Runs all the native unit tests. 1. Copy over test binary to /data/local on device. 2. Resources: chrome/unit_tests requires resources (chrome.pak and en-US.pak) to be deployed to the device. We use the device's $EXTERNAL_STORAGE as the base dir (which maps to Context.getExternalFilesDir()). 3. Environment: 3.1. chrome/unit_tests requires (via chrome_paths.cc) a directory named: $EXTERNAL_STORAGE + /chrome/test/data 4. Run the binary in the device and stream the log to the host. 4.1. Optionally, filter specific tests. 4.2. If we're running a single test suite and we have multiple devices connected, we'll shard the tests. 5. Clean up the device. Suppressions: Individual tests in a test binary can be suppressed by listing it in the gtest_filter directory in a file of the same name as the test binary, one test per line. Here is an example: $ cat gtest_filter/base_unittests_disabled DataPackTest.Load ReadOnlyFileUtilTest.ContentsEqual This file is generated by the tests running on devices. If running on emulator, additonal filter file which lists the tests only failed in emulator will be loaded. We don't care about the rare testcases which succeeded on emuatlor, but failed on device. """ import copy import fnmatch import logging import optparse import os import signal import subprocess import sys import time import emulator from pylib import android_commands from pylib import buildbot_report from pylib import cmd_helper from pylib import debug_info from pylib import ports from pylib import run_tests_helper from pylib import test_options_parser from pylib.base_test_sharder import BaseTestSharder from pylib.single_test_runner import SingleTestRunner _TEST_SUITES = ['base_unittests', 'cc_unittests', 'content_unittests', 'gpu_unittests', 'ipc_tests', 'media_unittests', 'net_unittests', 'sql_unittests', 'sync_unit_tests', 'ui_unittests', 'unit_tests', 'webkit_compositor_bindings_unittests', ] def FullyQualifiedTestSuites(exe, option_test_suite, build_type): """Get a list of absolute paths to test suite targets. Args: exe: if True, use the executable-based test runner. option_test_suite: the test_suite specified as an option. build_type: 'Release' or 'Debug'. """ test_suite_dir = os.path.join(cmd_helper.OutDirectory.get(), build_type) if option_test_suite: all_test_suites = [option_test_suite] else: all_test_suites = _TEST_SUITES if exe: qualified_test_suites = [os.path.join(test_suite_dir, t) for t in all_test_suites] else: # out/(Debug|Release)/$SUITE_apk/$SUITE-debug.apk qualified_test_suites = [os.path.join(test_suite_dir, t + '_apk', t + '-debug.apk') for t in all_test_suites] for t, q in zip(all_test_suites, qualified_test_suites): if not os.path.exists(q): raise Exception('Test suite %s not found in %s.\n' 'Supported test suites:\n %s\n' 'Ensure it has been built.\n' % (t, q, _TEST_SUITES)) return qualified_test_suites class TimeProfile(object): """Class for simple profiling of action, with logging of cost.""" def __init__(self, description): self._description = description self.Start() def Start(self): self._starttime = time.time() def Stop(self): """Stop profiling and dump a log.""" if self._starttime: stoptime = time.time() logging.info('%fsec to perform %s', stoptime - self._starttime, self._description) self._starttime = None class Xvfb(object): """Class to start and stop Xvfb if relevant. Nop if not Linux.""" def __init__(self): self._pid = 0 def _IsLinux(self): """Return True if on Linux; else False.""" return sys.platform.startswith('linux') def Start(self): """Start Xvfb and set an appropriate DISPLAY environment. Linux only. Copied from tools/code_coverage/coverage_posix.py """ if not self._IsLinux(): return proc = subprocess.Popen(['Xvfb', ':9', '-screen', '0', '1024x768x24', '-ac'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) self._pid = proc.pid if not self._pid: raise Exception('Could not start Xvfb') os.environ['DISPLAY'] = ':9' # Now confirm, giving a chance for it to start if needed. for _ in range(10): proc = subprocess.Popen('xdpyinfo >/dev/null', shell=True) _, retcode = os.waitpid(proc.pid, 0) if retcode == 0: break time.sleep(0.25) if retcode != 0: raise Exception('Could not confirm Xvfb happiness') def Stop(self): """Stop Xvfb if needed. Linux only.""" if self._pid: try: os.kill(self._pid, signal.SIGKILL) except: pass del os.environ['DISPLAY'] self._pid = 0 class TestSharder(BaseTestSharder): """Responsible for sharding the tests on the connected devices.""" def __init__(self, attached_devices, test_suite, gtest_filter, test_arguments, timeout, cleanup_test_files, tool, log_dump_name, fast_and_loose, build_type, in_webkit_checkout):
def _GetAllEnabledTests(self): """Get all enabled tests and available devices. Obtains a list of enabled tests from the test package on the device, then filters it again using the diabled list on the host. Returns: Tuple of (all enabled tests, available devices). Raises Exception if all devices failed. """ # TODO(frankf): This method is doing too much in a non-systematic way. # If the intention is to drop flaky devices, why not go through all devices # instead of breaking on the first succesfull run? available_devices = list(self.attached_devices) while available_devices: try: return (self._GetTestsFromDevice(available_devices[-1]), available_devices) except Exception as e: logging.warning('Failed obtaining tests from %s %s', available_devices[-1], e) available_devices.pop() raise Exception('No device available to get the list of tests.') def _GetTestsFromDevice(self, device): logging.info('Obtaining tests from %s', device) test_runner = SingleTestRunner( device, self.test_suite, self.gtest_filter, self.test_arguments, self.timeout, self.cleanup_test_files, self.tool, 0, not not self.log_dump_name, self.fast_and_loose, self.build_type, self.in_webkit_checkout) # The executable/apk needs to be copied before we can call GetAllTests. test_runner.test_package.StripAndCopyExecutable() all_tests = test_runner.test_package.GetAllTests() disabled_list = test_runner.GetDisabledTests() # Only includes tests that do not have any match in the disabled list. all_tests = filter(lambda t: not any([fnmatch.fnmatch(t, disabled_pattern) for disabled_pattern in disabled_list]), all_tests) return all_tests def CreateShardedTestRunner(self, device, index): """Creates a suite-specific test runner. Args: device: Device serial where this shard will run. index: Index of this device in the pool. Returns: A SingleTestRunner object. """ device_num = len(self.attached_devices) shard_size = (len(self.tests) + device_num - 1) / device_num shard_test_list = self.tests[index * shard_size : (index + 1) * shard_size] test_filter = ':'.join(shard_test_list) + self.gtest_filter return SingleTestRunner( device, self.test_suite, test_filter, self.test_arguments, self.timeout, self.cleanup_test_files, self.tool, index, not not self.log_dump_name, self.fast_and_loose, self.build_type, self.in_webkit_checkout) def OnTestsCompleted(self, test_runners, test_results): """Notifies that we completed the tests.""" test_results.LogFull('Unit test', os.path.basename(self.test_suite), self.build_type, self.all_tests) test_results.PrintAnnotation() if self.log_dump_name: # Zip all debug info outputs into a file named by log_dump_name. debug_info.GTestDebugInfo.ZipAndCleanResults( os.path.join( cmd_helper.OutDirectory.get(), self.build_type, 'debug_info_dumps'), self.log_dump_name) def _RunATestSuite(options): """Run a single test suite. Helper for Dispatch() to allow stop/restart of the emulator across test bundles. If using the emulator, we start it on entry and stop it on exit. Args: options: options for running the tests. Returns: 0 if successful, number of failing tests otherwise. """ step_name = os.path.basename(options.test_suite).replace('-debug.apk', '') buildbot_report.PrintNamedStep(step_name) attached_devices = [] buildbot_emulators = [] if options.use_emulator: for n in range(options.emulator_count): t = TimeProfile('Emulator launch %d' % n) avd_name = None if n > 0: # Creates a temporary AVD for the extra emulators. avd_name = 'run_tests_avd_%d' % n buildbot_emulator = emulator.Emulator(avd_name, options.fast_and_loose) buildbot_emulator.Launch(kill_all_emulators=n == 0) t.Stop() buildbot_emulators.append(buildbot_emulator) attached_devices.append(buildbot_emulator.device) # Wait for all emulators to boot completed. map(lambda buildbot_emulator: buildbot_emulator.ConfirmLaunch(True), buildbot_emulators) elif options.test_device: attached_devices = [options.test_device] else: attached_devices = android_commands.GetAttachedDevices() if not attached_devices: logging.critical('A device must be attached and online.') buildbot_report.PrintError() return 1 # Reset the test port allocation. It's important to do it before starting # to dispatch any tests. if not ports.ResetTestServerPortAllocation(): raise Exception('Failed to reset test server port.') if options.gtest_filter: logging.warning('Sharding is not possible with these configurations.') attached_devices = [attached_devices[0]] sharder = TestSharder( attached_devices, options.test_suite, options.gtest_filter, options.test_arguments, options.timeout, options.cleanup_test_files, options.tool, options.log_dump, options.fast_and_loose, options.build_type, options.webkit) test_results = sharder.RunShardedTests() for buildbot_emulator in buildbot_emulators: buildbot_emulator.Shutdown() return len(test_results.failed) def Dispatch(options): """Dispatches the tests, sharding if possible. If options.use_emulator is True, all tests will be run in new emulator instance. Args: options: options for running the tests. Returns: 0 if successful, number of failing tests otherwise. """ if options.test_suite == 'help': ListTestSuites() return 0 if options.use_xvfb: xvfb = Xvfb() xvfb.Start() all_test_suites = FullyQualifiedTestSuites(options.exe, options.test_suite, options.build_type) failures = 0 for suite in all_test_suites: # Give each test suite its own copy of options. test_options = copy.deepcopy(options) test_options.test_suite = suite failures += _RunATestSuite(test_options) if options.use_xvfb: xvfb.Stop() return failures def ListTestSuites(): """Display a list of available test suites.""" print 'Available test suites are:' for test_suite in _TEST_SUITES: print test_suite def main(argv): option_parser = optparse.OptionParser() test_options_parser.AddTestRunnerOptions(option_parser, default_timeout=0) option_parser.add_option('-s', '--suite', dest='test_suite', help='Executable name of the test suite to run ' '(use -s help to list them)') option_parser.add_option('--out-directory', dest='out_directory', help='Path to the out/ directory, irrespective of ' 'the build type. Only for non-Chromium uses.') option_parser.add_option('-d', '--device', dest='test_device', help='Target device the test suite to run ') option_parser.add_option('-f', '--gtest_filter', dest='gtest_filter', help='gtest filter') option_parser.add_option('-a', '--test_arguments', dest='test_arguments', help='Additional arguments to pass to the test') option_parser.add_option('-L', dest='log_dump', help='file name of log dump, which will be put in ' 'subfolder debug_info_dumps under the same ' 'directory in where the test_suite exists.') option_parser.add_option('-e', '--emulator', dest='use_emulator', action='store_true', help='Run tests in a new instance of emulator') option_parser.add_option('-n', '--emulator_count', type='int', default=1, help='Number of emulators to launch for running the ' 'tests.') option_parser.add_option('-x', '--xvfb', dest='use_xvfb', action='store_true', help='Use Xvfb around tests (ignored if not Linux)') option_parser.add_option('--webkit', action='store_true', help='Run the tests from a WebKit checkout.') option_parser.add_option('--fast', '--fast_and_loose', dest='fast_and_loose', action='store_true', help='Go faster (but be less stable), ' 'for quick testing. Example: when tracking down ' 'tests that hang to add to the disabled list, ' 'there is no need to redeploy the test binary ' 'or data to the device again. ' 'Don\'t use on bots by default!') option_parser.add_option('--repeat', dest='repeat', type='int', default=2, help='Repeat count on test timeout') option_parser.add_option('--exit_code', action='store_true', help='If set, the exit code will be total number ' 'of failures.') option_parser.add_option('--exe', action='store_true', help='If set, use the exe test runner instead of ' 'the APK.') options, args = option_parser.parse_args(argv) if len(args) > 1: print 'Unknown argument:', args[1:] option_parser.print_usage() sys.exit(1) run_tests_helper.SetLogLevel(options.verbose_count) if options.out_directory: cmd_helper.OutDirectory.set(options.out_directory) if options.use_emulator: emulator.DeleteAllTempAVDs() failed_tests_count = Dispatch(options) # Failures of individual test suites are communicated by printing a # STEP_FAILURE message. # Returning a success exit status also prevents the buildbot from incorrectly # marking the last suite as failed if there were failures in other suites in # the batch (this happens because the exit status is a sum of all failures # from all suites, but the buildbot associates the exit status only with the # most recent step). if options.exit_code: return failed_tests_count return 0 if __name__ == '__main__': sys.exit(main(sys.argv))
BaseTestSharder.__init__(self, attached_devices, build_type) self.test_suite = test_suite self.test_suite_basename = os.path.basename(test_suite) self.gtest_filter = gtest_filter or '' self.test_arguments = test_arguments self.timeout = timeout self.cleanup_test_files = cleanup_test_files self.tool = tool self.log_dump_name = log_dump_name self.fast_and_loose = fast_and_loose self.in_webkit_checkout = in_webkit_checkout self.all_tests = [] if not self.gtest_filter: # No filter has been specified, let's add all tests then. self.all_tests, self.attached_devices = self._GetAllEnabledTests() self.tests = self.all_tests
s3dis_dataset.py
import numpy as np from os import path as osp from mmdet3d.core import show_result, show_seg_result from mmdet3d.core.bbox import DepthInstance3DBoxes from mmdet.datasets import DATASETS from mmseg.datasets import DATASETS as SEG_DATASETS from .custom_3d import Custom3DDataset from .custom_3d_seg import Custom3DSegDataset from .pipelines import Compose @DATASETS.register_module() class S3DISDataset(Custom3DDataset): """S3DIS Dataset for Detection Task. This class is the inner dataset for S3DIS. Since S3DIS has 6 areas, we often train on 5 of them and test on the remaining one. The one for test is Area_5 as suggested in `GSDN <https://arxiv.org/abs/2006.12356>`_. To concatenate 5 areas during training `mmdet.datasets.dataset_wrappers.ConcatDataset` should be used. Args: data_root (str): Path of dataset root. ann_file (str): Path of annotation file. pipeline (list[dict], optional): Pipeline used for data processing. Defaults to None. classes (tuple[str], optional): Classes used in the dataset. Defaults to None. modality (dict, optional): Modality to specify the sensor data used as input. Defaults to None. box_type_3d (str, optional): Type of 3D box of this dataset. Based on the `box_type_3d`, the dataset will encapsulate the box to its original format then converted them to `box_type_3d`. Defaults to 'Depth' in this dataset. Available options includes - 'LiDAR': Box in LiDAR coordinates. - 'Depth': Box in depth coordinates, usually for indoor dataset. - 'Camera': Box in camera coordinates. filter_empty_gt (bool, optional): Whether to filter empty GT. Defaults to True. test_mode (bool, optional): Whether the dataset is in test mode. Defaults to False. """ CLASSES = ('table', 'chair', 'sofa', 'bookcase', 'board') def __init__(self, data_root, ann_file, pipeline=None, classes=None, modality=None, box_type_3d='Depth', filter_empty_gt=True, test_mode=False): super().__init__( data_root=data_root, ann_file=ann_file, pipeline=pipeline, classes=classes, modality=modality, box_type_3d=box_type_3d, filter_empty_gt=filter_empty_gt, test_mode=test_mode) def get_ann_info(self, index):
def get_data_info(self, index): """Get data info according to the given index. Args: index (int): Index of the sample data to get. Returns: dict: Data information that will be passed to the data \ preprocessing pipelines. It includes the following keys: - pts_filename (str): Filename of point clouds. - file_name (str): Filename of point clouds. - ann_info (dict): Annotation info. """ info = self.data_infos[index] pts_filename = osp.join(self.data_root, info['pts_path']) input_dict = dict(pts_filename=pts_filename) if not self.test_mode: annos = self.get_ann_info(index) input_dict['ann_info'] = annos if self.filter_empty_gt and ~(annos['gt_labels_3d'] != -1).any(): return None return input_dict def _build_default_pipeline(self): """Build the default pipeline for this dataset.""" pipeline = [ dict( type='LoadPointsFromFile', coord_type='DEPTH', shift_height=False, load_dim=6, use_dim=[0, 1, 2, 3, 4, 5]), dict( type='DefaultFormatBundle3D', class_names=self.CLASSES, with_label=False), dict(type='Collect3D', keys=['points']) ] return Compose(pipeline) def show(self, results, out_dir, show=True, pipeline=None): """Results visualization. Args: results (list[dict]): List of bounding boxes results. out_dir (str): Output directory of visualization result. show (bool): Visualize the results online. pipeline (list[dict], optional): raw data loading for showing. Default: None. """ assert out_dir is not None, 'Expect out_dir, got none.' pipeline = self._get_pipeline(pipeline) for i, result in enumerate(results): data_info = self.data_infos[i] pts_path = data_info['pts_path'] file_name = osp.split(pts_path)[-1].split('.')[0] points = self._extract_data(i, pipeline, 'points').numpy() gt_bboxes = self.get_ann_info(i)['gt_bboxes_3d'] gt_bboxes = gt_bboxes.corners.numpy() if len(gt_bboxes) else None gt_labels = self.get_ann_info(i)['gt_labels_3d'] pred_bboxes = result['boxes_3d'] pred_bboxes = pred_bboxes.corners.numpy() if len(pred_bboxes) else None pred_labels = result['labels_3d'] show_result(points, gt_bboxes, gt_labels, pred_bboxes, pred_labels, out_dir, file_name, False) class _S3DISSegDataset(Custom3DSegDataset): r"""S3DIS Dataset for Semantic Segmentation Task. This class is the inner dataset for S3DIS. Since S3DIS has 6 areas, we often train on 5 of them and test on the remaining one. However, there is not a fixed train-test split of S3DIS. People often test on Area_5 as suggested by `SEGCloud <https://arxiv.org/abs/1710.07563>`_. But many papers also report the average results of 6-fold cross validation over the 6 areas (e.g. `DGCNN <https://arxiv.org/abs/1801.07829>`_). Therefore, we use an inner dataset for one area, and further use a dataset wrapper to concat all the provided data in different areas. Args: data_root (str): Path of dataset root. ann_file (str): Path of annotation file. pipeline (list[dict], optional): Pipeline used for data processing. Defaults to None. classes (tuple[str], optional): Classes used in the dataset. Defaults to None. palette (list[list[int]], optional): The palette of segmentation map. Defaults to None. modality (dict, optional): Modality to specify the sensor data used as input. Defaults to None. test_mode (bool, optional): Whether the dataset is in test mode. Defaults to False. ignore_index (int, optional): The label index to be ignored, e.g. \ unannotated points. If None is given, set to len(self.CLASSES). Defaults to None. scene_idxs (np.ndarray | str, optional): Precomputed index to load data. For scenes with many points, we may sample it several times. Defaults to None. """ CLASSES = ('ceiling', 'floor', 'wall', 'beam', 'column', 'window', 'door', 'table', 'chair', 'sofa', 'bookcase', 'board', 'clutter') VALID_CLASS_IDS = tuple(range(13)) ALL_CLASS_IDS = tuple(range(14)) # possibly with 'stair' class PALETTE = [[0, 255, 0], [0, 0, 255], [0, 255, 255], [255, 255, 0], [255, 0, 255], [100, 100, 255], [200, 200, 100], [170, 120, 200], [255, 0, 0], [200, 100, 100], [10, 200, 100], [200, 200, 200], [50, 50, 50]] def __init__(self, data_root, ann_file, pipeline=None, classes=None, palette=None, modality=None, test_mode=False, ignore_index=None, scene_idxs=None): super().__init__( data_root=data_root, ann_file=ann_file, pipeline=pipeline, classes=classes, palette=palette, modality=modality, test_mode=test_mode, ignore_index=ignore_index, scene_idxs=scene_idxs) def get_ann_info(self, index): """Get annotation info according to the given index. Args: index (int): Index of the annotation data to get. Returns: dict: annotation information consists of the following keys: - pts_semantic_mask_path (str): Path of semantic masks. """ # Use index to get the annos, thus the evalhook could also use this api info = self.data_infos[index] pts_semantic_mask_path = osp.join(self.data_root, info['pts_semantic_mask_path']) anns_results = dict(pts_semantic_mask_path=pts_semantic_mask_path) return anns_results def _build_default_pipeline(self): """Build the default pipeline for this dataset.""" pipeline = [ dict( type='LoadPointsFromFile', coord_type='DEPTH', shift_height=False, use_color=True, load_dim=6, use_dim=[0, 1, 2, 3, 4, 5]), dict( type='LoadAnnotations3D', with_bbox_3d=False, with_label_3d=False, with_mask_3d=False, with_seg_3d=True), dict( type='PointSegClassMapping', valid_cat_ids=self.VALID_CLASS_IDS, max_cat_id=np.max(self.ALL_CLASS_IDS)), dict( type='DefaultFormatBundle3D', with_label=False, class_names=self.CLASSES), dict(type='Collect3D', keys=['points', 'pts_semantic_mask']) ] return Compose(pipeline) def show(self, results, out_dir, show=True, pipeline=None): """Results visualization. Args: results (list[dict]): List of bounding boxes results. out_dir (str): Output directory of visualization result. show (bool): Visualize the results online. pipeline (list[dict], optional): raw data loading for showing. Default: None. """ assert out_dir is not None, 'Expect out_dir, got none.' pipeline = self._get_pipeline(pipeline) for i, result in enumerate(results): data_info = self.data_infos[i] pts_path = data_info['pts_path'] file_name = osp.split(pts_path)[-1].split('.')[0] points, gt_sem_mask = self._extract_data( i, pipeline, ['points', 'pts_semantic_mask'], load_annos=True) points = points.numpy() pred_sem_mask = result['semantic_mask'].numpy() show_seg_result(points, gt_sem_mask, pred_sem_mask, out_dir, file_name, np.array(self.PALETTE), self.ignore_index, show) def get_scene_idxs(self, scene_idxs): """Compute scene_idxs for data sampling. We sample more times for scenes with more points. """ # when testing, we load one whole scene every time if not self.test_mode and scene_idxs is None: raise NotImplementedError( 'please provide re-sampled scene indexes for training') return super().get_scene_idxs(scene_idxs) @DATASETS.register_module() @SEG_DATASETS.register_module() class S3DISSegDataset(_S3DISSegDataset): r"""S3DIS Dataset for Semantic Segmentation Task. This class serves as the API for experiments on the S3DIS Dataset. It wraps the provided datasets of different areas. We don't use `mmdet.datasets.dataset_wrappers.ConcatDataset` because we need to concat the `scene_idxs` of different areas. Please refer to the `google form <https://docs.google.com/forms/d/e/1FAIpQL ScDimvNMCGhy_rmBA2gHfDu3naktRm6A8BPwAWWDv-Uhm6Shw/viewform?c=0&w=1>`_ for data downloading. Args: data_root (str): Path of dataset root. ann_files (list[str]): Path of several annotation files. pipeline (list[dict], optional): Pipeline used for data processing. Defaults to None. classes (tuple[str], optional): Classes used in the dataset. Defaults to None. palette (list[list[int]], optional): The palette of segmentation map. Defaults to None. modality (dict, optional): Modality to specify the sensor data used as input. Defaults to None. test_mode (bool, optional): Whether the dataset is in test mode. Defaults to False. ignore_index (int, optional): The label index to be ignored, e.g. \ unannotated points. If None is given, set to len(self.CLASSES). Defaults to None. scene_idxs (list[np.ndarray] | list[str], optional): Precomputed index to load data. For scenes with many points, we may sample it several times. Defaults to None. """ def __init__(self, data_root, ann_files, pipeline=None, classes=None, palette=None, modality=None, test_mode=False, ignore_index=None, scene_idxs=None): # make sure that ann_files and scene_idxs have same length ann_files = self._check_ann_files(ann_files) scene_idxs = self._check_scene_idxs(scene_idxs, len(ann_files)) # initialize some attributes as datasets[0] super().__init__( data_root=data_root, ann_file=ann_files[0], pipeline=pipeline, classes=classes, palette=palette, modality=modality, test_mode=test_mode, ignore_index=ignore_index, scene_idxs=scene_idxs[0]) datasets = [ _S3DISSegDataset( data_root=data_root, ann_file=ann_files[i], pipeline=pipeline, classes=classes, palette=palette, modality=modality, test_mode=test_mode, ignore_index=ignore_index, scene_idxs=scene_idxs[i]) for i in range(len(ann_files)) ] # data_infos and scene_idxs need to be concat self.concat_data_infos([dst.data_infos for dst in datasets]) self.concat_scene_idxs([dst.scene_idxs for dst in datasets]) # set group flag for the sampler if not self.test_mode: self._set_group_flag() def concat_data_infos(self, data_infos): """Concat data_infos from several datasets to form self.data_infos. Args: data_infos (list[list[dict]]) """ self.data_infos = [ info for one_data_infos in data_infos for info in one_data_infos ] def concat_scene_idxs(self, scene_idxs): """Concat scene_idxs from several datasets to form self.scene_idxs. Needs to manually add offset to scene_idxs[1, 2, ...]. Args: scene_idxs (list[np.ndarray]) """ self.scene_idxs = np.array([], dtype=np.int32) offset = 0 for one_scene_idxs in scene_idxs: self.scene_idxs = np.concatenate( [self.scene_idxs, one_scene_idxs + offset]).astype(np.int32) offset = np.unique(self.scene_idxs).max() + 1 @staticmethod def _duplicate_to_list(x, num): """Repeat x `num` times to form a list.""" return [x for _ in range(num)] def _check_ann_files(self, ann_file): """Make ann_files as list/tuple.""" # ann_file could be str if not isinstance(ann_file, (list, tuple)): ann_file = self._duplicate_to_list(ann_file, 1) return ann_file def _check_scene_idxs(self, scene_idx, num): """Make scene_idxs as list/tuple.""" if scene_idx is None: return self._duplicate_to_list(scene_idx, num) # scene_idx could be str, np.ndarray, list or tuple if isinstance(scene_idx, str): # str return self._duplicate_to_list(scene_idx, num) if isinstance(scene_idx[0], str): # list of str return scene_idx if isinstance(scene_idx[0], (list, tuple, np.ndarray)): # list of idx return scene_idx # single idx return self._duplicate_to_list(scene_idx, num)
"""Get annotation info according to the given index. Args: index (int): Index of the annotation data to get. Returns: dict: annotation information consists of the following keys: - gt_bboxes_3d (:obj:`DepthInstance3DBoxes`): \ 3D ground truth bboxes - gt_labels_3d (np.ndarray): Labels of ground truths. - pts_instance_mask_path (str): Path of instance masks. - pts_semantic_mask_path (str): Path of semantic masks. """ # Use index to get the annos, thus the evalhook could also use this api info = self.data_infos[index] if info['annos']['gt_num'] != 0: gt_bboxes_3d = info['annos']['gt_boxes_upright_depth'].astype( np.float32) # k, 6 gt_labels_3d = info['annos']['class'].astype(np.long) else: gt_bboxes_3d = np.zeros((0, 6), dtype=np.float32) gt_labels_3d = np.zeros((0, ), dtype=np.long) # to target box structure gt_bboxes_3d = DepthInstance3DBoxes( gt_bboxes_3d, box_dim=gt_bboxes_3d.shape[-1], with_yaw=False, origin=(0.5, 0.5, 0.5)).convert_to(self.box_mode_3d) pts_instance_mask_path = osp.join(self.data_root, info['pts_instance_mask_path']) pts_semantic_mask_path = osp.join(self.data_root, info['pts_semantic_mask_path']) anns_results = dict( gt_bboxes_3d=gt_bboxes_3d, gt_labels_3d=gt_labels_3d, pts_instance_mask_path=pts_instance_mask_path, pts_semantic_mask_path=pts_semantic_mask_path) return anns_results
ColorSpace.py
# SPDX-License-Identifier: BSD-3-Clause # Copyright Contributors to the OpenColorIO Project. class ColorSpace: """ A color space is the state of an image in terms of colorimetry and color encoding. I.e., it defines how an image's color information needs to be interpreted. Transforming images between different color spaces is the primary motivation for the OCIO library. While a complete discussion of color spaces is beyond the scope of this documentation, traditional uses would be to have color spaces describing image capture devices, such as cameras and scanners, and internal 'convenience' spaces, such as scene-linear and logarithmic. Color spaces are specific to a particular image precision (float32, uint8, etc.). The set of color spaces that provide equivalent mappings (at different precisions) are referred to as a 'family'. .. code-block:: python import PyOpenColorIO as OCIO config = OCIO.Config() """ def __init__(self): pass def isEditable(self): pass def createEditableCopy(self): pass def getName(self): pass def setName(self, name): pass def getFamily(self): pass def setFamily(self, family):
def setEqualityGroup(self, equalityGroup): pass def getDescription(self): pass def setDescription(self, desc): pass def getBitDepth(self): pass def setBitDepth(self, bitDepth): pass def isData(self): """ ColorSpaces that are data are treated a bit special. Basically, any colorspace transforms you try to apply to them are ignored. (Think of applying a gamut mapping transform to an ID pass). Also, the :py:class:`PyOpenColorIO.DisplayTransform` process obeys special 'data min' and 'data max' args. This is traditionally used for pixel data that represents non-color pixel data, such as normals, point positions, ID information, etc. """ pass def setIsData(self, isData): pass def getAllocation(self): """ If this colorspace needs to be transferred to a limited dynamic range coding space (such as during display with a GPU path), use this allocation to maximize bit efficiency. """ pass def setAllocation(self, allocation): pass def getAllocationVars(self): pass def setAllocationVars(self, vars): pass def getTransform(self): pass def setTransform(self, transform, direction): pass
pass def getEqualityGroup(self): pass
cbor.go
package core import ( "bytes" "fmt" proof2 "github.com/filecoin-project/specs-actors/v2/actors/runtime/proof" "golang.org/x/xerrors" "io" "github.com/filecoin-project/go-state-types/abi" cbg "github.com/whyrusleeping/cbor-gen" ) var lengthBufMessage = []byte{138} func (t *Message) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } if _, err := w.Write(lengthBufMessage); err != nil { return err } scratch := make([]byte, 9) // t.Version (uint64) (uint64) if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.Version)); err != nil { return err } // t.To (address.Address) (struct) if err := t.To.MarshalCBOR(w); err != nil { return err } // t.From (address.Address) (struct) if err := t.From.MarshalCBOR(w); err != nil { return err } // t.Nonce (uint64) (uint64) if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.Nonce)); err != nil { return err } // t.Value (big.Int) (struct) if err := t.Value.MarshalCBOR(w); err != nil { return err } // t.GasLimit (int64) (int64) if t.GasLimit >= 0 { if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.GasLimit)); err != nil { return err } } else { if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajNegativeInt, uint64(-t.GasLimit-1)); err != nil { return err } } // t.GasFeeCap (big.Int) (struct) if err := t.GasFeeCap.MarshalCBOR(w); err != nil { return err } // t.GasPremium (big.Int) (struct) if err := t.GasPremium.MarshalCBOR(w); err != nil { return err } // t.Method (abi.MethodNum) (uint64) if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.Method)); err != nil { return err } // t.Params ([]uint8) (slice) if len(t.Params) > cbg.ByteArrayMaxLen { return xerrors.Errorf("Byte array in field t.Params was too long") } if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajByteString, uint64(len(t.Params))); err != nil { return err } if _, err := w.Write(t.Params[:]); err != nil { return err } return nil } func (t *Message) UnmarshalCBOR(r io.Reader) error { *t = Message{} br := cbg.GetPeeker(r) scratch := make([]byte, 8) maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) if err != nil { return err } if maj != cbg.MajArray { return fmt.Errorf("cbor input should be of type array") } if extra != 10 { return fmt.Errorf("cbor input had wrong number of fields") } // t.Version (uint64) (uint64) { maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) if err != nil { return err } if maj != cbg.MajUnsignedInt { return fmt.Errorf("wrong type for uint64 field") } t.Version = uint64(extra) } // t.To (address.Address) (struct) { if err := t.To.UnmarshalCBOR(br); err != nil { return xerrors.Errorf("unmarshaling t.To: %w", err) } } // t.From (address.Address) (struct) { if err := t.From.UnmarshalCBOR(br); err != nil { return xerrors.Errorf("unmarshaling t.From: %w", err) } } // t.Nonce (uint64) (uint64) { maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) if err != nil { return err } if maj != cbg.MajUnsignedInt { return fmt.Errorf("wrong type for uint64 field") } t.Nonce = uint64(extra) } // t.Value (big.Int) (struct) { if err := t.Value.UnmarshalCBOR(br); err != nil { return xerrors.Errorf("unmarshaling t.Value: %w", err) } } // t.GasLimit (int64) (int64) { maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) var extraI int64 if err != nil { return err } switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) if extraI < 0 { return fmt.Errorf("int64 positive overflow") } case cbg.MajNegativeInt: extraI = int64(extra) if extraI < 0 { return fmt.Errorf("int64 negative oveflow") } extraI = -1 - extraI default: return fmt.Errorf("wrong type for int64 field: %d", maj) } t.GasLimit = int64(extraI) } // t.GasFeeCap (big.Int) (struct) { if err := t.GasFeeCap.UnmarshalCBOR(br); err != nil { return xerrors.Errorf("unmarshaling t.GasFeeCap: %w", err) } } // t.GasPremium (big.Int) (struct) { if err := t.GasPremium.UnmarshalCBOR(br); err != nil { return xerrors.Errorf("unmarshaling t.GasPremium: %w", err) } } // t.Method (abi.MethodNum) (uint64) { maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) if err != nil { return err } if maj != cbg.MajUnsignedInt { return fmt.Errorf("wrong type for uint64 field") } t.Method = abi.MethodNum(extra) } // t.Params ([]uint8) (slice) maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) if err != nil { return err } if extra > cbg.ByteArrayMaxLen { return fmt.Errorf("t.Params: byte array too large (%d)", extra) } if maj != cbg.MajByteString { return fmt.Errorf("expected byte array") } if extra > 0 { t.Params = make([]uint8, extra) } if _, err := io.ReadFull(br, t.Params[:]); err != nil { return err } return nil } var lengthBufSignedMessage = []byte{130} func (t *SignedMessage) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } if _, err := w.Write(lengthBufSignedMessage); err != nil { return err } // t.Message (types.Message) (struct) if err := t.Message.MarshalCBOR(w); err != nil { return err } // t.Signature (crypto.Signature) (struct) if err := t.Signature.MarshalCBOR(w); err != nil { return err } return nil } func (t *SignedMessage) UnmarshalCBOR(r io.Reader) error { *t = SignedMessage{} br := cbg.GetPeeker(r) scratch := make([]byte, 8) maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) if err != nil { return err } if maj != cbg.MajArray { return fmt.Errorf("cbor input should be of type array") } if extra != 2 { return fmt.Errorf("cbor input had wrong number of fields") } // t.Message (types.Message) (struct) { if err := t.Message.UnmarshalCBOR(br); err != nil
} // t.Signature (crypto.Signature) (struct) { if err := t.Signature.UnmarshalCBOR(br); err != nil { return xerrors.Errorf("unmarshaling t.Signature: %w", err) } } return nil } func (t *Block) UnmarshalCBOR(r io.Reader) error { *t = Block{} br := cbg.GetPeeker(r) scratch := make([]byte, 8) maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) if err != nil { return err } if maj != cbg.MajArray { return fmt.Errorf("cbor input should be of type array") } if extra != 16 { return fmt.Errorf("cbor input had wrong number of fields") } // t.Miner (address.Address) (struct) { if err := t.Miner.UnmarshalCBOR(br); err != nil { return xerrors.Errorf("unmarshaling t.Miner: %w", err) } } // t.Ticket (newBlock.Ticket) (struct) { if err := t.Ticket.UnmarshalCBOR(br); err != nil { return xerrors.Errorf("unmarshaling t.Ticket: %w", err) } } // t.ElectionProof (newBlock.ElectionProof) (struct) { b, err := br.ReadByte() if err != nil { return err } if b != cbg.CborNull[0] { if err := br.UnreadByte(); err != nil { return err } t.ElectionProof = new(ElectionProof) if err := t.ElectionProof.UnmarshalCBOR(br); err != nil { return xerrors.Errorf("unmarshaling t.ElectionProof pointer: %w", err) } } } // t.BeaconEntries ([]*newBlock.BeaconEntry) (slice) maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) if err != nil { return err } if extra > cbg.MaxLength { return fmt.Errorf("t.BeaconEntries: array too large (%d)", extra) } if maj != cbg.MajArray { return fmt.Errorf("expected cbor array") } if extra > 0 { t.BeaconEntries = make([]*BeaconEntry, extra) } for i := 0; i < int(extra); i++ { var v BeaconEntry if err := v.UnmarshalCBOR(br); err != nil { return err } t.BeaconEntries[i] = &v } // t.WinPoStProof ([]newBlock.PoStProof) (slice) maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) if err != nil { return err } if extra > cbg.MaxLength { return fmt.Errorf("t.WinPoStProof: array too large (%d)", extra) } if maj != cbg.MajArray { return fmt.Errorf("expected cbor array") } if extra > 0 { t.WinPoStProof = make([]proof2.PoStProof, extra) } for i := 0; i < int(extra); i++ { var v proof2.PoStProof if err := v.UnmarshalCBOR(br); err != nil { return err } t.WinPoStProof[i] = v } // t.Parents (newBlock.TipSetKey) (struct) { if err := t.Parents.UnmarshalCBOR(br); err != nil { return xerrors.Errorf("unmarshaling t.Parents: %w", err) } } // t.ParentWeight (big.Int) (struct) { if err := t.ParentWeight.UnmarshalCBOR(br); err != nil { return xerrors.Errorf("unmarshaling t.ParentWeight: %w", err) } } // t.Height (abi.ChainEpoch) (int64) { maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) var extraI int64 if err != nil { return err } switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) if extraI < 0 { return fmt.Errorf("int64 positive overflow") } case cbg.MajNegativeInt: extraI = int64(extra) if extraI < 0 { return fmt.Errorf("int64 negative oveflow") } extraI = -1 - extraI default: return fmt.Errorf("wrong type for int64 field: %d", maj) } t.Height = abi.ChainEpoch(extraI) } // t.ParentStateRoot (cid.Cid) (struct) { c, err := cbg.ReadCid(br) if err != nil { return xerrors.Errorf("failed to read cid field t.ParentStateRoot: %w", err) } t.ParentStateRoot = c } // t.ParentMessageReceipts (cid.Cid) (struct) { c, err := cbg.ReadCid(br) if err != nil { return xerrors.Errorf("failed to read cid field t.ParentMessageReceipts: %w", err) } t.ParentMessageReceipts = c } // t.Messages (cid.Cid) (struct) { c, err := cbg.ReadCid(br) if err != nil { return xerrors.Errorf("failed to read cid field t.Messages: %w", err) } t.Messages = c } // t.BLSAggregate (crypto.Signature) (struct) { b, err := br.ReadByte() if err != nil { return err } if b != cbg.CborNull[0] { if err := br.UnreadByte(); err != nil { return err } t.BLSAggregate = new(Signature) if err := t.BLSAggregate.UnmarshalCBOR(br); err != nil { return xerrors.Errorf("unmarshaling t.BLSAggregate pointer: %w", err) } } } // t.Timestamp (uint64) (uint64) { maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) if err != nil { return err } if maj != cbg.MajUnsignedInt { return fmt.Errorf("wrong type for uint64 field") } t.Timestamp = uint64(extra) } // t.BlockSig (crypto.Signature) (struct) { b, err := br.ReadByte() if err != nil { return err } if b != cbg.CborNull[0] { if err := br.UnreadByte(); err != nil { return err } t.BlockSig = new(Signature) if err := t.BlockSig.UnmarshalCBOR(br); err != nil { return xerrors.Errorf("unmarshaling t.BlockSig pointer: %w", err) } } } // t.ForkSignaling (uint64) (uint64) { maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) if err != nil { return err } if maj != cbg.MajUnsignedInt { return fmt.Errorf("wrong type for uint64 field") } t.ForkSignaling = uint64(extra) } // t.ParentBaseFee (big.Int) (struct) { if err := t.ParentBaseFee.UnmarshalCBOR(br); err != nil { return xerrors.Errorf("unmarshaling t.ParentBaseFee: %w", err) } } return nil } func (t *Ticket) UnmarshalCBOR(r io.Reader) error { *t = Ticket{} br := cbg.GetPeeker(r) scratch := make([]byte, 8) maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) if err != nil { return err } if maj != cbg.MajArray { return fmt.Errorf("cbor input should be of type array") } if extra != 1 { return fmt.Errorf("cbor input had wrong number of fields") } // t.VRFProof (newBlock.VRFPi) (slice) maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) if err != nil { return err } if extra > cbg.ByteArrayMaxLen { return fmt.Errorf("t.VRFProof: byte array too large (%d)", extra) } if maj != cbg.MajByteString { return fmt.Errorf("expected byte array") } if extra > 0 { t.VRFProof = make([]uint8, extra) } if _, err := io.ReadFull(br, t.VRFProof[:]); err != nil { return err } return nil } func (t *ElectionProof) UnmarshalCBOR(r io.Reader) error { *t = ElectionProof{} br := cbg.GetPeeker(r) scratch := make([]byte, 8) maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) if err != nil { return err } if maj != cbg.MajArray { return fmt.Errorf("cbor input should be of type array") } if extra != 2 { return fmt.Errorf("cbor input had wrong number of fields") } // t.WinCount (int64) (int64) { maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) var extraI int64 if err != nil { return err } switch maj { case cbg.MajUnsignedInt: extraI = int64(extra) if extraI < 0 { return fmt.Errorf("int64 positive overflow") } case cbg.MajNegativeInt: extraI = int64(extra) if extraI < 0 { return fmt.Errorf("int64 negative oveflow") } extraI = -1 - extraI default: return fmt.Errorf("wrong type for int64 field: %d", maj) } t.WinCount = int64(extraI) } // t.VRFProof (newBlock.VRFPi) (slice) maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) if err != nil { return err } if extra > cbg.ByteArrayMaxLen { return fmt.Errorf("t.VRFProof: byte array too large (%d)", extra) } if maj != cbg.MajByteString { return fmt.Errorf("expected byte array") } if extra > 0 { t.VRFProof = make([]uint8, extra) } if _, err := io.ReadFull(br, t.VRFProof[:]); err != nil { return err } return nil } func (t *BeaconEntry) UnmarshalCBOR(r io.Reader) error { *t = BeaconEntry{} br := cbg.GetPeeker(r) scratch := make([]byte, 8) maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) if err != nil { return err } if maj != cbg.MajArray { return fmt.Errorf("cbor input should be of type array") } if extra != 2 { return fmt.Errorf("cbor input had wrong number of fields") } // t.Round (uint64) (uint64) { maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) if err != nil { return err } if maj != cbg.MajUnsignedInt { return fmt.Errorf("wrong type for uint64 field") } t.Round = uint64(extra) } // t.Data ([]uint8) (slice) maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) if err != nil { return err } if extra > cbg.ByteArrayMaxLen { return fmt.Errorf("t.Data: byte array too large (%d)", extra) } if maj != cbg.MajByteString { return fmt.Errorf("expected byte array") } if extra > 0 { t.Data = make([]uint8, extra) } if _, err := io.ReadFull(br, t.Data[:]); err != nil { return err } return nil } func (tipsetKey *TipSetKey) UnmarshalCBOR(r io.Reader) error { br := cbg.GetPeeker(r) scratch := make([]byte, 8) maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) if err != nil { return err } if extra > cbg.MaxLength { return fmt.Errorf("t.Parents: array too large (%d)", extra) } if maj != cbg.MajArray { return fmt.Errorf("expected cbor array") } if extra > 0 { cids := make([]Cid, extra) for i := 0; i < int(extra); i++ { c, err := cbg.ReadCid(br) if err != nil { return xerrors.Errorf("reading cid field t.Parents failed: %v", err) } cids[i] = c } tipsetKey.value = string(encodeKey(cids)) } return nil } func encodeKey(cids []Cid) []byte { buffer := new(bytes.Buffer) for _, c := range cids { // bytes.Buffer.Write() err is documented to be always nil. _, _ = buffer.Write(c.Bytes()) } return buffer.Bytes() }
{ return xerrors.Errorf("unmarshaling t.Message: %w", err) }
from_str.rs
// This does practically the same thing that TryFrom<&str> does. // Additionally, upon implementing FromStr, you can use the `parse` method // on strings to generate an object of the implementor type. // You can read more about it at https://doc.rust-lang.org/std/str/trait.FromStr.html use std::str::FromStr; #[derive(Debug)] struct Person { name: String, age: usize, } // I AM NOT DONE // Steps: // 1. If the length of the provided string is 0, then return an error // 2. Split the given string on the commas present in it // 3. Extract the first element from the split operation and use it as the name // 4. If the name is empty, then return an error // 5. Extract the other element from the split operation and parse it into a `usize` as the age // with something like `"4".parse::<usize>()`. // If while parsing the age, something goes wrong, then return an error // Otherwise, then return a Result of a Person object impl FromStr for Person { type Err = String; fn from_str(s: &str) -> Result<Person, Self::Err> { } } fn main() { let p = "Mark,20".parse::<Person>().unwrap(); println!("{:?}", p); } #[cfg(test)] mod tests { use super::*; #[test] fn empty_input() { assert!("".parse::<Person>().is_err()); } #[test] fn good_input() { let p = "John,32".parse::<Person>(); assert!(p.is_ok()); let p = p.unwrap(); assert_eq!(p.name, "John"); assert_eq!(p.age, 32); } #[test] #[should_panic] fn missing_age() { "John,".parse::<Person>().unwrap(); } #[test] #[should_panic] fn invalid_age() { "John,twenty".parse::<Person>().unwrap(); } #[test] #[should_panic] fn missing_comma_and_age() { "John".parse::<Person>().unwrap(); } #[test] #[should_panic] fn missing_name() { ",1".parse::<Person>().unwrap(); } #[test] #[should_panic] fn missing_name_and_age() { ",".parse::<Person>().unwrap(); } #[test] #[should_panic] fn missing_name_and_invalid_age()
}
{ ",one".parse::<Person>().unwrap(); }
shared_bst_incom_intimidator_mk2.py
#### NOTICE: THIS FILE IS AUTOGENERATED #### MODIFICATIONS MAY BE LOST IF DONE IMPROPERLY #### PLEASE SEE THE ONLINE DOCUMENTATION FOR EXAMPLES from swgpy.object import * def
(kernel): result = Tangible() result.template = "object/tangible/ship/components/booster/shared_bst_incom_intimidator_mk2.iff" result.attribute_template_id = 8 result.stfName("space/space_item","bst_incom_intimidator_mk2_n") #### BEGIN MODIFICATIONS #### #### END MODIFICATIONS #### return result
create
pretty_printer.rs
use std::io::Read; use std::path::Path; use console::Term; use syntect::parsing::SyntaxReference; use crate::{ assets::HighlightingAssets, config::{Config, VisibleLines}, controller::Controller, error::Result, input, line_range::{HighlightedLineRanges, LineRange, LineRanges}, style::{StyleComponent, StyleComponents}, SyntaxMapping, WrappingMode, }; #[cfg(feature = "paging")] use crate::paging::PagingMode; #[derive(Default)] struct ActiveStyleComponents { header: bool, vcs_modification_markers: bool, grid: bool, rule: bool, line_numbers: bool, snip: bool, } pub struct PrettyPrinter<'a> { inputs: Vec<Input<'a>>, config: Config<'a>, assets: HighlightingAssets, highlighted_lines: Vec<LineRange>, term_width: Option<usize>, active_style_components: ActiveStyleComponents, } impl<'a> PrettyPrinter<'a> { pub fn new() -> Self { let config = Config { colored_output: true, true_color: true, ..Default::default() }; PrettyPrinter { inputs: vec![], config, assets: HighlightingAssets::from_binary(), highlighted_lines: vec![], term_width: None, active_style_components: ActiveStyleComponents::default(), } } /// Add an input which should be pretty-printed pub fn input(&mut self, input: Input<'a>) -> &mut Self { self.inputs.push(input); self } /// Adds multiple inputs which should be pretty-printed pub fn inputs(&mut self, inputs: impl IntoIterator<Item = Input<'a>>) -> &mut Self { for input in inputs { self.inputs.push(input); } self } /// Add a file which should be pretty-printed pub fn input_file(&mut self, path: impl AsRef<Path>) -> &mut Self { self.input(Input::from_file(path).kind("File")) } /// Add multiple files which should be pretty-printed pub fn input_files<I, P>(&mut self, paths: I) -> &mut Self where I: IntoIterator<Item = P>, P: AsRef<Path>, { self.inputs(paths.into_iter().map(Input::from_file)) } /// Add STDIN as an input pub fn input_stdin(&mut self) -> &mut Self { self.inputs.push(Input::from_stdin()); self } /// Add a byte string as an input pub fn input_from_bytes(&mut self, content: &'a [u8]) -> &mut Self { self.input_from_reader(content) } /// Add a custom reader as an input pub fn input_from_reader<R: Read + 'a>(&mut self, reader: R) -> &mut Self { self.inputs.push(Input::from_reader(reader)); self } /// Specify the syntax file which should be used (default: auto-detect) pub fn language(&mut self, language: &'a str) -> &mut Self { self.config.language = Some(language); self } /// The character width of the terminal (default: autodetect) pub fn term_width(&mut self, width: usize) -> &mut Self { self.term_width = Some(width); self } /// The width of tab characters (default: None - do not turn tabs to spaces) pub fn tab_width(&mut self, tab_width: Option<usize>) -> &mut Self { self.config.tab_width = tab_width.unwrap_or(0); self } /// Whether or not the output should be colorized (default: true) pub fn colored_output(&mut self, yes: bool) -> &mut Self { self.config.colored_output = yes; self } /// Whether or not to output 24bit colors (default: true) pub fn true_color(&mut self, yes: bool) -> &mut Self { self.config.true_color = yes; self } /// Whether to show a header with the file name pub fn header(&mut self, yes: bool) -> &mut Self { self.active_style_components.header = yes; self } /// Whether to show line numbers pub fn line_numbers(&mut self, yes: bool) -> &mut Self { self.active_style_components.line_numbers = yes; self } /// Whether to paint a grid, separating line numbers, git changes and the code pub fn grid(&mut self, yes: bool) -> &mut Self { self.active_style_components.grid = yes; self } /// Whether to paint a horizontal rule to delimit files pub fn rule(&mut self, yes: bool) -> &mut Self { self.active_style_components.rule = yes; self } /// Whether to show modification markers for VCS changes. This has no effect if /// the `git` feature is not activated. #[cfg(feature = "git")] pub fn vcs_modification_markers(&mut self, yes: bool) -> &mut Self { self.active_style_components.vcs_modification_markers = yes; self } /// Whether to show "snip" markers between visible line ranges (default: no) pub fn snip(&mut self, yes: bool) -> &mut Self { self.active_style_components.snip = yes; self } /// Text wrapping mode (default: do not wrap) pub fn wrapping_mode(&mut self, mode: WrappingMode) -> &mut Self { self.config.wrapping_mode = mode; self } /// Whether or not to use ANSI italics (default: off) pub fn
(&mut self, yes: bool) -> &mut Self { self.config.use_italic_text = yes; self } /// If and how to use a pager (default: no paging) #[cfg(feature = "paging")] pub fn paging_mode(&mut self, mode: PagingMode) -> &mut Self { self.config.paging_mode = mode; self } /// Specify the command to start the pager (default: use "less") #[cfg(feature = "paging")] pub fn pager(&mut self, cmd: &'a str) -> &mut Self { self.config.pager = Some(cmd); self } /// Specify the lines that should be printed (default: all) pub fn line_ranges(&mut self, ranges: LineRanges) -> &mut Self { self.config.visible_lines = VisibleLines::Ranges(ranges); self } /// Specify a line that should be highlighted (default: none). /// This can be called multiple times to highlight more than one /// line. See also: highlight_range. pub fn highlight(&mut self, line: usize) -> &mut Self { self.highlighted_lines.push(LineRange::new(line, line)); self } /// Specify a range of lines that should be highlighted (default: none). /// This can be called multiple times to highlight more than one range /// of lines. pub fn highlight_range(&mut self, from: usize, to: usize) -> &mut Self { self.highlighted_lines.push(LineRange::new(from, to)); self } /// Specify the highlighting theme pub fn theme(&mut self, theme: impl AsRef<str>) -> &mut Self { self.config.theme = theme.as_ref().to_owned(); self } /// Specify custom file extension / file name to syntax mappings pub fn syntax_mapping(&mut self, mapping: SyntaxMapping<'a>) -> &mut Self { self.config.syntax_mapping = mapping; self } pub fn themes(&self) -> impl Iterator<Item = &str> { self.assets.themes() } pub fn syntaxes(&self) -> impl Iterator<Item = &SyntaxReference> { self.assets.syntaxes().iter() } /// Pretty-print all specified inputs. This method will "use" all stored inputs. /// If you want to call 'print' multiple times, you have to call the appropriate /// input_* methods again. pub fn print(&mut self) -> Result<bool> { self.config.highlighted_lines = HighlightedLineRanges(LineRanges::from(self.highlighted_lines.clone())); self.config.term_width = self .term_width .unwrap_or_else(|| Term::stdout().size().1 as usize); let mut style_components = vec![]; if self.active_style_components.grid { style_components.push(StyleComponent::Grid); } if self.active_style_components.rule { style_components.push(StyleComponent::Rule); } if self.active_style_components.header { style_components.push(StyleComponent::Header); } if self.active_style_components.line_numbers { style_components.push(StyleComponent::LineNumbers); } if self.active_style_components.snip { style_components.push(StyleComponent::Snip); } if self.active_style_components.vcs_modification_markers { #[cfg(feature = "git")] style_components.push(StyleComponent::Changes); } self.config.style_components = StyleComponents::new(&style_components); // Collect the inputs to print let mut inputs: Vec<Input> = vec![]; std::mem::swap(&mut inputs, &mut self.inputs); // Run the controller let controller = Controller::new(&self.config, &self.assets); controller.run(inputs.into_iter().map(|i| i.into()).collect()) } } impl Default for PrettyPrinter<'_> { fn default() -> Self { Self::new() } } /// An input source for the pretty printer. pub struct Input<'a> { input: input::Input<'a>, } impl<'a> Input<'a> { /// A new input from a reader. pub fn from_reader<R: Read + 'a>(reader: R) -> Self { input::Input::from_reader(Box::new(reader)).into() } /// A new input from a file. pub fn from_file(path: impl AsRef<Path>) -> Self { input::Input::ordinary_file(path).into() } /// A new input from bytes. pub fn from_bytes(bytes: &'a [u8]) -> Self { Input::from_reader(bytes) } /// A new input from STDIN. pub fn from_stdin() -> Self { input::Input::stdin().into() } /// The filename of the input. /// This affects syntax detection and changes the default header title. pub fn name(mut self, name: impl AsRef<Path>) -> Self { self.input = self.input.with_name(Some(name)); self } /// The description for the type of input (e.g. "File") pub fn kind(mut self, kind: impl Into<String>) -> Self { let kind = kind.into(); self.input .description_mut() .set_kind(if kind.is_empty() { None } else { Some(kind) }); self } /// The title for the input (e.g. "Descriptive title") /// This defaults to the file name. pub fn title(mut self, title: impl Into<String>) -> Self { self.input.description_mut().set_title(Some(title.into())); self } } impl<'a> From<input::Input<'a>> for Input<'a> { fn from(input: input::Input<'a>) -> Self { Self { input } } } impl<'a> From<Input<'a>> for input::Input<'a> { fn from(Input { input }: Input<'a>) -> Self { input } }
use_italics
wasm_macros.go
package compiler import ( "bytes" "encoding/binary" ) // WasmMacros are the macros called from .wat templates // // NOTE! Due to the single pass nature of the compilation and the way memory is // organized, you should initialize all initialized data in the .wat files using // DataB, DataW and DataD macros _before_ any calls to Block. Block allocates // uninitialized data blocks from the memory. type WasmMacros struct { data *bytes.Buffer blockStart int blockAlign int Labels map[string]int } func
() *WasmMacros { return &WasmMacros{ data: new(bytes.Buffer), blockAlign: 128, Labels: map[string]int{}, } } func (wm *WasmMacros) SetDataLabel(label string) string { wm.Labels[label] = wm.data.Len() return "" } func (wm *WasmMacros) SetBlockLabel(label string) string { wm.Labels[label] = wm.blockStart return "" } func (wm *WasmMacros) Align() string { wm.blockStart += wm.blockAlign - 1 - ((wm.blockStart + wm.blockAlign - 1) % wm.blockAlign) return "" } func (wm *WasmMacros) MemoryPages() int { return (wm.blockStart + 65535) / 65536 } func (wm *WasmMacros) GetLabel(label string) int { return wm.Labels[label] } func (wm *WasmMacros) DataB(value byte) string { binary.Write(wm.data, binary.LittleEndian, value) wm.blockStart++ return "" } func (wm *WasmMacros) DataW(value uint16) string { binary.Write(wm.data, binary.LittleEndian, value) wm.blockStart += 2 return "" } func (wm *WasmMacros) DataD(value uint32) string { binary.Write(wm.data, binary.LittleEndian, value) wm.blockStart += 4 return "" } func (wm *WasmMacros) Block(value int) string { wm.blockStart += value return "" } func (wm *WasmMacros) ToByte(value int) byte { return byte(value) } func (wm *WasmMacros) Data() []byte { return wm.data.Bytes() }
NewWasmMacros
epub.rs
use crossterm::style::{Attribute, Attributes}; use roxmltree::{Document, Node, ParsingOptions}; use std::{ collections::HashMap, fs::File, io::{self, Read}, }; pub struct Chapter { pub title: String, // single string for search pub text: String, pub lines: Vec<(usize, usize)>, // crossterm gives us a bitset but doesn't let us diff it, so store the state transition pub attrs: Vec<(usize, Attribute, Attributes)>, pub links: Vec<(usize, usize, String)>, frag: Vec<(String, usize)>, state: Attributes, } pub struct Epub { container: zip::ZipArchive<File>, rootdir: String, pub chapters: Vec<Chapter>, pub links: HashMap<String, (usize, usize)>, pub meta: String, } impl Epub { pub fn new(path: &str, meta: bool) -> io::Result<Self> { let file = File::open(path)?; let mut epub = Epub { container: zip::ZipArchive::new(file)?, rootdir: String::new(), chapters: Vec::new(), links: HashMap::new(), meta: String::new(), }; let chapters = epub.get_spine(); if !meta { epub.get_chapters(chapters); } Ok(epub) } fn get_text(&mut self, name: &str) -> String { let mut text = String::new(); self.container .by_name(name) .unwrap() .read_to_string(&mut text) .unwrap(); text } fn get_chapters(&mut self, spine: Vec<(String, String)>) { for (title, path) in spine { // https://github.com/RazrFalcon/roxmltree/issues/12 // UnknownEntityReference for HTML entities let xml = self.get_text(&format!("{}{}", self.rootdir, path)); let opt = ParsingOptions { allow_dtd: true }; let doc = Document::parse_with_options(&xml, opt).unwrap(); let body = doc.root_element().last_element_child().unwrap(); let state = Attributes::default(); let mut c = Chapter { title, text: String::new(), lines: Vec::new(), attrs: vec![(0, Attribute::Reset, state)], state, links: Vec::new(), frag: Vec::new(), }; render(body, &mut c); if c.text.trim().is_empty() { continue; } let relative = path.rsplit('/').next().unwrap(); self.links .insert(relative.to_string(), (self.chapters.len(), 0)); for (id, pos) in c.frag.drain(..) { let url = format!("{}#{}", relative, id); self.links.insert(url, (self.chapters.len(), pos)); } for link in c.links.iter_mut() { if link.2.starts_with('#') { link.2.insert_str(0, relative); } } self.chapters.push(c); } } fn get_spine(&mut self) -> Vec<(String, String)> { let xml = self.get_text("META-INF/container.xml"); let doc = Document::parse(&xml).unwrap(); let path = doc .descendants() .find(|n| n.has_tag_name("rootfile")) .unwrap() .attribute("full-path") .unwrap(); let xml = self.get_text(path); let doc = Document::parse(&xml).unwrap(); // zip expects unix path even on windows self.rootdir = match path.rfind('/') { Some(n) => &path[..=n], None => "", } .to_string(); let mut manifest = HashMap::new(); let mut nav = HashMap::new(); let mut children = doc.root_element().children().filter(Node::is_element); let meta_node = children.next().unwrap(); let manifest_node = children.next().unwrap(); let spine_node = children.next().unwrap(); meta_node.children().filter(Node::is_element).for_each(|n| { let name = n.tag_name().name(); let text = n.text(); if text.is_some() && name != "meta" { self.meta .push_str(&format!("{}: {}\n", name, text.unwrap())); } }); manifest_node .children() .filter(Node::is_element) .for_each(|n| { manifest.insert(n.attribute("id").unwrap(), n.attribute("href").unwrap()); }); if doc.root_element().attribute("version") == Some("3.0") { let path = manifest_node .children() .find(|n| n.attribute("properties") == Some("nav")) .unwrap() .attribute("href") .unwrap(); let xml = self.get_text(&format!("{}{}", self.rootdir, path)); let doc = Document::parse(&xml).unwrap(); epub3(doc, &mut nav); } else { let id = spine_node.attribute("toc").unwrap_or("ncx"); let path = manifest.get(id).unwrap(); let xml = self.get_text(&format!("{}{}", self.rootdir, path)); let doc = Document::parse(&xml).unwrap(); epub2(doc, &mut nav); } spine_node .children() .filter(Node::is_element) .enumerate() .map(|(i, n)| { let id = n.attribute("idref").unwrap(); let path = manifest.remove(id).unwrap(); let label = nav.remove(path).unwrap_or_else(|| i.to_string()); (label, path.to_string()) }) .collect() } } impl Chapter { fn render(&mut self, n: Node, open: Attribute, close: Attribute) { self.state.set(open); self.attrs.push((self.text.len(), open, self.state)); self.render_text(n); self.state.unset(open); self.attrs.push((self.text.len(), close, self.state)); } fn render_text(&mut self, n: Node) { for child in n.children() { render(child, self); } } } fn render(n: Node, c: &mut Chapter) { if n.is_text() { let text = n.text().unwrap(); let content: Vec<_> = text.split_ascii_whitespace().collect(); if text.starts_with(char::is_whitespace) { c.text.push(' '); } c.text.push_str(&content.join(" ")); if text.ends_with(char::is_whitespace) { c.text.push(' '); } return; } if let Some(id) = n.attribute("id") { c.frag.push((id.to_string(), c.text.len())); } match n.tag_name().name() { "br" => c.text.push('\n'), "hr" => c.text.push_str("\n* * *\n"), "img" => c.text.push_str("\n[IMG]\n"), "a" => { match n.attribute("href") { // TODO open external urls in browser Some(url) if !url.starts_with("http") => { let start = c.text.len(); c.render(n, Attribute::Underlined, Attribute::NoUnderline); c.links.push((start, c.text.len(), url.to_string())); } _ => c.render_text(n), } } "em" => c.render(n, Attribute::Italic, Attribute::NoItalic), "strong" => c.render(n, Attribute::Bold, Attribute::NormalIntensity), "h1" | "h2" | "h3" | "h4" | "h5" | "h6" => { c.text.push('\n'); c.render(n, Attribute::Bold, Attribute::NormalIntensity); c.text.push('\n'); } "blockquote" | "div" | "p" | "tr" => { // TODO compress newlines c.text.push('\n'); c.render_text(n); c.text.push('\n'); } "li" => { c.text.push_str("\n- "); c.render_text(n); c.text.push('\n'); } "pre" => { c.text.push_str("\n "); n .descendants() .filter(Node::is_text) .map(|n| n.text().unwrap().replace('\n', "\n ")) .for_each(|s| c.text.push_str(&s)); c.text.push('\n'); } _ => c.render_text(n), } } fn epub2(doc: Document, nav: &mut HashMap<String, String>) { doc.descendants() .find(|n| n.has_tag_name("navMap")) .unwrap() .descendants() .filter(|n| n.has_tag_name("navPoint")) .for_each(|n| { let path = n .descendants() .find(|n| n.has_tag_name("content")) .unwrap() .attribute("src") .unwrap() .split('#') .next() .unwrap() .to_string(); let text = n .descendants() .find(|n| n.has_tag_name("text")) .unwrap() .text() .unwrap() .to_string(); // TODO subsections nav.entry(path).or_insert(text); }); } fn epub3(doc: Document, nav: &mut HashMap<String, String>) { doc.descendants() .find(|n| n.has_tag_name("nav")) .unwrap() .children() .find(|n| n.has_tag_name("ol")) .unwrap() .descendants() .filter(|n| n.has_tag_name("a")) .for_each(|n| { let path = n
.unwrap() .split('#') .next() .unwrap() .to_string(); let text = n .descendants() .filter(Node::is_text) .map(|n| n.text().unwrap()) .collect(); nav.insert(path, text); }); }
.attribute("href")
helpers.py
import os import json import sys import random import time filename = "db.json" def init(): """Initialize Database""" if os.path.isfile(filename) != True: db = open(filename, 'w').close() else: db = open(filename, 'r') try: content = json.load(db) except ValueError: content = [] return content def callback(func): time.sleep(0.2) res = input('\nWould you like to try again? [y]es or [n]o\n\t=>').lower() if res == 'n' or res == 'no': return elif res == 'y' or res == 'yes': func() else: callback(func) def add(): """Appends words to dictionary.""" content = init() key = input('\nWhat is your term?\n\t=>') definition = input('\nWhat is your definition?\n\t=>') content.append({'key':key, 'definition': definition}) db = open(filename, 'w') json.dump(content, db) db.close() callback(add) def view(): """View your dictionary""" content = init() index = 1 if len(content) == 0: print('\nYou have no words. Add more.') for i in content: key = i['key'] definition = i['definition'] print('{}. {}: {}\n'.format(index, key, definition)) index += 1 callback(view) def delete():
def destroy(): """Wipes dictionary clear of anything""" open(filename, 'w').close() def menu(): """Menu Function""" def run(func): """Calls functions""" func() menu() print('\n\t\tYour Personal dictionary!') choice = input("\nDo you want to 'view', 'add', 'delete', or 'destroy'? Enter 'x' to exit.\n\t=>").lower() if choice == 'view': run(view) elif choice == 'add': run(add) elif choice == 'delete': run(delete) elif choice == 'destroy': run(destroy) elif choice == 'x': raise SystemExit else: print('\n\tInvalid input.') menu()
"""Remove a word from your dictionary.""" content = init() newContent = [] print('\n\tWord Choices (Case Sensitive):') for word in content: print('\n\t{}'.format(word['key'])) wordToDel = input('\n\tWhat word do you want to delete?\n\t\t=>') validList = [] vCount = 0 for word in content: validList.append(word['key']) for key in validList: print('\n\tScanning..') time.sleep(0.1) vCount += 1 if key != wordToDel and vCount < len(validList): continue elif key == wordToDel: print('\n\tFound. Deleting..') time.sleep(1) print('\n\t\tSuccess!') break else: print("\nInvalid Input.") delete() for i in content: if i['key'] != wordToDel: newContent.append(i) db = open(filename, 'w') json.dump(newContent, db) db.close() callback(delete)
fake_build.go
// Code generated by counterfeiter. DO NOT EDIT. package dbfakes import ( "encoding/json" "sync" "time" "code.cloudfoundry.org/lager" "github.com/concourse/concourse/atc" "github.com/concourse/concourse/atc/db" "github.com/concourse/concourse/atc/db/lock" ) type FakeBuild struct { AbortNotifierStub func() (db.Notifier, error) abortNotifierMutex sync.RWMutex abortNotifierArgsForCall []struct { } abortNotifierReturns struct { result1 db.Notifier result2 error } abortNotifierReturnsOnCall map[int]struct { result1 db.Notifier result2 error } AcquireTrackingLockStub func(lager.Logger, time.Duration) (lock.Lock, bool, error) acquireTrackingLockMutex sync.RWMutex acquireTrackingLockArgsForCall []struct { arg1 lager.Logger arg2 time.Duration } acquireTrackingLockReturns struct { result1 lock.Lock result2 bool result3 error } acquireTrackingLockReturnsOnCall map[int]struct { result1 lock.Lock result2 bool result3 error } AdoptInputsAndPipesStub func() ([]db.BuildInput, bool, error) adoptInputsAndPipesMutex sync.RWMutex adoptInputsAndPipesArgsForCall []struct { } adoptInputsAndPipesReturns struct { result1 []db.BuildInput result2 bool result3 error } adoptInputsAndPipesReturnsOnCall map[int]struct { result1 []db.BuildInput result2 bool result3 error } AdoptRerunInputsAndPipesStub func() ([]db.BuildInput, bool, error) adoptRerunInputsAndPipesMutex sync.RWMutex adoptRerunInputsAndPipesArgsForCall []struct { } adoptRerunInputsAndPipesReturns struct { result1 []db.BuildInput result2 bool result3 error } adoptRerunInputsAndPipesReturnsOnCall map[int]struct { result1 []db.BuildInput result2 bool result3 error } ArtifactStub func(int) (db.WorkerArtifact, error) artifactMutex sync.RWMutex artifactArgsForCall []struct { arg1 int } artifactReturns struct { result1 db.WorkerArtifact result2 error } artifactReturnsOnCall map[int]struct { result1 db.WorkerArtifact result2 error } ArtifactsStub func() ([]db.WorkerArtifact, error) artifactsMutex sync.RWMutex artifactsArgsForCall []struct { } artifactsReturns struct { result1 []db.WorkerArtifact result2 error } artifactsReturnsOnCall map[int]struct { result1 []db.WorkerArtifact result2 error } DeleteStub func() (bool, error) deleteMutex sync.RWMutex deleteArgsForCall []struct { } deleteReturns struct { result1 bool result2 error } deleteReturnsOnCall map[int]struct { result1 bool result2 error } EndTimeStub func() time.Time endTimeMutex sync.RWMutex endTimeArgsForCall []struct { } endTimeReturns struct { result1 time.Time } endTimeReturnsOnCall map[int]struct { result1 time.Time } EventsStub func(uint) (db.EventSource, error) eventsMutex sync.RWMutex eventsArgsForCall []struct { arg1 uint } eventsReturns struct { result1 db.EventSource result2 error } eventsReturnsOnCall map[int]struct { result1 db.EventSource result2 error } FinishStub func(db.BuildStatus) error finishMutex sync.RWMutex finishArgsForCall []struct { arg1 db.BuildStatus } finishReturns struct { result1 error } finishReturnsOnCall map[int]struct { result1 error } HasPlanStub func() bool hasPlanMutex sync.RWMutex hasPlanArgsForCall []struct { } hasPlanReturns struct { result1 bool } hasPlanReturnsOnCall map[int]struct { result1 bool } IDStub func() int iDMutex sync.RWMutex iDArgsForCall []struct { } iDReturns struct { result1 int } iDReturnsOnCall map[int]struct { result1 int } InputsReadyStub func() bool inputsReadyMutex sync.RWMutex inputsReadyArgsForCall []struct { } inputsReadyReturns struct { result1 bool } inputsReadyReturnsOnCall map[int]struct { result1 bool } InterceptibleStub func() (bool, error) interceptibleMutex sync.RWMutex interceptibleArgsForCall []struct { } interceptibleReturns struct { result1 bool result2 error } interceptibleReturnsOnCall map[int]struct { result1 bool result2 error } IsAbortedStub func() bool isAbortedMutex sync.RWMutex isAbortedArgsForCall []struct { } isAbortedReturns struct { result1 bool } isAbortedReturnsOnCall map[int]struct { result1 bool } IsCompletedStub func() bool isCompletedMutex sync.RWMutex isCompletedArgsForCall []struct { } isCompletedReturns struct { result1 bool } isCompletedReturnsOnCall map[int]struct { result1 bool } IsDrainedStub func() bool isDrainedMutex sync.RWMutex isDrainedArgsForCall []struct { } isDrainedReturns struct { result1 bool } isDrainedReturnsOnCall map[int]struct { result1 bool } IsManuallyTriggeredStub func() bool isManuallyTriggeredMutex sync.RWMutex isManuallyTriggeredArgsForCall []struct { } isManuallyTriggeredReturns struct { result1 bool } isManuallyTriggeredReturnsOnCall map[int]struct { result1 bool } IsNewerThanLastCheckOfStub func(db.Resource) bool isNewerThanLastCheckOfMutex sync.RWMutex isNewerThanLastCheckOfArgsForCall []struct { arg1 db.Resource } isNewerThanLastCheckOfReturns struct { result1 bool } isNewerThanLastCheckOfReturnsOnCall map[int]struct { result1 bool } IsRunningStub func() bool isRunningMutex sync.RWMutex isRunningArgsForCall []struct { } isRunningReturns struct { result1 bool } isRunningReturnsOnCall map[int]struct { result1 bool } IsScheduledStub func() bool isScheduledMutex sync.RWMutex isScheduledArgsForCall []struct { } isScheduledReturns struct { result1 bool } isScheduledReturnsOnCall map[int]struct { result1 bool } JobIDStub func() int jobIDMutex sync.RWMutex jobIDArgsForCall []struct { } jobIDReturns struct { result1 int } jobIDReturnsOnCall map[int]struct { result1 int } JobNameStub func() string jobNameMutex sync.RWMutex jobNameArgsForCall []struct { } jobNameReturns struct { result1 string } jobNameReturnsOnCall map[int]struct { result1 string } MarkAsAbortedStub func() error markAsAbortedMutex sync.RWMutex markAsAbortedArgsForCall []struct { } markAsAbortedReturns struct { result1 error } markAsAbortedReturnsOnCall map[int]struct { result1 error } NameStub func() string nameMutex sync.RWMutex nameArgsForCall []struct { } nameReturns struct { result1 string } nameReturnsOnCall map[int]struct { result1 string } PipelineStub func() (db.Pipeline, bool, error) pipelineMutex sync.RWMutex pipelineArgsForCall []struct { } pipelineReturns struct { result1 db.Pipeline result2 bool result3 error } pipelineReturnsOnCall map[int]struct { result1 db.Pipeline result2 bool result3 error } PipelineIDStub func() int pipelineIDMutex sync.RWMutex pipelineIDArgsForCall []struct { } pipelineIDReturns struct { result1 int } pipelineIDReturnsOnCall map[int]struct { result1 int } PipelineNameStub func() string pipelineNameMutex sync.RWMutex pipelineNameArgsForCall []struct { } pipelineNameReturns struct { result1 string } pipelineNameReturnsOnCall map[int]struct { result1 string } PreparationStub func() (db.BuildPreparation, bool, error) preparationMutex sync.RWMutex preparationArgsForCall []struct { } preparationReturns struct { result1 db.BuildPreparation result2 bool result3 error } preparationReturnsOnCall map[int]struct { result1 db.BuildPreparation result2 bool result3 error } PrivatePlanStub func() atc.Plan privatePlanMutex sync.RWMutex privatePlanArgsForCall []struct { } privatePlanReturns struct { result1 atc.Plan } privatePlanReturnsOnCall map[int]struct { result1 atc.Plan } PublicPlanStub func() *json.RawMessage publicPlanMutex sync.RWMutex publicPlanArgsForCall []struct { } publicPlanReturns struct { result1 *json.RawMessage } publicPlanReturnsOnCall map[int]struct { result1 *json.RawMessage } ReapTimeStub func() time.Time reapTimeMutex sync.RWMutex reapTimeArgsForCall []struct { } reapTimeReturns struct { result1 time.Time } reapTimeReturnsOnCall map[int]struct { result1 time.Time } ReloadStub func() (bool, error) reloadMutex sync.RWMutex reloadArgsForCall []struct { } reloadReturns struct { result1 bool result2 error } reloadReturnsOnCall map[int]struct { result1 bool result2 error } RerunNumberStub func() int rerunNumberMutex sync.RWMutex rerunNumberArgsForCall []struct { } rerunNumberReturns struct { result1 int } rerunNumberReturnsOnCall map[int]struct { result1 int } RerunOfStub func() int rerunOfMutex sync.RWMutex rerunOfArgsForCall []struct { } rerunOfReturns struct { result1 int } rerunOfReturnsOnCall map[int]struct { result1 int } RerunOfNameStub func() string rerunOfNameMutex sync.RWMutex rerunOfNameArgsForCall []struct { } rerunOfNameReturns struct { result1 string } rerunOfNameReturnsOnCall map[int]struct { result1 string } ResourcesStub func() ([]db.BuildInput, []db.BuildOutput, error) resourcesMutex sync.RWMutex resourcesArgsForCall []struct { } resourcesReturns struct { result1 []db.BuildInput result2 []db.BuildOutput result3 error } resourcesReturnsOnCall map[int]struct { result1 []db.BuildInput result2 []db.BuildOutput result3 error } ResourcesCheckedStub func() (bool, error) resourcesCheckedMutex sync.RWMutex resourcesCheckedArgsForCall []struct { } resourcesCheckedReturns struct { result1 bool result2 error } resourcesCheckedReturnsOnCall map[int]struct { result1 bool result2 error } SaveEventStub func(atc.Event) error saveEventMutex sync.RWMutex saveEventArgsForCall []struct { arg1 atc.Event } saveEventReturns struct { result1 error } saveEventReturnsOnCall map[int]struct { result1 error } SaveImageResourceVersionStub func(db.UsedResourceCache) error saveImageResourceVersionMutex sync.RWMutex saveImageResourceVersionArgsForCall []struct { arg1 db.UsedResourceCache } saveImageResourceVersionReturns struct { result1 error } saveImageResourceVersionReturnsOnCall map[int]struct { result1 error } SaveOutputStub func(string, atc.Source, atc.VersionedResourceTypes, atc.Version, db.ResourceConfigMetadataFields, string, string) error saveOutputMutex sync.RWMutex saveOutputArgsForCall []struct { arg1 string arg2 atc.Source arg3 atc.VersionedResourceTypes arg4 atc.Version arg5 db.ResourceConfigMetadataFields arg6 string arg7 string } saveOutputReturns struct { result1 error } saveOutputReturnsOnCall map[int]struct { result1 error } SchemaStub func() string schemaMutex sync.RWMutex schemaArgsForCall []struct { } schemaReturns struct { result1 string } schemaReturnsOnCall map[int]struct { result1 string } SetDrainedStub func(bool) error setDrainedMutex sync.RWMutex setDrainedArgsForCall []struct { arg1 bool } setDrainedReturns struct { result1 error } setDrainedReturnsOnCall map[int]struct { result1 error } SetInterceptibleStub func(bool) error setInterceptibleMutex sync.RWMutex setInterceptibleArgsForCall []struct { arg1 bool } setInterceptibleReturns struct { result1 error } setInterceptibleReturnsOnCall map[int]struct { result1 error } StartStub func(atc.Plan) (bool, error) startMutex sync.RWMutex startArgsForCall []struct { arg1 atc.Plan } startReturns struct { result1 bool result2 error } startReturnsOnCall map[int]struct { result1 bool result2 error } StartTimeStub func() time.Time startTimeMutex sync.RWMutex startTimeArgsForCall []struct { } startTimeReturns struct { result1 time.Time } startTimeReturnsOnCall map[int]struct { result1 time.Time } StatusStub func() db.BuildStatus statusMutex sync.RWMutex statusArgsForCall []struct { } statusReturns struct { result1 db.BuildStatus } statusReturnsOnCall map[int]struct { result1 db.BuildStatus } TeamIDStub func() int teamIDMutex sync.RWMutex teamIDArgsForCall []struct { } teamIDReturns struct { result1 int } teamIDReturnsOnCall map[int]struct { result1 int } TeamNameStub func() string teamNameMutex sync.RWMutex teamNameArgsForCall []struct { } teamNameReturns struct { result1 string } teamNameReturnsOnCall map[int]struct { result1 string } invocations map[string][][]interface{} invocationsMutex sync.RWMutex } func (fake *FakeBuild) AbortNotifier() (db.Notifier, error) { fake.abortNotifierMutex.Lock() ret, specificReturn := fake.abortNotifierReturnsOnCall[len(fake.abortNotifierArgsForCall)] fake.abortNotifierArgsForCall = append(fake.abortNotifierArgsForCall, struct { }{}) fake.recordInvocation("AbortNotifier", []interface{}{}) fake.abortNotifierMutex.Unlock() if fake.AbortNotifierStub != nil { return fake.AbortNotifierStub() } if specificReturn { return ret.result1, ret.result2 } fakeReturns := fake.abortNotifierReturns return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeBuild) AbortNotifierCallCount() int { fake.abortNotifierMutex.RLock() defer fake.abortNotifierMutex.RUnlock() return len(fake.abortNotifierArgsForCall) } func (fake *FakeBuild) AbortNotifierCalls(stub func() (db.Notifier, error)) { fake.abortNotifierMutex.Lock() defer fake.abortNotifierMutex.Unlock() fake.AbortNotifierStub = stub } func (fake *FakeBuild) AbortNotifierReturns(result1 db.Notifier, result2 error) { fake.abortNotifierMutex.Lock() defer fake.abortNotifierMutex.Unlock() fake.AbortNotifierStub = nil fake.abortNotifierReturns = struct { result1 db.Notifier result2 error }{result1, result2} } func (fake *FakeBuild) AbortNotifierReturnsOnCall(i int, result1 db.Notifier, result2 error) { fake.abortNotifierMutex.Lock() defer fake.abortNotifierMutex.Unlock() fake.AbortNotifierStub = nil if fake.abortNotifierReturnsOnCall == nil { fake.abortNotifierReturnsOnCall = make(map[int]struct { result1 db.Notifier result2 error }) } fake.abortNotifierReturnsOnCall[i] = struct { result1 db.Notifier result2 error }{result1, result2} } func (fake *FakeBuild) AcquireTrackingLock(arg1 lager.Logger, arg2 time.Duration) (lock.Lock, bool, error) { fake.acquireTrackingLockMutex.Lock() ret, specificReturn := fake.acquireTrackingLockReturnsOnCall[len(fake.acquireTrackingLockArgsForCall)] fake.acquireTrackingLockArgsForCall = append(fake.acquireTrackingLockArgsForCall, struct { arg1 lager.Logger arg2 time.Duration }{arg1, arg2}) fake.recordInvocation("AcquireTrackingLock", []interface{}{arg1, arg2}) fake.acquireTrackingLockMutex.Unlock() if fake.AcquireTrackingLockStub != nil { return fake.AcquireTrackingLockStub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2, ret.result3 } fakeReturns := fake.acquireTrackingLockReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } func (fake *FakeBuild) AcquireTrackingLockCallCount() int { fake.acquireTrackingLockMutex.RLock() defer fake.acquireTrackingLockMutex.RUnlock() return len(fake.acquireTrackingLockArgsForCall) } func (fake *FakeBuild) AcquireTrackingLockCalls(stub func(lager.Logger, time.Duration) (lock.Lock, bool, error)) { fake.acquireTrackingLockMutex.Lock() defer fake.acquireTrackingLockMutex.Unlock() fake.AcquireTrackingLockStub = stub } func (fake *FakeBuild) AcquireTrackingLockArgsForCall(i int) (lager.Logger, time.Duration) { fake.acquireTrackingLockMutex.RLock() defer fake.acquireTrackingLockMutex.RUnlock() argsForCall := fake.acquireTrackingLockArgsForCall[i] return argsForCall.arg1, argsForCall.arg2 } func (fake *FakeBuild) AcquireTrackingLockReturns(result1 lock.Lock, result2 bool, result3 error) { fake.acquireTrackingLockMutex.Lock() defer fake.acquireTrackingLockMutex.Unlock() fake.AcquireTrackingLockStub = nil fake.acquireTrackingLockReturns = struct { result1 lock.Lock result2 bool result3 error }{result1, result2, result3} } func (fake *FakeBuild) AcquireTrackingLockReturnsOnCall(i int, result1 lock.Lock, result2 bool, result3 error) { fake.acquireTrackingLockMutex.Lock() defer fake.acquireTrackingLockMutex.Unlock() fake.AcquireTrackingLockStub = nil if fake.acquireTrackingLockReturnsOnCall == nil { fake.acquireTrackingLockReturnsOnCall = make(map[int]struct { result1 lock.Lock result2 bool result3 error }) } fake.acquireTrackingLockReturnsOnCall[i] = struct { result1 lock.Lock result2 bool result3 error }{result1, result2, result3} } func (fake *FakeBuild) AdoptInputsAndPipes() ([]db.BuildInput, bool, error) { fake.adoptInputsAndPipesMutex.Lock() ret, specificReturn := fake.adoptInputsAndPipesReturnsOnCall[len(fake.adoptInputsAndPipesArgsForCall)] fake.adoptInputsAndPipesArgsForCall = append(fake.adoptInputsAndPipesArgsForCall, struct { }{}) fake.recordInvocation("AdoptInputsAndPipes", []interface{}{}) fake.adoptInputsAndPipesMutex.Unlock() if fake.AdoptInputsAndPipesStub != nil { return fake.AdoptInputsAndPipesStub() } if specificReturn { return ret.result1, ret.result2, ret.result3 } fakeReturns := fake.adoptInputsAndPipesReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } func (fake *FakeBuild) AdoptInputsAndPipesCallCount() int { fake.adoptInputsAndPipesMutex.RLock() defer fake.adoptInputsAndPipesMutex.RUnlock() return len(fake.adoptInputsAndPipesArgsForCall) } func (fake *FakeBuild) AdoptInputsAndPipesCalls(stub func() ([]db.BuildInput, bool, error)) { fake.adoptInputsAndPipesMutex.Lock() defer fake.adoptInputsAndPipesMutex.Unlock() fake.AdoptInputsAndPipesStub = stub } func (fake *FakeBuild) AdoptInputsAndPipesReturns(result1 []db.BuildInput, result2 bool, result3 error) { fake.adoptInputsAndPipesMutex.Lock() defer fake.adoptInputsAndPipesMutex.Unlock() fake.AdoptInputsAndPipesStub = nil fake.adoptInputsAndPipesReturns = struct { result1 []db.BuildInput result2 bool result3 error }{result1, result2, result3} } func (fake *FakeBuild) AdoptInputsAndPipesReturnsOnCall(i int, result1 []db.BuildInput, result2 bool, result3 error) { fake.adoptInputsAndPipesMutex.Lock() defer fake.adoptInputsAndPipesMutex.Unlock() fake.AdoptInputsAndPipesStub = nil if fake.adoptInputsAndPipesReturnsOnCall == nil { fake.adoptInputsAndPipesReturnsOnCall = make(map[int]struct { result1 []db.BuildInput result2 bool result3 error }) } fake.adoptInputsAndPipesReturnsOnCall[i] = struct { result1 []db.BuildInput result2 bool result3 error }{result1, result2, result3} } func (fake *FakeBuild) AdoptRerunInputsAndPipes() ([]db.BuildInput, bool, error) { fake.adoptRerunInputsAndPipesMutex.Lock() ret, specificReturn := fake.adoptRerunInputsAndPipesReturnsOnCall[len(fake.adoptRerunInputsAndPipesArgsForCall)] fake.adoptRerunInputsAndPipesArgsForCall = append(fake.adoptRerunInputsAndPipesArgsForCall, struct { }{}) fake.recordInvocation("AdoptRerunInputsAndPipes", []interface{}{}) fake.adoptRerunInputsAndPipesMutex.Unlock() if fake.AdoptRerunInputsAndPipesStub != nil { return fake.AdoptRerunInputsAndPipesStub() } if specificReturn { return ret.result1, ret.result2, ret.result3 } fakeReturns := fake.adoptRerunInputsAndPipesReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } func (fake *FakeBuild) AdoptRerunInputsAndPipesCallCount() int { fake.adoptRerunInputsAndPipesMutex.RLock() defer fake.adoptRerunInputsAndPipesMutex.RUnlock() return len(fake.adoptRerunInputsAndPipesArgsForCall) } func (fake *FakeBuild) AdoptRerunInputsAndPipesCalls(stub func() ([]db.BuildInput, bool, error)) { fake.adoptRerunInputsAndPipesMutex.Lock() defer fake.adoptRerunInputsAndPipesMutex.Unlock() fake.AdoptRerunInputsAndPipesStub = stub } func (fake *FakeBuild) AdoptRerunInputsAndPipesReturns(result1 []db.BuildInput, result2 bool, result3 error) { fake.adoptRerunInputsAndPipesMutex.Lock() defer fake.adoptRerunInputsAndPipesMutex.Unlock() fake.AdoptRerunInputsAndPipesStub = nil fake.adoptRerunInputsAndPipesReturns = struct { result1 []db.BuildInput result2 bool result3 error }{result1, result2, result3} } func (fake *FakeBuild) AdoptRerunInputsAndPipesReturnsOnCall(i int, result1 []db.BuildInput, result2 bool, result3 error) { fake.adoptRerunInputsAndPipesMutex.Lock() defer fake.adoptRerunInputsAndPipesMutex.Unlock() fake.AdoptRerunInputsAndPipesStub = nil if fake.adoptRerunInputsAndPipesReturnsOnCall == nil { fake.adoptRerunInputsAndPipesReturnsOnCall = make(map[int]struct { result1 []db.BuildInput result2 bool result3 error }) } fake.adoptRerunInputsAndPipesReturnsOnCall[i] = struct { result1 []db.BuildInput result2 bool result3 error }{result1, result2, result3} } func (fake *FakeBuild) Artifact(arg1 int) (db.WorkerArtifact, error) { fake.artifactMutex.Lock() ret, specificReturn := fake.artifactReturnsOnCall[len(fake.artifactArgsForCall)] fake.artifactArgsForCall = append(fake.artifactArgsForCall, struct { arg1 int }{arg1}) fake.recordInvocation("Artifact", []interface{}{arg1}) fake.artifactMutex.Unlock() if fake.ArtifactStub != nil { return fake.ArtifactStub(arg1) } if specificReturn { return ret.result1, ret.result2 } fakeReturns := fake.artifactReturns return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeBuild) ArtifactCallCount() int { fake.artifactMutex.RLock() defer fake.artifactMutex.RUnlock() return len(fake.artifactArgsForCall) } func (fake *FakeBuild) ArtifactCalls(stub func(int) (db.WorkerArtifact, error)) { fake.artifactMutex.Lock() defer fake.artifactMutex.Unlock() fake.ArtifactStub = stub } func (fake *FakeBuild) ArtifactArgsForCall(i int) int { fake.artifactMutex.RLock() defer fake.artifactMutex.RUnlock() argsForCall := fake.artifactArgsForCall[i] return argsForCall.arg1 } func (fake *FakeBuild) ArtifactReturns(result1 db.WorkerArtifact, result2 error) { fake.artifactMutex.Lock() defer fake.artifactMutex.Unlock() fake.ArtifactStub = nil fake.artifactReturns = struct { result1 db.WorkerArtifact result2 error }{result1, result2} } func (fake *FakeBuild) ArtifactReturnsOnCall(i int, result1 db.WorkerArtifact, result2 error) { fake.artifactMutex.Lock() defer fake.artifactMutex.Unlock() fake.ArtifactStub = nil if fake.artifactReturnsOnCall == nil { fake.artifactReturnsOnCall = make(map[int]struct { result1 db.WorkerArtifact result2 error }) } fake.artifactReturnsOnCall[i] = struct { result1 db.WorkerArtifact result2 error }{result1, result2} } func (fake *FakeBuild) Artifacts() ([]db.WorkerArtifact, error) { fake.artifactsMutex.Lock() ret, specificReturn := fake.artifactsReturnsOnCall[len(fake.artifactsArgsForCall)] fake.artifactsArgsForCall = append(fake.artifactsArgsForCall, struct { }{}) fake.recordInvocation("Artifacts", []interface{}{}) fake.artifactsMutex.Unlock() if fake.ArtifactsStub != nil { return fake.ArtifactsStub() } if specificReturn { return ret.result1, ret.result2 } fakeReturns := fake.artifactsReturns return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeBuild) ArtifactsCallCount() int { fake.artifactsMutex.RLock() defer fake.artifactsMutex.RUnlock() return len(fake.artifactsArgsForCall) } func (fake *FakeBuild) ArtifactsCalls(stub func() ([]db.WorkerArtifact, error)) { fake.artifactsMutex.Lock() defer fake.artifactsMutex.Unlock() fake.ArtifactsStub = stub } func (fake *FakeBuild) ArtifactsReturns(result1 []db.WorkerArtifact, result2 error) { fake.artifactsMutex.Lock()
fake.ArtifactsStub = nil fake.artifactsReturns = struct { result1 []db.WorkerArtifact result2 error }{result1, result2} } func (fake *FakeBuild) ArtifactsReturnsOnCall(i int, result1 []db.WorkerArtifact, result2 error) { fake.artifactsMutex.Lock() defer fake.artifactsMutex.Unlock() fake.ArtifactsStub = nil if fake.artifactsReturnsOnCall == nil { fake.artifactsReturnsOnCall = make(map[int]struct { result1 []db.WorkerArtifact result2 error }) } fake.artifactsReturnsOnCall[i] = struct { result1 []db.WorkerArtifact result2 error }{result1, result2} } func (fake *FakeBuild) Delete() (bool, error) { fake.deleteMutex.Lock() ret, specificReturn := fake.deleteReturnsOnCall[len(fake.deleteArgsForCall)] fake.deleteArgsForCall = append(fake.deleteArgsForCall, struct { }{}) fake.recordInvocation("Delete", []interface{}{}) fake.deleteMutex.Unlock() if fake.DeleteStub != nil { return fake.DeleteStub() } if specificReturn { return ret.result1, ret.result2 } fakeReturns := fake.deleteReturns return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeBuild) DeleteCallCount() int { fake.deleteMutex.RLock() defer fake.deleteMutex.RUnlock() return len(fake.deleteArgsForCall) } func (fake *FakeBuild) DeleteCalls(stub func() (bool, error)) { fake.deleteMutex.Lock() defer fake.deleteMutex.Unlock() fake.DeleteStub = stub } func (fake *FakeBuild) DeleteReturns(result1 bool, result2 error) { fake.deleteMutex.Lock() defer fake.deleteMutex.Unlock() fake.DeleteStub = nil fake.deleteReturns = struct { result1 bool result2 error }{result1, result2} } func (fake *FakeBuild) DeleteReturnsOnCall(i int, result1 bool, result2 error) { fake.deleteMutex.Lock() defer fake.deleteMutex.Unlock() fake.DeleteStub = nil if fake.deleteReturnsOnCall == nil { fake.deleteReturnsOnCall = make(map[int]struct { result1 bool result2 error }) } fake.deleteReturnsOnCall[i] = struct { result1 bool result2 error }{result1, result2} } func (fake *FakeBuild) EndTime() time.Time { fake.endTimeMutex.Lock() ret, specificReturn := fake.endTimeReturnsOnCall[len(fake.endTimeArgsForCall)] fake.endTimeArgsForCall = append(fake.endTimeArgsForCall, struct { }{}) fake.recordInvocation("EndTime", []interface{}{}) fake.endTimeMutex.Unlock() if fake.EndTimeStub != nil { return fake.EndTimeStub() } if specificReturn { return ret.result1 } fakeReturns := fake.endTimeReturns return fakeReturns.result1 } func (fake *FakeBuild) EndTimeCallCount() int { fake.endTimeMutex.RLock() defer fake.endTimeMutex.RUnlock() return len(fake.endTimeArgsForCall) } func (fake *FakeBuild) EndTimeCalls(stub func() time.Time) { fake.endTimeMutex.Lock() defer fake.endTimeMutex.Unlock() fake.EndTimeStub = stub } func (fake *FakeBuild) EndTimeReturns(result1 time.Time) { fake.endTimeMutex.Lock() defer fake.endTimeMutex.Unlock() fake.EndTimeStub = nil fake.endTimeReturns = struct { result1 time.Time }{result1} } func (fake *FakeBuild) EndTimeReturnsOnCall(i int, result1 time.Time) { fake.endTimeMutex.Lock() defer fake.endTimeMutex.Unlock() fake.EndTimeStub = nil if fake.endTimeReturnsOnCall == nil { fake.endTimeReturnsOnCall = make(map[int]struct { result1 time.Time }) } fake.endTimeReturnsOnCall[i] = struct { result1 time.Time }{result1} } func (fake *FakeBuild) Events(arg1 uint) (db.EventSource, error) { fake.eventsMutex.Lock() ret, specificReturn := fake.eventsReturnsOnCall[len(fake.eventsArgsForCall)] fake.eventsArgsForCall = append(fake.eventsArgsForCall, struct { arg1 uint }{arg1}) fake.recordInvocation("Events", []interface{}{arg1}) fake.eventsMutex.Unlock() if fake.EventsStub != nil { return fake.EventsStub(arg1) } if specificReturn { return ret.result1, ret.result2 } fakeReturns := fake.eventsReturns return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeBuild) EventsCallCount() int { fake.eventsMutex.RLock() defer fake.eventsMutex.RUnlock() return len(fake.eventsArgsForCall) } func (fake *FakeBuild) EventsCalls(stub func(uint) (db.EventSource, error)) { fake.eventsMutex.Lock() defer fake.eventsMutex.Unlock() fake.EventsStub = stub } func (fake *FakeBuild) EventsArgsForCall(i int) uint { fake.eventsMutex.RLock() defer fake.eventsMutex.RUnlock() argsForCall := fake.eventsArgsForCall[i] return argsForCall.arg1 } func (fake *FakeBuild) EventsReturns(result1 db.EventSource, result2 error) { fake.eventsMutex.Lock() defer fake.eventsMutex.Unlock() fake.EventsStub = nil fake.eventsReturns = struct { result1 db.EventSource result2 error }{result1, result2} } func (fake *FakeBuild) EventsReturnsOnCall(i int, result1 db.EventSource, result2 error) { fake.eventsMutex.Lock() defer fake.eventsMutex.Unlock() fake.EventsStub = nil if fake.eventsReturnsOnCall == nil { fake.eventsReturnsOnCall = make(map[int]struct { result1 db.EventSource result2 error }) } fake.eventsReturnsOnCall[i] = struct { result1 db.EventSource result2 error }{result1, result2} } func (fake *FakeBuild) Finish(arg1 db.BuildStatus) error { fake.finishMutex.Lock() ret, specificReturn := fake.finishReturnsOnCall[len(fake.finishArgsForCall)] fake.finishArgsForCall = append(fake.finishArgsForCall, struct { arg1 db.BuildStatus }{arg1}) fake.recordInvocation("Finish", []interface{}{arg1}) fake.finishMutex.Unlock() if fake.FinishStub != nil { return fake.FinishStub(arg1) } if specificReturn { return ret.result1 } fakeReturns := fake.finishReturns return fakeReturns.result1 } func (fake *FakeBuild) FinishCallCount() int { fake.finishMutex.RLock() defer fake.finishMutex.RUnlock() return len(fake.finishArgsForCall) } func (fake *FakeBuild) FinishCalls(stub func(db.BuildStatus) error) { fake.finishMutex.Lock() defer fake.finishMutex.Unlock() fake.FinishStub = stub } func (fake *FakeBuild) FinishArgsForCall(i int) db.BuildStatus { fake.finishMutex.RLock() defer fake.finishMutex.RUnlock() argsForCall := fake.finishArgsForCall[i] return argsForCall.arg1 } func (fake *FakeBuild) FinishReturns(result1 error) { fake.finishMutex.Lock() defer fake.finishMutex.Unlock() fake.FinishStub = nil fake.finishReturns = struct { result1 error }{result1} } func (fake *FakeBuild) FinishReturnsOnCall(i int, result1 error) { fake.finishMutex.Lock() defer fake.finishMutex.Unlock() fake.FinishStub = nil if fake.finishReturnsOnCall == nil { fake.finishReturnsOnCall = make(map[int]struct { result1 error }) } fake.finishReturnsOnCall[i] = struct { result1 error }{result1} } func (fake *FakeBuild) HasPlan() bool { fake.hasPlanMutex.Lock() ret, specificReturn := fake.hasPlanReturnsOnCall[len(fake.hasPlanArgsForCall)] fake.hasPlanArgsForCall = append(fake.hasPlanArgsForCall, struct { }{}) fake.recordInvocation("HasPlan", []interface{}{}) fake.hasPlanMutex.Unlock() if fake.HasPlanStub != nil { return fake.HasPlanStub() } if specificReturn { return ret.result1 } fakeReturns := fake.hasPlanReturns return fakeReturns.result1 } func (fake *FakeBuild) HasPlanCallCount() int { fake.hasPlanMutex.RLock() defer fake.hasPlanMutex.RUnlock() return len(fake.hasPlanArgsForCall) } func (fake *FakeBuild) HasPlanCalls(stub func() bool) { fake.hasPlanMutex.Lock() defer fake.hasPlanMutex.Unlock() fake.HasPlanStub = stub } func (fake *FakeBuild) HasPlanReturns(result1 bool) { fake.hasPlanMutex.Lock() defer fake.hasPlanMutex.Unlock() fake.HasPlanStub = nil fake.hasPlanReturns = struct { result1 bool }{result1} } func (fake *FakeBuild) HasPlanReturnsOnCall(i int, result1 bool) { fake.hasPlanMutex.Lock() defer fake.hasPlanMutex.Unlock() fake.HasPlanStub = nil if fake.hasPlanReturnsOnCall == nil { fake.hasPlanReturnsOnCall = make(map[int]struct { result1 bool }) } fake.hasPlanReturnsOnCall[i] = struct { result1 bool }{result1} } func (fake *FakeBuild) ID() int { fake.iDMutex.Lock() ret, specificReturn := fake.iDReturnsOnCall[len(fake.iDArgsForCall)] fake.iDArgsForCall = append(fake.iDArgsForCall, struct { }{}) fake.recordInvocation("ID", []interface{}{}) fake.iDMutex.Unlock() if fake.IDStub != nil { return fake.IDStub() } if specificReturn { return ret.result1 } fakeReturns := fake.iDReturns return fakeReturns.result1 } func (fake *FakeBuild) IDCallCount() int { fake.iDMutex.RLock() defer fake.iDMutex.RUnlock() return len(fake.iDArgsForCall) } func (fake *FakeBuild) IDCalls(stub func() int) { fake.iDMutex.Lock() defer fake.iDMutex.Unlock() fake.IDStub = stub } func (fake *FakeBuild) IDReturns(result1 int) { fake.iDMutex.Lock() defer fake.iDMutex.Unlock() fake.IDStub = nil fake.iDReturns = struct { result1 int }{result1} } func (fake *FakeBuild) IDReturnsOnCall(i int, result1 int) { fake.iDMutex.Lock() defer fake.iDMutex.Unlock() fake.IDStub = nil if fake.iDReturnsOnCall == nil { fake.iDReturnsOnCall = make(map[int]struct { result1 int }) } fake.iDReturnsOnCall[i] = struct { result1 int }{result1} } func (fake *FakeBuild) InputsReady() bool { fake.inputsReadyMutex.Lock() ret, specificReturn := fake.inputsReadyReturnsOnCall[len(fake.inputsReadyArgsForCall)] fake.inputsReadyArgsForCall = append(fake.inputsReadyArgsForCall, struct { }{}) fake.recordInvocation("InputsReady", []interface{}{}) fake.inputsReadyMutex.Unlock() if fake.InputsReadyStub != nil { return fake.InputsReadyStub() } if specificReturn { return ret.result1 } fakeReturns := fake.inputsReadyReturns return fakeReturns.result1 } func (fake *FakeBuild) InputsReadyCallCount() int { fake.inputsReadyMutex.RLock() defer fake.inputsReadyMutex.RUnlock() return len(fake.inputsReadyArgsForCall) } func (fake *FakeBuild) InputsReadyCalls(stub func() bool) { fake.inputsReadyMutex.Lock() defer fake.inputsReadyMutex.Unlock() fake.InputsReadyStub = stub } func (fake *FakeBuild) InputsReadyReturns(result1 bool) { fake.inputsReadyMutex.Lock() defer fake.inputsReadyMutex.Unlock() fake.InputsReadyStub = nil fake.inputsReadyReturns = struct { result1 bool }{result1} } func (fake *FakeBuild) InputsReadyReturnsOnCall(i int, result1 bool) { fake.inputsReadyMutex.Lock() defer fake.inputsReadyMutex.Unlock() fake.InputsReadyStub = nil if fake.inputsReadyReturnsOnCall == nil { fake.inputsReadyReturnsOnCall = make(map[int]struct { result1 bool }) } fake.inputsReadyReturnsOnCall[i] = struct { result1 bool }{result1} } func (fake *FakeBuild) Interceptible() (bool, error) { fake.interceptibleMutex.Lock() ret, specificReturn := fake.interceptibleReturnsOnCall[len(fake.interceptibleArgsForCall)] fake.interceptibleArgsForCall = append(fake.interceptibleArgsForCall, struct { }{}) fake.recordInvocation("Interceptible", []interface{}{}) fake.interceptibleMutex.Unlock() if fake.InterceptibleStub != nil { return fake.InterceptibleStub() } if specificReturn { return ret.result1, ret.result2 } fakeReturns := fake.interceptibleReturns return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeBuild) InterceptibleCallCount() int { fake.interceptibleMutex.RLock() defer fake.interceptibleMutex.RUnlock() return len(fake.interceptibleArgsForCall) } func (fake *FakeBuild) InterceptibleCalls(stub func() (bool, error)) { fake.interceptibleMutex.Lock() defer fake.interceptibleMutex.Unlock() fake.InterceptibleStub = stub } func (fake *FakeBuild) InterceptibleReturns(result1 bool, result2 error) { fake.interceptibleMutex.Lock() defer fake.interceptibleMutex.Unlock() fake.InterceptibleStub = nil fake.interceptibleReturns = struct { result1 bool result2 error }{result1, result2} } func (fake *FakeBuild) InterceptibleReturnsOnCall(i int, result1 bool, result2 error) { fake.interceptibleMutex.Lock() defer fake.interceptibleMutex.Unlock() fake.InterceptibleStub = nil if fake.interceptibleReturnsOnCall == nil { fake.interceptibleReturnsOnCall = make(map[int]struct { result1 bool result2 error }) } fake.interceptibleReturnsOnCall[i] = struct { result1 bool result2 error }{result1, result2} } func (fake *FakeBuild) IsAborted() bool { fake.isAbortedMutex.Lock() ret, specificReturn := fake.isAbortedReturnsOnCall[len(fake.isAbortedArgsForCall)] fake.isAbortedArgsForCall = append(fake.isAbortedArgsForCall, struct { }{}) fake.recordInvocation("IsAborted", []interface{}{}) fake.isAbortedMutex.Unlock() if fake.IsAbortedStub != nil { return fake.IsAbortedStub() } if specificReturn { return ret.result1 } fakeReturns := fake.isAbortedReturns return fakeReturns.result1 } func (fake *FakeBuild) IsAbortedCallCount() int { fake.isAbortedMutex.RLock() defer fake.isAbortedMutex.RUnlock() return len(fake.isAbortedArgsForCall) } func (fake *FakeBuild) IsAbortedCalls(stub func() bool) { fake.isAbortedMutex.Lock() defer fake.isAbortedMutex.Unlock() fake.IsAbortedStub = stub } func (fake *FakeBuild) IsAbortedReturns(result1 bool) { fake.isAbortedMutex.Lock() defer fake.isAbortedMutex.Unlock() fake.IsAbortedStub = nil fake.isAbortedReturns = struct { result1 bool }{result1} } func (fake *FakeBuild) IsAbortedReturnsOnCall(i int, result1 bool) { fake.isAbortedMutex.Lock() defer fake.isAbortedMutex.Unlock() fake.IsAbortedStub = nil if fake.isAbortedReturnsOnCall == nil { fake.isAbortedReturnsOnCall = make(map[int]struct { result1 bool }) } fake.isAbortedReturnsOnCall[i] = struct { result1 bool }{result1} } func (fake *FakeBuild) IsCompleted() bool { fake.isCompletedMutex.Lock() ret, specificReturn := fake.isCompletedReturnsOnCall[len(fake.isCompletedArgsForCall)] fake.isCompletedArgsForCall = append(fake.isCompletedArgsForCall, struct { }{}) fake.recordInvocation("IsCompleted", []interface{}{}) fake.isCompletedMutex.Unlock() if fake.IsCompletedStub != nil { return fake.IsCompletedStub() } if specificReturn { return ret.result1 } fakeReturns := fake.isCompletedReturns return fakeReturns.result1 } func (fake *FakeBuild) IsCompletedCallCount() int { fake.isCompletedMutex.RLock() defer fake.isCompletedMutex.RUnlock() return len(fake.isCompletedArgsForCall) } func (fake *FakeBuild) IsCompletedCalls(stub func() bool) { fake.isCompletedMutex.Lock() defer fake.isCompletedMutex.Unlock() fake.IsCompletedStub = stub } func (fake *FakeBuild) IsCompletedReturns(result1 bool) { fake.isCompletedMutex.Lock() defer fake.isCompletedMutex.Unlock() fake.IsCompletedStub = nil fake.isCompletedReturns = struct { result1 bool }{result1} } func (fake *FakeBuild) IsCompletedReturnsOnCall(i int, result1 bool) { fake.isCompletedMutex.Lock() defer fake.isCompletedMutex.Unlock() fake.IsCompletedStub = nil if fake.isCompletedReturnsOnCall == nil { fake.isCompletedReturnsOnCall = make(map[int]struct { result1 bool }) } fake.isCompletedReturnsOnCall[i] = struct { result1 bool }{result1} } func (fake *FakeBuild) IsDrained() bool { fake.isDrainedMutex.Lock() ret, specificReturn := fake.isDrainedReturnsOnCall[len(fake.isDrainedArgsForCall)] fake.isDrainedArgsForCall = append(fake.isDrainedArgsForCall, struct { }{}) fake.recordInvocation("IsDrained", []interface{}{}) fake.isDrainedMutex.Unlock() if fake.IsDrainedStub != nil { return fake.IsDrainedStub() } if specificReturn { return ret.result1 } fakeReturns := fake.isDrainedReturns return fakeReturns.result1 } func (fake *FakeBuild) IsDrainedCallCount() int { fake.isDrainedMutex.RLock() defer fake.isDrainedMutex.RUnlock() return len(fake.isDrainedArgsForCall) } func (fake *FakeBuild) IsDrainedCalls(stub func() bool) { fake.isDrainedMutex.Lock() defer fake.isDrainedMutex.Unlock() fake.IsDrainedStub = stub } func (fake *FakeBuild) IsDrainedReturns(result1 bool) { fake.isDrainedMutex.Lock() defer fake.isDrainedMutex.Unlock() fake.IsDrainedStub = nil fake.isDrainedReturns = struct { result1 bool }{result1} } func (fake *FakeBuild) IsDrainedReturnsOnCall(i int, result1 bool) { fake.isDrainedMutex.Lock() defer fake.isDrainedMutex.Unlock() fake.IsDrainedStub = nil if fake.isDrainedReturnsOnCall == nil { fake.isDrainedReturnsOnCall = make(map[int]struct { result1 bool }) } fake.isDrainedReturnsOnCall[i] = struct { result1 bool }{result1} } func (fake *FakeBuild) IsManuallyTriggered() bool { fake.isManuallyTriggeredMutex.Lock() ret, specificReturn := fake.isManuallyTriggeredReturnsOnCall[len(fake.isManuallyTriggeredArgsForCall)] fake.isManuallyTriggeredArgsForCall = append(fake.isManuallyTriggeredArgsForCall, struct { }{}) fake.recordInvocation("IsManuallyTriggered", []interface{}{}) fake.isManuallyTriggeredMutex.Unlock() if fake.IsManuallyTriggeredStub != nil { return fake.IsManuallyTriggeredStub() } if specificReturn { return ret.result1 } fakeReturns := fake.isManuallyTriggeredReturns return fakeReturns.result1 } func (fake *FakeBuild) IsManuallyTriggeredCallCount() int { fake.isManuallyTriggeredMutex.RLock() defer fake.isManuallyTriggeredMutex.RUnlock() return len(fake.isManuallyTriggeredArgsForCall) } func (fake *FakeBuild) IsManuallyTriggeredCalls(stub func() bool) { fake.isManuallyTriggeredMutex.Lock() defer fake.isManuallyTriggeredMutex.Unlock() fake.IsManuallyTriggeredStub = stub } func (fake *FakeBuild) IsManuallyTriggeredReturns(result1 bool) { fake.isManuallyTriggeredMutex.Lock() defer fake.isManuallyTriggeredMutex.Unlock() fake.IsManuallyTriggeredStub = nil fake.isManuallyTriggeredReturns = struct { result1 bool }{result1} } func (fake *FakeBuild) IsManuallyTriggeredReturnsOnCall(i int, result1 bool) { fake.isManuallyTriggeredMutex.Lock() defer fake.isManuallyTriggeredMutex.Unlock() fake.IsManuallyTriggeredStub = nil if fake.isManuallyTriggeredReturnsOnCall == nil { fake.isManuallyTriggeredReturnsOnCall = make(map[int]struct { result1 bool }) } fake.isManuallyTriggeredReturnsOnCall[i] = struct { result1 bool }{result1} } func (fake *FakeBuild) IsNewerThanLastCheckOf(arg1 db.Resource) bool { fake.isNewerThanLastCheckOfMutex.Lock() ret, specificReturn := fake.isNewerThanLastCheckOfReturnsOnCall[len(fake.isNewerThanLastCheckOfArgsForCall)] fake.isNewerThanLastCheckOfArgsForCall = append(fake.isNewerThanLastCheckOfArgsForCall, struct { arg1 db.Resource }{arg1}) fake.recordInvocation("IsNewerThanLastCheckOf", []interface{}{arg1}) fake.isNewerThanLastCheckOfMutex.Unlock() if fake.IsNewerThanLastCheckOfStub != nil { return fake.IsNewerThanLastCheckOfStub(arg1) } if specificReturn { return ret.result1 } fakeReturns := fake.isNewerThanLastCheckOfReturns return fakeReturns.result1 } func (fake *FakeBuild) IsNewerThanLastCheckOfCallCount() int { fake.isNewerThanLastCheckOfMutex.RLock() defer fake.isNewerThanLastCheckOfMutex.RUnlock() return len(fake.isNewerThanLastCheckOfArgsForCall) } func (fake *FakeBuild) IsNewerThanLastCheckOfCalls(stub func(db.Resource) bool) { fake.isNewerThanLastCheckOfMutex.Lock() defer fake.isNewerThanLastCheckOfMutex.Unlock() fake.IsNewerThanLastCheckOfStub = stub } func (fake *FakeBuild) IsNewerThanLastCheckOfArgsForCall(i int) db.Resource { fake.isNewerThanLastCheckOfMutex.RLock() defer fake.isNewerThanLastCheckOfMutex.RUnlock() argsForCall := fake.isNewerThanLastCheckOfArgsForCall[i] return argsForCall.arg1 } func (fake *FakeBuild) IsNewerThanLastCheckOfReturns(result1 bool) { fake.isNewerThanLastCheckOfMutex.Lock() defer fake.isNewerThanLastCheckOfMutex.Unlock() fake.IsNewerThanLastCheckOfStub = nil fake.isNewerThanLastCheckOfReturns = struct { result1 bool }{result1} } func (fake *FakeBuild) IsNewerThanLastCheckOfReturnsOnCall(i int, result1 bool) { fake.isNewerThanLastCheckOfMutex.Lock() defer fake.isNewerThanLastCheckOfMutex.Unlock() fake.IsNewerThanLastCheckOfStub = nil if fake.isNewerThanLastCheckOfReturnsOnCall == nil { fake.isNewerThanLastCheckOfReturnsOnCall = make(map[int]struct { result1 bool }) } fake.isNewerThanLastCheckOfReturnsOnCall[i] = struct { result1 bool }{result1} } func (fake *FakeBuild) IsRunning() bool { fake.isRunningMutex.Lock() ret, specificReturn := fake.isRunningReturnsOnCall[len(fake.isRunningArgsForCall)] fake.isRunningArgsForCall = append(fake.isRunningArgsForCall, struct { }{}) fake.recordInvocation("IsRunning", []interface{}{}) fake.isRunningMutex.Unlock() if fake.IsRunningStub != nil { return fake.IsRunningStub() } if specificReturn { return ret.result1 } fakeReturns := fake.isRunningReturns return fakeReturns.result1 } func (fake *FakeBuild) IsRunningCallCount() int { fake.isRunningMutex.RLock() defer fake.isRunningMutex.RUnlock() return len(fake.isRunningArgsForCall) } func (fake *FakeBuild) IsRunningCalls(stub func() bool) { fake.isRunningMutex.Lock() defer fake.isRunningMutex.Unlock() fake.IsRunningStub = stub } func (fake *FakeBuild) IsRunningReturns(result1 bool) { fake.isRunningMutex.Lock() defer fake.isRunningMutex.Unlock() fake.IsRunningStub = nil fake.isRunningReturns = struct { result1 bool }{result1} } func (fake *FakeBuild) IsRunningReturnsOnCall(i int, result1 bool) { fake.isRunningMutex.Lock() defer fake.isRunningMutex.Unlock() fake.IsRunningStub = nil if fake.isRunningReturnsOnCall == nil { fake.isRunningReturnsOnCall = make(map[int]struct { result1 bool }) } fake.isRunningReturnsOnCall[i] = struct { result1 bool }{result1} } func (fake *FakeBuild) IsScheduled() bool { fake.isScheduledMutex.Lock() ret, specificReturn := fake.isScheduledReturnsOnCall[len(fake.isScheduledArgsForCall)] fake.isScheduledArgsForCall = append(fake.isScheduledArgsForCall, struct { }{}) fake.recordInvocation("IsScheduled", []interface{}{}) fake.isScheduledMutex.Unlock() if fake.IsScheduledStub != nil { return fake.IsScheduledStub() } if specificReturn { return ret.result1 } fakeReturns := fake.isScheduledReturns return fakeReturns.result1 } func (fake *FakeBuild) IsScheduledCallCount() int { fake.isScheduledMutex.RLock() defer fake.isScheduledMutex.RUnlock() return len(fake.isScheduledArgsForCall) } func (fake *FakeBuild) IsScheduledCalls(stub func() bool) { fake.isScheduledMutex.Lock() defer fake.isScheduledMutex.Unlock() fake.IsScheduledStub = stub } func (fake *FakeBuild) IsScheduledReturns(result1 bool) { fake.isScheduledMutex.Lock() defer fake.isScheduledMutex.Unlock() fake.IsScheduledStub = nil fake.isScheduledReturns = struct { result1 bool }{result1} } func (fake *FakeBuild) IsScheduledReturnsOnCall(i int, result1 bool) { fake.isScheduledMutex.Lock() defer fake.isScheduledMutex.Unlock() fake.IsScheduledStub = nil if fake.isScheduledReturnsOnCall == nil { fake.isScheduledReturnsOnCall = make(map[int]struct { result1 bool }) } fake.isScheduledReturnsOnCall[i] = struct { result1 bool }{result1} } func (fake *FakeBuild) JobID() int { fake.jobIDMutex.Lock() ret, specificReturn := fake.jobIDReturnsOnCall[len(fake.jobIDArgsForCall)] fake.jobIDArgsForCall = append(fake.jobIDArgsForCall, struct { }{}) fake.recordInvocation("JobID", []interface{}{}) fake.jobIDMutex.Unlock() if fake.JobIDStub != nil { return fake.JobIDStub() } if specificReturn { return ret.result1 } fakeReturns := fake.jobIDReturns return fakeReturns.result1 } func (fake *FakeBuild) JobIDCallCount() int { fake.jobIDMutex.RLock() defer fake.jobIDMutex.RUnlock() return len(fake.jobIDArgsForCall) } func (fake *FakeBuild) JobIDCalls(stub func() int) { fake.jobIDMutex.Lock() defer fake.jobIDMutex.Unlock() fake.JobIDStub = stub } func (fake *FakeBuild) JobIDReturns(result1 int) { fake.jobIDMutex.Lock() defer fake.jobIDMutex.Unlock() fake.JobIDStub = nil fake.jobIDReturns = struct { result1 int }{result1} } func (fake *FakeBuild) JobIDReturnsOnCall(i int, result1 int) { fake.jobIDMutex.Lock() defer fake.jobIDMutex.Unlock() fake.JobIDStub = nil if fake.jobIDReturnsOnCall == nil { fake.jobIDReturnsOnCall = make(map[int]struct { result1 int }) } fake.jobIDReturnsOnCall[i] = struct { result1 int }{result1} } func (fake *FakeBuild) JobName() string { fake.jobNameMutex.Lock() ret, specificReturn := fake.jobNameReturnsOnCall[len(fake.jobNameArgsForCall)] fake.jobNameArgsForCall = append(fake.jobNameArgsForCall, struct { }{}) fake.recordInvocation("JobName", []interface{}{}) fake.jobNameMutex.Unlock() if fake.JobNameStub != nil { return fake.JobNameStub() } if specificReturn { return ret.result1 } fakeReturns := fake.jobNameReturns return fakeReturns.result1 } func (fake *FakeBuild) JobNameCallCount() int { fake.jobNameMutex.RLock() defer fake.jobNameMutex.RUnlock() return len(fake.jobNameArgsForCall) } func (fake *FakeBuild) JobNameCalls(stub func() string) { fake.jobNameMutex.Lock() defer fake.jobNameMutex.Unlock() fake.JobNameStub = stub } func (fake *FakeBuild) JobNameReturns(result1 string) { fake.jobNameMutex.Lock() defer fake.jobNameMutex.Unlock() fake.JobNameStub = nil fake.jobNameReturns = struct { result1 string }{result1} } func (fake *FakeBuild) JobNameReturnsOnCall(i int, result1 string) { fake.jobNameMutex.Lock() defer fake.jobNameMutex.Unlock() fake.JobNameStub = nil if fake.jobNameReturnsOnCall == nil { fake.jobNameReturnsOnCall = make(map[int]struct { result1 string }) } fake.jobNameReturnsOnCall[i] = struct { result1 string }{result1} } func (fake *FakeBuild) MarkAsAborted() error { fake.markAsAbortedMutex.Lock() ret, specificReturn := fake.markAsAbortedReturnsOnCall[len(fake.markAsAbortedArgsForCall)] fake.markAsAbortedArgsForCall = append(fake.markAsAbortedArgsForCall, struct { }{}) fake.recordInvocation("MarkAsAborted", []interface{}{}) fake.markAsAbortedMutex.Unlock() if fake.MarkAsAbortedStub != nil { return fake.MarkAsAbortedStub() } if specificReturn { return ret.result1 } fakeReturns := fake.markAsAbortedReturns return fakeReturns.result1 } func (fake *FakeBuild) MarkAsAbortedCallCount() int { fake.markAsAbortedMutex.RLock() defer fake.markAsAbortedMutex.RUnlock() return len(fake.markAsAbortedArgsForCall) } func (fake *FakeBuild) MarkAsAbortedCalls(stub func() error) { fake.markAsAbortedMutex.Lock() defer fake.markAsAbortedMutex.Unlock() fake.MarkAsAbortedStub = stub } func (fake *FakeBuild) MarkAsAbortedReturns(result1 error) { fake.markAsAbortedMutex.Lock() defer fake.markAsAbortedMutex.Unlock() fake.MarkAsAbortedStub = nil fake.markAsAbortedReturns = struct { result1 error }{result1} } func (fake *FakeBuild) MarkAsAbortedReturnsOnCall(i int, result1 error) { fake.markAsAbortedMutex.Lock() defer fake.markAsAbortedMutex.Unlock() fake.MarkAsAbortedStub = nil if fake.markAsAbortedReturnsOnCall == nil { fake.markAsAbortedReturnsOnCall = make(map[int]struct { result1 error }) } fake.markAsAbortedReturnsOnCall[i] = struct { result1 error }{result1} } func (fake *FakeBuild) Name() string { fake.nameMutex.Lock() ret, specificReturn := fake.nameReturnsOnCall[len(fake.nameArgsForCall)] fake.nameArgsForCall = append(fake.nameArgsForCall, struct { }{}) fake.recordInvocation("Name", []interface{}{}) fake.nameMutex.Unlock() if fake.NameStub != nil { return fake.NameStub() } if specificReturn { return ret.result1 } fakeReturns := fake.nameReturns return fakeReturns.result1 } func (fake *FakeBuild) NameCallCount() int { fake.nameMutex.RLock() defer fake.nameMutex.RUnlock() return len(fake.nameArgsForCall) } func (fake *FakeBuild) NameCalls(stub func() string) { fake.nameMutex.Lock() defer fake.nameMutex.Unlock() fake.NameStub = stub } func (fake *FakeBuild) NameReturns(result1 string) { fake.nameMutex.Lock() defer fake.nameMutex.Unlock() fake.NameStub = nil fake.nameReturns = struct { result1 string }{result1} } func (fake *FakeBuild) NameReturnsOnCall(i int, result1 string) { fake.nameMutex.Lock() defer fake.nameMutex.Unlock() fake.NameStub = nil if fake.nameReturnsOnCall == nil { fake.nameReturnsOnCall = make(map[int]struct { result1 string }) } fake.nameReturnsOnCall[i] = struct { result1 string }{result1} } func (fake *FakeBuild) Pipeline() (db.Pipeline, bool, error) { fake.pipelineMutex.Lock() ret, specificReturn := fake.pipelineReturnsOnCall[len(fake.pipelineArgsForCall)] fake.pipelineArgsForCall = append(fake.pipelineArgsForCall, struct { }{}) fake.recordInvocation("Pipeline", []interface{}{}) fake.pipelineMutex.Unlock() if fake.PipelineStub != nil { return fake.PipelineStub() } if specificReturn { return ret.result1, ret.result2, ret.result3 } fakeReturns := fake.pipelineReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } func (fake *FakeBuild) PipelineCallCount() int { fake.pipelineMutex.RLock() defer fake.pipelineMutex.RUnlock() return len(fake.pipelineArgsForCall) } func (fake *FakeBuild) PipelineCalls(stub func() (db.Pipeline, bool, error)) { fake.pipelineMutex.Lock() defer fake.pipelineMutex.Unlock() fake.PipelineStub = stub } func (fake *FakeBuild) PipelineReturns(result1 db.Pipeline, result2 bool, result3 error) { fake.pipelineMutex.Lock() defer fake.pipelineMutex.Unlock() fake.PipelineStub = nil fake.pipelineReturns = struct { result1 db.Pipeline result2 bool result3 error }{result1, result2, result3} } func (fake *FakeBuild) PipelineReturnsOnCall(i int, result1 db.Pipeline, result2 bool, result3 error) { fake.pipelineMutex.Lock() defer fake.pipelineMutex.Unlock() fake.PipelineStub = nil if fake.pipelineReturnsOnCall == nil { fake.pipelineReturnsOnCall = make(map[int]struct { result1 db.Pipeline result2 bool result3 error }) } fake.pipelineReturnsOnCall[i] = struct { result1 db.Pipeline result2 bool result3 error }{result1, result2, result3} } func (fake *FakeBuild) PipelineID() int { fake.pipelineIDMutex.Lock() ret, specificReturn := fake.pipelineIDReturnsOnCall[len(fake.pipelineIDArgsForCall)] fake.pipelineIDArgsForCall = append(fake.pipelineIDArgsForCall, struct { }{}) fake.recordInvocation("PipelineID", []interface{}{}) fake.pipelineIDMutex.Unlock() if fake.PipelineIDStub != nil { return fake.PipelineIDStub() } if specificReturn { return ret.result1 } fakeReturns := fake.pipelineIDReturns return fakeReturns.result1 } func (fake *FakeBuild) PipelineIDCallCount() int { fake.pipelineIDMutex.RLock() defer fake.pipelineIDMutex.RUnlock() return len(fake.pipelineIDArgsForCall) } func (fake *FakeBuild) PipelineIDCalls(stub func() int) { fake.pipelineIDMutex.Lock() defer fake.pipelineIDMutex.Unlock() fake.PipelineIDStub = stub } func (fake *FakeBuild) PipelineIDReturns(result1 int) { fake.pipelineIDMutex.Lock() defer fake.pipelineIDMutex.Unlock() fake.PipelineIDStub = nil fake.pipelineIDReturns = struct { result1 int }{result1} } func (fake *FakeBuild) PipelineIDReturnsOnCall(i int, result1 int) { fake.pipelineIDMutex.Lock() defer fake.pipelineIDMutex.Unlock() fake.PipelineIDStub = nil if fake.pipelineIDReturnsOnCall == nil { fake.pipelineIDReturnsOnCall = make(map[int]struct { result1 int }) } fake.pipelineIDReturnsOnCall[i] = struct { result1 int }{result1} } func (fake *FakeBuild) PipelineName() string { fake.pipelineNameMutex.Lock() ret, specificReturn := fake.pipelineNameReturnsOnCall[len(fake.pipelineNameArgsForCall)] fake.pipelineNameArgsForCall = append(fake.pipelineNameArgsForCall, struct { }{}) fake.recordInvocation("PipelineName", []interface{}{}) fake.pipelineNameMutex.Unlock() if fake.PipelineNameStub != nil { return fake.PipelineNameStub() } if specificReturn { return ret.result1 } fakeReturns := fake.pipelineNameReturns return fakeReturns.result1 } func (fake *FakeBuild) PipelineNameCallCount() int { fake.pipelineNameMutex.RLock() defer fake.pipelineNameMutex.RUnlock() return len(fake.pipelineNameArgsForCall) } func (fake *FakeBuild) PipelineNameCalls(stub func() string) { fake.pipelineNameMutex.Lock() defer fake.pipelineNameMutex.Unlock() fake.PipelineNameStub = stub } func (fake *FakeBuild) PipelineNameReturns(result1 string) { fake.pipelineNameMutex.Lock() defer fake.pipelineNameMutex.Unlock() fake.PipelineNameStub = nil fake.pipelineNameReturns = struct { result1 string }{result1} } func (fake *FakeBuild) PipelineNameReturnsOnCall(i int, result1 string) { fake.pipelineNameMutex.Lock() defer fake.pipelineNameMutex.Unlock() fake.PipelineNameStub = nil if fake.pipelineNameReturnsOnCall == nil { fake.pipelineNameReturnsOnCall = make(map[int]struct { result1 string }) } fake.pipelineNameReturnsOnCall[i] = struct { result1 string }{result1} } func (fake *FakeBuild) Preparation() (db.BuildPreparation, bool, error) { fake.preparationMutex.Lock() ret, specificReturn := fake.preparationReturnsOnCall[len(fake.preparationArgsForCall)] fake.preparationArgsForCall = append(fake.preparationArgsForCall, struct { }{}) fake.recordInvocation("Preparation", []interface{}{}) fake.preparationMutex.Unlock() if fake.PreparationStub != nil { return fake.PreparationStub() } if specificReturn { return ret.result1, ret.result2, ret.result3 } fakeReturns := fake.preparationReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } func (fake *FakeBuild) PreparationCallCount() int { fake.preparationMutex.RLock() defer fake.preparationMutex.RUnlock() return len(fake.preparationArgsForCall) } func (fake *FakeBuild) PreparationCalls(stub func() (db.BuildPreparation, bool, error)) { fake.preparationMutex.Lock() defer fake.preparationMutex.Unlock() fake.PreparationStub = stub } func (fake *FakeBuild) PreparationReturns(result1 db.BuildPreparation, result2 bool, result3 error) { fake.preparationMutex.Lock() defer fake.preparationMutex.Unlock() fake.PreparationStub = nil fake.preparationReturns = struct { result1 db.BuildPreparation result2 bool result3 error }{result1, result2, result3} } func (fake *FakeBuild) PreparationReturnsOnCall(i int, result1 db.BuildPreparation, result2 bool, result3 error) { fake.preparationMutex.Lock() defer fake.preparationMutex.Unlock() fake.PreparationStub = nil if fake.preparationReturnsOnCall == nil { fake.preparationReturnsOnCall = make(map[int]struct { result1 db.BuildPreparation result2 bool result3 error }) } fake.preparationReturnsOnCall[i] = struct { result1 db.BuildPreparation result2 bool result3 error }{result1, result2, result3} } func (fake *FakeBuild) PrivatePlan() atc.Plan { fake.privatePlanMutex.Lock() ret, specificReturn := fake.privatePlanReturnsOnCall[len(fake.privatePlanArgsForCall)] fake.privatePlanArgsForCall = append(fake.privatePlanArgsForCall, struct { }{}) fake.recordInvocation("PrivatePlan", []interface{}{}) fake.privatePlanMutex.Unlock() if fake.PrivatePlanStub != nil { return fake.PrivatePlanStub() } if specificReturn { return ret.result1 } fakeReturns := fake.privatePlanReturns return fakeReturns.result1 } func (fake *FakeBuild) PrivatePlanCallCount() int { fake.privatePlanMutex.RLock() defer fake.privatePlanMutex.RUnlock() return len(fake.privatePlanArgsForCall) } func (fake *FakeBuild) PrivatePlanCalls(stub func() atc.Plan) { fake.privatePlanMutex.Lock() defer fake.privatePlanMutex.Unlock() fake.PrivatePlanStub = stub } func (fake *FakeBuild) PrivatePlanReturns(result1 atc.Plan) { fake.privatePlanMutex.Lock() defer fake.privatePlanMutex.Unlock() fake.PrivatePlanStub = nil fake.privatePlanReturns = struct { result1 atc.Plan }{result1} } func (fake *FakeBuild) PrivatePlanReturnsOnCall(i int, result1 atc.Plan) { fake.privatePlanMutex.Lock() defer fake.privatePlanMutex.Unlock() fake.PrivatePlanStub = nil if fake.privatePlanReturnsOnCall == nil { fake.privatePlanReturnsOnCall = make(map[int]struct { result1 atc.Plan }) } fake.privatePlanReturnsOnCall[i] = struct { result1 atc.Plan }{result1} } func (fake *FakeBuild) PublicPlan() *json.RawMessage { fake.publicPlanMutex.Lock() ret, specificReturn := fake.publicPlanReturnsOnCall[len(fake.publicPlanArgsForCall)] fake.publicPlanArgsForCall = append(fake.publicPlanArgsForCall, struct { }{}) fake.recordInvocation("PublicPlan", []interface{}{}) fake.publicPlanMutex.Unlock() if fake.PublicPlanStub != nil { return fake.PublicPlanStub() } if specificReturn { return ret.result1 } fakeReturns := fake.publicPlanReturns return fakeReturns.result1 } func (fake *FakeBuild) PublicPlanCallCount() int { fake.publicPlanMutex.RLock() defer fake.publicPlanMutex.RUnlock() return len(fake.publicPlanArgsForCall) } func (fake *FakeBuild) PublicPlanCalls(stub func() *json.RawMessage) { fake.publicPlanMutex.Lock() defer fake.publicPlanMutex.Unlock() fake.PublicPlanStub = stub } func (fake *FakeBuild) PublicPlanReturns(result1 *json.RawMessage) { fake.publicPlanMutex.Lock() defer fake.publicPlanMutex.Unlock() fake.PublicPlanStub = nil fake.publicPlanReturns = struct { result1 *json.RawMessage }{result1} } func (fake *FakeBuild) PublicPlanReturnsOnCall(i int, result1 *json.RawMessage) { fake.publicPlanMutex.Lock() defer fake.publicPlanMutex.Unlock() fake.PublicPlanStub = nil if fake.publicPlanReturnsOnCall == nil { fake.publicPlanReturnsOnCall = make(map[int]struct { result1 *json.RawMessage }) } fake.publicPlanReturnsOnCall[i] = struct { result1 *json.RawMessage }{result1} } func (fake *FakeBuild) ReapTime() time.Time { fake.reapTimeMutex.Lock() ret, specificReturn := fake.reapTimeReturnsOnCall[len(fake.reapTimeArgsForCall)] fake.reapTimeArgsForCall = append(fake.reapTimeArgsForCall, struct { }{}) fake.recordInvocation("ReapTime", []interface{}{}) fake.reapTimeMutex.Unlock() if fake.ReapTimeStub != nil { return fake.ReapTimeStub() } if specificReturn { return ret.result1 } fakeReturns := fake.reapTimeReturns return fakeReturns.result1 } func (fake *FakeBuild) ReapTimeCallCount() int { fake.reapTimeMutex.RLock() defer fake.reapTimeMutex.RUnlock() return len(fake.reapTimeArgsForCall) } func (fake *FakeBuild) ReapTimeCalls(stub func() time.Time) { fake.reapTimeMutex.Lock() defer fake.reapTimeMutex.Unlock() fake.ReapTimeStub = stub } func (fake *FakeBuild) ReapTimeReturns(result1 time.Time) { fake.reapTimeMutex.Lock() defer fake.reapTimeMutex.Unlock() fake.ReapTimeStub = nil fake.reapTimeReturns = struct { result1 time.Time }{result1} } func (fake *FakeBuild) ReapTimeReturnsOnCall(i int, result1 time.Time) { fake.reapTimeMutex.Lock() defer fake.reapTimeMutex.Unlock() fake.ReapTimeStub = nil if fake.reapTimeReturnsOnCall == nil { fake.reapTimeReturnsOnCall = make(map[int]struct { result1 time.Time }) } fake.reapTimeReturnsOnCall[i] = struct { result1 time.Time }{result1} } func (fake *FakeBuild) Reload() (bool, error) { fake.reloadMutex.Lock() ret, specificReturn := fake.reloadReturnsOnCall[len(fake.reloadArgsForCall)] fake.reloadArgsForCall = append(fake.reloadArgsForCall, struct { }{}) fake.recordInvocation("Reload", []interface{}{}) fake.reloadMutex.Unlock() if fake.ReloadStub != nil { return fake.ReloadStub() } if specificReturn { return ret.result1, ret.result2 } fakeReturns := fake.reloadReturns return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeBuild) ReloadCallCount() int { fake.reloadMutex.RLock() defer fake.reloadMutex.RUnlock() return len(fake.reloadArgsForCall) } func (fake *FakeBuild) ReloadCalls(stub func() (bool, error)) { fake.reloadMutex.Lock() defer fake.reloadMutex.Unlock() fake.ReloadStub = stub } func (fake *FakeBuild) ReloadReturns(result1 bool, result2 error) { fake.reloadMutex.Lock() defer fake.reloadMutex.Unlock() fake.ReloadStub = nil fake.reloadReturns = struct { result1 bool result2 error }{result1, result2} } func (fake *FakeBuild) ReloadReturnsOnCall(i int, result1 bool, result2 error) { fake.reloadMutex.Lock() defer fake.reloadMutex.Unlock() fake.ReloadStub = nil if fake.reloadReturnsOnCall == nil { fake.reloadReturnsOnCall = make(map[int]struct { result1 bool result2 error }) } fake.reloadReturnsOnCall[i] = struct { result1 bool result2 error }{result1, result2} } func (fake *FakeBuild) RerunNumber() int { fake.rerunNumberMutex.Lock() ret, specificReturn := fake.rerunNumberReturnsOnCall[len(fake.rerunNumberArgsForCall)] fake.rerunNumberArgsForCall = append(fake.rerunNumberArgsForCall, struct { }{}) fake.recordInvocation("RerunNumber", []interface{}{}) fake.rerunNumberMutex.Unlock() if fake.RerunNumberStub != nil { return fake.RerunNumberStub() } if specificReturn { return ret.result1 } fakeReturns := fake.rerunNumberReturns return fakeReturns.result1 } func (fake *FakeBuild) RerunNumberCallCount() int { fake.rerunNumberMutex.RLock() defer fake.rerunNumberMutex.RUnlock() return len(fake.rerunNumberArgsForCall) } func (fake *FakeBuild) RerunNumberCalls(stub func() int) { fake.rerunNumberMutex.Lock() defer fake.rerunNumberMutex.Unlock() fake.RerunNumberStub = stub } func (fake *FakeBuild) RerunNumberReturns(result1 int) { fake.rerunNumberMutex.Lock() defer fake.rerunNumberMutex.Unlock() fake.RerunNumberStub = nil fake.rerunNumberReturns = struct { result1 int }{result1} } func (fake *FakeBuild) RerunNumberReturnsOnCall(i int, result1 int) { fake.rerunNumberMutex.Lock() defer fake.rerunNumberMutex.Unlock() fake.RerunNumberStub = nil if fake.rerunNumberReturnsOnCall == nil { fake.rerunNumberReturnsOnCall = make(map[int]struct { result1 int }) } fake.rerunNumberReturnsOnCall[i] = struct { result1 int }{result1} } func (fake *FakeBuild) RerunOf() int { fake.rerunOfMutex.Lock() ret, specificReturn := fake.rerunOfReturnsOnCall[len(fake.rerunOfArgsForCall)] fake.rerunOfArgsForCall = append(fake.rerunOfArgsForCall, struct { }{}) fake.recordInvocation("RerunOf", []interface{}{}) fake.rerunOfMutex.Unlock() if fake.RerunOfStub != nil { return fake.RerunOfStub() } if specificReturn { return ret.result1 } fakeReturns := fake.rerunOfReturns return fakeReturns.result1 } func (fake *FakeBuild) RerunOfCallCount() int { fake.rerunOfMutex.RLock() defer fake.rerunOfMutex.RUnlock() return len(fake.rerunOfArgsForCall) } func (fake *FakeBuild) RerunOfCalls(stub func() int) { fake.rerunOfMutex.Lock() defer fake.rerunOfMutex.Unlock() fake.RerunOfStub = stub } func (fake *FakeBuild) RerunOfReturns(result1 int) { fake.rerunOfMutex.Lock() defer fake.rerunOfMutex.Unlock() fake.RerunOfStub = nil fake.rerunOfReturns = struct { result1 int }{result1} } func (fake *FakeBuild) RerunOfReturnsOnCall(i int, result1 int) { fake.rerunOfMutex.Lock() defer fake.rerunOfMutex.Unlock() fake.RerunOfStub = nil if fake.rerunOfReturnsOnCall == nil { fake.rerunOfReturnsOnCall = make(map[int]struct { result1 int }) } fake.rerunOfReturnsOnCall[i] = struct { result1 int }{result1} } func (fake *FakeBuild) RerunOfName() string { fake.rerunOfNameMutex.Lock() ret, specificReturn := fake.rerunOfNameReturnsOnCall[len(fake.rerunOfNameArgsForCall)] fake.rerunOfNameArgsForCall = append(fake.rerunOfNameArgsForCall, struct { }{}) fake.recordInvocation("RerunOfName", []interface{}{}) fake.rerunOfNameMutex.Unlock() if fake.RerunOfNameStub != nil { return fake.RerunOfNameStub() } if specificReturn { return ret.result1 } fakeReturns := fake.rerunOfNameReturns return fakeReturns.result1 } func (fake *FakeBuild) RerunOfNameCallCount() int { fake.rerunOfNameMutex.RLock() defer fake.rerunOfNameMutex.RUnlock() return len(fake.rerunOfNameArgsForCall) } func (fake *FakeBuild) RerunOfNameCalls(stub func() string) { fake.rerunOfNameMutex.Lock() defer fake.rerunOfNameMutex.Unlock() fake.RerunOfNameStub = stub } func (fake *FakeBuild) RerunOfNameReturns(result1 string) { fake.rerunOfNameMutex.Lock() defer fake.rerunOfNameMutex.Unlock() fake.RerunOfNameStub = nil fake.rerunOfNameReturns = struct { result1 string }{result1} } func (fake *FakeBuild) RerunOfNameReturnsOnCall(i int, result1 string) { fake.rerunOfNameMutex.Lock() defer fake.rerunOfNameMutex.Unlock() fake.RerunOfNameStub = nil if fake.rerunOfNameReturnsOnCall == nil { fake.rerunOfNameReturnsOnCall = make(map[int]struct { result1 string }) } fake.rerunOfNameReturnsOnCall[i] = struct { result1 string }{result1} } func (fake *FakeBuild) Resources() ([]db.BuildInput, []db.BuildOutput, error) { fake.resourcesMutex.Lock() ret, specificReturn := fake.resourcesReturnsOnCall[len(fake.resourcesArgsForCall)] fake.resourcesArgsForCall = append(fake.resourcesArgsForCall, struct { }{}) fake.recordInvocation("Resources", []interface{}{}) fake.resourcesMutex.Unlock() if fake.ResourcesStub != nil { return fake.ResourcesStub() } if specificReturn { return ret.result1, ret.result2, ret.result3 } fakeReturns := fake.resourcesReturns return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } func (fake *FakeBuild) ResourcesCallCount() int { fake.resourcesMutex.RLock() defer fake.resourcesMutex.RUnlock() return len(fake.resourcesArgsForCall) } func (fake *FakeBuild) ResourcesCalls(stub func() ([]db.BuildInput, []db.BuildOutput, error)) { fake.resourcesMutex.Lock() defer fake.resourcesMutex.Unlock() fake.ResourcesStub = stub } func (fake *FakeBuild) ResourcesReturns(result1 []db.BuildInput, result2 []db.BuildOutput, result3 error) { fake.resourcesMutex.Lock() defer fake.resourcesMutex.Unlock() fake.ResourcesStub = nil fake.resourcesReturns = struct { result1 []db.BuildInput result2 []db.BuildOutput result3 error }{result1, result2, result3} } func (fake *FakeBuild) ResourcesReturnsOnCall(i int, result1 []db.BuildInput, result2 []db.BuildOutput, result3 error) { fake.resourcesMutex.Lock() defer fake.resourcesMutex.Unlock() fake.ResourcesStub = nil if fake.resourcesReturnsOnCall == nil { fake.resourcesReturnsOnCall = make(map[int]struct { result1 []db.BuildInput result2 []db.BuildOutput result3 error }) } fake.resourcesReturnsOnCall[i] = struct { result1 []db.BuildInput result2 []db.BuildOutput result3 error }{result1, result2, result3} } func (fake *FakeBuild) ResourcesChecked() (bool, error) { fake.resourcesCheckedMutex.Lock() ret, specificReturn := fake.resourcesCheckedReturnsOnCall[len(fake.resourcesCheckedArgsForCall)] fake.resourcesCheckedArgsForCall = append(fake.resourcesCheckedArgsForCall, struct { }{}) fake.recordInvocation("ResourcesChecked", []interface{}{}) fake.resourcesCheckedMutex.Unlock() if fake.ResourcesCheckedStub != nil { return fake.ResourcesCheckedStub() } if specificReturn { return ret.result1, ret.result2 } fakeReturns := fake.resourcesCheckedReturns return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeBuild) ResourcesCheckedCallCount() int { fake.resourcesCheckedMutex.RLock() defer fake.resourcesCheckedMutex.RUnlock() return len(fake.resourcesCheckedArgsForCall) } func (fake *FakeBuild) ResourcesCheckedCalls(stub func() (bool, error)) { fake.resourcesCheckedMutex.Lock() defer fake.resourcesCheckedMutex.Unlock() fake.ResourcesCheckedStub = stub } func (fake *FakeBuild) ResourcesCheckedReturns(result1 bool, result2 error) { fake.resourcesCheckedMutex.Lock() defer fake.resourcesCheckedMutex.Unlock() fake.ResourcesCheckedStub = nil fake.resourcesCheckedReturns = struct { result1 bool result2 error }{result1, result2} } func (fake *FakeBuild) ResourcesCheckedReturnsOnCall(i int, result1 bool, result2 error) { fake.resourcesCheckedMutex.Lock() defer fake.resourcesCheckedMutex.Unlock() fake.ResourcesCheckedStub = nil if fake.resourcesCheckedReturnsOnCall == nil { fake.resourcesCheckedReturnsOnCall = make(map[int]struct { result1 bool result2 error }) } fake.resourcesCheckedReturnsOnCall[i] = struct { result1 bool result2 error }{result1, result2} } func (fake *FakeBuild) SaveEvent(arg1 atc.Event) error { fake.saveEventMutex.Lock() ret, specificReturn := fake.saveEventReturnsOnCall[len(fake.saveEventArgsForCall)] fake.saveEventArgsForCall = append(fake.saveEventArgsForCall, struct { arg1 atc.Event }{arg1}) fake.recordInvocation("SaveEvent", []interface{}{arg1}) fake.saveEventMutex.Unlock() if fake.SaveEventStub != nil { return fake.SaveEventStub(arg1) } if specificReturn { return ret.result1 } fakeReturns := fake.saveEventReturns return fakeReturns.result1 } func (fake *FakeBuild) SaveEventCallCount() int { fake.saveEventMutex.RLock() defer fake.saveEventMutex.RUnlock() return len(fake.saveEventArgsForCall) } func (fake *FakeBuild) SaveEventCalls(stub func(atc.Event) error) { fake.saveEventMutex.Lock() defer fake.saveEventMutex.Unlock() fake.SaveEventStub = stub } func (fake *FakeBuild) SaveEventArgsForCall(i int) atc.Event { fake.saveEventMutex.RLock() defer fake.saveEventMutex.RUnlock() argsForCall := fake.saveEventArgsForCall[i] return argsForCall.arg1 } func (fake *FakeBuild) SaveEventReturns(result1 error) { fake.saveEventMutex.Lock() defer fake.saveEventMutex.Unlock() fake.SaveEventStub = nil fake.saveEventReturns = struct { result1 error }{result1} } func (fake *FakeBuild) SaveEventReturnsOnCall(i int, result1 error) { fake.saveEventMutex.Lock() defer fake.saveEventMutex.Unlock() fake.SaveEventStub = nil if fake.saveEventReturnsOnCall == nil { fake.saveEventReturnsOnCall = make(map[int]struct { result1 error }) } fake.saveEventReturnsOnCall[i] = struct { result1 error }{result1} } func (fake *FakeBuild) SaveImageResourceVersion(arg1 db.UsedResourceCache) error { fake.saveImageResourceVersionMutex.Lock() ret, specificReturn := fake.saveImageResourceVersionReturnsOnCall[len(fake.saveImageResourceVersionArgsForCall)] fake.saveImageResourceVersionArgsForCall = append(fake.saveImageResourceVersionArgsForCall, struct { arg1 db.UsedResourceCache }{arg1}) fake.recordInvocation("SaveImageResourceVersion", []interface{}{arg1}) fake.saveImageResourceVersionMutex.Unlock() if fake.SaveImageResourceVersionStub != nil { return fake.SaveImageResourceVersionStub(arg1) } if specificReturn { return ret.result1 } fakeReturns := fake.saveImageResourceVersionReturns return fakeReturns.result1 } func (fake *FakeBuild) SaveImageResourceVersionCallCount() int { fake.saveImageResourceVersionMutex.RLock() defer fake.saveImageResourceVersionMutex.RUnlock() return len(fake.saveImageResourceVersionArgsForCall) } func (fake *FakeBuild) SaveImageResourceVersionCalls(stub func(db.UsedResourceCache) error) { fake.saveImageResourceVersionMutex.Lock() defer fake.saveImageResourceVersionMutex.Unlock() fake.SaveImageResourceVersionStub = stub } func (fake *FakeBuild) SaveImageResourceVersionArgsForCall(i int) db.UsedResourceCache { fake.saveImageResourceVersionMutex.RLock() defer fake.saveImageResourceVersionMutex.RUnlock() argsForCall := fake.saveImageResourceVersionArgsForCall[i] return argsForCall.arg1 } func (fake *FakeBuild) SaveImageResourceVersionReturns(result1 error) { fake.saveImageResourceVersionMutex.Lock() defer fake.saveImageResourceVersionMutex.Unlock() fake.SaveImageResourceVersionStub = nil fake.saveImageResourceVersionReturns = struct { result1 error }{result1} } func (fake *FakeBuild) SaveImageResourceVersionReturnsOnCall(i int, result1 error) { fake.saveImageResourceVersionMutex.Lock() defer fake.saveImageResourceVersionMutex.Unlock() fake.SaveImageResourceVersionStub = nil if fake.saveImageResourceVersionReturnsOnCall == nil { fake.saveImageResourceVersionReturnsOnCall = make(map[int]struct { result1 error }) } fake.saveImageResourceVersionReturnsOnCall[i] = struct { result1 error }{result1} } func (fake *FakeBuild) SaveOutput(arg1 string, arg2 atc.Source, arg3 atc.VersionedResourceTypes, arg4 atc.Version, arg5 db.ResourceConfigMetadataFields, arg6 string, arg7 string) error { fake.saveOutputMutex.Lock() ret, specificReturn := fake.saveOutputReturnsOnCall[len(fake.saveOutputArgsForCall)] fake.saveOutputArgsForCall = append(fake.saveOutputArgsForCall, struct { arg1 string arg2 atc.Source arg3 atc.VersionedResourceTypes arg4 atc.Version arg5 db.ResourceConfigMetadataFields arg6 string arg7 string }{arg1, arg2, arg3, arg4, arg5, arg6, arg7}) fake.recordInvocation("SaveOutput", []interface{}{arg1, arg2, arg3, arg4, arg5, arg6, arg7}) fake.saveOutputMutex.Unlock() if fake.SaveOutputStub != nil { return fake.SaveOutputStub(arg1, arg2, arg3, arg4, arg5, arg6, arg7) } if specificReturn { return ret.result1 } fakeReturns := fake.saveOutputReturns return fakeReturns.result1 } func (fake *FakeBuild) SaveOutputCallCount() int { fake.saveOutputMutex.RLock() defer fake.saveOutputMutex.RUnlock() return len(fake.saveOutputArgsForCall) } func (fake *FakeBuild) SaveOutputCalls(stub func(string, atc.Source, atc.VersionedResourceTypes, atc.Version, db.ResourceConfigMetadataFields, string, string) error) { fake.saveOutputMutex.Lock() defer fake.saveOutputMutex.Unlock() fake.SaveOutputStub = stub } func (fake *FakeBuild) SaveOutputArgsForCall(i int) (string, atc.Source, atc.VersionedResourceTypes, atc.Version, db.ResourceConfigMetadataFields, string, string) { fake.saveOutputMutex.RLock() defer fake.saveOutputMutex.RUnlock() argsForCall := fake.saveOutputArgsForCall[i] return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5, argsForCall.arg6, argsForCall.arg7 } func (fake *FakeBuild) SaveOutputReturns(result1 error) { fake.saveOutputMutex.Lock() defer fake.saveOutputMutex.Unlock() fake.SaveOutputStub = nil fake.saveOutputReturns = struct { result1 error }{result1} } func (fake *FakeBuild) SaveOutputReturnsOnCall(i int, result1 error) { fake.saveOutputMutex.Lock() defer fake.saveOutputMutex.Unlock() fake.SaveOutputStub = nil if fake.saveOutputReturnsOnCall == nil { fake.saveOutputReturnsOnCall = make(map[int]struct { result1 error }) } fake.saveOutputReturnsOnCall[i] = struct { result1 error }{result1} } func (fake *FakeBuild) Schema() string { fake.schemaMutex.Lock() ret, specificReturn := fake.schemaReturnsOnCall[len(fake.schemaArgsForCall)] fake.schemaArgsForCall = append(fake.schemaArgsForCall, struct { }{}) fake.recordInvocation("Schema", []interface{}{}) fake.schemaMutex.Unlock() if fake.SchemaStub != nil { return fake.SchemaStub() } if specificReturn { return ret.result1 } fakeReturns := fake.schemaReturns return fakeReturns.result1 } func (fake *FakeBuild) SchemaCallCount() int { fake.schemaMutex.RLock() defer fake.schemaMutex.RUnlock() return len(fake.schemaArgsForCall) } func (fake *FakeBuild) SchemaCalls(stub func() string) { fake.schemaMutex.Lock() defer fake.schemaMutex.Unlock() fake.SchemaStub = stub } func (fake *FakeBuild) SchemaReturns(result1 string) { fake.schemaMutex.Lock() defer fake.schemaMutex.Unlock() fake.SchemaStub = nil fake.schemaReturns = struct { result1 string }{result1} } func (fake *FakeBuild) SchemaReturnsOnCall(i int, result1 string) { fake.schemaMutex.Lock() defer fake.schemaMutex.Unlock() fake.SchemaStub = nil if fake.schemaReturnsOnCall == nil { fake.schemaReturnsOnCall = make(map[int]struct { result1 string }) } fake.schemaReturnsOnCall[i] = struct { result1 string }{result1} } func (fake *FakeBuild) SetDrained(arg1 bool) error { fake.setDrainedMutex.Lock() ret, specificReturn := fake.setDrainedReturnsOnCall[len(fake.setDrainedArgsForCall)] fake.setDrainedArgsForCall = append(fake.setDrainedArgsForCall, struct { arg1 bool }{arg1}) fake.recordInvocation("SetDrained", []interface{}{arg1}) fake.setDrainedMutex.Unlock() if fake.SetDrainedStub != nil { return fake.SetDrainedStub(arg1) } if specificReturn { return ret.result1 } fakeReturns := fake.setDrainedReturns return fakeReturns.result1 } func (fake *FakeBuild) SetDrainedCallCount() int { fake.setDrainedMutex.RLock() defer fake.setDrainedMutex.RUnlock() return len(fake.setDrainedArgsForCall) } func (fake *FakeBuild) SetDrainedCalls(stub func(bool) error) { fake.setDrainedMutex.Lock() defer fake.setDrainedMutex.Unlock() fake.SetDrainedStub = stub } func (fake *FakeBuild) SetDrainedArgsForCall(i int) bool { fake.setDrainedMutex.RLock() defer fake.setDrainedMutex.RUnlock() argsForCall := fake.setDrainedArgsForCall[i] return argsForCall.arg1 } func (fake *FakeBuild) SetDrainedReturns(result1 error) { fake.setDrainedMutex.Lock() defer fake.setDrainedMutex.Unlock() fake.SetDrainedStub = nil fake.setDrainedReturns = struct { result1 error }{result1} } func (fake *FakeBuild) SetDrainedReturnsOnCall(i int, result1 error) { fake.setDrainedMutex.Lock() defer fake.setDrainedMutex.Unlock() fake.SetDrainedStub = nil if fake.setDrainedReturnsOnCall == nil { fake.setDrainedReturnsOnCall = make(map[int]struct { result1 error }) } fake.setDrainedReturnsOnCall[i] = struct { result1 error }{result1} } func (fake *FakeBuild) SetInterceptible(arg1 bool) error { fake.setInterceptibleMutex.Lock() ret, specificReturn := fake.setInterceptibleReturnsOnCall[len(fake.setInterceptibleArgsForCall)] fake.setInterceptibleArgsForCall = append(fake.setInterceptibleArgsForCall, struct { arg1 bool }{arg1}) fake.recordInvocation("SetInterceptible", []interface{}{arg1}) fake.setInterceptibleMutex.Unlock() if fake.SetInterceptibleStub != nil { return fake.SetInterceptibleStub(arg1) } if specificReturn { return ret.result1 } fakeReturns := fake.setInterceptibleReturns return fakeReturns.result1 } func (fake *FakeBuild) SetInterceptibleCallCount() int { fake.setInterceptibleMutex.RLock() defer fake.setInterceptibleMutex.RUnlock() return len(fake.setInterceptibleArgsForCall) } func (fake *FakeBuild) SetInterceptibleCalls(stub func(bool) error) { fake.setInterceptibleMutex.Lock() defer fake.setInterceptibleMutex.Unlock() fake.SetInterceptibleStub = stub } func (fake *FakeBuild) SetInterceptibleArgsForCall(i int) bool { fake.setInterceptibleMutex.RLock() defer fake.setInterceptibleMutex.RUnlock() argsForCall := fake.setInterceptibleArgsForCall[i] return argsForCall.arg1 } func (fake *FakeBuild) SetInterceptibleReturns(result1 error) { fake.setInterceptibleMutex.Lock() defer fake.setInterceptibleMutex.Unlock() fake.SetInterceptibleStub = nil fake.setInterceptibleReturns = struct { result1 error }{result1} } func (fake *FakeBuild) SetInterceptibleReturnsOnCall(i int, result1 error) { fake.setInterceptibleMutex.Lock() defer fake.setInterceptibleMutex.Unlock() fake.SetInterceptibleStub = nil if fake.setInterceptibleReturnsOnCall == nil { fake.setInterceptibleReturnsOnCall = make(map[int]struct { result1 error }) } fake.setInterceptibleReturnsOnCall[i] = struct { result1 error }{result1} } func (fake *FakeBuild) Start(arg1 atc.Plan) (bool, error) { fake.startMutex.Lock() ret, specificReturn := fake.startReturnsOnCall[len(fake.startArgsForCall)] fake.startArgsForCall = append(fake.startArgsForCall, struct { arg1 atc.Plan }{arg1}) fake.recordInvocation("Start", []interface{}{arg1}) fake.startMutex.Unlock() if fake.StartStub != nil { return fake.StartStub(arg1) } if specificReturn { return ret.result1, ret.result2 } fakeReturns := fake.startReturns return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeBuild) StartCallCount() int { fake.startMutex.RLock() defer fake.startMutex.RUnlock() return len(fake.startArgsForCall) } func (fake *FakeBuild) StartCalls(stub func(atc.Plan) (bool, error)) { fake.startMutex.Lock() defer fake.startMutex.Unlock() fake.StartStub = stub } func (fake *FakeBuild) StartArgsForCall(i int) atc.Plan { fake.startMutex.RLock() defer fake.startMutex.RUnlock() argsForCall := fake.startArgsForCall[i] return argsForCall.arg1 } func (fake *FakeBuild) StartReturns(result1 bool, result2 error) { fake.startMutex.Lock() defer fake.startMutex.Unlock() fake.StartStub = nil fake.startReturns = struct { result1 bool result2 error }{result1, result2} } func (fake *FakeBuild) StartReturnsOnCall(i int, result1 bool, result2 error) { fake.startMutex.Lock() defer fake.startMutex.Unlock() fake.StartStub = nil if fake.startReturnsOnCall == nil { fake.startReturnsOnCall = make(map[int]struct { result1 bool result2 error }) } fake.startReturnsOnCall[i] = struct { result1 bool result2 error }{result1, result2} } func (fake *FakeBuild) StartTime() time.Time { fake.startTimeMutex.Lock() ret, specificReturn := fake.startTimeReturnsOnCall[len(fake.startTimeArgsForCall)] fake.startTimeArgsForCall = append(fake.startTimeArgsForCall, struct { }{}) fake.recordInvocation("StartTime", []interface{}{}) fake.startTimeMutex.Unlock() if fake.StartTimeStub != nil { return fake.StartTimeStub() } if specificReturn { return ret.result1 } fakeReturns := fake.startTimeReturns return fakeReturns.result1 } func (fake *FakeBuild) StartTimeCallCount() int { fake.startTimeMutex.RLock() defer fake.startTimeMutex.RUnlock() return len(fake.startTimeArgsForCall) } func (fake *FakeBuild) StartTimeCalls(stub func() time.Time) { fake.startTimeMutex.Lock() defer fake.startTimeMutex.Unlock() fake.StartTimeStub = stub } func (fake *FakeBuild) StartTimeReturns(result1 time.Time) { fake.startTimeMutex.Lock() defer fake.startTimeMutex.Unlock() fake.StartTimeStub = nil fake.startTimeReturns = struct { result1 time.Time }{result1} } func (fake *FakeBuild) StartTimeReturnsOnCall(i int, result1 time.Time) { fake.startTimeMutex.Lock() defer fake.startTimeMutex.Unlock() fake.StartTimeStub = nil if fake.startTimeReturnsOnCall == nil { fake.startTimeReturnsOnCall = make(map[int]struct { result1 time.Time }) } fake.startTimeReturnsOnCall[i] = struct { result1 time.Time }{result1} } func (fake *FakeBuild) Status() db.BuildStatus { fake.statusMutex.Lock() ret, specificReturn := fake.statusReturnsOnCall[len(fake.statusArgsForCall)] fake.statusArgsForCall = append(fake.statusArgsForCall, struct { }{}) fake.recordInvocation("Status", []interface{}{}) fake.statusMutex.Unlock() if fake.StatusStub != nil { return fake.StatusStub() } if specificReturn { return ret.result1 } fakeReturns := fake.statusReturns return fakeReturns.result1 } func (fake *FakeBuild) StatusCallCount() int { fake.statusMutex.RLock() defer fake.statusMutex.RUnlock() return len(fake.statusArgsForCall) } func (fake *FakeBuild) StatusCalls(stub func() db.BuildStatus) { fake.statusMutex.Lock() defer fake.statusMutex.Unlock() fake.StatusStub = stub } func (fake *FakeBuild) StatusReturns(result1 db.BuildStatus) { fake.statusMutex.Lock() defer fake.statusMutex.Unlock() fake.StatusStub = nil fake.statusReturns = struct { result1 db.BuildStatus }{result1} } func (fake *FakeBuild) StatusReturnsOnCall(i int, result1 db.BuildStatus) { fake.statusMutex.Lock() defer fake.statusMutex.Unlock() fake.StatusStub = nil if fake.statusReturnsOnCall == nil { fake.statusReturnsOnCall = make(map[int]struct { result1 db.BuildStatus }) } fake.statusReturnsOnCall[i] = struct { result1 db.BuildStatus }{result1} } func (fake *FakeBuild) TeamID() int { fake.teamIDMutex.Lock() ret, specificReturn := fake.teamIDReturnsOnCall[len(fake.teamIDArgsForCall)] fake.teamIDArgsForCall = append(fake.teamIDArgsForCall, struct { }{}) fake.recordInvocation("TeamID", []interface{}{}) fake.teamIDMutex.Unlock() if fake.TeamIDStub != nil { return fake.TeamIDStub() } if specificReturn { return ret.result1 } fakeReturns := fake.teamIDReturns return fakeReturns.result1 } func (fake *FakeBuild) TeamIDCallCount() int { fake.teamIDMutex.RLock() defer fake.teamIDMutex.RUnlock() return len(fake.teamIDArgsForCall) } func (fake *FakeBuild) TeamIDCalls(stub func() int) { fake.teamIDMutex.Lock() defer fake.teamIDMutex.Unlock() fake.TeamIDStub = stub } func (fake *FakeBuild) TeamIDReturns(result1 int) { fake.teamIDMutex.Lock() defer fake.teamIDMutex.Unlock() fake.TeamIDStub = nil fake.teamIDReturns = struct { result1 int }{result1} } func (fake *FakeBuild) TeamIDReturnsOnCall(i int, result1 int) { fake.teamIDMutex.Lock() defer fake.teamIDMutex.Unlock() fake.TeamIDStub = nil if fake.teamIDReturnsOnCall == nil { fake.teamIDReturnsOnCall = make(map[int]struct { result1 int }) } fake.teamIDReturnsOnCall[i] = struct { result1 int }{result1} } func (fake *FakeBuild) TeamName() string { fake.teamNameMutex.Lock() ret, specificReturn := fake.teamNameReturnsOnCall[len(fake.teamNameArgsForCall)] fake.teamNameArgsForCall = append(fake.teamNameArgsForCall, struct { }{}) fake.recordInvocation("TeamName", []interface{}{}) fake.teamNameMutex.Unlock() if fake.TeamNameStub != nil { return fake.TeamNameStub() } if specificReturn { return ret.result1 } fakeReturns := fake.teamNameReturns return fakeReturns.result1 } func (fake *FakeBuild) TeamNameCallCount() int { fake.teamNameMutex.RLock() defer fake.teamNameMutex.RUnlock() return len(fake.teamNameArgsForCall) } func (fake *FakeBuild) TeamNameCalls(stub func() string) { fake.teamNameMutex.Lock() defer fake.teamNameMutex.Unlock() fake.TeamNameStub = stub } func (fake *FakeBuild) TeamNameReturns(result1 string) { fake.teamNameMutex.Lock() defer fake.teamNameMutex.Unlock() fake.TeamNameStub = nil fake.teamNameReturns = struct { result1 string }{result1} } func (fake *FakeBuild) TeamNameReturnsOnCall(i int, result1 string) { fake.teamNameMutex.Lock() defer fake.teamNameMutex.Unlock() fake.TeamNameStub = nil if fake.teamNameReturnsOnCall == nil { fake.teamNameReturnsOnCall = make(map[int]struct { result1 string }) } fake.teamNameReturnsOnCall[i] = struct { result1 string }{result1} } func (fake *FakeBuild) Invocations() map[string][][]interface{} { fake.invocationsMutex.RLock() defer fake.invocationsMutex.RUnlock() fake.abortNotifierMutex.RLock() defer fake.abortNotifierMutex.RUnlock() fake.acquireTrackingLockMutex.RLock() defer fake.acquireTrackingLockMutex.RUnlock() fake.adoptInputsAndPipesMutex.RLock() defer fake.adoptInputsAndPipesMutex.RUnlock() fake.adoptRerunInputsAndPipesMutex.RLock() defer fake.adoptRerunInputsAndPipesMutex.RUnlock() fake.artifactMutex.RLock() defer fake.artifactMutex.RUnlock() fake.artifactsMutex.RLock() defer fake.artifactsMutex.RUnlock() fake.deleteMutex.RLock() defer fake.deleteMutex.RUnlock() fake.endTimeMutex.RLock() defer fake.endTimeMutex.RUnlock() fake.eventsMutex.RLock() defer fake.eventsMutex.RUnlock() fake.finishMutex.RLock() defer fake.finishMutex.RUnlock() fake.hasPlanMutex.RLock() defer fake.hasPlanMutex.RUnlock() fake.iDMutex.RLock() defer fake.iDMutex.RUnlock() fake.inputsReadyMutex.RLock() defer fake.inputsReadyMutex.RUnlock() fake.interceptibleMutex.RLock() defer fake.interceptibleMutex.RUnlock() fake.isAbortedMutex.RLock() defer fake.isAbortedMutex.RUnlock() fake.isCompletedMutex.RLock() defer fake.isCompletedMutex.RUnlock() fake.isDrainedMutex.RLock() defer fake.isDrainedMutex.RUnlock() fake.isManuallyTriggeredMutex.RLock() defer fake.isManuallyTriggeredMutex.RUnlock() fake.isNewerThanLastCheckOfMutex.RLock() defer fake.isNewerThanLastCheckOfMutex.RUnlock() fake.isRunningMutex.RLock() defer fake.isRunningMutex.RUnlock() fake.isScheduledMutex.RLock() defer fake.isScheduledMutex.RUnlock() fake.jobIDMutex.RLock() defer fake.jobIDMutex.RUnlock() fake.jobNameMutex.RLock() defer fake.jobNameMutex.RUnlock() fake.markAsAbortedMutex.RLock() defer fake.markAsAbortedMutex.RUnlock() fake.nameMutex.RLock() defer fake.nameMutex.RUnlock() fake.pipelineMutex.RLock() defer fake.pipelineMutex.RUnlock() fake.pipelineIDMutex.RLock() defer fake.pipelineIDMutex.RUnlock() fake.pipelineNameMutex.RLock() defer fake.pipelineNameMutex.RUnlock() fake.preparationMutex.RLock() defer fake.preparationMutex.RUnlock() fake.privatePlanMutex.RLock() defer fake.privatePlanMutex.RUnlock() fake.publicPlanMutex.RLock() defer fake.publicPlanMutex.RUnlock() fake.reapTimeMutex.RLock() defer fake.reapTimeMutex.RUnlock() fake.reloadMutex.RLock() defer fake.reloadMutex.RUnlock() fake.rerunNumberMutex.RLock() defer fake.rerunNumberMutex.RUnlock() fake.rerunOfMutex.RLock() defer fake.rerunOfMutex.RUnlock() fake.rerunOfNameMutex.RLock() defer fake.rerunOfNameMutex.RUnlock() fake.resourcesMutex.RLock() defer fake.resourcesMutex.RUnlock() fake.resourcesCheckedMutex.RLock() defer fake.resourcesCheckedMutex.RUnlock() fake.saveEventMutex.RLock() defer fake.saveEventMutex.RUnlock() fake.saveImageResourceVersionMutex.RLock() defer fake.saveImageResourceVersionMutex.RUnlock() fake.saveOutputMutex.RLock() defer fake.saveOutputMutex.RUnlock() fake.schemaMutex.RLock() defer fake.schemaMutex.RUnlock() fake.setDrainedMutex.RLock() defer fake.setDrainedMutex.RUnlock() fake.setInterceptibleMutex.RLock() defer fake.setInterceptibleMutex.RUnlock() fake.startMutex.RLock() defer fake.startMutex.RUnlock() fake.startTimeMutex.RLock() defer fake.startTimeMutex.RUnlock() fake.statusMutex.RLock() defer fake.statusMutex.RUnlock() fake.teamIDMutex.RLock() defer fake.teamIDMutex.RUnlock() fake.teamNameMutex.RLock() defer fake.teamNameMutex.RUnlock() copiedInvocations := map[string][][]interface{}{} for key, value := range fake.invocations { copiedInvocations[key] = value } return copiedInvocations } func (fake *FakeBuild) recordInvocation(key string, args []interface{}) { fake.invocationsMutex.Lock() defer fake.invocationsMutex.Unlock() if fake.invocations == nil { fake.invocations = map[string][][]interface{}{} } if fake.invocations[key] == nil { fake.invocations[key] = [][]interface{}{} } fake.invocations[key] = append(fake.invocations[key], args) } var _ db.Build = new(FakeBuild)
defer fake.artifactsMutex.Unlock()
AdafruitDHT.py
#!/usr/bin/python # Copyright (c) 2014 Adafruit Industries # Author: Tony DiCola # 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
# 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. import sys import Adafruit_DHT import time # Parse command line parameters. sensor_args = { '11': Adafruit_DHT.DHT11, '22': Adafruit_DHT.DHT22, '2302': Adafruit_DHT.AM2302 } if len(sys.argv) == 3 and sys.argv[1] in sensor_args: sensor = sensor_args[sys.argv[1]] pin = sys.argv[2] else: print('Usage: sudo ./Adafruit_DHT.py [11|22|2302] <GPIO pin number>') print('Example: sudo ./Adafruit_DHT.py 2302 4 - Read from an AM2302 connected to GPIO pin #4') sys.exit(1) # Try to grab a sensor reading. Use the read_retry method which will retry up # to 15 times to get a sensor reading (waiting 2 seconds between each retry). humidity, temperature = Adafruit_DHT.read_retry(sensor, pin) # Un-comment the line below to convert the temperature to Fahrenheit. # temperature = temperature * 9/5.0 + 32 # Note that sometimes you won't get a reading and # the results will be null (because Linux can't # guarantee the timing of calls to read the sensor). # If this happens try again! while (1): time.sleep(1) humidity, temperature = Adafruit_DHT.read_retry(sensor, pin) if humidity is not None and temperature is not None: print('Temp={0:0.1f}* Humidity={1:0.1f}%'.format(temperature, humidity)) else: print('Failed to get reading. Try again!') sys.exit(1)
# 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
strings.js
/////////////////////////////////////////////////////////////////////////// // Copyright © Esri. All Rights Reserved.
// 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. /////////////////////////////////////////////////////////////////////////// define({ "_widgetLabel": "Parcellaszerkesztő", "newTraverseButtonLabel": "Új sokszögelés indítása", "invalidConfigMsg": "Érvénytelen konfiguráció", "geometryServiceURLNotFoundMSG": "Nem sikerült meghatározni a geometriai adatszolgáltatás URL-címét", "editTraverseButtonLabel": "Sokszögelés szerkesztése", "mapTooltipForStartNewTraverse": "A kezdéshez jelöljön ki egy pontot a térképen vagy lent írja be az értéket", "mapTooltipForEditNewTraverse": "Jelöljön ki egy szerkeszteni kívánt parcellát", "mapTooltipForUpdateStartPoint": "Kattintson a kezdőpont frissítéséhez", "mapTooltipForScreenDigitization": "Kattintson egy parcellapont hozzáadásához", "mapTooltipForUpdatingRotaionPoint": "Kattintson az elforgatási pont frissítéséhez", "mapTooltipForRotate": "Húzza a forgatáshoz", "mapTooltipForScale": "Húzza a méretezéshez", "backButtonTooltip": "Vissza", "newTraverseTitle": "Új sokszögelés", "editTraverseTitle": "Sokszögelés szerkesztése", "clearingDataConfirmationMessage": "A változtatások elvesznek. Biztosan folytatja?", "unableToFetchParcelMessage": "Nem sikerült beolvasni a parcellát.", "unableToFetchParcelLinesMessage": "Nem sikerült beolvasni a parcellavonalakat.", "planSettings": { "planSettingsTitle": "Beállítások", "directionOrAngleTypeLabel": "Irány- vagy szögtípus", "directionOrAngleUnitsLabel": "Irány- vagy szögegységek", "distanceAndLengthUnitsLabel": "Távolság- és hosszmértékegységek", "areaUnitsLabel": "Terület mértékegységek", "circularCurveParameters": "Köríves görbék paraméterei", "northAzimuth": "Északi azimut", "southAzimuth": "Dél azimut", "quadrantBearing": "Irányszög kvadránsok szerint", "radiusAndChordLength": "Sugár- és húrhossz", "radiusAndArcLength": "Sugár- és ívhossz", "expandGridTooltipText": "Rács kibontása", "collapseGridTooltipText": "Rács bezárása", "zoomToLocationTooltipText": "Zoomolás a helyre", "onScreenDigitizationTooltipText": "Digitalizálás", "updateRotationPointTooltipText": "Elforgatási pont frissítése" }, "traverseSettings": { "bearingLabel": "Irányszög", "lengthLabel": "Hossz", "radiusLabel": "Sugár", "noMiscloseCalculated": "Az eltérés nincs kiszámítva", "traverseMiscloseBearing": "Eltérési irányszög", "traverseAccuracy": "Pontosság", "accuracyHigh": "Magas", "traverseDistance": "Eltérés távolsága", "traverseMiscloseRatio": "Eltérési arány", "traverseStatedArea": "Rögzített terület", "traverseCalculatedArea": "Számított terület", "addButtonTitle": "Hozzáadás", "deleteButtonTitle": "Eltávolítás" }, "parcelTools": { "rotationToolLabel": "Szög", "scaleToolLabel": "Méretarány" }, "newTraverse": { "invalidBearingMessage": "Érvénytelen irányszög.", "invalidLengthMessage": "Érvénytelen hossz.", "invalidRadiusMessage": "Érvénytelen sugár.", "negativeLengthMessage": "Csak görbékre érvényes", "enterValidValuesMessage": "Adjon meg érvényes értékeket.", "enterValidParcelInfoMessage": "Adjon meg érvényes parcellaadatokat a mentéshez.", "unableToDrawLineMessage": "Nem sikerült a vonal megrajzolása.", "invalidEndPointMessage": "Érvénytelen végpont, a vonal nem rajzolható meg.", "lineTypeLabel": "Vonaltípus" }, "planInfo": { "requiredText": "(kötelező)", "optionalText": "(opcionális)", "parcelNamePlaceholderText": "Parcella neve", "parcelDocumentTypeText": "Dokumentumtípus", "planNamePlaceholderText": "Terv neve", "cancelButtonLabel": "Mégse", "saveButtonLabel": "Mentés", "saveNonClosedParcelConfirmationMessage": "A megadott parcella nincs lezárva. Ennek ellenére folytatja úgy, hogy csak a parcellavonalakat menti?", "unableToCreatePolygonParcel": "Nem sikerült létrehozni a parcella polygonját.", "unableToSavePolygonParcel": "Nem sikerült menteni a parcella polygonját.", "unableToSaveParcelLines": "Nem sikerült menteni a parcella vonalait.", "unableToUpdateParcelLines": "Nem sikerült frissíteni a parcella vonalait.", "parcelSavedSuccessMessage": "Parcella sikeresen mentve.", "parcelDeletedSuccessMessage": "Telek sikeresen törölve.", "parcelDeleteErrorMessage": "Hiba történt a telek törlésekor.", "enterValidParcelNameMessage": "Adjon meg érvényes nevet a parcellához.", "enterValidPlanNameMessage": "Adjon meg érvényes nevet a tervhez.", "enterValidDocumentTypeMessage": "Érvénytelen dokumentumtípus.", "enterValidStatedAreaNameMessage": "Adjon meg érvényes rögzített területet." }, "xyInput": { "explanation": "Adja meg a koordinátákat a réteggel megegyező térbeli vonatkoztatási rendszerben" } });
// // Licensed under the Apache License Version 2.0 (the 'License'); // you may not use this file except in compliance with the License.
group_extended.rs
use crate::{ opcode::{ execute_cpi_cpd, execute_ini_ind, execute_ldi_ldd, execute_outi_outd, execute_pop_16, BlockDir, Opcode, Prefix, }, smallnum::{U1, U2, U3}, tables::{ lookup16_r12, lookup8_r12, HALF_CARRY_ADD_TABLE, HALF_CARRY_SUB_TABLE, OVERFLOW_ADD_TABLE, OVERFLOW_SUB_TABLE, SZF3F5_TABLE, SZPF3F5_TABLE, }, IntMode, RegName16, RegName8, Z80Bus, FLAG_CARRY, FLAG_PV, FLAG_SUB, FLAG_ZERO, Z80, }; /// Extended instruction group (ED-prefixed) /// (assorted operations) pub fn execute_extended(cpu: &mut Z80, bus: &mut impl Z80Bus, opcode: Opcode) { match opcode.x { U2::N0 | U2::N3 => { bus.process_unknown_opcode(Prefix::ED, opcode); } // --------------------------------- // [0b01yyyzzz] instruction section // --------------------------------- // Assorted operations U2::N1 => { match opcode.z { // IN // [0b01yyy000] : 40 48 50 58 60 68 70 78 U3::N0 => { let reg = RegName8::from_u3(opcode.y); let data = bus.read_io(cpu.regs.get_bc()); if let Some(reg) = reg { cpu.regs.set_reg_8(reg, data); }; let flags = cpu.regs.get_flags() & FLAG_CARRY | SZPF3F5_TABLE[data as usize]; cpu.regs.set_flags(flags); } // OUT // [0b01yyy001] : 41 49 51 59 61 69 71 79 U3::N1 => { let data = match RegName8::from_u3(opcode.y) { Some(reg) => cpu.regs.get_reg_8(reg), None => 0, }; bus.write_io(cpu.regs.get_bc(), data); } // SBC, ADC // [0b0ppq010] U3::N2 => { bus.wait_loop(cpu.regs.get_ir(), 7); let with_carry = (cpu.regs.get_flags() & FLAG_CARRY) != 0; let operand = cpu.regs.get_reg_16(RegName16::from_u2_sp(opcode.p)); let hl = cpu.regs.get_hl(); let mut flags = 0u8; let result = match opcode.q { // SBC HL, rp[p] U1::N0 => { let result = (hl as u32) .wrapping_sub(operand as u32) .wrapping_sub(with_carry as u32); let lookup = lookup16_r12(hl, operand, result as u16); flags |= OVERFLOW_SUB_TABLE[(lookup >> 4) as usize]; flags |= HALF_CARRY_SUB_TABLE[(lookup & 0x07) as usize]; flags |= FLAG_SUB; result } // ADC HL, rp[p] U1::N1 => { let result = (hl as u32) .wrapping_add(operand as u32) .wrapping_add(with_carry as u32); let lookup = lookup16_r12(hl, operand, result as u16); flags |= OVERFLOW_ADD_TABLE[(lookup >> 4) as usize]; flags |= HALF_CARRY_ADD_TABLE[(lookup & 0x07) as usize]; result } }; flags |= (result > 0xFFFF) as u8 * FLAG_CARRY; flags |= SZF3F5_TABLE[((result >> 8) as u8) as usize]; flags &= !FLAG_ZERO; flags |= ((result as u16) == 0) as u8 * FLAG_ZERO; cpu.regs.set_flags(flags); cpu.regs.set_hl(result as u16); // Clocks 4 + 4 + 7 = 15 } // LD U3::N3 => { let addr = cpu.fetch_word(bus, 3); let reg = RegName16::from_u2_sp(opcode.p); match opcode.q { // LD (nn), rp[p] U1::N0 => { bus.write_word(addr, cpu.regs.get_reg_16(reg), 3); } // LD rp[p], (nn) U1::N1 => { cpu.regs.set_reg_16(reg, bus.read_word(addr, 3)); } } } // NEG (A = 0 - A) U3::N4 => { let acc = cpu.regs.get_acc(); let result = 0u8.wrapping_sub(acc); cpu.regs.set_acc(result); let mut flags = FLAG_SUB; flags |= SZF3F5_TABLE[result as usize]; let lookup = lookup8_r12(0, acc, result); flags |= HALF_CARRY_SUB_TABLE[(lookup & 0x07) as usize]; flags |= (acc == 0x80) as u8 * FLAG_PV; flags |= (acc != 0x00) as u8 * FLAG_CARRY; cpu.regs.set_flags(flags); } // RETN, RETI U3::N5 => { // RETN and even RETI should copy iff2 into iff1 let iff2 = cpu.regs.get_iff2(); cpu.regs.set_iff1(iff2); execute_pop_16(cpu, bus, RegName16::PC, 3); if opcode.y == U3::N1 { bus.reti(); } } // IM im[y] U3::N6 => { cpu.int_mode = match opcode.y { U3::N0 | U3::N1 | U3::N4 | U3::N5 => IntMode::Im0, U3::N2 | U3::N6 => IntMode::Im1, U3::N3 | U3::N7 => IntMode::Im2, }; } // Assorted - LD, rotations, nop's U3::N7 => { match opcode.y { // LD I, A U3::N0 => { bus.wait_no_mreq(cpu.regs.get_ir(), 1); let acc = cpu.regs.get_acc(); cpu.regs.set_i(acc); } // LD R, A U3::N1 => { bus.wait_no_mreq(cpu.regs.get_ir(), 1); let acc = cpu.regs.get_acc(); cpu.regs.set_r(acc); } // LD A, I U3::N2 => { bus.wait_no_mreq(cpu.regs.get_ir(), 1); let iff2 = cpu.regs.get_iff2(); let i = cpu.regs.get_i(); cpu.regs.set_acc(i); let mut flags = cpu.regs.get_flags() & FLAG_CARRY; flags |= SZF3F5_TABLE[i as usize]; flags |= iff2 as u8 * FLAG_PV; cpu.regs.set_flags(flags); } // LD A, R U3::N3 => { bus.wait_no_mreq(cpu.regs.get_ir(), 1); let iff2 = cpu.regs.get_iff2(); let r = cpu.regs.get_r(); cpu.regs.set_acc(r); let mut flags = cpu.regs.get_flags() & FLAG_CARRY; flags |= SZF3F5_TABLE[r as usize]; flags |= iff2 as u8 * FLAG_PV; cpu.regs.set_flags(flags); } // RRD U3::N4 => { let mut acc = cpu.regs.get_acc(); let mut mem = bus.read(cpu.regs.get_hl(), 3); // low nibble let mem_lo = mem & 0x0F; // mem_hi to mem_lo and clear hi nibble mem = (mem >> 4) & 0x0F; // acc_lo to mem_hi mem |= (acc << 4) & 0xF0; acc = (acc & 0xF0) | mem_lo; cpu.regs.set_acc(acc); bus.wait_loop(cpu.regs.get_hl(), 4); bus.write(cpu.regs.get_hl(), mem, 3); let mut flags = cpu.regs.get_flags() & FLAG_CARRY; flags |= SZPF3F5_TABLE[acc as usize]; cpu.regs.set_flags(flags); // Clocks: 4 + 4 + 3 + 4 + 3 = 18 } // RLD U3::N5 => { let mut acc = cpu.regs.get_acc(); let mut mem = bus.read(cpu.regs.get_hl(), 3); // low nibble let acc_lo = acc & 0x0F; // mem_hi to acc_lo acc = (acc & 0xF0) | ((mem >> 4) & 0x0F); // mem_lo to mem_hi and tmp to mem_lo mem = ((mem << 4) & 0xF0) | acc_lo; cpu.regs.set_acc(acc); bus.wait_loop(cpu.regs.get_hl(), 4); bus.write(cpu.regs.get_hl(), mem, 3); let mut flags = cpu.regs.get_flags() & FLAG_CARRY; flags |= SZPF3F5_TABLE[acc as usize]; cpu.regs.set_flags(flags); // Clocks: 4 + 4 + 3 + 4 + 3 = 18 } // NOP U3::N6 | U3::N7 => { bus.process_unknown_opcode(Prefix::ED, opcode); } } } } } // --------------------------------- // [0b10yyyzzz] instruction section // --------------------------------- // Block instructions U2::N2 => { match opcode.z { // LD Block group U3::N0 => { match opcode.y { // LDI U3::N4 => execute_ldi_ldd(cpu, bus, BlockDir::Inc), // LDD U3::N5 => execute_ldi_ldd(cpu, bus, BlockDir::Dec), // LDIR U3::N6 => { execute_ldi_ldd(cpu, bus, BlockDir::Inc); if cpu.regs.get_reg_16(RegName16::BC) != 0 { // last DE for wait bus.wait_loop(cpu.regs.get_de().wrapping_sub(1), 5); cpu.regs.dec_pc(); cpu.regs.dec_pc(); }; } // LDDR U3::N7 => { execute_ldi_ldd(cpu, bus, BlockDir::Dec); if cpu.regs.get_reg_16(RegName16::BC) != 0 { // last DE for wait bus.wait_loop(cpu.regs.get_de().wrapping_add(1), 5); cpu.regs.dec_pc(); cpu.regs.dec_pc(); }; } // NOP _ => { bus.process_unknown_opcode(Prefix::ED, opcode); } } } // CP Block group U3::N1 => { match opcode.y { // CPI U3::N4 => { execute_cpi_cpd(cpu, bus, BlockDir::Inc); } // CPD U3::N5 => { execute_cpi_cpd(cpu, bus, BlockDir::Dec); } // CPIR U3::N6 => { let result = execute_cpi_cpd(cpu, bus, BlockDir::Inc); if (cpu.regs.get_reg_16(RegName16::BC) != 0) & (!result) { // last HL bus.wait_loop(cpu.regs.get_hl().wrapping_sub(1), 5); cpu.regs.dec_pc(); cpu.regs.dec_pc(); }; } // CPDR U3::N7 => { let result = execute_cpi_cpd(cpu, bus, BlockDir::Dec); if (cpu.regs.get_reg_16(RegName16::BC) != 0) & (!result) { bus.wait_loop(cpu.regs.get_hl().wrapping_add(1), 5); cpu.regs.dec_pc(); cpu.regs.dec_pc(); }; } // NOP _ => { bus.process_unknown_opcode(Prefix::ED, opcode); } } } // IN Block group U3::N2 => { match opcode.y { // INI U3::N4 => execute_ini_ind(cpu, bus, BlockDir::Inc), // IND U3::N5 => execute_ini_ind(cpu, bus, BlockDir::Dec), // INIR U3::N6 => { execute_ini_ind(cpu, bus, BlockDir::Inc); if cpu.regs.get_reg_8(RegName8::B) != 0 { bus.wait_loop(cpu.regs.get_hl().wrapping_sub(1), 5); cpu.regs.dec_pc(); cpu.regs.dec_pc(); }; } // INDR U3::N7 => { execute_ini_ind(cpu, bus, BlockDir::Dec); if cpu.regs.get_reg_8(RegName8::B) != 0 { bus.wait_loop(cpu.regs.get_hl().wrapping_add(1), 5); cpu.regs.dec_pc(); cpu.regs.dec_pc(); }; } // NOP _ => { bus.process_unknown_opcode(Prefix::ED, opcode); } } } // Out Block group U3::N3 =>
// NOP _ => { bus.process_unknown_opcode(Prefix::ED, opcode); } } } } }
{ match opcode.y { // OUTI U3::N4 => execute_outi_outd(cpu, bus, BlockDir::Inc), // OUTD U3::N5 => execute_outi_outd(cpu, bus, BlockDir::Dec), // OTIR U3::N6 => { execute_outi_outd(cpu, bus, BlockDir::Inc); if cpu.regs.get_reg_8(RegName8::B) != 0 { bus.wait_loop(cpu.regs.get_bc(), 5); cpu.regs.dec_pc(); cpu.regs.dec_pc(); }; } // OTDR U3::N7 => { execute_outi_outd(cpu, bus, BlockDir::Dec); if cpu.regs.get_reg_8(RegName8::B) != 0 { bus.wait_loop(cpu.regs.get_bc(), 5); cpu.regs.dec_pc(); cpu.regs.dec_pc(); }; } // NOP _ => { bus.process_unknown_opcode(Prefix::ED, opcode); } } }
capture.rs
use angular_units::Rad; use nalgebra_glm as glm; use std::ops::{ControlFlow, FromResidual, Try}; #[derive(Debug, PartialEq)] pub enum Capture { Miss, AllowDrag, NoDrag, TakeFocus, Keyboard(KeyCapture), MoveSelectedSquids { delta_in_world: glm::Vec2 }, RotateSelectedSquids { delta_theta: Rad<f32> }, ScaleSelectedSquids { total_scale_factor: f32 }, SpreadSelectedSquids { current: glm::Vec2 }, RevolveSelectedSquids { current: glm::Vec2 }, DilateSelectedSquids { current: glm::Vec2 }, } #[derive(Debug, PartialEq)] pub enum KeyCapture { Capture, Miss, } impl KeyCapture { pub fn to_option(self) -> Option<KeyCapture> { if self != KeyCapture::Miss { Some(self) } else { None } } } impl Try for Capture { type Output = Capture;
#[inline] fn from_output(output: Self::Output) -> Self { output } #[inline] fn branch(self) -> ControlFlow<Self::Residual, Self::Output> { match self { Capture::Miss => ControlFlow::Continue(Capture::Miss), _ => ControlFlow::Break(self), } } } impl FromResidual<Capture> for Capture { #[inline] fn from_residual(residual: Capture) -> Self { residual } }
type Residual = Capture;
action-providers.ts
import * as vscode from "vscode"; import { createSelectionFromVSCode } from "./editor/adapters/vscode-editor"; import { Selection } from "./editor/selection"; import { RefactoringWithActionProvider } from "./types"; import * as t from "./ast"; export { RefactoringActionProvider }; class RefactoringActionProvider implements vscode.CodeActionProvider { private refactorings: RefactoringWithActionProvider[]; constructor(refactorings: RefactoringWithActionProvider[]) { this.refactorings = refactorings; } provideCodeActions( document: vscode.TextDocument, range: vscode.Range | vscode.Selection ): vscode.ProviderResult<vscode.CodeAction[]> { const ast = t.parse(document.getText()); const selection = createSelectionFromVSCode(range); return this.refactorings .filter(refactoring => this.canPerform(refactoring, ast, selection)) .map(refactoring => this.buildCodeActionFor(refactoring)); } private canPerform( refactoring: RefactoringWithActionProvider, ast: t.AST, selection: Selection ) { try { return refactoring.actionProvider.canPerform(ast, selection); } catch (_) { // Silently fail, we don't care why it failed (e.g. code can't be parsed). return false; } } private buildCodeActionFor(refactoring: RefactoringWithActionProvider) { const action = new vscode.CodeAction( `✨ ${refactoring.actionProvider.message}`, vscode.CodeActionKind.RefactorRewrite ); action.isPreferred = refactoring.actionProvider.isPreferred; action.command = { command: `abracadabra.${refactoring.command.key}`, title: refactoring.command.title }; return action;
} }
convert.rs
use crate::errors::*; use crate::row::*; use crate::types::*; use std::convert::{TryFrom, TryInto}; impl TryFrom<BoltType> for f64 { type Error = Error; fn try_from(input: BoltType) -> Result<f64> { match input { BoltType::Float(t) => Ok(t.value), _ => Err(Error::ConverstionError), } } } impl TryFrom<BoltType> for i64 { type Error = Error; fn try_from(input: BoltType) -> Result<i64> { match input { BoltType::Integer(t) => Ok(t.value), _ => Err(Error::ConverstionError), } } } impl TryFrom<BoltType> for bool { type Error = Error; fn try_from(input: BoltType) -> Result<bool> { match input { BoltType::Boolean(t) => Ok(t.value), _ => Err(Error::ConverstionError), } } } impl TryFrom<BoltType> for Point2D { type Error = Error; fn try_from(input: BoltType) -> Result<Point2D> { match input { BoltType::Point2D(p) => Ok(Point2D::new(p)), _ => Err(Error::ConverstionError), } } } impl TryFrom<BoltType> for std::time::Duration { type Error = Error; fn try_from(input: BoltType) -> Result<std::time::Duration> { match input { BoltType::Duration(d) => Ok(d.into()), _ => Err(Error::ConverstionError), } } } impl TryFrom<BoltType> for chrono::NaiveDate { type Error = Error; fn try_from(input: BoltType) -> Result<chrono::NaiveDate> { match input { BoltType::Date(d) => d.try_into(), _ => Err(Error::ConverstionError), } } } impl TryFrom<BoltType> for chrono::DateTime<chrono::FixedOffset> { type Error = Error; fn try_from(input: BoltType) -> Result<chrono::DateTime<chrono::FixedOffset>> { match input { BoltType::DateTime(d) => d.try_into(), _ => Err(Error::ConverstionError), } } } impl TryFrom<BoltType> for chrono::NaiveDateTime { type Error = Error; fn try_from(input: BoltType) -> Result<chrono::NaiveDateTime> { match input { BoltType::LocalDateTime(d) => d.try_into(), _ => Err(Error::ConverstionError), } } } impl TryFrom<BoltType> for (chrono::NaiveTime, Option<chrono::FixedOffset>) { type Error = Error; fn try_from(input: BoltType) -> Result<(chrono::NaiveTime, Option<chrono::FixedOffset>)> { match input { BoltType::Time(bolt_time) => { let (time, offset) = bolt_time.into(); if offset.local_minus_utc() == 0 { Ok((time, None)) } else { Ok((time, Some(offset))) } } BoltType::LocalTime(d) => Ok((d.into(), None)), _ => Err(Error::ConverstionError), } } } impl TryFrom<BoltType> for (chrono::NaiveDateTime, String) { type Error = Error; fn try_from(input: BoltType) -> Result<(chrono::NaiveDateTime, String)> { match input { BoltType::DateTimeZoneId(date_time_zone_id) => date_time_zone_id.try_into(), _ => Err(Error::ConverstionError), } } } impl TryFrom<BoltType> for Vec<u8> { type Error = Error; fn try_from(input: BoltType) -> Result<Vec<u8>> { match input { BoltType::Bytes(b) => Ok(b.value.to_vec()), _ => Err(Error::ConverstionError), } } } impl TryFrom<BoltType> for Point3D { type Error = Error; fn try_from(input: BoltType) -> Result<Point3D> { match input { BoltType::Point3D(p) => Ok(Point3D::new(p)), _ => Err(Error::ConverstionError), } } } impl TryFrom<BoltType> for Node { type Error = Error; fn try_from(input: BoltType) -> Result<Node> { match input { BoltType::Node(n) => Ok(Node::new(n)), _ => Err(Error::ConverstionError), } } } impl TryFrom<BoltType> for Path { type Error = Error; fn try_from(input: BoltType) -> Result<Path> { match input { BoltType::Path(n) => Ok(Path::new(n)), _ => Err(Error::ConverstionError), } } } impl TryFrom<BoltType> for Relation { type Error = Error; fn try_from(input: BoltType) -> Result<Relation> { match input { BoltType::Relation(r) => Ok(Relation::new(r)), _ => Err(Error::ConverstionError), } } } impl TryFrom<BoltType> for UnboundedRelation { type Error = Error; fn try_from(input: BoltType) -> Result<UnboundedRelation> { match input { BoltType::UnboundedRelation(r) => Ok(UnboundedRelation::new(r)), _ => Err(Error::ConverstionError), } } } impl TryFrom<BoltType> for BoltList { type Error = Error; fn try_from(input: BoltType) -> Result<BoltList> { match input { BoltType::List(l) => Ok(l), _ => Err(Error::ConverstionError), } } } impl TryFrom<BoltType> for BoltString { type Error = Error; fn try_from(input: BoltType) -> Result<BoltString> { match input { BoltType::String(s) => Ok(s), _ => Err(Error::ConverstionError), } } } impl TryFrom<BoltType> for String { type Error = Error; fn try_from(input: BoltType) -> Result<String> { match input { BoltType::String(t) => Ok(t.value), _ => Err(Error::ConverstionError), } } } impl Into<BoltType> for std::time::Duration { fn into(self) -> BoltType { BoltType::Duration(self.into()) } } impl Into<BoltType> for chrono::NaiveDate { fn into(self) -> BoltType { BoltType::Date(self.into()) } } impl Into<BoltType> for chrono::NaiveTime { fn into(self) -> BoltType { BoltType::LocalTime(self.into()) } } impl Into<BoltType> for chrono::NaiveDateTime { fn into(self) -> BoltType { BoltType::LocalDateTime(self.into()) } } impl Into<BoltType> for chrono::DateTime<chrono::FixedOffset> { fn into(self) -> BoltType { BoltType::DateTime(self.into()) } } impl Into<BoltType> for (chrono::NaiveTime, chrono::FixedOffset) { fn into(self) -> BoltType { BoltType::Time(self.into()) } } impl Into<BoltType> for (chrono::NaiveDateTime, &str) { fn into(self) -> BoltType { BoltType::DateTimeZoneId(self.into()) } } impl Into<BoltType> for Vec<u8> { fn into(self) -> BoltType { BoltType::Bytes(BoltBytes::new(self.into())) } } impl Into<BoltType> for i64 { fn into(self) -> BoltType { BoltType::Integer(BoltInteger::new(self)) } } impl Into<BoltType> for String { fn into(self) -> BoltType
} impl Into<BoltType> for &str { fn into(self) -> BoltType { BoltType::String(self.into()) } }
{ BoltType::String(self.into()) }
ClampTest.py
########################################################################## # # Copyright (c) 2013-2015, Image Engine Design 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 John Haddon nor the names of # any other contributors to this software 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. # ########################################################################## import unittest import os import IECore import Gaffer import GafferTest import GafferImage import GafferImageTest class ClampTest( GafferImageTest.ImageTestCase ) : def testClamp( self ) : i = GafferImage.ImageReader() i["fileName"].setValue( os.path.expandvars( "$GAFFER_ROOT/python/GafferImageTest/images/colorbars_half_max.exr" ) ) clamp = GafferImage.Clamp() clamp["in"].setInput(i["out"]) clamp["max"].setValue( IECore.Color4f( .5, .5, .5, .5 ) ) self.assertEqual(i['out'].image().hash(), clamp['out'].image().hash()) def
( self ) : i = GafferImage.ImageReader() i["fileName"].setValue( os.path.expandvars( "$GAFFER_ROOT/python/GafferImageTest/images/colorbars_half_max.exr" ) ) clamp = GafferImage.Clamp() clamp["in"].setInput(i["out"]) clamp["max"].setValue( IECore.Color4f( 1., 1., 1., 1. ) ) redHash = clamp["out"].channelDataHash( "R", IECore.V2i( 0 ) ) greenHash = clamp["out"].channelDataHash( "G", IECore.V2i( 0 ) ) blueHash = clamp["out"].channelDataHash( "B", IECore.V2i( 0 ) ) clamp["max"].setValue( IECore.Color4f( .25, 1., 1., 1. ) ) redHash2 = clamp["out"].channelDataHash( "R", IECore.V2i( 0 ) ) greenHash2 = clamp["out"].channelDataHash( "G", IECore.V2i( 0 ) ) blueHash2 = clamp["out"].channelDataHash( "B", IECore.V2i( 0 ) ) self.assertNotEqual(redHash, redHash2) self.assertEqual(greenHash, greenHash2) self.assertEqual(blueHash, blueHash2) def testDisconnectedDirty( self ) : r = GafferImage.ImageReader() r["fileName"].setValue( os.path.expandvars( "$GAFFER_ROOT/python/GafferImageTest/images/colorbars_half_max.exr" ) ) clamp = GafferImage.Clamp() clamp["in"].setInput( r["out"] ) cs = GafferTest.CapturingSlot( clamp.plugDirtiedSignal() ) clamp["max"].setValue( IECore.Color4f( .25, 1., 1., 1. ) ) dirtiedPlugs = set( [ x[0].relativeName( x[0].node() ) for x in cs ] ) expectedPlugs = [ 'out.channelData', 'out' ] for plug in expectedPlugs : self.assertTrue( plug in dirtiedPlugs ) def testClampWithMaxTo( self ) : i = GafferImage.ImageReader() i["fileName"].setValue( os.path.expandvars( "$GAFFER_ROOT/python/GafferImageTest/images/colorbars_max_clamp.exr" ) ) clamp = GafferImage.Clamp() clamp["in"].setInput(i["out"]) clamp["min"].setValue( IECore.Color4f( .0, .0, .0, .0 ) ) clamp["max"].setValue( IECore.Color4f( .0, .25, .25, .25 ) ) clamp["minClampTo"].setValue( IECore.Color4f( .0, .0, .0, .0 ) ) clamp["maxClampTo"].setValue( IECore.Color4f( 1., .5, .25, 1. ) ) clamp["minEnabled"].setValue( True ) clamp["maxEnabled"].setValue( True ) clamp["minClampToEnabled"].setValue( False ) clamp["maxClampToEnabled"].setValue( True ) self.assertEqual(i['out'].image().hash(), clamp['out'].image().hash()) def testDefaultState( self ) : clamp = GafferImage.Clamp() self.assertTrue( clamp['minEnabled'].getValue() ) self.assertTrue( clamp['maxEnabled'].getValue() ) self.assertFalse( clamp['minClampToEnabled'].getValue() ) self.assertFalse( clamp['maxClampToEnabled'].getValue() ) def testEnabledBypass( self ) : i = GafferImage.ImageReader() i["fileName"].setValue( os.path.expandvars( "$GAFFER_ROOT/python/GafferImageTest/images/colorbars_half_max.exr" ) ) clamp = GafferImage.Clamp() clamp["in"].setInput(i["out"]) clamp["minEnabled"].setValue( False ) clamp["maxEnabled"].setValue( False ) self.assertEqual( i["out"].imageHash(), clamp["out"].imageHash() ) self.assertEqual( i["out"]["format"].hash(), clamp["out"]["format"].hash() ) self.assertEqual( i["out"]["dataWindow"].hash(), clamp["out"]["dataWindow"].hash() ) self.assertEqual( i["out"]["channelNames"].hash(), clamp["out"]["channelNames"].hash() ) def testEnableBehaviour( self ) : clamp = GafferImage.Clamp() self.assertTrue( clamp.enabledPlug().isSame( clamp["enabled"] ) ) self.assertTrue( clamp.correspondingInput( clamp["out"] ).isSame( clamp["in"] ) ) self.assertEqual( clamp.correspondingInput( clamp["in"] ), None ) self.assertEqual( clamp.correspondingInput( clamp["enabled"] ), None ) self.assertEqual( clamp.correspondingInput( clamp["min"] ), None ) def testPassThrough( self ) : i = GafferImage.ImageReader() i["fileName"].setValue( os.path.expandvars( "$GAFFER_ROOT/python/GafferImageTest/images/colorbars_half_max.exr" ) ) c = GafferImage.Clamp() c["in"].setInput( i["out"] ) c["max"].setValue( IECore.Color4f( .5, .5, .5, .5 ) ) self.assertEqual( i["out"]["format"].hash(), c["out"]["format"].hash() ) self.assertEqual( i["out"]["dataWindow"].hash(), c["out"]["dataWindow"].hash() ) self.assertEqual( i["out"]["metadata"].hash(), c["out"]["metadata"].hash() ) self.assertEqual( i["out"]["channelNames"].hash(), c["out"]["channelNames"].hash() ) self.assertEqual( i["out"]["format"].getValue(), c["out"]["format"].getValue() ) self.assertEqual( i["out"]["dataWindow"].getValue(), c["out"]["dataWindow"].getValue() ) self.assertEqual( i["out"]["metadata"].getValue(), c["out"]["metadata"].getValue() ) self.assertEqual( i["out"]["channelNames"].getValue(), c["out"]["channelNames"].getValue() ) if __name__ == "__main__": unittest.main()
testPerChannelHash
crawler.py
# -*- coding: utf-8 -*- """\ This is a python port of "Goose" orignialy licensed to Gravity.com under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. Python port was written by Xavier Grangier for Recrutae Gravity.com licenses this file to you 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. """ import os import glob from copy import deepcopy import dateutil.parser from dateutil.tz import tzutc from goose3.article import Article from goose3.utils import URLHelper, RawHelper from goose3.text import get_encodings_from_content from goose3.extractors.content import StandardContentExtractor from goose3.extractors.videos import VideoExtractor from goose3.extractors.title import TitleExtractor from goose3.extractors.images import ImageExtractor from goose3.extractors.links import LinksExtractor from goose3.extractors.tweets import TweetsExtractor from goose3.extractors.authors import AuthorsExtractor from goose3.extractors.tags import TagsExtractor from goose3.extractors.opengraph import OpenGraphExtractor from goose3.extractors.publishdate import PublishDateExtractor from goose3.extractors.schema import SchemaExtractor from goose3.extractors.metas import MetasExtractor from goose3.cleaners import StandardDocumentCleaner from goose3.outputformatters import StandardOutputFormatter from goose3.network import NetworkFetcher class CrawlCandidate(object): def __init__(self, config, url, raw_html): self.config = config # parser self.parser = self.config.get_parser() self.url = url self.raw_html = raw_html class Crawler(object): def __init__(self, config, fetcher=None): # config self.config = config # parser self.parser = self.config.get_parser() # article self.article = Article() # init the extractor self.extractor = self.get_extractor() # init the document cleaner self.cleaner = self.get_cleaner() # init the output formatter self.formatter = self.get_formatter() # metas extractor self.metas_extractor = self.get_metas_extractor() # opengraph extractor self.opengraph_extractor = self.get_opengraph_extractor() # schema.org news article extractor self.schema_extractor = self.get_schema_extractor() # publishdate extractor self.publishdate_extractor = self.get_publishdate_extractor() # tags extractor self.tags_extractor = self.get_tags_extractor() # authors extractor self.authors_extractor = self.get_authors_extractor() # tweets extractor self.tweets_extractor = self.get_tweets_extractor() # links extractor self.links_extractor = self.get_links_extractor() # video extractor self.video_extractor = self.get_video_extractor() # title extractor self.title_extractor = self.get_title_extractor() # html fetcher if isinstance(fetcher, NetworkFetcher): self.fetcher = fetcher else: self.fetcher = NetworkFetcher(self.config) # image extractor self.image_extractor = self.get_image_extractor() # TODO: use the log prefix self.log_prefix = "crawler: " def crawl(self, crawl_candidate): # parser candidate parse_candidate = self.get_parse_candidate(crawl_candidate) # raw html raw_html = self.get_html(crawl_candidate, parse_candidate) if raw_html is None: return self.article return self.process(raw_html, parse_candidate.url, parse_candidate.link_hash) def process(self, raw_html, final_url, link_hash): #remove footnotes raw_html_no_footnotes = self.formatter.remove_footnotes(raw_html) # create document doc = self.get_document(raw_html_no_footnotes) # article self.article._final_url = final_url self.article._link_hash = link_hash self.article._raw_html = raw_html_no_footnotes self.article._doc = doc self.article._raw_doc = deepcopy(doc) # open graph self.article._opengraph = self.opengraph_extractor.extract() # schema.org: # - (ReportageNewsArticle) https://pending.schema.org/ReportageNewsArticle # - (NewsArticle) https://schema.org/NewsArticle # - (Article) https://schema.org/Article self.article._schema = self.schema_extractor.extract() if not self.article._final_url: if "url" in self.article.opengraph: self.article._final_url = self.article.opengraph["url"] elif self.article.schema and "url" in self.article.schema: self.article._final_url = self.article.schema["url"] # meta metas = self.metas_extractor.extract() # print(metas) self.article._meta_lang = metas['lang'] self.article._meta_favicon = metas['favicon'] self.article._meta_description = metas['description'] self.article._meta_keywords = metas['keywords'] self.article._meta_encoding = metas['encoding'] self.article._canonical_link = metas['canonical'] self.article._domain = metas['domain'] # publishdate self.article._publish_date = self.publishdate_extractor.extract() if self.article.publish_date: try: publish_datetime = dateutil.parser.parse(self.article.publish_date) if publish_datetime.tzinfo: self.article._publish_datetime_utc = publish_datetime.astimezone(tzutc()) else: self.article._publish_datetime_utc = publish_datetime except (ValueError, OverflowError): self.article._publish_datetime_utc = None # tags self.article._tags = self.tags_extractor.extract() # authors self.article._authors = self.authors_extractor.extract() # title self.article._title = self.title_extractor.extract() # check for known node as content body # if we find one force the article.doc to be the found node # this will prevent the cleaner to remove unwanted text content article_body = self.extractor.get_known_article_tags() if article_body is not None: doc = article_body # before we do any calcs on the body itself let's clean up the document if not isinstance(doc, list): doc = [self.cleaner.clean(doc)] else: doc = [self.cleaner.clean(deepcopy(x)) for x in doc] # big stuff self.article._top_node = self.extractor.calculate_best_node(doc) # if we do not find an article within the discovered possible article nodes, # try again with the root node. if self.article._top_node is None: # try again with the root node. self.article._top_node = self.extractor.calculate_best_node(self.article._doc) else: # set the doc member to the discovered article node. self.article._doc = doc # if we have a top node # let's process it if self.article._top_node is not None: # article links self.article._links = self.links_extractor.extract() # tweets self.article._tweets = self.tweets_extractor.extract() # video handling self.article._movies = self.video_extractor.get_videos() # image handling if self.config.enable_image_fetching: self.get_image() # post cleanup self.article._top_node = self.extractor.post_cleanup() # clean_text self.article._cleaned_text = self.formatter.get_formatted_text() # cleanup tmp file self.release_resources() # return the article return self.article @staticmethod def get_parse_candidate(crawl_candidate): if crawl_candidate.raw_html: return RawHelper.get_parsing_candidate(crawl_candidate.url, crawl_candidate.raw_html) return URLHelper.get_parsing_candidate(crawl_candidate.url) def get_image(self):
def get_html(self, crawl_candidate, parsing_candidate): # we got a raw_tml # no need to fetch remote content if crawl_candidate.raw_html: return crawl_candidate.raw_html # fetch HTML response = self.fetcher.fetch_obj(parsing_candidate.url) if response.encoding != 'ISO-8859-1': # requests has a good idea; use what it says # return response as a unicode string html = response.text self.article._meta_encoding = response.encoding else: html = response.content encodings = get_encodings_from_content(response.text) if len(encodings) > 0: self.article._meta_encoding = encodings[0] response.encoding = encodings[0] html = response.text else: self.article._meta_encoding = encodings return html def get_metas_extractor(self): return MetasExtractor(self.config, self.article) def get_publishdate_extractor(self): return PublishDateExtractor(self.config, self.article) def get_opengraph_extractor(self): return OpenGraphExtractor(self.config, self.article) def get_schema_extractor(self): return SchemaExtractor(self.config, self.article) def get_tags_extractor(self): return TagsExtractor(self.config, self.article) def get_authors_extractor(self): return AuthorsExtractor(self.config, self.article) def get_tweets_extractor(self): return TweetsExtractor(self.config, self.article) def get_links_extractor(self): return LinksExtractor(self.config, self.article) def get_title_extractor(self): return TitleExtractor(self.config, self.article) def get_image_extractor(self): return ImageExtractor(self.fetcher, self.config, self.article) def get_video_extractor(self): return VideoExtractor(self.config, self.article) def get_formatter(self): return StandardOutputFormatter(self.config, self.article) def get_cleaner(self): return StandardDocumentCleaner(self.config, self.article) def get_document(self, raw_html): doc = self.parser.fromstring(raw_html) return doc def get_extractor(self): return StandardContentExtractor(self.config, self.article) def release_resources(self): path = os.path.join(self.config.local_storage_path, '%s_*' % self.article.link_hash) for fname in glob.glob(path): try: os.remove(fname) except OSError: # TODO: better log handeling pass
doc = self.article.raw_doc top_node = self.article.top_node self.article._top_image = self.image_extractor.get_best_image(doc, top_node)
pin.py
"""Tegra T186 pin names""" import atexit import Jetson.GPIO as GPIO GPIO.setmode(GPIO.TEGRA_SOC) GPIO.setwarnings(False) # shh! class Pin:
# Cannot be used as GPIO SDA = Pin("GPIO_SEN9") SCL = Pin("GPIO_SEN8") SDA_1 = Pin("GEN1_I2C_SDA") SCL_1 = Pin("GEN1_I2C_SCL") # Jetson TX2 specific J06 = Pin("GPIO_AUD1") AA02 = Pin("CAN_GPIO2") N06 = Pin("GPIO_CAM7") N04 = Pin("GPIO_CAM5") N05 = Pin("GPIO_CAM6") N03 = Pin("GPIO_CAM4") AA01 = Pin("CAN_GPIO1") I05 = Pin("GPIO_PQ5") T03 = Pin("UART1_CTS") T02 = Pin("UART1_RTS") P17 = Pin("GPIO_EXP_P17") AA00 = Pin("CAN0_GPIO0") Y01 = Pin("GPIO_MDM2") P16 = Pin("GPIO_EXP_P16") I04 = Pin("GPIO_PQ4") J05 = Pin("GPIO_AUD0") # Jetson TX2 NX specific W04 = Pin("UART3_RTS") V01 = Pin("GPIO_SEN1") C02 = Pin("DAP2_DOUT") C03 = Pin("DAP2_DIN") V04 = Pin("GPIO_SEN4") H02 = Pin("GPIO_WAN7") H01 = Pin("GPIO_WAN6") V02 = Pin("GPIO_SEN2") H00 = Pin("GPIO_WAN5") H03 = Pin("GPIO_WAN8") Y03 = Pin("GPIO_MDM4") N01 = Pin("GPIO_CAM2") EE02 = Pin("TOUCH_CLK") U00 = Pin("GPIO_DIS0") U05 = Pin("GPIO_DIS5") W05 = Pin("UART3_CTS") V03 = Pin("GPIO_SEN3") # Shared pin J03 = Pin("DAP1_FS") J02 = Pin("DAP1_DIN") J01 = Pin("DAP1_DOUT") J00 = Pin("DAP1_SCLK") J04 = Pin("AUD_MCLK") i2cPorts = ( (1, SCL, SDA), (0, SCL_1, SDA_1), ) # ordered as spiId, sckId, mosiId, misoId spiPorts = ((3, N03, N05, N04),)
"""Pins dont exist in CPython so...lets make our own!""" IN = 0 OUT = 1 LOW = 0 HIGH = 1 PULL_NONE = 0 PULL_UP = 1 PULL_DOWN = 2 id = None _value = LOW _mode = IN def __init__(self, bcm_number): self.id = bcm_number def __repr__(self): return str(self.id) def __eq__(self, other): return self.id == other def init(self, mode=IN, pull=None): """Initialize the Pin""" if mode is not None: if mode == self.IN: self._mode = self.IN GPIO.setup(self.id, GPIO.IN) elif mode == self.OUT: self._mode = self.OUT GPIO.setup(self.id, GPIO.OUT) else: raise RuntimeError("Invalid mode for pin: %s" % self.id) if pull is not None: if self._mode != self.IN: raise RuntimeError("Cannot set pull resistor on output") if pull == self.PULL_UP: GPIO.setup(self.id, GPIO.IN, pull_up_down=GPIO.PUD_UP) elif pull == self.PULL_DOWN: GPIO.setup(self.id, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) else: raise RuntimeError("Invalid pull for pin: %s" % self.id) def value(self, val=None): """Set or return the Pin Value""" if val is not None: if val == self.LOW: self._value = val GPIO.output(self.id, val) return None if val == self.HIGH: self._value = val GPIO.output(self.id, val) return None raise RuntimeError("Invalid value for pin") return GPIO.input(self.id) # pylint: disable=no-method-argument @atexit.register def cleanup(): """Clean up pins""" print("Exiting... \nCleaning up pins") GPIO.cleanup() # pylint: enable=no-method-argument
protected_vm_types.go
/* Copyright AppsCode Inc. and Contributors 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. */ // Code generated by Kubeform. DO NOT EDIT. package v1alpha1 import ( base "kubeform.dev/apimachinery/api/v1alpha1" core "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" kmapi "kmodules.xyz/client-go/api/v1" "sigs.k8s.io/cli-utils/pkg/kstatus/status" ) // +genclient // +k8s:openapi-gen=true // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +kubebuilder:object:root=true // +kubebuilder:subresource:status // +kubebuilder:printcolumn:name="Phase",type=string,JSONPath=`.status.phase` type ProtectedVm struct { metav1.TypeMeta `json:",inline,omitempty"` metav1.ObjectMeta `json:"metadata,omitempty"` Spec ProtectedVmSpec `json:"spec,omitempty"` Status ProtectedVmStatus `json:"status,omitempty"` } type ProtectedVmSpec struct { State *ProtectedVmSpecResource `json:"state,omitempty" tf:"-"` Resource ProtectedVmSpecResource `json:"resource" tf:"resource"` UpdatePolicy base.UpdatePolicy `json:"updatePolicy,omitempty" tf:"-"` TerminationPolicy base.TerminationPolicy `json:"terminationPolicy,omitempty" tf:"-"` ProviderRef core.LocalObjectReference `json:"providerRef" tf:"-"` BackendRef *core.LocalObjectReference `json:"backendRef,omitempty" tf:"-"` } type ProtectedVmSpecResource struct { Timeouts *base.ResourceTimeout `json:"timeouts,omitempty" tf:"timeouts"` ID string `json:"id,omitempty" tf:"id,omitempty"` BackupPolicyID *string `json:"backupPolicyID" tf:"backup_policy_id"` RecoveryVaultName *string `json:"recoveryVaultName" tf:"recovery_vault_name"` ResourceGroupName *string `json:"resourceGroupName" tf:"resource_group_name"` SourceVmID *string `json:"sourceVmID" tf:"source_vm_id"` // +optional Tags *map[string]string `json:"tags,omitempty" tf:"tags"` } type ProtectedVmStatus struct { // Resource generation, which is updated on mutation by the API Server. // +optional ObservedGeneration int64 `json:"observedGeneration,omitempty"` // +optional Phase status.Status `json:"phase,omitempty"` // +optional Conditions []kmapi.Condition `json:"conditions,omitempty"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +kubebuilder:object:root=true // ProtectedVmList is a list of ProtectedVms type ProtectedVmList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` // Items is a list of ProtectedVm CRD objects Items []ProtectedVm `json:"items,omitempty"`
}
lyrics.py
from telethon import events import asyncio from PyLyrics import * from __main__ import client from constants import Config CMD_PREFIX = Config.CMD_PREFIX @client.on(events.NewMessage(outgoing=True, pattern=CMD_PREFIX + "lyrics (.*)")) async def _(event):
if event.fwd_from: return i = 0 input_str = event.pattern_match.group(1) try: song = input_str.split("-") if len(song) == 1: CMD = CMD_PREFIX[1:] await event.edit(f"Usage: {CMD}lyrics Duman - Haberin Yok Ölüyorum") else: await event.edit("🔍︎Searching lyrics") lyrics = PyLyrics.getLyrics(song[0].strip(), song[1].strip()).split("\n") lyric_message = f"Singing {song[0].strip()} from {song[1].strip()} 🎙" lyric_message += "\n\n" + "\n".join(lyrics) try: await event.edit(lyric_message) except: # TODO: send as file await event.edit('ERRRO') except ValueError: await event.edit("Song not found")
hdfs.py
import locale import os import platform import uuid from contextlib import contextmanager import pytest from dvc.path_info import URLInfo from .base import Base class HDFS(Base, URLInfo): # pylint: disable=abstract-method @contextmanager def _hdfs(self): import pyarrow conn = pyarrow.hdfs.connect(self.host, self.port) try: yield conn finally: conn.close() def is_file(self): with self._hdfs() as _hdfs: return _hdfs.isfile(self.path) def is_dir(self): with self._hdfs() as _hdfs: return _hdfs.isfile(self.path) def exists(self): with self._hdfs() as _hdfs: return _hdfs.exists(self.path) def mkdir(self, mode=0o777, parents=False, exist_ok=False): assert mode == 0o777 assert parents assert not exist_ok with self._hdfs() as _hdfs: # NOTE: hdfs.mkdir always creates parents _hdfs.mkdir(self.path) def write_bytes(self, contents):
def write_text(self, contents, encoding=None, errors=None): if not encoding: encoding = locale.getpreferredencoding(False) assert errors is None self.write_bytes(contents.encode(encoding)) def read_bytes(self): with self._hdfs() as _hdfs: # NOTE: hdfs.open only supports 'rb', 'wb' or 'ab' with _hdfs.open(self.path, "rb") as fobj: return fobj.read() def read_text(self, encoding=None, errors=None): if not encoding: encoding = locale.getpreferredencoding(False) assert errors is None return self.read_bytes().decode(encoding) @pytest.fixture(scope="session") def hadoop(): import wget import tarfile from appdirs import user_cache_dir if platform.system() != "Linux": pytest.skip("only supported on Linux") hadoop_name = "hadoop-2.7.2.tar.gz" java_name = "openjdk-7u75-b13-linux-x64-18_dec_2014.tar.gz" base_url = "https://s3-us-east-2.amazonaws.com/dvc-public/dvc-test/" hadoop_url = base_url + hadoop_name java_url = base_url + java_name (cache_dir,) = (user_cache_dir("dvc-test", "iterative"),) dname = os.path.join(cache_dir, "hdfs") java_tar = os.path.join(dname, java_name) hadoop_tar = os.path.join(dname, hadoop_name) java_home = os.path.join(dname, "java-se-7u75-ri") hadoop_home = os.path.join(dname, "hadoop-2.7.2") def _get(url, tar, target): if os.path.isdir(target): return if not os.path.exists(tar): wget.download(url, out=tar) tar = tarfile.open(tar) tar.extractall(dname) assert os.path.isdir(target) os.makedirs(dname, exist_ok=True) _get(hadoop_url, hadoop_tar, hadoop_home) _get(java_url, java_tar, java_home) os.environ["JAVA_HOME"] = java_home os.environ["HADOOP_HOME"] = hadoop_home os.environ["PATH"] += f":{hadoop_home}/bin:{hadoop_home}/sbin" @pytest.fixture(scope="session") def hdfs_server(hadoop, docker_compose, docker_services): import pyarrow port = docker_services.port_for("hdfs", 8020) def _check(): try: # NOTE: just connecting or even opening something is not enough, # we need to make sure that we are able to write something. conn = pyarrow.hdfs.connect("127.0.0.1", port) try: with conn.open(str(uuid.uuid4()), "wb") as fobj: fobj.write(b"test") finally: conn.close() return True except (pyarrow.ArrowException, OSError): return False docker_services.wait_until_responsive(timeout=30.0, pause=5, check=_check) return port @pytest.fixture def hdfs(hdfs_server): port = hdfs_server url = f"hdfs://127.0.0.1:{port}/{uuid.uuid4()}" yield HDFS(url)
with self._hdfs() as _hdfs: # NOTE: hdfs.open only supports 'rb', 'wb' or 'ab' with _hdfs.open(self.path, "wb") as fobj: fobj.write(contents)
PasswordFieldRenderer.js
/*! * UI development toolkit for HTML5 (OpenUI5) * (c) Copyright 2009-2015 SAP SE or an SAP affiliate company.
* Licensed under the Apache License, Version 2.0 - see LICENSE.txt. */ sap.ui.define(['jquery.sap.global','./TextFieldRenderer'],function(q,T){"use strict";var P=sap.ui.core.Renderer.extend(T);P.renderInnerAttributes=function(r,p){if(sap.ui.Device.support.input.placeholder||p.getValue()||!p.getPlaceholder()){r.writeAttribute('type','password');}};P.renderTextFieldEnabled=function(r,p){if(!p.getEnabled()&&!p.getEditable()){r.writeAttribute('readonly','readonly');r.writeAttribute('tabindex','-1');}else{r.writeAttribute('tabindex','0');}};P.setEnabled=function(p,e){var t=p.getDomRef();if(e){if(p.getEditable()){q(t).removeClass('sapUiTfDsbl').addClass('sapUiTfStd');q(t).removeAttr('readonly').attr('tabindex','0');}else{q(t).removeClass('sapUiTfDsbl').addClass('sapUiTfRo');q(t).attr('tabindex','0');}}else{if(p.getEditable()){q(t).removeClass('sapUiTfStd').addClass('sapUiTfDsbl');q(t).attr('readonly','readonly').attr('tabindex','-1');}else{q(t).removeClass('sapUiTfRo').addClass('sapUiTfDsbl');q(t).attr('tabindex','-1');}}};return P;},true);
rpmcheck.py
# vim: set ts=4 sw=4 et: coding=UTF-8 from .rpmsection import Section class RpmCheck(Section): """ A class providing methods for %check section cleaning. Replace various troublemakers in check phase. """ def add(self, line: str) -> None: line = self._complete_cleanup(line) # smp_mflags for jobs macro replacement line = self.reg.re_jobs.sub('%{?_smp_mflags}', line) if not self.minimal: line = self._add_jobs(line) line = self._replace_pytest(line) Section.add(self, line) def _add_jobs(self, line: str) -> str: """ Add %{?_smp_mflags} to 'make' call. Args: line: A string representing a line to process. Return: The processed line. """ # add jobs if we have just make call on line # if user want single thread he should specify -j1 if self.reg.re_make.match(line): # if there are no smp_flags or jobs spec if line.find('%{?_smp_mflags}') == -1 and line.find('-j') == -1: # Don't append %_smp_mflags if the line ends with a backslash, # it would break the formatting if not line.endswith('\\') and not line.lstrip().startswith('#'): line = self.reg.re_make.sub(r'\1make %{?_smp_mflags}\2', line) return line def
(self, line: str) -> str: """ Replace various pytest calls with %pytest or %pytest_arch macros. Args: line: A string representing a line to process. Return: The processed line. """ line = self.reg.re_pytest.sub('%pytest', line) line = self.reg.re_pytest_arch.sub('%pytest_arch', line) return line
_replace_pytest
init.rs
///init the root_user extern crate db; use db::models::*; use db::schema::*; use db::DbConnecting; extern crate md5; fn insert_root_user() -> ()
fn insert_root_cat() -> () { let conn = DbConnecting::establish_connection(); let root_cat = NewCategory { super_id: None, cat_name: "Default Category".to_string(), }; diesel::insert_into(categories::table) .values(&root_cat) .get_result::<Category>(&conn) .expect("Error saving new Category"); println!("init inserted: Category"); } fn insert_root_article() -> () { let conn = DbConnecting::establish_connection(); let user = users::table .filter(users::user_email.eq("[email protected]")) .first::<User>(&conn) .expect("Error loading users"); let cat = categories::table .filter(categories::cat_name.eq("Default Category")) .first::<Category>(&conn) .expect("Error loading Category"); let root_article = NewArticle { user_id: user.id, category_id: cat.id, title: "Hello World !".to_string(), content: "This is the first blog".to_string(), release_status: 100i16, }; diesel::insert_into(articles::table) .values(&root_article) .get_result::<Article>(&conn) .expect("Error saving new Article"); println!("init inserted: Article"); } fn main() { let conn = DbConnecting::establish_connection(); let res_vec = users::table .filter(users::user_email.eq("[email protected]")) .limit(1) .load::<User>(&conn) .expect("Error loading users"); if res_vec.len() < 1 { insert_root_user(); } else { println!("Root user has been added"); }; let cat_vec = categories::table .filter(categories::cat_name.eq("Default Category")) .limit(1) .load::<Category>(&conn) .expect("Error loading Category"); if cat_vec.len() < 1 { insert_root_cat(); } else { println!("Root Category has been added"); println!("{:?}", cat_vec); }; let res_vec = articles::table .filter(articles::title.eq("Hello World !")) .limit(1) .load::<Article>(&conn) .expect("Error loading Article"); if res_vec.len() < 1 { insert_root_article(); } else { println!("First Article has been added"); // println!("{:?}", res_vec); }; }
{ let conn = DbConnecting::establish_connection(); let pass = "000".to_string(); let pass = format!("{:x}", md5::compute(pass.as_bytes())); let salt = "792316348".to_string(); let pass_word = format!("{}{}", pass, salt); let pass_word = format!("{:x}", md5::compute(pass_word.as_bytes())); let root_user = NewUser { user_email: "[email protected]".to_string(), pass_word: pass_word, salt: salt, nick_name: "nick_name".to_string(), role_level: 9999i16, }; diesel::insert_into(users::table) .values(&root_user) .get_result::<User>(&conn) .expect("Error saving new user"); println!("init inserted: User"); }
remote_port_forwarding.rs
/* cargo run -p async-ssh2-lite-demo-smol --bin remote_port_forwarding 127.0.0.1:22 root 8101 */ use std::env; use std::io; use std::net::{TcpStream, ToSocketAddrs}; use std::str; use async_io::Async; use futures::executor::block_on; use futures::{AsyncReadExt, AsyncWriteExt}; use async_ssh2_lite::AsyncSession; fn main() -> io::Result<()> { block_on(run()) } async fn run() -> io::Result<()>
{ let addr = env::args() .nth(1) .unwrap_or_else(|| env::var("ADDR").unwrap_or("127.0.0.1:22".to_owned())); let username = env::args() .nth(2) .unwrap_or_else(|| env::var("USERNAME").unwrap_or("root".to_owned())); let remote_port: u16 = env::args() .nth(3) .unwrap_or_else(|| env::var("REMOTE_PORT").unwrap_or("0".to_owned())) .parse() .unwrap(); let addr = addr.to_socket_addrs().unwrap().next().unwrap(); let stream = Async::<TcpStream>::connect(addr).await?; let mut session = AsyncSession::new(stream, None)?; session.handshake().await?; session.userauth_agent(username.as_ref()).await?; if !session.authenticated() { return Err(session .last_error() .and_then(|err| Some(io::Error::from(err))) .unwrap_or(io::Error::new( io::ErrorKind::Other, "unknown userauth error", ))); } let (mut listener, remote_port) = session .channel_forward_listen(remote_port, Some("127.0.0.1"), None) .await?; println!("run `netstat -tunlp | grep {}` in ssh server", remote_port); println!( "run `curl http://127.0.0.1:{}/ -v` in ssh server", remote_port ); loop { match listener.accept().await { Ok(mut channel) => { let mut buf = vec![0; 64]; channel.read(&mut buf).await?; println!("channel receive {:?}", str::from_utf8(&buf)); if buf.starts_with(b"GET / HTTP/1.1\r\n") { channel.write_all(b"HTTP/1.1 200 OK\r\n\r\n").await?; } else { channel .write_all(b"HTTP/1.1 400 Bad Request\r\n\r\n") .await?; break; } } Err(err) => { eprintln!("accept failed, error: {:?}", err); } } } println!("done"); Ok(()) }
sync.py
def btSync(display, utime, ujson, bluetooth, startNewThread, playBuzzer, loadJSON, saveJSON, showControls, update, clear):
run = True toDo = loadJSON("to-do.json") toDoList = list(toDo.keys()) toDoDone = False shoppingItems = loadJSON("boodschappen.json") shoppingItemsList = list(shoppingItems.keys()) shoppingItemsDone = False index = 0 utime.sleep(0.5)#Sleep cause else it exits the app cnt = 0 btData = "" while run: clear() #Get and format Bluetooth data if not toDoDone or not shoppingItemsDone: try: btData += bluetooth.read().decode("utf-8") if btData[0] == "[" and btData[-1] == "]": print("valid data") btData = ujson.loads(btData) for i in range(1, len(btData)): btData[i] = ujson.loads(btData[i]) print(btData) if btData[0] == "to-do" and not toDoDone and len(btData) > 1: print("TODO") newDict = {} for i in range(1, len(btData)): newDict[btData[i]["name"]] = "x" if btData[i]["isComplete"] else " " saveJSON("to-do.json", newDict) toDoDone = True print(newDict) elif btData[0] == "boodschappen" and not shoppingItemsDone and len(btData) > 1: newDict = {} for i in range(1, len(btData)): newDict[btData[i]["name"]] = "x" if btData[i]["checked"] else " " saveJSON("boodschappen.json", newDict) shoppingItemsDone = True print(newDict) else: print("INVALID_DATA") bluetooth.write("INVALID_DATA") except: pass #Draw the app showControls(display.get_width(), display.get_height(), "esc", " ", " ", " ") if toDoDone and shoppingItemsDone: display.text("Sync: Klaar!", 20, display.get_height()//2 - 10, 500, 3) if cnt == 10: bluetooth.write("ALL_DONE") if cnt > 100: cnt = 0 elif cnt < 60: display.text("Sync: ." , 20, display.get_height()//2 - 10, 500, 3) elif cnt < 120: display.text("Sync: ..", 20, display.get_height()//2 - 10, 500, 3) elif cnt < 180: display.text("Sync: ...", 20, display.get_height()//2 - 10, 500, 3) else: cnt = 0 if toDoDone and shoppingItemsDone: pass elif toDoDone: bluetooth.write("BOODSCHAPPEN") else: bluetooth.write("TO-DO") pass print("WORKING") #<- remove this later fag btData = "" cnt += 1 #App Controls buttonPressed = False while display.is_pressed(display.BUTTON_X): if not buttonPressed: startNewThread(playBuzzer) buttonPressed = True while display.is_pressed(display.BUTTON_Y): if not buttonPressed: startNewThread(playBuzzer) buttonPressed = True while display.is_pressed(display.BUTTON_A): if not buttonPressed: startNewThread(playBuzzer) run = False buttonPressed = True while display.is_pressed(display.BUTTON_B): if not buttonPressed: startNewThread(playBuzzer) buttonPressed = True buttonPressed = False update()
filter.go
package __ComplexType import . "_ImportLocation" func Filter(slice []_ComplexType, fn func(_ComplexType,int)bool) (res []_ComplexType) { res = make([]_ComplexType, 0, len(slice)) for index, entry := range slice { if fn(entry, index)
} return } func (c *chain) Filter(fn func(_ComplexType,int)bool) *chain { return &chain{value: Filter(c.value, fn)} }
{ res = append(res, entry) }